Frictional Games Forum (read-only)
monster script setup - 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: monster script setup (/thread-10579.html)

Pages: 1 2 3


monster script setup - Manakind - 10-03-2011

hello i was following the wiki guide setting up a monster as im new to scripting i need some help here i think ive made an error somewhere in the script.

void TimerTutorial01(string &in asTimer)
{
SetMessage("Inventory", "CombineLevel12Error", 0);
}

void OnStart()
{
AddTimer("tut01", 5, "TimerTutorial01");

{
GiveItemFromFile("lantern", "lantern.ent");

for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction", true, 1);

}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}
void OnEnter()
{

}

void OnLeave()
{

}

this is my whole script thus far and i wanted my monster to spawn from a point and follow path nodes. but every time i start my level he doesnt spawn when i hit my scripted area spot. any ideas as to what im doing wrong? mucho help appriciate



RE: monster script setup - Urkle - 10-03-2011

I moved this over to the Customstories/modifications thread for Amnesia as the HPL1 forum is for the Opensource Penumbra engine.





RE: monster script setup - Manakind - 10-04-2011

bump bump =) still cant figure out where ive gone wrong. would love some help.



RE: monster script setup - Your Computer - 10-04-2011

Wait, the map worked for you without the game exiting with a script error?

Try replacing your code with this:
Code:
void TimerTutorial01(string &in asTimer)
{
    SetMessage("Inventory", "CombineLevel12Error", 0);
}

void OnStart()
{
    AddTimer("tut01", 5, "TimerTutorial01");
    GiveItemFromFile("lantern", "lantern.ent");

    for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");

    AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}

void OnEnter()
{

}

void OnLeave()
{

}



RE: monster script setup - i3670 - 10-04-2011

Hi Your Computer, you may remember me from yesterday Smile
I got the same problem with my monster, he just won't spawn.

Script:

void MyFunc(string &in asParent, string &in asChild, int alState)
{
AddEntityCollideCallback("Player", "Sound_5", "StartMusic", true, 1);
AddEntityCollideCallback("Player", "Sound_3", "StartMusic", true, 1);
AddEntityCollideCallback("Player", "Music_1", "StartMusic", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction", true, 1);
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}



RE: monster script setup - Manakind - 10-04-2011

(10-04-2011, 01:20 PM)Your Computer Wrote: Wait, the map worked for you without the game exiting with a script error?

Try replacing your code with this:
Code:
void TimerTutorial01(string &in asTimer)
{
    SetMessage("Inventory", "CombineLevel12Error", 0);
}

void OnStart()
{
    AddTimer("tut01", 5, "TimerTutorial01");
    GiveItemFromFile("lantern", "lantern.ent");

    for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");

    AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}

void OnEnter()
{

}

void OnLeave()
{

}
yep my script works without an error, now ive replaced my script with yours and the same thing is happening my map works but when i goto my designated area my inactive mob doesnt spawn. any suggestions?



RE: monster script setup - Your Computer - 10-04-2011

I'm going to need you guys to add this function to your script:
Code:
MonsterCheck(string &in entity, string &in type)
{
    AddDebugMessage(type, false);
}

Then in the level editor, select your monster and on the right, under the Entity tab, type in MonsterCheck for the CallbackFunc field. Be sure to save.

Also, update the MonsterFunction function so that it looks like this:
Code:
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    AddDebugMessage(asChild+" has activated!", false);
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}

Save. Now load your map and make sure show debug messages is enabled in your debug menu. Now activate the area by colliding with it and tell me if you see any text at the bottom left that says either "ScriptArea_1 has activated!" or "OnAutoDisabled" or both.


RE: monster script setup - Manakind - 10-04-2011

(10-04-2011, 05:34 PM)Your Computer Wrote: I'm going to need you guys to add this function to your script:
Code:
MonsterCheck(string &in entity, string &in type)
{
    AddDebugMessage(type, false);
}

Then in the level editor, select your monster and on the right, under the Entity tab, type in MonsterCheck for the CallbackFunc field. Be sure to save.

Also, update the MonsterFunction function so that it looks like this:
Code:
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
    AddDebugMessage(asChild+" has activated!", false);
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}

Save. Now load your map and make sure show debug messages is enabled in your debug menu. Now activate the area by colliding with it and tell me if you see any text at the bottom left that says either "ScriptArea_1 has activated!" or "OnAutoDisabled" or both.
silly question but how do you activate debug mode? ive tested the map and its not activating for me. would like to check if it says activated or onautodisabled =)



RE: monster script setup - i3670 - 10-04-2011

Same question as above. activate debug?

Tried to run the map. Gave me the error message: main(25,13): ERR : Expected identifier



RE: monster script setup - Your Computer - 10-05-2011

If you follow the steps written here, specifically step 3, you'll have access to the debug menu: http://wiki.frictionalgames.com/hpl2/amnesia/devenvguide

@i3670 That error message is not enough information for me to help you.