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