4 #include <common/mutators/base.qh>
9 .float spider_slowness; // effect time of slowness inflicted by spiders
11 .float spider_web_delay;
13 float autocvar_g_monster_spider_attack_web_damagetime;
14 float autocvar_g_monster_spider_attack_web_speed;
15 float autocvar_g_monster_spider_attack_web_speed_up;
16 float autocvar_g_monster_spider_attack_web_delay;
17 float autocvar_g_monster_spider_attack_web_range = 800;
19 float autocvar_g_monster_spider_attack_bite_damage;
20 float autocvar_g_monster_spider_attack_bite_delay;
22 void M_Spider_Attack_Web(entity this);
24 REGISTER_MUTATOR(spiderweb, true);
26 MUTATOR_HOOKFUNCTION(spiderweb, PlayerPhysics_UpdateStats)
28 entity player = M_ARGV(0, entity);
30 if(time < player.spider_slowness)
31 STAT(MOVEVARS_HIGHSPEED, player) *= 0.5;
34 MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove)
36 entity mon = M_ARGV(0, entity);
38 if(time < mon.spider_slowness)
40 M_ARGV(1, float) *= 0.5; // run speed
41 M_ARGV(2, float) *= 0.5; // walk speed
45 MUTATOR_HOOKFUNCTION(spiderweb, PlayerSpawn)
47 entity player = M_ARGV(0, entity);
49 player.spider_slowness = 0;
53 MUTATOR_HOOKFUNCTION(spiderweb, MonsterSpawn)
55 entity mon = M_ARGV(0, entity);
57 mon.spider_slowness = 0;
60 SOUND(SpiderAttack_FIRE, W_Sound("electro_fire"));
61 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire))
63 TC(SpiderAttack, thiswep);
64 bool isPlayer = IS_PLAYER(actor);
66 if ((!isPlayer && time >= actor.spider_web_delay) || (isPlayer && weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay))) {
68 actor.spider_web_delay = time + autocvar_g_monster_spider_attack_web_delay;
69 setanim(actor, actor.anim_shoot, true, true, true);
70 if(actor.animstate_endtime > time)
71 actor.anim_finished = actor.animstate_endtime;
73 actor.anim_finished = time + 1;
74 actor.attack_finished_single[0] = actor.anim_finished + 0.2;
76 if (isPlayer) actor.enemy = Monster_FindTarget(actor);
77 monster_makevectors(actor, actor.enemy);
78 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_SPIDER.m_id);
79 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
80 M_Spider_Attack_Web(actor);
81 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
85 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
87 actor.enemy = Monster_FindTarget(actor);
88 actor.attack_range = 60;
90 Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? actor.anim_melee : actor.anim_shoot), actor.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true);
91 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
95 float autocvar_g_monster_spider_health;
96 float autocvar_g_monster_spider_damageforcescale = 0.6;
97 float autocvar_g_monster_spider_speed_stop;
98 float autocvar_g_monster_spider_speed_run;
99 float autocvar_g_monster_spider_speed_walk;
102 const float spider_anim_idle = 0;
103 const float spider_anim_walk = 1;
104 const float spider_anim_attack = 2;
105 const float spider_anim_attack2 = 3;
108 void M_Spider_Attack_Web_Explode(entity this)
112 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
113 RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, DMG_NOWEP, NULL);
115 FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && it.monsterdef != MON_SPIDER,
117 it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
124 void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
126 M_Spider_Attack_Web_Explode(this);
129 void M_Spider_Attack_Web_Touch(entity this, entity toucher)
131 PROJECTILE_TOUCH(this, toucher);
133 M_Spider_Attack_Web_Explode(this);
136 void M_Spider_Attack_Web(entity this)
138 sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
140 entity proj = new(plasma);
141 proj.owner = proj.realowner = this;
142 proj.use = M_Spider_Attack_Web_Explode_use;
143 setthink(proj, adaptor_think2use_hittype_splash);
144 proj.bot_dodge = true;
145 proj.bot_dodgerating = 0;
146 proj.nextthink = time + 5;
147 PROJECTILE_MAKETRIGGER(proj);
148 proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
149 setorigin(proj, CENTER_OR_VIEWOFS(this));
151 //proj.glow_size = 50;
152 //proj.glow_color = 45;
153 set_movetype(proj, MOVETYPE_BOUNCE);
154 W_SetupProjVelocity_Explicit(proj, v_forward, v_up, (autocvar_g_monster_spider_attack_web_speed), (autocvar_g_monster_spider_attack_web_speed_up), 0, 0, false);
155 settouch(proj, M_Spider_Attack_Web_Touch);
156 setsize(proj, '-4 -4 -4', '4 4 4');
157 proj.takedamage = DAMAGE_NO;
158 proj.damageforcescale = 0;
159 SetResourceExplicit(proj, RES_HEALTH, 500);
160 proj.event_damage = func_null;
161 proj.flags = FL_PROJECTILE;
162 IL_PUSH(g_projectiles, proj);
163 IL_PUSH(g_bot_dodge, proj);
164 proj.damagedbycontents = true;
165 IL_PUSH(g_damagedbycontents, proj);
167 proj.bouncefactor = 0.3;
168 proj.bouncestop = 0.05;
169 proj.missile_flags = MIF_SPLASH | MIF_ARC;
171 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
174 bool M_Spider_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
176 Weapon wep = WEP_SPIDER_ATTACK;
179 case MONSTER_ATTACK_MELEE:
181 wep.wr_think(wep, actor, weaponentity, 2);
184 case MONSTER_ATTACK_RANGED:
186 if(vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_spider_attack_web_range))
188 wep.wr_think(wep, actor, weaponentity, 1);
197 spawnfunc(monster_spider) { Monster_Spawn(this, true, MON_SPIDER); }
201 METHOD(Spider, mr_think, bool(Spider this, entity actor))
207 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
210 setanim(actor, ((random() > 0.5) ? actor.anim_pain2 : actor.anim_pain1), true, true, false);
211 actor.pain_finished = actor.animstate_endtime;
215 METHOD(Spider, mr_death, bool(Spider this, entity actor))
218 setanim(actor, ((random() > 0.5) ? actor.anim_die2 : actor.anim_die1), false, true, true);
223 METHOD(Spider, mr_anim, bool(Spider this, entity actor))
226 vector none = '0 0 0';
227 actor.anim_melee = animfixfps(actor, '0 1 5', none); // analyze models and set framerate
228 actor.anim_die1 = animfixfps(actor, '1 1 1', none);
229 actor.anim_die2 = animfixfps(actor, '2 1 1', none);
230 actor.anim_shoot = animfixfps(actor, '3 1 1', none);
231 //actor.anim_fire2 = animfixfps(actor, '4 1 1', none);
232 actor.anim_idle = animfixfps(actor, '5 1 1', none);
233 //actor.anim_sight = animfixfps(actor, '6 1 1', none);
234 actor.anim_pain1 = animfixfps(actor, '7 1 1', none);
235 actor.anim_pain2 = animfixfps(actor, '8 1 1', none);
236 //actor.anim_pain3 = animfixfps(actor, '9 1 1', none);
237 actor.anim_walk = animfixfps(actor, '10 1 1', none);
238 actor.anim_run = animfixfps(actor, '10 1 1', none); // temp?
239 //actor.anim_forwardright = animfixfps(actor, '11 1 1', none);
240 //actor.anim_walkright = animfixfps(actor, '12 1 1', none);
241 //actor.anim_walkbackright = animfixfps(actor, '13 1 1', none);
242 //actor.anim_walkback = animfixfps(actor, '14 1 1', none);
243 //actor.anim_walkbackleft = animfixfps(actor, '15 1 1', none);
244 //actor.anim_walkleft = animfixfps(actor, '16 1 1', none);
245 //actor.anim_forwardleft = animfixfps(actor, '17 1 1', none);
250 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
253 if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_spider_health);
254 if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
255 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
256 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
257 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
259 actor.monster_loot = ITEM_HealthMedium;
260 actor.monster_attackfunc = M_Spider_Attack;