Modme Forums
Menu:

Add script to weapon

Game Modding | Call of Duty: Black Ops 3 | Scripting


Pepergogo:

Hi
I'm trying to add script that heals you when you kill a zombie to a normal weapon. Currently I'm using a "Pro Revenge's" script that spawn a fx when you kill a zombie. The fx work, but the other part of the script doesn't:


//Lumina
level.zombie_death_animscript_override = &zombie_death_animscript_override;

//Lumina
function zombie_death_animscript_override()
{
   // iPrintLnBold( "OVERRIDE" );
    if ( "iw5_mp412" == self.damageweapon.name )
    {
        self thread zm_spawner::dragons_breath_flame_death_fx();
        
        //This is what I add. It heals you when you kill a zombie
        if(self.health < self.maxhealth)
        {
            dif = self.maxhealth - self.health;
            if(dif < 10)
                self.health = self.maxhealth;
            else
                self.health += 10;
        }
    }

}


And I'm using the Ethereal Razor script for the healing part.
Anyone know what could I do to make it work?


Spiki:

Self is zombie


Pepergogo:

Self is zombie

Do you know how can I make for the player? 😭

Spiki:

Do you know how can I make for the player? 😭

prob self.attacker
i am unfamiliar with the animscript override func

Pepergogo:

[USER=64]@Spiki[/USER]
I'm using the Ethereal Razor script as a guide and I guess the function to give the perk the functionality is this one:

function ethereal_razor_arc()
{
    damage = 1500;
    if(self HasDbPerkNew(ETHEREAL_RAZOR_SPECIALTY))
        damage = 3500;
    angles = self getPlayerAngles();
    pos = self.origin;
    forward_view_angles = anglesToForward(angles);
    end_pos = pos + v_scale( forward_view_angles, 40 );
    end_pos = (end_pos[0],end_pos[1],self.origin[2]);
    a_zombies = zombie_utility::get_round_enemy_array();
    a_zombies = util::get_array_of_closest( end_pos, a_zombies, undefined, undefined, 80 );
    a_zombies = util::get_array_of_closest( pos, a_zombies );
    n_zombies_hit = 0;
    n_zombie_limit = 4;
    for ( i = 0; i < a_zombies.size; i++ )
    {
        if ( IsAlive( self ) && IsAlive( a_zombies[ i ] ) && distance(self.origin, a_zombies[ i ].origin) < 80)
        {
            if( n_zombies_hit < n_zombie_limit )
                n_zombies_hit++;       
            else
                break;
            wait 0.05;       
            if( isdefined( a_zombies[ i ] ) && IsAlive( a_zombies[ i ] ) ) // need to check again since we're post-wait
            {
                a_zombies[ i ] DoDamage( damage, self.origin, self, self, "none" );
                self thread ethereal_razor_heal();
            }
        }
    }
}

function ethereal_razor_heal()
{
    if(self.health < self.maxhealth)
    {
        dif = self.maxhealth - self.health;
        if(dif < 10)
            self.health = self.maxhealth;
        else
            self.health += 10;
    }
}

function v_scale(v, scale)
{
    v = (v * scale);
    return v;
}

function ethereal_razor_zombie_damage_response( str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel )
{
    if ( IS_EQUAL(str_mod,"MOD_MELEE") && IsDefined(e_player) && IsPlayer(e_player) && e_player HasPerkNew(ETHEREAL_RAZOR_SPECIALTY) && !isdefined(self.ethereal_razor_zombie_damage_response) )
    {
        damage = 1500;
        if(self HasDbPerkNew(ETHEREAL_RAZOR_SPECIALTY))
            damage = 3500;
        self.ethereal_razor_zombie_damage_response = true;
        self DoDamage( damage, self.origin, e_player, self, "MOD_MELEE" );
        self thread ethereal_razor_zombie_damage_response_cooldown();
    }
    return false;
}

function ethereal_razor_zombie_damage_response_cooldown()
{
    wait .2;
    self.ethereal_razor_zombie_damage_response = undefined;
}

//make sure player never has razor knife unless they have the base melee weapon
function track_razor_melee_weapon()
{
    self notify("track_razor_melee_weapon");
    self endon("track_razor_melee_weapon");
    while(1)
    {
        if(!self hasperk("specialty_widowswine") && self HasPerkNew(ETHEREAL_RAZOR_SPECIALTY))//widows wine overides this otherwise its knife wont work
        {
            if(self HasWeapon( self zm_utility::get_player_melee_weapon() ) && self zm_utility::get_player_melee_weapon() == level.weaponBaseMelee)
            {
                self GiveWeapon( level.ethereal_razor_knife );
                self zm_utility::set_player_melee_weapon( level.ethereal_razor_knife );  
            }
        }
        else if(!self HasPerkNew(ETHEREAL_RAZOR_SPECIALTY))
        {
            if(self HasWeapon( level.ethereal_razor_knife ) && self zm_utility::get_player_melee_weapon() == level.ethereal_razor_knife)
            {
                self GiveWeapon( level.weaponBaseMelee );
                self zm_utility::set_player_melee_weapon( level.weaponBaseMelee );  
            }
        }
        wait .1;
    }
}


The function "ethereal_razor_heal" is the one I put in the anim script

I try the "self.attacker", but I really don't know where to put it

Hope this script can give more context


F3ARxReaper666:

//Lumina
function zombie_death_animscript_override()
{
   // iPrintLnBold( "OVERRIDE" );
    if ( "iw5_mp412" == self.damageweapon.name )
    {
        self thread zm_spawner::dragons_breath_flame_death_fx();
       
        //This is what I add. It heals you when you kill a zombie
        if(isdefined(self.attacker) && IsPlayer(self.attacker) && self.attacker.health < self.attacker.maxhealth)
        {
            dif = self.attacker.maxhealth - self.attacker.health;
            if(dif < 10)
                self.attacker.health = self.attacker.maxhealth;
            else
                self.attacker.health += 10;
        }
    }
}

try that out

also my ethereal razor only works in healing 10 health at a time, if you wanna fully heal the player or change the ammount change the 2 "10"s in

dif = self.attacker.maxhealth - self.attacker.health;
            if(dif < 10)
                self.attacker.health = self.attacker.maxhealth;
            else
                self.attacker.health += 10;


Pepergogo:

//Lumina
function zombie_death_animscript_override()
{
   // iPrintLnBold( "OVERRIDE" );
    if ( "iw5_mp412" == self.damageweapon.name )
    {
        self thread zm_spawner::dragons_breath_flame_death_fx();
      
        //This is what I add. It heals you when you kill a zombie
        if(isdefined(self.attacker) && IsPlayer(self.attacker) && self.attacker.health < self.attacker.maxhealth)
        {
            dif = self.attacker.maxhealth - self.attacker.health;
            if(dif < 10)
                self.attacker.health = self.attacker.maxhealth;
            else
                self.attacker.health += 10;
        }
    }
}

try that out

also my ethereal razor only works in healing 10 health at a time, if you wanna fully heal the player or change the ammount change the 2 "10"s in

dif = self.attacker.maxhealth - self.attacker.health;
            if(dif < 10)
                self.attacker.health = self.attacker.maxhealth;
            else
                self.attacker.health += 10;

Thanks for the code. Gonna try that when I get home

Pepergogo:

//Lumina
function zombie_death_animscript_override()
{
   // iPrintLnBold( "OVERRIDE" );
    if ( "iw5_mp412" == self.damageweapon.name )
    {
        self thread zm_spawner::dragons_breath_flame_death_fx();
      
        //This is what I add. It heals you when you kill a zombie
        if(isdefined(self.attacker) && IsPlayer(self.attacker) && self.attacker.health < self.attacker.maxhealth)
        {
            dif = self.attacker.maxhealth - self.attacker.health;
            if(dif < 10)
                self.attacker.health = self.attacker.maxhealth;
            else
                self.attacker.health += 10;
        }
    }
}

try that out

also my ethereal razor only works in healing 10 health at a time, if you wanna fully heal the player or change the ammount change the 2 "10"s in

dif = self.attacker.maxhealth - self.attacker.health;
            if(dif < 10)
                self.attacker.health = self.attacker.maxhealth;
            else
                self.attacker.health += 10;


[USER=230]@F3ARxReaper666[/USER]
Hi, I try the code but it doesn't heal you :(
I use the default value of 10 and then I change the value to 70 to check if the heals work but stays the same

I record a video to show what happen normally and when I kill a zombie


F3ARxReaper666:

it doesn't change the red screen if you get healed, run a test script to print the players health and you can see it should raise it when getting kills


Pepergogo:

it doesn't change the red screen if you get healed, run a test script to print the players health and you can see it should raise it when getting kills

Oh ok ok 😂
Gonna search for a healing script or command and take a look.
Thanks 😎

Pepergogo:

[USER=230]@F3ARxReaper666[/USER]
Just one more question
For other weapon I'm gonna use the same override function, but instead of the healing part I'm looking to decrease the life of the zombie for 3 seconds after you shoot him.

Like shoot it and if he doesn't die, then every second for 3 seconds he loose 10% percent of life or something like that.

Do you know how can it be done? I was trying to use the Harry's Napalm script (for the fire that kill the zombies) as a guide but is a little hard to understand.


Pepergogo:

[USER=230]@F3ARxReaper666[/USER]
Sorry for tellling you the heal script doesn't work, but I try it again and works perfectly fine. I just want to say thanks a loooot for your help :D