Gas_grenade help


(ksa2000) #1

Hi,I have add a “gasgranade” in my little mod.The skin is ok,weapon change is ok.

Now i have 2 probs.

  1. How to add damage to the smoke?
  2. How change the smoke color?

Now,i have 2 smoke_bombs in my mod,lol.

gruss
ksa2000


(xro) #2

take a look at the flamethrower’s code and do something similiar.


(PAV) #3

take a look at the flamethrower’s code and do something similiar. :lol:

Smoke bomb colours

  1. open cg_effects.c

  2. go to the function qboolean CG_SpawnSmokeSprite( centity_t *cent, float dist )

  3. modify this this 4 values (never > 1 ok !)
    smokesprite->colour[0] = .35f; // + crandom() * .1f;
    smokesprite->colour[1] = smokesprite->colour[0];
    smokesprite->colour[2] = smokesprite->colour[0];
    smokesprite->colour[3] = .8f;

By example u can do this
//Axis smokebomb colour
if(smokesprite->smokebomb->currentState.teamNum==1)
{ smokesprite->colour[0] = .4f;
smokesprite->colour[1] = .6f;
smokesprite->colour[2] = .6f;
smokesprite->colour[3] = .5f; //transparancy
}
//Allies smokebomb colour
else if(smokesprite->smokebomb->currentState.teamNum==2) // Allies
{ smokesprite->colour[0] = .5f;
smokesprite->colour[1] = .8f;
smokesprite->colour[2] = .3f;
smokesprite->colour[3] = .5f; //transparancy
}
else // default
{ smokesprite->colour[0] = .35f;
smokesprite->colour[1] = smokesprite->colour[0];
smokesprite->colour[2] = smokesprite->colour[0];
smokesprite->colour[3] = .8f;
}

For the poinson gaz u must create your function.


(ksa2000) #4

thx,the color change works fine.

gruss
ksa2000


(PAV) #5

on my mod (bobot) the smokebombgas has 2 options

  1. poison gas effect (similar to poison syringe)
  2. burn napalm effect (like flamethrower)

(ksa2000) #6

rw mod ?


(PAV) #7

rw ? real weapon ?

look at my web site http://www.wmaker.net/bobots/


(kamikazee) #8

RW -> probably ksa2000 meant “Realistic War”.

It had phosphorous and gas grenades, apart from your regular smoke grenade, air strike marker and explosives.


(PAV) #9

it is perfect to dislodge a guy of its hole :slight_smile:


(PAV) #10

ok, u have the damage gas smoke bomb code in PM, try it.


(ksa2000) #11

Now works the “giftgas” perfect!Much thanks to PAV!!

gruss
ksa2000 :smiley:


(Bonghead) #12

How do you make the smoke do damage… :penguin:


(Scennative) #13

These Code can change the color of the Smoke Bomb, add damage and add when u like a burn modus…

But that add only features to the smokebomb, but dont add a new weapon.

Add a colored Smoke bomb that burns

I) Donner de la couleur au smoke bomb / Make a colored smoke bomb.

1) open cg_effects.c
2) go to the function qboolean CG_SpawnSmokeSprite( centity_t *cent, float dist ) and modify like this.

qboolean CG_SpawnSmokeSprite( centity_t *cent, float dist )
{    smokesprite_t *smokesprite = AllocSmokeSprite();
    
    if( smokesprite )
    {   smokesprite->smokebomb = cent;
        VectorCopy( cent->origin2, smokesprite->pos );        
        VectorCopy( bytedirs[rand()%NUMVERTEXNORMALS], smokesprite->dir );
        smokesprite->dir[2] *= .5f;
        smokesprite->size = 16.f;
        if(smokesprite->smokebomb->currentState.teamNum==1)    //team Axis = blue smoke
        {    smokesprite->colour[0] = .2f;
            smokesprite->colour[1] = .3f;
            smokesprite->colour[2] = .6f;
            smokesprite->colour[3] = .25f; //smoke transparency
        }
        else if(smokesprite->smokebomb->currentState.teamNum==2)  // team Allies = orange smoke
        {    smokesprite->colour[0] = .5f;
            smokesprite->colour[1] = .2f;
            smokesprite->colour[2] = .1f;
            smokesprite->colour[3] = .25f; //smoke transparency
        }
        else
        {    smokesprite->colour[0] = .35f;                        // default
            smokesprite->colour[1] = smokesprite->colour[0];
            smokesprite->colour[2] = smokesprite->colour[0];
            smokesprite->colour[3] = .8f;
        }
        // Advance sprite
        if( !CG_SmokeSpritePhysics( smokesprite, dist ) )
        {    DeAllocSmokeSprite( smokesprite );
              return( qfalse );
        }
        else
            cent->miscTime++;
    }
    return( qtrue );
}

II) Brûler l'ennemi / Burn the enemy.
1) open g_active.c
2) create the function (smoke bomb that burns) into g_active.c

void smoke_bomb_burn(gentity_t *ent)
{   gentity_t    *dyn;
    vec3_t        diff;
    float        dist;
     //a smoke bomb is it launched ? Find it.
    for (dyn = G_FindSmokeBomb( NULL );dyn;dyn = G_FindSmokeBomb(dyn))
    {   VectorSubtract(ent->r.currentOrigin,dyn->r.currentOrigin,diff);  // a player is into the smoke ?
        dist = VectorLength(diff);

         // Example 1) if you want that it only burns adversary team, do this

        if(!OnSameTeam(ent,dyn->parent)) // burns only adversary team
        {    if (dist <= 300 && dyn->s.effect1Time==640 && ent->takedamage==qtrue) // a player is into the radius smoke (300)
               G_BurnMeGood(ent, ent); // the player is burned
         }

        // Example 2) if you want that it burns all teams, do this.

        if (dist <= 300 && dyn->s.effect1Time==640 && ent->takedamage==qtrue) // a player is into the radius smoke (300)
               G_BurnMeGood(ent, ent); // the player is burned

        // Example 3) You can burn adversary team and regenerate health of your team, like this.

        if(!OnSameTeam(ent,dyn->parent)) // burns only adversary team
        {    if (dist <= 300 && dyn->s.effect1Time==640 && ent->takedamage==qtrue) // a player is into the radius smoke (300)
               G_BurnMeGood(ent, ent); // the player is burned
         }

        else

           {  ent->health+=1;

              if ( ent->health > ent->client->ps.stats[STAT_MAX_HEALTH] )
                    ent->health = ent->client->ps.stats[STAT_MAX_HEALTH] ;

          }

    }    
}

3) Add function smoke_bomb_burn(gentity_t *ent) into the function : void ClientTimerActions( gentity_t *ent, int msec )

/*==================
ClientTimerActions
Actions that happen once a second
==================*/

void ClientTimerActions( gentity_t *ent, int msec )
{   gclient_t    *client;
    gentity_t    *attacker;
    int            regenRate1, regenRate2,i;
    
    client = ent->client;
    client->timeResidual += msec;
    
    while( client->timeResidual >= 1000 )
    {   
         client->timeResidual -= 1000;

         // Traitement du smokebomb
         smoke_bomb_burn(ent);


        // Adrenaline countdown.
        if(    g_logOptions.integer & LOGOPTS_ADR_COUNT && client->ps.powerups[PW_ADRENALINE] > level.time    )
            CP(va("cp \"^3Adrenaline (%d)\"", ((client->ps.powerups[PW_ADRENALINE] - level.time)/1000)));
        // Determine regenerate
        switch(g_medicHealthRegen.integer)
        {
            case MEDIC_REGENRATE22:
                regenRate1 = 2;
                regenRate2 = 2;
                break;
            case MEDIC_REGENRATE21:
                regenRate1 = 2;
                regenRate2 = 1;
                break;
            case MEDIC_REGENRATE20:
                regenRate1 = 2;
                regenRate2 = 0;
                break;
            case MEDIC_REGENRATE11:
                regenRate1 = 1;
                regenRate2 = 1;
                break;
            case MEDIC_REGENRATE10:
                regenRate1 = 1;
                regenRate2 = 0;
                break;
            case MEDIC_REGENRATE00:
                regenRate1 = 0;
                regenRate2 = 0;
                break;
            default:
                regenRate1 = 3;
                regenRate2 = 2;
                break;
        }
        // regenerate
        if( client->sess.playerType == PC_MEDIC && !(client->ps.eFlags & EF_DEAD) )
        {    if( ent->health < client->ps.stats[STAT_MAX_HEALTH])
            {    ent->health += regenRate1;
                if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.1)
                    ent->health = client->ps.stats[STAT_MAX_HEALTH] * 1.1;
            }
            else if( ent->health < client->ps.stats[STAT_MAX_HEALTH] * 1.12)
            {    ent->health += regenRate2;
                if( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.12 )
                    ent->health = client->ps.stats[STAT_MAX_HEALTH] * 1.12;    
            }
        }
        else
        {    if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] )
                    ent->health--;
        }
        if(ent->takedamage==qfalse)
        {    client->pmext.poisoned = qfalse; }
        if(client->pmext.poisoned && ent->health > 0 &&    g_poison.integer)
        {    attacker = g_entities + client->pmext.poisonerEnt;
            if(g_poisonSound.string[0])
            {    G_AddEvent(ent, EV_GLOBAL_SOUND,G_SoundIndex(g_poisonSound.string));    }
            G_Damage(ent, attacker, attacker, NULL, NULL,g_poison.integer, 0, MOD_POISON);
        }
        if(client->pmext.poisoned && (ent->health <= 0 || client->ps.eFlags & EF_DEAD))
           client->pmext.poisoned = qfalse;
  }

Dernière mise à jour de cette page le 09/08/2010

Credits to Bobot and PAV
Copied from: http://bobots.e-monsite.com/rubrique,add-smoke-bomb,1160045.html