]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/overkill/rpc.qc
Merge branch 'master' into Mario/intrusive
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / rpc.qc
1 #ifndef IMPLEMENTATION
2 CLASS(RocketPropelledChainsaw, Weapon)
3 /* ammotype  */ ATTRIB(RocketPropelledChainsaw, ammo_field, .int, ammo_rockets)
4 /* impulse   */ ATTRIB(RocketPropelledChainsaw, impulse, int, 7)
5 /* flags     */ ATTRIB(RocketPropelledChainsaw, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_SUPERWEAPON);
6 /* rating    */ ATTRIB(RocketPropelledChainsaw, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
7 /* color     */ ATTRIB(RocketPropelledChainsaw, wpcolor, vector, '0.5 0.5 0');
8 /* modelname */ ATTRIB(RocketPropelledChainsaw, mdl, string, "ok_rl");
9 #ifndef MENUQC
10 /* model     */ ATTRIB(RocketPropelledChainsaw, m_model, Model, MDL_RPC_ITEM);
11 #endif
12 /* crosshair */ ATTRIB(RocketPropelledChainsaw, w_crosshair, string, "gfx/crosshairrocketlauncher");
13 /* crosshair */ ATTRIB(RocketPropelledChainsaw, w_crosshair_size, float, 0.6);
14 /* wepimg    */ ATTRIB(RocketPropelledChainsaw, model2, string, "weaponrpc");
15 /* refname   */ ATTRIB(RocketPropelledChainsaw, netname, string, "rpc");
16 /* wepname   */ ATTRIB(RocketPropelledChainsaw, m_name, string, _("Rocket Propelled Chainsaw"));
17
18 #define X(BEGIN, P, END, class, prefix) \
19         BEGIN(class) \
20                 P(class, prefix, ammo, float, NONE) \
21                 P(class, prefix, animtime, float, NONE) \
22                 P(class, prefix, damage2, float, NONE) \
23                 P(class, prefix, damageforcescale, float, NONE) \
24                 P(class, prefix, damage, float, NONE) \
25                 P(class, prefix, edgedamage, float, NONE) \
26                 P(class, prefix, force, float, NONE) \
27                 P(class, prefix, health, float, NONE) \
28                 P(class, prefix, lifetime, float, NONE) \
29                 P(class, prefix, radius, float, NONE) \
30                 P(class, prefix, refire, float, NONE) \
31                 P(class, prefix, reload_ammo, float, NONE) \
32         P(class, prefix, reload_time, float, NONE) \
33                 P(class, prefix, speedaccel, float, NONE) \
34                 P(class, prefix, speed, float, NONE) \
35         P(class, prefix, switchdelay_drop, float, NONE) \
36         P(class, prefix, switchdelay_raise, float, NONE) \
37         P(class, prefix, weaponreplace, string, NONE) \
38         P(class, prefix, weaponstartoverride, float, NONE) \
39         P(class, prefix, weaponstart, float, NONE) \
40         P(class, prefix, weaponthrowable, float, NONE) \
41     END()
42     W_PROPS(X, RocketPropelledChainsaw, rpc)
43 #undef X
44
45 ENDCLASS(RocketPropelledChainsaw)
46 REGISTER_WEAPON(RPC, rpc, NEW(RocketPropelledChainsaw));
47
48 #endif
49 #ifdef IMPLEMENTATION
50 #ifdef SVQC
51 spawnfunc(weapon_rpc) { weapon_defaultspawnfunc(this, WEP_RPC); }
52
53 void W_RocketPropelledChainsaw_Explode(entity this, entity directhitentity)
54 {
55         this.event_damage = func_null;
56         this.takedamage = DAMAGE_NO;
57
58         RadiusDamage (this, this.realowner, WEP_CVAR(rpc, damage), WEP_CVAR(rpc, edgedamage), WEP_CVAR(rpc, radius), NULL, NULL, WEP_CVAR(rpc, force), this.projectiledeathtype, directhitentity);
59
60         remove (this);
61 }
62
63 void W_RocketPropelledChainsaw_Explode_think(entity this)
64 {
65         W_RocketPropelledChainsaw_Explode(this, NULL);
66 }
67
68 void W_RocketPropelledChainsaw_Touch (entity this, entity toucher)
69 {
70         if(WarpZone_Projectile_Touch(this, toucher))
71                 if(wasfreed(this))
72                         return;
73
74         W_RocketPropelledChainsaw_Explode(this, toucher);
75 }
76
77 void W_RocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
78 {
79         if (this.health <= 0)
80                 return;
81
82         if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
83                 return; // g_projectiles_damage says to halt
84
85         this.health = this.health - damage;
86
87         if (this.health <= 0)
88                 W_PrepareExplosionByDamage(this, attacker, W_RocketPropelledChainsaw_Explode_think);
89 }
90
91 void W_RocketPropelledChainsaw_Think(entity this)
92 {
93         if(this.cnt <= time)
94         {
95                 remove(this);
96                 return;
97         }
98
99         this.cnt = vlen(this.velocity);
100         this.wait = this.cnt * sys_frametime;
101         this.pos1 = normalize(this.velocity);
102
103         tracebox(this.origin, this.mins, this.maxs, this.origin + this.pos1 * (2 * this.wait), MOVE_NORMAL, this);
104         if(IS_PLAYER(trace_ent))
105                 Damage (trace_ent, this, this.realowner, WEP_CVAR(rpc, damage2), this.projectiledeathtype, this.origin, normalize(this.origin - other.origin) * WEP_CVAR(rpc, force));
106
107         this.velocity = this.pos1 * (this.cnt + (WEP_CVAR(rpc, speedaccel) * sys_frametime));
108
109         UpdateCSQCProjectile(this);
110         this.nextthink = time;
111 }
112
113 void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor)
114 {
115         entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor);
116         entity flash = spawn ();
117
118         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(rpc, ammo));
119         W_SetupShot_ProjectileSize (actor, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(rpc, damage));
120         Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
121         PROJECTILE_MAKETRIGGER(missile);
122
123         missile.owner = missile.realowner = actor;
124         missile.bot_dodge = true;
125         missile.bot_dodgerating = WEP_CVAR(rpc, damage) * 2;
126
127         missile.takedamage = DAMAGE_YES;
128         missile.damageforcescale = WEP_CVAR(rpc, damageforcescale);
129         missile.health = WEP_CVAR(rpc, health);
130         missile.event_damage = W_RocketPropelledChainsaw_Damage;
131         missile.damagedbycontents = true;
132         set_movetype(missile, MOVETYPE_FLY);
133
134         missile.projectiledeathtype = WEP_RPC.m_id;
135         setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
136
137         setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
138         W_SetupProjVelocity_Basic(missile, WEP_CVAR(rpc, speed), 0);
139
140         settouch(missile, W_RocketPropelledChainsaw_Touch);
141
142         setthink(missile, W_RocketPropelledChainsaw_Think);
143         missile.cnt = time + WEP_CVAR(rpc, lifetime);
144         missile.nextthink = time;
145         missile.flags = FL_PROJECTILE;
146         IL_PUSH(g_projectiles, missile);
147
148         CSQCProjectile(missile, true, PROJECTILE_RPC, false);
149
150         setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below
151         SUB_SetFade (flash, time, 0.1);
152         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
153         W_AttachToShotorg(actor, flash, '5 0 0');
154         missile.pos1 = missile.velocity;
155
156         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
157 }
158
159 METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor))
160 {
161     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
162 }
163
164 METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
165 {
166     if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) {
167         thiswep.wr_reload(thiswep, actor, weaponentity);
168     } else
169     {
170         if (fire & 1)
171         {
172             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(rpc, refire)))
173             {
174                 W_RocketPropelledChainsaw_Attack(thiswep, actor);
175                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
176             }
177         }
178
179         if (fire & 2)
180         {
181             // to-do
182         }
183     }
184 }
185
186 METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor))
187 {
188     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
189     ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
190     return ammo_amount;
191 }
192
193 METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor))
194 {
195     return false;
196 }
197
198 METHOD(RocketPropelledChainsaw, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
199 {
200     W_Reload(actor, WEP_CVAR(rpc, ammo), SND_RELOAD);
201 }
202
203 METHOD(RocketPropelledChainsaw, wr_suicidemessage, Notification(entity thiswep))
204 {
205     if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
206         return WEAPON_RPC_SUICIDE_SPLASH;
207     else
208         return WEAPON_RPC_SUICIDE_DIRECT;
209 }
210
211 METHOD(RocketPropelledChainsaw, wr_killmessage, Notification(entity thiswep))
212 {
213     if(w_deathtype & HITTYPE_SECONDARY)
214         return WEAPON_BLASTER_MURDER;
215     else if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
216         return WEAPON_RPC_MURDER_SPLASH;
217     else
218         return WEAPON_RPC_MURDER_DIRECT;
219 }
220
221 #endif
222
223 #ifdef CSQC
224
225 METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep, entity actor))
226 {
227     vector org2;
228     org2 = w_org + w_backoff * 12;
229     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
230     if(!w_issilent)
231         sound(actor, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
232 }
233
234 #endif
235 #endif