5 .float spider_slowness; // effect time of slowness inflicted by spiders
7 .float spider_web_delay;
9 float autocvar_g_monster_spider_attack_web_damagetime;
10 float autocvar_g_monster_spider_attack_web_speed;
11 float autocvar_g_monster_spider_attack_web_speed_up;
12 float autocvar_g_monster_spider_attack_web_delay;
14 float autocvar_g_monster_spider_attack_bite_damage;
15 float autocvar_g_monster_spider_attack_bite_delay;
17 void M_Spider_Attack_Web(entity this);
19 REGISTER_MUTATOR(spiderweb, true);
21 MUTATOR_HOOKFUNCTION(spiderweb, PlayerPhysics_UpdateStats)
23 entity player = M_ARGV(0, entity);
25 if(time < player.spider_slowness)
26 STAT(MOVEVARS_HIGHSPEED, player) *= 0.5;
29 MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove)
31 entity mon = M_ARGV(0, entity);
33 if(time < mon.spider_slowness)
35 M_ARGV(1, float) *= 0.5; // run speed
36 M_ARGV(2, float) *= 0.5; // walk speed
40 MUTATOR_HOOKFUNCTION(spiderweb, PlayerSpawn)
42 entity player = M_ARGV(0, entity);
44 player.spider_slowness = 0;
48 MUTATOR_HOOKFUNCTION(spiderweb, MonsterSpawn)
50 entity mon = M_ARGV(0, entity);
52 mon.spider_slowness = 0;
55 SOUND(SpiderAttack_FIRE, W_Sound("electro_fire"));
56 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire))
58 TC(SpiderAttack, thiswep);
59 bool isPlayer = IS_PLAYER(actor);
61 if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay)) {
63 actor.spider_web_delay = time + 3;
64 setanim(actor, actor.anim_shoot, true, true, true);
65 actor.attack_finished_single[0] = time + (autocvar_g_monster_spider_attack_web_delay);
66 actor.anim_finished = time + 1;
68 if (isPlayer) actor.enemy = Monster_FindTarget(actor);
69 monster_makevectors(actor, actor.enemy);
70 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_SPIDER.m_id);
71 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
72 M_Spider_Attack_Web(actor);
73 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
77 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
79 actor.enemy = Monster_FindTarget(actor);
80 actor.attack_range = 60;
82 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);
83 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
87 float autocvar_g_monster_spider_health;
88 float autocvar_g_monster_spider_damageforcescale = 0.6;
89 float autocvar_g_monster_spider_speed_stop;
90 float autocvar_g_monster_spider_speed_run;
91 float autocvar_g_monster_spider_speed_walk;
94 const float spider_anim_idle = 0;
95 const float spider_anim_walk = 1;
96 const float spider_anim_attack = 2;
97 const float spider_anim_attack2 = 3;
100 void M_Spider_Attack_Web_Explode(entity this)
104 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
105 RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, DMG_NOWEP, NULL);
107 FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && it.monsterid != MON_SPIDER.monsterid,
109 it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
116 void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
118 M_Spider_Attack_Web_Explode(this);
121 void M_Spider_Attack_Web_Touch(entity this, entity toucher)
123 PROJECTILE_TOUCH(this, toucher);
125 M_Spider_Attack_Web_Explode(this);
128 void adaptor_think2use_hittype_splash(entity this);
130 void M_Spider_Attack_Web(entity this)
132 sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
134 entity proj = new(plasma);
135 proj.owner = proj.realowner = this;
136 proj.use = M_Spider_Attack_Web_Explode_use;
137 setthink(proj, adaptor_think2use_hittype_splash);
138 proj.bot_dodge = true;
139 proj.bot_dodgerating = 0;
140 proj.nextthink = time + 5;
141 PROJECTILE_MAKETRIGGER(proj);
142 proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
143 setorigin(proj, CENTER_OR_VIEWOFS(this));
145 //proj.glow_size = 50;
146 //proj.glow_color = 45;
147 set_movetype(proj, MOVETYPE_BOUNCE);
148 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);
149 settouch(proj, M_Spider_Attack_Web_Touch);
150 setsize(proj, '-4 -4 -4', '4 4 4');
151 proj.takedamage = DAMAGE_NO;
152 proj.damageforcescale = 0;
153 SetResourceExplicit(proj, RES_HEALTH, 500);
154 proj.event_damage = func_null;
155 proj.flags = FL_PROJECTILE;
156 IL_PUSH(g_projectiles, proj);
157 IL_PUSH(g_bot_dodge, proj);
158 proj.damagedbycontents = true;
159 IL_PUSH(g_damagedbycontents, proj);
161 proj.bouncefactor = 0.3;
162 proj.bouncestop = 0.05;
163 proj.missile_flags = MIF_SPLASH | MIF_ARC;
165 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
168 bool M_Spider_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
170 Weapon wep = WEP_SPIDER_ATTACK;
173 case MONSTER_ATTACK_MELEE:
175 wep.wr_think(wep, actor, weaponentity, 2);
178 case MONSTER_ATTACK_RANGED:
180 wep.wr_think(wep, actor, weaponentity, 1);
188 spawnfunc(monster_spider) { Monster_Spawn(this, true, MON_SPIDER.monsterid); }
192 METHOD(Spider, mr_think, bool(Spider this, entity actor))
198 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
204 METHOD(Spider, mr_death, bool(Spider this, entity actor))
207 setanim(actor, actor.anim_melee, false, true, true);
208 actor.angles_x = 180;
213 METHOD(Spider, mr_anim, bool(Spider this, entity actor))
216 vector none = '0 0 0';
217 actor.anim_walk = animfixfps(actor, '1 1 1', none);
218 actor.anim_idle = animfixfps(actor, '0 1 1', none);
219 actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
220 actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
221 actor.anim_run = animfixfps(actor, '1 1 1', none);
226 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
229 if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_spider_health);
230 if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
231 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
232 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
233 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
235 actor.monster_loot = ITEM_HealthMedium;
236 actor.monster_attackfunc = M_Spider_Attack;