4 #include <common/mutators/base.qh>
8 float autocvar_g_monster_spider_health;
9 float autocvar_g_monster_spider_damageforcescale = 0.6;
10 float autocvar_g_monster_spider_attack_bite_damage;
11 float autocvar_g_monster_spider_attack_bite_delay;
12 float autocvar_g_monster_spider_attack_web_damagetime;
13 float autocvar_g_monster_spider_attack_web_speed;
14 float autocvar_g_monster_spider_attack_web_speed_up;
15 float autocvar_g_monster_spider_attack_web_delay;
16 float autocvar_g_monster_spider_attack_web_range = 800;
17 float autocvar_g_monster_spider_speed_stop;
18 float autocvar_g_monster_spider_speed_run;
19 float autocvar_g_monster_spider_speed_walk;
21 .float spider_web_delay;
23 void M_Spider_Attack_Web(entity this);
25 REGISTER_MUTATOR(spiderweb, true);
27 MUTATOR_HOOKFUNCTION(spiderweb, PlayerPhysics_UpdateStats)
29 entity player = M_ARGV(0, entity);
31 if(StatusEffects_active(STATUSEFFECT_Webbed, player))
32 STAT(MOVEVARS_HIGHSPEED, player) *= 0.5;
35 MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove)
37 entity mon = M_ARGV(0, entity);
39 if(StatusEffects_active(STATUSEFFECT_Webbed, mon))
41 M_ARGV(1, float) *= 0.5; // run speed
42 M_ARGV(2, float) *= 0.5; // walk speed
46 SOUND(SpiderAttack_FIRE, W_Sound("electro_fire"));
47 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire))
49 TC(SpiderAttack, thiswep);
50 bool isPlayer = IS_PLAYER(actor);
52 if ((!isPlayer && time >= actor.spider_web_delay) || (isPlayer && weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay))) {
54 actor.spider_web_delay = time + autocvar_g_monster_spider_attack_web_delay;
55 setanim(actor, actor.anim_shoot, true, true, true);
56 if(actor.animstate_endtime > time)
57 actor.anim_finished = actor.animstate_endtime;
59 actor.anim_finished = time + 1;
60 actor.attack_finished_single[0] = actor.anim_finished + 0.2;
62 if (isPlayer) actor.enemy = Monster_FindTarget(actor);
63 monster_makevectors(actor, actor.enemy);
64 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_SPIDER.m_id);
65 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
66 M_Spider_Attack_Web(actor);
67 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
71 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
73 actor.enemy = Monster_FindTarget(actor);
74 actor.attack_range = 60;
76 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);
77 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
81 void M_Spider_Attack_Web_Explode(entity this)
85 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
86 RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, DMG_NOWEP, NULL);
88 FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && it.monsterdef != MON_SPIDER,
90 StatusEffects_apply(STATUSEFFECT_Webbed, it, time + autocvar_g_monster_spider_attack_web_damagetime, 0);
97 void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
99 M_Spider_Attack_Web_Explode(this);
102 void M_Spider_Attack_Web_Touch(entity this, entity toucher)
104 PROJECTILE_TOUCH(this, toucher);
106 M_Spider_Attack_Web_Explode(this);
109 void M_Spider_Attack_Web(entity this)
111 sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
113 entity proj = new(plasma);
114 proj.owner = proj.realowner = this;
115 proj.use = M_Spider_Attack_Web_Explode_use;
116 setthink(proj, adaptor_think2use_hittype_splash);
117 proj.bot_dodge = true;
118 proj.bot_dodgerating = 0;
119 proj.nextthink = time + 5;
120 PROJECTILE_MAKETRIGGER(proj);
121 proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
122 setorigin(proj, CENTER_OR_VIEWOFS(this));
124 //proj.glow_size = 50;
125 //proj.glow_color = 45;
126 set_movetype(proj, MOVETYPE_BOUNCE);
127 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);
128 settouch(proj, M_Spider_Attack_Web_Touch);
129 setsize(proj, '-4 -4 -4', '4 4 4');
130 proj.takedamage = DAMAGE_NO;
131 proj.damageforcescale = 0;
132 SetResourceExplicit(proj, RES_HEALTH, 500);
133 proj.event_damage = func_null;
134 proj.flags = FL_PROJECTILE;
135 IL_PUSH(g_projectiles, proj);
136 IL_PUSH(g_bot_dodge, proj);
137 proj.damagedbycontents = true;
138 IL_PUSH(g_damagedbycontents, proj);
140 proj.bouncefactor = 0.3;
141 proj.bouncestop = 0.05;
142 proj.missile_flags = MIF_SPLASH | MIF_ARC;
144 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
147 bool M_Spider_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
149 Weapon wep = WEP_SPIDER_ATTACK;
152 case MONSTER_ATTACK_MELEE:
154 wep.wr_think(wep, actor, weaponentity, 2);
157 case MONSTER_ATTACK_RANGED:
159 if(vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_spider_attack_web_range))
161 wep.wr_think(wep, actor, weaponentity, 1);
170 spawnfunc(monster_spider) { Monster_Spawn(this, true, MON_SPIDER); }
174 METHOD(Spider, mr_think, bool(Spider this, entity actor))
180 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
183 setanim(actor, ((random() > 0.5) ? actor.anim_pain2 : actor.anim_pain1), true, true, false);
184 actor.pain_finished = actor.animstate_endtime;
188 METHOD(Spider, mr_death, bool(Spider this, entity actor))
191 setanim(actor, ((random() > 0.5) ? actor.anim_die2 : actor.anim_die1), false, true, true);
196 METHOD(Spider, mr_anim, bool(Spider this, entity actor))
199 vector none = '0 0 0';
200 actor.anim_melee = animfixfps(actor, '0 1 5', none); // analyze models and set framerate
201 actor.anim_die1 = animfixfps(actor, '1 1 1', none);
202 actor.anim_die2 = animfixfps(actor, '2 1 1', none);
203 actor.anim_shoot = animfixfps(actor, '3 1 1', none);
204 //actor.anim_fire2 = animfixfps(actor, '4 1 1', none);
205 actor.anim_idle = animfixfps(actor, '5 1 1', none);
206 //actor.anim_sight = animfixfps(actor, '6 1 1', none);
207 actor.anim_pain1 = animfixfps(actor, '7 1 1', none);
208 actor.anim_pain2 = animfixfps(actor, '8 1 1', none);
209 //actor.anim_pain3 = animfixfps(actor, '9 1 1', none);
210 actor.anim_walk = animfixfps(actor, '10 1 1', none);
211 actor.anim_run = animfixfps(actor, '10 1 1', none); // temp?
212 //actor.anim_forwardright = animfixfps(actor, '11 1 1', none);
213 //actor.anim_walkright = animfixfps(actor, '12 1 1', none);
214 //actor.anim_walkbackright = animfixfps(actor, '13 1 1', none);
215 //actor.anim_walkback = animfixfps(actor, '14 1 1', none);
216 //actor.anim_walkbackleft = animfixfps(actor, '15 1 1', none);
217 //actor.anim_walkleft = animfixfps(actor, '16 1 1', none);
218 //actor.anim_forwardleft = animfixfps(actor, '17 1 1', none);
223 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
226 if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_spider_health);
227 if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
228 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
229 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
230 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
232 actor.monster_loot = ITEM_HealthMedium;
233 actor.monster_attackfunc = M_Spider_Attack;