A "Parent" Object?
Xyore
28 Sept 2012, 14:53I'm trying to create a room that detects for any enemies. When there are no enemies in a room, an event occurs, e.g., the battle music stops, a door opens, or a message appears. The only object I have that's an enemy is a stalfos. Now, my problems is, how would I detect for different enemies without having to list them all?
Let's say there's a room with a spider, a lizard, and a goblin while there is battle music playing in the background. Instead of checking if 'spider', 'lizard', and 'goblin' are in the room, is there a way for me to classify them as 'enemies' and refer to them as such for when I have a variety of monsters in a room and I want to stop the music when there are no monsters?
Also, how can I make a sort of loop for checking whether or not there are any monsters in the room? In my demo game, when you kill all the monsters in the room, the music doesn't automatically stop. It's only set so it checks for monsters 'after you enter the room'. Where can I put this check so it will constantly check for enemies and stop the music when there are no more enemies?
Let's say there's a room with a spider, a lizard, and a goblin while there is battle music playing in the background. Instead of checking if 'spider', 'lizard', and 'goblin' are in the room, is there a way for me to classify them as 'enemies' and refer to them as such for when I have a variety of monsters in a room and I want to stop the music when there are no monsters?
Also, how can I make a sort of loop for checking whether or not there are any monsters in the room? In my demo game, when you kill all the monsters in the room, the music doesn't automatically stop. It's only set so it checks for monsters 'after you enter the room'. Where can I put this check so it will constantly check for enemies and stop the music when there are no more enemies?
Xyore
28 Sept 2012, 15:02I'm not able to attach the game file, sorry.
sgreig
28 Sept 2012, 18:51You could put the check in a turnscript so it will do the check every time the player takes an action. That's probably the best bet.
As for your other question, Quest doesn't have built-in support for that kind of thing. Parent objects in Quest are essentially containers. i.e. if you place an object in your inventory, you become that objects parent. The room you're in is the player's parent, etc.
There is the option of using types in Quest, which allows you to pass common attributes to objects. There was another thread about this recently in the forum and some people (Pertex I think) gave some code samples on how to do checks for an object's type.
As for your other question, Quest doesn't have built-in support for that kind of thing. Parent objects in Quest are essentially containers. i.e. if you place an object in your inventory, you become that objects parent. The room you're in is the player's parent, etc.
There is the option of using types in Quest, which allows you to pass common attributes to objects. There was another thread about this recently in the forum and some people (Pertex I think) gave some code samples on how to do checks for an object's type.
The Pixie
28 Sept 2012, 19:33To expand on that, i would set up a new type "monster", and then have the monsters all inherit from that (on the attributes tab).
Then you can check for the room in a turnscript, get a list of objects, go though the list, and see if any inherit the monster type. In code, something like this:
Then you can check for the room in a turnscript, get a list of objects, go though the list, and see if any inherit the monster type. In code, something like this:
list = GetDirectChildren(playerparent)
flag = false
foreach (obj, list) {
if (DoesInherit (obj, "monster")) {
flag = true
}
}
Xyore
28 Sept 2012, 20:05sgreig wrote:You could put the check in a turnscript so it will do the check every time the player takes an action. That's probably the best bet.
As for your other question, Quest doesn't have built-in support for that kind of thing. Parent objects in Quest are essentially containers. i.e. if you place an object in your inventory, you become that objects parent. The room you're in is the player's parent, etc.
There is the option of using types in Quest, which allows you to pass common attributes to objects. There was another thread about this recently in the forum and some people (Pertex I think) gave some code samples on how to do checks for an object's type.
I did manage to make a turn script that checks for any existing enemies, thank you.
The Pixie wrote:To expand on that, i would set up a new type "monster", and then have the monsters all inherit from that (on the attributes tab).
Then you can check for the room in a turnscript, get a list of objects, go though the list, and see if any inherit the monster type. In code, something like this:list = GetDirectChildren(playerparent)
flag = false
foreach (obj, list) {
if (DoesInherit (obj, "monster")) {
flag = true
}
}
That was actually very helpful. Thank you very much.