Monster walking paths - Shoop - 04-23-2011
You guys are probably bitch at me, but how do you get the monsters to move? I made it spawn but it only moves if it sees me, otherwise it just stands there. Not only that, but it never leaves it will stay there until I let it kill me. Please help me.
RE: Monster walking paths - Kyle - 04-23-2011
Don't worry, I'm here to help you.
On the side bar in the editor there is a button called "Areas" and there will be a drop box once you click it. Towards the bottom if it is "PathNode". Click it and place it next to your monster that shows what way it goes. So make a path with them, about a meter apart from each PathNode. Now you have to script.
The script line looks like this:
AddEnemyPatrolNode(string& asName, string& asNodeName, float afWaitTime, string& asAnimation);
For example, if my monster is called "Monster01" and the PathNode is called "PathNodeArea_1" and I want the monster to wait between nodes for 5 seconds I would do:
AddEnemyPatrolNode("Monster01", "PathNodeArea_1", 5, "");
AddEnemyPatrolNode("Monster01", "PathNodeArea_2", 5, "");
This would make the monster wait 5 seconds, then go to path node 1, then wait 5 seconds at path node 1 and then move on to path node 2. By the way, the last slot of the script line ("string& asAnimation") can be left blank.
Congratulations, you were just helped by a 13-year-old.
RE: Monster walking paths - Shoop - 04-23-2011
Thank you good sir, but at this path node 2 is that far away from the player? and will that make him vanish or do I gotta do a collide callback then a void entity false thing?
RE: Monster walking paths - Hunter of Shadows - 04-23-2011
Quote:You guys are probably bitch at me
The community here is very nice, you have nothing to fear, I have yet to meet one troll or flamer etc etc.
RE: Monster walking paths - Shoop - 04-23-2011
I have been called a noob and told to learn scripting and stop bugging the forums once before. I know this a very nice community, probably the best one.
Does this work?
Code: AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_86", "5", "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_99", "5", "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_52", "5", "");
AddEntityCollideCallback("servant_grunt_2" , "MonsterDie" , "MonsterDie1" , true , 1);
}
void MonsterDie1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_2" , false);
}
In better posistions of course, but would that make him leave and die.
RE: Monster walking paths - Kyle - 04-23-2011
(04-23-2011, 02:33 AM)Shoop Wrote: Thank you good sir, but at this path node 2 is that far away from the player? and will that make him vanish or do I gotta do a collide callback then a void entity false thing?
It doesn't matter if the path node is far away from the player or not, it depends what you want. Once the path nodes stop from going into the game, then it dissapears. For example:
Code: void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "SpawnMonsterFunction", true, 1);
}
void SpawnMonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
AddEnemyPatrolNode("Monster", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_3", 20, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_4", 2, "");
}
The example script causes the Monster to spawn once the player collides with an area. Then the monster goes to path node 1 and waits there for 2 seconds. Then it moves to path node 2 and then goes to path node 3 without stopping. Then when it gets to path node 3, it stays where it is for 20 seconds. When 20 seconds past, it goes to path node 4 and from there waits for 2 seconds. Then it turns to dust and dissapears because it is the end of it's path. If the player is detected by the monster, it will move off it it's path and follow you. If it loses you, it doesn't look for you because it is not part of it's path.
RE: Monster walking paths - Shoop - 04-23-2011
(04-23-2011, 02:47 AM)Kyle Wrote: (04-23-2011, 02:33 AM)Shoop Wrote: Thank you good sir, but at this path node 2 is that far away from the player? and will that make him vanish or do I gotta do a collide callback then a void entity false thing?
It doesn't matter if the path node is far away from the player or not, it depends what you want. Once the path nodes stop from going into the game, then it dissapears. For example:
Code: void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "SpawnMonsterFunction", true, 1);
}
void SpawnMonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
AddEnemyPatrolNode("Monster", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_3", 20, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_4", 2, "");
}
The example script causes the Monster to spawn once the player collides with an area. Then the monster goes to path node 1 and waits there for 2 seconds. Then it moves to path node 2 and then goes to path node 3 without stopping. Then when it gets to path node 3, it stays where it is for 20 seconds. When 20 seconds past, it goes to path node 4 and from there waits for 2 seconds. Then it turns to dust and dissapears because it is the end of it's path. If the player is detected by the monster, it will move off it it's path and follow you. If it loses you, it doesn't look for you because it is not part of it's path.
If it cannot find you after chasing you, does it go back on course or will it just stand there? Will it destroy doors in its way too? Also, look above and check mine please.
RE: Monster walking paths - Kyle - 04-23-2011
It will go back onto it's course.
RE: Monster walking paths - Shoop - 04-23-2011
What did I do wrong?
Code: void OnStart()
{
AddUseItemCallback("", "key1", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor2", true);
AddUseItemCallback("", "key3", "castle_3", "UsedKeyOnDoor3", true);
AddUseItemCallback("", "key4", "castle_6", "UsedKeyOnDoor4", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player" , "ScriptArea_3" , "MonsterFunc2" , true , 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "ChangeMap", true, 1);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_86", "1", "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_99", "10", "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_52", "5", "");
AddEntityCollideCallback("servant_grunt_2" , "MonsterDie" , "MonsterDie1" , true , 1);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_66", "1", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_63", "8", "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_82", "5", "");
AddEntityCollideCallback("servant_grunt_1" , "MonsterDie2" , "MonsterDie2" , true , 1);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("key1");
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
RemoveItem("key2");
}
void UsedKeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_3", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
RemoveItem("key3");
}
void UsedKeyOnDoor4(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_6", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_6", 0, false);
RemoveItem("key4");
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}
void MonsterDie1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_2" , false);
}
void MonsterDie2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , false);
}
void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_2" , true);
}
void ChangeMap(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Level2.map", "PlayerStartArea_1", "break_stairs", "water_lurker_eat");
}
void OpenDoor(string &in asParent, string &in asChild, int alState)
{
AddEntityCollideCallback("Player", "ScriptArea_4", "metal_1", true, 1);
}
RE: Monster walking paths - palistov - 04-23-2011
Do patrol nodes create a loop? Or will I have to re-add them if I want a monster to say, walk in a circle around a large room indefinitely?
|