Frictional Games Forum (read-only)
Script causing game to randomly crash (No FATAL ERROR) - 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 causing game to randomly crash (No FATAL ERROR) (/thread-7885.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14


RE: extra_english now is working, but I need help with a different script :) - Roenlond - 05-12-2011

void OnStart()
{
AddEntityCollideCallback("servant_grunt_1", "monstergone_area", "MonsterGone", true, 1);
}

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

When "servant_grunt_1" collides with "monstergone_area", run the gone function Smile That should work, unless I messed something up.


RE: extra_english now is working, but I need help with a different script :) - RawkBandMan - 05-13-2011

(05-12-2011, 03:59 PM)Roenlond Wrote: void OnStart()
{
AddEntityCollideCallback("servant_grunt_1", "monstergone_area", "MonsterGone", true, 1);
}

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

When "servant_grunt_1" collides with "monstergone_area", run the gone function Smile That should work, unless I messed something up.

Thanks! Will try when I get the chance.

What songfile should I use though? Can I just leave it blank if I don't want it to make a sound?


RE: extra_english now is working, but I need help with a different script :) - RawkBandMan - 05-15-2011

Bumpity Bump Bump!


RE: extra_english now is working, but I need help with a different script :) - Roenlond - 05-15-2011

Oh sorry, don't know what I was thinking.

FadeEnemyToSmoke("servant_grunt_1", true/false);

true to make a "boom" and false for no sound. It's not a string, it's a boolean value.


RE: extra_english now is working, but I need help with a different script :) - RawkBandMan - 05-15-2011

(05-15-2011, 08:54 PM)Roenlond Wrote: Oh sorry, don't know what I was thinking.

FadeEnemyToSmoke("servant_grunt_1", true/false);

true to make a "boom" and false for no sound. It's not a string, it's a boolean value.

Ah Alright. Thanks. Once I can complete that little part of my map, place the area's and path nodes and stuff, I will test this.


RE: extra_english now is working, but I need help with a different script :) - RawkBandMan - 05-17-2011

(05-08-2011, 08:31 PM)Roenlond Wrote: Credits are made in the extra_english.lang file.

I do not have any example here, but I will try to write from my memory.

in extra_english.lang:

<CATEGORY Name ="Ending">
<Entry Name ="StartCredits">
Title of Story[br]
Made By:[br]
blablabla[br]
</Entry>
</CATEGORY>

and to call it, use this in your functions, preferably void OnLeave()

void OnLeave()
{
StartCredits("musicfiletoplay", true, "Ending", "StartCredits", 0);
}

That should do the trick, tell me if you have any troubles Smile

Also with this, can I make it so it's when I collide with a entity/door/area? would it be like this?

Spoiler below!

{
AddEntityCollideCallback("Player", "credits_area", "Credits", true, "");
}

void Credits(string &in asName, string &in asEntity)

{
StartCredits("ending_daniel.ogg", true, "Ending", "Credits", -1);
}



I think I'm getting better at this Smile


EDIT: also, getting a crash with a different map.

FATAL ERROR: Could not load script file Cells4.hps!
main(2,1) : ERR : Expected "," or ";"
main(18,1) : ERR : Unexpected token "{"
main(29,1) : ERR : Unexpected token "{"
main(60,1) : ERR : Unexpected token "{"

I checked my hps, and those lines are correct (As far as I know.)

my hps
Spoiler below!

void onStart()
wakeUp();


void wakeUp ()
{
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(20); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

{
void beginStory(string &in asTimer)
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

{
AddUseItemCallback("", "key_torture_chamber_1", "prison_section_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Player", "script_area_2", "ActivateMonster", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{
SetSwingDoorLocked("prison_section_1", false, true);
PlaySoundAtEntity("", "unlock_door", "prison_section_1", 0, false);
RemoveItem("key_torture_chamber_1");
}

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

{
SetEntityActive(servant_grunt_2", true);
}

void SetEnemyDisableTriggers("servant_grunt_1", "true");

{
AddEntityCollideCallback("servant_grunt_1", "monstergone_area", "MonsterGone", true, 1);
}

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

{
FadeEnemyToSmoke(servant_grunt_1", "false");
}

{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", "5.5f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", "0.0f", "");
}




RE: extra_english now is working, but I need help with a different script :) - Roenlond - 05-17-2011

First:
The syntax in parentheses is wrong. Since the command is "AddEntityCollideCallback", the script functions page http://wiki.frictionalgames.com/hpl2/amnesia/script_functions says that you should use:
void MyFunc(string &in asParent, string &in asChild, int alState)

the code should work besides that, as long as the callback is inside a function (void OnStart in most cases). Syntax errors are one of the nastiest; they don't give any errors but the function won't work anyhow.
Code:
{
AddEntityCollideCallback("Player", "credits_area", "Credits", true, "");
}

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

{
StartCredits("ending_daniel.ogg", true, "Ending", "Credits", -1);
}
Second map:
Spoiler below!

void onStart()
wakeUp();


void wakeUp ()
{
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(20); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

{
void beginStory(string &in asTimer)
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

{
AddUseItemCallback("", "key_torture_chamber_1", "prison_section_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Player", "script_area_2", "ActivateMonster", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{
SetSwingDoorLocked("prison_section_1", false, true);
PlaySoundAtEntity("", "unlock_door", "prison_section_1", 0, false);
RemoveItem("key_torture_chamber_1");
}

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

{
SetEntityActive("servant_grunt_2", true);
}

void SetEnemyDisableTriggers("servant_grunt_1", "true");

{
AddEntityCollideCallback("servant_grunt_1", "monstergone_area", "MonsterGone", true, 1);
}

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

{
FadeEnemyToSmoke("servant_grunt_1", "false");
}

{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", "5.5f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", "0.0f", "");
}

Forgot a quote around the monster name in two areas.


RE: extra_english now is working, but I need help with a different script :) - RawkBandMan - 05-17-2011

(05-17-2011, 03:55 PM)Roenlond Wrote: First:
The syntax in parentheses is wrong. Since the command is "AddEntityCollideCallback", the script functions page http://wiki.frictionalgames.com/hpl2/amnesia/script_functions says that you should use:
void MyFunc(string &in asParent, string &in asChild, int alState)

the code should work besides that, as long as the callback is inside a function (void OnStart in most cases). Syntax errors are one of the nastiest; they don't give any errors but the function won't work anyhow.
Code:
{
AddEntityCollideCallback("Player", "credits_area", "Credits", true, "");
}

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

{
StartCredits("ending_daniel.ogg", true, "Ending", "Credits", -1);
}
Second map:
Spoiler below!

void onStart()
wakeUp();


void wakeUp ()
{
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(20); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

{
void beginStory(string &in asTimer)
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

{
AddUseItemCallback("", "key_torture_chamber_1", "prison_section_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Player", "script_area_2", "ActivateMonster", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{
SetSwingDoorLocked("prison_section_1", false, true);
PlaySoundAtEntity("", "unlock_door", "prison_section_1", 0, false);
RemoveItem("key_torture_chamber_1");
}

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

{
SetEntityActive("servant_grunt_2", true);
}

void SetEnemyDisableTriggers("servant_grunt_1", "true");

{
AddEntityCollideCallback("servant_grunt_1", "monstergone_area", "MonsterGone", true, 1);
}

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

{
FadeEnemyToSmoke("servant_grunt_1", "false");
}

{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", "5.5f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", "0.0f", "");
}

Forgot a quote around the monster name in two areas.

Ah I was so close in the credits function! xD Alright I'll try this.


RE: extra_english now is working, but I need help with a different script :) - RawkBandMan - 05-18-2011

Nope. Got a different script and all its giving me is the same error, except with this.

main (8,1) : ERR : Unexpected '{'

HPS
Spoiler below!
void onStart()
{
AddUseItemCallback("", "key_torture_chamber_1", "prison_section_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Player", "script_area_2", "ActivateMonster", true);
AddEntityCollideCallback("servant_grunt_1", "monstergone_area", "MonsterGone", true, 1);
}

{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", "5.5f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", "0.0f", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", "0.0f", "");
}

void wakeUp()
{
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(20); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer)
{
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_section_1", false, true);
PlaySoundAtEntity("", "unlock_door", "prison_section_1", 0, false);
RemoveItem("key_torture_chamber_1");
}

void ActivateMonster(string &in asItem, string &in asEntity)
{
SetEntityActive(servant_grunt_2", true);
}

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


Thats like 56 lines of script. My other one had 68. Im confused.


RE: extra_english now is working, but I need help with a different script :) - Roenlond - 05-18-2011

void OnStart(), not void onStart()