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