]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/stingray.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / stingray.qc
1 #ifdef REGISTER_MONSTER
2 REGISTER_MONSTER(
3 /* MON_##id   */ STINGRAY,
4 /* function   */ m_stingray,
5 /* spawnflags */ MONSTER_TYPE_SWIM | MONSTER_SIZE_BROKEN | MON_FLAG_MELEE,
6 /* mins,maxs  */ '-20 -20 -31', '20 20 20',
7 /* model      */ "fish.mdl",
8 /* netname    */ "stingray",
9 /* fullname   */ _("Stingray")
10 );
11
12 #define STINGRAY_SETTINGS(monster) \
13         MON_ADD_CVAR(monster, health) \
14         MON_ADD_CVAR(monster, attack_bite_damage) \
15         MON_ADD_CVAR(monster, attack_bite_delay) \
16         MON_ADD_CVAR(monster, speed_stop) \
17         MON_ADD_CVAR(monster, speed_run) \
18         MON_ADD_CVAR(monster, speed_walk) 
19
20 #ifdef SVQC
21 STINGRAY_SETTINGS(stingray)
22 #endif // SVQC
23 #else
24 #ifdef SVQC
25 const float stingray_anim_attack = 0;
26 const float stingray_anim_death  = 1;
27 const float stingray_anim_swim   = 2;
28 const float stingray_anim_pain   = 3;
29
30 float stingray_attack(float attack_type)
31 {
32         switch(attack_type)
33         {
34                 case MONSTER_ATTACK_MELEE:
35                 {
36                         return monster_melee(self.enemy, MON_CVAR(stingray, attack_bite_damage), stingray_anim_attack, self.attack_range, MON_CVAR(stingray, attack_bite_delay), DEATH_MONSTER_STINGRAY, FALSE);
37                 }
38                 case MONSTER_ATTACK_RANGED:
39                 {
40                         // no ranged attack for stingray (yet?)
41                         return FALSE;
42                 }
43         }
44         
45         return FALSE;
46 }
47
48 void spawnfunc_monster_stingray()
49 {
50         self.classname = "monster_stingray";
51         
52         self.monster_spawnfunc = spawnfunc_monster_stingray;
53         
54         if(Monster_CheckAppearFlags(self))
55                 return;
56         
57         if not(monster_initialize(MON_STINGRAY, TRUE)) { remove(self); return; }
58 }
59
60 float m_stingray(float req)
61 {
62         switch(req)
63         {
64                 case MR_THINK:
65                 {
66                         monster_move(MON_CVAR(stingray, speed_run), MON_CVAR(stingray, speed_walk), MON_CVAR(stingray, speed_stop), stingray_anim_swim, stingray_anim_swim, stingray_anim_swim);
67                         return TRUE;
68                 }
69                 case MR_DEATH:
70                 {
71                         monsters_setframe(stingray_anim_death);
72                         return TRUE;
73                 }
74                 case MR_SETUP:
75                 {
76                         if not(self.health) self.health = MON_CVAR(stingray, health);
77                         
78                         self.monster_loot = spawnfunc_item_health_small;
79                         self.monster_attackfunc = stingray_attack;
80                         monsters_setframe(stingray_anim_swim);
81                         
82                         return TRUE;
83                 }
84                 case MR_INIT:
85                 {
86                         // nothing
87                         return TRUE;
88                 }
89                 case MR_CONFIG:
90                 {
91                         MON_CONFIG_SETTINGS(STINGRAY_SETTINGS(stingray))
92                         return TRUE;
93                 }
94         }
95         
96         return TRUE;
97 }
98
99 #endif // SVQC
100 #ifdef CSQC
101 float m_stingray(float req)
102 {
103         switch(req)
104         {
105                 case MR_DEATH:
106                 {
107                         // nothing
108                         return TRUE;
109                 }
110                 case MR_INIT:
111                 {
112                         precache_model ("models/monsters/fish.mdl");
113                         return TRUE;
114                 }
115         }
116         
117         return TRUE;
118 }
119
120 #endif // CSQC
121 #endif // REGISTER_MONSTER