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
Triggering Monsters
HansEnMilan Offline
Junior Member

Posts: 6
Threads: 2
Joined: Aug 2011
Reputation: 0
#1
Triggering Monsters

Hello,

I don't know if this is the right place to post this thread but I am new here.

Well I have tried everything to trigger a monster and make it walk from one position to another and then dissapear.

I've added a monster and 1 PathNode and I added a script area.

But everytime I end up getting different kinds of errors like : Invalid Token ''{'', etc

This is what I've got so far :

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "AreaEen", "CollideRoomEen", true, 1);
}

void CollideRoomEen(string &in asParent, string &in asChild, int alState)

{
SetSwingDoorLocked("hanskamerdeur", true, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "hanskamerdeurkey_1", "hanskamerdeur", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hanskamerdeur", false, true);
PlaySoundAtEntity("", "unlock_door", "hanskamerdeur", 0, false);
RemoveItem("hanskamerdeurkey_1");
}

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

}

As you can see I can trigger a door to close itself but I can't seem to trigger a monster, I started off the same way as I started with the door but then instead of CloseDoor I used this scripts :

void AddEnemyPatrolNode(string& asName, string& asNodeName, float afWaitTime, string& asAnimation);

Could someone Please help me, I've searched all of the internet but no one can give me a answer.





08-12-2011, 05:54 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: Triggering Monsters

Hi and welcome to forum.
Yes, this is correct section.

You need to place a monster where you want to spawn it, then deactivate it in the editor. This can be done with unchecking "active" checkbox.
After that, you need to activate the monster, with setentityactive function; then add the patrols.

You need to add patrol nodes in level editor first.
You can find the exact functions here: http://wiki.frictionalgames.com/hpl2/amn..._functions

08-12-2011, 06:06 PM
Website Find
HansEnMilan Offline
Junior Member

Posts: 6
Threads: 2
Joined: Aug 2011
Reputation: 0
#3
RE: Triggering Monsters

(08-12-2011, 06:06 PM)Tanshaydar Wrote: Hi and welcome to forum.
Yes, this is correct section.

You need to place a monster where you want to spawn it, then deactivate it in the editor. This can be done with unchecking "active" checkbox.
After that, you need to activate the monster, with setentityactive function; then add the patrols.

You need to add patrol nodes in level editor first.
You can find the exact functions here: http://wiki.frictionalgames.com/hpl2/amn..._functions

I tried this but I seem to fail haha, So If I'm correct I use :
void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

then link it with :
void SetEntityActive(string& asName, bool abActive);

and link that up with :
void AddEnemyPatrolNode(string& asName, string& asNodeName, float afWaitTime, string& asAnimation);

Mind giving me an example that fits in with this:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "AreaEen", "CollideRoomEen", true, 1);
}

void CollideRoomEen(string &in asParent, string &in asChild, int alState)

{
SetSwingDoorLocked("hanskamerdeur", true, true);
}


////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "hanskamerdeurkey_1", "hanskamerdeur", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hanskamerdeur", false, true);
PlaySoundAtEntity("", "unlock_door", "hanskamerdeur", 0, false);
RemoveItem("hanskamerdeurkey_1");
}


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

}

I would be very very happy.




08-12-2011, 06:25 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#4
RE: Triggering Monsters

If you already have a deactivated monster in your map, then:
void OnStart()
{
AddEntityCollideCallback("Player", "AreaEen", "CollideRoomEen", true, 1);
}

void CollideRoomEen(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("hanskamerdeur", true, true);
SetEntityActive("monster_name_here", true);
AddEnemyPatrolNode("monster_name_here", "node_name_here", 0, "");
}


////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "hanskamerdeurkey_1", "hanskamerdeur", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hanskamerdeur", false, true);
PlaySoundAtEntity("", "unlock_door", "hanskamerdeur", 0, false);
RemoveItem("hanskamerdeurkey_1");
}


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

}

08-12-2011, 06:28 PM
Website Find
HansEnMilan Offline
Junior Member

Posts: 6
Threads: 2
Joined: Aug 2011
Reputation: 0
#5
RE: Triggering Monsters

(08-12-2011, 06:28 PM)Tanshaydar Wrote: If you already have a deactivated monster in your map, then:
void OnStart()
{
AddEntityCollideCallback("Player", "AreaEen", "CollideRoomEen", true, 1);
}

void CollideRoomEen(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("hanskamerdeur", true, true);
SetEntityActive("monster_name_here", true);
AddEnemyPatrolNode("monster_name_here", "node_name_here", 0, "");
}


////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "hanskamerdeurkey_1", "hanskamerdeur", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hanskamerdeur", false, true);
PlaySoundAtEntity("", "unlock_door", "hanskamerdeur", 0, false);
RemoveItem("hanskamerdeurkey_1");
}


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

}

Thanks for helping, But I seem to be a total noob at coding.

I made it like this now :

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "AreaEen", "CollideRoomEen", true, 1);
}

void CollideRoomEen(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("hanskamerdeur", true, true);
SetEntityActive("Hans", true);
AddEnemyPatrolNode("Hans", "PadTwee", 0, "");
}









////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "hanskamerdeurkey_1", "hanskamerdeur", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hanskamerdeur", false, true);
PlaySoundAtEntity("", "unlock_door", "hanskamerdeur", 0, false);
RemoveItem("hanskamerdeurkey_1");
}





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

}




But I get this error :

FATAL ERROR: Could not load script file
'custom_stories/DeAvond/maps/Lol.hps'!
main (36,1) : ERR : Unexpected token '--''


Sorry again for not being able to fix it Sad
08-12-2011, 06:38 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#6
RE: Triggering Monsters

There is something wrong in 36th row, however as far as I can see 36th row is empty.
Check it in your text editor, it should work as it is now.

08-12-2011, 06:56 PM
Website Find
HansEnMilan Offline
Junior Member

Posts: 6
Threads: 2
Joined: Aug 2011
Reputation: 0
#7
RE: Triggering Monsters

(08-12-2011, 06:56 PM)Tanshaydar Wrote: There is something wrong in 36th row, however as far as I can see 36th row is empty.
Check it in your text editor, it should work as it is now.

I looked at Notepad ++ and there isn't anything in at row 36?

So I guess it just doesn't work for me?


(08-12-2011, 06:56 PM)Tanshaydar Wrote: There is something wrong in 36th row, however as far as I can see 36th row is empty.
Check it in your text editor, it should work as it is now.

Never Mind I got it to work, I was saving on the backup file which actually wasn't in the maps folder :$

Thanks for all your help!

(This post was last modified: 08-12-2011, 07:03 PM by HansEnMilan.)
08-12-2011, 06:59 PM
Find
MegaScience Offline
Member

Posts: 213
Threads: 1
Joined: Aug 2011
Reputation: 2
#8
RE: Triggering Monsters

Although you said you figured this out, I felt this might need to be added: I work with Torque Game Code, and I believe the source it uses is the same (or similar) language to this. Although I haven't worked with the source, it appears to be a much more specific variation of the game coding I'm accustom to. As such, you should avoid extra spaces and words out of proper case/capitalization.
08-13-2011, 06:20 AM
Find




Users browsing this thread: 1 Guest(s)