From 02968c1a2d49ccb1d7032dc35878fb5f57c8f775 Mon Sep 17 00:00:00 2001 From: Lucas GAUTHERON Date: Thu, 25 Aug 2011 14:28:41 +0000 Subject: [PATCH] onAttack (bukz: update if you want to pass more parameters) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6613 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/weapon.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index df5e9593..e6e91785 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -378,6 +378,15 @@ struct hitweap }; hitweap accuracym[NUMGUNS]; +inline void attackevent(playerent *owner, int weapon) +{ + if(owner == player1 && identexists("onAttack")) + { + defformatstring(onattackevent)("onAttack %d", weapon); + execute(onattackevent); + } +} + vector hits; void hit(int damage, playerent *d, playerent *at, const vec &vel, int gun, bool gib, int info) @@ -1024,8 +1033,12 @@ bool grenades::attack(vec &targ) switch(state) { case GST_NONE: - if(waitdone && owner->attacking && this==owner->weaponsel) activatenade(to); // activate - break; + if(waitdone && owner->attacking && this==owner->weaponsel) + { + attackevent(owner, type); + activatenade(to); // activate + } + break; case GST_INHAND: if(waitdone || ( quicknade && quickwait ) ) @@ -1195,6 +1208,8 @@ bool gun::attack(vec &targ) mag--; sendshoot(from, to, attackmillis); + + attackevent(owner, type); return true; } @@ -1524,6 +1539,8 @@ bool knife::attack(vec &targ) attackfx(from, to, 0); sendshoot(from, to, attackmillis); gunwait = info.attackdelay; + + attackevent(owner, type); return true; }