]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/animus.qc
83f1b695e5513fe44d41c75a2f21a3d2b7b81c7e
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / animus.qc
1 // size
2 const vector ANIMUS_MIN = '-41 -41 -31';
3 const vector ANIMUS_MAX = '41 41 31';
4
5 // model
6 string ANIMUS_MODEL = "models/monsters/demon.mdl";
7
8 #ifdef SVQC
9 // cvars
10 float autocvar_g_monster_animus;
11 float autocvar_g_monster_animus_health;
12 float autocvar_g_monster_animus_attack_jump_damage;
13 float autocvar_g_monster_animus_damage;
14 float autocvar_g_monster_animus_speed_walk;
15 float autocvar_g_monster_animus_speed_run;
16
17 // animations
18 const float animus_anim_stand   = 0;
19 const float animus_anim_walk    = 1;
20 const float animus_anim_run             = 2;
21 const float animus_anim_leap    = 3;
22 const float animus_anim_pain    = 4;
23 const float animus_anim_death   = 5;
24 const float animus_anim_attack  = 6;
25
26 void animus_think ()
27 {
28         self.think = animus_think;
29         self.nextthink = time + self.ticrate;
30         
31         monster_move(autocvar_g_monster_animus_speed_run, autocvar_g_monster_animus_speed_walk, 100, animus_anim_run, animus_anim_walk, animus_anim_stand);
32 }
33
34 void animus_touch_jump ()
35 {
36         if (self.health <= 0)
37                 return;
38
39         if (monster_isvalidtarget(other, self))
40         {
41                 if (vlen(self.velocity) > 300)
42                 {
43                         Damage(other, self, self, autocvar_g_monster_animus_attack_jump_damage * monster_skill, DEATH_MONSTER_ANIMUS, other.origin, normalize(other.origin - self.origin));
44                         self.touch = MonsterTouch; // instantly turn it off to stop damage spam
45                 }
46         }
47
48         if(trace_dphitcontents)
49                 self.touch = MonsterTouch;
50 }
51
52 float animus_attack(float attack_type)
53 {
54         switch(attack_type)
55         {
56                 case MONSTER_ATTACK_MELEE:
57                 {
58                         monsters_setframe(animus_anim_attack);
59                         self.attack_finished_single = time + 1;
60                         monster_melee(self.enemy, autocvar_g_monster_animus_damage, 0.3, DEATH_MONSTER_ANIMUS, TRUE);
61                         
62                         return TRUE;
63                 }
64                 case MONSTER_ATTACK_RANGED:
65                 {
66                         makevectors(self.angles);
67                         if(monster_leap(animus_anim_leap, animus_touch_jump, v_forward * 700 + '0 0 300', 0.8))
68                                 return TRUE;
69                 }
70         }
71         
72         return FALSE;
73 }
74
75 void animus_die ()
76 {
77         Monster_CheckDropCvars ("animus");
78         
79         self.think = monster_dead_think;
80         self.nextthink = time + self.ticrate;
81         self.ltime = time + 5;
82         monsters_setframe(animus_anim_death);
83         
84         monster_hook_death(); // for post-death mods
85 }
86
87 void animus_spawn ()
88 {
89         if not(self.health)
90                 self.health = autocvar_g_monster_animus_health;
91
92         self.damageforcescale   = 0;
93         self.classname                  = "monster_animus";
94         self.monster_attackfunc = animus_attack;
95         self.nextthink                  = time + random() * 0.5 + 0.1;
96         self.think                              = animus_think;
97         
98         monsters_setframe(animus_anim_stand);
99         
100         monster_setupsounds("animus");
101         
102         monster_hook_spawn(); // for post-spawn mods
103 }
104
105 void spawnfunc_monster_animus ()
106 {       
107         if not(autocvar_g_monster_animus) { remove(self); return; }
108         
109         self.monster_spawnfunc = spawnfunc_monster_animus;
110         
111         if(Monster_CheckAppearFlags(self))
112                 return;
113         
114         self.scale = 1.3;
115         
116         if not (monster_initialize(
117                          "Animus", MONSTER_ANIMUS,
118                          ANIMUS_MIN, ANIMUS_MAX,
119                          FALSE,
120                          animus_die, animus_spawn))
121         {
122                 remove(self);
123                 return;
124         }
125 }
126
127 // compatibility with old spawns
128 void spawnfunc_monster_demon1() { spawnfunc_monster_animus(); }
129 void spawnfunc_monster_demon() { spawnfunc_monster_animus(); }
130
131 #endif // SVQC