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 script setup
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#11
RE: monster script setup

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

AddEntityCollideCallback("Player", "Scare_1", "Collide_Scare_1", true, 1); //Callback for grunt spawn
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt_1", true);
AddEnemyPatrolNode("grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_10", 4, "");
}

Scare_1 = name of script area
I can start the map, but monster won't spawn
10-05-2011, 09:25 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#12
RE: monster script setup

(10-05-2011, 09:25 AM)i3670 Wrote: Scare_1 = name of script area
I can start the map, but monster won't spawn

By the looks of your code, Scare_1 isn't the area that triggers the MonsterFunction function.

Tutorials: From Noob to Pro
10-05-2011, 11:37 AM
Website Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#13
RE: monster script setup

(10-05-2011, 11:37 AM)Your Computer Wrote:
(10-05-2011, 09:25 AM)i3670 Wrote: Scare_1 = name of script area
I can start the map, but monster won't spawn

By the looks of your code, Scare_1 isn't the area that triggers the MonsterFunction function.
Any suggestion to what I should do?


10-05-2011, 11:47 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#14
RE: monster script setup

(10-05-2011, 11:47 AM)i3670 Wrote: Any suggestion to what I should do?

The code you provided implies that you have a line that adds the MyFunc function as a collision callback for another entity. You, therefore, have to collide with that entity (area) in order to add a collision callback to the "Scare_1" area. However, the collision callback set for "Scare_1" is a function called "Collide_Scare_1", which i do not see anywhere in the code you provided.

Tutorials: From Noob to Pro
(This post was last modified: 10-05-2011, 12:25 PM by Your Computer.)
10-05-2011, 12:24 PM
Website Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#15
RE: monster script setup

(10-05-2011, 12:24 PM)Your Computer Wrote:
(10-05-2011, 11:47 AM)i3670 Wrote: Any suggestion to what I should do?

The code you provided implies that you have a line that adds the MyFunc function as a collision callback for another entity. You, therefore, have to collide with that entity (area) in order to add a collision callback to the "Scare_1" area. However, the collision callback set for "Scare_1" is a function called "Collide_Scare_1", which i do not see anywhere in the code you provided.
Forgot to add the

void Collide_Scare_1(string &in asParent, string &in asChild, int alState) //Activates grunt
{
SetEntityActive("grunt_1", true);
}

I assume that makes sense
10-05-2011, 12:31 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#16
RE: monster script setup

(10-05-2011, 12:31 PM)i3670 Wrote: Forgot to add the

void Collide_Scare_1(string &in asParent, string &in asChild, int alState) //Activates grunt
{
SetEntityActive("grunt_1", true);
}

I assume that makes sense

Assuming i just add that code to the previous code, colliding with "Scare_1" still would not trigger the Collide_Scare_1 function. However, if you were to place the following code in the OnStart function, it should then work:
AddEntityCollideCallback("Player", "Scare_1", "Collide_Scare_1", true, 1);

Then you'd just have to clean up your code to remove any redundancy.

Tutorials: From Noob to Pro
10-05-2011, 12:37 PM
Website Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#17
RE: monster script setup

And I can use that code over and over again for different monster. If I change the area name and such, of course

I guess
(This post was last modified: 10-05-2011, 12:53 PM by i3670.)
10-05-2011, 12:52 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#18
RE: monster script setup

(10-05-2011, 12:52 PM)i3670 Wrote: And I can use that code over and over again for different monster. If I change the area name and such, of course

I guess

Yes; however, if you're planning on activating multiple monsters with the same callback for different events, you'd have to include conditional statements to differentiate between monsters within the callback function, or else you'd be activating all the monsters at the same time by colliding with just one area.

Tutorials: From Noob to Pro
10-05-2011, 12:57 PM
Website Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#19
RE: monster script setup

I tried to spawn the 2nd monster with this script, didn't work

void OnStart()
{
AddEntityCollideCallback("Player", "Scare_2", "Collide_Scare_2", true, 1);
AddEntityCollideCallback("Player", "Scare_1", "Collide_Scare_1", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt_1", true);
SetEntityActive("grunt_2", true);
AddEnemyPatrolNode("grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("grunt_1", "PathNodeArea_10", 4, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_11", 2, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_12", 4, "");
}

void Collide_Scare_1(string &in asParent, string &in asChild, int alState) //Activates grunt
{
SetEntityActive("grunt_1", true);
}

void Collide_Scare_2(string &in asParent, string &in asChild, int alState) //Activates grunt
{
SetEntityActive("grunt_2", true);
}


I assume I can't place the script for the path nodes like that? or the SetEntityActive. Do I haft to make a separate {} for that monster? or just skip a line?
10-05-2011, 01:04 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#20
RE: monster script setup

(10-05-2011, 01:04 PM)i3670 Wrote: I tried to spawn the 2nd monster with this script, didn't work
[...]
I assume I can't place the script for the path nodes like that? or the SetEntityActive. Do I haft to make a separate {} for that monster? or just skip a line?

Follow the MonsterCheck instructions from here and add the following to each Collide_Scare_* function:
AddDebugMessage(asChild+" has activated!", false);

Again, make sure debug messages are shown and tell me if you see any text at the bottom left of the game window when colliding with the areas.

It's true that MonsterFunction would never be called in your script and that each Collide_Scare_* function should only contain code specific to the monster you are activating.

Tutorials: From Noob to Pro
10-05-2011, 07:16 PM
Website Find




Users browsing this thread: 2 Guest(s)