diff --git a/source/src/bot/bot_util.h b/source/src/bot/bot_util.h index 2fa362ff..ef33931d 100644 --- a/source/src/bot/bot_util.h +++ b/source/src/bot/bot_util.h @@ -1,13 +1,6 @@ #ifndef BOT_UTIL_H #define BOT_UTIL_H -// Structure for storing traceresults -struct traceresult_s -{ - vec end; - bool collided; -}; - long RandomLong(long from, long to); float RandomFloat(float from, float to); void lsrand(unsigned long initial_seed); @@ -15,8 +8,7 @@ void lsrand(unsigned long initial_seed); void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up); float WrapXAngle(float angle); float WrapYZAngle(float angle); -void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, - bool SkipTags=false); + float GetDistance(vec v1, vec v2); float Get2DDistance(vec v1, vec v2); bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false); diff --git a/source/src/protos.h b/source/src/protos.h index c4babeab..9d51ac94 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -677,6 +677,13 @@ extern void setscope(bool activate); extern void setburst(bool activate); extern int intersect(playerent *d, const vec &from, const vec &to, vec *end = NULL); extern bool intersect(entity *e, const vec &from, const vec &to, vec *end = NULL); +// Structure for storing traceresults +struct traceresult_s +{ + vec end; + bool collided; +}; +void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, bool SkipTags=false); extern void damageeffect(int damage, playerent *d); extern void tryreload(playerent *p); extern void checkakimbo(); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 23aff589..578e06e7 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -1193,9 +1193,11 @@ bool gun::attack(vec &targ) void gun::attackfx(const vec &from, const vec &to, int millis) { - addbullethole(owner, from, to); - addshotline(owner, from, to); - particle_splash(0, 5, 250, to); + traceresult_s tr; + TraceLine(from, to, owner, true, &tr); + addbullethole(owner, from, tr.end); + addshotline(owner, from, tr.end); + particle_splash(0, 5, 250, tr.end); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); } @@ -1251,10 +1253,12 @@ sniperrifle::sniperrifle(playerent *owner) : gun(owner, GUN_SNIPER), scoped(fals void sniperrifle::attackfx(const vec &from, const vec &to, int millis) { - addbullethole(owner, from, to); - addshotline(owner, from, to); - particle_splash(0, 50, 200, to); - particle_trail(1, 500, from, to); + traceresult_s tr; + TraceLine(from, to, owner, true, &tr); + addbullethole(owner, from, tr.end); + addshotline(owner, from, tr.end); + particle_splash(0, 50, 200, tr.end); + particle_trail(1, 500, from, tr.end); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); }