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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help with this script
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#1
Need some help with this script

Okay everything in this script is working except two events:
1. When you pick up the item "bone_saw_2", you get sanity and then 3 seconds later, a grunt is activated.
2. When you enter a room, there is a dead man in an open closet that you look at and you get scared, much like the event in Amnesia when you open the desk door and the skulls fall out, except I want the player to look at the corpse and get frightened.
Nothing happens when you enter the room or pick up the bone saw. I'm honestly really not sure of what's going wrong, although because I'm a beginner scripter I didn't expect the complicated script I wrote to be perfect. I copied and pasted the script here.

void OnStart()
{
AddEntityCollideCallback("Player", "AreaActivateGrunt", "Func01", false, 1);
AddEntityCollideCallback("servant_grunt_1", "AreaDisableGrunt", "Func02", false, 1);
SetEntityPlayerInteractCallback("bone_saw_2", "GiveSanityAndAlertGrunt", false);
AddEntityCollideCallback("servant_grunt_2", "AreaDisableSecondGrunt", "DisableSecondGrunt", false, 1);
AddEntityCollideCallback("Player", "AreaDeadManInCloset", "LookAtDeadMan", true, 1);
AddUseItemCallback("", "studykey", "mansion_3", "UnlockStudyHallway",
true);

PlayMusic("00_creak.ogg", true, 1.0f, 0, 0, true);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
if (HasItem("lantern_1") == true)
{
SetEntityActive("servant_grunt_1", true);
RemoveEntityCollideCallback("Player", "AreaActivateGrunt");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 4.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_11", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_12", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_13", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_14", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_16", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_18", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_20", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_21", 2.0f, "");
}
}
void Func02(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", false);
}
void UnlockStudyHallway(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("studykey");
}
void GiveSanityAndAlertGrunt(string &in asItem, string &in asEntity)
{
SetPlayerSanity(100);
PlaySoundAtEntity("DanielSanityGain", "ui_sanity_gain", "Player", 0.0f, false);
AddTimer("TimerActivateSecondGrunt", 3.0f, "ActivateSecondGrunt");
}
void ActivateSecondGrunt(string &in asTimer)
{
SetEntityActive("servant_grunt_2", true);
StopSound("DanielSanityGain", 0);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_4", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_5", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_19", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_22", 4.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_23", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_24", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_25", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_26", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_27", 0.0f, "");
}
void DisableSecondGrunt(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_2", false);
}
void LookAtDeadMan(string &in asParent, string &in asChild, int alState)
{
if (GetEntityExists("servant_grunt_2") == false)
{
StartPlayerLookAt("corpse_male_1", 0.5f, 0.5f, "");
AddTimer ("TimerStopLookDeadMan", 2.0f, "StopLookDeadMan");
GiveSanityDamage(15, true);
PlayMusic("04_event_stairs", false, 1, 0.25f, 0, false);
AddTimer("reacttocorpse", 0.5f, "TimerPlayerReactToCorpse");
}
}
void TimerPlayerReactToCorpse(string &in asTimer)
{
PlaySoundAtEntity("scarecorpse", "react_breath", "Player", 0.1f, false);
}
void StopLookDeadMan(string &in asTimer)
{
StopPlayerLookAt();
}
(This post was last modified: 05-30-2011, 07:34 PM by willochill.)
05-30-2011, 06:45 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#2
RE: Need some help with this script

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "AreaActivateGrunt", "Func01", false, 1);
AddEntityCollideCallback("servant_grunt_1", "AreaDisableGrunt", "Func02", false, 1);
SetEntityPlayerInteractCallback("bone_saw_2", "GiveSanityAndAlertGrunt", false);
AddEntityCollideCallback("servant_grunt_2", "AreaDisableSecondGrunt", "DisableSecondGrunt", false, 1);
AddEntityCollideCallback("Player", "AreaDeadManInCloset", "LookAtDeadMan", true, 1);
AddUseItemCallback("", "studykey", "mansion_3", "UnlockStudyHallway", true);
PlayMusic("00_creak.ogg", true, 1.0f, 0, 0, true);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
if (HasItem("lantern_1") == true)
{
SetEntityActive("servant_grunt_1", true);
RemoveEntityCollideCallback("Player", "AreaActivateGrunt");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 4.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_11", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_12", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_13", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_14", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_16", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_18", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_20", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_21", 2.0f, "");
}
}

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

void UnlockStudyHallway(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("studykey");
}
void GiveSanityAndAlertGrunt(string &in entity)
{
SetPlayerSanity(100);
PlaySoundAtEntity("DanielSanityGain", "ui_sanity_gain", "Player", 0.0f, false);
AddTimer("TimerActivateSecondGrunt", 3.0f, "ActivateSecondGrunt");
}
void ActivateSecondGrunt(string &in asTimer)
{
SetEntityActive("servant_grunt_2", true);
StopSound("DanielSanityGain", 0);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_4", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_5", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_19", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_22", 4.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_23", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_24", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_25", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_26", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_27", 0.0f, "");
}
void DisableSecondGrunt(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_2", false);
}
void LookAtDeadMan(string &in asParent, string &in asChild, int alState)
{
if (GetEntityExists("servant_grunt_2") == false)
{
StartPlayerLookAt("corpse_male_1", 0.5f, 0.5f, "");
AddTimer ("TimerStopLookDeadMan", 2.0f, "StopLookDeadMan");
GiveSanityDamage(15, true);
PlayMusic("04_event_stairs", false, 1, 0.25f, 0, false);
AddTimer("reacttocorpse", 0.5f, "TimerPlayerReactToCorpse");
}
}
void TimerPlayerReactToCorpse(string &in asTimer)
{
PlaySoundAtEntity("scarecorpse", "react_breath", "Player", 0.1f, false);
}
void StopLookDeadMan(string &in asTimer)
{
StopPlayerLookAt();
}


I changed the syntax for the bone saw. That should sort that, but I didn't find anything wrong with the LookAtDeadMan. It's probably something to do with the "if (GetEntityExists("servant_grunt_2") == false)". I frankly have no idea why you want to use that, try doing it without that part to check if it works.
(This post was last modified: 05-30-2011, 08:23 PM by Roenlond.)
05-30-2011, 08:23 PM
Find




Users browsing this thread: 1 Guest(s)