hhdeath/src/shared/fx_soda.qc

118 lines
3.2 KiB
Plaintext

/*
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef CLIENT
var float PARTICLE_SODA;
void
FX_Soda_Init(void)
{
precache_model("sprites/blooddrop.spr");
precache_model("sprites/soda2.spr");
precache_model("sprites/soda1.spr");
PARTICLE_SODA = particleeffectnum("part_soda");
}
#endif
void
FX_Soda(vector pos, int col)
{
#ifdef SERVER
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_SODA);
WriteCoord(MSG_MULTICAST, pos[0]);
WriteCoord(MSG_MULTICAST, pos[1]);
WriteCoord(MSG_MULTICAST, pos[2]);
WriteByte(MSG_MULTICAST, col);
msg_entity = self;
multicast(pos, MULTICAST_PVS);
#else
vector color = [1,1,1];
/* Decals use a palette to set color, we need to set sprite colors by hand.
* The order is important, we need to keep the clients and server in sync
* for the view model, soda projectile, and soda spill effect */
switch (col) {
case 1:
Decals_Place(pos, "{sodared");
color = [1,0,0];
break;
case 2:
Decals_Place(pos, "{sodapurple");
color = [1,0,1];
break;
case 3:
Decals_Place(pos, "{sodayellow");
color = [1,1,0];
break;
case 4:
Decals_Place(pos, "{sodablue");
color = [0,0,1];
break;
case 5:
Decals_Place(pos, "{sodabrown");
color = [1,0.5,0];
break;
default:
Decals_Place(pos, "{sodagreen");
color = [0,1,0];
break;
}
/* enchancement from mod */
env_sprite eSoda = spawn(env_sprite);
setorigin(eSoda, pos);
setmodel(eSoda, "sprites/soda1.spr");
eSoda.effects = EF_ADDITIVE;
eSoda.drawmask = MASK_ENGINE;
eSoda.SetMaxFrame(modelframecount(eSoda.modelindex));
eSoda.SetLoopFlag(false);
eSoda.SetRenderColor(color);
eSoda.SetRenderMode(RM_ADDITIVE);
eSoda.SetFramerate(20);
eSoda.nextthink = time + 0.05f;
static void Soda_Remove(void) {
NSEntity me = (NSEntity)self;
me.Destroy();
}
/* Has a dripping effect from spill */
for (int i = 0; i < 10; i++) {
env_sprite eSodaPart = spawn(env_sprite);
setorigin(eSodaPart, pos);
setmodel(eSodaPart, "sprites/soda2.spr");
eSodaPart.movetype = MOVETYPE_TOSS;
eSodaPart.gravity = 0.3f;
eSodaPart.scale = 0.5f;
eSodaPart.SetRenderMode(RM_ADDITIVE);
eSodaPart.SetRenderAmt(1.0);
eSodaPart.drawmask = MASK_ENGINE;
eSodaPart.SetMaxFrame(modelframecount(eSodaPart.modelindex));
eSodaPart.SetLoopFlag(true);
eSodaPart.SetRenderColor(color);
eSodaPart.SetFramerate(10);
eSodaPart.touch = Soda_Remove;
eSodaPart.nextthink = time + 0.1f;
eSodaPart.velocity = randomvec() * 128;
eSodaPart.solid = SOLID_BBOX;
setsize(eSodaPart, [0,0,0], [0,0,0]);
}
#endif
}