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;
18 float autocvar_g_monster_spider_attack_bite_damage;
19 float autocvar_g_monster_spider_attack_bite_delay;
21 void M_Spider_Attack_Web(entity this);
23 REGISTER_MUTATOR(spiderweb, true);
25 MUTATOR_HOOKFUNCTION(spiderweb, PlayerPhysics_UpdateStats)
27 entity player = M_ARGV(0, entity);
29 if(time < player.spider_slowness)
30 STAT(MOVEVARS_HIGHSPEED, 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 monster_makevectors(actor, actor.enemy);
74 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_SPIDER.m_id);
75 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
76 M_Spider_Attack_Web(actor);
77 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
81 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
83 actor.enemy = Monster_FindTarget(actor);
84 actor.attack_range = 60;
86 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);
87 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
91 float autocvar_g_monster_spider_health;
92 float autocvar_g_monster_spider_damageforcescale = 0.6;
93 float autocvar_g_monster_spider_speed_stop;
94 float autocvar_g_monster_spider_speed_run;
95 float autocvar_g_monster_spider_speed_walk;
98 const float spider_anim_idle = 0;
99 const float spider_anim_walk = 1;
100 const float spider_anim_attack = 2;
101 const float spider_anim_attack2 = 3;
104 void M_Spider_Attack_Web_Explode(entity this)
108 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
109 RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, DMG_NOWEP, NULL);
111 FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && it.monsterdef != MON_SPIDER,
113 it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
120 void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
122 M_Spider_Attack_Web_Explode(this);
125 void M_Spider_Attack_Web_Touch(entity this, entity toucher)
127 PROJECTILE_TOUCH(this, toucher);
129 M_Spider_Attack_Web_Explode(this);
132 void M_Spider_Attack_Web(entity this)
134 sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
136 entity proj = new(plasma);
137 proj.owner = proj.realowner = this;
138 proj.use = M_Spider_Attack_Web_Explode_use;
139 setthink(proj, adaptor_think2use_hittype_splash);
140 proj.bot_dodge = true;
141 proj.bot_dodgerating = 0;
142 proj.nextthink = time + 5;
143 PROJECTILE_MAKETRIGGER(proj);
144 proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
145 setorigin(proj, CENTER_OR_VIEWOFS(this));
147 //proj.glow_size = 50;
148 //proj.glow_color = 45;
149 set_movetype(proj, MOVETYPE_BOUNCE);
150 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);
151 settouch(proj, M_Spider_Attack_Web_Touch);
152 setsize(proj, '-4 -4 -4', '4 4 4');
153 proj.takedamage = DAMAGE_NO;
154 proj.damageforcescale = 0;
155 SetResourceExplicit(proj, RES_HEALTH, 500);
156 proj.event_damage = func_null;
157 proj.flags = FL_PROJECTILE;
158 IL_PUSH(g_projectiles, proj);
159 IL_PUSH(g_bot_dodge, proj);
160 proj.damagedbycontents = true;
161 IL_PUSH(g_damagedbycontents, proj);
163 proj.bouncefactor = 0.3;
164 proj.bouncestop = 0.05;
165 proj.missile_flags = MIF_SPLASH | MIF_ARC;
167 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
170 bool M_Spider_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
172 Weapon wep = WEP_SPIDER_ATTACK;
175 case MONSTER_ATTACK_MELEE:
177 wep.wr_think(wep, actor, weaponentity, 2);
180 case MONSTER_ATTACK_RANGED:
182 wep.wr_think(wep, actor, weaponentity, 1);
190 spawnfunc(monster_spider) { Monster_Spawn(this, true, MON_SPIDER); }
194 METHOD(Spider, mr_think, bool(Spider this, entity actor))
200 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
206 METHOD(Spider, mr_death, bool(Spider this, entity actor))
209 setanim(actor, actor.anim_melee, false, true, true);
210 actor.angles_x = 180;
215 METHOD(Spider, mr_anim, bool(Spider this, entity actor))
218 vector none = '0 0 0';
219 actor.anim_walk = animfixfps(actor, '1 1 1', none);
220 actor.anim_idle = animfixfps(actor, '0 1 1', none);
221 actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
222 actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
223 actor.anim_run = animfixfps(actor, '1 1 1', none);
228 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
231 if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_spider_health);
232 if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
233 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
234 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
235 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
237 actor.monster_loot = ITEM_HealthMedium;
238 actor.monster_attackfunc = M_Spider_Attack;