]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/ogre.qc
fb67de9b927084662c1d0be4dd66a56c4e444db6
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / ogre.qc
1 #ifndef MENUQC
2 // size
3 const vector OGRE_MIN = '-36 -36 -20';
4 const vector OGRE_MAX = '36 36 50';
5
6 // model
7 string OGRE_MODEL = "models/monsters/ogre.dpm";
8
9 #endif
10
11 #ifdef SVQC
12 // cvars
13 float autocvar_g_monster_ogre;
14 float autocvar_g_monster_ogre_health;
15 float autocvar_g_monster_ogre_chainsaw_damage;
16 float autocvar_g_monster_ogre_speed_walk;
17 float autocvar_g_monster_ogre_speed_run;
18 float autocvar_g_monster_ogre_attack_uzi_bullets;
19 float autocvar_g_monster_ogre_attack_uzi_damage;
20 float autocvar_g_monster_ogre_attack_uzi_force;
21 float autocvar_g_monster_ogre_attack_uzi_chance;
22
23 // animations
24 const float ogre_anim_idle              = 0;
25 const float ogre_anim_walk              = 1;
26 const float ogre_anim_run               = 2;
27 const float ogre_anim_pain              = 3;
28 const float ogre_anim_swing     = 4;
29 const float ogre_anim_die               = 5;
30
31 void chainsaw (float side)
32 {
33         if (!self.enemy)
34                 return;
35
36         if (vlen(self.enemy.origin - self.origin) > 100 * self.scale)
37                 return;
38
39         Damage(self.enemy, self, self, autocvar_g_monster_ogre_chainsaw_damage * monster_skill, DEATH_MONSTER_OGRE_CHAINSAW, self.enemy.origin, normalize(self.enemy.origin - self.origin));
40 }
41
42 void ogre_think ()
43 {
44         self.think = ogre_think;
45         self.nextthink = time + self.ticrate;
46         
47         if(self.delay != -1)
48                 self.nextthink = self.delay;
49         
50         monster_move(autocvar_g_monster_ogre_speed_run, autocvar_g_monster_ogre_speed_walk, 300, ogre_anim_run, ogre_anim_walk, ogre_anim_idle);
51 }
52
53 .float ogre_cycles;
54 void ogre_swing ()
55 {
56         self.ogre_cycles += 1;
57         monsters_setframe(ogre_anim_swing);
58         if(self.ogre_cycles == 1)
59                 self.attack_finished_single = time + 1.3;
60         self.angles_y = self.angles_y + random()* 25;
61         self.nextthink = time + 0.2;
62         self.think = ogre_swing;
63         
64         if(self.ogre_cycles <= 2)
65                 chainsaw(200);
66         else if(self.ogre_cycles <= 4)
67                 chainsaw(-200);
68         else
69                 chainsaw(0);
70         
71         if(self.ogre_cycles >= 4)
72                 self.think = ogre_think;
73 }
74
75 void ogre_uzi_fire ()
76 {
77         self.ogre_cycles += 1;
78         
79         if(self.ogre_cycles > autocvar_g_monster_ogre_attack_uzi_bullets)
80         {
81                 self.monster_delayedattack = func_null;
82                 self.delay = -1;
83                 return;
84         }
85         
86         W_SetupShot (self, autocvar_g_antilag_bullets && 18000 >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, autocvar_g_monster_ogre_attack_uzi_damage);
87         fireBallisticBullet(w_shotorg, w_shotdir, 0.02, 18000, 5, autocvar_g_monster_ogre_attack_uzi_damage, autocvar_g_monster_ogre_attack_uzi_force, DEATH_MONSTER_OGRE_UZI, 0, 1, 115);
88         endFireBallisticBullet();
89         
90         self.delay = time + 0.1;
91         self.monster_delayedattack = ogre_uzi_fire;
92 }
93
94 void ogre_uzi ()
95 {
96         monsters_setframe(ogre_anim_pain);
97         self.attack_finished_single = time + 0.8;
98         self.delay = time + 0.1;
99         self.monster_delayedattack = ogre_uzi_fire;
100 }
101
102 void ogre_gl ()
103 {
104         W_Grenade_Attack2();
105         monsters_setframe(ogre_anim_pain);
106         self.attack_finished_single = time + 0.8;
107 }
108
109 float ogre_missile ()
110 {
111         self.ogre_cycles = 0;
112         if (random() <= autocvar_g_monster_ogre_attack_uzi_chance)
113         {
114                 ogre_uzi();
115                 return TRUE;
116         }
117         else
118         {
119                 ogre_gl();
120                 return TRUE;
121         }
122 }
123
124 void ogre_melee ()
125 {
126         self.ogre_cycles = 0;
127         ogre_swing();
128 }
129
130 void ogre_die()
131 {
132         Monster_CheckDropCvars ("ogre");
133         
134         self.think = Monster_Fade;
135         self.nextthink = time + 5;
136         monsters_setframe(ogre_anim_die);
137                 
138         monster_hook_death(); // for post-death mods
139 }
140
141 void ogre_spawn ()
142 {
143         if not(self.health)
144                 self.health = autocvar_g_monster_ogre_health * self.scale;
145
146         self.damageforcescale   = 0.003;
147         self.classname                  = "monster_ogre";
148         self.checkattack                = GenericCheckAttack;
149         self.attack_melee               = ogre_melee;
150         self.attack_ranged              = ogre_missile;
151         self.nextthink                  = time + 0.1;
152         self.think                              = ogre_think;
153         self.sprite_height              = 65;
154         self.weapon                             = WEP_GRENADE_LAUNCHER;
155         
156         monsters_setframe(ogre_anim_idle);
157         
158         monster_setupsounds("ogre");
159         
160         monster_hook_spawn(); // for post-spawn mods
161 }
162
163 void spawnfunc_monster_ogre ()
164 {       
165         if not(autocvar_g_monster_ogre) { remove(self); return; }
166         
167         self.monster_spawnfunc = spawnfunc_monster_ogre;
168         
169         if(Monster_CheckAppearFlags(self))
170                 return;
171         
172         if not (monster_initialize(
173                          "Ogre", MONSTER_OGRE,
174                          OGRE_MIN, OGRE_MAX,
175                          FALSE,
176                          ogre_die, ogre_spawn))
177         {
178                 remove(self);
179                 return;
180         }
181         
182         weapon_action(WEP_GRENADE_LAUNCHER, WR_PRECACHE);
183 }
184
185 #endif // SVQC