4 float autocvar_g_monster_shambler_health;
5 float autocvar_g_monster_shambler_damageforcescale = 0.1;
6 float autocvar_g_monster_shambler_attack_smash_damage;
7 float autocvar_g_monster_shambler_attack_smash_range;
8 float autocvar_g_monster_shambler_attack_claw_damage;
9 float autocvar_g_monster_shambler_attack_lightning_damage;
10 float autocvar_g_monster_shambler_attack_lightning_damage_zap = 15;
11 float autocvar_g_monster_shambler_attack_lightning_force;
12 float autocvar_g_monster_shambler_attack_lightning_radius;
13 float autocvar_g_monster_shambler_attack_lightning_radius_zap;
14 float autocvar_g_monster_shambler_attack_lightning_speed;
15 float autocvar_g_monster_shambler_attack_lightning_speed_up;
16 float autocvar_g_monster_shambler_speed_stop;
17 float autocvar_g_monster_shambler_speed_run;
18 float autocvar_g_monster_shambler_speed_walk;
21 const float shambler_anim_stand = 0;
22 const float shambler_anim_walk = 1;
23 const float shambler_anim_run = 2;
24 const float shambler_anim_smash = 3;
25 const float shambler_anim_swingr = 4;
26 const float shambler_anim_swingl = 5;
27 const float shambler_anim_magic = 6;
28 const float shambler_anim_pain = 7;
29 const float shambler_anim_death = 8;
32 .float shambler_lastattack; // delay attacks separately
34 void M_Shambler_Attack_Smash(entity this)
36 makevectors(this.angles);
37 Send_Effect(EFFECT_EXPLOSION_MEDIUM, (this.origin + (v_forward * 150)) - ('0 0 1' * this.maxs.z), '0 0 0', 1);
38 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
40 // RadiusDamage does NOT support custom starting location, which means we must use this hack...
42 tracebox(this.origin + v_forward * 50, this.mins * 0.5, this.maxs * 0.5, this.origin + v_forward * autocvar_g_monster_shambler_attack_smash_range, MOVE_NORMAL, this);
44 if(trace_ent.takedamage)
45 Damage(trace_ent, this, this, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_SMASH.m_id, DMG_NOWEP, trace_ent.origin, normalize(trace_ent.origin - this.origin));
48 void M_Shambler_Attack_Swing(entity this)
50 Monster_Attack_Melee(this, this.enemy, (autocvar_g_monster_shambler_attack_claw_damage), ((random() >= 0.5) ? this.anim_melee2 : this.anim_melee3), this.attack_range, 0.8, DEATH_MONSTER_SHAMBLER_CLAW.m_id, true);
53 #include <common/effects/qc/_mod.qh>
55 void M_Shambler_Attack_Lightning_Explode(entity this, entity directhitentity)
57 sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
58 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
60 this.event_damage = func_null;
61 this.takedamage = DAMAGE_NO;
62 set_movetype(this, MOVETYPE_NONE);
63 this.velocity = '0 0 0';
65 if(this.move_movetype == MOVETYPE_NONE)
66 this.velocity = this.oldvelocity;
68 RadiusDamage (this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius),
69 NULL, NULL, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, DMG_NOWEP, directhitentity);
71 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_shambler_attack_lightning_radius_zap, it != this.realowner && it.takedamage,
73 te_csqc_lightningarc(this.origin, it.origin);
74 Damage(it, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, DMG_NOWEP, it.origin, '0 0 0');
77 setthink(this, SUB_Remove);
78 this.nextthink = time + 0.2;
81 void M_Shambler_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
83 M_Shambler_Attack_Lightning_Explode(this, trigger);
86 void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
88 if (GetResource(this, RES_HEALTH) <= 0)
91 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
92 return; // g_projectiles_damage says to halt
94 TakeResource(this, RES_HEALTH, damage);
96 if (GetResource(this, RES_HEALTH) <= 0)
97 W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
100 void M_Shambler_Attack_Lightning_Touch(entity this, entity toucher)
102 PROJECTILE_TOUCH(this, toucher);
104 this.use(this, NULL, toucher);
107 void M_Shambler_Attack_Lightning_Think(entity this)
109 this.nextthink = time;
112 M_Shambler_Attack_Lightning_Explode(this, NULL);
117 void M_Shambler_Attack_Lightning(entity this)
119 monster_makevectors(this, this.enemy);
121 entity gren = new(grenade);
122 gren.owner = gren.realowner = this;
123 gren.bot_dodge = true;
124 gren.bot_dodgerating = (autocvar_g_monster_shambler_attack_lightning_damage);
125 set_movetype(gren, MOVETYPE_BOUNCE);
126 PROJECTILE_MAKETRIGGER(gren);
127 gren.projectiledeathtype = DEATH_MONSTER_SHAMBLER_ZAP.m_id;
128 setorigin(gren, CENTER_OR_VIEWOFS(this));
129 setsize(gren, '-8 -8 -8', '8 8 8');
133 gren.nextthink = time;
134 setthink(gren, M_Shambler_Attack_Lightning_Think);
135 gren.use = M_Shambler_Attack_Lightning_Explode_use;
136 settouch(gren, M_Shambler_Attack_Lightning_Touch);
138 gren.takedamage = DAMAGE_YES;
139 SetResourceExplicit(gren, RES_HEALTH, 50);
140 gren.damageforcescale = 0;
141 gren.event_damage = M_Shambler_Attack_Lightning_Damage;
142 gren.damagedbycontents = true;
143 IL_PUSH(g_damagedbycontents, gren);
144 gren.missile_flags = MIF_SPLASH | MIF_ARC;
145 W_SetupProjVelocity_Explicit(gren, v_forward, v_up, (autocvar_g_monster_shambler_attack_lightning_speed), (autocvar_g_monster_shambler_attack_lightning_speed_up), 0, 0, false);
147 gren.angles = vectoangles (gren.velocity);
148 gren.flags = FL_PROJECTILE;
149 IL_PUSH(g_projectiles, gren);
150 IL_PUSH(g_bot_dodge, gren);
152 CSQCProjectile(gren, true, PROJECTILE_SHAMBLER_LIGHTNING, true);
157 bool M_Shambler_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
161 case MONSTER_ATTACK_MELEE:
163 int swing_cnt = bound(1, floor(random() * 4), 3);
164 Monster_Delay(actor, swing_cnt, 0.5, M_Shambler_Attack_Swing);
165 actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay
168 case MONSTER_ATTACK_RANGED:
170 float randomness = random();
172 if(time >= actor.shambler_lastattack) // shambler doesn't attack much
173 if(IS_ONGROUND(actor))
174 if(randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_shambler_attack_smash_range))
176 setanim(actor, actor.anim_melee2, true, true, false);
177 Monster_Delay(actor, 1, 0.7, M_Shambler_Attack_Smash);
178 actor.attack_finished_single[0] = time + 1.1;
179 actor.anim_finished = time + 1.1;
180 actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
181 actor.shambler_lastattack = time + 3 + random() * 1.5;
184 else if(randomness <= 0.1 && vdist(actor.enemy.origin - actor.origin, >=, autocvar_g_monster_shambler_attack_smash_range * 1.5)) // small chance, don't want this spammed
186 setanim(actor, actor.anim_shoot, true, true, false);
187 actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
188 actor.attack_finished_single[0] = time + 1.1;
189 actor.anim_finished = 1.1;
190 actor.shambler_lastattack = time + 3 + random() * 1.5;
191 Monster_Delay(actor, 1, 0.6, M_Shambler_Attack_Lightning);
202 spawnfunc(monster_shambler) { Monster_Spawn(this, true, MON_SHAMBLER.monsterid); }
206 METHOD(Shambler, mr_think, bool(Shambler this, entity actor))
212 METHOD(Shambler, mr_pain, float(Shambler this, entity actor, float damage_take, entity attacker, float deathtype))
215 actor.pain_finished = time + 0.5;
216 setanim(actor, actor.anim_pain1, true, true, false);
220 METHOD(Shambler, mr_death, bool(Shambler this, entity actor))
223 setanim(actor, actor.anim_die1, false, true, true);
228 METHOD(Shambler, mr_anim, bool(Shambler this, entity actor))
231 vector none = '0 0 0';
232 actor.anim_die1 = animfixfps(actor, '8 1 0.5', none); // 2 seconds
233 actor.anim_walk = animfixfps(actor, '1 1 1', none);
234 actor.anim_idle = animfixfps(actor, '0 1 1', none);
235 actor.anim_pain1 = animfixfps(actor, '7 1 2', none); // 0.5 seconds
236 actor.anim_melee1 = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
237 actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
238 actor.anim_melee3 = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
239 actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
240 actor.anim_run = animfixfps(actor, '2 1 1', none);
245 .float animstate_endtime;
246 METHOD(Shambler, mr_setup, bool(Shambler this, entity actor))
249 if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_shambler_health);
250 if(!actor.attack_range) actor.attack_range = 150;
251 if(!actor.speed) { actor.speed = (autocvar_g_monster_shambler_speed_walk); }
252 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_shambler_speed_run); }
253 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_shambler_speed_stop); }
254 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_shambler_damageforcescale); }
256 actor.monster_loot = ITEM_HealthMega;
257 actor.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX
259 setanim(actor, actor.anim_shoot, false, true, true);
260 actor.spawn_time = actor.animstate_endtime;
261 actor.spawnshieldtime = actor.spawn_time;
262 actor.monster_attackfunc = M_Shambler_Attack;