]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/hlac.qc
weapons: remove IMPLEMENTATION
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / hlac.qc
1 #include "hlac.qh"
2
3 #ifdef SVQC
4 spawnfunc(weapon_hlac) { weapon_defaultspawnfunc(this, WEP_HLAC); }
5
6 void W_HLAC_Touch(entity this, entity toucher)
7 {
8         float isprimary;
9
10         PROJECTILE_TOUCH(this, toucher);
11
12         this.event_damage = func_null;
13
14         isprimary = !(this.projectiledeathtype & HITTYPE_SECONDARY);
15
16         RadiusDamage(this, this.realowner, WEP_CVAR_BOTH(hlac, isprimary, damage), WEP_CVAR_BOTH(hlac, isprimary, edgedamage), WEP_CVAR_BOTH(hlac, isprimary, radius), NULL, NULL, WEP_CVAR_BOTH(hlac, isprimary, force), this.projectiledeathtype, toucher);
17
18         delete(this);
19 }
20
21 void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity)
22 {
23         entity missile;
24     float spread;
25
26         W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hlac, ammo), weaponentity);
27
28     spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.(weaponentity).misc_bulletcounter);
29     spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
30     if(actor.crouch)
31         spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
32
33         W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage));
34         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
35         if(!autocvar_g_norecoil)
36         {
37                 actor.punchangle_x = random() - 0.5;
38                 actor.punchangle_y = random() - 0.5;
39         }
40
41         missile = new(hlacbolt);
42         missile.owner = missile.realowner = actor;
43         missile.bot_dodge = true;
44
45     missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage);
46
47         set_movetype(missile, MOVETYPE_FLY);
48         PROJECTILE_MAKETRIGGER(missile);
49
50         setorigin(missile, w_shotorg);
51         setsize(missile, '0 0 0', '0 0 0');
52
53         W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
54         //missile.angles = vectoangles(missile.velocity); // csqc
55
56         settouch(missile, W_HLAC_Touch);
57         setthink(missile, SUB_Remove);
58
59     missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
60
61         missile.flags = FL_PROJECTILE;
62         IL_PUSH(g_projectiles, missile);
63         IL_PUSH(g_bot_dodge, missile);
64         missile.projectiledeathtype = WEP_HLAC.m_id;
65
66         CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
67
68         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
69 }
70
71 void W_HLAC_Attack2(entity actor, .entity weaponentity)
72 {
73         entity missile;
74     float spread;
75
76     spread = WEP_CVAR_SEC(hlac, spread);
77
78
79     if(actor.crouch)
80         spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
81
82         W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
83         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
84
85         missile = new(hlacbolt);
86         missile.owner = missile.realowner = actor;
87         missile.bot_dodge = true;
88
89     missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage);
90
91         set_movetype(missile, MOVETYPE_FLY);
92         PROJECTILE_MAKETRIGGER(missile);
93
94         setorigin(missile, w_shotorg);
95         setsize(missile, '0 0 0', '0 0 0');
96
97         W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
98         //missile.angles = vectoangles(missile.velocity); // csqc
99
100         settouch(missile, W_HLAC_Touch);
101         setthink(missile, SUB_Remove);
102
103     missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
104
105         missile.flags = FL_PROJECTILE;
106         IL_PUSH(g_projectiles, missile);
107         IL_PUSH(g_bot_dodge, missile);
108         missile.missile_flags = MIF_SPLASH;
109         missile.projectiledeathtype = WEP_HLAC.m_id | HITTYPE_SECONDARY;
110
111         CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
112
113         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
114 }
115
116 // weapon frames
117 void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int fire)
118 {
119         if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon) // abort immediately if switching
120         {
121                 w_ready(thiswep, actor, weaponentity, fire);
122                 return;
123         }
124
125         if(PHYS_INPUT_BUTTON_ATCK(actor))
126         {
127                 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
128                 if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
129                 {
130                         W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
131                         w_ready(thiswep, actor, weaponentity, fire);
132                         return;
133                 }
134
135                 int slot = weaponslot(weaponentity);
136                 ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
137                 W_HLAC_Attack(WEP_HLAC, actor, weaponentity);
138                 actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
139         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
140         }
141         else
142         {
143                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready);
144         }
145 }
146
147 void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity)
148 {
149     float i;
150
151         W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hlac, ammo), weaponentity);
152
153     for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
154         W_HLAC_Attack2(actor, weaponentity);
155
156         if(!autocvar_g_norecoil)
157         {
158                 actor.punchangle_x = random() - 0.5;
159                 actor.punchangle_y = random() - 0.5;
160         }
161 }
162
163 METHOD(HLAC, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
164 {
165     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
166 }
167 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
168 {
169     if(autocvar_g_balance_hlac_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
170         thiswep.wr_reload(thiswep, actor, weaponentity);
171     } else if(fire & 1)
172     {
173         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
174         {
175             actor.(weaponentity).misc_bulletcounter = 0;
176             W_HLAC_Attack(thiswep, actor, weaponentity);
177             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
178         }
179     }
180
181     else if((fire & 2) && WEP_CVAR(hlac, secondary))
182     {
183         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
184         {
185             W_HLAC_Attack2_Frame(thiswep, actor, weaponentity);
186             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
187         }
188     }
189 }
190 METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
191 {
192     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
193     ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
194     return ammo_amount;
195 }
196 METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
197 {
198     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
199     ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
200     return ammo_amount;
201 }
202 METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
203 {
204     W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
205 }
206 METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep))
207 {
208     return WEAPON_HLAC_SUICIDE;
209 }
210 METHOD(HLAC, wr_killmessage, Notification(entity thiswep))
211 {
212     return WEAPON_HLAC_MURDER;
213 }
214
215 #endif
216 #ifdef CSQC
217
218 METHOD(HLAC, wr_impacteffect, void(entity thiswep, entity actor))
219 {
220     vector org2;
221     org2 = w_org + w_backoff * 6;
222     pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
223     if(!w_issilent)
224         sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM);
225 }
226
227 #endif