#1 2016-05-30 07:02:25

VladCosmonaut
Member

Need help adding in gun

I am trying to program a gun in Tesseract, I have gotten it to show up and shoot, but it doesn't hurt/collide with any players.

Offline

#2 2016-05-30 11:08:40

NeoXploD
Member

Re: Need help adding in gun

Hello
you did well in game.h add your gun?

static const struct attackinfo { int gun, action, anim, vwepanim, hudanim, sound, hudsound, attackdelay, damage, spread, margin, projspeed, kickamount, range, rays, hitpush, exprad, ttl, use; } attacks[NUMATKS] =
{
    { GUN_RAIL,  ACT_SHOOT, ANIM_SHOOT, ANIM_VWEP_SHOOT, ANIM_GUN_SHOOT, S_RAIL1,  S_RAIL2, 1300, 1, 0, 0,    0, 30, 2048, 1, 5000,  0, 0, 0 },
    { GUN_RAIL,  ACT_MELEE, ANIM_MELEE, ANIM_VWEP_MELEE, ANIM_GUN_MELEE, S_MELEE,  S_MELEE,  500, 1, 0, 2,    0,  0,   14, 1,    0,  0, 0, 0 },
    { GUN_PULSE, ACT_SHOOT, ANIM_SHOOT, ANIM_VWEP_SHOOT, ANIM_GUN_SHOOT, S_PULSE1, S_PULSE2, 700, 1, 0, 1, 1000, 30, 1024, 1, 5000, 15, 0, 0 },
    { GUN_PULSE, ACT_MELEE, ANIM_MELEE, ANIM_VWEP_MELEE, ANIM_GUN_MELEE, S_MELEE,  S_MELEE,  500, 1, 0, 2,    0,  0,   14, 1,    0,  0, 0, 0 }
};

or ai.cpp

bool hasgoodammo(gameent *d)
    {
        static const int goodguns[] = { GUN_PULSE, GUN_RAIL };
        loopi(sizeof(goodguns)/sizeof(goodguns[0])) if(d->hasammo(goodguns[0])) return true;
        return false;
    }

Offline

#3 2016-06-04 23:25:23

chasester
Member

Re: Need help adding in gun

Id rewrite the enum

enum GUNS { GUN_RAIL = 0, GUN_PULSE ... etc GUN_MAX }

then you just can go
if (gun < GUN_MAX)

:)

Offline

Board footer