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