]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/spider.qc
Merge breaking changes for 0.8.5 into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / spider.qc
index 3f3e65d4a3dee63da2cb3d91bdf08871a7146552..0d0936eabb530a298930a56e830514f0a41e66b7 100644 (file)
@@ -5,16 +5,20 @@
 #endif
 
 #ifdef SVQC
-
-.float spider_web_delay;
-
+float autocvar_g_monster_spider_health;
+float autocvar_g_monster_spider_damageforcescale = 0.6;
+float autocvar_g_monster_spider_attack_bite_damage;
+float autocvar_g_monster_spider_attack_bite_delay;
 float autocvar_g_monster_spider_attack_web_damagetime;
 float autocvar_g_monster_spider_attack_web_speed;
 float autocvar_g_monster_spider_attack_web_speed_up;
 float autocvar_g_monster_spider_attack_web_delay;
+float autocvar_g_monster_spider_attack_web_range = 800;
+float autocvar_g_monster_spider_speed_stop;
+float autocvar_g_monster_spider_speed_run;
+float autocvar_g_monster_spider_speed_walk;
 
-float autocvar_g_monster_spider_attack_bite_damage;
-float autocvar_g_monster_spider_attack_bite_delay;
+.float spider_web_delay;
 
 void M_Spider_Attack_Web(entity this);
 
@@ -45,12 +49,15 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity
     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);
@@ -71,19 +78,6 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity
     }
 }
 
-float autocvar_g_monster_spider_health;
-float autocvar_g_monster_spider_damageforcescale = 0.6;
-float autocvar_g_monster_spider_speed_stop;
-float autocvar_g_monster_spider_speed_run;
-float autocvar_g_monster_spider_speed_walk;
-
-/*
-const float spider_anim_idle           = 0;
-const float spider_anim_walk           = 1;
-const float spider_anim_attack         = 2;
-const float spider_anim_attack2                = 3;
-*/
-
 void M_Spider_Attack_Web_Explode(entity this)
 {
        if(this)
@@ -162,8 +156,11 @@ bool M_Spider_Attack(int attack_type, entity actor, entity targ, .entity weapone
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       wep.wr_think(wep, actor, weaponentity, 1);
-                       return true;
+                       if(vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_spider_attack_web_range))
+                       {
+                               wep.wr_think(wep, actor, weaponentity, 1);
+                               return true;
+                       }
                }
        }
 
@@ -183,14 +180,15 @@ METHOD(Spider, mr_think, bool(Spider this, entity actor))
 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
 {
     TC(Spider, this);
+    setanim(actor, ((random() > 0.5) ? actor.anim_pain2 : actor.anim_pain1), true, true, false);
+    actor.pain_finished = actor.animstate_endtime;
     return damage_take;
 }
 
 METHOD(Spider, mr_death, bool(Spider this, entity actor))
 {
     TC(Spider, this);
-    setanim(actor, actor.anim_melee, false, true, true);
-    actor.angles_x = 180;
+    setanim(actor, ((random() > 0.5) ? actor.anim_die2 : actor.anim_die1), false, true, true);
     return true;
 }
 #endif
@@ -199,11 +197,25 @@ METHOD(Spider, mr_anim, bool(Spider this, entity actor))
 {
     TC(Spider, this);
     vector none = '0 0 0';
-    actor.anim_walk = animfixfps(actor, '1 1 1', none);
-    actor.anim_idle = animfixfps(actor, '0 1 1', none);
-    actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
-    actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
-    actor.anim_run = animfixfps(actor, '1 1 1', none);
+    actor.anim_melee = animfixfps(actor, '0 1 5', none); // analyze models and set framerate
+    actor.anim_die1 = animfixfps(actor, '1 1 1', none);
+    actor.anim_die2 = animfixfps(actor, '2 1 1', none);
+    actor.anim_shoot = animfixfps(actor, '3 1 1', none);
+    //actor.anim_fire2 = animfixfps(actor, '4 1 1', none);
+    actor.anim_idle = animfixfps(actor, '5 1 1', none);
+    //actor.anim_sight = animfixfps(actor, '6 1 1', none);
+    actor.anim_pain1 = animfixfps(actor, '7 1 1', none);
+    actor.anim_pain2 = animfixfps(actor, '8 1 1', none);
+    //actor.anim_pain3 = animfixfps(actor, '9 1 1', none);
+    actor.anim_walk = animfixfps(actor, '10 1 1', none);
+    actor.anim_run = animfixfps(actor, '10 1 1', none); // temp?
+    //actor.anim_forwardright = animfixfps(actor, '11 1 1', none);
+    //actor.anim_walkright = animfixfps(actor, '12 1 1', none);
+    //actor.anim_walkbackright = animfixfps(actor, '13 1 1', none);
+    //actor.anim_walkback = animfixfps(actor, '14 1 1', none);
+    //actor.anim_walkbackleft = animfixfps(actor, '15 1 1', none);
+    //actor.anim_walkleft = animfixfps(actor, '16 1 1', none);
+    //actor.anim_forwardleft = animfixfps(actor, '17 1 1', none);
     return true;
 }
 #endif