]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/knight.qc
Remove enforcer & all W_ attack functions from the monster code
[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_Fade;
56         self.nextthink = time + 5;
57         monsters_setframe((random() > 0.5) ? knight_anim_death1 : knight_anim_death2);
58         
59         monster_hook_death(); // for post-death mods
60 }
61
62 void knight_spawn ()
63 {
64         if not(self.health)
65                 self.health = autocvar_g_monster_knight_health * self.scale;
66
67         self.damageforcescale   = 0.003;
68         self.classname                  = "monster_knight";
69         self.checkattack                = GenericCheckAttack;
70         self.attack_melee               = knight_attack;
71         self.nextthink                  = time + random() * 0.5 + 0.1;
72         self.think                              = knight_think;
73         self.sprite_height              = 30;
74         self.view_ofs              *= 0.5;
75         
76         monsters_setframe(knight_anim_stand);
77         
78         monster_setupsounds("knight");
79         
80         monster_hook_spawn(); // for post-spawn mods
81 }
82
83 void spawnfunc_monster_knight ()
84 {       
85         if not(autocvar_g_monster_knight) { remove(self); return; }
86         
87         self.monster_spawnfunc = spawnfunc_monster_knight;
88         
89         if(Monster_CheckAppearFlags(self))
90                 return;
91         
92         self.scale = 1.3;
93         
94         if not (monster_initialize(
95                          "Knight", MONSTER_KNIGHT,
96                          KNIGHT_MIN, KNIGHT_MAX,
97                          FALSE,
98                          knight_die, knight_spawn))
99         {
100                 remove(self);
101                 return;
102         }
103 }
104
105 #endif // SVQC