]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/slime.qc
Replace monsters config with a modified dumped config
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / slime.qc
1 #ifdef REGISTER_MONSTER
2 REGISTER_MONSTER(
3 /* MON_##id   */ SLIME,
4 /* function   */ m_slime,
5 /* spawnflags */ 0,
6 /* mins,maxs  */ '-16 -16 -24', '16 16 16',
7 /* model      */ "slime.dpm",
8 /* netname    */ "slime",
9 /* fullname   */ _("Slime")
10 );
11
12 #define SLIME_SETTINGS(monster) \
13         MON_ADD_CVAR(monster, health) \
14         MON_ADD_CVAR(monster, attack_explode_damage) \
15         MON_ADD_CVAR(monster, speed_stop) \
16         MON_ADD_CVAR(monster, speed_run) \
17         MON_ADD_CVAR(monster, speed_walk) 
18
19 #ifdef SVQC
20 SLIME_SETTINGS(slime)
21 #endif // SVQC
22 #else
23 #ifdef SVQC
24 const float slime_anim_walk             = 0;
25 const float slime_anim_idle             = 1;
26 const float slime_anim_jump             = 2;
27 const float slime_anim_fly              = 3;
28 const float slime_anim_die              = 4;
29 const float slime_anim_pain             = 5;
30
31 void slime_touch_jump()
32 {
33         if(self.health > 0)
34         if(other.health > 0)
35         if(other.takedamage)
36         if(vlen(self.velocity) > 200)
37         {
38                 Damage (self, world, world, MON_CVAR(slime, attack_explode_damage), DEATH_MONSTER_SLIME, 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 float slime_attack(float attack_type)
51 {
52         switch(attack_type)
53         {
54                 case MONSTER_ATTACK_MELEE:
55                 case MONSTER_ATTACK_RANGED:
56                 {
57                         makevectors(self.angles);
58                         if(monster_leap(slime_anim_jump, slime_touch_jump, v_forward * 600 + '0 0 200', 0.5))
59                                 return TRUE;
60                 }
61         }
62         
63         return FALSE;
64 }
65
66 void slime_explode()
67 {
68         RadiusDamage(self, self, MON_CVAR(slime, attack_explode_damage), 15, MON_CVAR(slime, attack_explode_damage) * 0.7, world, 250, DEATH_MONSTER_SLIME, world);
69         pointparticles(particleeffectnum("explosion_medium"), self.origin, '0 0 0', 1);
70         sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
71         
72         setmodel(self, "");
73 }
74
75 void slime_dead()
76 {
77         self.health = -100; // gibbed
78         slime_explode();
79         
80         Monster_CheckDropCvars (self.netname); // TODO: add a special function to drop items after death
81         
82         self.deadflag = DEAD_DEAD;
83         self.think = Monster_Fade;
84         self.nextthink = time + 0.1;
85 }
86
87 void spawnfunc_monster_slime()
88 {
89         self.classname = "monster_slime";
90         
91         self.monster_spawnfunc = spawnfunc_monster_slime;
92         
93         if(Monster_CheckAppearFlags(self))
94                 return;
95         
96         if not(monster_initialize(MON_SLIME, FALSE)) { remove(self); return; }
97 }
98
99 // compatibility with old spawns
100 void spawnfunc_monster_tarbaby() { spawnfunc_monster_slime(); }
101
102 float m_slime(float req)
103 {
104         switch(req)
105         {
106                 case MR_THINK:
107                 {
108                         monster_move(MON_CVAR(slime, speed_run), MON_CVAR(slime, speed_walk), MON_CVAR(slime, speed_stop), slime_anim_walk, slime_anim_walk, slime_anim_idle);
109                         return TRUE;
110                 }
111                 case MR_DEATH:
112                 {
113                         self.think                      = slime_dead;
114                         self.nextthink          = time;
115                         self.event_damage   = func_null;
116                         self.movetype           = MOVETYPE_NONE;
117                         self.takedamage         = DAMAGE_NO;
118                         self.enemy                      = world;
119                         self.health                     = 0;
120                         
121                         self.SendFlags |= MSF_MOVE | MSF_STATUS;
122                         
123                         return TRUE;
124                 }
125                 case MR_SETUP:
126                 {
127                         if not(self.health) self.health = MON_CVAR(slime, health);
128                                 
129                         self.monster_attackfunc = slime_attack;
130                         monsters_setframe(slime_anim_idle);
131                         
132                         return TRUE;
133                 }
134                 case MR_INIT:
135                 {
136                         // nothing
137                         return TRUE;
138                 }
139                 case MR_CONFIG:
140                 {
141                         MON_CONFIG_SETTINGS(SLIME_SETTINGS(slime))
142                         return TRUE;
143                 }
144         }
145         
146         return TRUE;
147 }
148
149 #endif // SVQC
150 #ifdef CSQC
151 float m_slime(float req)
152 {
153         switch(req)
154         {
155                 case MR_DEATH:
156                 {
157                         // nothing
158                         return TRUE;
159                 }
160                 case MR_INIT:
161                 {
162                         precache_model ("models/monsters/slime.dpm");
163                         return TRUE;
164                 }
165         }
166         
167         return TRUE;
168 }
169
170 #endif // CSQC
171 #endif // REGISTER_MONSTER