6 float autocvar_g_monster_shambler_health;
7 float autocvar_g_monster_shambler_damageforcescale = 0.1;
8 float autocvar_g_monster_shambler_attack_smash_damage;
9 float autocvar_g_monster_shambler_attack_smash_range;
10 float autocvar_g_monster_shambler_attack_claw_damage;
11 float autocvar_g_monster_shambler_attack_lightning_damage;
12 float autocvar_g_monster_shambler_attack_lightning_damage_zap = 15;
13 float autocvar_g_monster_shambler_attack_lightning_force;
14 float autocvar_g_monster_shambler_attack_lightning_radius;
15 float autocvar_g_monster_shambler_attack_lightning_radius_zap;
16 float autocvar_g_monster_shambler_attack_lightning_speed;
17 float autocvar_g_monster_shambler_attack_lightning_speed_up;
18 float autocvar_g_monster_shambler_speed_stop;
19 float autocvar_g_monster_shambler_speed_run;
20 float autocvar_g_monster_shambler_speed_walk;
23 const float shambler_anim_stand = 0;
24 const float shambler_anim_walk = 1;
25 const float shambler_anim_run = 2;
26 const float shambler_anim_smash = 3;
27 const float shambler_anim_swingr = 4;
28 const float shambler_anim_swingl = 5;
29 const float shambler_anim_magic = 6;
30 const float shambler_anim_pain = 7;
31 const float shambler_anim_death = 8;
34 .float shambler_lastattack; // delay attacks separately
36 void M_Shambler_Attack_Smash(entity this)
38 makevectors(this.angles);
39 Send_Effect(EFFECT_EXPLOSION_MEDIUM, (this.origin + (v_forward * 150)) - ('0 0 1' * this.maxs.z), '0 0 0', 1);
40 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
42 // RadiusDamage does NOT support custom starting location, which means we must use this hack...
44 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);
46 if(trace_ent.takedamage)
47 Damage(trace_ent, this, this, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_SMASH.m_id, trace_ent.origin, normalize(trace_ent.origin - this.origin));
50 void M_Shambler_Attack_Swing(entity this)
52 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);
55 #include <common/effects/qc/all.qh>
57 void M_Shambler_Attack_Lightning_Explode(entity this, entity directhitentity)
59 sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
60 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
62 this.event_damage = func_null;
63 this.takedamage = DAMAGE_NO;
64 set_movetype(this, MOVETYPE_NONE);
65 this.velocity = '0 0 0';
67 if(this.move_movetype == MOVETYPE_NONE)
68 this.velocity = this.oldvelocity;
70 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),
71 NULL, NULL, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, directhitentity);
73 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_shambler_attack_lightning_radius_zap, it != this.realowner && it.takedamage,
75 te_csqc_lightningarc(this.origin, it.origin);
76 Damage(it, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, it.origin, '0 0 0');
79 setthink(this, SUB_Remove);
80 this.nextthink = time + 0.2;
83 void M_Shambler_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
85 M_Shambler_Attack_Lightning_Explode(this, trigger);
88 void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
93 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
94 return; // g_projectiles_damage says to halt
96 this.health = this.health - damage;
99 W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
102 void M_Shambler_Attack_Lightning_Touch(entity this, entity toucher)
104 PROJECTILE_TOUCH(this, toucher);
106 this.use(this, NULL, toucher);
109 void M_Shambler_Attack_Lightning_Think(entity this)
111 this.nextthink = time;
114 M_Shambler_Attack_Lightning_Explode(this, NULL);
119 void M_Shambler_Attack_Lightning(entity this)
123 monster_makevectors(this, this.enemy);
126 gren.owner = gren.realowner = this;
127 gren.bot_dodge = true;
128 gren.bot_dodgerating = (autocvar_g_monster_shambler_attack_lightning_damage);
129 set_movetype(gren, MOVETYPE_BOUNCE);
130 PROJECTILE_MAKETRIGGER(gren);
131 gren.projectiledeathtype = DEATH_MONSTER_SHAMBLER_ZAP.m_id;
132 setorigin(gren, CENTER_OR_VIEWOFS(this));
133 setsize(gren, '-8 -8 -8', '8 8 8');
137 gren.nextthink = time;
138 setthink(gren, M_Shambler_Attack_Lightning_Think);
139 gren.use = M_Shambler_Attack_Lightning_Explode_use;
140 settouch(gren, M_Shambler_Attack_Lightning_Touch);
142 gren.takedamage = DAMAGE_YES;
144 gren.damageforcescale = 0;
145 gren.event_damage = M_Shambler_Attack_Lightning_Damage;
146 gren.damagedbycontents = true;
147 gren.missile_flags = MIF_SPLASH | MIF_ARC;
148 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);
150 gren.angles = vectoangles (gren.velocity);
151 gren.flags = FL_PROJECTILE;
152 IL_PUSH(g_projectiles, gren);
153 IL_PUSH(g_bot_dodge, gren);
155 CSQCProjectile(gren, true, PROJECTILE_SHAMBLER_LIGHTNING, true);
160 bool M_Shambler_Attack(int attack_type, entity actor, entity targ)
164 case MONSTER_ATTACK_MELEE:
166 int swing_cnt = bound(1, floor(random() * 4), 3);
167 Monster_Delay(actor, swing_cnt, 0.5, M_Shambler_Attack_Swing);
168 actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay
171 case MONSTER_ATTACK_RANGED:
173 float randomness = random();
175 if(time >= actor.shambler_lastattack) // shambler doesn't attack much
176 if(IS_ONGROUND(actor))
177 if(randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_shambler_attack_smash_range))
179 setanim(actor, actor.anim_melee2, true, true, false);
180 Monster_Delay(actor, 1, 0.7, M_Shambler_Attack_Smash);
181 actor.attack_finished_single[0] = time + 1.1;
182 actor.anim_finished = time + 1.1;
183 actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
184 actor.shambler_lastattack = time + 3 + random() * 1.5;
187 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
189 setanim(actor, actor.anim_shoot, true, true, false);
190 actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
191 actor.attack_finished_single[0] = time + 1.1;
192 actor.anim_finished = 1.1;
193 actor.shambler_lastattack = time + 3 + random() * 1.5;
194 Monster_Delay(actor, 1, 0.6, M_Shambler_Attack_Lightning);
205 spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); }
209 METHOD(Shambler, mr_think, bool(Shambler this, entity actor))
215 METHOD(Shambler, mr_pain, float(Shambler this, entity actor, float damage_take, entity attacker, float deathtype))
218 actor.pain_finished = time + 0.5;
219 setanim(actor, actor.anim_pain1, true, true, false);
223 METHOD(Shambler, mr_death, bool(Shambler this, entity actor))
226 setanim(actor, actor.anim_die1, false, true, true);
231 METHOD(Shambler, mr_anim, bool(Shambler this, entity actor))
234 vector none = '0 0 0';
235 actor.anim_die1 = animfixfps(actor, '8 1 0.5', none); // 2 seconds
236 actor.anim_walk = animfixfps(actor, '1 1 1', none);
237 actor.anim_idle = animfixfps(actor, '0 1 1', none);
238 actor.anim_pain1 = animfixfps(actor, '7 1 2', none); // 0.5 seconds
239 actor.anim_melee1 = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
240 actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
241 actor.anim_melee3 = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
242 actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
243 actor.anim_run = animfixfps(actor, '2 1 1', none);
248 spawnfunc(item_health_mega);
249 .float animstate_endtime;
250 METHOD(Shambler, mr_setup, bool(Shambler this, entity actor))
253 if(!actor.health) actor.health = (autocvar_g_monster_shambler_health);
254 if(!actor.attack_range) actor.attack_range = 150;
255 if(!actor.speed) { actor.speed = (autocvar_g_monster_shambler_speed_walk); }
256 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_shambler_speed_run); }
257 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_shambler_speed_stop); }
258 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_shambler_damageforcescale); }
260 actor.monster_loot = spawnfunc_item_health_mega;
261 actor.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX
263 setanim(actor, actor.anim_shoot, false, true, true);
264 actor.spawn_time = actor.animstate_endtime;
265 actor.spawnshieldtime = actor.spawn_time;
266 actor.monster_attackfunc = M_Shambler_Attack;
271 METHOD(Shambler, mr_precache, bool(Shambler this))