04-03-2011, 11:54 PM
04-04-2011, 12:14 AM
First make a script area, name it whatever you want.
In your script file under OnStart, put this
"Monster_1" is the name of my script area. Change it to whatever yours is called.
"MonsterFunc1" is the name of the function we're going to use later.
Oh, I forgot. Make sure the enemy is "disabled" in the editor. Do this by clicking on the enemy and finding the box called "Active" and click it if it's checked.
Once all that is done, add this to your script
MonsterFunc1 is the name of your function. The string stuff is just randomness and I don't know what they do, but you need them, lol
Replace the name of "servant_grunt_1" with whatever you named your grunt. Voila. Your enemy should appear when you walk into the area script ~_^
In your script file under OnStart, put this
Code:
AddEntityCollideCallback("Player", "Monster_1", "MonsterFunc1", true, 1);
"Monster_1" is the name of my script area. Change it to whatever yours is called.
"MonsterFunc1" is the name of the function we're going to use later.
Oh, I forgot. Make sure the enemy is "disabled" in the editor. Do this by clicking on the enemy and finding the box called "Active" and click it if it's checked.
Once all that is done, add this to your script
Code:
void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
}
MonsterFunc1 is the name of your function. The string stuff is just randomness and I don't know what they do, but you need them, lol
Replace the name of "servant_grunt_1" with whatever you named your grunt. Voila. Your enemy should appear when you walk into the area script ~_^
04-04-2011, 12:34 AM
Quote:////////////////////////////There is my whole code after I added your stuff in it. But I got an error upon loading my map.
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "DoorClose", "CollideScript", true, 1);
}
void CollideScript(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("castle_2", true, true);
AddEntityCollideCallback("Player", "DoorClose", "ScriptArea_2", true, 1);
GiveSanityDamage(2, true);
PlaySoundAtEntity("DoorClose", "react_scare.snt", "Player", 0, false);
AddEntityCollideCallback("Player", "Monster", "Spawn", true, 1);
void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Fag", true);
}
04-04-2011, 12:37 AM
Well... Yeah. It looks like there are a lot of things wrong with your script, tbh.
04-04-2011, 12:49 AM
Check the link in my sig.
04-04-2011, 12:57 AM
(04-04-2011, 12:37 AM)Austums Wrote: [ -> ]Well... Yeah. It looks like there are a lot of things wrong with your script, tbh.Lol, that's what I thought
(04-04-2011, 12:49 AM)Pandemoneus Wrote: [ -> ]Check the link in my sig.I have been there several times. I downloaded all the videos and reviewed them. But they don't answer all of my questions. I don't know how to keep adding commands without having the ones before it mess up, or my game just crashes.
(04-04-2011, 12:49 AM)Pandemoneus Wrote: [ -> ]Check the link in my sig.I have been there several times. I downloaded all the videos and reviewed them. But they don't answer all of my questions. I don't know how to keep adding commands without having the ones before it mess up, or my game just crashes.
04-04-2011, 10:11 AM
Also use the search function.
http://www.frictionalgames.com/forum/thread-5117.html
http://www.frictionalgames.com/forum/thread-5117.html
04-04-2011, 11:53 AM
Code:
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:
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
04-04-2011, 08:36 PM
Thanks man! This surely does help!