From fb6fcf9138af734ba6fc2bbac5d1123249d431e3 Mon Sep 17 00:00:00 2001 From: driAn Date: Wed, 16 Apr 2008 20:09:32 +0000 Subject: [PATCH] spectfov, weap code restructured git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1800 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/entities.cpp | 26 ++++++++++++++++++++++++++ source/src/entity.h | 6 ++++++ source/src/protos.h | 1 + source/src/sound.cpp | 3 ++- source/src/weapon.cpp | 2 +- 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 21347bf0..b319b53c 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -3,6 +3,32 @@ #include "pch.h" #include "cube.h" + +grenadeent::grenadeent (playerent *owner, int millis) +{ + ASSERT(owner); + bounceent::owner = owner; + bounceent::millis = lastmillis; + timetolife = 2000-millis; + bouncestate = NADE_ACTIVATED; + maxspeed = 27.0f; + rotspeed = 6.0f; +} + +void grenadeent::explode() +{ + static vec n(0,0,0); + if(bouncestate != NADE_THROWED) owner->weapons[GUN_GRENADE]->attack(n); + playsound(S_FEXPLODE, &o); + newprojectile(o, o, 1, owner==player1, owner, GUN_GRENADE, millis); +} + +void grenadeent::destroy() +{ + if(bouncestate==NADE_ACTIVATED || bouncestate==NADE_THROWED) explode(); +} + + vector ents; const char *entnames[] = diff --git a/source/src/entity.h b/source/src/entity.h index 31d72d55..ec5db7c7 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -459,3 +459,9 @@ struct bounceent : physent // nades, gibs }; +struct grenadeent : bounceent +{ + grenadeent (playerent *owner, int millis = 0); + void explode(); + virtual void destroy(); +}; \ No newline at end of file diff --git a/source/src/protos.h b/source/src/protos.h index 890b848a..b5b6c7ab 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -477,6 +477,7 @@ extern bool intersect(entity *e, const vec &from, const vec &to, vec *end = NULL extern void damageeffect(int damage, playerent *d); extern void tryreload(playerent *p); extern void checkakimbo(); +extern void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun, int id = lastmillis); // entities extern const char *entnames[]; diff --git a/source/src/sound.cpp b/source/src/sound.cpp index f87e3406..f26c3862 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -476,7 +476,8 @@ void initsound() { conoutf("Sound: %s (%s)", alGetString(AL_RENDERER), alGetString(AL_VENDOR)); conoutf("Driver: %s", alGetString(AL_VERSION)); - alDistanceModel(AL_INVERSE_DISTANCE); + //alDistanceModel(AL_INVERSE_DISTANCE); + alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED); nosound = false; } } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 12fdd72d..75ba08b1 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -180,7 +180,7 @@ vector projs; void projreset() { projs.setsize(0); } -void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun, int id = lastmillis) +void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun, int id) { projectile &p = projs.add(); p.o = from;