hhdeath/src/shared/fx_lego.qc

99 lines
2.7 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_LEGO;
void
FX_Lego_Init(void)
{
Sound_Precache("weapon_lego.explode");
precache_model("models/lego.mdl");
precache_model("sprites/stmbal1.spr");
PARTICLE_LEGO = particleeffectnum("part_lego");
}
string g_fxlego_sets[12] = {
"geomset 0 1",
"geomset 0 2",
"geomset 0 3",
"geomset 0 4",
"geomset 0 5",
"geomset 0 6",
"geomset 0 7",
"geomset 0 8",
"geomset 0 9",
"geomset 0 10",
"geomset 0 11",
"geomset 0 12",
};
#endif
void
FX_Lego(vector pos)
{
#ifdef SERVER
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_LEGO);
WriteCoord(MSG_MULTICAST, pos[0]);
WriteCoord(MSG_MULTICAST, pos[1]);
WriteCoord(MSG_MULTICAST, pos[2]);
msg_entity = self;
multicast(pos, MULTICAST_PVS);
#else
static void Lego_Remove(void) {
remove(self);
}
/* cast an explosive effect minus the fire */
/* wrong decal atm, decal.wad loading is messy in HL */
Decals_Place(pos, "{spraypaint");
/* has a different smoke sprite */
env_sprite eSmoke = spawn(env_sprite);
setorigin(eSmoke, pos);
setmodel(eSmoke, "sprites/stmbal1.spr");
Sound_Play(eSmoke, CHAN_WEAPON, "weapon_lego.explode");
eSmoke.SetRenderMode(RM_ADDITIVE);
eSmoke.SetRenderColor([1,1,1]);
eSmoke.SetRenderAmt(1.0f);
eSmoke.drawmask = MASK_ENGINE;
eSmoke.SetMaxFrame(modelframecount(eSmoke.modelindex));
eSmoke.SetLoopFlag(false);
eSmoke.SetFramerate(15);
eSmoke.nextthink = time + 0.05f;
/* there are many different lego submodels */
for (int i = 0; i < 12; i++) {
entity eLego = spawn();
setorigin(eLego, pos);
setmodel(eLego, "models/lego.mdl");
eLego.movetype = MOVETYPE_BOUNCE;
eLego.gravity = 0.5f;
eLego.scale = 1.0f;
eLego.drawmask = MASK_ENGINE;
eLego.velocity = randomvec() * 192;
eLego.think = Lego_Remove;
eLego.nextthink = time + 5.0f;
eLego.solid = SOLID_BBOX;
setcustomskin(eLego, "", g_fxlego_sets[floor(random(0,12))]);
setsize(eLego, [0,0,0], [0,0,0]);
}
#endif
}