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
How do I make an enemy spawn when the player enters a script area?
iNs Offline
Junior Member

Posts: 21
Threads: 4
Joined: Mar 2011
Reputation: 0
#8
RE: How do I make an enemy spawn when the player enters a script area?

void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

What does it?
It calls a function when two entites collide.

Callback syntax:
void MyFunc(string &in asParent, string &in asChild, int alState)

asParentName
internal name of main object

asChildName
internal name of object that collides with main object
(asterix (*) NOT supported!)

asFunction
function to call (for example "MyFunction")

abDeleteOnCollide
delete the callback after it was called?

alStates:
1 = on enter (when the 2 entities collide)
-1 = on leave (when they dont collide anymore)
0 = on enter AND on leave

---
I have fixed your code:

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

}

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

}

////////////////////////////
// Run first time starting map
void OnStart()
{
  // Player collides with 'AreaCloseDoor' => function 'CloseDoor' is called
  AddEntityCollideCallback("Player", "AreaCloseDoor", "CloseDoor", true, 1);

  // Player collides with 'AreaCloseDoor2' => function 'CloseDoor' is called
  // you can remove this callback, when you dont need a 2nd script area
  AddEntityCollideCallback("Player", "AreaCloseDoor2", "CloseDoor", true, 1);
  
  // Player collides with 'MonsterArea' => function 'SpawnMonster' is called
  AddEntityCollideCallback("Player", "MonsterArea", "SpawnMonster", true, 1);
}

// Player collides with 'AreaCloseDoor'
void CloseDoor(string &in asParent, string &in asChild, int alState)
{
  SetSwingDoorClosed("castle_2", true, true);
  GiveSanityDamage(2, true);
  PlaySoundAtEntity("DoorClose", "react_scare.snt", "Player", 0, false);
}

// Player collides with 'MonsterArea'
void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
  SetEntityActive("NotSoScaryMonster", true);
}

What do you need to get this code to work?
- Script Area named: "AreaCloseDoor"
- Script Area named: "AreaCloseDoor2" (optional)
- Script Area named: "MonsterArea"
- Your Monster named: "NotSoScaryMonster"

---
I hope that helps ya.


Regards
iNs
(This post was last modified: 04-04-2011, 11:53 AM by iNs.)
04-04-2011, 11:53 AM
Find


Messages In This Thread
RE: How do I make an enemy spawn when the player enters a script area? - by iNs - 04-04-2011, 11:53 AM



Users browsing this thread: 1 Guest(s)