Game Modding | Call of Duty: Black Ops 3 | Scripting
ModmeBot:
Thread By: eDeK How i detect a "hit" of zombie?
My idea is "when i get a hit by a zombie, i lose a perk/money".
This function can help me? I think is something similar ("damage", amount, attacker, dir, point, mod ") but im lost.
ModmeBot:
Reply By: mathfag
Haven't tested this. No idea if it will work. Don't even know if waittill damage is a thing for players.
ModmeBot:
Reply By: ihmiskeho
mathfag callback::on_spawned( &playerHurtcheck ); //in main function playerHurtcheck() //self = player { self endon("noHealthOverlay"); self.hurtAgain = false; for ( ;; ) { self waittill( "damage", amount, attacker, dir, point, mod ); if(isdefined(attacker) && attacker.team = level.zombie_team) { //if it was a zombie do something here self zm_score::minus_to_player_score(2000); } self.hurtAgain = true; self.damagePoint = point; self.damageAttacker = attacker; //idk what you're trying to do here } } Haven't tested this. No idea if it will work. Don't even know if waittill damage is a thing for players.
The function he had is from _zm_playerhealth.gsc so waittill damage is for players also.
For perk losing:
If you want the player to lose a random perk, use something like this:
ModmeBot:
Reply By: eDeK I delete this line:
and is work well now, but i lose perks/money with any damage (grenades, wunderwaffe, etc, ...) thanks for reply/help.
ModmeBot:
Reply By: ihmiskeho
eDeK I delete this line: if(isdefined(attacker) && attacker.team = level.zombie_team) and is work well now, but i lose perks/money with any damage (grenades, wunderwaffe, etc, ...) thanks for reply/help.
Because when you remove that line it doesn't check if the damage was done by an attacker, it just checks if you've been damaged.
This was tested and it works:
ModmeBot:
Reply By: eDeK Works perfect your script, the problem is im doing probably something wrong with the perks.
Compiler Internal Error : Uninitialized local variable 'player'
ModmeBot:
Reply By: Abnormal202 In this case (though I can't see it) I assume each player is getting threaded to your playerhurtcheck() function, meaning that in the function the player is stored as self.
So whenever you want to use the player, use self instead, because we haven't defined anything as player.