]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/spider.qc
Hide the MOTD when going spec
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / spider.qc
1 #ifndef SPIDER_H
2 #define SPIDER_H
3
4 #ifndef MENUQC
5 MODEL(MON_SPIDER, "models/monsters/spider.dpm");
6 #endif
7
8 CLASS(Spider, Monster)
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');
12 #ifndef MENUQC
13     ATTRIB(Spider, m_model, Model, MDL_MON_SPIDER);
14 #endif
15     ATTRIB(Spider, netname, string, "spider");
16     ATTRIB(Spider, monster_name, string, _("Spider"));
17 ENDCLASS(Spider)
18
19 REGISTER_MONSTER(SPIDER, NEW(Spider)) {
20 #ifndef MENUQC
21     this.mr_precache(this);
22 #endif
23 }
24
25 #include "../../weapons/all.qh"
26
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, message, string, _("Spider attack"));
32 ENDCLASS(SpiderAttack)
33 REGISTER_WEAPON(SPIDER_ATTACK, NEW(SpiderAttack));
34
35 #endif
36
37 #ifdef IMPLEMENTATION
38
39 #ifdef SVQC
40
41 .float spider_web_delay;
42
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;
47
48 float autocvar_g_monster_spider_attack_bite_damage;
49 float autocvar_g_monster_spider_attack_bite_delay;
50
51 void M_Spider_Attack_Web();
52
53 METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) {
54     bool isPlayer = IS_PLAYER(actor);
55     if (fire1)
56     if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, false, autocvar_g_monster_spider_attack_web_delay)) {
57                 if (!isPlayer) {
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;
62                 }
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);
68         return;
69     }
70     if (fire2)
71     if (!isPlayer || weapon_prepareattack(thiswep, actor, true, 0.5)) {
72         if (isPlayer) {
73                 actor.enemy = Monster_FindTarget(actor);
74                 actor.attack_range = 60;
75         }
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.m_id, true);
77         weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
78     }
79 }
80
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;
86
87 /*
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;
92 */
93
94 void M_Spider_Attack_Web_Explode()
95 {SELFPARAM();
96         entity e;
97         if(self)
98         {
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);
101
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);
104
105                 remove(self);
106         }
107 }
108
109 void M_Spider_Attack_Web_Touch()
110 {
111         PROJECTILE_TOUCH;
112
113         M_Spider_Attack_Web_Explode();
114 }
115
116 void adaptor_think2use_hittype_splash();
117
118 void M_Spider_Attack_Web()
119 {SELFPARAM();
120         monster_makevectors(self.enemy);
121
122         sound(self, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
123
124         entity proj = spawn ();
125         proj.classname = "plasma";
126         proj.owner = proj.realowner = self;
127         proj.use = M_Spider_Attack_Web_Explode;
128         proj.think = adaptor_think2use_hittype_splash;
129         proj.bot_dodge = true;
130         proj.bot_dodgerating = 0;
131         proj.nextthink = time + 5;
132         PROJECTILE_MAKETRIGGER(proj);
133         proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
134         setorigin(proj, CENTER_OR_VIEWOFS(self));
135
136         //proj.glow_size = 50;
137         //proj.glow_color = 45;
138         proj.movetype = MOVETYPE_BOUNCE;
139         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);
140         proj.touch = M_Spider_Attack_Web_Touch;
141         setsize(proj, '-4 -4 -4', '4 4 4');
142         proj.takedamage = DAMAGE_NO;
143         proj.damageforcescale = 0;
144         proj.health = 500;
145         proj.event_damage = func_null;
146         proj.flags = FL_PROJECTILE;
147         proj.damagedbycontents = true;
148
149         proj.bouncefactor = 0.3;
150         proj.bouncestop = 0.05;
151         proj.missile_flags = MIF_SPLASH | MIF_ARC;
152
153         CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
154 }
155
156 bool M_Spider_Attack(int attack_type, entity targ)
157 {SELFPARAM();
158         switch(attack_type)
159         {
160                 Weapon wep = WEP_SPIDER_ATTACK;
161                 case MONSTER_ATTACK_MELEE:
162                 {
163                         wep.wr_think(wep, self, false, true);
164                         return true;
165                 }
166                 case MONSTER_ATTACK_RANGED:
167                 {
168                         wep.wr_think(wep, self, true, false);
169                         return true;
170                 }
171         }
172
173         return false;
174 }
175
176 spawnfunc(monster_spider) { Monster_Spawn(MON_SPIDER.monsterid); }
177 #endif // SVQC
178
179                 #ifdef SVQC
180                 METHOD(Spider, mr_think, bool(Spider thismon))
181                 {
182                         return true;
183                 }
184                 METHOD(Spider, mr_pain, bool(Spider thismon))
185                 {
186                         return true;
187                 }
188                 METHOD(Spider, mr_death, bool(Spider thismon))
189                 {
190                         SELFPARAM();
191                         setanim(self, self.anim_melee, false, true, true);
192                         self.angles_x = 180;
193                         return true;
194                 }
195                 #endif
196                 #ifndef MENUQC
197                 METHOD(Spider, mr_anim, bool(Spider thismon))
198                 {
199                         SELFPARAM();
200                         vector none = '0 0 0';
201                         self.anim_walk = animfixfps(self, '1 1 1', none);
202                         self.anim_idle = animfixfps(self, '0 1 1', none);
203                         self.anim_melee = animfixfps(self, '2 1 5', none); // analyze models and set framerate
204                         self.anim_shoot = animfixfps(self, '3 1 5', none); // analyze models and set framerate
205                         self.anim_run = animfixfps(self, '1 1 1', none);
206
207                         return true;
208                 }
209                 #endif
210                 #ifdef SVQC
211                 spawnfunc(item_health_medium);
212                 METHOD(Spider, mr_setup, bool(Spider thismon))
213                 {
214                         SELFPARAM();
215                         if(!self.health) self.health = (autocvar_g_monster_spider_health);
216                         if(!self.speed) { self.speed = (autocvar_g_monster_spider_speed_walk); }
217                         if(!self.speed2) { self.speed2 = (autocvar_g_monster_spider_speed_run); }
218                         if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_spider_speed_stop); }
219                         if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
220
221                         self.monster_loot = spawnfunc_item_health_medium;
222                         self.monster_attackfunc = M_Spider_Attack;
223
224                         return true;
225                 }
226                 METHOD(Spider, mr_precache, bool(Spider thismon))
227                 {
228                         return true;
229                 }
230                 #endif
231
232 #endif