The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Emergency Flare
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#1
Emergency Flare

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()
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
//////////////////////////
//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

(This post was last modified: 06-18-2012, 08:32 PM by SilentStriker.)
06-17-2012, 10:50 AM
Find


Messages In This Thread
Emergency Flare - by SilentStriker - 06-17-2012, 10:50 AM
RE: Emergency Flare - by MaZiCUT - 06-17-2012, 11:23 AM
RE: Emergency Flare - by SilentStriker - 06-17-2012, 11:26 AM
RE: Emergency Flare - by MaZiCUT - 06-17-2012, 11:27 AM
RE: Emergency Flare - by SilentStriker - 06-17-2012, 11:31 AM
RE: Emergency Flare - by MaZiCUT - 06-17-2012, 11:42 AM
RE: Emergency Flare - by SilentStriker - 06-17-2012, 12:08 PM
RE: Emergency Flare - by palistov - 06-18-2012, 12:29 AM
RE: Emergency Flare - by SilentStriker - 06-18-2012, 09:09 AM
RE: Emergency Flare - by kartanonperuna - 07-16-2012, 03:55 PM
RE: Emergency Flare - by DnALANGE - 12-29-2012, 06:32 PM
RE: Emergency Flare - by SilentStriker - 12-30-2012, 02:53 AM
RE: Emergency Flare - by DnALANGE - 12-30-2012, 04:17 PM



Users browsing this thread: 1 Guest(s)