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
Custom Story Script Problems
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#1
Custom Story Script Problems

Before I begin, I am moderately decent with java and have tried looking everywhere before bugging everyone with a question.
I am new to making Amnesia custom stories, and was able to make a room and a hallway no sweat. I was also able to do some simple scripting but I instantly ran into problems. At first I was trying to lock a door and have it be able to be opened by a key. I watched 3 tutorial videos on it and made everything exactly the way the showed me, yet whenever I tried the key on the door it said "cannot use this way!". I cant figure out what I did wrong. While I was trying to figure out the key lock thing, I decided to make a monster break down the door to the hallway and walk in, patrol a bit, and leave when you pick up the key. I also watched a tutorial on this and followed exactly what he said. The funny thing is, it worked the first time I did it, but the monster (who I wanted to not be there, then suddenly appear behind the door and break it down) was there the whole time and you could hear him behind the door so it was no big surprise. Once I picked up the key however, he broke down the door and everything worked. I realized I had forgot to save the level editor when I made him unactive, so I did that and launched it again. The monster never even showed up even after I picked up the key. The code is set up to make him appear yet he doesnt. I have no idea why some of my code wont work even though it works for other people, and am wondering if i am doing something wrong or if the videos are out of date. Heres the code:
////////////////////////////
// Run when starting map
void OnStart()
{
AddUseItemCallback("OpenDoor", "key", "castle_1", "KeyOnDoor", true);
SetEntityPlayerInteractCallback("key", "ActivateMonster", true);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}
void ActivateMonster(String &in item)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolMode("servant_grunt_1", "PathNodeArea_1", 0, "Idle");
AddEnemyPatrolMode("servant_grunt_1", "PathNodeArea_2", 0, "Idle");
AddEnemyPatrolMode("servant_grunt_1", "PathNodeArea_3", 0, "Idle");
AddEnemyPatrolMode("servant_grunt_1", "PathNodeArea_4", 0, "Idle");
AddEnemyPatrolMode("servant_grunt_1", "PathNodeArea_5", 0, "Idle");
{
void KeyOnDoor(string &in item, string &in entity)
{
SetSwingDoorLocked(entity, false);
PlaySoundAtEntity("", "unlock_door", entity, 0, false);
RemoveItem(item);
}
Any help would be GREATLY appreciated. Thank you!
7/14/12 EDIT: I am still unable to figure out what is wrong. All the suggestions so far havent really changed much. Is there any more information I can provide that can help provide an answer? If anyone can help thatd be great. Thanks!
(This post was last modified: 07-16-2012, 07:19 PM by zergling50.)
07-14-2012, 08:25 PM
Find
JMFStorm Offline
Member

Posts: 205
Threads: 8
Joined: Aug 2011
Reputation: 28
#2
RE: Custom Story Script Problems

void ActivateMonster(string &in asItem)
void KeyOnDoor(string &in asItem, string &in asEntity)

(This post was last modified: 07-14-2012, 08:29 PM by JMFStorm.)
07-14-2012, 08:29 PM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#3
RE: Custom Story Script Problems

(07-14-2012, 08:29 PM)JMFStorm Wrote: void ActivateMonster(string &in asItem)
void KeyOnDoor(string &in asItem, string &in asEntity)

They were that originally, but some guy managed to do it with them like this so i just recently changed them to this to see if it would work. Still wouldnt work with them like as you showed above.
07-14-2012, 08:34 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Custom Story Script Problems

ActivateMonster was not properly closed, and it's string not String.

Tutorials: From Noob to Pro
(This post was last modified: 07-14-2012, 09:20 PM by Your Computer.)
07-14-2012, 09:18 PM
Website Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#5
RE: Custom Story Script Problems

(07-14-2012, 09:18 PM)Your Computer Wrote: ActivateMonster was not properly closed, and it's string not String.
How do I properly close it? And what about the key code?
EDIT: OH My bad! just noticed what you meant. Thanks! ill test it and see if it works. Still not sure what to do about the key code though.

(07-14-2012, 10:13 PM)zergling50 Wrote:
(07-14-2012, 09:18 PM)Your Computer Wrote: ActivateMonster was not properly closed, and it's string not String.
How do I properly close it? And what about the key code?
EDIT: OH My bad! just noticed what you meant. Thanks! ill test it and see if it works. Still not sure what to do about the key code though.
I tested it after I properly closed it and made string lower case, but it still wont work. any other ideas? The Grunt still wont even spawn.

I just realized I put AddEnemyPatrolMode instead of AddEnemyPatrolNode, yet sadly this does nothing to change the problem. Current Code:
////////////////////////////
// Run when starting map
void OnStart()
{
AddUseItemCallback("OpenDoor", "key", "castle_1", "KeyOnDoor", true);
SetEntityPlayerInteractCallback("key", "ActivateMonster", true);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}
void ActivateMonster(string &in asItem)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "Idle");
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(entity, false);
PlaySoundAtEntity("", "unlock_door", entity, 0, false);
RemoveItem(item);
}
(This post was last modified: 07-14-2012, 10:36 PM by zergling50.)
07-14-2012, 10:13 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: Custom Story Script Problems

When you change parameter variable names, you also have to change the names within the function body to match the parameters.

Tutorials: From Noob to Pro
07-15-2012, 12:28 AM
Website Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#7
RE: Custom Story Script Problems

(07-15-2012, 12:28 AM)Your Computer Wrote: When you change parameter variable names, you also have to change the names within the function body to match the parameters.

which paramater variable names do I have messed up?
07-15-2012, 01:01 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#8
RE: Custom Story Script Problems

(07-15-2012, 01:01 AM)zergling50 Wrote: which paramater variable names do I have messed up?

SetSwingDoorLocked(entity, false);
PlaySoundAtEntity("", "unlock_door", entity, 0, false);
RemoveItem(item);

You should have received the AngelScript output telling you this.

Tutorials: From Noob to Pro
07-15-2012, 01:49 AM
Website Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#9
RE: Custom Story Script Problems

(07-15-2012, 01:49 AM)Your Computer Wrote:
(07-15-2012, 01:01 AM)zergling50 Wrote: which paramater variable names do I have messed up?

SetSwingDoorLocked(entity, false);
PlaySoundAtEntity("", "unlock_door", entity, 0, false);
RemoveItem(item);

You should have received the AngelScript output telling you this.
I dont know what AngelScript output is, ive never recieved any error messages( im doing coding in notepad)

(07-15-2012, 06:26 AM)zergling50 Wrote:
(07-15-2012, 01:49 AM)Your Computer Wrote:
(07-15-2012, 01:01 AM)zergling50 Wrote: which paramater variable names do I have messed up?

SetSwingDoorLocked(entity, false);
PlaySoundAtEntity("", "unlock_door", entity, 0, false);
RemoveItem(item);

You should have received the AngelScript output telling you this.
I dont know what AngelScript output is, ive never recieved any error messages( im doing coding in notepad)


I tried what you said and my code still wont work. Current code:
////////////////////////////
// Run when starting map
void OnStart()
{
AddUseItemCallback("OpenDoor", "key", "castle_1", "KeyOnDoor", true);
SetEntityPlayerInteractCallback("key", "ActivateMonster", true);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}
void ActivateMonster(string &in asItem)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "Idle");
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(entity, false, true);
PlaySoundAtEntity("", "unlock_door", entity, 0, false);
RemoveItem(item);
}
(This post was last modified: 07-15-2012, 07:21 AM by zergling50.)
07-15-2012, 06:26 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#10
RE: Custom Story Script Problems

PlaySoundAtEntity("", "unlock_door", entity, 0, false);
SetSwingDoorLocked(entity, false, true);


I dont think you can write 'entity' in there, without having an object in your map called: entity.

If you have an object called: entity, then you have to put these "" around the word.

SetSwingDoorLocked("entity", false, true);
PlaySoundAtEntity("", "unlock_door", "entity", 0, false);


In this case: [ SetSwingDoorLocked("entity", false, true); ] you are using a door. If you haven't changed your door name then it would be something like "mansion_1" or "castle_1".

Something like that, instead of entity

Trying is the first step to success.
07-15-2012, 04:01 PM
Find




Users browsing this thread: 1 Guest(s)