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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Scares
Yare Offline
Junior Member

Posts: 22
Threads: 2
Joined: Mar 2013
Reputation: 0
#4
RE: Random Scares

Well, in your example it's surely much more comfortable. But in calculating a chance of event occurence, it doesn't really matter whether I use switch or if. Here is an example of sound function, that consists of both our ideas:

void SoundArea8(string &in asParent, string &in asChild, int alState)
{
    SetLocalVarInt("EventChance", RandInt(1,3));
    if (GetLocalVarInt("EventChance") == 1) AddTimer("", RandInt(0,3), "SoundArea8Delay");
}
void SoundArea8Delay(string &in asTimer)
{    
    SetLocalVarInt("WhatSound", RandInt(1,4));
    switch(GetLocalVarInt("WhatSound"))
    {
        case 1:
            
        SetLocalVarInt("WhatArea", RandInt(46,49));
        PlaySoundAtEntity("", "18_blow_wind.snt", "ScriptArea_"+GetLocalVarInt("WhatArea"), 0, false);
        break;
            
        case 2:

        SetLocalVarInt("WhatArea", RandInt(46,49));
        PlaySoundAtEntity("", "15_man01_whimp.snt", "ScriptArea_"+GetLocalVarInt("WhatArea"), 0, false);
        break;
        
        case 3:

        SetLocalVarInt("WhatArea", RandInt(46,49));
        PlaySoundAtEntity("", "05_whine.snt", "ScriptArea_"+GetLocalVarInt("WhatArea"), 0, false);
        break;
        
        case 4:

        SetLocalVarInt("WhatArea", RandInt(46,49));
        PlaySoundAtEntity("", "suitor/amb_idle_whimp.snt", "ScriptArea_"+GetLocalVarInt("WhatArea"), 0, false);
        break;
    }
}

The script has 30% chance to activate (it works every time you walk into area). It can be activated instantly or with not more than 3 seconds delay. It plays one of four sounds in one of four script areas. I know it looks more complicated with full variables declarations, but somehow only in this way everything is clear to me.
04-17-2013, 12:44 PM
Find


Messages In This Thread
Random Scares - by PutraenusAlivius - 04-16-2013, 03:10 PM
RE: Random Scares - by Yare - 04-16-2013, 03:39 PM
RE: Random Scares - by PutraenusAlivius - 04-17-2013, 06:10 AM
RE: Random Scares - by Yare - 04-17-2013, 12:44 PM
RE: Random Scares - by PutraenusAlivius - 04-17-2013, 12:51 PM
RE: Random Scares - by Yare - 04-17-2013, 01:55 PM
RE: Random Scares - by VeNoMzTeamHysterical - 04-17-2013, 02:04 PM
RE: Random Scares - by FlawlessHappiness - 04-18-2013, 11:11 AM
RE: Random Scares - by PutraenusAlivius - 04-18-2013, 11:58 AM
RE: Random Scares - by Your Computer - 04-18-2013, 12:10 PM
RE: Random Scares - by Adrianis - 04-18-2013, 12:40 PM
RE: Random Scares - by Your Computer - 04-18-2013, 01:00 PM
RE: Random Scares - by CarnivorousJelly - 04-19-2013, 05:57 AM
RE: Random Scares - by Adrianis - 04-19-2013, 09:45 AM
RE: Random Scares - by Adrianis - 04-18-2013, 01:11 PM
RE: Random Scares - by FlawlessHappiness - 04-20-2013, 09:42 AM
RE: Random Scares - by Adrianis - 04-20-2013, 08:23 PM
RE: Random Scares - by FlawlessHappiness - 04-23-2013, 06:48 PM
RE: Random Scares - by PutraenusAlivius - 04-24-2013, 08:24 AM
RE: Random Scares - by Adrianis - 04-24-2013, 04:56 PM
RE: Random Scares - by RurouniMori - 05-07-2013, 04:22 AM
RE: Random Scares - by PutraenusAlivius - 05-17-2013, 12:19 PM
RE: Random Scares - by FlawlessHappiness - 04-24-2013, 04:50 PM
RE: Random Scares - by PutraenusAlivius - 05-07-2013, 04:30 AM
RE: Random Scares - by RurouniMori - 05-07-2013, 04:47 AM
RE: Random Scares - by Adrianis - 05-20-2013, 06:49 PM
RE: Random Scares - by PutraenusAlivius - 05-21-2013, 02:19 AM
RE: Random Scares - by GoreGrinder99 - 07-21-2013, 11:22 AM
RE: Random Scares - by PutraenusAlivius - 07-21-2013, 11:30 AM
RE: Random Scares - by GoreGrinder99 - 07-21-2013, 11:50 AM
RE: Random Scares - by PutraenusAlivius - 07-21-2013, 12:27 PM



Users browsing this thread: 3 Guest(s)