Frictional Games Forum (read-only)
Call Monster When Interact With Door? - 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: Call Monster When Interact With Door? (/thread-6780.html)



Call Monster When Interact With Door? - theDARKW0LF - 03-04-2011

Hi guys, quick question...

What's the proper code to create an event where a monster is spawned after I interact with a door? I haven't created one of these specific situations before so I'm pretty much using trial and error methods right now...

Right now my code looks like this:
Code:
void CollideAreaGruntDoorCallback(string &in asParent, string &in asChild, int alState)
{
    SetEntityPlayerInteractCallback("DoorGrunt", "SpawnGrunt", false);
}

void SpawnGrunt(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("SpotGrunt2", true);
    GiveSanityDamage(10, true);
    AddEnemyPatrolNode("SpotGrunt", "PathNodeArea_98", 1, "");
    AddTimer("Waypoints", 13.0f, "TimerSpotGrunt2");
}

void TimerSpotGrunt2(string &in asTimer)
{
    if(asTimer == "Waypoints")
    {
        ClearEnemyPatrolNodes("SpotGrunt2");
        AddEnemyPatrolNode("SpotGrunt2", "PathNodeArea_83", 1, "");
    }
}

Something's wrong here, but I'm not too sure what, any help?


RE: Call Monster When Interact With Door? - Russ Money - 03-04-2011

SetEntityActive("SpotGrunt2", true);

SpotGrunt2 is the name of the grunt enemy entity?

I don't know what the name of the monster is, so I can't tell you if that's coded correctly.\

Edit:

Also, if you meant for the door to be intractable after a trigger,

SetEntityPlayerInteractCallback("DoorGrunt", "SpawnGrunt", false);

Then, it's right, if it's a door that's to spawn the monster whenever it gets touched, then just put it in OnStart.


RE: Call Monster When Interact With Door? - theDARKW0LF - 03-04-2011

(03-04-2011, 08:31 AM)Russ Money Wrote: SetEntityActive("SpotGrunt2", true);

SpotGrunt2 is the name of the grunt enemy entity?

I don't know what the name of the monster is, so I can't tell you if that's coded correctly.\

Edit:

Also, if you meant for the door to be intractable after a trigger,

SetEntityPlayerInteractCallback("DoorGrunt", "SpawnGrunt", false);

Then, it's right, if it's a door that's to spawn the monster whenever it gets touched, then just put it in OnStart.

Yes, SpotGrunt2 is the enemy. I'll try that out and get back to you, thanks!


RE: Call Monster When Interact With Door? - theDARKW0LF - 03-05-2011

Yup, that worked. Appears that I had other things typed out incorrectly as well, but all has been remedied now!

Appreciate the help!


RE: Call Monster When Interact With Door? - Droopy - 03-06-2011

(03-05-2011, 01:31 AM)theDARKW0LF Wrote: Yup, that worked. Appears that I had other things typed out incorrectly as well, but all has been remedied now!

You don't mind sharing the finished script for those who may have the same problems?


RE: Call Monster When Interact With Door? - Russ Money - 03-06-2011

(03-06-2011, 05:51 PM)Droopy Wrote:
(03-05-2011, 01:31 AM)theDARKW0LF Wrote: Yup, that worked. Appears that I had other things typed out incorrectly as well, but all has been remedied now!

You don't mind sharing the finished script for those who may have the same problems?

It'd look something like this

Code:
OnStart()
}
SetEntityPlayerInteractCallback("door", "monsterscare2", true);
{

void monsterscare2(string &in asEntity)
{
SetEntityActive("servant_grunt_1", true);
}



RE: Call Monster When Interact With Door? - theDARKW0LF - 03-07-2011

(03-06-2011, 05:51 PM)Droopy Wrote: You don't mind sharing the finished script for those who may have the same problems?

Sure. This is how mine goes:
Code:
void OnStart()
{

SetEntityPlayerInteractCallback("DoorGrunt", "SpawnGrunt", false);
    
}

void SpawnGrunt(string &in entity)
{
    SetEntityActive("SpotGrunt2", true);
    GiveSanityDamage(10, true);
    AddEnemyPatrolNode("SpotGrunt2", "PathNodeArea_100", 15, "");
    AddTimer("Waypoints1", 15.0f, "TimerSpotGrunt2");
    AddTimer("Waypoints2", 20.0f, "TimerSpotGrunt2");
    AddTimer("Waypoints3", 30.0f, "TimerSpotGrunt2");
}

void TimerSpotGrunt2(string &in asTimer)
{
    if(asTimer == "Waypoints1")
    {
        ClearEnemyPatrolNodes("SpotGrunt2");
    }
    else if(asTimer == "Waypoints2")
    {
        AddEnemyPatrolNode("SpotGrunt2", "PathNodeArea_54", 10, "");
    }
    else if(asTimer == "Waypoints3")
    {
        AddEnemyPatrolNode("SpotGrunt2", "PathNodeArea_83", 1, "");
    }
}