]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/knight.qc
Fix hell-knight .think usage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / knight.qc
1 #ifndef MENUQC
2 // size
3 const vector KNIGHT_MIN = '-16 -16 -24';
4 const vector KNIGHT_MAX = '16 16 32';
5
6 // model
7 string KNIGHT_MODEL = "models/monsters/knight.mdl";
8
9 #endif
10
11 #ifdef SVQC
12 // cvars
13 float autocvar_g_monster_knight;
14 float autocvar_g_monster_knight_health;
15 float autocvar_g_monster_knight_melee_damage;
16 float autocvar_g_monster_knight_speed_walk;
17 float autocvar_g_monster_knight_speed_run;
18
19 // animations
20 const float knight_anim_stand           = 0;
21 const float knight_anim_run             = 1;
22 const float knight_anim_runattack       = 2;
23 const float knight_anim_pain1           = 3;
24 const float knight_anim_pain2           = 4;
25 const float knight_anim_attack          = 5;
26 const float knight_anim_walk            = 6;
27 const float knight_anim_kneel           = 7;
28 const float knight_anim_standing        = 8;
29 const float knight_anim_death1          = 9;
30 const float knight_anim_death2          = 10;
31
32 void knight_think ()
33 {
34         self.think = knight_think;
35         self.nextthink = time + self.ticrate;
36         
37         monster_move(autocvar_g_monster_knight_speed_run, autocvar_g_monster_knight_speed_walk, 50, knight_anim_run, knight_anim_walk, knight_anim_stand);
38 }
39
40 void knight_attack ()
41 {
42         float len = vlen(self.velocity);
43
44         monsters_setframe((len < 50) ? knight_anim_attack : knight_anim_runattack);
45         
46         self.attack_finished_single = time + 1.25;
47         
48         monster_melee(self.enemy, autocvar_g_monster_knight_melee_damage, 0.3, DEATH_MONSTER_KNIGHT, FALSE);
49 }
50
51 void knight_die ()
52 {
53         Monster_CheckDropCvars ("knight");
54         
55         self.think = monster_dead_think;
56         self.nextthink = time + self.ticrate;
57         self.ltime = time + 5;
58         monsters_setframe((random() > 0.5) ? knight_anim_death1 : knight_anim_death2);
59         
60         monster_hook_death(); // for post-death mods
61 }
62
63 void knight_spawn ()
64 {
65         if not(self.health)
66                 self.health = autocvar_g_monster_knight_health * self.scale;
67
68         self.damageforcescale   = 0.003;
69         self.classname                  = "monster_knight";
70         self.checkattack                = GenericCheckAttack;
71         self.attack_melee               = knight_attack;
72         self.nextthink                  = time + random() * 0.5 + 0.1;
73         self.think                              = knight_think;
74         
75         monsters_setframe(knight_anim_stand);
76         
77         monster_setupsounds("knight");
78         
79         monster_hook_spawn(); // for post-spawn mods
80 }
81
82 void spawnfunc_monster_knight ()
83 {       
84         if not(autocvar_g_monster_knight) { remove(self); return; }
85         
86         self.monster_spawnfunc = spawnfunc_monster_knight;
87         
88         if(Monster_CheckAppearFlags(self))
89                 return;
90         
91         self.scale = 1.3;
92         
93         if not (monster_initialize(
94                          "Knight", MONSTER_KNIGHT,
95                          KNIGHT_MIN, KNIGHT_MAX,
96                          FALSE,
97                          knight_die, knight_spawn))
98         {
99                 remove(self);
100                 return;
101         }
102 }
103
104 #endif // SVQC