]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/shambler.qc
Steal new weapon cvar system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / shambler.qc
1 #ifdef REGISTER_MONSTER
2 REGISTER_MONSTER(
3 /* MON_##id   */ SHAMBLER,
4 /* function   */ m_shambler,
5 /* spawnflags */ MONSTER_SIZE_BROKEN,
6 /* mins,maxs  */ '-41 -41 -31', '41 41 65',
7 /* model      */ "shambler.mdl",
8 /* netname    */ "shambler",
9 /* fullname   */ _("Shambler")
10 );
11
12 #define SHAMBLER_SETTINGS(monster) \
13         MON_ADD_CVAR(monster, health) \
14         MON_ADD_CVAR(monster, attack_smash_damage) \
15         MON_ADD_CVAR(monster, attack_claw_damage) \
16         MON_ADD_CVAR(monster, attack_lightning_damage) \
17         MON_ADD_CVAR(monster, speed_run) \
18         MON_ADD_CVAR(monster, speed_walk) 
19
20 #ifdef SVQC
21 SHAMBLER_SETTINGS(shambler)
22 #endif // SVQC
23 #else
24 #ifdef SVQC
25 const float shambler_anim_stand         = 0;
26 const float shambler_anim_walk          = 1;
27 const float shambler_anim_run           = 2;
28 const float shambler_anim_smash         = 3;
29 const float shambler_anim_swingr        = 4;
30 const float shambler_anim_swingl        = 5;
31 const float shambler_anim_magic         = 6;
32 const float shambler_anim_pain          = 7;
33 const float shambler_anim_death         = 8;
34
35 void shambler_smash()
36 {
37         monster_melee(self.enemy, MON_CVAR(shambler, attack_smash_damage), 0.3, DEATH_MONSTER_SHAMBLER_SMASH, TRUE);
38 }
39
40 void shambler_delayedsmash()
41 {
42         monsters_setframe(shambler_anim_smash);
43         defer(0.7, shambler_smash);
44         self.attack_finished_single = time + 1.1;
45 }
46
47 void shambler_swing()
48 {
49         float r = (random() < 0.5);
50         monsters_setframe((r) ? shambler_anim_swingr : shambler_anim_swingl);
51         monster_melee(self.enemy, MON_CVAR(shambler, attack_claw_damage), 0.3, DEATH_MONSTER_SHAMBLER_CLAW, TRUE);
52         self.attack_finished_single = time + 0.8;
53         if(r)
54                 defer(0.5, shambler_swing);
55 }
56
57 void CastLightning()
58 {
59         local vector org, dir;
60         //vector v = '0 0 0';
61
62         self.effects |= EF_MUZZLEFLASH;
63
64         org = self.origin + '0 0 40';
65
66         dir = self.enemy.origin + '0 0 16' - org;
67         dir = normalize (dir);
68
69         traceline (org, self.origin + dir * 1000, TRUE, self);
70                 
71         FireRailgunBullet (org, org + dir * 1000, MON_CVAR(shambler, attack_lightning_damage) * monster_skill, 0, 0, 0, 0, 0, DEATH_MONSTER_SHAMBLER_ZAP);
72         
73         // teamcolor / hit beam effect
74         //v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
75         //WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), org, v);
76         
77         te_csqc_lightningarc(org, trace_endpos);
78 }
79
80 float shambler_attack(float attack_type)
81 {
82         switch(attack_type)
83         {
84                 case MONSTER_ATTACK_MELEE:
85                 {
86                         float chance = random();
87
88                         if(chance > 0.6)
89                                 shambler_delayedsmash();
90                         else
91                                 shambler_swing();
92                         
93                         return TRUE;
94                 }
95                 case MONSTER_ATTACK_RANGED:
96                 {
97                         monsters_setframe(shambler_anim_magic);
98                         self.attack_finished_single = time + 1.1;
99                         defer(0.6, CastLightning);
100                         
101                         return TRUE;
102                 }
103         }
104         
105         return FALSE;
106 }
107
108 void spawnfunc_monster_shambler()
109 {
110         self.classname = "monster_shambler";
111         
112         self.monster_spawnfunc = spawnfunc_monster_shambler;
113         
114         if(Monster_CheckAppearFlags(self))
115                 return;
116         
117         if not(monster_initialize(MON_SHAMBLER, FALSE)) { remove(self); return; }
118 }
119
120 float m_shambler(float req)
121 {
122         switch(req)
123         {
124                 case MR_THINK:
125                 {
126                         monster_move(MON_CVAR(shambler, speed_run), MON_CVAR(shambler, speed_walk), 300, shambler_anim_run, shambler_anim_walk, shambler_anim_stand);
127                         return TRUE;
128                 }
129                 case MR_DEATH:
130                 {
131                         monsters_setframe(shambler_anim_death);
132                         return TRUE;
133                 }
134                 case MR_SETUP:
135                 {
136                         if not(self.health) self.health = MON_CVAR(shambler, health);
137                                 
138                         self.monster_attackfunc = shambler_attack;
139                         monsters_setframe(shambler_anim_stand);
140                         self.weapon = WEP_NEX;
141                         
142                         return TRUE;
143                 }
144                 case MR_INIT:
145                 {
146                         // nothing
147                         return TRUE;
148                 }
149                 case MR_CONFIG:
150                 {
151                         MON_CONFIG_SETTINGS(SHAMBLER_SETTINGS(shambler))
152                         return TRUE;
153                 }
154         }
155         
156         return TRUE;
157 }
158
159 #endif // SVQC
160 #ifdef CSQC
161 float m_shambler(float req)
162 {
163         switch(req)
164         {
165                 case MR_DEATH:
166                 {
167                         // nothing
168                         return TRUE;
169                 }
170                 case MR_INIT:
171                 {
172                         precache_model ("models/monsters/shambler.mdl");
173                         return TRUE;
174                 }
175         }
176         
177         return TRUE;
178 }
179
180 #endif // CSQC
181 #endif // REGISTER_MONSTER