]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/tarbaby.qc
Move monster model precaching/loading to the client
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / tarbaby.qc
1 #ifndef MENUQC
2 // size
3 const vector TARBABY_MIN = '-16 -16 -24';
4 const vector TARBABY_MAX = '16 16 16';
5
6 // model
7 string TARBABY_MODEL = "models/monsters/tarbaby.mdl";
8
9 #endif
10
11 #ifdef SVQC
12 // cvars
13 float autocvar_g_monster_tarbaby;
14 float autocvar_g_monster_tarbaby_health;
15 float autocvar_g_monster_tarbaby_speed_walk;
16 float autocvar_g_monster_tarbaby_speed_run;
17
18 // animations
19 const float tarbaby_anim_walk           = 0;
20 const float tarbaby_anim_run            = 1;
21 const float tarbaby_anim_jump           = 2;
22 const float tarbaby_anim_fly            = 3;
23 const float tarbaby_anim_explode        = 4;
24
25 void tarbaby_think ()
26 {
27         self.think = tarbaby_think;
28         self.nextthink = time + self.ticrate;
29         
30         monster_move(autocvar_g_monster_tarbaby_speed_run, autocvar_g_monster_tarbaby_speed_walk, 20, tarbaby_anim_run, tarbaby_anim_walk, tarbaby_anim_walk);
31 }
32
33 void Tar_JumpTouch ()
34 {
35         if(self.health > 0)
36         if(other.health > 0)
37         if(other.takedamage)
38         if(vlen(self.velocity) > 200)
39         {
40                 // make the monster die
41                 self.event_damage(self, self, self.health + self.max_health + 200, DEATH_MONSTER_TARBABY, self.origin, '0 0 0');
42                         
43                 return;
44         }
45
46         if (trace_dphitcontents)
47         {
48                 if not(self.flags & FL_ONGROUND)
49                 {
50                         self.touch = MonsterTouch;
51                         self.flags |= FL_ONGROUND;
52                         self.movetype = MOVETYPE_WALK;
53                 }
54         }
55 }
56
57 void tarbaby_jump ()
58 {
59         if not(self.flags & FL_ONGROUND)
60                 return;
61         monsters_setframe(tarbaby_anim_jump);
62         self.movetype = MOVETYPE_BOUNCE;
63         self.touch = Tar_JumpTouch;
64         makevectors (self.angles);
65         self.origin_z += 1;
66         self.velocity = v_forward * 600 + '0 0 200';
67         self.velocity_z += random()*150;
68         if (self.flags & FL_ONGROUND)
69                 self.flags -= FL_ONGROUND;
70                 
71         self.attack_finished_single = time + 0.5;
72 }
73
74 float tbaby_jump ()
75 {
76         tarbaby_jump();
77         return TRUE;
78 }
79
80 void tarbaby_blowup ()
81 {
82         float bigboom = 250 * (self.scale * 0.7);
83         RadiusDamage(self, self, 250 * monster_skill, 15, bigboom * (monster_skill * 0.7), world, 250, DEATH_MONSTER_TARBABY, world);
84         pointparticles(particleeffectnum(((self.scale > 3) ? "explosion_big" : "explosion_medium")), self.origin, '0 0 0', 1);
85         sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
86         
87         Monster_CheckDropCvars ("tarbaby"); // drop items after exploding to prevent player picking up item before dying
88         
89         setmodel(self, "");
90 }
91
92 void tarbaby_explode()
93 {
94         tarbaby_blowup();
95         
96         self.think = Monster_Fade;
97         self.nextthink = time + 0.1;
98         
99         monster_hook_death(); // calling this next frame should be ok...
100 }
101
102 void tarbaby_die ()
103 {
104         self.think                      = tarbaby_explode;
105         self.nextthink          = time + 0.1;
106         self.event_damage   = func_null;
107         self.movetype           = MOVETYPE_NONE;
108         self.enemy                      = world;
109         self.health                     = 0;
110         
111         WaypointSprite_Kill(self.sprite);
112         
113         self.SendFlags          |= MSF_MOVE | MSF_STATUS;
114 }
115
116 void tarbaby_spawn ()
117 {
118         if not(self.health)
119                 self.health = autocvar_g_monster_tarbaby_health * self.scale;
120         
121         self.damageforcescale   = 0.003;
122         self.classname                  = "monster_tarbaby";
123         self.checkattack                = GenericCheckAttack;
124         self.attack_ranged              = tbaby_jump;
125         self.attack_melee               = tarbaby_jump;
126         self.nextthink                  = time + random() * 0.5 + 0.1;
127         self.think                              = tarbaby_think;
128         self.sprite_height              = 20;
129         
130         monsters_setframe(tarbaby_anim_walk);
131         
132         monster_hook_spawn(); // for post-spawn mods
133 }
134
135 void spawnfunc_monster_tarbaby ()
136 {       
137         if not(autocvar_g_monster_tarbaby) { remove(self); return; }
138         
139         self.monster_spawnfunc = spawnfunc_monster_tarbaby;
140         
141         if(Monster_CheckAppearFlags(self))
142                 return;
143         
144         self.scale = 1.3;
145         
146         if not (monster_initialize(
147                          "Spawn", MONSTER_TARBABY,
148                          TARBABY_MIN, TARBABY_MAX,
149                          FALSE,
150                          tarbaby_die, tarbaby_spawn))
151         {
152                 remove(self);
153                 return;
154         }
155         
156         precache_sound ("weapons/rocket_impact.wav");
157 }
158
159 // compatibility with old spawns
160 void spawnfunc_monster_spawn () { spawnfunc_monster_tarbaby(); }
161
162 #endif // SVQC