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


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a hallucination event.
Author Message
ZxBrad Offline
Member

Posts: 140
Joined: Mar 2011
Reputation: 0
Post: #1
How to make a hallucination event.

I just need help on setting up a event for walking in a room and a monster pops out of the cabinet and disappears.

WARNING: Noob Doesn't Know How To Script.
[Image: xcn384.gif]

04-09-2011 01:29 PM
Find all posts by this user Quote this message in a reply
larslu Offline
Junior Member

Posts: 30
Joined: Mar 2011
Reputation: 0
Post: #2
RE: How to make a hallucination event.

(04-09-2011 01:29 PM)ZxBrad Wrote:  I just need help on setting up a event for walking in a room and a monster pops out of the cabinet and disappears.

Click on the monster you want to hallucinate. Then you see the general things of the monster on your right. Go to the entity of that. Check the box of Hallucination and choose the distance at which distance you want to the monster disappear (HallucinationEndDist).
04-09-2011 01:34 PM
Find all posts by this user Quote this message in a reply
ZxBrad Offline
Member

Posts: 140
Joined: Mar 2011
Reputation: 0
Post: #3
RE: How to make a hallucination event.

(04-09-2011 01:34 PM)larslu Wrote:  
(04-09-2011 01:29 PM)ZxBrad Wrote:  I just need help on setting up a event for walking in a room and a monster pops out of the cabinet and disappears.

Click on the monster you want to hallucinate. Then you see the general things of the monster on your right. Go to the entity of that. Check the box of Hallucination and choose the distance at which distance you want to the monster disappear (HallucinationEndDist).

I did that. but how will the game know when to activate the monster at the right time.

WARNING: Noob Doesn't Know How To Script.
[Image: xcn384.gif]

04-09-2011 01:50 PM
Find all posts by this user Quote this message in a reply
Dalroc Offline
Member

Posts: 57
Joined: Mar 2011
Reputation: 0
Post: #4
RE: How to make a hallucination event.

This is taken directly from Scripts Recollection, the stickied thread on top of this forum.
Always check if what you need has been posted there already!
void OnStart()
{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt" , true);
}
"ScriptArea_1" is the name of the script area where you collide which causes the monster to spawn.
"MonsterFunc1" is the name of the function used later on when you want to add to the script instead of it doing nothing.
"servant_grunt" is the name of the monster that spawns.
Remember to set the monster's entity to not active.
04-09-2011 02:14 PM
Find all posts by this user Quote this message in a reply
ZxBrad Offline
Member

Posts: 140
Joined: Mar 2011
Reputation: 0
Post: #5
RE: How to make a hallucination event.

I put those in heres my hps file rite now.

////////////////////////////
// Run first time starting map
void OnStart()
{
    SetMessage("Journal", "start", 8.0f);
    AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("castle_1", false, true);
    PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
    RemoveItem("doorkey_1");
}

{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_1" , true);
}

And when i try to start my map up it crashes on me.

WARNING: Noob Doesn't Know How To Script.
[Image: xcn384.gif]

04-09-2011 02:40 PM
Find all posts by this user Quote this message in a reply
teddifisk Offline
Senior Member

Posts: 303
Joined: Dec 2010
Reputation: 2
Post: #6
RE: How to make a hallucination event.

[size=xx-small]
(04-09-2011 02:40 PM)ZxBrad Wrote:  I put those in heres my hps file rite now.

////////////////////////////
// Run first time starting map
void OnStart()
{
    SetMessage("Journal", "start", 8.0f);
    AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("castle_1", false, true);
    PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
    RemoveItem("doorkey_1");
}

{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_1" , true);
}

And when i try to start my map up it crashes on me.

It should be like this i think:

// Run first time starting map
void OnStart()
{
SetMessage("Journal", "start", 8.0f);
AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("doorkey_1");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}

04-09-2011 02:44 PM
Find all posts by this user Quote this message in a reply
Dalroc Offline
Member

Posts: 57
Joined: Mar 2011
Reputation: 0
Post: #7
RE: How to make a hallucination event.

(04-09-2011 02:40 PM)ZxBrad Wrote:  I put those in heres my hps file rite now.

*insert code*

And when i try to start my map up it crashes on me.
As you can see in the AddUseItemCallback you have a "AutoDestroy" parameter, that means you can set that too true and you won't have to remove the item with RemoveItem("doorkey_1");.
void AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);

Allows the player to use items on the world.
Callback syntax: void MyFunc(string &in asItem, string &in asEntity)

asName - internal name
asItem - internal name of the item
asEntity - entity to be able to use the item on
asFunction - function to call
abAutoDestroy - determines whether the item is destroyed when used

The thing that is crashing your game is this part
{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
That's supposed to be in the OnStart function. Here is a cleaned up script for you
// Run first time starting map
void OnStart()
{
    SetMessage("Journal", "start", 8.0f);
    AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("castle_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "castle_1", 0, false);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_1" , true);
}
04-09-2011 03:01 PM
Find all posts by this user Quote this message in a reply
ZxBrad Offline
Member

Posts: 140
Joined: Mar 2011
Reputation: 0
Post: #8
RE: How to make a hallucination event.

I did that. but then i added a new key to my map and a unlock door script thing and im getting another crash now. Heres my script. And srry if im not getting it my signature clearly states im a noob.

// Run first time starting map
void OnStart()
{
SetMessage("Journal", "start", 8.0f);
AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "exitkey_1", "metal_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("doorkey_1");
}
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("exitkey_1");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}

WARNING: Noob Doesn't Know How To Script.
[Image: xcn384.gif]

04-09-2011 03:16 PM
Find all posts by this user Quote this message in a reply
Dalroc Offline
Member

Posts: 57
Joined: Mar 2011
Reputation: 0
Post: #9
RE: How to make a hallucination event.

(04-09-2011 03:16 PM)ZxBrad Wrote:  I did that. but then i added a new key to my map and a unlock door script thing and im getting another crash now. Heres my script. And srry if im not getting it my signature clearly states im a noob.

// Run first time starting map
void OnStart()
{
SetMessage("Journal", "start", 8.0f);
AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "exitkey_1", "metal_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("doorkey_1");
}
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("exitkey_1");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}
You are lacking the fundamental basic knowledge of scripting.
The braces ({ and }) notes the beginning and start of a function (or a for-loop or a if conditional), everything you want to happen within a function has to be placed between the braces.
The OnStart function is called when the map is first loaded, so if you want any other function in your script you will have to call that function within the Onstart function. Thats why you have the Callbacks, they will call the function it's told to call.
So as you probably understand the functions need names to be called, that's what the OnStart, UsedKeyOnDoor and MonsterFunc1 is.

As you can see in your code you have a function that has no name.
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("exitkey_1");
}
It's probably this that is crashing your game. You have to give this function a name and the right parameters. Also in your AddUseItemCallback("", "exitkey_1", "metal_1", "UsedKeyOnDoor", true); you are calling the same function as the other ItemCallback.
This means that when you use "exitkey_1" on "metal_1" you will call the function to unlock "castle_1". So you will have to make the new ItemCallback call your nameless function, or you modify your "UsedKeyOnDoor" to a generic unlock function that work for several doors (search forums for this).

I really can't learn you too script, please read some easy guide, or just look through some other people scripts and learn from that. It's not that hard!

P.S. Also, look at my last post what I said about the key being removed automatically by the ItemCallback.. If you are going to ask for help on the forums at least make use of the help you get.
(This post was last modified: 04-09-2011 03:41 PM by Dalroc.)
04-09-2011 03:35 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)