Request for advice on certain parimeters

starmoxas
07 Oct 2012, 22:38
Hello, I downloaded Quest 5 in order to create a text adventure game with the minimum of fuss. Because I am completely worthless at coding I believed and correctly that this program would be more simple and what I wanted than all the other programs. I am writing a game *cough cough* and would like your advice on certain concepts I do not think I can grasp easily.

1. I have replaced the regular health stat with a modified value called Stamina, and have an additional value called Mana for magic. Now in the course of the game, the values will drop up and down. However I wish to set a maximum value for these two statuses because I don't wish to cheapen the value of healing in the game. Here is the example of the code I used to set these values in the first place
<Stamina type="int">0</Stamina>
<Mana type="int">0</Mana>
player.Stamina = player.Warrior+6
player.Mana = player.Mage * 2
So how would I set a maximum value for these two, and if there are events in the game that can change these values how I do I code for this circumstance?

2.Next I have set a menu based system for selecting the player character's race and class. However if during certain events in the game where I mention these two choices in a description and event or open up a different story path depending on these choices. How do I place this information in descriptions and how do I set flags that require a certain class, race, etc? This is the example of how I set the classes

<Class type="list">Paladin; Barbarian; Sorcerer; Bard; Wizard; Ranger; Thief; Monk</Class>
show menu ("\"Now choose your class\"", game.Class, false) {
if (result ="Barbarian") {
msg ("\"You are a Barbarian\"")
player.Warrior = player.Warrior+5
player.Rogue = player.Rogue+2
}
else if (result ="Paladin") {
msg ("\"You are a Paladin\"")
player.Warrior = player.Warrior+4
player.Mage = player.Mage+3
}
else if (result ="Thief") {
msg ("\"You are a Thief\"")
player.Rogue = player.Rogue+3
player.Mage = player.Mage+2
player.Warrior = player.Warrior+2
}
else if (result ="Ranger") {
msg ("\"You are a Ranger\"")
player.Warrior = player.Warrior+3
player.Rogue = player.Rogue+3
player.Mage = player.Mage+1
}
else if (result ="Sorcerer") {
msg ("\"You are a Sorcerer\"")
player.Mage = player.Mage+5
player.Rogue = player.Rogue+1
player.Warrior = player.Warrior+1
}
else if (result ="Wizard") {
msg ("\"You are a Wizard\"")
player.Mage = player.Mage+6
player.Rogue = player.Rogue+1
}
else if (result ="Bard") {
msg ("\"You are such a spoony Bard\"")
player.Mage = player.Mage+3
player.Rogue = player.Rogue+2
player.Warrior = player.Warrior+2
}
else if (result ="Monk") {
msg ("\"Really? Well if you don't mind that Monks suck\"")
player.Warrior = player.Warrior+3
player.Rogue = player.Rogue+2
player.Mage = player.Mage+2


3. In the event that I give certain classes abilities, how do I set them? I had the idea that the skills are only active when a flag is set off by selecting a particular class. But what do you suggest the procedure I should go about using?

4.Last for now I'm using a particular game system that requires the selection of a random value, adding it to a particular status and comparing whether it is smaller or larger to a target value. The problem is while I have a working system for this, it requires me to use a script to set the random value each and every time. Is there anyway I can streamline this by setting a attribute somewhere that selects the random number and all I have to do is place that attribute into the script? This is the working system that I developed

<look type="script"><![CDATA[
msg ("\"It's a Trap Dummy! You are smacked in the face by the trap\"")
roll = GetRandomInt(1,6)
if (player.Rogue+roll<5) {
player.Stamina = player.Stamina- 1
}
else if (player.Rogue+roll>5) {
msg ("\"You Dodged it\"")
}


Also one last thing, why does one have to put player. or game. in front of an attribute when using it in a script? I wasted a lot of time figuring that out. Thank you for your assistance

The Pixie
08 Oct 2012, 07:19
Hi starmoxas

1. Your code:

<Stamina type="int">0</Stamina>
<Mana type="int">0</Mana>
player.Stamina = player.Warrior+6
player.Mana = player.Mage * 2


The last two lines should be inside a script, but perhaps that is already the case as Quest will not let you put in code exactly as you have put it here.

To ensure they do not go above the maximum, have a turn script that is set to run from the start, then do something like this:

if (player.Stamina > stamina_max) {
player.Stamina = stamina_max
}

2. In your code, add a line like this after the second line:

player.Class = result


Now in text you can say:

msg ("As you are a " + player.Class + " you find this very interesting.")


Or make decisions

if (player.Class = "Thief") {


3. The answer to 2 might be a step in the right direction, but if you can give an example, I can say more.

4. Not sure what you mean here. I can think of nothing obvious to streamline what you already have.

5. In Quest, all variables* have to be associated with a thing; they belong to that thing. When the player saves the game, all Quest does in save the game thing (I think), but as that has all the other things attached, they all get saved too, and as all variable belong to things, they all get saved too (it all comes from the "object-orientated" paradigm).

*Actually, not quite all, local variables (like roll in your own code) do not, but they only last for a moment while that script is being run.

starmoxas
08 Oct 2012, 18:09
Well thank you for your advice and I attempted to use it.

For point one I did set a turn script but the system didn't recognize the variable Mana_Max or Stamina_Max. I had to set an attribute called StaminaMax and ManaMax and did the following
<turnscript name="Max Health Mana">
<enabled />
<script><![CDATA[
if (player.Mana > player.MaxMana) {
player.Mana = player.MaxMana
}
if (player.Stamina > player.MaxStamina) {
player.Stamina = player.MaxStamina
}

Do you think that this code system would be adequate.

Next for point two does this only work for print message scripts? I'm trying to follow your advice for room descriptions but it only shows " + game.class +" do I have to set a attribute called class before I can use this trick or am I typing the code incorrectly?

Thank you for your assistance

The Pixie
08 Oct 2012, 21:21
Point 1: looks good

Point 2: You will have to set your room description to be a script rather than text, and in the script print an expression. The variable player.class does need to be set before hand, as I said, when the selection is made.

starmoxas
08 Oct 2012, 23:05
Ah yes now I'm coding in healing potions (after all it's no fun if a player dies too quickly), I have made an object let us call it "potion" and now wonder where should I put it? Should this object be put under the "game" object because it isn't for a particular location. Also I would like for this object to disappear when it is used by the player. Do objects that are of a nature to be used vanish from the inventory automatically or do I need to code for this event?

sgreig
09 Oct 2012, 04:51
starmoxas wrote:Ah yes now I'm coding in healing potions (after all it's no fun if a player dies too quickly), I have made an object let us call it "potion" and now wonder where should I put it? Should this object be put under the "game" object because it isn't for a particular location. Also I would like for this object to disappear when it is used by the player. Do objects that are of a nature to be used vanish from the inventory automatically or do I need to code for this event?


Put the object wherever you'd like the player to get it. There are lots of ways you can tackle this. You could simply have one potion that gets reused throughout the game, and could simulate multiple potions by giving it a "uses" attribute that increments by 1 every time you "pick up" a health potion, and subtracts 1 every time it's used and then move out of the player's inventory when it's all used up.

Or you could create a "master" healing potion item and clone it wherever you want to have the player be able to pick it up, and remove them from the player's inventory when they've been used up.

Those are just a couple of examples. I'm sure there are other ways this could be addressed as well. Hope that helps!

starmoxas
19 Oct 2012, 17:29
Hm I'm trying to depict a number of stamina points being healed via this code
msg ("You healed  " +game.roll+ " stamina.")
But it doesn't show in the print message line.

The Pixie
19 Oct 2012, 18:53
Looks okay. Could you upload the whole game file for us?

starmoxas
21 Oct 2012, 21:29
Well here it is, the link should be www.textadventure.co.uk/review/790
The final version will likely be not E for everyone,so are there regulations for that? I checked but couldn't find any information.

jaynabonne
21 Oct 2012, 22:59
The link is actually: www.textadventures.co.uk/review/790

The line of code you asked about isn't what you showed. The line in the file is:

       msg ("You healed  ' +game.roll+ ' stamina.")


You have single quotes internally. If you change it to what you have in the original question (with double quotes), you'll get a better result.

        msg ("You healed  " +game.roll+ " stamina.")


(Note: For any future uploads, it will be easier if you attach the aslx file here instead of publishing and uploading it. If we have to go into the quest file, the source is not what you are looking at, which can make it a bit harder to work through.)

starmoxas
21 Oct 2012, 23:39
Oh well in truth I switched to single quotes because double quotes were not working. I'll try again and see though. Remind me it is " then space and the +'s have to stick to the variable in question then another space and the "
So the end result being " +game.roll+ " instead of " + game.roll + "?

jaynabonne
22 Oct 2012, 09:23
Actually, outside the quotes, spaces don't matter. So it could be

"+game.roll+"

or

" +game.roll+ "

or

" + game.roll+"

or any variant of that. Spaces inside quotes affect your output, as they are printed literally. If the double quotes still don't work, let us know. And attach your game file here. :)