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
Script Help Timers
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#1
Timers

Hello Frictional!


I am trying to zoom in the FOV of player for 4 seconds, then back out after 4 seconds.
This is literally my first go at timers, hopefully I was somewhere close, please correct me if you can!

My script:


oid OnPickup(string &in asEntity, string &in type)
{
SetMessage("Messages", "noise", 4.0);
AddTimer("FOV", 0, "FadePlayerFOVMulTo");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25, false);

void FadePlayerFOVMulTo(string &in timer_name)
{
if (timer_name == "FOV")
{
FadePlayerFOVMulTo(0.5, 2);
SetPlayerActive(false);
AddTimer("Normal1", 4, "FadePlayerFOVMulTo");
}
else if (timer_name == "Normal1")
{
FadePlayerFOVMulTo(1, 2);
SetPlayerActive(true);
}

Bold is what I'm talking about
08-10-2012, 07:27 AM
Find
EXAWOLT Offline
Member

Posts: 113
Threads: 14
Joined: Apr 2012
Reputation: 3
#2
RE: Timers

void OnPickup()
string &in asTimer
(This post was last modified: 08-10-2012, 08:25 AM by EXAWOLT.)
08-10-2012, 08:24 AM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#3
RE: Timers

Ah, sorry, I do have a V in void. But,
SetEntityCallbackFunc("key_study_1", "OnPickup");


Is my script in the OnStart. I picking up a key, then ZOOM in for 4 seconds, then back out.

So I think the
void OnPickup(string &in asEntity, string &in type) still works.


Do I need to AddTimer in the OnStart?

Oh I see what you meant.

I tried that, no luck, I still get a "unexpected end of file". And the area where it says its wrong is lines 2 and 79, and thats the very start and end of the hps.

It must be something else..

(08-10-2012, 06:53 PM)TheIcyPickle Wrote: Ah, sorry, I do have a V in void. But,
SetEntityCallbackFunc("key_study_1", "OnPickup");


Is my script in the OnStart. I picking up a key, then ZOOM in for 4 seconds, then back out.

So I think the
void OnPickup(string &in asEntity, string &in type) still works.


Do I need to AddTimer in the OnStart?

Oh I see what you meant.

I tried that, no luck, I still get a "unexpected end of file". And the area where it says its wrong is lines 2 and 79, and thats the very start and end of the hps.

It must be something else..
Here is my script once more

void OnStart()
{
SetEntityCallbackFunc("key_study_1", "OnPickup");

}



void OnPickup(string &in asEntity, string &in type)
{
SetMessage("Messages", "noise", 4.0);
AddTimer("FOV", 0, "FadePlayerFOVMulTo");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25, false);

void FadePlayerFOVMulTo(string &in asTimer)
{
if (timer_name == "FOV")
{
FadePlayerFOVMulTo(0.5, 2);
SetPlayerActive(false);
AddTimer("Normal1", 4, "FadePlayerFOVMulTo");
}
else if (timer_name == "Normal1")
{
FadePlayerFOVMulTo(1, 2);
SetPlayerActive(true);
}
}
(This post was last modified: 08-10-2012, 07:25 PM by TheIcyPickle.)
08-10-2012, 06:53 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#4
RE: Timers

you forgot the } from:
void OnPickup(string &in asEntity, string &in type)
so make it:

void OnPickup(string &in asEntity, string &in type)
{
SetMessage("Messages", "noise", 4.0);
AddTimer("FOV", 0, "FadePlayerFOVMulTo");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25, false);
}

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
08-10-2012, 07:44 PM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#5
RE: Timers

Thank you steve, I have done that, and now, I get errors which are more understandable.
Which is a good thing Smile

It seems to not like where I say

if timer_name == ("x")


It says that the name is not set and it must be of "boolean type"
(This post was last modified: 08-10-2012, 08:04 PM by TheIcyPickle.)
08-10-2012, 08:04 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#6
RE: Timers

Quick question:

Judging by the sound effects you're using and the FOV change, are you trying to simulate the sanity damage effect used in game?

Anyways, this script should give you no errors at all:


void OnStart()
{
SetEntityPlayerInteractCallback("key_study_1", "OnPickup", true);
}

void OnPickup(string &in asEntity)
{
SetMessage("Messages", "noise", 4.0f);
AddTimer("FOV", 0, "ChangeFOV");
AddTimer("Normal1", 4, "ChangeFOV");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25.0f, false);
}

void ChangeFOV(string &in asTimer)
{
if(asTimer == "FOV")
{
FadePlayerFOVMulTo(0.5f, 2);
SetPlayerActive(false);
}
if(asTimer == "Normal1")
{
FadePlayerFOVMulTo(1, 2);
SetPlayerActive(true);
}
}

I rate it 3 memes.
(This post was last modified: 08-10-2012, 08:17 PM by Adny.)
08-10-2012, 08:14 PM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#7
RE: Timers

Andy, what would I do without you?
lol

Thanks for all the help guys, I think I did ok at my first go at timers. hehe
08-10-2012, 08:21 PM
Find




Users browsing this thread: 2 Guest(s)