Frictional Games Forum (read-only)
[SCRIPT] Help With .hps File - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Help With .hps File (/thread-13842.html)



[SCRIPT] Help With .hps File - NaughtySly - 03-08-2012

Ok so I'm quite new to the whole scripting and Amnesia Custom Map Making but I've been doing good up untill this point which is where I got this problem and everywhere I go there is no awnser or help to this so my problem is..
In my .hps say if I had a KEY to open ADOOR and AGRUNT would spawn. like this


void OnStart()
{
AddUseItemCallback("", "KEY", "ADOOR", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("KEY", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("ADOOR", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "ADOOR", 0, false);
RemoveItem("KEY");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("AGRUNT", true);
ShowEnemyPlayerPosition("AGRUNT");
}

Now in the same map I want to have a diffrent key open a diffrent door but how would I put that because I just right it like this.. Then I get a error saying something like "ERR Incorrect"{" or something like that so just look


{
AddUseItemCallback("", "KEY", "ADOOR", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("KEY", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("ADOOR", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "ADOOR", 0, false);
RemoveItem("KEY");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("AGRUNT", true);
ShowEnemyPlayerPosition("AGRUNT");
}


{<-This little guy right here is what causes the error?? now please tell me why? and how to correctly right this
AddUseItemCallback("", "KEY1", "ADOOR1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("KEY1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("ADOOR1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "ADOOR1", 0, false);
RemoveItem("KEY1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("AGRUNT1", true);
ShowEnemyPlayerPosition("AGRUNT1");
}

just so I dont confuse you to much here is my full script.


void OnStart()
{
AddUseItemCallback("", "bedroomkey", "bedroomdoor", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("bedroomkey", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("bedroomdoor", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "bedroomdoor", 0, false);
RemoveItem("bedroomkey");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
ShowEnemyPlayerPosition("monster_grunt");
}
Every thing here works fine but instead of having another Door opened by another Key I have a monster activated by PLAYER walking into an Area and it works but! not if I have it set up like this.. It keeps saying the same error about how "{" that is placed incorrectly or something so pretty much my question is "How do I start a new FUNCTION like a Whole new Script set up like 2 diffrent things happening like here? With out any problems"
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 1, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 1, "");
}

void OnEnter()
{
SetLocalVarInt("Var1", 0);
SetEntityPlayerInteractCallback("hallbutton_1", "func1", true);
SetEntityPlayerInteractCallback("hallbutton_2", "func2", true);
SetEntityPlayerInteractCallback("hallbutton_3", "func3", true);
SetEntityPlayerInteractCallback("hallbutton_4", "func4", true);
}

void func1(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func3(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func4(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{

SetSwingDoorLocked("halldoor", false, false);
PlaySoundAtEntity("", "unlock_door.snt", "halldoor", 0.5f, false);
}
}

If You can please help me out with this! I would Forever thank you! sorry for such a long Thread but I really Need Help...


RE: [SCRIPT] Help With .hps File - Linus Ă…gren - 03-08-2012

Quote:void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("AGRUNT", true);
ShowEnemyPlayerPosition("AGRUNT");
}


{<-This little guy right here is what causes the error?? now please tell me why? and how to correctly right this
AddUseItemCallback("", "KEY1", "ADOOR1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("KEY1", "OnPickup");
}

If you compare the two scripts you wrote here, you are opening functions with your brackets. However, you aren't opening anything at all with your code at the bottom.


RE: [SCRIPT] Help With .hps File - Stepper321 - 03-08-2012

Wheres the void name(syntax)?