TC(SpiderAttack, thiswep);
bool isPlayer = IS_PLAYER(actor);
if (fire & 1)
- if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay)) {
+ if ((!isPlayer && time >= actor.spider_web_delay) || (isPlayer && weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay))) {
if (!isPlayer) {
- actor.spider_web_delay = time + 3;
+ actor.spider_web_delay = time + autocvar_g_monster_spider_attack_web_delay;
setanim(actor, actor.anim_shoot, true, true, true);
- actor.attack_finished_single[0] = time + (autocvar_g_monster_spider_attack_web_delay);
- actor.anim_finished = time + 1;
+ if(actor.animstate_endtime > time)
+ actor.anim_finished = actor.animstate_endtime;
+ else
+ actor.anim_finished = time + 1;
+ actor.attack_finished_single[0] = actor.anim_finished + 0.2;
}
if (isPlayer) actor.enemy = Monster_FindTarget(actor);
+ monster_makevectors(actor, actor.enemy);
W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_SPIDER.m_id);
if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
M_Spider_Attack_Web(actor);
return s;
}
-bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance)
+bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance, bool frompos)
{
- float m, i;
- vector start, org, delta, end, enddown, mstart;
-
- m = e.dphitcontentsmask;
+ float m = e.dphitcontentsmask;
e.dphitcontentsmask = goodcontents | badcontents;
- org = boundmin;
- delta = boundmax - boundmin;
+ vector org = boundmin;
+ vector delta = boundmax - boundmin;
+ vector start, end;
start = end = org;
-
- for (i = 0; i < attempts; ++i)
+ int j; // used after the loop
+ for(j = 0; j < attempts; ++j)
{
start.x = org.x + random() * delta.x;
start.y = org.y + random() * delta.y;
if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
continue;
- // rule 4: we must "see" some spawnpoint or item
- entity sp = NULL;
- if(frompos)
- {
- if((traceline(mstart, e.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
- sp = e;
- }
- if(!sp)
- {
- IL_EACH(g_spawnpoints, checkpvs(mstart, it),
+ // rule 4: we must "see" some spawnpoint or item
+ entity sp = NULL;
- IL_EACH(g_spawnpoints, checkpvs(mstart, it),
++ if(frompos)
{
-- if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
-- {
-- sp = it;
-- break;
-- }
-- });
- }
- if(!sp)
- {
- int items_checked = 0;
- IL_EACH(g_items, checkpvs(mstart, it),
++ if((traceline(mstart, e.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
++ sp = e;
++ }
++ if(!sp)
++ {
++ IL_EACH(g_spawnpoints, checkpvs(mstart, it),
++ {
++ if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
++ {
++ sp = it;
++ break;
++ }
++ });
++ }
+ if(!sp)
{
- if((traceline(mstart, it.origin + (it.mins + it.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
+ int items_checked = 0;
+ IL_EACH(g_items, checkpvs(mstart, it),
{
- sp = it;
- break;
- }
+ if((traceline(mstart, it.origin + (it.mins + it.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
+ {
+ sp = it;
+ break;
+ }
- ++items_checked;
- if(items_checked >= attempts)
- break; // sanity
- });
+ ++items_checked;
+ if(items_checked >= attempts)
+ break; // sanity
+ });
- if(!sp)
- continue;
- }
+ if(!sp)
+ continue;
+ }
// find a random vector to "look at"
end.x = org.x + random() * delta.x;
{
setorigin(e, start);
e.angles = vectoangles(end - start);
- LOG_DEBUG("Needed ", ftos(i + 1), " attempts");
+ LOG_DEBUG("Needed ", ftos(j + 1), " attempts");
return true;
}
- else
- return false;
+ return false;
}
-float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
+bool MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance)
{
- return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance);
+ return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance, false);
}
void write_recordmarker(entity pl, float tstart, float dt)