Frictional Games Forum (read-only)

Full Version: Emergency Flare
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello everyone

So this is a little thing I have wanted to do for a while and now I finally got it everything I need and got it working so I want to share it with the forum.

So this is an Emergency flare that spawns on a script area that will light up areas for you but will burn out after a certain amount of time which makes it an alternate portable light source that has some dynamics in it Smile

Picture of it in action
[Image: dq6gbo.jpg]

This package comes with a Flare model, Flare sound and some burning flare particles. And if you want to use it you need to place each folder in it's certain category. Flare goes in to Entities, Flare_sound to sound folder and flare_particles goes into the particle folder (remember to add these components to your CS folder if you are going to use it Smile

Here's the code to make it work

Put this code inside void OnStart()
Code:
SpawnFlareAtArea("EmergencyFlare", "SpawnFlare", 0.79f);

So I'm going to break down this code so you can change it yourself.

EmergencyFlare: is the name of the Flare (it's not that relevant so just keep it.)
SpawnFlare: is the name of the Script Area you want to spawn the flare.
0.79f: is the Burn Time for the Flare, you can change it to what ever you want (Remember that the higher the number is the longer it will burn and right now it burns for around 1 minute)

Here's the rest of the code that you just have to copy and paste in to your .hps
Code:
//////////////////////////
//Emergency Flare Script//
const string _FlareOBJ = "Flare.ent";
void SpawnFlareAtArea(string &in flareName, string &in areaTarget, float burnTime)
{
    CreateEntityAtArea(flareName, _FlareOBJ, areaTarget, true);
    SetLocalVarFloat(flareName+"_time", burnTime >= 1.0f ? 0.999f : burnTime);
    SetEntityPlayerInteractCallback(flareName, "InteractFlare", true);
    AddDebugMessage("Flare Spawned", true);
}

void InteractFlare(string &in entity)
{
    CreateParticleSystemAtEntity("PFlare", "ps_flare_sparkles", entity, false);
    FadeLightTo(entity+"_FlareLight", 1.0f, 0.1f, 0.0f, 0.7f, -1, 1.5f);
    PlaySoundAtEntity("SFlare", "flare_loop.snt", entity, 1, false);
    BurnLoop(entity);
    AddDebugMessage("Picked :" +entity, true);
}

void BurnLoop(string &in timer)
{
    if(GetLocalVarFloat(timer+"_time") <= 0.0f)
    {
        StopFlareParticles("PFlare", "SFlare");
        return;
    }
    AddLocalVarFloat(timer+"_time", -0.00035f);
    AddTimer(timer, 0.0166f, "BurnLoop");
    AddDebugMessage("Time: "+GetLocalVarFloat(timer+"_time"), false);
}

void StopFlareParticles(string &in ParticleName, string &in SoundName)
{
        DestroyParticleSystem(ParticleName);
        StopSound(SoundName, 1.5f);
        FadeLightTo("EmergencyFlare"+"_FlareLight", 0, 0, 0, 0, -1, 1);
}
//End Flare Script//
/////////////////////

If you have any questions feel free to ask them and I will be glad to answer Smile

CREDIT
Traggey for making me the Flare model (since my own sucked x))
DarkAdders for making the particles system for the flare (also since my own sucked)
Palistov for the source and gave me the inspiration and knowledge to do this
Frictional Games for making the Flare sound (it's from penumbra)

DOWNLOAD V1.1
Updated it by changing side of the flare so it don't collide with the lantern
Do you have to have a total conversion?
Nope, since it's not a lantern it works on any CS and any FC Smile It's just an entity I played around with so when you grab it you will hold it like a lantern then you can throw it away and have a flare lighting up an area without you holding it ^^ That's why I said it's an alternative light source Wink
(06-17-2012, 11:26 AM)SilentStriker Wrote: [ -> ]Nope, since it's not a lantern it works on any CS and any FC Smile It's just an entity I played around with so when you grab it you will hold it like a lantern then you can throw it away and have a flare lighting up an area without you holding it ^^
Oh good, so it's an entity that just lights up when you touch it


good thing i can use it in a custom story but that's the flaw, is there no way to light it up when you want to instead?


looks sweet though Smile
(06-17-2012, 11:27 AM)CrazyArts Wrote: [ -> ]
(06-17-2012, 11:26 AM)SilentStriker Wrote: [ -> ]Nope, since it's not a lantern it works on any CS and any FC Smile It's just an entity I played around with so when you grab it you will hold it like a lantern then you can throw it away and have a flare lighting up an area without you holding it ^^
Oh good, so it's an entity that just lights up when you touch it

good thing i can use it in a custom story but that's the flaw, is there no way to light it up when you want to instead?

looks sweet though Smile
Well since it's a flare you are supposed to touch it and light it Wink but if you change the SetEntityPlayerInteractCallback(flareName, "InteractFlare", true);

to maybe
AddEntityCollideCallback or something and then change the syntax on InteractFlare then you can have it light up when you want instead of touching it. But it's supposed to light up when YOU touch it since flares don't start burning by themselves Wink (But if you want to have like a flare laying in a corner already burned then you can make it start burning from the beginning pretty much but remember that it burns out after a certain amount of time
(06-17-2012, 11:31 AM)SilentStriker Wrote: [ -> ]
(06-17-2012, 11:27 AM)CrazyArts Wrote: [ -> ]
(06-17-2012, 11:26 AM)SilentStriker Wrote: [ -> ]Nope, since it's not a lantern it works on any CS and any FC Smile It's just an entity I played around with so when you grab it you will hold it like a lantern then you can throw it away and have a flare lighting up an area without you holding it ^^
Oh good, so it's an entity that just lights up when you touch it

good thing i can use it in a custom story but that's the flaw, is there no way to light it up when you want to instead?

looks sweet though
Well since it's a flare you are supposed to touch it and light it Wink but if you change the SetEntityPlayerInteractCallback(flareName, "InteractFlare", true);

to maybe
AddEntityCollideCallback or something and then change the syntax on InteractFlare then you can have it light up when you want instead of touching it. But it's supposed to light up when YOU touch it since flares don't start burning by themselves Wink (But if you want to have like a flare laying in a corner already burned then you can make it start burning from the beginning pretty much but remember that it burns out after a certain amount of time
No i don't think a flare just lights up when you touch it, i meant what if i want to carry it around for a little while until i light it up, or maybe there can be different places with proper material to light them up? Like i have a flare that's not lit, then i find this gas leak and theres an area around that gas leak called LightFlare and when the flare comes in contact with it , it lights up Big Grin
Well then you change the SetEntityPlayerInteract to AddEntityCollideCallback but the problem then you need to change a bit in the code, for example every part of the code were it says entity pretty much x)
(06-17-2012, 12:08 PM)SilentStriker Wrote: [ -> ]
PHP Code:
if(!GetPropIsInteractedWith(timer))
    {
        
SetEntityPlayerInteractCallback(timer"InteractFlashLightHUDobj"true);
        
    } 
Fix that. You've got an artifact from my source in there Wink
Oops I thought I had removed that ^^
Nice.
Pages: 1 2