mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Fix DOD grenade_throw incorrect calling behavior and wrong returned weapon IDs (bug 5785, r=arkshine)
This commit is contained in:
parent
163098892c
commit
79252c33fb
@ -215,81 +215,82 @@ void PlayerPreThink_Post(edict_t *pEntity)
|
|||||||
pEntity->v.fuser4 = (float)pPlayer->staminaMin;
|
pEntity->v.fuser4 = (float)pPlayer->staminaMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pPlayer->current == 29 || pPlayer->current == 30 || pPlayer->current == 31)
|
if(pPlayer->current == DODW_BAZOOKA || pPlayer->current == DODW_PANZERSCHRECK || pPlayer->current == DODW_PIAT)
|
||||||
{
|
{
|
||||||
if(!(pPlayer->pEdict->v.oldbuttons&IN_ATTACK) && (pPlayer->pEdict->v.button&IN_ATTACK))
|
if(!(pPlayer->pEdict->v.oldbuttons&IN_ATTACK) && (pPlayer->pEdict->v.button&IN_ATTACK))
|
||||||
gPlayerRocket = GET_PLAYER_POINTER(pEntity);
|
gPlayerRocket = GET_PLAYER_POINTER(pEntity); // Store player ID for rocket_shoot() event
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetModel_Post(edict_t *e, const char *m)
|
void SetModel_Post(edict_t *e, const char *m) {
|
||||||
{
|
|
||||||
|
/* For a grenade, this function gets called twice. The first time, all models are w_grenade.mdl and dmgtime is 0.
|
||||||
|
* The second time, the proper model and dmgtime are set.
|
||||||
|
* gPlayerRocket is set in PlayerPreThink_Post for all rockets.
|
||||||
|
* So, if neither is set, the model isn't being set on a grenade or rocket and we just return.
|
||||||
|
* TNT bundles/satchel charges also initially use w_grenade.mdl, so we can't efficiently filter based on model.
|
||||||
|
*/
|
||||||
|
if (!gPlayerRocket && !e->v.dmgtime) {
|
||||||
|
RETURN_META(MRES_IGNORED);
|
||||||
|
}
|
||||||
|
|
||||||
int w_id = 0;
|
int w_id = 0;
|
||||||
|
|
||||||
if(!e->v.owner || !e->v.dmgtime)
|
if(e->v.owner && e->v.dmgtime) { // owner was always set in my testing, but better safe than sorry
|
||||||
{
|
|
||||||
int owner = ENTINDEX(e->v.owner);
|
|
||||||
|
|
||||||
if(owner && owner < 33 && m[7]=='w' && m[8]=='_')
|
CPlayer* pPlayer = GET_PLAYER_POINTER(e->v.owner);
|
||||||
{
|
// current weapon is never set to DODW_MILLS_BOMB; only DODW_HANDGRENADE/DODW_STICKGRENADE
|
||||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(owner);
|
bool newNade = (pPlayer->current == DODW_HANDGRENADE || pPlayer->current == DODW_STICKGRENADE) ? true : false;
|
||||||
bool newNade = (pPlayer->current == 13 || pPlayer->current == 14) ? true : false;
|
|
||||||
|
|
||||||
if(m[9]=='g' && m[10]=='r' && m[11]=='e' && m[12]=='n')
|
if(m[9]=='g' && m[10]=='r' && m[12]=='n') { // w_grenade.mdl (Allies)
|
||||||
w_id = newNade ? 13 : 16; // grenade
|
w_id = newNade ? DODW_HANDGRENADE : DODW_HANDGRENADE_EX;
|
||||||
|
} else if(m[9]=='s' && m[10]=='t' && m[11]=='i') { // w_stick.mdl (Axis)
|
||||||
|
w_id = newNade ? DODW_STICKGRENADE : DODW_STICKGRENADE_EX;
|
||||||
|
} else if(m[9]=='m' && m[10]=='i') { // w_mills.mdl (British)
|
||||||
|
w_id = newNade ? DODW_MILLS_BOMB : DODW_HANDGRENADE_EX;
|
||||||
|
// A mills_ex weapon should be added in dlls/dod/dodfun/CMisc.h, plugins/include/dodconst.inc,
|
||||||
|
// and probably dlls/dod/dodx/NBase.cpp. The DODMAX_WEAPONS define should be updated too.
|
||||||
|
}
|
||||||
|
|
||||||
else if(m[9]=='m' && m[10]=='i')
|
if(!w_id) { // Fail-safe, just in case..
|
||||||
w_id = newNade ? 36 : 16 ; // mills ; should I add mills_grenade_ex weapon ?
|
|
||||||
|
|
||||||
else if(m[9]=='s' && m[10]=='t' && m[11]=='i')
|
|
||||||
w_id = newNade ? 14 : 15; // stick
|
|
||||||
|
|
||||||
if(!w_id)
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
|
}
|
||||||
|
|
||||||
if(w_id == 13 || w_id == 14 || w_id == 15 || w_id == 16 || w_id == 36)
|
MF_ExecuteForward(iFGrenade, pPlayer->index, ENTINDEX(e), w_id); // Call grenade_throw() event
|
||||||
{
|
|
||||||
MF_ExecuteForward(iFGrenade, pPlayer->index, ENTINDEX(e), w_id);
|
|
||||||
|
|
||||||
/* fuse start */
|
/* fuse start */
|
||||||
if(pPlayer->fuseSet)
|
if(pPlayer->fuseSet) {
|
||||||
{
|
|
||||||
if(newNade)
|
if(newNade) {
|
||||||
{
|
|
||||||
if(pPlayer->fuseType & 1<<0)
|
if(pPlayer->fuseType & 1<<0) {
|
||||||
{
|
|
||||||
e->v.dmgtime += pPlayer->nadeFuse - 5.0;
|
e->v.dmgtime += pPlayer->nadeFuse - 5.0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float fExp = e->v.dmgtime - gpGlobals->time;
|
float fExp = e->v.dmgtime - gpGlobals->time;
|
||||||
e->v.dmgtime += pPlayer->nadeFuse - fExp;
|
e->v.dmgtime += pPlayer->nadeFuse - fExp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* fuse end */
|
/* fuse end */
|
||||||
}
|
|
||||||
|
} else if(gPlayerRocket && strstr(m, "rocket")) {
|
||||||
|
|
||||||
|
// Since "rocket" exists in the model name, there are only 3 possibilities.
|
||||||
|
if(m[9]=='b') { // w_bazooka_rocket.mdl (Allies)
|
||||||
|
w_id = DODW_BAZOOKA;
|
||||||
|
} else if(m[10]=='s') { // w_pschreck_rocket.mdl (Axis)
|
||||||
|
w_id = DODW_PANZERSCHRECK;
|
||||||
|
} else if(m[10]=='i') { // w_piat_rocket.mdl (British)
|
||||||
|
w_id = DODW_PIAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(strstr(m, "rocket") && gPlayerRocket)
|
MF_ExecuteForward(iFRocket, gPlayerRocket->index, ENTINDEX(e), w_id); // Call rocket_shoot() event
|
||||||
{
|
|
||||||
if(strstr(m, "bazooka"))
|
|
||||||
w_id = 29;
|
|
||||||
|
|
||||||
else if(strstr(m, "piat"))
|
|
||||||
w_id = 30;
|
|
||||||
|
|
||||||
else if(strstr(m, "pschreck"))
|
|
||||||
w_id = 31;
|
|
||||||
|
|
||||||
MF_ExecuteForward(iFRocket, gPlayerRocket->index, ENTINDEX(e), w_id);
|
|
||||||
|
|
||||||
gPlayerRocket = NULL;
|
gPlayerRocket = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user