5 MODEL(MON_SPIDER, M_Model("spider.dpm"));
9 ATTRIB(Spider, spawnflags, int, MON_FLAG_MELEE | MON_FLAG_RANGED | MON_FLAG_RIDE);
10 ATTRIB(Spider, mins, vector, '-18 -18 -25');
11 ATTRIB(Spider, maxs, vector, '18 18 30');
13 ATTRIB(Spider, m_model, Model, MDL_MON_SPIDER);
15 ATTRIB(Spider, netname, string, "spider");
16 ATTRIB(Spider, monster_name, string, _("Spider"));
19 REGISTER_MONSTER(SPIDER, NEW(Spider)) {
21 this.mr_precache(this);
25 #include <common/weapons/all.qh>
27 CLASS(SpiderAttack, PortoLaunch)
28 /* flags */ ATTRIB(SpiderAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
29 /* impulse */ ATTRIB(SpiderAttack, impulse, int, 9);
30 /* refname */ ATTRIB(SpiderAttack, netname, string, "spider");
31 /* wepname */ ATTRIB(SpiderAttack, m_name, string, _("Spider attack"));
32 ENDCLASS(SpiderAttack)
33 REGISTER_WEAPON(SPIDER_ATTACK, NEW(SpiderAttack));
41 .float spider_slowness; // effect time of slowness inflicted by spiders
43 .float spider_web_delay;
45 float autocvar_g_monster_spider_attack_web_damagetime;
46 float autocvar_g_monster_spider_attack_web_speed;
47 float autocvar_g_monster_spider_attack_web_speed_up;
48 float autocvar_g_monster_spider_attack_web_delay;
50 float autocvar_g_monster_spider_attack_bite_damage;
51 float autocvar_g_monster_spider_attack_bite_delay;
53 void M_Spider_Attack_Web(entity this);
55 REGISTER_MUTATOR(spiderweb, true);
57 MUTATOR_HOOKFUNCTION(spiderweb, PlayerPhysics)
59 entity player = M_ARGV(0, entity);
61 if (time >= player.spider_slowness)
63 PHYS_MAXSPEED(player) *= 0.5; // half speed while slow from spider
64 PHYS_MAXAIRSPEED(player) *= 0.5;
65 PHYS_AIRSPEEDLIMIT_NONQW(player) *= 0.5;
66 PHYS_AIRSTRAFEACCELERATE(player) *= 0.5;
69 MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove)
71 entity mon = M_ARGV(0, entity);
73 if(time < mon.spider_slowness)
75 M_ARGV(1, float) *= 0.5; // run speed
76 M_ARGV(2, float) *= 0.5; // walk speed
80 MUTATOR_HOOKFUNCTION(spiderweb, PlayerSpawn)
82 entity player = M_ARGV(0, entity);
84 player.spider_slowness = 0;
88 MUTATOR_HOOKFUNCTION(spiderweb, MonsterSpawn)
90 entity mon = M_ARGV(0, entity);
92 mon.spider_slowness = 0;
95 SOUND(SpiderAttack_FIRE, W_Sound("electro_fire"));
96 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire))
98 TC(SpiderAttack, thiswep);
99 bool isPlayer = IS_PLAYER(actor);
101 if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay)) {
103 actor.spider_web_delay = time + 3;
104 setanim(actor, actor.anim_shoot, true, true, true);
105 actor.attack_finished_single[0] = time + (autocvar_g_monster_spider_attack_web_delay);
106 actor.anim_finished = time + 1;
108 if (isPlayer) actor.enemy = Monster_FindTarget(actor);
109 W_SetupShot_Dir(actor, v_forward, false, 0, SND_SpiderAttack_FIRE, CH_WEAPON_B, 0);
110 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
111 M_Spider_Attack_Web(actor);
112 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
116 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
118 actor.enemy = Monster_FindTarget(actor);
119 actor.attack_range = 60;
121 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);
122 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
126 float autocvar_g_monster_spider_health;
127 float autocvar_g_monster_spider_damageforcescale = 0.6;
128 float autocvar_g_monster_spider_speed_stop;
129 float autocvar_g_monster_spider_speed_run;
130 float autocvar_g_monster_spider_speed_walk;
133 const float spider_anim_idle = 0;
134 const float spider_anim_walk = 1;
135 const float spider_anim_attack = 2;
136 const float spider_anim_attack2 = 3;
139 void M_Spider_Attack_Web_Explode(entity this)
143 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
144 RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, NULL);
146 FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && it.monsterid != MON_SPIDER.monsterid,
148 it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
155 void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
157 M_Spider_Attack_Web_Explode(this);
160 void M_Spider_Attack_Web_Touch(entity this, entity toucher)
162 PROJECTILE_TOUCH(this, toucher);
164 M_Spider_Attack_Web_Explode(this);
167 void adaptor_think2use_hittype_splash(entity this);
169 void M_Spider_Attack_Web(entity this)
171 monster_makevectors(this, this.enemy);
173 sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
175 entity proj = new(plasma);
176 proj.owner = proj.realowner = this;
177 proj.use = M_Spider_Attack_Web_Explode_use;
178 setthink(proj, adaptor_think2use_hittype_splash);
179 proj.bot_dodge = true;
180 proj.bot_dodgerating = 0;
181 proj.nextthink = time + 5;
182 PROJECTILE_MAKETRIGGER(proj);
183 proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
184 setorigin(proj, CENTER_OR_VIEWOFS(this));
186 //proj.glow_size = 50;
187 //proj.glow_color = 45;
188 set_movetype(proj, MOVETYPE_BOUNCE);
189 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);
190 settouch(proj, M_Spider_Attack_Web_Touch);
191 setsize(proj, '-4 -4 -4', '4 4 4');
192 proj.takedamage = DAMAGE_NO;
193 proj.damageforcescale = 0;
195 proj.event_damage = func_null;
196 proj.flags = FL_PROJECTILE;
197 proj.damagedbycontents = true;
199 proj.bouncefactor = 0.3;
200 proj.bouncestop = 0.05;
201 proj.missile_flags = MIF_SPLASH | MIF_ARC;
203 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
206 bool M_Spider_Attack(int attack_type, entity actor, entity targ)
208 .entity weaponentity = weaponentities[0];
211 Weapon wep = WEP_SPIDER_ATTACK;
212 case MONSTER_ATTACK_MELEE:
214 wep.wr_think(wep, actor, weaponentity, 2);
217 case MONSTER_ATTACK_RANGED:
219 wep.wr_think(wep, actor, weaponentity, 1);
227 spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); }
231 METHOD(Spider, mr_think, bool(Spider this, entity actor))
237 METHOD(Spider, mr_pain, float(Spider this, entity actor, float damage_take, entity attacker, float deathtype))
243 METHOD(Spider, mr_death, bool(Spider this, entity actor))
246 setanim(actor, actor.anim_melee, false, true, true);
247 actor.angles_x = 180;
252 METHOD(Spider, mr_anim, bool(Spider this, entity actor))
255 vector none = '0 0 0';
256 actor.anim_walk = animfixfps(actor, '1 1 1', none);
257 actor.anim_idle = animfixfps(actor, '0 1 1', none);
258 actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
259 actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
260 actor.anim_run = animfixfps(actor, '1 1 1', none);
265 spawnfunc(item_health_medium);
266 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
269 if(!actor.health) actor.health = (autocvar_g_monster_spider_health);
270 if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
271 if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
272 if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
273 if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
275 actor.monster_loot = spawnfunc_item_health_medium;
276 actor.monster_attackfunc = M_Spider_Attack;
281 METHOD(Spider, mr_precache, bool(Spider this))