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