That's great that you went through the tutorial (it really does help a lot).
A good next step in learning, is to get fully competent in the:
character creation (
http://docs.textadventures.co.uk/quest/ ... ation.html )
after that, then slowly start on the various other guides, and get familiar with these links too:
Quest's 'Code Bible' links:
http://docs.textadventures.co.uk/quest/http://docs.textadventures.co.uk/quest/ ... notes.htmlhttp://docs.textadventures.co.uk/quest/tutorial/http://docs.textadventures.co.uk/quest/guides/viewforum.php?f=18http://docs.textadventures.co.uk/quest/ ... quest.htmlhttp://docs.textadventures.co.uk/quest/ ... ments.htmlhttp://docs.textadventures.co.uk/quest/elements/http://docs.textadventures.co.uk/quest/types/http://docs.textadventures.co.uk/quest/functions/ (category order)
http://docs.textadventures.co.uk/quest/ ... tions.html (alphabetical order)
http://docs.textadventures.co.uk/quest/scripts/http://docs.textadventures.co.uk/quest/ ... lists.htmlhttp://docs.textadventures.co.uk/quest/ ... aries.htmlhttp://docs.textadventures.co.uk/quest/ ... reach.htmlhttp://docs.textadventures.co.uk/quest/scripts/for.htmlhttp://docs.textadventures.co.uk/quest/scopes.htmlunder the Function section (see links above), the: 'Alls', 'Gets', 'Scopes', and 'Contains'
-----------
as for what you want specifically:
Ilmiasu wrote:Hello, I'm new to these forums and to Quest. I have done the tutorial, and spent some time becoming familiar, with the program, but there are still a lot I don't know. Now I have a problem, which I'm not sure how to solve or have found a solution to, from this forum.
Basically I'm trying to have the player fight the enemy objects inside a room, without being able to leave until the enemies are defeated. I know how to stop the player from moving by adjusting the "go" command and I have a script for the fighting.
The problem is how do I make the fighting script recognise, that all the enemies in the room are defeated? So I need a script that checks how many enemies are present in the room. How do I do that? Suggestions and advise would be most appreciated.
(there's many ways to do what you want, here's hopefully the best~simpliest way for you, lol ~ I'm still a noob myself at coding)
Conceptually:
1. you need a way for quest to identify your 'enemy' Objects, vs the 'non-enemy' Objects
2. to check if you got all of the 'enemy' Objects killed, in order to (or before able to) leave the room
------------
for #1:
(for these examples, I'll be using my own labeling system~convention, you can of course call~name~label the stuff however you want)
if you want a simple and static 'monster~enemy vs npc~townsperson' system, then we can just use a Boolean (a true~false flag) Attribute
--- if you want something else, such as dynamic system (they can change between friend and foe), then let me know!
'whatever' Object -> Attributes Tab -> Attributes (NOT Status Attributes) -> Add -> (set it up, see below, repeat as needed for each Object and~or Attributes)
An Enemy Object:
(Object name: whatever)
Attribute Name: hostile_boolean
Attribute Type: boolean
Attribute Value: true
A Non-Enemy Object:
(Object name: whatever)
Attribute Name: hostile_boolean
Attribute Type: boolean
Attribute Value: false
------
in-code, it'd look like this (an example):
Object_name.Attribute_name = Value_or_Expression
non-enemy:
inn_keeper.hostile_boolean = false
enemy:
orc.hostile_boolean = true
-------
for #2:
http://docs.textadventures.co.uk/quest/ ... arent.htmlObject_name.Attribute_name = Value_or_Expression
(moving Object).parent = (destination Object)
example: player.parent = room
http://docs.textadventures.co.uk/quest/ ... reach.htmlhttp://docs.textadventures.co.uk/quest/ ... ldren.htmlhttp://docs.textadventures.co.uk/quest/ ... olean.htmlhttp://docs.textadventures.co.uk/quest/ ... t_add.htmlhttp://docs.textadventures.co.uk/quest/ ... count.htmland this will be in code (ask if you need help with implementing the code into your game), as I'm not familiar with using the GUI~Editor...
(also, this code below, requires that you either remove the 'enemy' Object when it's dead from the room or to change it's Boolean Attribute's 'hostile_boolean' Value to being 'false', otehrwise, if you want we can implement a 'dead' condition, either as a String Attribute or a Boolean Attribute, and change the code for it)
(the below though is jsut a sample code, we can change it to what+how you want done in your game, and I will gladly explain and help you through it's implementation into your game)
// A Scripting location:
// check_for_zero_enemies_in_order_to_leave_room_function (player.parent)
<function name="check_for_zero_enemies_in_order_to_leave_room_function" parameters="room_parameter" type="boolean">
foreach (object_variable, GetDirectChildren (room_parameter) ) {
if (GetBoolean (object_variable, "hostile_boolean") {
list add (enemy_objectlist_variable, object_variable)
}
}
on ready {
if (ListCount (enemy_objectlist_variable) = 0) {
// script that enables you to leave the room
} else {
// script that prevents you from leaving the room
}
}
</function>
this is a bit advancd if you're new to coding, and~or to quest's coding.
------------
Conceptually what is going on (what the code is doing):
------------
check_for_zero_enemies_in_order_to_leave_room_function (player.parent)
<function name="check_for_zero_enemies_in_order_to_leave_room_function" parameters="room_parameter" type="boolean">
foreach (object_variable, GetDirectChildren (room_parameter) ) {
it's going through all of the Objects in the specified room ( 'player.parent' ===> 'room_parameter' ), and will apply the following scripts below to each~every~all of the Objects (object_variable) in the specified room
-----------
if (GetBoolean (object_variable, "hostile_boolean") {
list add (enemy_objectlist_variable, object_variable)
}
if any of the Objects (object_variable), have the 'hostile_boolean' Boolean Attribute AND it's Value is 'true', then adds it to a new (temporary) objectlist (enemy_objectlist_variable).
-----------
if (ListCount (enemy_objectlist_variable) = 0) {
// script that enables you to leave the room
} else {
// script that prevents you from leaving the room
}
this checks the quantity of Objects in the temporary objectlist (enemy_object_variable), and if it is 0~ZERO, then it'll run the script needed to let you leave the room, else, it runs a script preventing you from leaving the room.