MCPcopy Create free account
hub / github.com/assaultcube/AC / attack

Method attack

source/src/weapon.cpp:1219–1259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1217bool grenades::busy() { return state!=GST_NONE; }
1218
1219bool grenades::attack(vec &targ)
1220{
1221 int attackmillis = lastmillis-owner->lastaction;
1222 vec &vel = targ;
1223
1224 bool waitdone = attackmillis>=gunwait && !(m_arena && m_teammode && arenaintermission);
1225 if(waitdone) gunwait = reloading = 0;
1226
1227 switch(state)
1228 {
1229 case GST_NONE:
1230 if(waitdone && owner->attacking && this==owner->weaponsel)
1231 {
1232 attackevent(owner, type);
1233 activatenade(vel);
1234 }
1235 break;
1236
1237 case GST_INHAND:
1238 if(waitdone)
1239 {
1240 if(!owner->attacking || this!=owner->weaponsel) thrownade();
1241 else if(!inhandnade->isalive(lastmillis)) dropnade();
1242 }
1243 break;
1244
1245 case GST_THROWING:
1246 if(attackmillis >= throwwait)
1247 {
1248 reset();
1249 if(!mag && this==owner->weaponsel)
1250 {
1251 owner->weaponchanging = lastmillis-1-(weaponchangetime/2);
1252 owner->nextweaponsel = owner->weaponsel = owner->primweap;
1253 }
1254 return false;
1255 }
1256 break;
1257 }
1258 return true;
1259}
1260
1261void grenades::attackfx(const vec &from, const vec &vel, int millis) // other player's grenades
1262{

Callers 2

checkweaponswitchFunction · 0.80
shootFunction · 0.80

Calls 12

attackeventFunction · 0.85
minFunction · 0.85
updatelastactionFunction · 0.85
raydamageFunction · 0.85
attackFunction · 0.85
intersectgeometryFunction · 0.85
playsoundMethod · 0.80
setsizeMethod · 0.80
distMethod · 0.80
mulMethod · 0.80
isaliveMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected