Skip to content
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

Closed

Conversation

mugg91
Copy link
Contributor

@mugg91 mugg91 commented May 4, 2022

Status

  • READY: this PR is (to the best of your knowledge) ready to be incorporated into the game.

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)

  • Mounted Bow doesn't fall through small gaps anymore. Since player can attach himself to it, the player could also fall through the gap with it, causing unwanted behavior or wall clipping. This was done by changing verticesXY.
  • Bomber and Airship now show health bar. Instead of decaying if an enemy is near, it can be converted to the enemy now. As for the health bar, I think all big vehicles should show it.
  • Mounted Bow/Catapult/Ballista no longer look bugged when they were attached to Bomber/Airship/Warship and then changing facing direction. Mounted Bow had this problem even when not attached.
  • Mounted Bow can now always be detached from another vehicle. It was not possible before. The Mounted Bow on Warboat is unaffected and cannot be detached.
  • Catapult and Ballista can now be detached if the other vehicle is either "touching ground" or "not touching ground but not touching water either". Therefore, Catapult and Ballista cannot be detached from a Warboat that is riding on water without ground. But it can be detached from Airship and Bomber as long as they are not in water. I think this feels the most practical. But of course feel free to say if you have a different opinion.
  • Mounted Bow doesn't fall through doors, platforms, etc.
  • All vehicles' ammo counts are no longer hidden in single player.
  • Mounted Bow can be picked up and thereby be converted to your team. Mounted Bow that has been there from the start cannot be picked up and will stay neutral and stationary, possible to be used by all teams.

Steps to Test or Reproduce

  • Place a small gap and !mounted_bow. Notice it doesn't fall into the gap anymore.
  • !bomber and !airship. Notice they don't get destroyed if you go away. Notice they have health bar.
    !team 1 , notice they can be converted to Red Team.
  • Go to Save the Princess, !tradingpost, !coins, buy a Mounted Bow. Shooting diagonally with it. Detach yourself and pick it up. Face the other direction. Alternatively, you can load it on a Catapult and ride the other direction. Notice it doesn't look bugged anymore.
  • Go to Sandbox, !catapult, !bomber. The Catapult should be attached to the Bomber. Get seated in the Bomber and make it face the other direction. Notice the Catapult doesn't look bugged anymore.
  • !bomber (or !airship or !warboat), !mounted_bow. Notice if you show buttons, there is a "Detach" button.
  • !bomber, !catapult. Use the bomber to fly. Notice you can "Detach" the Catapult while in the air.
  • Go to Save the Princess, !tradingpost, !coins, buy a Mounted Bow. !tent, change class to builder, !wood, build some doors and platforms. Throw the Mounted Bow into the doors and platforms. Notice that it collides with them now.
  • Go to Save the Princess, !tradingpost, !coins, buy a Mounted Bow. Throw it away. !team 1. Notice that it will get converted to Red Team if you pick it up. If you go to Sandbox, /loadmap "Biurza_Black_Dog", you can notice that the Mounted Bow in the middle does not get converted to any team when attaching yourself to it.
  • Go to any single player mode and use a catapult or a mounted bow. Notice that they show the ammo count now.

mugg91 added 10 commits May 4, 2022 18:18
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.
@mugg91
Copy link
Contributor Author

mugg91 commented May 8, 2022

While trying to fix "Mounted Bow on Catapult bug", I found this:

  1. Catapult.as detaches the MountedBow upon use. Near line 474:

this.server_DetachFrom(blobInMag);

  1. In MountedBow.as OnCommand(), blob will be an arrow when used in any other circumstance but will be set to catapult's id when it is loaded on the Catapult.
    params.read_netid() will somehow return the catapult's id.
    I'm not sure if I will be able to fix this but I will keep trying.

mugg91 added 5 commits May 8, 2022 12:51
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.
@mugg91
Copy link
Contributor Author

mugg91 commented May 8, 2022

I'm done with this PR, so setting this to "READY". I was not able to fix these two issues, though:

@mugg91
Copy link
Contributor Author

mugg91 commented May 28, 2022

I added another change.
When a vehicle is converted from your team to enemy team, you will be detached from it or let go of it.

Reproduction Steps:

  • Be on Blue Team and hold a Blue Dinghy.
  • Go to two Red Builders, crouch, wait for your Blue Dinghy to be converted to Red.
  • Instead of holding a Red Dinghy, it will be detached from you.

  • Be on Blue Team and sit in a Blue Catapult.
  • Have two Red Builders nearby so your Catapult is converted from Blue to Red.
  • Instead of sitting in a Red Catapult, you will be detached from it.

  • Be on Blue Team and sit in a Blue Whatever.
  • !team 1
  • You will be detached.

@mugg91 mugg91 mentioned this pull request May 28, 2022
mugg91 added 2 commits May 28, 2022 13:57
You can attach yourself to neutral mounted bow, neutral catapult, etc.
Copy link
Member

@eps0003 eps0003 left a 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.

Entities/Common/Scripts/SetTeamToCarrier.as Outdated Show resolved Hide resolved
Entities/Structures/MountedBow/MountedBow.cfg Outdated Show resolved Hide resolved
Comment on lines 575 to 576
&& (this.getTeamNum() >= 0 && this.getTeamNum() <= 7)
&& (occupied.getName() == "knight" || occupied.getName() == "archer" || occupied.getName() == "builder")))
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

@mugg91 mugg91 Jun 5, 2022

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?

Copy link
Member

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.

Copy link
Contributor Author

@mugg91 mugg91 Jun 5, 2022

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).

Copy link
Member

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.

Copy link
Contributor Author

@mugg91 mugg91 Jun 5, 2022

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()?

Copy link
Member

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.

Copy link
Contributor Author

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.

Entities/Structures/MountedBow/MountedBow.cfg Outdated Show resolved Hide resolved
Entities/Vehicles/Common/VehicleCommon.as Outdated Show resolved Hide resolved
Entities/Structures/MountedBow/MountedBow.as Outdated Show resolved Hide resolved
mugg91 added 3 commits June 1, 2022 19:17
- 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.
@mugg91
Copy link
Contributor Author

mugg91 commented Jun 4, 2022

Fixed some vehicle conversion bugs:

  • Bow on Warboat will get converted along with the Warboat now.
  • When a vehicle which is attached to a carrier vehicle gets converted, it will detach now instead of erroneously converting the carrier vehicle.

@mugg91 mugg91 closed this Jun 6, 2022
@mugg91 mugg91 reopened this Jun 6, 2022
@mugg91
Copy link
Contributor Author

mugg91 commented Jun 6, 2022

The merge commit and the closing/re-opening of this PR are misclicks, please do not mind.
The thing to note is commit 6dfb653.

  • Added TeamChecking.as.
    This was done because there are too many inconsistent checks and eps0003 urged me to find better ways of checking teams.
    Treat 0-254 as player teams and 255 as neutral team.
    This was done in this PR because a lot of team checking was already done here.
    The functions in TeamChecking.as are shared because HallCommon.as calls from it in a shared function, otherwise it would cause an error when loading a new map with a Hall in it.
  • Storage: Can be used if it is in your team or in team 255.
  • Hall: Minimap icon differentiates between team 0-254 and 255 instead of 0-9 and 10-254.
  • Hall: Only show buttons when the hall is yours and you are nearby.
  • Hall: Migrants converted to your team will receive your color.
  • Vehicles: Don't receive coins for damaging or destroying vehicles in team 255.
  • Vehicles: Can sit in, ammo-load, item-load, detach, look in inventory of, flip vehicles in your team or in team 255.
  • Tent: Can change class if tent is in team 255.
    (I made a different PR which deals with resupplies from enemy structures here. Maybe worth considering to let neutral bases give resupplies.)
  • Longboat: Removed DecayIfLeftAlone.as (It makes no sense that it could be converted but also get auto-destroyed when only the enemy is there)
  • Red Barrier: Only team 255 can pass, instead of teams 100-255.

@mugg91
Copy link
Contributor Author

mugg91 commented Jun 7, 2022

Ok, I may have gone a little overboard with this latest team checking commit.
But I hope you understand why I did it.
I guess it makes more sense to split it into its own PR.
I just had figured, it may save trouble down the line to reduce workload of whoever has to merge all these things later.
Let me know what should be done.

@Vam-Jam
Copy link
Member

Vam-Jam commented Nov 28, 2024

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.

@mugg91
Copy link
Contributor Author

mugg91 commented Nov 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants