Frictional Games Forum (read-only)

Full Version: Please help me :(
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hi all,

I'm making my first custom story now and im kinda stuck at scripting... I thought I knew pretty much already but I still seem to get stuck Sad

Here is my script for my map:


void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "playsound", true, 1);
AddUseItemCallback("StudyKey", "studykey_1", "mansion_2", "UsedKeyOnDoor", true);
SetEnemyIsHallucination("servant_grunt_1", true);
AddEntityCollideCallback("Player", "ScriptArea_2", "EnemyAppear", true, 1);
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_3", "EnemyDisable", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "LookTimer", true, 1); // TROUBLE HERE?
}

void playsound(string &in asParent, string &in asChild, int alState)
{
PlayMusic("break_wood1.ogg", false, 1, 0, 1.0, false);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("unlock_door.snt", "unlock_door", "mansion_2", 0.0f, false);
RemoveItem("studykey_1");
}

void EnemyAppear(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_1", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
}

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

// HAVING TROUBLE FROM HERE
// makes sure the player looks at Compound_5
void LookTimer(string &in asTimer)
{
AddTimer("LookAtEntity_1", 0, "LookAt_1");
}

// makes sure the player looks at chest_of_drawers_nice_broken_1
void Timer_1(string &in asTimer)
{
StopPlayerLookAt();
AddTimer("LookAtEntity_2", 1, "LookAt_2");
}

// makes sure the player looks at painting03_1
void Timer_2(string &in asTimer)
{
StopPlayerLookAt();
AddTimer("LookAtEntity_3", 1, "LookAt_3");
}

//LookTimer
void LookAt_1(string &in asEntity)
{
StartPlayerLookAt("Compound_5", 1, 1, "Timer_1");
}

// Timer_1
void LookAt_2(string &in asEntity)
{
StartPlayerLookAt("chest_of_drawers_nice_broken_1", 1, 1, "Timer_2");
}

// Timer_2
void LookAt_3(string &in asEntity)
{
StartPlayerLookAt("painting03_1", 1, 1, "Timer_3");
}

void OnLeave()
{

}

after the part that says "// HAVING TROUBLE FROM HERE" (obviously) I got stuck.. as well as the part at OnStart: "// TROUBLE HERE??" I want the player to look at 3 entities and then fall down as your sanity goes to 0. After that happened I want it to load a new map.. Though I didn't even got the player to look at certain entities... not any entity at all Sad Can someone please help me? Huh

I hope you guys can figure it out a bit..

Thanks! Big Grin
Aha! I love helping! I found your problem.

This line calls a collide callback

AddEntityCollideCallback("Player", "ScriptArea_4", "LookTimer", true, 1);


but this line has (string &in asTimer) instead of (string &in asParent, string &in asChild, int alState)


void LookTimer(string &in asTimer)



change it to this:


void LookTimer(string &in asParent, string &in asChild, int alState)



That should fix your problem, but I will keep looking over the script if that wasn't the solution!
(06-12-2012, 05:14 PM)andyrockin123 Wrote: [ -> ]Aha! I love helping! I found your problem.

This line calls a collide callback

AddEntityCollideCallback("Player", "ScriptArea_4", "LookTimer", true, 1);


but this line has (string &in asTimer) instead of (string &in asParent, string &in asChild, int alState)


void LookTimer(string &in asTimer)



change it to this:


void LookTimer(string &in asParent, string &in asChild, int alState)



That should fix your problem, but I will keep looking over the script if that wasn't the solution!
Still nog working Sad
And could you maybe explain what "string" you use on what situations? for now I'm just guessing a bit.. Blush
Correct me if I`m wrong, (I can`t search up the string for the timers in class), but are you sure if there`s supposed to be an extra variable there? StartPlayerLookAt("Compound_5", 1, 1, "Timer_1");

EDIT: Just searched it up, and the string for the timer is string& asName, float afTime, string& asFunction
In english: the name of the timer, the time the timer runs for and the function to call.
After the first timer, you're calling all other timers as (string &in asEntity) when it should be
(string &in asTimer)

Try this instead:


void LookTimer(string &in asParent, string &in asChild, int alState)
{
AddTimer("LookAtEntity_1", 0, "LookAt_1");
}

// makes sure the player looks at chest_of_drawers_nice_broken_1
void Timer_1(string &in asTimer)
{
StopPlayerLookAt();
AddTimer("LookAtEntity_2", 1, "LookAt_2");
}

// makes sure the player looks at painting03_1
void Timer_2(string &in asTimer)
{
StopPlayerLookAt();
AddTimer("LookAtEntity_3", 1, "LookAt_3");
}

//LookTimer
void LookAt_1(string &in asTimer)
{
StartPlayerLookAt("Compound_5", 1, 1, "Timer_1");
}

// Timer_1
void LookAt_2(string &in asTimer)
{
StartPlayerLookAt("chest_of_drawers_nice_broken_1", 1, 1, "Timer_2");
}

// Timer_2
void LookAt_3(string &in asTimer)
{
StartPlayerLookAt("painting03_1", 1, 1, "Timer_3");
}

(06-12-2012, 05:18 PM)Science Wrote: [ -> ]Correct me if I`m wrong, (I can`t search up the string for the timers in class), but are you sure if there`s supposed to be an extra variable there? StartPlayerLookAt("Compound_5", 1, 1, "Timer_1");
It threw me off at first, too. But that actually is correct:

StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);



Two simultaneous float values looks so strange for some reason.
Still doesn't work Sad and suddenly the monster doesn't spawn either... I thought I pretty much knew the basics of scripting but apparently not Sad
You seem to have Setenemy to hallucination in between the collidecallbacks.Try moving it?
(06-12-2012, 06:15 PM)Datguy5 Wrote: [ -> ]You seem to have Setenemy to hallucination in between the collidecallbacks.Try moving it?
It doesn't matter where you put the function right? as long as they trigger an event.. right? And even so.. where should I move it to?
(06-12-2012, 06:18 PM)pdkgaming Wrote: [ -> ]
(06-12-2012, 06:15 PM)Datguy5 Wrote: [ -> ]You seem to have Setenemy to hallucination in between the collidecallbacks.Try moving it?
It doesn't matter where you put the function right? as long as they trigger an event.. right? And even so.. where should I move it to?

You dont actually even need that.You can go to the level editor and click the enemy and then click the hallucination button in the other tab.
(06-12-2012, 06:19 PM)Datguy5 Wrote: [ -> ]
(06-12-2012, 06:18 PM)pdkgaming Wrote: [ -> ]
(06-12-2012, 06:15 PM)Datguy5 Wrote: [ -> ]You seem to have Setenemy to hallucination in between the collidecallbacks.Try moving it?
It doesn't matter where you put the function right? as long as they trigger an event.. right? And even so.. where should I move it to?

You dont actually even need that.You can go to the level editor and click the enemy and then click the hallucination button in the other tab.
Oh, lol.. I didn't know that xD Thanks! Smile
Pages: 1 2 3