From: Mario Date: Tue, 21 Jan 2020 20:35:01 +0000 (+1000) Subject: Merge branch 'master' into Mario/monsters X-Git-Tag: xonotic-v0.8.5~7^2~1^2~22 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fe65404b4515e2f7db18a71c9953f318003b214e;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into Mario/monsters --- fe65404b4515e2f7db18a71c9953f318003b214e diff --cc qcsrc/common/monsters/monster/spider.qc index 7d021f4c26,d9a51c05e9..518b93035d --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@@ -59,17 -58,15 +59,18 @@@ METHOD(SpiderAttack, wr_think, void(Spi 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); diff --cc qcsrc/server/miscfunctions.qc index 4c5bef5979,6e2bbb8d7c..14f704f547 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@@ -1257,20 -1274,18 +1274,18 @@@ string uid2name(string myuid 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; @@@ -1315,43 -1330,35 +1330,43 @@@ 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; @@@ -1383,16 -1390,15 +1398,15 @@@ { 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)