Jump to content

Flamethrower coding

Recommended Posts

Hi, I'm making an actual flamethrower based off the code from boba fett, but whenever I try to shoot it, the flame shoots backwards through the back of the gun, but it still seems to damage people close to me in front.  Here is what I have.  Anyone know what I can do to reverse the flame?


#include "b_local.h"
#include "../Ravl/CVec.h"
#include "../cgame/cg_local.h"
void WP_FireFlameThrower(gentity_t *self);
void WP_StopFlameThrower(gentity_t *self);
void WP_StartFlameThrower(gentity_t *self);
void WP_DoFlameThrower(gentity_t *self);
extern cvar_t* g_bobaDebug;
extern void CG_DrawEdge(vec3_t start, vec3_t end, int type);
void WP_FireFlameThrower(gentity_t *ent)
trace_t tr;
vec3_t start, end, dir;
CVec3 traceMins(ent->mins);
CVec3 traceMaxs(ent->maxs);
gentity_t* traceEnt = NULL;
AngleVectors(ent->currentAngles, dir, 0, 0);  
dir[2] = 0.0f;
VectorCopy(ent->currentOrigin, start);
traceMins *= 0.5f;
traceMaxs *= 0.5f;
start[2] += 840.0f;
G_SoundOnEnt(ent, CHAN_WEAPON, "sound/weapons/boba/bf_flame.mp3");
VectorMA(start, 150.0f, dir, end);
if (g_bobaDebug->integer)
CG_DrawEdge(start, end, EDGE_IMPACT_POSSIBLE);
gi.trace(&tr, start, ent->mins, ent->maxs, end, ent->s.number, MASK_SHOT, (EG2_Collision)0, 0);
traceEnt = &g_entities[tr.entityNum];
if (tr.entityNum < ENTITYNUM_WORLD && traceEnt->takedamage)
G_Damage(traceEnt, ent, ent, dir, tr.endpos, damage, DAMAGE_NO_ARMOR | DAMAGE_NO_KNOCKBACK | DAMAGE_NO_HIT_LOC | DAMAGE_IGNORE_TEAM, MOD_LAVA, HL_NONE);
if (traceEnt->health>0)
// G_Knockdown( traceEnt, self, dir, Q_irand(200, 330), qfalse);
G_Throw(traceEnt, dir, 30);
Link to comment

I was able to fix it.  Turns out the stuff I had was only for the damage formula.  I didn't have anything to say which direction the effect should go, so instead of banging my head against the desk since I'm not that great at coding, I just edited the effect to start and end opposite, making the flame effect do a 180 turn.  So it's working now.

Asgarath83 likes this
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...