]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/demon.qc
Rename tarbaby to slime & begin cleanup of monster_attack_melee function
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / demon.qc
1 // size
2 const vector DEMON_MIN = '-41 -41 -31';
3 const vector DEMON_MAX = '41 41 31';
4
5 // model
6 string DEMON_MODEL = "models/monsters/demon.mdl";
7
8 #ifdef SVQC
9 // cvars
10 float autocvar_g_monster_demon;
11 float autocvar_g_monster_demon_health;
12 float autocvar_g_monster_demon_attack_jump_damage;
13 float autocvar_g_monster_demon_damage;
14 float autocvar_g_monster_demon_speed_walk;
15 float autocvar_g_monster_demon_speed_run;
16
17 // animations
18 const float demon_anim_stand    = 0;
19 const float demon_anim_walk             = 1;
20 const float demon_anim_run              = 2;
21 const float demon_anim_leap             = 3;
22 const float demon_anim_pain             = 4;
23 const float demon_anim_death    = 5;
24 const float demon_anim_attack   = 6;
25
26 void demon_think ()
27 {
28         self.think = demon_think;
29         self.nextthink = time + self.ticrate;
30         
31         monster_move(autocvar_g_monster_demon_speed_run, autocvar_g_monster_demon_speed_walk, 100, demon_anim_run, demon_anim_walk, demon_anim_stand);
32 }
33
34 float demon_attack_melee ()
35 {
36         monsters_setframe(demon_anim_attack);
37         self.attack_finished_single = time + 1;
38         
39         monster_melee(self.enemy, autocvar_g_monster_demon_damage, 0.3, DEATH_MONSTER_FIEND, TRUE);
40         
41         return TRUE;
42 }
43
44 void Demon_JumpTouch ()
45 {
46         if (self.health <= 0)
47                 return;
48
49         if (monster_isvalidtarget(other, self))
50         {
51                 if (vlen(self.velocity) > 300)
52                 {
53                         Damage(other, self, self, autocvar_g_monster_demon_attack_jump_damage * monster_skill, DEATH_MONSTER_FIEND, other.origin, normalize(other.origin - self.origin));
54                         self.touch = MonsterTouch; // instantly turn it off to stop damage spam
55                 }
56         }
57
58         if(self.flags & FL_ONGROUND)
59                 self.touch = MonsterTouch;
60 }
61
62 float demon_jump ()
63 {
64         makevectors(self.angles);
65         if(monster_leap(demon_anim_leap, Demon_JumpTouch, v_forward * 700 + '0 0 300', 0.8))
66                 return TRUE;
67                 
68         return FALSE;
69 }
70
71 void demon_die ()
72 {
73         Monster_CheckDropCvars ("demon");
74         
75         self.think = monster_dead_think;
76         self.nextthink = time + self.ticrate;
77         self.ltime = time + 5;
78         monsters_setframe(demon_anim_death);
79         
80         monster_hook_death(); // for post-death mods
81 }
82
83 void demon_spawn ()
84 {
85         if not(self.health)
86                 self.health = autocvar_g_monster_demon_health;
87
88         self.damageforcescale   = 0;
89         self.classname                  = "monster_demon";
90         self.checkattack                = GenericCheckAttack;
91         self.attack_melee               = demon_attack_melee;
92         self.attack_ranged              = demon_jump;
93         self.nextthink                  = time + random() * 0.5 + 0.1;
94         self.think                              = demon_think;
95         
96         monsters_setframe(demon_anim_stand);
97         
98         monster_setupsounds("demon");
99         
100         monster_hook_spawn(); // for post-spawn mods
101 }
102
103 void spawnfunc_monster_demon ()
104 {       
105         if not(autocvar_g_monster_demon) { remove(self); return; }
106         
107         self.monster_spawnfunc = spawnfunc_monster_demon;
108         
109         if(Monster_CheckAppearFlags(self))
110                 return;
111         
112         self.scale = 1.3;
113         
114         if not (monster_initialize(
115                          "Fiend", MONSTER_DEMON,
116                          DEMON_MIN, DEMON_MAX,
117                          FALSE,
118                          demon_die, demon_spawn))
119         {
120                 remove(self);
121                 return;
122         }
123 }
124
125 // compatibility with old spawns
126 void spawnfunc_monster_demon1() { spawnfunc_monster_demon(); }
127
128 #endif // SVQC