]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/animus.qc
Properly fix monsters thinking they're fish
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / animus.qc
1 #ifdef REGISTER_MONSTER
2 REGISTER_MONSTER(
3 /* MON_##id   */ ANIMUS,
4 /* function   */ m_animus,
5 /* spawnflags */ MONSTER_SIZE_BROKEN,
6 /* mins,maxs  */ '-41 -41 -31', '41 41 31',
7 /* model      */ "demon.mdl",
8 /* netname    */ "animus",
9 /* fullname   */ _("Animus")
10 );
11
12 #else
13 #ifdef SVQC
14 float autocvar_g_monster_animus;
15 float autocvar_g_monster_animus_health;
16 float autocvar_g_monster_animus_attack_jump_damage;
17 float autocvar_g_monster_animus_damage;
18 float autocvar_g_monster_animus_speed_walk;
19 float autocvar_g_monster_animus_speed_run;
20
21 const float animus_anim_stand   = 0;
22 const float animus_anim_walk    = 1;
23 const float animus_anim_run             = 2;
24 const float animus_anim_leap    = 3;
25 const float animus_anim_pain    = 4;
26 const float animus_anim_death   = 5;
27 const float animus_anim_attack  = 6;
28
29 void animus_touch_jump()
30 {
31         if (self.health <= 0)
32                 return;
33
34         if (monster_isvalidtarget(other, self))
35         {
36                 if (vlen(self.velocity) > 300)
37                 {
38                         Damage(other, self, self, autocvar_g_monster_animus_attack_jump_damage * monster_skill, DEATH_MONSTER_ANIMUS, other.origin, normalize(other.origin - self.origin));
39                         self.touch = MonsterTouch; // instantly turn it off to stop damage spam
40                 }
41         }
42
43         if(trace_dphitcontents)
44                 self.touch = MonsterTouch;
45 }
46
47 float animus_attack(float attack_type)
48 {
49         switch(attack_type)
50         {
51                 case MONSTER_ATTACK_MELEE:
52                 {
53                         monsters_setframe(animus_anim_attack);
54                         self.attack_finished_single = time + 1;
55                         monster_melee(self.enemy, autocvar_g_monster_animus_damage, 0.3, DEATH_MONSTER_ANIMUS, TRUE);
56                         
57                         return TRUE;
58                 }
59                 case MONSTER_ATTACK_RANGED:
60                 {
61                         makevectors(self.angles);
62                         if(monster_leap(animus_anim_leap, animus_touch_jump, v_forward * 700 + '0 0 300', 0.8))
63                                 return TRUE;
64                 }
65         }
66         
67         return FALSE;
68 }
69
70 void spawnfunc_monster_animus()
71 {
72         if not(autocvar_g_monster_animus) { remove(self); return; }
73         
74         self.classname = "monster_animus";
75         
76         self.monster_spawnfunc = spawnfunc_monster_animus;
77         
78         if(Monster_CheckAppearFlags(self))
79                 return;
80         
81         if not(monster_initialize(MON_ANIMUS, FALSE)) { remove(self); return; }
82 }
83
84 // compatibility with old spawns
85 void spawnfunc_monster_demon1() { spawnfunc_monster_animus(); }
86 void spawnfunc_monster_demon() { spawnfunc_monster_animus(); }
87
88 float m_animus(float req)
89 {
90         switch(req)
91         {
92                 case MR_THINK:
93                 {
94                         monster_move(autocvar_g_monster_animus_speed_run, autocvar_g_monster_animus_speed_walk, 100, animus_anim_run, animus_anim_walk, animus_anim_stand);
95                         return TRUE;
96                 }
97                 case MR_DEATH:
98                 {
99                         monsters_setframe(animus_anim_death);
100                         return TRUE;
101                 }
102                 case MR_SETUP:
103                 {
104                         if not(self.health) self.health = autocvar_g_monster_animus_health;
105                                 
106                         self.monster_attackfunc = animus_attack;
107                         monsters_setframe(animus_anim_stand);
108                         
109                         return TRUE;
110                 }
111                 case MR_INIT:
112                 {
113                         // nothing
114                         return TRUE;
115                 }
116         }
117         
118         return TRUE;
119 }
120
121 #endif // SVQC
122 #ifdef CSQC
123 float m_animus(float req)
124 {
125         switch(req)
126         {
127                 case MR_DEATH:
128                 {
129                         // nothing
130                         return TRUE;
131                 }
132                 case MR_INIT:
133                 {
134                         precache_model ("models/monsters/demon.mdl");
135                         return TRUE;
136                 }
137         }
138         
139         return TRUE;
140 }
141
142 #endif // CSQC
143 #endif // REGISTER_MONSTER