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