Allow servers to define custom help messages for votes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / rpc.qc
1 #include "rpc.qh"
2
3 #ifdef SVQC
4
5 void W_RocketPropelledChainsaw_Explode(entity this, entity directhitentity)
6 {
7         this.event_damage = func_null;
8         this.takedamage = DAMAGE_NO;
9
10         RadiusDamage (this, this.realowner, WEP_CVAR(rpc, damage), WEP_CVAR(rpc, edgedamage), WEP_CVAR(rpc, radius), NULL, NULL, WEP_CVAR(rpc, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity);
11
12         delete(this);
13 }
14
15 void W_RocketPropelledChainsaw_Explode_think(entity this)
16 {
17         W_RocketPropelledChainsaw_Explode(this, NULL);
18 }
19
20 void W_RocketPropelledChainsaw_Touch (entity this, entity toucher)
21 {
22         if(WarpZone_Projectile_Touch(this, toucher))
23                 if(wasfreed(this))
24                         return;
25
26         W_RocketPropelledChainsaw_Explode(this, toucher);
27 }
28
29 void W_RocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
30 {
31         if (this.health <= 0)
32                 return;
33
34         if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
35                 return; // g_projectiles_damage says to halt
36
37         this.health = this.health - damage;
38
39         if (this.health <= 0)
40                 W_PrepareExplosionByDamage(this, attacker, W_RocketPropelledChainsaw_Explode_think);
41 }
42
43 void W_RocketPropelledChainsaw_Think(entity this)
44 {
45         if(this.cnt <= time)
46         {
47                 delete(this);
48                 return;
49         }
50
51         float myspeed = vlen(this.velocity);
52         float myspeed_accel = myspeed * sys_frametime;
53         vector mydir = normalize(this.velocity);
54
55         tracebox(this.origin, this.mins, this.maxs, this.origin + mydir * (2 * myspeed_accel), MOVE_NORMAL, this);
56         if(IS_PLAYER(trace_ent))
57                 Damage (trace_ent, this, this.realowner, WEP_CVAR(rpc, damage2), this.projectiledeathtype, this.weaponentity_fld, this.origin, normalize(this.origin - trace_ent.origin) * WEP_CVAR(rpc, force));
58
59         this.velocity = mydir * (myspeed + (WEP_CVAR(rpc, speedaccel) * sys_frametime));
60
61         UpdateCSQCProjectile(this);
62         this.nextthink = time;
63 }
64
65 void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .entity weaponentity)
66 {
67         entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor);
68         entity flash = spawn ();
69
70         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(rpc, ammo), weaponentity);
71         W_SetupShot_ProjectileSize (actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(rpc, damage), WEP_RPC.m_id);
72         Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
73         PROJECTILE_MAKETRIGGER(missile);
74
75         missile.owner = missile.realowner = actor;
76         missile.bot_dodge = true;
77         missile.bot_dodgerating = WEP_CVAR(rpc, damage) * 2;
78
79         missile.takedamage = DAMAGE_YES;
80         missile.damageforcescale = WEP_CVAR(rpc, damageforcescale);
81         missile.health = WEP_CVAR(rpc, health);
82         missile.event_damage = W_RocketPropelledChainsaw_Damage;
83         missile.damagedbycontents = true;
84         IL_PUSH(g_damagedbycontents, missile);
85         set_movetype(missile, MOVETYPE_FLY);
86
87         missile.projectiledeathtype = WEP_RPC.m_id;
88         missile.weaponentity_fld = weaponentity;
89         setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
90
91         setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
92         W_SetupProjVelocity_Basic(missile, WEP_CVAR(rpc, speed), 0);
93
94         settouch(missile, W_RocketPropelledChainsaw_Touch);
95
96         setthink(missile, W_RocketPropelledChainsaw_Think);
97         missile.cnt = time + WEP_CVAR(rpc, lifetime);
98         missile.nextthink = time;
99         missile.flags = FL_PROJECTILE;
100         IL_PUSH(g_projectiles, missile);
101         IL_PUSH(g_bot_dodge, missile);
102
103         CSQCProjectile(missile, true, PROJECTILE_RPC, false);
104
105         setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below
106         SUB_SetFade (flash, time, 0.1);
107         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
108         W_AttachToShotorg(actor, weaponentity, flash, '5 0 0');
109
110         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
111 }
112
113 METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
114 {
115     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
116 }
117
118 METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
119 {
120     if(WEP_CVAR(rpc, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(rpc, ammo)) {
121         thiswep.wr_reload(thiswep, actor, weaponentity);
122     } else
123     {
124         if (fire & 1)
125         {
126             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(rpc, refire)))
127             {
128                 W_RocketPropelledChainsaw_Attack(thiswep, actor, weaponentity);
129                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
130             }
131         }
132
133         if (fire & 2)
134         {
135             // to-do
136         }
137     }
138 }
139
140 METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
141 {
142     float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(rpc, ammo);
143     ammo_amount += actor.(weaponentity).(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
144     return ammo_amount;
145 }
146
147 METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
148 {
149     return false;
150 }
151
152 METHOD(RocketPropelledChainsaw, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
153 {
154     W_Reload(actor, weaponentity, WEP_CVAR(rpc, ammo), SND_RELOAD);
155 }
156
157 METHOD(RocketPropelledChainsaw, wr_suicidemessage, Notification(entity thiswep))
158 {
159     if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
160         return WEAPON_RPC_SUICIDE_SPLASH;
161     else
162         return WEAPON_RPC_SUICIDE_DIRECT;
163 }
164
165 METHOD(RocketPropelledChainsaw, wr_killmessage, Notification(entity thiswep))
166 {
167     if(w_deathtype & HITTYPE_SECONDARY)
168         return WEAPON_BLASTER_MURDER;
169     else if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
170         return WEAPON_RPC_MURDER_SPLASH;
171     else
172         return WEAPON_RPC_MURDER_DIRECT;
173 }
174
175 #endif
176
177 #ifdef CSQC
178
179 METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep, entity actor))
180 {
181     vector org2;
182     org2 = w_org + w_backoff * 12;
183     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
184     if(!w_issilent)
185         sound(actor, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
186 }
187
188 #endif