]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/wizard.qc
Move monster model precaching/loading to the client
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / wizard.qc
1 #ifndef MENUQC
2 // size
3 const vector WIZARD_MIN = '-16 -16 -45';
4 const vector WIZARD_MAX = '16 16 16';
5
6 // model
7 string WIZARD_MODEL = "models/monsters/wizard.mdl";
8
9 #endif
10
11 #ifdef SVQC
12 // cvars
13 float autocvar_g_monster_wizard;
14 float autocvar_g_monster_wizard_health;
15 float autocvar_g_monster_wizard_speed_walk;
16 float autocvar_g_monster_wizard_speed_run;
17 float autocvar_g_monster_wizard_spike_damage;
18 float autocvar_g_monster_wizard_spike_edgedamage;
19 float autocvar_g_monster_wizard_spike_radius;
20 float autocvar_g_monster_wizard_spike_speed;
21
22 // animations
23 const float wizard_anim_hover   = 0;
24 const float wizard_anim_fly     = 1;
25 const float wizard_anim_magic   = 2;
26 const float wizard_anim_pain    = 3;
27 const float wizard_anim_death   = 4;
28
29 void Wiz_FastExplode()
30 {
31         self.event_damage = func_null;
32         self.takedamage = DAMAGE_NO;
33         RadiusDamage (self, self.realowner, autocvar_g_monster_wizard_spike_damage, autocvar_g_monster_wizard_spike_edgedamage, autocvar_g_monster_wizard_spike_radius, world, 0, self.projectiledeathtype, other);
34
35         remove (self);
36 }
37
38 void Wiz_FastTouch ()
39 {
40         PROJECTILE_TOUCH;
41         
42         if(other == self.owner)
43                 return;
44                 
45         if(teamplay)
46         if(other.team == self.owner.team)
47                 return;
48                 
49         pointparticles(particleeffectnum("TE_WIZSPIKE"), self.origin, '0 0 0', 1);
50         
51         Wiz_FastExplode();
52 }
53
54 void Wiz_StartFast ()
55 {
56         local   entity  missile;
57         local   vector  dir = '0 0 0';
58         local   float   dist = 0, flytime = 0;
59         
60         self.attack_finished_single = time + 0.2;
61
62         dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
63         dist = vlen (self.enemy.origin - self.origin);
64         flytime = dist * 0.002;
65         if (flytime < 0.1)
66                 flytime = 0.1;
67         
68         self.v_angle = self.angles;
69         makevectors (self.angles);
70
71         missile = spawn ();
72         missile.owner = missile.realowner = self;
73         setsize (missile, '0 0 0', '0 0 0');            
74         setorigin (missile, self.origin + v_forward * 14 + '0 0 30' + v_right * 14);
75         missile.enemy = self.enemy;
76         missile.nextthink = time + 3;
77         missile.think = Wiz_FastExplode;
78         missile.velocity = dir * autocvar_g_monster_wizard_spike_speed;
79         missile.avelocity = '300 300 300';
80         missile.solid = SOLID_BBOX;
81         missile.movetype = MOVETYPE_FLYMISSILE;
82         missile.touch = Wiz_FastTouch;
83         missile.projectiledeathtype = DEATH_MONSTER_SCRAG;
84         CSQCProjectile(missile, TRUE, PROJECTILE_CRYLINK, TRUE);
85         
86         missile = spawn ();
87         missile.owner = missile.realowner = self;
88         setsize (missile, '0 0 0', '0 0 0');            
89         setorigin (missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14);
90         missile.enemy = self.enemy;
91         missile.nextthink = time + 3;
92         missile.touch = Wiz_FastTouch;
93         missile.solid = SOLID_BBOX;
94         missile.movetype = MOVETYPE_FLYMISSILE;
95         missile.think = Wiz_FastExplode;
96         missile.velocity = dir * autocvar_g_monster_wizard_spike_speed;
97         missile.avelocity = '300 300 300';
98         missile.projectiledeathtype = DEATH_MONSTER_SCRAG;
99         CSQCProjectile(missile, TRUE, PROJECTILE_CRYLINK, TRUE);
100 }
101
102 void wizard_think ()
103 {
104         self.think = wizard_think;
105         self.nextthink = time + self.ticrate;
106         
107         monster_move(autocvar_g_monster_wizard_speed_run, autocvar_g_monster_wizard_speed_walk, 300, wizard_anim_fly, wizard_anim_hover, wizard_anim_hover);
108 }
109
110 void wizard_fastattack ()
111 {
112         Wiz_StartFast();
113 }
114
115 void wizard_die ()
116 {
117         Monster_CheckDropCvars ("wizard");
118         
119         self.think                      = Monster_Fade;
120         self.nextthink          = time + 5;
121         self.flags                      = FL_ONGROUND;
122         self.velocity_x         = -200 + 400 * random();
123         self.velocity_y         = -200 + 400 * random();
124         self.velocity_z         = 100 + 100 * random();
125         
126         monsters_setframe(wizard_anim_death);
127         
128         monster_hook_death(); // for post-death mods
129 }
130
131 float Wiz_Missile ()
132 {
133         wizard_fastattack();
134         return TRUE;
135 }
136
137 void wizard_spawn ()
138 {
139         if not(self.health)
140                 self.health = autocvar_g_monster_wizard_health * self.scale;
141         
142         self.classname                  = "monster_wizard";
143         self.checkattack                = GenericCheckAttack;
144         self.attack_ranged              = Wiz_Missile;
145         self.nextthink                  = time + random() * 0.5 + 0.1;
146         self.movetype                   = MOVETYPE_FLY; // TODO: make it fly up/down
147         self.flags                         |= FL_FLY;
148         self.think                              = wizard_think;
149         self.sprite_height              = 30;
150         
151         monster_hook_spawn(); // for post-spawn mods
152 }
153
154 void spawnfunc_monster_wizard ()
155 {       
156         if not(autocvar_g_monster_wizard) { remove(self); return; }
157         
158         self.monster_spawnfunc = spawnfunc_monster_wizard;
159         
160         if(Monster_CheckAppearFlags(self))
161                 return;
162         
163         self.scale = 1.3;
164         
165         if not (monster_initialize(
166                          "Scrag", MONSTER_SCRAG,
167                          WIZARD_MIN, WIZARD_MAX,
168                          TRUE,
169                          wizard_die, wizard_spawn))
170         {
171                 remove(self);
172                 return;
173         }
174         
175         precache_model ("models/spike.mdl");
176         precache_sound ("weapons/spike.wav");
177 }
178
179 // compatibility with old spawns
180 void spawnfunc_monster_scrag () { spawnfunc_monster_wizard(); }
181
182 #endif // SVQC