]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/fish.qc
Replace enforcer model with e-wheel
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / fish.qc
1 // size
2 const vector FISH_MIN = '-16 -16 -24';
3 const vector FISH_MAX = '16 16 16';
4
5 // cvars
6 float autocvar_g_monster_fish;
7 float autocvar_g_monster_fish_health;
8 float autocvar_g_monster_fish_damage;
9 float autocvar_g_monster_fish_speed_walk;
10 float autocvar_g_monster_fish_speed_run;
11
12 // animations
13 #define fish_anim_attack 0
14 #define fish_anim_death  1
15 #define fish_anim_swim   2
16 #define fish_anim_pain   3
17
18 void fish_think ()
19 {
20         self.think = fish_think;
21         self.nextthink = time + 0.1;
22         
23         monster_move(autocvar_g_monster_fish_speed_run, autocvar_g_monster_fish_speed_walk, 10, fish_anim_swim, fish_anim_swim, fish_anim_swim);
24 }
25
26 void fish_attack ()
27 {
28         float bigdmg = autocvar_g_monster_fish_damage * self.scale;
29         
30         self.frame = fish_anim_attack;
31         self.attack_finished_single = time + 0.5;
32
33         monster_melee(self.enemy, bigdmg * monster_skill, 60, DEATH_MONSTER_FISH_BITE);
34 }
35
36 void fish_die ()
37 {
38         Monster_CheckDropCvars ("fish");
39         
40         self.solid                      = SOLID_NOT;
41         self.takedamage         = DAMAGE_NO;
42         self.event_damage   = func_null;
43         self.enemy                      = world;
44         self.pain_finished  = self.nextthink;
45         self.frame                      = fish_anim_death;
46         self.think                      = Monster_Fade;
47         self.nextthink          = time + 2.1;
48         
49         monster_hook_death(); // for post-death mods
50 }
51
52 void fish_spawn ()
53 {
54         if not(self.health)
55                 self.health = autocvar_g_monster_fish_health * self.scale;
56
57         self.damageforcescale   = 0.5;
58         self.classname                  = "monster_fish";
59         self.checkattack                = GenericCheckAttack;
60         self.attack_melee               = fish_attack;
61         self.flags                         |= FL_SWIM;
62         self.nextthink                  = time + random() * 0.5 + 0.1;
63         self.think                              = fish_think;
64         self.sprite_height              = 20 * self.scale;
65         
66         monster_hook_spawn(); // for post-spawn mods
67 }
68
69 void spawnfunc_monster_fish ()
70 {       
71         if not(autocvar_g_monster_fish) { remove(self); return; }
72         
73         self.monster_spawnfunc = spawnfunc_monster_fish;
74         
75         if(self.spawnflags & MONSTERFLAG_APPEAR)
76         {
77                 self.think = func_null;
78                 self.nextthink = -1;
79                 self.use = Monster_Appear;
80                 return;
81         }
82         
83         self.scale = 1.3;
84         
85         if not (monster_initialize(
86                          "Rotfish",
87                          "models/monsters/fish.mdl",
88                          FISH_MIN, FISH_MAX,
89                          TRUE,
90                          fish_die, fish_spawn))
91         {
92                 remove(self);
93                 return;
94         }
95 }