Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Changes from 18 commits
4d43c33
5548506
4bbf8e8
21e9b5c
3297992
b1c5556
b2946bc
6d2e468
8368219
e589e59
8e8899f
11b1fce
cdb12e8
0c193f0
a0096c3
7ba4929
ea21584
ab67c23
c0171e4
83d3f73
f319f22
20f42b4
6dfb653
b5de4d3
c0f8761
130db67
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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.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.
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. WillgetRules().getSpectatorTeamNum()
always return -1? Can the Map loader callgetRules().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.