]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/golem.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / golem.qc
index 9a420aa24408f308d50584f62df3f10d618f41c3..a9d9224dad59a66958caf4dd9ebdaa001138e405 100644 (file)
@@ -4,7 +4,8 @@
 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_range;
+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;
@@ -37,12 +38,14 @@ void M_Golem_Attack_Smash(entity this)
        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);
 
-       // RadiusDamage does NOT support custom starting location, which means we must use this hack...
+       vector loc = this.origin + v_forward * 50;
 
-       tracebox(this.origin + v_forward * 50, this.mins * 0.5, this.maxs * 0.5, this.origin + v_forward * autocvar_g_monster_golem_attack_smash_range, MOVE_NORMAL, this);
-
-       if(trace_ent.takedamage)
-               Damage(trace_ent, this, this, (autocvar_g_monster_golem_attack_smash_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_GOLEM_SMASH.m_id, trace_ent.origin, normalize(trace_ent.origin - this.origin));
+       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)
@@ -50,7 +53,7 @@ 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/all.qh>
+#include <common/effects/qc/_mod.qh>
 
 void M_Golem_Attack_Lightning_Explode(entity this, entity directhitentity)
 {
@@ -66,12 +69,12 @@ void M_Golem_Attack_Lightning_Explode(entity this, entity directhitentity)
                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, directhitentity);
+                                       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, it.origin, '0 0 0');
+               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);
@@ -83,17 +86,17 @@ void M_Golem_Attack_Lightning_Explode_use(entity this, entity actor, entity trig
        M_Golem_Attack_Lightning_Explode(this, trigger);
 }
 
-void M_Golem_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void M_Golem_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
-       if (this.health <= 0)
+       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
 
-       this.health = this.health - damage;
+       TakeResource(this, RES_HEALTH, damage);
 
-       if (this.health <= 0)
+       if (GetResource(this, RES_HEALTH) <= 0)
                W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
 }
 
@@ -138,7 +141,7 @@ void M_Golem_Attack_Lightning(entity this)
        settouch(gren, M_Golem_Attack_Lightning_Touch);
 
        gren.takedamage = DAMAGE_YES;
-       gren.health = 50;
+       SetResourceExplicit(gren, RES_HEALTH, 50);
        gren.damageforcescale = 0;
        gren.event_damage = M_Golem_Attack_Lightning_Damage;
        gren.damagedbycontents = true;
@@ -162,6 +165,7 @@ bool M_Golem_Attack(int attack_type, entity actor, entity targ, .entity weaponen
        {
                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
@@ -171,21 +175,25 @@ bool M_Golem_Attack(int attack_type, entity actor, entity targ, .entity weaponen
                {
                        float randomness = random();
 
-                       if(time >= actor.golem_lastattack) // golem doesn't attack much
-                       if(IS_ONGROUND(actor))
+                       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_melee2, true, true, false);
-                               Monster_Delay(actor, 1, 0.7, M_Golem_Attack_Smash);
-                               actor.attack_finished_single[0] = time + 1.1;
-                               actor.anim_finished = time + 1.1;
+                               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_shoot, true, true, false);
+                               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;
@@ -201,7 +209,7 @@ bool M_Golem_Attack(int attack_type, entity actor, entity targ, .entity weaponen
        return false;
 }
 
-spawnfunc(monster_golem) { Monster_Spawn(this, true, MON_GOLEM.monsterid); }
+spawnfunc(monster_golem) { Monster_Spawn(this, true, MON_GOLEM); }
 // compatibility
 spawnfunc(monster_shambler) { spawnfunc_monster_golem(this); }
 #endif // SVQC
@@ -217,7 +225,7 @@ METHOD(Golem, mr_pain, float(Golem this, entity actor, float damage_take, entity
 {
     TC(Golem, this);
     actor.pain_finished = time + 0.5;
-    setanim(actor, actor.anim_pain1, true, true, false);
+    setanim(actor, ((random() >= 0.5) ? actor.anim_pain2 : actor.anim_pain1), true, true, false);
     return damage_take;
 }
 
@@ -236,19 +244,21 @@ METHOD(Golem, mr_anim, bool(Golem this, entity actor))
     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_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_sight = animfixfps(actor, '12 1 5', none); // analyze models and set framerate
+    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_die2 = animfixfps(actor, '14 1 0.5', none); // 2 seconds
-    //actor.anim_dead = animfixfps(actor, '15 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
@@ -264,7 +274,7 @@ METHOD(Golem, mr_anim, bool(Golem this, entity actor))
 METHOD(Golem, mr_setup, bool(Golem this, entity actor))
 {
     TC(Golem, this);
-    if(!actor.health) actor.health = (autocvar_g_monster_golem_health);
+    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); }
@@ -274,17 +284,11 @@ METHOD(Golem, mr_setup, bool(Golem this, entity actor))
     actor.monster_loot = ITEM_HealthMega;
     actor.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX
 
-    setanim(actor, actor.anim_shoot, false, true, true);
+    setanim(actor, actor.anim_spawn, false, true, true);
     actor.spawn_time = actor.animstate_endtime;
-    actor.spawnshieldtime = actor.spawn_time;
+    StatusEffects_apply(STATUSEFFECT_SpawnShield, actor, actor.spawn_time, 0);
     actor.monster_attackfunc = M_Golem_Attack;
 
     return true;
 }
-
-METHOD(Golem, mr_precache, bool(Golem this))
-{
-    TC(Golem, this);
-    return true;
-}
 #endif