AmnesiaIsScary :S
Junior Member
Posts: 22
Threads: 3
Joined: Sep 2011
Reputation:
1
|
Scripting Problems !
Hey, I have a lot of problems with the scripting here !
When I try to make a key to a door it doesn't work or that the game crashes when im starting the map.
And the thing I would love to know most :
How to make insanity effects ? When I Tried they worked when I started the map.
(I want it to be in specific area's or when touching an entity)
Help would be much appreciated .
|
|
09-12-2011, 02:39 PM |
|
Obliviator27
Posting Freak
Posts: 792
Threads: 10
Joined: Jul 2011
Reputation:
66
|
RE: Scripting Problems !
I'll give you some examples based upon what you want to do. For starters, you can find all the script functions you need here: http://wiki.frictionalgames.com/hpl2/amn..._functions
Now, to tackle your key problem, you simply need to place an AddUseItemCallback into your OnStart() function. The parameters you need will be shown in the wiki.
EXAMPLE (I placed descriptions in [], so you can replace those with what you need.
void OnStart()
{
AddUseItemCallback("[Can leave this blank]", "[Name of the key]", "[Name of the Door], [Function to call when item is used]", [leave as either true or false, depending if you want the key to disappear]);
}
void UnlockDoor[Has to be what you placed in your adduseitemcallback](string &in asItem, string &in asEntity)[this blurb is simply proper syntax to make your function work. It tells you this in the wiki]
{
SetSwingDoorLocked("[Name of Door]", [True locks the door, false unlocks door], [True or false, depending if you want effects used]);
}
To make your insanity effects work, you simply need to add a
SetEntityPlayerInteractCallback for when an item is interacted with
or
AddEntityCollideCallback for when you want the player to walk into an area.
Be sure to have all names match up perfectly in the level editor. Also note that on the Entities, you can set up an interact callback without having to place it in your OnStart function.
Hopefully this helps you!
|
|
09-12-2011, 05:52 PM |
|
Itskody
Member
Posts: 100
Threads: 30
Joined: Mar 2011
Reputation:
1
|
RE: Scripting Problems !
in your hps file you have to have this
void UsedKeyOnDoorOne(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("name of door", false, true);
PlaySoundAtEntity("", "unlock_door", "name of door", 0, false);
RemoveItem("name of key");
}
The names you put there are the names of the key/door in the map editor. so the door would be like mansion_1 and the key would be like key_study_1... Get it?
and if you want to add sanity damage to your character(along with the effects) when a door is slammed or at ANY time, do this..
void ONStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
}
// Now add a script area in your map editor and where is says "ScriptArea_1" ABOVE, that is the name of the script in the map editor( such as key_study_1, or mansion_1). And where is says "Open" that is what YOU are choosing to call the function that will occur. You can name it what ever you want.
Now that you have the entity collide function you have to add effects to what happends when you collide with that function.
so then in your hps file you add(NOT IN THE OnStart BRACKETS BUT BELOW IT):
void Scare(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
}
Now this function is boring. You spice it up a bit add some noises so lets add some monster/ and player noises(some *gasps* obviously or moans from monsters.)
so add:
PlayGuiSound("amb_alert.snt", 0.5f);
and
PlayGuiSound("react_scare.snt", 0.5f);
into the function so now you have
void Scare(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
PlayGuiSound("amb_alert.snt", 0.5f);
PlayGuiSound("react_scare.snt", 0.5f);
}
If you have any more questions then just ask.
Hope this helped and this function is only good for when you walk through the script created on the hps map editor. if you want to know how to make effects when touching something or when a monster touches something or anything then just ask.
|
|
09-12-2011, 06:04 PM |
|
AmnesiaIsScary :S
Junior Member
Posts: 22
Threads: 3
Joined: Sep 2011
Reputation:
1
|
RE: Scripting Problems !
Ok thanks a lot guys ... The last comment helped, but the key is still not working for me ... It says unexpected token or other errors when I try to fix it .. So this is the door name :
"monsterdoor"
This is the key:
"key_study_1"
Maybe you can give me the exact command now ?
And "itskody" can you give me the command when touching something ?
Oh and how to do another scare ? like where do i put the command ? I tried like this but it didnt work , look maybe you will understand what do I want ...
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
}
void Scare(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
PlayGuiSound("amb_alert.snt", 0.5f);
PlayGuiSound("react_scare.snt", 0.5f);
}
{
AddEntityCollideCallback("Player", "ScriptArea_2", "Scare", true, 1);
}
void Scare(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
PlayGuiSound("amb_alert.snt", 0.5f);
PlayGuiSound("react_scare.snt", 0.5f);
}
What that I meant is that I want to do another scare effect in another place .. how to do it ,and how to do a scarier react effect ? or scarier insanity effect ?
And thanks for the help
|
|
09-13-2011, 07:40 PM |
|
Itskody
Member
Posts: 100
Threads: 30
Joined: Mar 2011
Reputation:
1
|
RE: Scripting Problems !
You cannot have 2 functions leading to the same void function.. like you cant have both:
AddEntityCollideCallback("Player", "ScriptArea_2", "Scare", true, 1);
and
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
have the same "Scare" function. You need to make a new name for the second reaction.
So for the first reaction do what i said and put
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
in the OnStart brackets and put the
AddEntityCollideCallback("Player", "ScriptArea_2", "Scare", true, 1);
ALSO in the OnStart brackets but for the second script dont use the Void function "Scare" becasue that is already in use so you have to change it to another name. Lets use Monster in this example. so your OnStart should look like this:
Void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Monster", true, 1);
}
//////// Then when you are making the reaction you have to do a separate void for each function so OUT of the OnStart brackets you should have:
void Scare(string &in asParent, string &in asChild, int alState)
{
///////The functions you want such as sanity damage or noises you want to put in
}
AND
void Monster(string &in asParent, string &in asChild, int alState)
{
/////// Whatever functions you want here.
}
SOOOOO YOUR TOTAL SCRIPT WITH 2 EFFECTS SHOULD LOOK LIKE THIS
Void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Monster", true, 1);
}
void Monster(string &in asParent, string &in asChild, int alState)
{
/////// Whatever functions you want here.
}
void Scare(string &in asParent, string &in asChild, int alState)
{
/////// Whatever functions you want here.
}
Would you like me to send you my HPS file for a part of my custom story so you can get ideas?
|
|
09-13-2011, 08:02 PM |
|
AmnesiaIsScary :S
Junior Member
Posts: 22
Threads: 3
Joined: Sep 2011
Reputation:
1
|
RE: Scripting Problems !
Would you like me to send you my HPS file for a part of my custom story so you can get ideas?
^ Yes .
P.S You helped me a LOT , really.
Can you tell me the name of the command to a bigger scare reaction ? And send the file ?
I have so many shit to learn from you !!!
|
|
09-13-2011, 08:19 PM |
|
Itskody
Member
Posts: 100
Threads: 30
Joined: Mar 2011
Reputation:
1
|
RE: Scripting Problems !
haha alright and what do you mean a bigger scare? describe what you want to happen?
http://www.mediafire.com/?qp5a4d9zfdxh69w
open that file in notepad and look through it, Its a small part of my map but has a bunch of different ideas in it. so ASK away
(This post was last modified: 09-14-2011, 12:37 AM by Itskody.)
|
|
09-14-2011, 12:35 AM |
|
AmnesiaIsScary :S
Junior Member
Posts: 22
Threads: 3
Joined: Sep 2011
Reputation:
1
|
RE: Scripting Problems !
Ok i went through a part of it and i tried to do the :
StartPlayerLookAt("monsterdoor", 5, 10, "");
now i tried to stop it and i didn't know how .. this is my whole hps, Can you show me what to put to stop it ?
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Monster", true, 1);
}
void Scare(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
PlayGuiSound("amb_alert.snt", 0.5f);
PlayGuiSound("react_pant.snt", 0.5f);
StartPlayerLookAt("monsterdoor", 5, 10, "");
AddTimer("", 0.5f, "TimerScare");
}
void Monster(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10, true);
PlayGuiSound("amb_alert.snt", 0.5f);
PlayGuiSound("react_pant.snt", 0.5f);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
And when I meant bigger scares i Meant like different scares , like you did the earthquake and som people make him to get scared more (I think they raise the scaredamage)
Oh and another thing .. How to you spawn a monster when entering a script area ?
|
|
09-14-2011, 05:52 AM |
|
AmnesiaIsScary :S
Junior Member
Posts: 22
Threads: 3
Joined: Sep 2011
Reputation:
1
|
RE: Scripting Problems !
Anyone ^ ?
|
|
09-14-2011, 04:10 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
|
09-14-2011, 04:24 PM |
|
|