Left 4 Dead 2

Left 4 Dead 2

Staggering Melee Specials
ChimiChamo 31 Oct, 2023 @ 1:49pm
A more compatible version of the script
Having made this I realise that me giving advice on how to code probably isn't the best idea but whatever. Here's a fixed version that fixes several errors and allows for compatibility with other scripts:

StaggeringSpecials <- { function OnGameEvent_player_hurt(params) { if("attackerentid" in params && "type" in params && "userid" in params && "attacker" in params && "weapon" in params) { if(params.type != DMG_POISON) { if(EntIndexToHScript(params.attackerentid).IsPlayer()) { local infected = GetPlayerFromUserID(params.attacker) local survivor = GetPlayerFromUserID(params.userid) local damagetype = params.weapon if(infected.GetZombieType() <= 6 && survivor.IsSurvivor()) { if(!survivor.IsDominatedBySpecialInfected() && damagetype != "insect_swarm") { survivor.Stagger(infected.GetOrigin()) } } } } } } } __CollectEventCallbacks(StaggeringSpecials, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener)
< >
Showing 1-4 of 4 comments
Interneted  [developer] 1 Nov, 2023 @ 2:28am 
I knew it! So putting it in a table and call the event to the director table fixes it afterall, it just that I haven't tested it yet.

Anyways I was just wondering on the purpose of checking if the string keys exist on the game event params table and the next 2 if statements? I don't think it is needed, unless you got some explanation about it, newbie here.

For anyone wondering why do I include every single non boss SI, I got issues on my sanity.

Help.

Jokes aside, I will add a configurable settings later after I dive into more built in functions that I am unaware in the future.
Last edited by Interneted; 1 Nov, 2023 @ 2:29am
R󠀡F 1 Nov, 2023 @ 3:00am 
Yeah you need to put game events into a isolated section or else other scripts wont be able to use those events.
ChimiChamo 1 Nov, 2023 @ 8:58am 
I suppose I should have added comments to it. We check for all the stuff in params so we know that we have all the things we call functions on. For example in the current version of your script, if a common infected damages you, the common has GetZombieType() called on it. The entity doesn’t support that function so there’s an error. The next if statement is just a check for whether the damagetype isn’t the one used when you’re bleeding out when incapped since that caused an error. The next one is probably done incorrectly but that’s just how I do things. It just checks whether the attacker’s entity id is one of a player, so the rest of the stuff doesn’t call on a common infected for example.
Interneted  [developer] 1 Nov, 2023 @ 7:42pm 
Omg, totally forgot about the incapacitation damage and other stuff, oh well, thanks @RF, @ChimiChamo!

So uh, any plans on updating your shove tanks add-on and others?
Last edited by Interneted; 1 Nov, 2023 @ 10:40pm
< >
Showing 1-4 of 4 comments
Per page: 1530 50