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
My boolean functions are messing up the script
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#1
My boolean functions are messing up the script

I copied and pasted the script i wrote for a map below. for some reason when i introduce a boolean function and say if(blabbity blah(blah) == true), then the function works fine but if i use if(blabbity blah(blah) == false), the function stops working altogether. what am i doing wrong?
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);
if (GetEntityExists("servant_grunt_2") == false)
{
AddEntityCollideCallback("Player", "AreaDeadManInCloset", "LookAtDeadMan", true, 1);
}
if (HasItem("bone_saw_2") == false)
{
AddEntityCollideCallback("Player", "AreaSave_1", "AutoSaveStudy", true, 1);
}
AddUseItemCallback("", "studykey", "mansion_3", "UnlockStudyHallway", true);
SetEntityPlayerInteractCallback("mansion_3", "AddQuestGetKey", false);

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 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)
{
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();
}
void AddQuestGetKey(string &in asEntity)
{
AddQuest("QuestStudyHallway", "Quest_1");
}
void AutoSaveStudy(string &in asParent, string &in asChild, int alState)
{
AutoSave();
}

06-01-2011, 12:42 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: My boolean functions are messing up the script

You should really indent it and also put it into code form. :/

For code form, [*code] at the beginning of the script and [*/code] at the end. Remove asterisks.

06-01-2011, 12:48 AM
Find
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#3
RE: My boolean functions are messing up the script

well is indenting gonna make a difference in my script? i need a solution to my problem lol
06-01-2011, 12:50 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#4
RE: My boolean functions are messing up the script

(06-01-2011, 12:50 AM)willochill Wrote: well is indenting gonna make a difference in my script? i need a solution to my problem lol

Indenting is a good thing. It can help you find errors, bugs, and makes it look neater. So you should do it.

But I guess I'll have to... -_-

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);
     if (GetEntityExists("servant_grunt_2") == false)
     {
          AddEntityCollideCallback("Player", "AreaDeadManInCloset", "LookAtDeadMan", true, 1);
     }
     if (HasItem("bone_saw_2") == false)
     {
          AddEntityCollideCallback("Player", "AreaSave_1", "AutoSaveStudy", true, 1);
     }
     AddUseItemCallback("", "studykey", "mansion_3", "UnlockStudyHallway", true);
     SetEntityPlayerInteractCallback("mansion_3", "AddQuestGetKey", false);

     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 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)
{
     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();
}
void AddQuestGetKey(string &in asEntity)
{
     AddQuest("QuestStudyHallway", "Quest_1");
}
void AutoSaveStudy(string &in asParent, string &in asChild, int alState)
{
     AutoSave();
}

06-01-2011, 01:16 AM
Find
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#5
RE: My boolean functions are messing up the script

well thanks for indenting it but it didnt really help make the script work.. lol
it's neater and nicer though
any other suggestions to help with the problem?
06-01-2011, 03:27 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: My boolean functions are messing up the script

(06-01-2011, 03:27 AM)willochill Wrote: well thanks for indenting it but it didnt really help make the script work.. lol
it's neater and nicer though
any other suggestions to help with the problem?

So what exactly ISN'T working?

06-01-2011, 03:35 AM
Find
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#7
RE: My boolean functions are messing up the script

this is what isn't working:
in void OnStart(),
if (GetEntityExists("servant_grunt_2") == false)
{
AddEntityCollideCallback("Player", "AreaDeadManInCloset", "LookAtDeadMan", true, 1);
}
AND:
if (HasItem("bone_saw_2") == false)
{
AddEntityCollideCallback("Player", "AreaSave_1", "AutoSaveStudy", true, 1);
}
for both of these basically the if statement before it basically just eliminates the entire function. dunno why.
and yes they are indented in my script lol
(This post was last modified: 06-01-2011, 03:43 AM by willochill.)
06-01-2011, 03:42 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#8
RE: My boolean functions are messing up the script

You should add debug messages if you create a dev environment.

If you did already, use this to check if something is working or not:

AddDebugMessage(string& asString, bool abCheckForDuplicates);

Example:

AddDebugMessage("The player doesn't have the item.", false);

Try this:

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);
     if (GetEntityExists("servant_grunt_2") == false)
     {
          AddDebugMessage("servant_grunt_2 does not exist.", false);
          AddEntityCollideCallback("Player", "AreaDeadManInCloset", "LookAtDeadMan", true, 1);
     }
     if (HasItem("bone_saw_2") == false)
     {
          AddDebugMessage("Player doesn't have bone_saw_2.", false);
          AddEntityCollideCallback("Player", "AreaSave_1", "AutoSaveStudy", true, 1);
     }
     AddUseItemCallback("", "studykey", "mansion_3", "UnlockStudyHallway", true);
     SetEntityPlayerInteractCallback("mansion_3", "AddQuestGetKey", false);

     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 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)
{
     AddDebugMessage("LookAtDeadMan function has been called.", 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();
}
void AddQuestGetKey(string &in asEntity)
{
     AddQuest("QuestStudyHallway", "Quest_1");
}
void AutoSaveStudy(string &in asParent, string &in asChild, int alState)
{
     AutoSave();
     AddDebugMessage("AutoSaveStudy function has been called.", false);
}

06-01-2011, 03:52 AM
Find




Users browsing this thread: 4 Guest(s)