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
How do i make the Sanity script?
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#1
How do i make the Sanity script?

Hey guys!
I'm really new at scripting amnesia custom stories and with HPL editor Big Grin

My question is how exacly can you make a Sanity Script?
Let's say i've set an area (script) and exacly when the players goes in that area that awesome screen zooming with the sound effects happens Smile

Thanks! Big Grin

And only if it's possible, a script that activates the sanity, AND makes his lantern go off (he can still light it up, just to let the lantern off his hand)
(This post was last modified: 05-25-2012, 01:55 PM by Clear.)
05-25-2012, 01:50 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#2
RE: How do i make the Sanity script?

I don't understand what "Sanity Script" means?

Do you want to raise/lower the sanity?

Raising, just put one of these lines of code in your script:

GiveSanityBoost();
GiveSanityBoostSmall();

To lower it:

GiveSanityDamage(int number, bool showeffects);

for example:
GiveSanityDamage(10, true);

Alternatively, you can manually set it, but this is less dynamic and more brute force:
SetPlayerSanity(50);

100 - Full Sanity
75 - Slight headache
50 - Head is pounding and hands are shaking
25 - ...

05-25-2012, 01:54 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#3
RE: How do i make the Sanity script?

(05-25-2012, 01:54 PM)Putmalk Wrote: I don't understand what "Sanity Script" means?

Do you want to raise/lower the sanity?

Raising, just put one of these lines of code in your script:

GiveSanityBoost();
GiveSanityBoostSmall();

To lower it:

GiveSanityDamage(int number, bool showeffects);

for example:
GiveSanityDamage(10, true);

Alternatively, you can manually set it, but this is less dynamic and more brute force:
SetPlayerSanity(50);

100 - Full Sanity
75 - Slight headache
50 - Head is pounding and hands are shaking
25 - ...
By sanity script i mean that, well, kinda hard to explain.... i'll try i guess, it's like one of those creepy custom stories where you enter a room and the author have placed some Area that when you go by pass it your sanity like goes down, when the screen gets blurry for like half a second and the screen zoomes in and that "Boom" sound effect comes.

And once again soory if i sound noobish Tongue
05-25-2012, 02:00 PM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#4
RE: How do i make the Sanity script?

You would have to set up a CollideCallback, which calls the function GiveSanityDamage. Like so

void OnStart()
{
AddEntityCollideCallback("Player", "RoomArea", "SanityDamage", true, 1);
}
void SanityDamage(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
}

05-25-2012, 02:25 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#5
RE: How do i make the Sanity script?

(05-25-2012, 02:25 PM)Obliviator27 Wrote: You would have to set up a CollideCallback, which calls the function GiveSanityDamage. Like so

void OnStart()
{
AddEntityCollideCallback("Player", "RoomArea", "SanityDamage", true, 1);
}
void SanityDamage(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
}
Thanks!
But i have a problem while putting the script down the HPS file, when i put it and load the game it gives me an error wich says function with the same parameters allready exicts... i have 2 void OnStart() in 1 HPS file, is that suppose to be like it?
One of it is for a key & door script, what do i need to do?
05-25-2012, 02:34 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#6
RE: How do i make the Sanity script?

(05-25-2012, 02:34 PM)Clear Wrote:
(05-25-2012, 02:25 PM)Obliviator27 Wrote: You would have to set up a CollideCallback, which calls the function GiveSanityDamage. Like so

void OnStart()
{
AddEntityCollideCallback("Player", "RoomArea", "SanityDamage", true, 1);
}
void SanityDamage(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
}
Thanks!
But i have a problem while putting the script down the HPS file, when i put it and load the game it gives me an error wich says function with the same parameters allready exicts... i have 2 void OnStart() in 1 HPS file, is that suppose to be like it?
One of it is for a key & door script, what do i need to do?
No. NEVER have two functions with the same name in it.

A basic script always looks like:

void OnStart()
{

}

void OnEnter()
{

}

void OnLeave()
{

}

05-25-2012, 02:44 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#7
RE: How do i make the Sanity script?

(05-25-2012, 02:44 PM)Putmalk Wrote:
(05-25-2012, 02:34 PM)Clear Wrote:
(05-25-2012, 02:25 PM)Obliviator27 Wrote: You would have to set up a CollideCallback, which calls the function GiveSanityDamage. Like so

void OnStart()
{
AddEntityCollideCallback("Player", "RoomArea", "SanityDamage", true, 1);
}
void SanityDamage(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
}
Thanks!
But i have a problem while putting the script down the HPS file, when i put it and load the game it gives me an error wich says function with the same parameters allready exicts... i have 2 void OnStart() in 1 HPS file, is that suppose to be like it?
One of it is for a key & door script, what do i need to do?
No. NEVER have two functions with the same name in it.

A basic script always looks like:

void OnStart()
{

}

void OnEnter()
{

}

void OnLeave()
{

}
This is my .HPS so far,



////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key1", "DoorName01", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("DoorName01", false, true);
PlaySoundAtEntity("", "unlock_door", "DoorName01", 0, false);
RemoveItem("key1");
}

{
AddEntityCollideCallback("Player", "Sanity1", "SanityDamage", true, 1);
}
void SanityDamage(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
}

I removed the second "void OnStart()" and it looks like this, it gives me an error of Unexpected token in 14,1, what the Hell do i do Q_Q
05-25-2012, 02:51 PM
Find
wolfmaster1231 Offline
Member

Posts: 132
Threads: 43
Joined: May 2012
Reputation: 2
#8
RE: How do i make the Sanity script?

AddEntityCollideCallback("Player", "Sanity1", "SanityDamage", true, 1) this should be under
AddUseItemCallback
05-25-2012, 02:57 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#9
RE: How do i make the Sanity script?

(14, 1) refers to line 14, character 1.

In this case, you are misusing the "{" "}". They cannot be floating around there. May I suggest reviewing a basic scripting tutorial, as syntax errors like these will stop you from doing anything.

When utilizing those brackets, they have to be after a function.

Like:
void OnStart()
{

}

Alternatively, after an if-else statement:

if(whatever)
{

}
else
{

}

or a loop

for(int i=0;i<5;i++)
{

}

So, specifically, your error is right here:
{

AddEntityCollideCallback("Player", "Sanity1", "SanityDamage", true, 1);

}

Just shift that into the original void OnStart(), so it looks like
void OnStart()
{
AddUseItemCallback("", "key1", "DoorName01", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "Sanity1", "SanityDamage", true, 1);
}

And remove that line plus the brackets where you had it.

(This post was last modified: 05-25-2012, 03:01 PM by Putmalk.)
05-25-2012, 03:01 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#10
RE: How do i make the Sanity script?

(05-25-2012, 02:57 PM)wolfmaster1231 Wrote: AddEntityCollideCallback("Player", "Sanity1", "SanityDamage", true, 1) this should be under
AddUseItemCallback

Can you write that for me please?
05-25-2012, 03:03 PM
Find




Users browsing this thread: 3 Guest(s)