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)
23 entity player = M_ARGV(0, entity);
25 if (time >= player.spider_slowness)
27 PHYS_MAXSPEED(player) *= 0.5; // half speed while slow from spider
28 PHYS_MAXAIRSPEED(player) *= 0.5;
29 PHYS_AIRSPEEDLIMIT_NONQW(player) *= 0.5;
30 PHYS_AIRSTRAFEACCELERATE(player) *= 0.5;
33 MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove)
35 entity mon = M_ARGV(0, entity);
37 if(time < mon.spider_slowness)
39 M_ARGV(1, float) *= 0.5; // run speed
40 M_ARGV(2, float) *= 0.5; // walk speed
44 MUTATOR_HOOKFUNCTION(spiderweb, PlayerSpawn)
46 entity player = M_ARGV(0, entity);
48 player.spider_slowness = 0;
52 MUTATOR_HOOKFUNCTION(spiderweb, MonsterSpawn)
54 entity mon = M_ARGV(0, entity);
56 mon.spider_slowness = 0;
59 SOUND(SpiderAttack_FIRE, W_Sound("electro_fire"));
60 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire))
62 TC(SpiderAttack, thiswep);
63 bool isPlayer = IS_PLAYER(actor);
65 if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay)) {
67 actor.spider_web_delay = time + 3;
68 setanim(actor, actor.anim_shoot, true, true, true);
69 actor.attack_finished_single[0] = time + (autocvar_g_monster_spider_attack_web_delay);
70 actor.anim_finished = time + 1;
72 if (isPlayer) actor.enemy = Monster_FindTarget(actor);
73 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0);
74 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
75 M_Spider_Attack_Web(actor);
76 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
80 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
82 actor.enemy = Monster_FindTarget(actor);
83 actor.attack_range = 60;
85 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);
86 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
90 float autocvar_g_monster_spider_health;
91 float autocvar_g_monster_spider_damageforcescale = 0.6;
92 float autocvar_g_monster_spider_speed_stop;
93 float autocvar_g_monster_spider_speed_run;
94 float autocvar_g_monster_spider_speed_walk;
97 const float spider_anim_idle = 0;
98 const float spider_anim_walk = 1;
99 const float spider_anim_attack = 2;
100 const float spider_anim_attack2 = 3;
103 void M_Spider_Attack_Web_Explode(entity this)
107 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
108 RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, NULL);
110 FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && it.monsterid != MON_SPIDER.monsterid,
112 it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
119 void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
121 M_Spider_Attack_Web_Explode(this);
124 void M_Spider_Attack_Web_Touch(entity this, entity toucher)
126 PROJECTILE_TOUCH(this, toucher);
128 M_Spider_Attack_Web_Explode(this);
131 void adaptor_think2use_hittype_splash(entity this);
133 void M_Spider_Attack_Web(entity this)
135 monster_makevectors(this, this.enemy);
137 sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
139 entity proj = new(plasma);
140 proj.owner = proj.realowner = this;
141 proj.use = M_Spider_Attack_Web_Explode_use;
142 setthink(proj, adaptor_think2use_hittype_splash);
143 proj.bot_dodge = true;
144 proj.bot_dodgerating = 0;
145 proj.nextthink = time + 5;
146 PROJECTILE_MAKETRIGGER(proj);
147 proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
148 setorigin(proj, CENTER_OR_VIEWOFS(this));
150 //proj.glow_size = 50;
151 //proj.glow_color = 45;
152 set_movetype(proj, MOVETYPE_BOUNCE);
153 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);
154 settouch(proj, M_Spider_Attack_Web_Touch);
155 setsize(proj, '-4 -4 -4', '4 4 4');
156 proj.takedamage = DAMAGE_NO;
157 proj.damageforcescale = 0;
159 proj.event_damage = func_null;
160 proj.flags = FL_PROJECTILE;
161 IL_PUSH(g_projectiles, proj);
162 IL_PUSH(g_bot_dodge, proj);
163 proj.damagedbycontents = true;
165 proj.bouncefactor = 0.3;
166 proj.bouncestop = 0.05;
167 proj.missile_flags = MIF_SPLASH | MIF_ARC;
169 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
172 bool M_Spider_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
176 Weapon wep = WEP_SPIDER_ATTACK;
177 case MONSTER_ATTACK_MELEE:
179 wep.wr_think(wep, actor, weaponentity, 2);
182 case MONSTER_ATTACK_RANGED:
184 wep.wr_think(wep, actor, weaponentity, 1);
192 spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); }
196 METHOD(Spider, mr_think, bool(Spider this, entity actor))
202 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
208 METHOD(Spider, mr_death, bool(Spider this, entity actor))
211 setanim(actor, actor.anim_melee, false, true, true);
212 actor.angles_x = 180;
217 METHOD(Spider, mr_anim, bool(Spider this, entity actor))
220 vector none = '0 0 0';
221 actor.anim_walk = animfixfps(actor, '1 1 1', none);
222 actor.anim_idle = animfixfps(actor, '0 1 1', none);
223 actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
224 actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
225 actor.anim_run = animfixfps(actor, '1 1 1', none);
230 spawnfunc(item_health_medium);
231 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
234 if(!actor.health) actor.health = (autocvar_g_monster_spider_health);
235 if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
236 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
237 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
238 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
240 actor.monster_loot = spawnfunc_item_health_medium;
241 actor.monster_attackfunc = M_Spider_Attack;
246 METHOD(Spider, mr_precache, bool(Spider this))