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.
function playerHurtcheck()
{
self endon("noHealthOverlay");
self.hurtAgain = false;
for ( ;; )
{
self waittill( "damage", amount, attacker, dir, point, mod );
if(isdefined(attacker) && isplayer(attacker) && attacker.team == self.team)
{
continue;
}
self.hurtAgain = true;
self.damagePoint = point;
self.damageAttacker = attacker;
}
}
ModmeBot:
Reply By: 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.
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.
perk = "specialty_perk_name"; //replace with the perk you want
perk_str = perk + "_stop";
self notify( perk_str );
/*Perk names:
Mule Kick = specialty_additionalprimaryweapon
Deathshot = specialty_deadshot
Doubletap = specialty_doubletap2
Electric Cherry = specialty_electriccherry
Jugg = specialty_armorvest
Quick Revive = specialty_quickrevive
Speed Cola = specialty_fastreload
Stamin Up = specialty_staminup
Widows Wine = specialty_widowswine
Harrys Perks
PHD Flopper = specialty_phdflopper
Who's Who = specialty_whoswho
Vulture Aid = specialty_vultureaid
Tombstone = specialty_tombstone
*/
a_perks = self zm_perks::get_perk_array();
perk = array::random(a_perks);
self notify( perk + "_stop" );
ModmeBot:
Reply By: eDeK
I delete this line:
if(isdefined(attacker) && attacker.team = level.zombie_team)
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.
function playerHurtcheck()
{
n_score_to_take = 2000; //Change this to the amount of money you want the player to lose!
for ( ;; )
{
self waittill( "damage", amount, attacker, dir, point, mod );
if(isdefined(attacker) && attacker.team != self.team && !isdefined(attacker.playername)) //Not in the team of player = zombie
{
if(self.score >= n_score_to_take) //So you don't take more than the player has
{
self zm_score::minus_to_player_score(n_score_to_take);
}
else
{
self zm_score::minus_to_player_score(self.score); //If player has less points than should be taken, take all points
}
//Add perk loss stuff here!
}
}
}
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'
function playerHurtcheck()
{
n_score_to_take = 999999999; //Change this to the amount of money you want the player to lose!
for ( ;; )
{
self waittill( "damage", amount, attacker, dir, point, mod );
if(isdefined(attacker) && attacker.team != self.team && !isdefined(attacker.playername)) //Not in the team of player = zombie
{
if(self.score >= n_score_to_take)
//So you don't take more than the player has
{
self zm_score::minus_to_player_score(n_score_to_take);
}
else
{
self zm_score::minus_to_player_score(self.score);
//If player has less points than should be taken, take all points
}
//Add perk loss stuff here!
perk = "specialty_armorvest";
perk_str = perk + "_stop";
player notify( perk_str );
perk = "specialty_fastreload";
perk_str = perk + "_stop";
player notify( perk_str );
perk = "specialty_doubletap2";
perk_str = perk + "_stop";
player notify( perk_str );
perk = "specialty_staminup";
perk_str = perk + "_stop";
player notify( perk_str );
perk = "specialty_deadshot";
perk_str = perk + "_stop";
player notify( perk_str );
perk = "specialty_additionalprimaryweapon";
perk_str = perk + "_stop";
player notify( perk_str );
}
}
}
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.
Meaning this:
player notify( perk_str );
should be:
self notify( perk_str );
ModmeBot:
Reply By: eDeK
Yeah exact, my fault, "player" to "self", works perfect now, thanks <span style="color:#ffffff;">mathfag</span>, <span style="color:#ffffff;">ihmiskeho</span>, <span style="color:#ffffff;">Abnormal202</span> for reply/help, really apreciated.
This method can works for 4 players playing at the same time or only work for 1 player?