• Welcome Guest, The new Modme forums are here! Please visit here for all recommended information.

Adaptive trigger_damage

Magicman

Active member
How could I make a trigger_damage that could be activated multiple times per game and every time you have to use a different weapon. For example, if I wanted a trigger that every time it was shot it would give you a max ammo, and I shoot it with the ray gun, next time I want to do it, the ray gun wouldn’t activate it. Hopefully that made some sort of sense. I hope this idea is possible and/ or practical.
 

modric1337

Active member
Code:
while ( 1 )
    {
    self waittill( "damage", n_damage, e_attacker, v_dir, v_point, str_mod, str_model, str_tag, str_part, w_weapon, str_flags, e_inflictor, n_charge_level );
    if ( isdefined( w_weapon ) )
    {
        //IPrintLnBold("w_weapon is defined");
        rootWeapon = w_weapon.rootWeapon;
        if ( rootWeapon == getWeapon( "ar_marksman_upgraded" ) )
        {
            //IPrintLnBold("w_weapon is ar");
            thread zm_powerups::specific_powerup_drop( "full_ammo", plane_package_struct.origin);
            
            break;
        }
      
        
    }
    
    }
This is some stuff i had that worked thrown together, self is the trig that is threaded from a previous function, if you are using only one trig u can just change self to a trig name... and make sure you set up a struct for the powerup and of course change the weapon... if u want it to be any weapon just doing waitill trigger on a trig damage will work
 

Magicman

Active member
Code:
while ( 1 )
    {
    self waittill( "damage", n_damage, e_attacker, v_dir, v_point, str_mod, str_model, str_tag, str_part, w_weapon, str_flags, e_inflictor, n_charge_level );
    if ( isdefined( w_weapon ) )
    {
        //IPrintLnBold("w_weapon is defined");
        rootWeapon = w_weapon.rootWeapon;
        if ( rootWeapon == getWeapon( "ar_marksman_upgraded" ) )
        {
            //IPrintLnBold("w_weapon is ar");
            thread zm_powerups::specific_powerup_drop( "full_ammo", plane_package_struct.origin);
           
            break;
        }
     
       
    }
   
    }
This is some stuff i had that worked thrown together, self is the trig that is threaded from a previous function, if you are using only one trig u can just change self to a trig name... and make sure you set up a struct for the powerup and of course change the weapon... if u want it to be any weapon just doing waitill trigger on a trig damage will work

so if I activate the trigger with the "ar_marksman_upgraded" then I can continue to activate it, but I will no longer be able to do it with that gun, but every other gun will work? Also I appreciate the help
 

modric1337

Active member
Hm not sure about that, im sure it can be done by using a variable for the gun thats used and making it so the trig doesnt accept that variable anymore
 

Spiki

Active member
*FIXED POST*
If I understand correctly you want to shoot a trigger damage multiple times but never twice with the same gun.
If yes then this code should work but I didn't test it. It should be enough to see what's going on.
Code:
function gun_ammo_thing()
{
trig = GetEnt("whatever trigger","targetname");

rejected_guns = array(); //store guns here after use

while(1)
    {
    trig waittill( "damage", n_damage, e_attacker, v_dir, v_point, str_mod, str_model, str_tag, str_part, w_weapon, str_flags, e_inflictor, n_charge_level);
    if(!isdefined(w_weapon)) //restart loop if no weapon
        continue;

    rootWeapon = w_weapon.rootWeapon;
    if(rootWeapon is_rejected_gun(rejected_guns )) //restart loop if gun was used before
        continue;
    ArrayInsert(rejected_guns, rootWeapon, rejected_guns.size); //add gun to reject pile

    //post trig code here
    zm_powerups::specific_powerup_drop("full_ammo", e_attacker.origin);

    }

}


function is_rejected_gun(guns) //self is gun in question
{
foreach(gun in guns)
    if(self == gun)
        return 1;
return 0;
}

If you wanted to shoot it with specific guns in order then write back and we'll work something out
 
Last edited:

Magicman

Active member
If I understand correctly you want to shoot a trigger damage multiple times but never twice with the same gun.
If yes then this code should work but I didn't test it. It should be enough to see what's going on.
Code:
function gun_ammo_thing()
{
trig = GetEnt("whatever trigger","targetname");

rejected_guns = array(); //store guns here after use

while(1)
    {
    trig waittill( "damage", n_damage, e_attacker, v_dir, v_point, str_mod, str_model, str_tag, str_part, w_weapon, str_flags, e_inflictor, n_charge_level);
    if(!isdefined(w_weapon)) //restart loop if no weapon
        continue;

    rootWeapon = w_weapon.rootWeapon;
    if(rootWeapon is_rejected_gun(rejected_guns )) //restart loop if gun was used before
        continue;
    ArrayInsert(rejected_guns, rootWeapon, rejected_guns.size); //add gun to reject pile

    //post trig code here
    zm_powerups::specific_powerup_drop("full_ammo", e_attacker.origin);

    }

}


function is_rejected_gun(guns) //self is gun in question
{
weap = self.name;
foreach(gun in guns)
    if(weap== gun)
        return 1;
return 0;
}

If you wanted to shoot it with specific guns in order then write back and we'll work something out

I appreciate it, but I am able to activate the trigger with the same gun an infinite amount of times. Just to make sure, all I needed to do was create a trigger_damage with "whatever trigger", "targetname"?
 

Spiki

Active member
I think i see where i screwed up
I compared text to a weapon. This should fix it
Code:
function is_rejected_gun(guns) //self is gun in question
{
foreach(gun in guns)
    if(self == gun)
        return 1;
return 0;
}
 

Magicman

Active member
I think i see where i screwed up
I compared text to a weapon. This should fix it
Code:
function is_rejected_gun(guns) //self is gun in question
{
foreach(gun in guns)
    if(self == gun)
        return 1;
return 0;
}
Yup, worked perfectly. Much appreciated:)
 

Magicman

Active member
I think i see where i screwed up
I compared text to a weapon. This should fix it
Code:
function is_rejected_gun(guns) //self is gun in question
{
foreach(gun in guns)
    if(self == gun)
        return 1;
return 0;
}
If for example I wanted to make it delete a script_brushmodel everytime I activate the trigger, but not all of them at once. How would I do that?
 

Spiki

Active member
Basically give your bruhsmodels the KVP "index" and value any integer. start at 0. So the first brush to go has the value 0, second has 1, 3rd has 2... If you want to shoot twice to remove 1 brush, just skip a number so first is 0, second is 2, third is 3...


C-like:
function gun_ammo_thing()
{
trig = GetEnt("whatever trigger","targetname");

rejected_guns = array(); //store guns here after use
index = 0;

while(1)
    {
    trig waittill( "damage", n_damage, e_attacker, v_dir, v_point, str_mod, str_model, str_tag, str_part, w_weapon, str_flags, e_inflictor, n_charge_level);
    if(!isdefined(w_weapon)) //restart loop if no weapon
        continue;

    rootWeapon = w_weapon.rootWeapon;
    if(rootWeapon is_rejected_gun(rejected_guns )) //restart loop if gun was used before
        continue;
    ArrayInsert(rejected_guns, rootWeapon, rejected_guns.size); //add gun to reject pile

    //post trig code here
    zm_powerups::specific_powerup_drop("full_ammo", e_attacker.origin);

    delete_brush(index);
    index++;
    }

}


function is_rejected_gun(guns) //self is gun in question
{
foreach(gun in guns)
    if(self == gun)
        return 1;
return 0;
}



function delete_brush(index)
{
brushes = GetEntArray("brushes","targetname");

foreach(brush in brushes)
    if(brush.index == index)
        brush Delete();

}
changes in OG code: before and at end of while and new function
 
Top