Merge branch 'master' into Mario/monsters
authorMario <mario@smbclan.net>
Sun, 17 Mar 2019 09:54:59 +0000 (19:54 +1000)
committerMario <mario@smbclan.net>
Sun, 17 Mar 2019 09:54:59 +0000 (19:54 +1000)
# Conflicts:
# qcsrc/client/csqcmodel_hooks.qc
# qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc
# qcsrc/common/monsters/monster/mage.qc
# qcsrc/common/monsters/monster/shambler.qc
# qcsrc/common/monsters/sv_monsters.qc

18 files changed:
1  2 
qcsrc/client/csqcmodel_hooks.qc
qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc
qcsrc/common/mapobjects/func/breakable.qc
qcsrc/common/monsters/monster/golem.qc
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/monster/wyvern.qc
qcsrc/common/monsters/monster/zombie.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/notifications/all.inc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/menu/xonotic/util.qc
qcsrc/server/autocvars.qh
qcsrc/server/command/common.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc

index b5e0ff5d5da3d97fd64f993ca2e5c39edd90f98d,939e5d77fa80dd57c4ae4c7bb4382f413c85917d..16f89af0208ebd940ddb2ad01350bc62dd53263e
@@@ -610,10 -606,10 +608,10 @@@ void CSQCModel_Hook_PreDraw(entity this
        else
                this.drawmask = MASK_NORMAL;
  
-       if(this.isplayermodel && this.drawmask) // this checks if it's a player MODEL!
+       if((this.isplayermodel & ISPLAYER_MODEL) && this.drawmask) // this checks if it's a player MODEL!
        {
-               CSQCPlayer_ModelAppearance_Apply(this, this.entnum == player_localnum + 1);
+               CSQCPlayer_ModelAppearance_Apply(this, (this.isplayermodel & ISPLAYER_LOCAL));
 -              CSQCPlayer_LOD_Apply(this);
 +              CSQCPlayer_LOD_Apply(this, true);
  
                if(!isplayer)
                {
index 5b61762784070e68fa395bb2b94be3e43a82572a,31c5711424834925e91cb53e21d64da6ea2e9e39..1e54617219ffa492b44468b0b06b49309093e01e
@@@ -261,9 -286,9 +261,9 @@@ bool Invasion_CheckWinner(
                return 1;
        }
  
 -      float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0;
 +      float total_alive_monsters = 0, supermonster_count = 0;
  
-       IL_EACH(g_monsters, GetResourceAmount(it, RESOURCE_HEALTH) > 0,
+       IL_EACH(g_monsters, GetResource(it, RES_HEALTH) > 0,
        {
                if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
                        ++supermonster_count;
index f75a8050e86440bd2ac107b702398e91dec31511,0000000000000000000000000000000000000000..9a181386f7c64fb2e73208ac6a10f1d5f7ec52ab
mode 100644,000000..100644
--- /dev/null
@@@ -1,294 -1,0 +1,294 @@@
-       if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
 +#include "golem.qh"
 +
 +#ifdef SVQC
 +float autocvar_g_monster_golem_health;
 +float autocvar_g_monster_golem_damageforcescale = 0.1;
 +float autocvar_g_monster_golem_attack_smash_damage;
 +float autocvar_g_monster_golem_attack_smash_force = 100;
 +float autocvar_g_monster_golem_attack_smash_range = 200;
 +float autocvar_g_monster_golem_attack_claw_damage;
 +float autocvar_g_monster_golem_attack_lightning_damage;
 +float autocvar_g_monster_golem_attack_lightning_damage_zap = 15;
 +float autocvar_g_monster_golem_attack_lightning_force;
 +float autocvar_g_monster_golem_attack_lightning_radius;
 +float autocvar_g_monster_golem_attack_lightning_radius_zap;
 +float autocvar_g_monster_golem_attack_lightning_speed;
 +float autocvar_g_monster_golem_attack_lightning_speed_up;
 +float autocvar_g_monster_golem_speed_stop;
 +float autocvar_g_monster_golem_speed_run;
 +float autocvar_g_monster_golem_speed_walk;
 +
 +/*
 +const float golem_anim_stand          = 0;
 +const float golem_anim_walk           = 1;
 +const float golem_anim_run            = 2;
 +const float golem_anim_smash          = 3;
 +const float golem_anim_swingr = 4;
 +const float golem_anim_swingl = 5;
 +const float golem_anim_magic          = 6;
 +const float golem_anim_pain           = 7;
 +const float golem_anim_death          = 8;
 +*/
 +
 +.float golem_lastattack; // delay attacks separately
 +
 +void M_Golem_Attack_Smash(entity this)
 +{
 +      makevectors(this.angles);
 +      Send_Effect(EFFECT_EXPLOSION_MEDIUM, (this.origin + (v_forward * 150)) - ('0 0 1' * this.maxs.z), '0 0 0', 1);
 +      sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 +
 +      vector loc = this.origin + v_forward * 50;
 +
 +      entity dmgent = spawn();
 +      dmgent.owner = dmgent.realowner = this;
 +      setorigin(dmgent, loc);
 +      RadiusDamage (dmgent, this, (autocvar_g_monster_golem_attack_smash_damage) * MONSTER_SKILLMOD(this), (autocvar_g_monster_golem_attack_smash_damage * 0.5) * MONSTER_SKILLMOD(this), 
 +                                      autocvar_g_monster_golem_attack_smash_range, this, NULL, autocvar_g_monster_golem_attack_smash_force, DEATH_MONSTER_GOLEM_SMASH.m_id, DMG_NOWEP, NULL);
 +      delete(dmgent);
 +}
 +
 +void M_Golem_Attack_Swing(entity this)
 +{
 +      Monster_Attack_Melee(this, this.enemy, (autocvar_g_monster_golem_attack_claw_damage), ((random() >= 0.5) ? this.anim_melee2 : this.anim_melee3), this.attack_range, 0.8, DEATH_MONSTER_GOLEM_CLAW.m_id, true);
 +}
 +
 +#include <common/effects/qc/_mod.qh>
 +
 +void M_Golem_Attack_Lightning_Explode(entity this, entity directhitentity)
 +{
 +      sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
 +      Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
 +
 +      this.event_damage = func_null;
 +      this.takedamage = DAMAGE_NO;
 +      set_movetype(this, MOVETYPE_NONE);
 +      this.velocity = '0 0 0';
 +
 +      if(this.move_movetype == MOVETYPE_NONE)
 +              this.velocity = this.oldvelocity;
 +
 +      RadiusDamage (this, this.realowner, (autocvar_g_monster_golem_attack_lightning_damage), (autocvar_g_monster_golem_attack_lightning_damage), (autocvar_g_monster_golem_attack_lightning_radius),
 +                                      NULL, NULL, (autocvar_g_monster_golem_attack_lightning_force), this.projectiledeathtype, DMG_NOWEP, directhitentity);
 +
 +      FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_golem_attack_lightning_radius_zap, it != this.realowner && it.takedamage,
 +      {
 +              te_csqc_lightningarc(this.origin, it.origin);
 +              Damage(it, this, this.realowner, (autocvar_g_monster_golem_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_GOLEM_ZAP.m_id, DMG_NOWEP, it.origin, '0 0 0');
 +      });
 +
 +      setthink(this, SUB_Remove);
 +      this.nextthink = time + 0.2;
 +}
 +
 +void M_Golem_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
 +{
 +      M_Golem_Attack_Lightning_Explode(this, trigger);
 +}
 +
 +void M_Golem_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 +{
-       TakeResource(this, RESOURCE_HEALTH, damage);
++      if (GetResource(this, RES_HEALTH) <= 0)
 +              return;
 +
 +      if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
 +              return; // g_projectiles_damage says to halt
 +
-       if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
++      TakeResource(this, RES_HEALTH, damage);
 +
-       SetResourceAmountExplicit(gren, RESOURCE_HEALTH, 50);
++      if (GetResource(this, RES_HEALTH) <= 0)
 +              W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
 +}
 +
 +void M_Golem_Attack_Lightning_Touch(entity this, entity toucher)
 +{
 +      PROJECTILE_TOUCH(this, toucher);
 +
 +      this.use(this, NULL, toucher);
 +}
 +
 +void M_Golem_Attack_Lightning_Think(entity this)
 +{
 +      this.nextthink = time;
 +      if (time > this.cnt)
 +      {
 +              M_Golem_Attack_Lightning_Explode(this, NULL);
 +              return;
 +      }
 +}
 +
 +void M_Golem_Attack_Lightning(entity this)
 +{
 +      entity gren;
 +
 +      monster_makevectors(this, this.enemy);
 +
 +      gren = new(grenade);
 +      gren.owner = gren.realowner = this;
 +      gren.bot_dodge = true;
 +      gren.bot_dodgerating = (autocvar_g_monster_golem_attack_lightning_damage);
 +      set_movetype(gren, MOVETYPE_BOUNCE);
 +      PROJECTILE_MAKETRIGGER(gren);
 +      gren.projectiledeathtype = DEATH_MONSTER_GOLEM_ZAP.m_id;
 +      setorigin(gren, CENTER_OR_VIEWOFS(this));
 +      setsize(gren, '-8 -8 -8', '8 8 8');
 +      gren.scale = 2.5;
 +
 +      gren.cnt = time + 5;
 +      gren.nextthink = time;
 +      setthink(gren, M_Golem_Attack_Lightning_Think);
 +      gren.use = M_Golem_Attack_Lightning_Explode_use;
 +      settouch(gren, M_Golem_Attack_Lightning_Touch);
 +
 +      gren.takedamage = DAMAGE_YES;
-     if(!GetResourceAmount(actor, RESOURCE_HEALTH)) SetResourceAmountExplicit(actor, RESOURCE_HEALTH, autocvar_g_monster_golem_health);
++      SetResourceExplicit(gren, RES_HEALTH, 50);
 +      gren.damageforcescale = 0;
 +      gren.event_damage = M_Golem_Attack_Lightning_Damage;
 +      gren.damagedbycontents = true;
 +      IL_PUSH(g_damagedbycontents, gren);
 +      gren.missile_flags = MIF_SPLASH | MIF_ARC;
 +      W_SetupProjVelocity_Explicit(gren, v_forward, v_up, (autocvar_g_monster_golem_attack_lightning_speed), (autocvar_g_monster_golem_attack_lightning_speed_up), 0, 0, false);
 +
 +      gren.angles = vectoangles (gren.velocity);
 +      gren.flags = FL_PROJECTILE;
 +      IL_PUSH(g_projectiles, gren);
 +      IL_PUSH(g_bot_dodge, gren);
 +
 +      CSQCProjectile(gren, true, PROJECTILE_GOLEM_LIGHTNING, true);
 +}
 +
 +.int state;
 +
 +bool M_Golem_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
 +{
 +      switch(attack_type)
 +      {
 +              case MONSTER_ATTACK_MELEE:
 +              {
 +                      setanim(actor, ((random() >= 0.5) ? actor.anim_melee2 : actor.anim_melee3), false, true, true);
 +                      int swing_cnt = bound(1, floor(random() * 4), 3);
 +                      Monster_Delay(actor, swing_cnt, 0.5, M_Golem_Attack_Swing);
 +                      actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay
 +                      return true;
 +              }
 +              case MONSTER_ATTACK_RANGED:
 +              {
 +                      float randomness = random();
 +
 +                      if(time < actor.golem_lastattack || !IS_ONGROUND(actor))
 +                              return false;
 +
 +                      if(randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_golem_attack_smash_range))
 +                      {
 +                              setanim(actor, actor.anim_melee1, false, true, true);
 +                              Monster_Delay(actor, 1, 1.1, M_Golem_Attack_Smash);
 +                              if(actor.animstate_endtime > time)
 +                                      actor.anim_finished = actor.animstate_endtime;
 +                              else
 +                                      actor.anim_finished = time + 1.2;
 +                              actor.attack_finished_single[0] = actor.anim_finished + 0.2;
 +                              actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
 +                              actor.golem_lastattack = time + 3 + random() * 1.5;
 +                              return true;
 +                      }
 +                      else if(randomness <= 0.1 && vdist(actor.enemy.origin - actor.origin, >=, autocvar_g_monster_golem_attack_smash_range * 1.5)) // small chance, don't want this spammed
 +                      {
 +                              setanim(actor, actor.anim_melee2, true, true, false);
 +                              actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
 +                              actor.attack_finished_single[0] = time + 1.1;
 +                              actor.anim_finished = 1.1;
 +                              actor.golem_lastattack = time + 3 + random() * 1.5;
 +                              Monster_Delay(actor, 1, 0.6, M_Golem_Attack_Lightning);
 +                              return true;
 +                      }
 +
 +                      return false;
 +              }
 +      }
 +
 +      return false;
 +}
 +
 +spawnfunc(monster_golem) { Monster_Spawn(this, true, MON_GOLEM.monsterid); }
 +// compatibility
 +spawnfunc(monster_shambler) { spawnfunc_monster_golem(this); }
 +#endif // SVQC
 +
 +#ifdef SVQC
 +METHOD(Golem, mr_think, bool(Golem this, entity actor))
 +{
 +    TC(Golem, this);
 +    return true;
 +}
 +
 +METHOD(Golem, mr_pain, float(Golem this, entity actor, float damage_take, entity attacker, float deathtype))
 +{
 +    TC(Golem, this);
 +    actor.pain_finished = time + 0.5;
 +    setanim(actor, ((random() >= 0.5) ? actor.anim_pain2 : actor.anim_pain1), true, true, false);
 +    return damage_take;
 +}
 +
 +METHOD(Golem, mr_death, bool(Golem this, entity actor))
 +{
 +    TC(Golem, this);
 +    setanim(actor, actor.anim_die1, false, true, true);
 +    return true;
 +}
 +#endif
 +#ifdef GAMEQC
 +METHOD(Golem, mr_anim, bool(Golem this, entity actor))
 +{
 +    TC(Golem, this);
 +    vector none = '0 0 0';
 +    actor.anim_idle = animfixfps(actor, '0 1 1', none);
 +    actor.anim_walk = animfixfps(actor, '1 1 1', none);
 +    actor.anim_run = animfixfps(actor, '2 1 1', none);
 +    //actor.anim_melee1 = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
 +    actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
 +    actor.anim_melee3 = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
 +    //actor.anim_melee4 = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
 +    actor.anim_melee1 = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
 +    actor.anim_pain1 = animfixfps(actor, '7 1 2', none); // 0.5 seconds
 +    actor.anim_pain2 = animfixfps(actor, '8 1 2', none); // 0.5 seconds
 +    //actor.anim_pain3 = animfixfps(actor, '9 1 2', none); // 0.5 seconds
 +    //actor.anim_pain4 = animfixfps(actor, '10 1 2', none); // 0.5 seconds
 +    //actor.anim_pain5 = animfixfps(actor, '11 1 2', none); // 0.5 seconds
 +    actor.anim_spawn = animfixfps(actor, '12 1 5', none); // analyze models and set framerate
 +    actor.anim_die1 = animfixfps(actor, '13 1 0.5', none); // 2 seconds
 +    //actor.anim_dead = animfixfps(actor, '14 1 0.5', none); // 2 seconds
 +    actor.anim_die2 = animfixfps(actor, '15 1 0.5', none); // 2 seconds
 +    // dead2 16
 +    //actor.anim_dieback = animfixfps(actor, '16 1 0.5', none); // 2 seconds
 +    //actor.anim_deadback = animfixfps(actor, '17 1 0.5', none); // 2 seconds
 +    //actor.anim_dead2 = animfixfps(actor, '18 1 0.5', none); // 2 seconds
 +    //actor.anim_dead3 = animfixfps(actor, '19 1 0.5', none); // 2 seconds
 +    //actor.anim_dead4 = animfixfps(actor, '20 1 0.5', none); // 2 seconds
 +    //actor.anim_dead5 = animfixfps(actor, '21 1 0.5', none); // 2 seconds
 +    //actor.anim_dead6 = animfixfps(actor, '22 1 0.5', none); // 2 seconds
 +    return true;
 +}
 +#endif
 +#ifdef SVQC
 +.float animstate_endtime;
 +METHOD(Golem, mr_setup, bool(Golem this, entity actor))
 +{
 +    TC(Golem, this);
++    if(!GetResource(actor, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_golem_health);
 +    if(!actor.attack_range) actor.attack_range = 150;
 +    if(!actor.speed) { actor.speed = (autocvar_g_monster_golem_speed_walk); }
 +    if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_golem_speed_run); }
 +    if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_golem_speed_stop); }
 +    if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_golem_damageforcescale); }
 +
 +    actor.monster_loot = ITEM_HealthMega;
 +    actor.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX
 +
 +    setanim(actor, actor.anim_spawn, false, true, true);
 +    actor.spawn_time = actor.animstate_endtime;
 +    actor.spawnshieldtime = actor.spawn_time;
 +    actor.monster_attackfunc = M_Golem_Attack;
 +
 +    return true;
 +}
 +#endif
index f2de0602bc3481188cd45fb1bf4af5a090a6bcc9,86e780e0a4657aa523489eb0b9ad82bc7bf9f698..b2dba6a99cebf1ad63f21cfcec641fcb3414ebd2
@@@ -247,11 -241,11 +247,11 @@@ void M_Mage_Defend_Heal(entity this
                                }
                                case 1:
                                {
-                                       if(GetResourceAmount(it, RESOURCE_CELLS)) GiveResourceWithLimit(it, RESOURCE_CELLS, 1, g_pickup_cells_max);
-                                       if(GetResourceAmount(it, RESOURCE_PLASMA)) GiveResourceWithLimit(it, RESOURCE_PLASMA, 1, g_pickup_plasma_max);
-                                       if(GetResourceAmount(it, RESOURCE_ROCKETS)) GiveResourceWithLimit(it, RESOURCE_ROCKETS, 1, g_pickup_rockets_max);
-                                       if(GetResourceAmount(it, RESOURCE_SHELLS)) GiveResourceWithLimit(it, RESOURCE_SHELLS, 2, g_pickup_shells_max);
-                                       if(GetResourceAmount(it, RESOURCE_BULLETS)) GiveResourceWithLimit(it, RESOURCE_BULLETS, 5, g_pickup_nails_max);
 -                                      if(GetResource(this, RES_CELLS)) GiveResourceWithLimit(it, RES_CELLS, 1, g_pickup_cells_max);
 -                                      if(GetResource(this, RES_PLASMA)) GiveResourceWithLimit(it, RES_PLASMA, 1, g_pickup_plasma_max);
 -                                      if(GetResource(this, RES_ROCKETS)) GiveResourceWithLimit(it, RES_ROCKETS, 1, g_pickup_rockets_max);
 -                                      if(GetResource(this, RES_SHELLS)) GiveResourceWithLimit(it, RES_SHELLS, 2, g_pickup_shells_max);
 -                                      if(GetResource(this, RES_BULLETS)) GiveResourceWithLimit(it, RES_BULLETS, 5, g_pickup_nails_max);
++                                      if(GetResource(it, RES_CELLS)) GiveResourceWithLimit(it, RES_CELLS, 1, g_pickup_cells_max);
++                                      if(GetResource(it, RES_PLASMA)) GiveResourceWithLimit(it, RES_PLASMA, 1, g_pickup_plasma_max);
++                                      if(GetResource(it, RES_ROCKETS)) GiveResourceWithLimit(it, RES_ROCKETS, 1, g_pickup_rockets_max);
++                                      if(GetResource(it, RES_SHELLS)) GiveResourceWithLimit(it, RES_SHELLS, 2, g_pickup_shells_max);
++                                      if(GetResource(it, RES_BULLETS)) GiveResourceWithLimit(it, RES_BULLETS, 5, g_pickup_nails_max);
                                        // TODO: fuel?
                                        fx = EFFECT_AMMO_REGEN;
                                        break;
@@@ -361,10 -332,10 +361,10 @@@ void M_Mage_Defend_Shield(entity this
  {
        this.effects |= (EF_ADDITIVE | EF_BLUE);
        this.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay);
-       SetResourceAmountExplicit(this, RESOURCE_ARMOR, autocvar_g_monster_mage_shield_blockpercent);
+       SetResourceExplicit(this, RES_ARMOR, autocvar_g_monster_mage_shield_blockpercent);
        this.mage_shield_time = time + (autocvar_g_monster_mage_shield_time);
        setanim(this, this.anim_shoot, true, true, true);
 -      this.attack_finished_single[0] = time + 1;
 +      this.attack_finished_single[0] = time + 1; // give just a short cooldown on attacking
        this.anim_finished = time + 1;
  }
  
index 57e1c3015d644208208c8204444e80ef6029fdb3,97a68b5f8f92877e95d115b0bf6c50d03b804088..54f1d81cc1558b852bea048465fe234b6f5b86c7
@@@ -583,7 -559,8 +583,7 @@@ vector Monster_Move_Target(entity this
                WarpZone_TraceLine(this.origin, targ_origin, MOVE_NOMONSTERS, this);
  
                // cases where the enemy may have changed their state (don't need to check everything here)
-               if(    (IS_DEAD(this.enemy) || GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 1)
 -              if((!this.enemy)
 -                      || (IS_DEAD(this.enemy) || GetResource(this.enemy, RES_HEALTH) < 1)
++              if(    (IS_DEAD(this.enemy) || GetResource(this.enemy, RES_HEALTH) < 1)
                        || (STAT(FROZEN, this.enemy))
                        || (this.enemy.flags & FL_NOTARGET)
                        || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
@@@ -783,20 -795,20 +783,22 @@@ void Monster_Move(entity this, float ru
        if(!(this.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(this.flags & FL_SWIM))
                this.moveto_z = this.origin_z;
  
 -      if(vdist(this.origin - this.moveto, >, 100))
 +      fixedmakevectors(this.angles);
 +      float vz = this.velocity_z;
 +
 +      if(!turret_closetotarget(this, this.moveto, 16))
        {
                bool do_run = (this.enemy || this.monster_moveto);
 -              if(IS_ONGROUND(this) || ((this.flags & FL_FLY) || (this.flags & FL_SWIM)))
 -                      Monster_CalculateVelocity(this, this.moveto, this.origin, true, ((do_run) ? runspeed : walkspeed));
 +              movelib_move_simple(this, v_forward, ((do_run) ? runspeed : walkspeed), 0.4);
  
 -              if(time > this.pain_finished && time > this.anim_finished) // TODO: use anim_finished instead!?
 +              if(time > this.pain_finished && time > this.anim_finished)
                if(!this.state)
-               if(vdist(this.velocity, >, 10))
-                       setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false);
-               else
-                       setanim(this, this.anim_idle, true, false, false);
+               {
+                       if(vdist(this.velocity, >, 10))
+                               setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false);
+                       else
+                               setanim(this, this.anim_idle, true, false, false);
+               }
        }
        else
        {
@@@ -1264,9 -1271,8 +1268,9 @@@ bool Monster_Spawn_Setup(entity this
                        this.skin = rint(random() * 4);
        }
  
-       this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+       this.max_health = GetResource(this, RES_HEALTH);
        this.pain_finished = this.nextthink;
 +      this.last_enemycheck = this.spawn_time + random(); // slight delay
  
        if(IS_PLAYER(this.monster_follow))
                this.effects |= EF_DIMLIGHT;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge