1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Answered Is there a way to track when a grenade detonates?

Discussion in 'Call of Duty: Black Ops 3 Answered Questions' started by Cxwh, Nov 4, 2016.

  1. Cxwh

    Cxwh Active Member

    54
    33
    18
    Credits:
    1,173
    I know this is pretty random, but I'm trying to remake the decoy grenade from CS:GO (which plays random gunshot sounds). I looked through the gscs and found some things that might be helpful, like the FakeFire from the psychosis bots, but can't really find a proper way to track when a grenade should detonate. It would also be helpful if someone knows how to remove the effects (like the smoke fx for smoke grenades). I know I'm asking for alot, but I'm really kind of lost right now.
     
  2. God

    God Skiddy

    339
    232
    143
    Credits:
    608
    self waittill("grenade_fire"); //idk if this is when you throw a grenade or when it explodes
     
  3. SeriousHD-

    SeriousHD- Guest

    Credits:
    0
    self waittill("grenade_fire", weapon, grenade); //Fires when grenade is thrown
     
    Cxwh and JayCoder like this.
  4. Cxwh

    Cxwh Active Member

    54
    33
    18
    Credits:
    1,173
    This is how far I could get today
    Code:
    function __init__()
    {
        callback::on_start_gametype( &init );
        callback::on_connect( &on_player_connect );
        callback::on_spawned( &on_player_spawned );
    }
    
    function init()
    {
        level.decoyWeapons = strTok("ar_standard ar_accurate ar_fastburst ar_cqb ar_damage ar_longburst ar_marksman ar_garand ar_famas ar_peacekeeper smg_standard smg_versatile smg_fastfire smg_longrange smg_burst smg_capacity smg_mp40 lmg_light lmg_heavy lmg_cqb lmg_slowfire lmg_infinite", " ");
    }
    
    function on_player_connect()
    {
        //dunno if i need it yet
    }
    
    function on_player_spawned()
    {
        self endon("disconnect");
        self thread watchDecoyGrenade();
    }
    
    function watchDecoyGrenade()
    {
        self endon("death");
        self endon("disconnect");
    
        weapon_decoy = GetWeapon("willy_pete"); //smoke grenade
        for(;;)
        {
            self waittill("grenade_fire", grenade, weapon, cookTime);
            if(weapon.rootWeapon == weapon_decoy) //checks if its the smoke grenade
            {
                grenade thread watchDecoyGrenadeDetonation(self, weapon_decoy, 4);
            }
        }
    }
    
    function watchDecoyGrenadeDetonation(owner, statWeapon, shotsFired)
    {
        //owner AddWeaponStat(statWeapon, "used", 1);
        self waittill("explode", position, surface);
        self decoyDetonate(owner, position, shotsFired);
    }
    
    function decoyDetonate(owner, position, shotsFired)
    {
        decWeaps = level.decoyWeapons.size - 1;
        i = RandomIntRange(0, decWeaps);
    
        fakeFireWeapon = level.decoyWeapons[i];
        self decoyFakeFire(owner, position, fakeFireWeapon, shotsFired);
    }
    
    
    function decoyFakeFire(owner, position, fakeFireWeapon, shotsFired)
    {
        max_range = (750*750);
        while(true)
        {
            if(isDefined(fakeFireWeapon))
            {
                players = GetPlayers();
                foreach(player in players)
                {
                    if(isDefined(player) && isAlive(player))
                    {
                        if(DistanceSquared(player.origin, position) < max_range)
                        {
                            self FakeFire(owner, position, fakeFireWeapon, shotsFired);
                            break;
                        }
                    }
                }
            }
            wait(shotsFired / 2);
            self SetFakeFire(false);
        }
    }
     
    CabCon likes this.
  5. CabCon

    CabCon Head Administrator Staff Member

    3,182
    1,890
    263
    Credits:
    67,364
    Question answered!
     

Share This Page