]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/stingray.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / stingray.qc
1 // size
2 const vector STINGRAY_MIN = '-20 -20 -31';
3 const vector STINGRAY_MAX = '20 20 20';
4
5 // model
6 string STINGRAY_MODEL = "models/monsters/fish.mdl";
7
8 #ifdef SVQC
9 // cvars
10 float autocvar_g_monster_stingray;
11 float autocvar_g_monster_stingray_health;
12 float autocvar_g_monster_stingray_damage;
13 float autocvar_g_monster_stingray_speed_walk;
14 float autocvar_g_monster_stingray_speed_run;
15
16 // animations
17 const float stingray_anim_attack = 0;
18 const float stingray_anim_death  = 1;
19 const float stingray_anim_swim   = 2;
20 const float stingray_anim_pain   = 3;
21
22 void stingray_think ()
23 {
24         self.think = stingray_think;
25         self.nextthink = time + self.ticrate;
26         
27         monster_move(autocvar_g_monster_stingray_speed_run, autocvar_g_monster_stingray_speed_walk, 10, stingray_anim_swim, stingray_anim_swim, stingray_anim_swim);
28 }
29
30 float stingray_attack(float attack_type)
31 {
32         switch(attack_type)
33         {
34                 case MONSTER_ATTACK_MELEE:
35                 {
36                         monsters_setframe(stingray_anim_attack);
37                         self.attack_finished_single = time + 0.5;
38                         monster_melee(self.enemy, autocvar_g_monster_stingray_damage, 0.1, DEATH_MONSTER_STINGRAY, FALSE);
39                         
40                         return TRUE;
41                 }
42                 case MONSTER_ATTACK_RANGED:
43         }
44         
45         return FALSE;
46 }
47
48 void stingray_die ()
49 {
50         Monster_CheckDropCvars ("stingray");
51         
52         self.think = monster_dead_think;
53         self.nextthink = time + self.ticrate;
54         self.ltime = time + 5;
55         monsters_setframe(stingray_anim_death);
56         
57         monster_hook_death(); // for post-death mods
58 }
59
60 void stingray_spawn ()
61 {
62         if not(self.health)
63                 self.health = autocvar_g_monster_stingray_health;
64
65         self.damageforcescale   = 0.5;
66         self.classname                  = "monster_stingray";
67         self.monster_attackfunc = stingray_attack;
68         self.flags                         |= FL_SWIM;
69         self.nextthink                  = time + random() * 0.5 + 0.1;
70         self.think                              = stingray_think;
71         
72         monster_setupsounds("stingray");
73         
74         monster_hook_spawn(); // for post-spawn mods
75 }
76
77 void spawnfunc_monster_stingray ()
78 {       
79         if not(autocvar_g_monster_stingray) { remove(self); return; }
80         
81         self.monster_spawnfunc = spawnfunc_monster_stingray;
82         
83         if(Monster_CheckAppearFlags(self))
84                 return;
85         
86         self.scale = 1.3;
87         
88         if not (monster_initialize(
89                          "Stingray", MONSTER_STINGRAY,
90                          STINGRAY_MIN, STINGRAY_MAX,
91                          TRUE,
92                          stingray_die, stingray_spawn))
93         {
94                 remove(self);
95                 return;
96         }
97 }
98
99 #endif // SVQC