5 MODEL(MON_SPIDER, "models/monsters/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 MON_ACTION(this, MR_PRECACHE);
25 #include "../../weapons/all.qh"
27 CLASS(SpiderAttack, PortoLaunch)
28 /* flags */ ATTRIB(SpiderAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN);
29 /* impulse */ ATTRIB(SpiderAttack, impulse, int, 9);
30 /* refname */ ATTRIB(SpiderAttack, netname, string, "spider");
31 /* wepname */ ATTRIB(SpiderAttack, message, string, _("Spider attack"));
32 ENDCLASS(SpiderAttack)
33 REGISTER_WEAPON(SPIDER_ATTACK, NEW(SpiderAttack));
41 .float spider_web_delay;
43 float autocvar_g_monster_spider_attack_web_damagetime;
44 float autocvar_g_monster_spider_attack_web_speed;
45 float autocvar_g_monster_spider_attack_web_speed_up;
46 float autocvar_g_monster_spider_attack_web_delay;
48 float autocvar_g_monster_spider_attack_bite_damage;
49 float autocvar_g_monster_spider_attack_bite_delay;
51 void M_Spider_Attack_Web();
53 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) {
54 bool isPlayer = IS_PLAYER(actor);
56 if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(actor, false, autocvar_g_monster_spider_attack_web_delay)) {
58 actor.spider_web_delay = time + 3;
59 setanim(actor, actor.anim_shoot, true, true, true);
60 actor.attack_finished_single = time + (autocvar_g_monster_spider_attack_web_delay);
61 actor.anim_finished = time + 1;
63 if (isPlayer) actor.enemy = Monster_FindTarget(actor);
64 W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
65 if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
66 M_Spider_Attack_Web();
67 weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
71 if (!isPlayer || weapon_prepareattack(actor, true, 0.5)) {
73 actor.enemy = Monster_FindTarget(actor);
74 actor.attack_range = 60;
76 Monster_Attack_Melee(actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER, true);
77 weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
81 float autocvar_g_monster_spider_health;
82 float autocvar_g_monster_spider_damageforcescale = 0.6;
83 float autocvar_g_monster_spider_speed_stop;
84 float autocvar_g_monster_spider_speed_run;
85 float autocvar_g_monster_spider_speed_walk;
88 const float spider_anim_idle = 0;
89 const float spider_anim_walk = 1;
90 const float spider_anim_attack = 2;
91 const float spider_anim_attack2 = 3;
94 void M_Spider_Attack_Web_Explode()
99 Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
100 RadiusDamage(self, self.realowner, 0, 0, 25, world, world, 25, self.projectiledeathtype, world);
102 for(e = findradius(self.origin, 25); e; e = e.chain) if(e != self) if(e.takedamage && e.deadflag == DEAD_NO) if(e.health > 0) if(e.monsterid != MON_SPIDER.monsterid)
103 e.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
109 void M_Spider_Attack_Web_Touch()
113 M_Spider_Attack_Web_Explode();
116 void M_Spider_Attack_Web()
118 monster_makevectors(self.enemy);
120 sound(self, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
122 entity proj = spawn ();
123 proj.classname = "plasma";
124 proj.owner = proj.realowner = self;
125 proj.use = M_Spider_Attack_Web_Explode;
126 proj.think = adaptor_think2use_hittype_splash;
127 proj.bot_dodge = true;
128 proj.bot_dodgerating = 0;
129 proj.nextthink = time + 5;
130 PROJECTILE_MAKETRIGGER(proj);
131 proj.projectiledeathtype = DEATH_MONSTER_SPIDER;
132 setorigin(proj, CENTER_OR_VIEWOFS(self));
134 //proj.glow_size = 50;
135 //proj.glow_color = 45;
136 proj.movetype = MOVETYPE_BOUNCE;
137 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);
138 proj.touch = M_Spider_Attack_Web_Touch;
139 setsize(proj, '-4 -4 -4', '4 4 4');
140 proj.takedamage = DAMAGE_NO;
141 proj.damageforcescale = 0;
143 proj.event_damage = func_null;
144 proj.flags = FL_PROJECTILE;
145 proj.damagedbycontents = true;
147 proj.bouncefactor = 0.3;
148 proj.bouncestop = 0.05;
149 proj.missile_flags = MIF_SPLASH | MIF_ARC;
151 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
154 bool M_Spider_Attack(int attack_type, entity targ)
158 Weapon wep = WEP_SPIDER_ATTACK;
159 case MONSTER_ATTACK_MELEE:
161 wep.wr_think(wep, self, false, true);
164 case MONSTER_ATTACK_RANGED:
166 wep.wr_think(wep, self, true, false);
174 void spawnfunc_monster_spider() { Monster_Spawn(MON_SPIDER.monsterid); }
178 METHOD(Spider, mr_think, bool(Spider thismon))
182 METHOD(Spider, mr_pain, bool(Spider thismon))
186 METHOD(Spider, mr_death, bool(Spider thismon))
189 setanim(self, self.anim_melee, false, true, true);
195 METHOD(Spider, mr_anim, bool(Spider thismon))
198 vector none = '0 0 0';
199 self.anim_walk = animfixfps(self, '1 1 1', none);
200 self.anim_idle = animfixfps(self, '0 1 1', none);
201 self.anim_melee = animfixfps(self, '2 1 5', none); // analyze models and set framerate
202 self.anim_shoot = animfixfps(self, '3 1 5', none); // analyze models and set framerate
203 self.anim_run = animfixfps(self, '1 1 1', none);
209 METHOD(Spider, mr_setup, bool(Spider thismon))
212 if(!self.health) self.health = (autocvar_g_monster_spider_health);
213 if(!self.speed) { self.speed = (autocvar_g_monster_spider_speed_walk); }
214 if(!self.speed2) { self.speed2 = (autocvar_g_monster_spider_speed_run); }
215 if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_spider_speed_stop); }
216 if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
218 self.monster_loot = spawnfunc_item_health_medium;
219 self.monster_attackfunc = M_Spider_Attack;
223 METHOD(Spider, mr_precache, bool(Spider thismon))