better onReload + documentation
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7460 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -902,6 +902,8 @@ docremark [The alias is executed before the name is effectively changed, so you
|
||||
docident [onPickup] [If defined, this will be executed each time you pick up an item.];
|
||||
docargument [item] [The item that was picked up] [integer (0 = pistol clips, 1 = ammo box, 2 = grenade, 3 = health, 4 = helmet, 5 = armour, 6 = akimbo)] [0];
|
||||
docargument [q] [The quantity that was received] [] [0];
|
||||
docident [onReload] [If defined, this will be executed each time you reload a weapon.];
|
||||
docargument [B] [was autoreload?] [0 (false), 1 (true)] [0];
|
||||
docident [onSpawn] [If defined, this will be executed each time a player spawns.];
|
||||
docargument [player] [The client number of the player who spawned] [integer] [0];
|
||||
docident [onVoteEnd] [If this alias exists it will be run every time a vote passes or fails.];
|
||||
|
||||
@@ -765,7 +765,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
|
||||
{
|
||||
int cn = getint(p), gun = getint(p);
|
||||
playerent *p = getclient(cn);
|
||||
if(p && p!=player1) p->weapons[gun]->reload();
|
||||
if(p && p!=player1) p->weapons[gun]->reload(false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+12
-8
@@ -149,7 +149,7 @@ COMMAND(magreserve, "i");
|
||||
void tryreload(playerent *p)
|
||||
{
|
||||
if(!p || p->state!=CS_ALIVE || p->weaponsel->reloading || p->weaponchanging) return;
|
||||
p->weaponsel->reload();
|
||||
p->weaponsel->reload(false);
|
||||
}
|
||||
|
||||
void selfreload() { tryreload(player1); }
|
||||
@@ -812,7 +812,7 @@ void weapon::attacksound()
|
||||
audiomgr.playsound(info.sound, owner, local ? SP_HIGH : SP_NORMAL);
|
||||
}
|
||||
|
||||
bool weapon::reload()
|
||||
bool weapon::reload(bool autoreloaded)
|
||||
{
|
||||
if(mag>=info.magsize || ammo<=0) return false;
|
||||
updatelastaction(owner);
|
||||
@@ -828,7 +828,11 @@ bool weapon::reload()
|
||||
if(local)
|
||||
{
|
||||
addmsg(SV_RELOAD, "ri2", lastmillis, owner->weaponsel->type);
|
||||
if(identexists("onReload")) execute("onReload");
|
||||
if(identexists("onReload"))
|
||||
{
|
||||
defformatstring(str)("onReload %d", (int)autoreloaded);
|
||||
execute(str);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1270,7 +1274,7 @@ void gun::attackfx(const vec &from, const vec &to, int millis)
|
||||
}
|
||||
|
||||
int gun::modelanim() { return modelattacking() ? ANIM_GUN_SHOOT|ANIM_LOOP : ANIM_GUN_IDLE; }
|
||||
void gun::checkautoreload() { if(autoreload && owner==player1 && !mag) reload(); }
|
||||
void gun::checkautoreload() { if(autoreload && owner==player1 && !mag) reload(true); }
|
||||
|
||||
|
||||
// shotgun
|
||||
@@ -1331,9 +1335,9 @@ void sniperrifle::attackfx(const vec &from, const vec &to, int millis)
|
||||
attacksound();
|
||||
}
|
||||
|
||||
bool sniperrifle::reload()
|
||||
bool sniperrifle::reload(bool autoreloaded)
|
||||
{
|
||||
bool r = weapon::reload();
|
||||
bool r = weapon::reload(autoreloaded);
|
||||
if(owner==player1 && r) { scoped = false; player1->scoping = false; }
|
||||
return r;
|
||||
}
|
||||
@@ -1395,9 +1399,9 @@ cpistol::cpistol(playerent *owner) : gun(owner, GUN_CPISTOL), bursting(false) {}
|
||||
bool cpistol::selectable() { return false; /*return weapon::selectable() && !m_noprimary && this == owner->primweap;*/ }
|
||||
void cpistol::onselecting() { weapon::onselecting(); bursting = false; }
|
||||
void cpistol::ondeselecting() { bursting = false; }
|
||||
bool cpistol::reload()
|
||||
bool cpistol::reload(bool autoreloaded)
|
||||
{
|
||||
bool r = weapon::reload();
|
||||
bool r = weapon::reload(autoreloaded);
|
||||
if(owner==player1 && r) { bursting = false; }
|
||||
return r;
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ struct weapon
|
||||
virtual void attackfx(const vec &from, const vec &to, int millis) = 0;
|
||||
virtual void attackphysics(vec &from, vec &to);
|
||||
virtual void attacksound();
|
||||
virtual bool reload();
|
||||
virtual bool reload(bool autoreloaded);
|
||||
virtual void reset() {}
|
||||
virtual bool busy() { return false; }
|
||||
|
||||
@@ -105,7 +105,7 @@ struct sniperrifle : gun
|
||||
|
||||
sniperrifle(playerent *owner);
|
||||
void attackfx(const vec &from, const vec &to, int millis);
|
||||
bool reload();
|
||||
bool reload(bool autoreloaded);
|
||||
|
||||
int dynspread();
|
||||
float dynrecoil();
|
||||
@@ -147,7 +147,7 @@ struct cpistol : gun
|
||||
{
|
||||
bool bursting;
|
||||
cpistol(playerent *owner);
|
||||
bool reload();
|
||||
bool reload(bool autoreloaded);
|
||||
bool selectable();
|
||||
void onselecting();
|
||||
void ondeselecting();
|
||||
|
||||
Reference in New Issue
Block a user