[SOLVED] How to count ammunition.

Passerine
I am VERY new to Quest and have been trying for the past hour how to count ammunition. I want the player to pick up a shotgun and 3 shells, but have absolutely no idea how to count the shells. I'll attach my game file if that helps at all. I haven't done any coding in a long time so I was hoping that I could do it without having to code but if I have to I will try to re-learn.

Marzipan
To begin with, I'm assuming it's not so much that you want three shells, as you want to be able to load the gun and have three shots?

Passerine
Marzipan wrote:To begin with, I'm assuming it's not so much that you want three shells, as you want to be able to load the gun and have three shots?

Yes that is correct. If it makes it easier, the shotgun doesn't have to "load" but just required to shoot.

HegemonKhan
first: Learning~Understanding Attributes

We want to use a 'bullet~capacity~magazine~etc' Integer Attribute (logical 'bullets~capacity~mag~etc' ) which we can then adjust, instead of actual 'bullet~mags~etc' Objects that we're moving from one Object to another Object.

Attribute Creation Only:

'gun~whatever' (Object) -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: gun~whatever)
Attribute Name: maximum_capacity
Attribute Type: integer (int)
Attribute Value: (you decide)

'gun~whatever' (Object) -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: gun~whatever)
Attribute Name: current_capacity
Attribute Type: integer (int)
Attribute Value: (you decide)

'gun~whatever' (Object) -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: gun~whatever)
Attribute Name: physical_damage
Attribute Type: integer (int)
Attribute Value: (you decide)

in code (tags: physical existence), it looks like this (examples):

<object name="rifle_gun_1">
<inherit name="editor_object" />
<alias>rifle</alias>
<attr name="maximum_capacity" type="int">50</attr>
<attr name="current_capacity" type="int">50</attr>
<attr name="physical_damage" type="int">100</attr>
</object>

<object name="machine_gun_1">
<inherit name="editor_object" />
<alias>machine gun</alias>
<attr name="maximum_capacity" type="int">500</attr>
<attr name="current_capacity" type="int">500</attr>
<attr name="physical_damage" type="int">50</attr>
</object>


Attribute Creation and~or Alteration (scripting: Object's Verbs, Object's 'Script' Attributes, Commands, Functions, Turnscripts, Timers, etc):

run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> (see 'in code' below)

in code (scripting: actions), it looks like this (examples):

rifle_gun_1.maximum_capacity = 50
rifle_gun_1.current_capacity = 50
rifle_gun_1.physical_damage = 100

machine_gun_1.maximum_capacity = 500
machine_gun_1.current_capacity = 500
machine_gun_1.physical_damage = 50


--------------------------

Basic Math Computation Equations:

run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> (see 'in code' below)

in code:

Object_name.Attribute_name = Value_or_Expression

Addition (examples):

player.strength = player.strength + 5
player.damage = player.strength + player.endurance

Subtraction (examples):

player.strength = player.strength - 5
player.endurance = player.damage - player.strength

Multiplication (examples):

player.strength = player.strength * 2

Division (examples):

player.strength = player.strength / 4

--------

Buying (example):

player.cash = player.cash - hat.cash
shop_owner.cash = shop_owner.cash + hat.cash
hat.parent = player

Selling (example):

player.cash = player.cash + hat.cash
shop_owner.cash = shop_owner.cash - hat.cash
hat.parent = shop_owner

------

this was a quick brief help, using both GUI~Editor + Code, so please ask if you got questions... I'm tired now, I'll get into the other aspects needed for your bullet feature in your game, but let's get down these basics first.

Marzipan
Hegemon, stop it, you're going to scare them off! :P

Passerine, I took your file and fooled around with it awhile and this is what I came up with:

Specifically I stuck a target in the room with a 'shoot' verb attached, and added the ability to load the gun after checking if the player was holding both it and the shells. You can examine the gun as you go to see how much ammo is left.

If you have any specific questions about what I did let me know, but I'm off to bed now so it'll be a little while before I can answer.

Passerine
HegemonKhan wrote:first: Learning~Understanding Attributes

We want to use a 'bullet~capacity~magazine~etc' Integer Attribute (logical 'bullets~capacity~mag~etc' ) which we can then adjust, instead of actual 'bullet~mags~etc' Objects that we're moving from one Object to another Object.

Attribute Creation Only:

'gun~whatever' (Object) -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: gun~whatever)
Attribute Name: maximum_capacity
Attribute Type: integer (int)
Attribute Value: (you decide)

'gun~whatever' (Object) -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: gun~whatever)
Attribute Name: current_capacity
Attribute Type: integer (int)
Attribute Value: (you decide)

'gun~whatever' (Object) -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: gun~whatever)
Attribute Name: physical_damage
Attribute Type: integer (int)
Attribute Value: (you decide)

in code (tags: physical existence), it looks like this (examples):

<object name="rifle_gun_1">
<inherit name="editor_object" />
<alias>rifle</alias>
<attr name="maximum_capacity" type="int">50</attr>
<attr name="current_capacity" type="int">50</attr>
<attr name="physical_damage" type="int">100</attr>
</object>

<object name="machine_gun_1">
<inherit name="editor_object" />
<alias>machine gun</alias>
<attr name="maximum_capacity" type="int">500</attr>
<attr name="current_capacity" type="int">500</attr>
<attr name="physical_damage" type="int">50</attr>
</object>

Attribute Creation and~or Alteration (scripting: Object's Verbs, Object's 'Script' Attributes, Commands, Functions, Turnscripts, Timers, etc):

run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> (see 'in code' below)

in code (scripting: actions), it looks like this (examples):

[code]rifle_gun_1.maximum_capacity = 50
rifle_gun_1.current_capacity = 50
rifle_gun_1.physical_damage = 100

machine_gun_1.maximum_capacity = 500
machine_gun_1.current_capacity = 500
machine_gun_1.physical_damage = 50


--------------------------

Basic Math Computation Equations:

run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> (see 'in code' below)

in code:

Object_name.Attribute_name = Value_or_Expression

Addition (examples):

player.strength = player.strength + 5
player.damage = player.strength + player.endurance

Subtraction (examples):

player.strength = player.strength - 5
player.endurance = player.damage - player.strength

Multiplication (examples):

player.strength = player.strength * 2

Division (examples):

player.strength = player.strength / 4

--------

Buying (example):

player.cash = player.cash - hat.cash
shop_owner.cash = shop_owner.cash + hat.cash
hat.parent = player

Selling (example):

player.cash = player.cash + hat.cash
shop_owner.cash = shop_owner.cash - hat.cash
hat.parent = shop_owner

------

this was a quick brief help, using both GUI~Editor + Code, so please ask if you got questions... I'm tired now, I'll get into the other aspects needed for your bullet feature in your game, but let's get down these basics first.


Wow! Needless to say I was not expecting someone to put that much work into helping me and I greatly appreciate your help! You and Marzipan both really helped me out. Thank you!

Passerine
Marzipan wrote:Hegemon, stop it, you're going to scare them off! :P

Passerine, I took your file and fooled around with it awhile and this is what I came up with: shotgun_test.aslx

Specifically I stuck a target in the room with a 'shoot' verb attached, and added the ability to load the gun after checking if the player was holding both it and the shells. You can examine the gun as you go to see how much ammo is left.

If you have any specific questions about what I did let me know, but I'm off to bed now so it'll be a little while before I can answer.


I'm actually really glad both of you posted :D ! You provided me with a ready-to-go example and Hegemon provided me with the intricacies of it! Both of you are awesome! Thank you!

Edit: To add to my post, I had no idea you could put If statements in the descriptions! That clears some things up! It's even right on the side and I didn't see it.

HegemonKhan
if, you're ready (if you're understanding Attributes fully), we can move onto the other main Script:

the 'if' Script

run as script -> add a~new script -> scripts -> 'if' Script -> (choose the drop down box choice you need, or choose, [EXPRESSION]:see below)

by choosing [EXPRESSION], you type in your own code line, (which is just the Attribute line: run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> Object_name.Attribute_name = Value_or_Expression), see below:

Object_name.Attribute_name (operator: =, <, >, >=, <=, not equals: <> or not xxx = xxx) Value_or_Expression

so, with the 'if [EXPRESSION]' script, now we're NOT stuck with just the '=' (equal) sign, (like we are with the 'set a variable or attribute' Script), thus allowing us to do conditionals (examples, in code below):

if (player.strength_integer = 100) {
player.strength_string = "powerful"
} else if (player.strength_integer < 100 and player.strength_integer > 50) {
player.strength_string = "strong"
} else if (player.strength_integer = 50) {
player.strength_string = "average"
} else if (player.strength_integer < 50 and player.strength_integer > 0) {
player.strength_string = "weak"
} else {
player.strength_string = "puny"
}

if (orc.dead_boolean = true) {
msg ("The orc is already dead, silly.")
} else if (orc.dead_boolean = false) {
orc.dead_boolean = true
msg ("You attack and kill the orc.")
}

etc etc etc 'if' script blocks


---------

these two SUPER Scripts (the 'if [EXPRESSION]' and 'set a variable or attribute' scripts), especially when used together, let's you do 90% of everything that you want to do in your game.

-------

yes, we've got the text processor now:

http://docs.textadventures.co.uk/quest/ ... essor.html

(I still haven't learned to use it yet though... I will at some point...)

enjoy :D

---------

P.S.

in quest, there's no separation of '=' (math equals) and '==' (assignment~definition setting), there's only '=', which does both functionalities (the quest engine handles this for you).

(hopefully, I don't have the symbols backwards, lol. I've only worked with Quest's code, so I'm not really familiar with most other codes that use the double equal signs)

flesh420
How exactly do I get the pistol description to show the amount of ammo left?

Silver
I don't understand what you're asking. The text processor scripts above just output specific text if certain conditions are met. So if the gun has five bullets in it, the {if object.attribute=?:text} script will spit something out accordingly.

I would also place all those codes on the same line, otherwise it will create new lines in the game I think so it would look something like this for one bullet:

>examine pistol




One shot left. Better make it count.

Because it's counting the line breaks between the other scripts that it doesn't print.

Silver
flesh420 wrote:How exactly do I get the pistol description to show the amount of ammo left?


Agghh, you edited which now makes my reply look weird. :twisted:

flesh420
Lol sorry. That doesn't work in the pistol description, instead it just displays the code. I keep running into this problem where it should be doing something, I follow everything to a T, but it just doesn't work.

And this is another example of that problem: This isn't subtracting ammo: msg ("You shot the pistol." + Pistol.pisammo + " left. ")
Pistol.pisammo = Pistol.pisammo-1
It should be subtracting one, right? I've successfully added ammo, but it won't subtract ammo from the Pistol.pisammo after I use it once.

Silver
Could you upload an example game with the error at all? Although you will probably need someone else to help with the code; I know about the text processor but haven't worked with atrribute values yet.

flesh420
The file:
Edit: I fixed the description and subtracting problem.

The Pixie
There are a few issues...

The check verb for pistol has this script:
msg ("pisammo !")

That is just going to print the message: "pisammo !" You need something like this:
msg ("The pistol has " + Pistol.pisammo + " bullets.")

The bits in quotes will appear as written, while Pistol.pisammo will get replaced by the value of Pistol.pisammo.

For the description you have:
{if Pistol.pisammo=?:text} 

Try this instead:
Just an ordinary pistol. {if Pistol.pisammo=0:It is empty.}


I appreciate you may not have got to this bit yet, but you cannot shoot the pistol (no shoot verb), the pistol will get 3 new bullets each time the clip is picked up, or at least that would happen if you could drop the clip.

flesh420
Ok thank you. I scrapped all that because it was too confusing, so I made a new simple pistol test. Now my problem is that it doesn't seem to add ammo and I can't figure out why. Could you point me to what's wrong please? Lol sorry if this is annoying.

HegemonKhan
General~base syntax structure for an Attribute:

Object_name.Attribute_name = Value_or_Expression

Setting an Attribute:

Creation and~or Alteration (scripting: Verbs, Script Attributes of an Object, Commands, Functions, Turnscripts, Timers, etc):

in the GUI~Editor:

run as script -> add new~a script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> Object_name.Attribute_name = Value_or_Expression

in code:

Object_name.Attribute_name = Value_or_Expression

OR, the:

'set' Script ( http://docs.textadventures.co.uk/quest/scripts/set.html )

Creation ONLY (GUI~Editor only):

'whatever' Object -> Attributes (Tab) -> Attributes -> Add -> (see below)

(Object Name: 'whatever' )
Attribute Name: whatever
Attribute Type: (String, Integer, Double, Boolean, Script, List, Dictionary, Inherited, etc)
Attribute Value (or Expression): whatever (but depends upon its Attribute Type)

examples:

Addition:

player.strength = player.strength + 5
~OR~
player.strength = player.strength + player.endurance
~OR~
player.strength = player.agility + player.endurance
~OR~
player.strength = player.agility + player.endurance + 8
~OR~
etc etc etc

conceptually:

player.strength = 0
player.strength = player.strength + 3

Original~Initial (old) value: player.strength = 0

player.strength (new) = player.strength (old:0) + 3
player.strength (new) = 0 + 3 = 3

new value: player.strength = 3

old value: player.strength = 3

player.strength (new) = player.strength (old:3) + 3
player.strength (new) = 3 + 3 = 6

new value: player.strength = 6

old value: player.strength = 6

player.strength (new) = player.strength (old:6) + 3
player.strength (new) = 6 + 3 = 9

new value: player.strength = 9

old value: ...9...
etc etc etc

Subtraction:

player.strength = player.strength - 9

Multiplication:

player.strength = player.strength * 3

Division:

player.strength = player.strength / 2

----------------

examples:

Buying:

hat.parent = store_owner

player.cash = player.cash - hat.cash
store_owner.cash = store_owner.cash + hat.cash
hat.parent = player

// the 'hat' Object starts in the 'store_owner' Object's possession, then goes to the 'player' Player Object's possession

Selling:

hat.parent = player

player.cash = player.cash + hat.cash
store_owner.cash = store_owner.cash - hat.cash
hat.parent = store_owner

// the 'hat' Object starts in the 'player' Player Object's possession, then goes to the 'store_owner' Object's possession

The Pixie
flesh420 wrote:Ok thank you. I scrapped all that because it was too confusing, so I made a new simple pistol test. Now my problem is that it doesn't seem to add ammo and I can't figure out why. Could you point me to what's wrong please? Lol sorry if this is annoying.

Probably going to kick yourself here... The problem is that when shooting you test:
if (pistol.ammo = 1) {

When you pick up a clip, however, pistol.ammo = 5, so you still cannot shoot the gun. What you need is this:
if (pistol.ammo > 0) {

By the way, I would suggest the clip is destroyed after picking up, rather than moving to the player's inventory.

flesh420
Lol yea. Thanks guys, it took me a while to finally understand the logic of coding. I figured out the clip removal after I posted. I created a status attribute for ammo but can't find any information on how to code it to display the ammo amount the player has, can anyone point me in the right direction? And one last thing, is there a list of the commands I can use for expressions? Example pistol.ammo>0. I can't find any info on those either other than the examples in the tutorial.

Silver
You were on the right path with the text processor commands you were using. But all the background stuff has to be in place. Not sure why it displayed the code though. What The Pixie says is right though.

HegemonKhan
Hopfully, these Game files will work with quest version '560', you may need to change or re-generate the 'gameid' String Attribute, anyways, here's the coding and game files:

All about using 'Status Attributes' (special String Dictionary Attributes, which only work with~for~within the special 'game' Game Object and Player Objects, such as the default 'player' Player Object, as the 'Status Attributes' is quest's built-in method of merely the *displayment* of already existing~created stats~attributes on the right pane, which is again only for your Game Object and Player Objects):

(there's tons of methods for displaying stats~attributes, this is just the built-in method for displaying certain Objects', the Game Object and Player Objects, stats~attributes on~in the right pane)

<asl version="560">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff 1">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
msg ("- " + result)
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender_x = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + " " + player.gender_x + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_player" />
<inherit name="editor_object" />
<alias_x type="string"></alias_x>
<gender_x type="string"></gender_x>
<strength type="int">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="simplestringdictionary">alias = Name: !;gender_x = Gender: !;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>potexp100</alias>
<take />
<displayverbs type="simplestringlist">Look at; Take; Drink</displayverbs>
<inventoryverbs type="simplestringlist">Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>potexp300</alias>
<take />
<displayverbs type="simplestringlist">Look at; Take; Drink</displayverbs>
<inventoryverbs type="simplestringlist">Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
player.experience = player.experience + 300
</drink>
</object>
</object>
<turnscript name="global_events_turnscript">
<enabled />
<script>
leveling_function
game.turns = game.turns + 1
</script>
</turnscript>
<function name="leveling_function"><![CDATA[
if (player.experience >= player.level * 100 + 100) {
player.experience = player.experience - (player.level * 100 + 100)
player.level = player.level + 1
switch (player.gender_x) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
}
case ("elf") {
player.agility = player.intelligence + 2
}
case ("human") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
leveling_function
}
]]></function>
</asl>


<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff 2">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns =</statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<curhp type="int">250</curhp>
<maxhp type="int">500</maxhp>
<current_hit_points type="int">999</current_hit_points>
<maximum_hit_points type="int">999</maximum_hit_points>
<maxhp type="int">500</maxhp>
<hp type="string">0/0</hp>
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<agility type="int">100</agility>
<hit_points type="string">0/0</hit_points>
<statusattributes type="simplestringdictionary">hp = ;hit_points =!;strength =;endurance = !;agility = Your agility is !</statusattributes>
</object>
</object>
<turnscript name="turns_turnscript">
<enabled />
<script>
player.hp = player.curhp + "/" + player.maxhp
player.hit_points = "HP: " + player.current_hit_points + "/" + player.maximum_hit_points
game.turns = game.turns + 1
</script>
</turnscript>
</asl>


<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff 3">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<game_is_paused type="boolean">false</game_is_paused>
<game_turns type="int">0</game_turns>
<point_score type="int">0</point_score>
<statusattributes type="simplestringdictionary">game_turns =;game_is_paused =;point_score =</statusattributes>
<start type="script">
msg ("NOTE: Type in something in the command box and hit enter on each turn, to see the attributes being changed.")
msg ("")
</start>
</game>
<function name="show_attributes_function">
msg ("")
msg ("Player's Attributes:")
msg ("")
msg ("Flying: " + player.flying)
msg ("Player Turns: " + player.player_turns)
msg ("")
msg ("Game's Attributes:")
msg ("")
msg ("Game Is Paused: " + game.game_is_paused)
msg ("Game Turns: " + game.game_turns)
msg ("Point Score: " + game.point_score)
msg ("")
msg ("Global Data Object's Attributes:")
msg ("")
msg ("Dragon Slayer Sword Acquired: " + global_data_object.dragon_slayer_sword_acquired)
msg ("Dragon Killed: " + global_data_object.dragon_killed)
msg ("Princess Rescued: " + global_data_object.princess_rescued)
msg ("")
msg ("Turnscript's Scripting Steps's Changed Attributes' Results:")
msg ("")
</function>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<flying type="boolean">false</flying>
<player_turns type="int">0</player_turns>
<statusattributes type="simplestringdictionary">player_turns =;flying =</statusattributes>
</object>
</object>
<object name="global_data_object">
<inherit name="editor_object" />
<dragon_killed type="boolean">false</dragon_killed>
<princess_rescued type="boolean">false</princess_rescued>
<dragon_slayer_sword_acquired type="boolean">false</dragon_slayer_sword_acquired>
</object>
<turnscript name="global_events_turnscript">
<enabled />
<script>
show_attributes_function
if (player.flying=false) {
player.flying=true
} else if (player.flying=true) {
player.flying=false
}
if (game.game_is_paused=false) {
game.game_is_paused=true
} else if (game.game_is_paused=true) {
game.game_is_paused=false
}
if (global_data_object.dragon_slayer_sword_acquired=false) {
global_data_object.dragon_slayer_sword_acquired=true
game.point_score = game.point_score + 50
msg ("dragon_slayer_sword_acquired: " + global_data_object.dragon_slayer_sword_acquired)
msg ("Point Score: " + game.point_score)
if (global_data_object.princess_rescued=true) {
global_data_object.princess_rescued=false
msg ("Princess Rescued: " + global_data_object.princess_rescued)
}
}
if (global_data_object.dragon_slayer_sword_acquired=true) {
global_data_object.dragon_killed=true
game.point_score = game.point_score + 250
global_data_object.dragon_slayer_sword_acquired=false
msg ("Dragon Killed: " + global_data_object.dragon_killed)
msg ("Point Score: " + game.point_score)
msg ("dragon_slayer_sword_acquired: " + global_data_object.dragon_slayer_sword_acquired)
}
if (global_data_object.dragon_killed=true) {
global_data_object.princess_rescued=true
game.point_score = game.point_score + 400
global_data_object.dragon_killed=false
msg ("Princess Rescued: " + global_data_object.princess_rescued)
msg ("Point Score: " + game.point_score)
msg ("Dragon Killed: " + global_data_object.dragon_killed)
}
game.game_turns = game.game_turns + 1
player.player_turns = player.player_turns + 5
</script>
</turnscript>
</asl>

HegemonKhan
flesh wrote:And one last thing, is there a list of the commands I can use for expressions? Example pistol.ammo>0. I can't find any info on those either other than the examples in the tutorial.


I'm not quite sure what you're asking for, as the terminology is a bit ambigious (and you're still learning quest and thus its concepts+terminolgy, too)...

if you want to see all the built-in stuff:

on the left side (the 'tree of stuff' ), at the bottom left is 'Filter', click on it, then a popupbox will appear and click on that, it's a toggle~boolean (on~off) box for 'Show Library Elements', which is all of the default stuff that makes up quest. when you check this box on, all the default stuff will be in light grey text above (on the left pane, the 'tree of stuff' ), and you can edit it too (via copy on the upper right side, after you click on something in the left side's 'tree of stuff' ), but you got to know what you're doing, as often this is global stuff as well as being quest's underlying code, so you could ruin the game that you're trying to work on (the quest software itself is fine as due to the forcing of you to use that 'copy' button, hehe).

---------

if you want to know how to use COMMANDS ( http://docs.textadventures.co.uk/quest/ ... mmand.html ), they're really open-ended (powerful) Verbs:

conceptually this is how COMMANDS work:

within~for its 'pattern' box, this is the input that quest will use to activate this Command, and it has two parts:

the command input:

kick
punch
kiss
take
drop
etc

than, the thing involved:

examples:

kick #object#
~OR~
kick #text#

I type in during game play:

kick ball

'kick' tells quest to do that specific Command that we set up for it via the Command's 'pattern' box

then quest goes: okay... now what?

oh, okay, 'ball', (depends on whether you used #object# or #text# ), quest takes the 'ball' and uses it in~for the Command's scripting (Scripts), which you also already added into the Command already.

that's how Commands work conceptually in a very brief way... let me know if this helps or not (with just understanding the conception of Commands).

(actually implementing a Command properly is something else that we'll get to doing later)

--------

if you mean, what can be done with [EXPRESSIONS], pretty much ANYTHING... (you just have to know how to code it in, of course)

all~most math expressions~formulas~operations is possible, as well as String~textual expressions, and etc

you can take a look at this code (if you can ~ if it's too scary, then ignore it, hehe):

(it's my initial, ugly~poor quality, combat code, and sorry about all the abrevs... I've learned not to use them anymore, laughs. Anyways, this shows a good sample of what you can do with [EXPRESSIONS], but there's so much more too)

<asl version="530">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Testing Game Stuff">
    <gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
    <version>1.0</version>
    <pov type="object">player</pov>
    <start type="script">
      cc
    </start>
    <turns type="int">0</turns>
    <statusattributes type="stringdictionary">turns = </statusattributes>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="defaultplayer" />
      <inherit name="pc" />
      <cur_hp type="int">999</cur_hp>
      <max_hp type="int">999</max_hp>
      <str type="int">100</str>
      <end type="int">100</end>
      <dex type="int">100</dex>
      <agi type="int">100</agi>
      <spd type="int">100</spd>
      <hc type="int">100</hc>
      <pd type="int">100</pd>
      <pr type="int">100</pr>
    </object>
    <object name="orc1">
      <inherit name="editor_object" />
      <inherit name="npc" />
      <hostile type="boolean">true</hostile>
      <dead type="boolean">false</dead>
      <alias>orc</alias>
      <cur_hp type="int">999</cur_hp>
      <max_hp type="int">999</max_hp>
      <str type="int">25</str>
      <end type="int">25</end>
      <dex type="int">25</dex>
      <agi type="int">25</agi>
      <spd type="int">25</spd>
      <hc type="int">25</hc>
      <pd type="int">25</pd>
      <pr type="int">25</pr>
    </object>
  </object>
  <turnscript name="game_turns">
    <enabled />
    <script>
      sa
      game.turns = game.turns + 1
    </script>
  </turnscript>
  <command name="fight">
    <pattern>fight #text#</pattern>
    <script>
      battle_system (game.pov,text)
    </script>
  </command>
  <type name="char">
    <cur_hp type="int">0</cur_hp>
    <drop type="boolean">false</drop>
    <defending type="boolean">false</defending>
    <max_hp type="int">0</max_hp>
    <str type="int">0</str>
    <end type="int">0</end>
    <dex type="int">0</dex>
    <agi type="int">0</agi>
    <spd type="int">0</spd>
    <hp type="int">0</hp>
    <hc type="int">0</hc>
    <pd type="int">0</pd>
    <pr type="int">0</pr>
  </type>
  <type name="pc">
    <inherit name="char" />
    <statusattributes type="stringdictionary">hp = ;str = ;end = ;dex = ;agi = ;spd = ;hc = ;pd = ;pr = </statusattributes>
  </type>
  <type name="npc">
    <inherit name="char" />
    <dead type="boolean">false</dead>
    <hostile type="boolean">false</hostile>
    <displayverbs type="list">Look at; Talk; Fight</displayverbs>
  </type>
  <function name="cc">
    msg ("What is your name?")
    get input {
      game.pov.alias = result
      msg (" - " + game.pov.alias)
      show menu ("What is your gender?", split ("male;female" , ";"), false) {
        game.pov.gender = result
        show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
          game.pov.race = result
          show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
            game.pov.class = result
            msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
            wait {
              ClearScreen
            }
          }
        }
      }
    }
  </function>
  <function name="sa">
    game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
  </function>
  <function name="battle_system" parameters="self,text" type="boolean">
    first_value = false
    enemy = GetObject (text)
    if (enemy = null) {
      foreach (obj,AllObjects()) {
        if (obj.alias=text) {
          enemy = obj
        }
      }
    }
    if (enemy = null) {
      msg ("There is no " + text + " here.")
      first_value = false
    }
    else if (not Doesinherit (enemy,"npc")) {
      msg ("You can not battle that!")
      first_value = false
    }
    else if (not npc_reachable (enemy)) {
      msg ("There is no " + enemy.alias + " in your vicinity.")
      first_value = false
    }
    else if (GetBoolean (enemy,"dead") = true) {
      msg (enemy.alias + " is already dead.")
      first_value = false
    }
    else if (GetBoolean (enemy,"hostile") = false) {
      msg (enemy.alias + " is not hostile.")
      first_value = false
    }
    else if (battle_sequence (self,enemy) = true) {
      msg ("The battle is over.")
      first_value = true
    }
    return (first_value)
  </function>
  <function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
    second_value = false
    if (enemy.dead = false) {
      if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
        on ready {
          msg ("You get to go first for this round")
          if (self_battle_turn (self,enemy) = true) {
            battle_sequence (self,enemy)
          }
        }
        on ready {
          if (enemy.dead = false) {
            if (enemy_battle_turn (self,enemy) = true) {
              msg ("The round has ended.")
            }
          }
        }
        on ready {
          battle_sequence (self,enemy)
        }
      }
      else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
        on ready {
          msg (enemy.alias + " gets to go first for this round.")
          if (enemy_battle_turn (self,enemy) = true) {
            msg ("It is now your turn.")
          }
        }
        on ready {
          if (self_battle_turn (self,enemy) = true) {
            battle_sequence (self,enemy)
          }
          else {
            msg ("The round has ended.")
          }
        }
        on ready {
          battle_sequence (self,enemy)
        }
      }
      else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
        if (RandomChance (50) = true) {
          on ready {
            msg ("You get to go first for this round")
            if (self_battle_turn (self,enemy) = true) {
              battle_sequence (self,enemy)
            }
          }
          on ready {
            if (enemy_battle_turn (self,enemy) = true) {
              msg ("The round has ended.")
            }
          }
          on ready {
            battle_sequence (self,enemy)
          }
        }
        else {
          on ready {
            msg (enemy.alias + " gets to go first for this round.")
            if (enemy_battle_turn (self,enemy) = true) {
              msg ("It is now your turn.")
            }
          }
          on ready {
            if (self_battle_turn (self,enemy) = true) {
              battle_sequence (self,enemy)
            }
            else {
              msg ("The round has ended.")
            }
          }
          on ready {
            battle_sequence (self,enemy)
          }
        }
      }
    }
    else {
      second_value = true
    }
    return (second_value)
  ]]></function>
  <function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
    third_value = false
    msg (self.alias + " has " + self.cur_hp + " HP left.")
    msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
    wait {
      show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
        switch (result) {
          case ("Attack") {
            fourth_value = false
            if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
              msg (enemy.alias + "evaded your attack!")
              fourth_value = true
            }
            else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
              msg (enemy.alias + "parried your attack!")
              fourth_value = true
            }
            else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
              msg (enemy.alias + "blocked your attack!")
              fourth_value = true
            }
            else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
              msg ("Your attack missed " + enemy.alias +"!")
              fourth_value = true
            }
            else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
              msg ("Your attack got resisted by " + enemy.alias +"!")
              fourth_value = true
            }
            else if (fourth_value = false) {
              if (self.defending = true and enemy.defending = true) {
                enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
                self.defending = false
              }
              else if (self.defending = true and enemy.defending = false) {
                enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
                self.defending = false
              }
              else if (self.defending = false and enemy.defending = true) {
                enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
              }
              else if (self.defending = false and enemy.defending = false) {
                enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
              }
            }
          }
          case ("Defend") {
            if (self.defending = false) {
              self.defending = true
            }
          }
          case ("Cast") {
            self.defending = false
          }
          case ("Item") {
            self.defending = false
          }
          case ("Run") {
            self.defending = false
          }
        }
        if (GetInt (enemy,"cur_hp") > 0) {
          if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
            msg ("You get an extra battle turn!")
            self_battle_turn (self,enemy)
          }
          else {
            msg ("Your battle turn is over.")
            third_value = false
          }
        }
        else if (GetInt (enemy,"cur_hp") <= 0) {
          msg (enemy.alias + " is dead.")
          msg ("You have won the battle!")
          enemy.defending = false
          enemy.dead = true
          third_value = true
          wait {
            ClearScreen
          }
        }
      }
    }
    return (third_value)
  ]]></function>
  <function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
    fifth_value = false
    msg (self.alias + " has " + self.cur_hp + " HP left.")
    msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
    result = GetRandomInt (1,3)
    switch (result) {
      case (1) {
        sixth_value = false
        if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
          msg ("You have evaded the attack!")
          sixth_value = true
        }
        else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
          msg ("You have parried the attack!")
          sixth_value = true
        }
        else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
          msg ("You have blocked the attack!")
          sixth_value = true
        }
        else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
          msg (enemy.alias +"'s attack missed!")
          sixth_value = true
        }
        else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
          msg ("You resisted the attack!")
          sixth_value = true
        }
        else if (sixth_value = false) {
          if (enemy.defending = true and self.defending = true) {
            self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
            msg (self.alias + " has " + self.cur_hp + " HP left.")
            enemy.defending = false
          }
          else if (enemy.defending = true and self.defending = false) {
            self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
            msg (self.alias + " has " + self.cur_hp + " HP left.")
            enemy.defending = false
          }
          else if (enemy.defending = false and self.defending = true) {
            self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
            msg (self.alias + " has " + self.cur_hp + " HP left.")
          }
          else if (enemy.defending = false and self.defending = false) {
            self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
            msg (self.alias + " has " + self.cur_hp + " HP left.")
          }
        }
      }
      case (2) {
        if (enemy.defending = false) {
          msg (enemy.alias + " has choosen to defend itself.")
          enemy.defending = true
        }
      }
      case (3) {
        enemy.defending = false
        msg ("Cast")
      }
    }
    if (GetInt (self,"cur_hp") > 0) {
      if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
        msg (enemy.alias + " gets an extra battle turn!")
        wait {
          enemy_battle_turn (self,enemy)
        }
      }
      else {
        msg (enemy.alias + " 's battle turn is over.")
        fifth_value = true
      }
    }
    else if (GetInt (self,"cur_hp") <= 0) {
      msg (self.alias + " has died.")
      msg ("GAME OVER")
      finish
    }
    return (fifth_value)
  ]]></function>
  <function name="npc_reachable" parameters="object" type="boolean">
    value = false
    foreach (x,ScopeReachableNotHeld ()) {
      if (x=object) {
        value = true
      }
    }
    return (value)
  </function>
  <function name="crit_hit" parameters="object" type="int">
    if (RandomChance (GetInt (object,"luck")) = true) {
      value = 2
    }
    else {
      value = 1
    }
    return (value)
  </function>
</asl>


01. cc = character creation function
02. sa = status attributes (mainly for implementing/displaying of ' cur / max ' stats) function
03. char = character object type ("pcs", "npcs", "monsters", etc., so, not a room, item, equipment, spell, etc)
04. pc = playable character object type ("player" characters / game.povs)
05. npc = non-playable character ("people", "monsters", and etc, so not a "player" character / not a game.pov, I'm going to have a hostility system, so any npc can be friendly or hostile, instead of having an actual "monster/enemy" type set aside)
06. hp = hit points (life) stat attribute
07. mp = mana points (magic) stat attribute
08. str = strength (physical damage, carry weight / equipment requirement, etc) stat attribute
09. end = endurance (physical defense, and etc) stat attribute
10. dex = dexterity (weapon~attack skill, think of this as "if your attack connects or not, do you 'whiff' or not", so not to gete confused with hc, and etc) stat attribute
11. agi = agility (dodging/evading, and etc) stat attribute
12. spd = speed (who goes first in battle, extra battle turns, escaping from battle, and etc) stat attribute
13. hc = hit chance (think of this more as piercing their armor or not, so not to get confused with dex, and etc) stat attribute
14. pd = physical damage stat attribute
15. fp = fire damage stat attribute
16. wp = water damage stat attribute
17. ap = air damage stat attribute
18. ed = earth damage stat attribute
19. ld = light damage stat attribute
20. dd = dark damage stat attribute
21. pr = physical resistance stat attribute
22. fr = fire resistance stat attribute
23. wr = water resistance stat attribute
24. ar = air resistance stat attribute
25. er = earth resistance stat attribute
26. lr = light resistance stat attribute
27. dr = dark resistance stat attribute
28. defending = boolean (reduces damage done for that character and increases the damage done by that character, if they chosoe to attack on the next turn)
29. escaped = boolean, run from battle (not completed/implemented yet)
30. hostile = boolean, any npc can be friendly or a(n) "monster/enemy", based upon a hostility scale (0-100), but not completed
31. dead = boolean
32. crit_hit = critical hit (bonus damage based upon luck)
33. luck = luck stat attribute
34. lvl = level stat attribute
35. exp = experience stat attribute
36. cash = cash stat attribute (currency)
37. lvlup = level up function

jaynabonne
flesh420 wrote:And one last thing, is there a list of the commands I can use for expressions? Example pistol.ammo>0. I can't find any info on those either other than the examples in the tutorial.

Here is a posting I did a while ago listing the expression operators. It has a link to the FLEE documentation as well as some other ones I found by trial and error.

viewtopic.php?f=18&t=3595

flesh420
Wow guys this is crazy. I've coded a command for any weapon to be used on anything with health. One thing I don't quite understand though, is where exactly does the + come from and what does it mean when you put something like + object.health +? (or just maybe what does it mean?) And also the # in #object#? Does that make sense? I don't understand fully everything you guys are saying with some stuff but you guys helped a crap load and I thank you very much!

The Pixie
The + for strings (or strings and numbers) means they are concatenated.

"hello " + " world"
-> "hello world"

"health is " + 5
-> "health is 5"

"health is " + object.health + "."
-> "health is 5."

----------------------------

The #object# is a pattern to be matched by the command. Quest looks at what the player has typed, and tries to match against all the commands it knows, If one has the pattern "shoot #object#" then it will try to match the word shoot and any object in scope. If it does match, it will run the script for the command, putting the object into a variable called object.

HegemonKhan
<pattern>kick #object#</pattern>

you type in during game play:

kick ball

quest takes 'ball', and connects it (that's what the # symbols tell quest in the Command's 'Pattern' box) to the variable:

# (object <--> this is the variable) # = object (for the scripting, unless re-named through using Functions and their 'parameter' ~ this is a bit confusing so ignore for now) = ball

#object# = object = ball

or, I instead type in during game play:

kick bamboo

#object# = object = bamboo

<command name="kick_command">
<pattern>kick #object#</pattern>
<script>
if (object.name = "ball") {
msg ("HK kicks the ball, without hurting his foot.")
} else if (object.name = "bamboo") {
msg ("Ouch, my foot~shin is broken! I'm not a Muay Thai martial artist!)
}
</script>
</command>


OR

<command name="kick_command">
<pattern>kick #text#</pattern>
<script>
if (text = "ball") {
msg ("HK kicks the ball, without hurting his foot.")
} else if (text = "bamboo") {
msg ("Ouch, my foot~shin is broken! I'm not a Muay Thai martial artist!)
}
</script>
</command>


there's an issue ( 'pros and cons differences' ) with using both of either: #object# or #text#

but, we'll get to that later on, when you're trying to craft~write work with Commands in actual implementation of doing things. First, understand the concepts + basics of using Commands.

jaynabonne
The primary difference between #object# and #text# is that #text# will match any text at all, whereas #object# will only match an object that's actually in scope (e.g. in the current room or in your inventory). In the above examples, "kick ball" with #object# requires there to be an object named "ball" (name or alias) available. If not, Quest will respond with the "object not available" text for the command. Whereas using #text#, the command will succeed anywhere, whether there's a ball or not.

The Pixie
jaynabonne wrote:The primary difference between #object# and #text# is that #text# will match any text at all, whereas #object# will only match an object that's actually in scope (e.g. in the current room or in your inventory). In the above examples, "kick ball" with #object# requires there to be an object named "ball" (name or alias) available. If not, Quest will respond with the "object not available" text for the command. Whereas using #text#, the command will succeed anywhere, whether there's a ball or not.

And when it has done that, if you used #object#, there will be a variable called object that contains the ball object, and if you used #text# it will contain a string that is "ball".

Silver
jaynabonne wrote:The primary difference between #object# and #text# is that #text# will match any text at all, whereas #object# will only match an object that's actually in scope (e.g. in the current room or in your inventory). In the above examples, "kick ball" with #object# requires there to be an object named "ball" (name or alias) available. If not, Quest will respond with the "object not available" text for the command. Whereas using #text#, the command will succeed anywhere, whether there's a ball or not.


That's interesting and I'm now starting to understand why people favour commands over object verbs. Because people could try and kick anything and it could return an else of msg ("you can't kick that.") or whatever rather than the core msg ("Wtf are you on about?").

You'd need to be careful about the else though in case people tried kicking something that isn't in any description or could return an inaccurate response.

>kick icecream
>you kick it and bruise your toe.

The Pixie
Silver wrote:That's interesting and I'm now starting to understand why people favour commands over object verbs. Because people could try and kick anything and it could return an else of msg ("you can't kick that.") or whatever rather than the core msg ("Wtf are you on about?").

You'd need to be careful about the else though in case people tried kicking something that isn't in any description or could return an inaccurate response.

>kick icecream
>you kick it and bruise your toe.

Verbs have default messages that will "kick" in if the object does not have the specific verb attribute. The default default for KICK will be:
"You can't kick " + object.article + "."
However, you can change that in the verb object itself (as opposed to the verb attribute of your object).

Silver
Ah right. I've never looked at them although I can see where they are in the left panel.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums