Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Monster appear
Sudden Offline
Junior Member

Posts: 10
Threads: 4
Joined: Jan 2011
Reputation: 0
#1
Monster appear

How do i make a monster appear from nowhere and start patroling when i enter a area?
01-29-2011, 11:54 AM
Find
Vradcly Offline
Member

Posts: 100
Threads: 6
Joined: Jan 2011
Reputation: 0
#2
RE: Monster appear

Create the monster in your map and make sure its not active (there is a checkbox for that), create pathnodes for where you want the enemy patrol (areas, pathnode), make sure not to set the pathnodes to far apart. Then open your map script and add the first and last point in the enemy path inside void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_1",0.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_50",0.0f, "");
}
like that for example.

Then create a area of type script and put it in your map where you want the player to be when the enemy activates. Then add a collide callback for that area:
AddEntityCollideCallback("Player", "Script_Area_1", "CollideScript_Area_1", true, 1);
Something like that.

Then you put the CollideScript_Area_1 function outside of your OnStart(), ex above:

void CollideScript_Area_1(string &in asParent, string &in asChild, int alState)
{

}
void OnStart()
{
(lots of code)
}

and at last put the SetEntityActive("servant_grunt_1", true); inside your callision function:

void CollideScript_Area_1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
}

like that. Hope that helps, if not I suggest you look at the guides for this, there are lots of information out there...
01-29-2011, 01:01 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#3
RE: Monster appear

Here is a script file that I used as an example.
////////////////////////////
// Run first time starting map
void OnStart()
{
     AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunc1", true, 1);
}
void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
     SetEntityActive("servant_grunt_1", true);
}
////////////////////////////
// Run when entering map
void OnEnter()
{

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

}

Notes: At the SetEntityActive line, you must use the monster's exact name.

If you have servant_grunt_1 in your level, for example, then you must use "servant_grunt_1" at the SetEntityActive line in the script file.

Just copy-paste the code, and check your entity and scriptarea in your map and in your script file.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 01-29-2011, 01:05 PM by Robby.)
01-29-2011, 01:04 PM
Website Find
Sudden Offline
Junior Member

Posts: 10
Threads: 4
Joined: Jan 2011
Reputation: 0
#4
RE: Monster appear

It worked! Big Grin Thanks alot Smile
01-29-2011, 02:55 PM
Find
CrushedRaiD Offline
Member

Posts: 115
Threads: 10
Joined: Dec 2010
Reputation: 0
#5
RE: Monster appear

Having problems with this script:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunc1", true, 1);
}
void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
}

AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_1",0.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_4",0.0f, "");
}
////////////////////////////
// Run when entering map
void OnEnter()
{

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

}

Any help plox =)[/quote]
02-05-2011, 08:35 AM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#6
RE: Monster appear

Your AddEnemyPatrolNodes are not in a function.

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunc1", true, 1);
}
void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_1",0.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_4",0.0f, "");
}

////////////////////////////
// Run when entering map
void OnEnter()
{

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

}

[Image: 2exldzm.png]
02-05-2011, 09:28 AM
Find
CrushedRaiD Offline
Member

Posts: 115
Threads: 10
Joined: Dec 2010
Reputation: 0
#7
RE: Monster appear

(02-05-2011, 09:28 AM)Oscar House Wrote: Your AddEnemyPatrolNodes are not in a function.

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunc1", true, 1);
}
void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_1",0.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_4",0.0f, "");
}

////////////////////////////
// Run when entering map
void OnEnter()
{

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

}
Thank you ill try that one Big Grin
02-05-2011, 09:43 AM
Find




Users browsing this thread: 2 Guest(s)