-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mounted Bow and other vehicle changes #1251
Mounted Bow and other vehicle changes #1251
Conversation
Player should not be able to fall through a small gap by attaching himself to a mounted bow falling into it.
To make it more consistent. Other vehicles can be detached so why not the bow too?
Bigger vehicles should show health bar. Make it not decay when no teammate is there. Make it possible to convert to other teams.
Make it show health bar like all bigger vehicles should. Make it not decay when no teammate is around. Make it possible to convert to other teams.
This makes it so that catapult/ballista can only be detached when the warboat/airship/bomber touches land or floats but touches no water (good for airships). Vehicles cannot be detached from a warboat that isn't touching land. Mounted Bow can always be detached regardless the situation, though.
This makes it so the mounted bow doesn't look buggy when it was turned around. onTick() (and with it all angle corrections) will run when the bow is being used or when it is held by player/vehicle.
Now it adjusts the angle only the first 30 ticks, when attaching yourself to the Bow and when the Bow changes direction. Works with multiple Bows on the map.
Fixes Catapult looking bugged when a it was attached to Bomber/Airship/Warship and changing direction. I removed the had_attached logic to adjust angle 1 tick after someone detaches, because I didn't see any side-effect after removing it. If there exist side-effects, please let me know, then I will add it back.
Fixed Ballista looking bugged when attached to Bomber/Airship/Warship and changing direction.
While trying to fix "Mounted Bow on Catapult bug", I found this:
|
Removed "CollidesOnlyWithLarger.as" so Mounted Bow can have collision with most tiles such as doors, platforms, etc.
Avoids collision with player.
v.infinite_ammo suggests that the player has infinite ammo, but in reality it was just not getting displayed and the player had the same ammo as normal. Therefore, removing this for now.
Allows grabbing and stealing mounted bows from other team.
Stuff only gets converted to your team if you carry it, not when you attach yourself to it. This prevents that stationary Mounted Bow (upon map loading) in gets converted when you attach yourself to it, blocking the other team from getting it.
I'm done with this PR, so setting this to "READY". I was not able to fix these two issues, though:
|
I added another change. Reproduction Steps:
|
You can attach yourself to neutral mounted bow, neutral catapult, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful with the extra whitespace you're accidentally adding in random places.
&& (this.getTeamNum() >= 0 && this.getTeamNum() <= 7) | ||
&& (occupied.getName() == "knight" || occupied.getName() == "archer" || occupied.getName() == "builder"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two checks are not good. You shouldn't be hardcoding team numbers and classes like this since it won't work with mods that add more teams or new classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"knight", "archer" and "builder is hard coded in a lot more places.
The ItemLimits script I made will also check for team number like this.
How to avoid this?
Although neutral blobs are usually set to -1 or 255, you can change to teams 8~254 via !team (number)
in Sandbox. Is there a way to check if a blob is in grey team that doesn't involve checking team number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"knight", "archer" and "builder is hard coded in a lot more places.
How to avoid this?
You should always endeavour to leave code in a better state than you found it. A potential solution would be to check for "player"
tag, but migrants also have this tag which could cause rare side effects.
Although neutral blobs are usually set to -1 or 255, you can change to teams 8~254 via !team (number) in Sandbox. Is there a way to check if a blob is in grey team that doesn't involve checking team number?
There is nothing special with grey teams. They are only grey because there aren't enough colours to cover all team numbers. The only team that should be treated differently from the rest is spectator team (getRules().getSpectatorTeamNum()
). -1 == 255 because team is u8 which wraps negative numbers around to the maximum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change to occupied.hasTag("player")
. I don't see a problem since migrants are never attached to vehicles. It would seem there are already several such checks in the same file, anyway.
With the team check, this kind of check is in many places. I guess teams 0-254 should be treated as player teams and team 255 as a neutral team for animals and stuff that can be used by anyone (vehicles, doors).
I have seen places where the team check says "anything that is higher than team 100" or "anything that is higher than team 10". Those checks seem arbitrary and inconsistent. Up until now, I tried to be a more precise by handling teams 0-7 as player teams, because they are colored, and anything else as neutral team.
I can change that so that 0-254 are player teams instead. And 255 is a neutral team.
Is that what should be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change that so that 0-254 are player teams instead. And 255 is a neutral team. Is that what should be done?
Yes, this sounds like the most appropriate way of dealing with teams. Please remember to check for getRules().getSpectatorTeamNum()
rather than specifically team 255.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if it was unclear. I was not talking about spectator team.
I'm still talking about teams that are currently on the field playing. Of those, 0 to 254 should be handled as teams that players could get assigned to. Players can also get assigned to team 255, but behavior will be different. I'd like to make it so that blobs in team 255 can be used by anyone (except for special cases like when trampolines are loaded with the map, they can't be used by anyone).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold up... why is there even a team or player check here? If the blob is already sitting on the vehicle, they must've been the correct team to get on it in the first place. And there is no need to check if it's a player since non-player blobs will never be pressing key_up
to get out. Even if they somehow did, there is no harm in allowing them to detach from the vehicle like players do.
Looking at SeatHop.as line 32, there already appears to be a check to allow neutral teams to sit in vehicles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is so that when you are sitting in your vehicle and it is getting converted to the enemy, you are kicked out.
The player check is so that enemy crates and enemy Dinghies can be loaded/can stay in the catapult's mag.
I'm not working on "neutral players doing stuff" but I'm working on "any players using neutral stuff".
About getRules().getSpectatorTeamNum()
, I can use it, but the Map loader will set blobs to -1 so I'm afraid of mismatch errors. Will getRules().getSpectatorTeamNum()
always return -1? Can the Map loader call getRules().getSpectatorTeamNum()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Team is a u8
which means -1 wraps around to 255 (the maximum). getRules().getSpectatorTeamNum()
returns 255 so it should match correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Sandbox mode, getRules().getSpectatorTeamNum()
returns 200 for me.
I'm reworking team checks and adding another commit later.
- When Warboat gets converted, its Bow will get converted, too. - When a vehicle gets converted it will detach from its carrier vehicle instead of converting its carrier vehicle. - Fix indents in code.
Fixed some vehicle conversion bugs:
|
The merge commit and the closing/re-opening of this PR are misclicks, please do not mind.
|
Ok, I may have gone a little overboard with this latest team checking commit. |
I'm going to close this PR as there's a lot of merge issues + It's a big PR that tries to do too much. I would suggest you split it up into separate PR's. E.g. Vehicles into a vehicle PR, 255 team changes into a 255 team pr etc. |
I opened separate issues for each problem, except things related to team checking. |
Status
Listing (Includes all commits)
[changed] Mounted Bow cannot fall through small gaps anymore.
[changed] Mounted Bow can now collide with platforms, doors, etc. but not with larger blobs.
[changed] Mounted Bow bought from Trader now can be converted by picking it up.
[changed] Airship and Bomber now show healthbar, can be converted and don't decay if left alone.
[changed] Mounted Bow which is attached to another vehicle can now always be detached via button.
[changed] Catapult and Ballista which is attached to another vehicle can now be detached if touching ground or when airborne.
[changed] Vehicles' ammo counter is not hidden in single player anymore.
[changed] You will detach from or let go of vehicles that aren't from your team.
[fixed] Mounted Bow doesn't look bugged when facing the other direction.
[fixed] Vehicles attached to other vehicles don't look bugged when facing the other direction.
[fixed] Bow on Warboat now gets converted along with the Warboat.
[fixed] Converting a Vehicle that is attached to another vehicle will detach instead of converting the other vehicle.
Team Checking Commit:
[changed] You can use Storage and Saw if it is in team 255.
[changed] You can change class at Tent from team 255.
[changed] Longboat doesn't Decay if left alone.
[changed] You can interact with vehicles if they are in team 255.
[fixed] Inconsistent team checking in Hall.as, HallCommon.as, MigrantBrain.as, SeatHop.as, SeatsGUI.as, VehicleConvert.as, RedBarrier.as.
[fixed] That Migrants converted to your team didn't receive your color.
TODO:
[Still unfixed...] Gunner in non-neutral team shooting from a neutral vehicle will cause damage to the vehicle.
Fixed in a different PR:
[fixed] Shooting from a Mounted Bow that is in a Catapult's mag will cause the Catapult to fly away. - #1311
[fixed] Mounted Bow shows a wrong "load item" button after it was put in a Catapult's mag. - #1311
Description (Only initial commits shown)
Steps to Test or Reproduce
!team 1 , notice they can be converted to Red Team.