Frictional Games Forum (read-only)

Full Version: Call Monster When Interact With Door?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.
(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!
Yup, that worked. Appears that I had other things typed out incorrectly as well, but all has been remedied now!

Appreciate the help!
(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?
(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);
}
(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, "");
    }
}