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
A little understanding needed...
KingWolf Offline
Member

Posts: 135
Threads: 2
Joined: Sep 2012
Reputation: 7
#1
A little understanding needed...

So, I was helping Nemet Robert with his unofficial map, and I thought of something. Alas, I'm unable to script it.

I've tried contacting Robby, but he didn't respond. I'm guessing he's still sleeping, or forgot to turn his phone on.

Either way, I have a script zone that triggers a small event (Sanity Damage), and that also triggers a timer. Now, I want that timer to randomly choose 1 event from 4 different events once it depletes.

The events (all can be called by timers) are.

#1 = A sound that plays.
#2 = A sudden increase in the player's FOV. Later on, it returns to normal, followed by the same sound that #1 plays.
#3 = A short hearbeat, soon followed by a small decrease in the player's FOV, and the vision turns blood-red.
#4 = Triggers a particle effect, plays the same sound as #1, triggers the sanity damage again, then plays a scream sound.

Now I can script the events themselves, I just don't know how to script the timer to randomly choose 1 from these 4 events.

If somebody is successful, they will receive a +1 from both me and Robby too!

Helping "Nemet Robert " with his unofficial map.
(This post was last modified: 09-10-2012, 09:05 AM by KingWolf.)
09-10-2012, 08:03 AM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#2
RE: A little understanding needed...

Ok, ^ refers to me. Phone was in charger, set to silent mode. Just recently noticed the call.

Anyway, it seems like this script is possible, but it is outside my "experience box". I know basic scripting and all, but this is advanced, and I find it difficult. I have little to no understanding in this section (the basic section is 100% over here).

I'm guessing you'll need to use some "float" or "int" thingies (can't find words) here. That is something I am not familiar with.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-10-2012, 08:10 AM
Website Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#3
RE: A little understanding needed...

RandInt + Var's seems like the easiest thing:


void OnStart()
{
SetLocalVarInt("RandomEvent", 0);
///add whatever other callback to set the timers, etc
}

/*
Assuming you have a basic timer set up and it is called, you can do something like this:
*/

void timer_name(string &in asTimer)
{
AddLocalVarInt("RandomEvent", RandInt(1,4));

if(GetLocalVarInt("RandomEvent") == 1)
{
event1();
}
if(GetLocalVarInt("RandomEvent") == 2)
{
event2();
}
if(GetLocalVarInt("RandomEvent") == 3)
{
event3();
}
if(GetLocalVarInt("RandomEvent") == 4)
{
event4();
}
}

void event1()
{
///do event 1 stuff
}

void event2()
{
///do event 2 stuff
}

void event3()
{
///do event 3 stuff
}

void event4()
{
///do event 4 stuff
}


Hope that helped! Also, instead of calling each function like "void event4()", you could put the event stuff inside the if statement to avoid clutter. I just add the extra step to help organize.

I rate it 3 memes.
09-10-2012, 08:11 AM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#4
RE: A little understanding needed...

First set a LocalInt, or global depending on your needs, and do it like so:

SetLocalVarInt("blahblah", RandInt(1,4));

The rand at the end will randomly give the generated int a value ranging from the starting number to the last number, in this case 1 to 4. Which means it could 1, 2, 3, or 4.

Then when your timer depletes have it run a script like this:

switch (GetLocalVarInt("blahblah"))
{
case 1:
{
//stuff
break;
}
case 2:
{
//stuff
break;
}
case 3:
{
//stuff
break;
}
case 4:
{
//stuff
break;
}

Put what you want to do inside the "cases", and whatever number gets picked, it will run that script.

[Image: Tv0YgQb.gif]
Image by BandyGrass
(This post was last modified: 09-10-2012, 08:16 AM by Kreekakon.)
09-10-2012, 08:15 AM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#5
RE: A little understanding needed...

Okay, this will take me a little time to implement. The map's script file is a little messy. Give me 15 minutes, tops!

EDIT: Doing both isn't easy. Give me some time. *refers to Kreekakon, already trying andryrocking123's post*

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 09-10-2012, 08:20 AM by Robby.)
09-10-2012, 08:16 AM
Website Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#6
RE: A little understanding needed...

(09-10-2012, 08:16 AM)Nemet Robert Wrote: EDIT: Doing both isn't easy. Give me some time. *refers to Kreekakon, already trying andryrocking123's post*
No one's rushing you. Take your time. Far as I know, both mine, and andy's methods will work, just pick whichever you like.

[Image: Tv0YgQb.gif]
Image by BandyGrass
09-10-2012, 08:21 AM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#7
RE: A little understanding needed...

(09-10-2012, 08:21 AM)Kreekakon Wrote:
(09-10-2012, 08:16 AM)Nemet Robert Wrote: EDIT: Doing both isn't easy. Give me some time. *refers to Kreekakon, already trying andryrocking123's post*
No one's rushing you. Take your time. Far as I know, both mine, and andy's methods will work, just pick whichever you like.
It is complicated. For me, that is. Almost done, just got to rename some things, and re-arrange the script file a bit.

EDIT: Massive load of errors. Approx. 6 errors in total. Must've done something wrong. I'll retry.

EDIT2: I found the problem. I kept doing something I shouldn't have. Fixing now.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 09-10-2012, 08:40 AM by Robby.)
09-10-2012, 08:25 AM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#8
RE: A little understanding needed...

You could also use:

AddTimer("Timer_"+RandInt(1, 4), 3, "Timer");


void Timer(string &in asTimer)
{
if(asTimer == Timer_1)
{
Event_1();
}


if(asTimer == Timer_2)
{
Event_2();
}


if(asTimer == Timer_3)
{
Event_3();
}


if(asTimer == Timer_4)
{
Event_4();
}
}

Trying is the first step to success.
09-10-2012, 08:42 AM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#9
RE: A little understanding needed...

EDIT: Fully tested and works. So scared right now! I knew what was supposed to happen, and out of those 4 events, one was randomly chosen, but it seemed to hate the 4th event (didn't want to happen). Until, after the 5th try, it suddenly did it, and I can officially say that my spirit landed in my ass! Also used the wrong sound back there, thus resulting in this scare.

KingWolf, when you see this, mark this thread as "[SOLVED]". I can confirm it works (I can just send you those files, since I am the dev here, and you're my assistant.) Or should I send you a video instead?

+1 given to Kreekakon and andyrockin123. KingWolf shall do the same.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 09-10-2012, 08:54 AM by Robby.)
09-10-2012, 08:43 AM
Website Find
KingWolf Offline
Member

Posts: 135
Threads: 2
Joined: Sep 2012
Reputation: 7
#10
RE: A little understanding needed...

Marked as solved. Problem's gone. Thanks. And +1 was given to both peeps, as per Robby's instructions.

Tested the map myself after Robby sent me the script file, and yes it works. Better than I thought.

I'll hang with sound creation, while you fix the map and scripts up. I'll also do some mapping if needs be.

Helping "Nemet Robert " with his unofficial map.
09-10-2012, 09:07 AM
Find




Users browsing this thread: 1 Guest(s)