Frictional Games Forum (read-only)
Monster isn't quite activating. - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Monster isn't quite activating. (/thread-7545.html)



Monster isn't quite activating. - DominusVita - 04-21-2011

Hey there. I'm trying to activate a grunt and it isn't quite happening. I checked the tutorials various times, and used the script provided. The monster is set to inactive, and the script looks like the following(The important sections are in bold):

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "FirstArea", "First", true, 1);
AddEntityCollideCallback("Player", "TeleStart", "FirstTele", true, 1);
AddEntityCollideCallback("Player", "Tele", "MonsterMash", true, 1);
AddEntityCollideCallback("Player", "WTF", "Second", true, 1);
}

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

{
SetMessage("TheBeginning", "Entry1", 20.0f);
}


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

{
SetMessage("TheBeginning", "Entry2", 20.0f);
}


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

{
SetEntityActive("BadMofo", true);
}



void FirstTele(string &in asParent, string &in asChild, int alState)
{
TeleportPlayer("Tele");
// Optional fading effects to make a better teleporting transition.
FadeOut(0);
FadeIn(20);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
//Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
{
GiveItemFromFile("lantern", "lantern.ent");

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


////////////////////////////
// Run when leaving map
void OnLeave()
{

}


RE: Monster isn't quite activating. - Josh707 - 04-21-2011

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

{
SetEntityActive("BadMofo", true);
}


where it says string &in asParent, string &in asChild,

after you put asParent there is no space before the ,

i'm not sure if that's the problem because that's the only one I see... when I make them I don't put spaces


RE: Monster isn't quite activating. - DominusVita - 04-21-2011

My other syntax code seems to work fine with it - I tried changing it but no go Sad

It's fine, I'll figure it out at one point or another. Thought I'd poll the more experienced before trying again.


RE: Monster isn't quite activating. - MrBigzy - 04-21-2011

Is the scriptarea named Tele and is the monster named BadMofo?


RE: Monster isn't quite activating. - Apjjm - 04-21-2011

(04-21-2011, 04:48 PM)DominusVita Wrote: My other syntax code seems to work fine with it - I tried changing it but no go Sad

It's fine, I'll figure it out at one point or another. Thought I'd poll the more experienced before trying again.

The trick is identifying exactly what the problem is. I suggest the following, so that you can trace the execution of your script:

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddDebugMessage("Started",false);
AddEntityCollideCallback("Player", "FirstArea", "First", true, 1);
AddEntityCollideCallback("Player", "TeleStart", "FirstTele", true, 1);
AddEntityCollideCallback("Player", "Tele", "MonsterMash", true, 1);
AddEntityCollideCallback("Player", "WTF", "Second", true, 1);
}

void First(string &in asParent , string &in asChild , int alState)
{
AddDebugMessage("First Called: " +asParent + "," + asChild,false);
SetMessage("TheBeginning", "Entry1", 20.0f);
}


void Second(string &in asParent , string &in asChild , int alState)
{
AddDebugMessage("Second Called: " +asParent + "," + asChild,false);
SetMessage("TheBeginning", "Entry2", 20.0f);
}


void MonsterMash(string &in asParent , string &in asChild , int alState)
{
AddDebugMessage("MonsterMash Called: " +asParent + "," + asChild,false);
SetEntityActive("BadMofo", true);
}


void FirstTele(string &in asParent, string &in asChild, int alState)
{
AddDebugMessage("FirstTele Called: " +asParent + "," + asChild,false);
TeleportPlayer("Tele");
// Optional fading effects to make a better teleporting transition.
FadeOut(0);
FadeIn(20);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
//Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
{
GiveItemFromFile("lantern", "lantern.ent");

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


////////////////////////////
// Run when leaving map
void OnLeave()
{

}

If it turns out "MonsterMash Called" never shows up, then you know you aren't triggering the script area*. If it does, you know the problem is in your SetEntitiyActive code. If you are still struggling to locate the error, print out more information. The more information you have, the easier it will be to find the problem.

*This could mean either your callback code is incorrect, or, teleporting into a script area doesn't fire a collision event - the latter you would have to work around.


RE: Monster isn't quite activating. - DominusVita - 04-21-2011

Thanks for the in-depth response, I'll try to find the error with that method.


RE: Monster isn't quite activating. - palistov - 04-21-2011

If it turns out teleporting to an area doesn't trigger a collide callback you could always use a very short timer (0.01) seconds to call a function immediately after teleporting the player. In the timer's callback do if(GetEntitiesCollide("Player", "Tele")) SetEntityActive("BadMofo", true);

Or just scratch the if statement and set the entity active 0.01 seconds later hehe Smile

Another option would be to set the entity active in your teleport function as opposed to making a collide callback with the teleport target area. So just add SetEntityActive("BadMofo", true); under your FirstTele function.


RE: Monster isn't quite activating. - DominusVita - 04-21-2011

That did it, having it all triggered in that one function made it work. Thanks Smile