]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/bruiser.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / bruiser.qc
1 // size
2 const vector BRUISER_MIN = '-20 -20 -31';
3 const vector BRUISER_MAX = '20 20 53';
4
5 // model
6 string BRUISER_MODEL = "models/monsters/knight.mdl";
7
8 #ifdef SVQC
9 // cvars
10 float autocvar_g_monster_bruiser;
11 float autocvar_g_monster_bruiser_health;
12 float autocvar_g_monster_bruiser_melee_damage;
13 float autocvar_g_monster_bruiser_speed_walk;
14 float autocvar_g_monster_bruiser_speed_run;
15
16 // animations
17 const float bruiser_anim_stand          = 0;
18 const float bruiser_anim_run            = 1;
19 const float bruiser_anim_runattack      = 2;
20 const float bruiser_anim_pain1          = 3;
21 const float bruiser_anim_pain2          = 4;
22 const float bruiser_anim_attack         = 5;
23 const float bruiser_anim_walk           = 6;
24 const float bruiser_anim_kneel          = 7;
25 const float bruiser_anim_standing       = 8;
26 const float bruiser_anim_death1         = 9;
27 const float bruiser_anim_death2         = 10;
28
29 void bruiser_think ()
30 {
31         self.think = bruiser_think;
32         self.nextthink = time + self.ticrate;
33         
34         monster_move(autocvar_g_monster_bruiser_speed_run, autocvar_g_monster_bruiser_speed_walk, 50, bruiser_anim_run, bruiser_anim_walk, bruiser_anim_stand);
35 }
36
37 float bruiser_attack(float attack_type)
38 {
39         switch(attack_type)
40         {
41                 case MONSTER_ATTACK_MELEE:
42                 {
43                         float len = vlen(self.velocity);
44                         monsters_setframe((len < 50) ? bruiser_anim_attack : bruiser_anim_runattack);
45                         self.attack_finished_single = time + 1.25;
46                         
47                         monster_melee(self.enemy, autocvar_g_monster_bruiser_melee_damage, 0.3, DEATH_MONSTER_BRUISER, FALSE);
48                         
49                         return TRUE;
50                 }
51                 case MONSTER_ATTACK_RANGED:
52         }
53         
54         return FALSE;
55 }
56
57 void bruiser_die ()
58 {
59         Monster_CheckDropCvars ("bruiser");
60         
61         self.think = monster_dead_think;
62         self.nextthink = time + self.ticrate;
63         self.ltime = time + 5;
64         monsters_setframe((random() > 0.5) ? bruiser_anim_death1 : bruiser_anim_death2);
65         
66         monster_hook_death(); // for post-death mods
67 }
68
69 void bruiser_spawn ()
70 {
71         if not(self.health)
72                 self.health = autocvar_g_monster_bruiser_health;
73
74         self.damageforcescale   = 0.003;
75         self.classname                  = "monster_bruiser";
76         self.monster_attackfunc = bruiser_attack;
77         self.nextthink                  = time + random() * 0.5 + 0.1;
78         self.think                              = bruiser_think;
79         
80         monsters_setframe(bruiser_anim_stand);
81         
82         monster_setupsounds("bruiser");
83         
84         monster_hook_spawn(); // for post-spawn mods
85 }
86
87 void spawnfunc_monster_bruiser ()
88 {       
89         if not(autocvar_g_monster_bruiser) { remove(self); return; }
90         
91         self.monster_spawnfunc = spawnfunc_monster_bruiser;
92         
93         if(Monster_CheckAppearFlags(self))
94                 return;
95         
96         self.scale = 1.3;
97         
98         if not (monster_initialize(
99                          "Bruiser", MONSTER_BRUISER,
100                          BRUISER_MIN, BRUISER_MAX,
101                          FALSE,
102                          bruiser_die, bruiser_spawn))
103         {
104                 remove(self);
105                 return;
106         }
107 }
108
109 #endif // SVQC