Author Topic: Player damage & NPCs + Teams  (Read 7762 times)

0 Members and 1 Guest are viewing this topic.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Player damage & NPCs + Teams
« on: March 01, 2015, 02:15:30 PM »
Guys, I know the answer to this one is going to be a facepalm moment for me...

If I spawn a typical zombie (npc_zombie or npc_fastzombie) it will do damage during its attacks when players are not assigned to teams.  The moment I assign teams, the zombies still attempt to attack, but no damage is dealt. Example:

In JailBreak, players are assigned to Team 1 or Team 2 (prisoners/guards)
If I spawn a zombie in (manually or through ulx maul) it doesn't do damage despite its efforts to attack  (eventually ulx maul will kill the player because it has a failsafe built in, but thats moot).
*IF* I modify the JailBreak code to assign the player to Team 0 (which of course breaks much of JailBreak's gameplay), zombies then do damage as expected  (like they do in non-Team gamemodes like base or sandbox).

What am I missing here? I don't think it's a relationship issue, since ulx maul very specifically sets the relationship.  I tried putting breadcrumbs in PlayerShouldTakeDamage both in Jailbreak and in base and I see no activity.

Thanks (again!)
Mike

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player damage & NPCs + Teams
« Reply #1 on: March 01, 2015, 02:47:15 PM »
Without looking at the entire gamemode code, my guess is that there's specific code somewhere to only allow team damage from opposing teams. (Obvious, yes, I know you're likely asking 'where')
At first thought, yes, I'd think that should be in PlayerTakeDamage. But, I could also see perhaps other checks used. Primary and or Secondary attack perhaps.
Does Jailbreak allow damage any other way but by the other team? (fall damage, vehicle?, prop?)
Anything in 'any' PlayerTakeDamage hook that does team comparisons?

When the wolves get spawned, are they assigned a team by the gamemode? (my guess is no of course)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #2 on: March 01, 2015, 06:18:09 PM »
Thanks.  I'd gone through as many hooks and overrides as I could find that seemed relevant, but of course I could have (and likely have) missed something. Will look again.

No team assignment to the NPC's as far as I can see, especially since ULX's own maul command is suffering the same issue (and why I felt like I could sneak the question in here, even though it's not really a ULX issue).

What's more, strider and headcrab damage works as expected, so I'm not sure if there's a common base class for zombies that is the issue, or perhaps slash damage (versus bullet, poison, etc). 

Thanks,
Mike

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player damage & NPCs + Teams
« Reply #3 on: March 01, 2015, 08:08:01 PM »
Wow, so, headcrabs, striders and other creatures cause damage but wolves do not. And, you've tried spawning using non-ulx spawned wolves I take it.
There are class commands in Gmod now, (You may know that, but I just stumbled across it while searching your issue in the Gmod wiki) I'd dig into class assignment checks too.
And, for your information, Dev corner is for more than just ULX/Lua coding questions.
Though it's intended for focus on our projects of course, we do like to exercise our brains outside of Team Ulysses projects.

(Oh, and for fun searches through code like this, I use a Windows 'grep' like tool. If you're not on linux, search out "dngrep". I like it much better than Windows search)

Does jailbreak allow team killing? If not, it's own protection scheme may be preventing wolves from hurting. Perhaps see if you can find that mechanism.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #4 on: March 01, 2015, 11:11:12 PM »
Just FYI -- it's zombies (ie, npc_zombie and npc_fastzombie, though there may be others) that are the issue.  Wolves seem to have crept in -- just wanted to clarify.  :)

Most everything I do server-wise for gmod is in linux, so yes -- grep and I are good friends.  :)  JB does have its own protection scheme baked into PlayerShouldTakeDamage. I've put breadcrumb statements in before any of the logic (as well as turning the logic on and off) and none of my zombie attacks ever make it that far.  And these are overrides too -- not hooks,

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #5 on: March 02, 2015, 05:50:46 AM »
For what it's worth, I'm starting to think the issue is around the handling of slash damage.  The only other NPC that seems to have this issue is the antlion. Everything else I've tried (combine NPCs, hostile rebels, manhacks, anything poison based, etc) all work.

Doesn't help me much at the moment, since I see nothing in the way of slash damage being handled differently -- it's gotta be somewhere though.


Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #6 on: March 02, 2015, 06:11:33 AM »
Never mind, false lead. Manhacks are DMG_SLASH as well, and they work fine.  So to recap:

* Player Team = 1 (or 2, or any non zero #), npc_zombie, npc_fastzombie and npc_antlion attack but do not register damage.   JB.Gamemode.PlayerShouldTakeDamage override is never called.  JB.Gamemode.EntityTakeDamage override is never called.  My own hook to EntityTakeDamage is never called.    All other npcs work fine (calls are made as expected and damage registers as expected)
* Player Team = 0, all npc's including zombie and antlion work fine, including all expected calls.


Argh.


Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #7 on: March 02, 2015, 07:15:17 AM »
Sorry for the spam.  Final update for a while.

It has nothing to do with Jailbreak.  If I set a team in Sandbox directly in PlayerInitialSpawn after the call to base, I get the same problem.  This is the only change I made (didn't even have to set up teams or set GM.TeamBased).  Just changing the player's team causes zombie damage to not register.

Code: [Select]
function GM:PlayerInitialSpawn( ply )
BaseClass.PlayerInitialSpawn( self, ply )
ply:SetTeam(1)
end

I've looked through npc_BaseZombie.cpp and didn't see anything jump out at me regarding zombie behavior against a teammember.  At least I now know it's not the gamemode itself.

EDIT:  It also has nothing to do with zombies.  :)  It's the NPC melee weapon logic.  I dropped some unarmed combine soldiers in and their roundhouse elbows are exhibiting the same problem as the zombie slashes. (I didn't realize this earlier, as my previous experiments with soldiers were at a distance, so they used their ranged weapons, not melee weapons).

« Last Edit: March 02, 2015, 10:28:24 AM by Buzzkill-THABB »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player damage & NPCs + Teams
« Reply #8 on: March 02, 2015, 07:40:51 PM »
I'd now be reaching far outside my educated hypotheses guesses.
Bug in team vs slash damage code in Gmod.
I'd dare say, if you haven't already, bring this up at Facepunch.
Our small community can only test it so far. (And, how would one go about submitting a real bug to Gmod devs? WeBrett emailed Garry one time and he responded, but, I doubt that would ever happen again)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Player damage & NPCs + Teams
« Reply #9 on: March 02, 2015, 08:26:51 PM »
I'd now be reaching far outside my educated hypotheses guesses.
Bug in team vs slash damage code in Gmod.
I'd dare say, if you haven't already, bring this up at Facepunch.
Our small community can only test it so far. (And, how would one go about submitting a real bug to Gmod devs? WeBrett emailed Garry one time and he responded, but, I doubt that would ever happen again)
This seems to be the place for (confirmed) issues.
bw81@ulysses-forums ~ % whoami
Homepage

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #10 on: March 03, 2015, 06:15:57 AM »
Thanks guys.  I always assume it's *not* a bug and that I'm just doing something wrong, but if it walks, talks and acts like a bug, well...   :)

I did post to the FP forums, but no response yet.  I've opened a new issue on the Github project.  Thanks again.

Mike

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player damage & NPCs + Teams
« Reply #11 on: March 03, 2015, 03:58:41 PM »
This goes without saying, but, I'd make sure you have a 100% vanilla server before expecting too much.
We did mention/discuss other damage questions in another thread. Basically, make sure you don't have your own various parts/lua code running around that may be doing odd funky things)
(Or, heck, 'ours', but, I wouldn't think so)

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Player damage & NPCs + Teams
« Reply #12 on: March 03, 2015, 07:13:34 PM »
RB concluded that it was most likely a bug (or undocumented behavior) on Github.  Looks like Team IDs 1-4 exhibit this issue, but anything higher works correctly. 

Thanks again.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player damage & NPCs + Teams
« Reply #13 on: March 03, 2015, 07:40:05 PM »
Good find. I'm always impressed when a member of our community finds a true bug undocumented/unintended feature. :)
For reference of those monitoring this thread and the particular bug, the original report and issue track link here -
https://github.com/Facepunch/garrysmod-issues/issues/1820
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming