Combat Starter Training Guide for Noobs by HK

HegemonKhan
Note: please feel free to add this to the wiki pages! Just credit~mention me if you do, please.

---------

if you want to work on combat, then try to do it slowly, through the Verb Tab's add a~new scripts:

here you go, a quality STEP BY STEP "noob-proof" GUI~Editor usage guide, lol

"room" (the default Room Object that contains your default "player" Player Object) -> Objects (Tab) -> Add ->

name: orc

orc -> Verb (Tab) -> Add ->

name: fight

box: RUN A SCRIPT (this allows us to add scripts, as you'll see the button for it show up upon changing to this setting)

let's start off trying something really simple:

(by the way, hopefully you understandd that my "->" arrows in the front~left side, mean indenting ~ "nesting" the script ~ make sure you click on the correct "add a~new script" I-think-circular button, lol. Correct indenting~"nesting" is a MUST !!!, or your series of scripts won't work correctly!!!)

it attacks you first doing damage to you and receiving a message of this act, and then you attack it for damage and receiving a message of this act

Add a~new script -> Variables -> Set an attribute or variable -> player.hit_points = player.hit_points - orc.physical_damage
Add a~new script -> Output -> Print a message -> Print [EXPRESSION] orc.alias + " hits " + player.alias + " for " + orc.physical_damage + " damage, leaving " + player.alias + " with only " + player.hit_points + " hitpoints remaining."
Add a~new script -> Variables -> Set an attribute or variable -> orc.hit_points = orc.hit_points - player.physical_damage
Add a~new script -> Output -> Print a message -> Print [EXPRESSION] player.alias + " hits " + orc.alias + " for " + player.physical_damage + " damage, leaving " + orc.alias + " with only " + orc.hit_points + " hitpoints remaining."

okay, we've added our scripts for our "orc" Object's "fight" Verb, but now we need our "player" and "orc" Objects to actually have the attributes that are used in our "orc" Object's "fight" Verb script~code block.

the Objects involved:

player
orc

and their Attributes needed:

hit_points
physical_damage
alias

player -> Attributes (Tab) -> Attributes -> Add ->

Name: hit_points
Type: int
Value: 999 // or whatever amount you want to start with

Name: physical_damage
Type: int
Value: 50 // or whatever amount you want to start with

player -> Setup (Tab) -> Alias -> onimike // or whatever you want, lol

player -> Attributes (Tab) -> Status Attributes -> Add -> // so they'll be displayed on the right side while playing the game

Name: hit_points
Value: (leave blank)

Name: physical_damage
Value: (leave blank)

orc -> Attributes (Tab) -> Attributes -> Add ->

Name: hit_points
Type: int
Value: 200 // or whatever amount you want it to have

Name: physical_damage
Type: int
Value: 10 // or whatever amount you want it to have

orc -> Setup (Tab) -> Alias -> kul'dan

goob job, but let's now try to do more now:

we need a reason for doing damage: killing the orc, or dying and losing the game, hehe. Also, let's have you get experience and cash for killing the orc too.

so back to our "orc" Object's "fight" Verb, we got to add in some new lines~scripts:

Add a~new script -> Scripts -> If... -> if [EXPRESSION] // or if [OBJECT DOES NOT HAVE FLAG] -> orc.dead = false // or Object: orc, [flag name]: dead
Then,
-> Add a~new script -> Variables -> Set an attribute or variable -> player.hit_points = player.hit_points - orc.physical_damage
-> Add a~new script -> Output -> Print a message -> Print [EXPRESSION] orc.alias + " hits " + player.alias + " for " + orc.physical_damage + " damage, leaving " + player.alias + " with only " + player.hit_points + " hitpoints remaining."
-> Add a~new script -> Scripts -> If... -> if [EXPRESSION] player.hit_points <= 0 // we can't do [OBJECT ATTRIBUTE EQUALS] as I don't think there's any way to add in the "equals and less than" operator for it. As we've only got the "equals" operator, so this won't work for us.
-> then,
->-> Add a~new script -> Game State -> Finish the game
-> else,
->-> Add a~new script -> Variables -> Set an attribute or variable -> orc.hit_points = orc.hit_points - player.physical_damage
->-> Add a~new script -> Output -> Print a message -> Print [EXPRESSION] player.alias + " hits " + orc.alias + " for " + player.physical_damage + " damage, leaving " + orc.alias + " with only " + orc.hit_points + " hitpoints remaining."
->-> Add a~new script -> Scripts -> If... -> if [EXPRESSION] orc.hit_points <= 0 // we can't do [OBJECT ATTRIBUTE EQUALS] as I don't think there's any way to add in the "equals and less than" operator for it. As we've only got the "equals" operator, so this won't work for us.
->-> then,
->->-> Add a~new script -> Variables -> Set an attribute or variable -> player.experience_points = player.experience_points + orc.experience_points
->->-> Add a~new script -> Variables -> Set an attribute or variable -> player.cash = player.cash + orc.cash
->->-> Add a~new script -> Variables -> Set a variable or attribute // or Set Object Flag -> orc.dead=true // or Object: orc, [flag name]: dead
->-> else,
->->-> Add a~new script -> Scripts -> Run an object's script attribute // I think this will loop~do this "fight" Verb again, but if not, then remove~delete this script line! -> run object [name] [orc] script attribute [name] fight, Using parameter dictionary (leave blank)
else,
-> Add a~new script -> Output -> Print a message -> Print [EXPRESSION] orc.alias + " is already dead."

but, let's not forget to add the new actual attributes to our objects!

orc -> Attributes (Tab) -> Attributes -> Add ->

Name: dead
Type: boolean
Value: false

Name: experience_points
Type: int
Value: 100 // or whatever amount you want it to have

Name: cash
Type: int
Value: 50 // or whatever amount you want it to have

player -> Attributes (Tab) -> Attributes -> Add ->

Name: experience_points
Type: int
Value: 0 // or whatever amount you want to start with

Name: cash
Type: int
Value: 0 // or whatever amount you want to start with

player -> Attributes (Tab) -> Status Attributes -> Add -> // again, for these to be displayed on the right side while playing the game

Name: experience_points
Value: (leave blank)

Name: cash
Value: (leave blank)

alright, that's good enough for my help for now, it's your turn to see what new or extra complexity you can add to or do on your own, hehe.

Try to add in scripting that let's you choose whether to "attack" (physically: with a weapon or no weapon), "cast" (magic spells), "use an item", "run away" (escape), and~or whatever else

Hints: "Show a menu", "If...", and "Switch"

Try to script the enemy object with A.I. behaviors

Hint: "GetRandomInt", "If...", and "Switch"

You can also try to add in more complex Game Mechanics too (such as for doing physical damage)

Hint: "Print a message -> Print [EXPRESSION]", and Quest's engine recognizes math's "order of operations" thankfully, making this "easy" to write into the hinted at script.

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

as can be seen by the amount of work this takes, it is so much easier to help people via code... lol. If you can learn to work with the code, it's so much easier and faster for us to help you! As helping~explaining through the GUI~Editor is a lot of work!

I could do this same thing in code, in like 5 minutes, where this took me maybe 1-2 hrs to do, argh! :P just kidding, as I was a noob too, who couldn't work with the code either.

TVJ
I could follow your instructions this far: box: RUN A SCRIPT (this allows us to add scripts, as you'll see the button for it show up upon changing to this setting)

As for the next paragraph:

(by the way, hopefully you understandd that my "->" arrows in the front~left side, mean indenting ~ "nesting" the script ~ make sure you click on the correct "add a~new script" I-think-circular button, lol. Correct indenting~"nesting" is a MUST !!!, or your series of scripts won't work correctly!!!) --> Nope, I'm afraid I don't understand (Gees, I'm feeling so dumb since I started to try and understand Quest. XD. So sorry!) What do you mean by 'nesting'? What do I have to do to 'nest' it?

it attacks you first doing damage to you and receiving a message of this act, and then you attack it for damage and receiving a message of this act

Add a~new script ->(Are we still in the 'verbs' tab of the orc object?) Variables (What? Where is that to be found?)-> Set an attribute or variable -> player.hit_points = player.hit_points - orc.physical_damage[/color] (Is this what I'm supposed to c&p somewhere? If so, where?) Again, either my editor is completely different from yours or I'm lost once again. :(

Oh heaven help me, this is giving me a severe headache. Whenever I try to solve my original problem I'm being lead to another bunch of problems which I don't understand either. :( It's like looking up a word in a dictionary that gives you a description of the word you're looking for by using other words I don't know. XD Oh my... :oops: Are there any Quest video tutorials that allow me to SEE where you're actually clicking, copy&pasting etc.? [/color]

(I'm so so sorry, I really don't want to waste your precious time! :oops: )

HegemonKhan
sorry, "nesting" is a term used as programming lingo, it basically means "indenting" (when/for doing actual code writing) and/or "inside of/contained within"

for you, who use the GUI~Editor, this means you got to be clicking on the correct 'add new script' circle buttons, as which one you click on, makes a huge difference.

this may not help, but think of scripting (add new scripts) (aka: actions/events/operations), as creating the procedure of your actions/events/operations as an outline:

I. earth
-> A. continents
->-> 1. europe
->->-> a. france
->->->-> (1) paris
-> B. oceans
->-> 1. atlantic
II. Mars

the 'orc' Object's 'fight' Verb's scripting (add new scripts), shown as code, so you can see how it works like an outline:

I. if (orc.dead) {
-> A. msg ("It's already dead, silly.")
I. }
II. else {
-> A. orc.life = orc.life - player.damage
-> B. msg ("You attack the orc, doing " + player.damage + " damage to it, leaving it with only " + orc.life + " life left.")
-> C. if (orc.life <= 0) {
->-> 1. orc.dead - true
->-> 2. player.experience = player.experience + orc.experience
->-> 3. player.cash = player.cash + orc.cash
->-> 4. msg ("You kill the orc and loot its corpse.")
-> C. }
-> D. else {
->-> 1. player.life = player.life - orc.damage
->-> 2. msg ("The orc attacks you, doing " + orc.damage + " damage, leaving you with only " + player.life + " life left.")
->-> 3. if (player.life <=0) {
->->-> a. msg ("You were killed by the orc.")
->->-> b. msg ("GAME OVER")
->->-> c. finish
->-> 3. }
->-> 4. else {
->->-> // loop (re-run) the Verb, via the 'invoke' or 'do' Script, using 'invoke' as example, in code it is this: invoke (orc.fight)
->-> }
-> D. }
II. }

each 'add new script' circle button corresponds to each line of the outline, so if you click on the wrong ones, you could get a totally screwed up outline, which obviously either will not work as you intended or not work at all. This outline concept is your 'order of operations' of your scripting (add new scripts), and thus it is vital that your 'order of operations' are correct.

for example, I think is how it looks in the GUI~Editor, for the 'if' Script block, using my 'fight' Verb for the 'orc' Object example:

add new script -> scripts -> 'if' Script -> [EXPRESSION] -> if [EXPRESSION] orc.dead

1. -> then, -> add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] The orc is already dead, silly.
VS
2. add else -> add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] The orc is already dead, silly.
VS
3. add new script -> output -> 'print a message' Script -> [MESSAGE] -> print [MESSAGE] The orc is already dead, silly.

if you click on the '#1 add new script circle button', and add in the 'msg' (message) Script, then you correctly order-place the 'msg' Script:

if (orc.dead) {
msg ("The orc is already dead, silly.")
}


it will correctly display 'The orc is already dead, silly.' as you click on the 'orc' Object's 'fight' Verb, when the orc is dead.

----

whereas if you click on' #2 add new script circle button', and add in the 'msg' (message) Script, then you incorrectly order-place the 'msg' Script:

if (orc.dead) {

} else {
msg ("The orc is already dead, silly.")
}


this is incorrect, as it'll display 'The orc is already dead, silly.' as you click on the 'orc' Object's 'fight' Verb, when the orc is not dead. Wait, if the orc is not dead, why is it saying that the orc is dead? OOPSY!

-----

whereas if you click on' #3 add new script circle button', and add in the 'msg' (message) Script, then you incorrectly order-place the 'msg' Script:

if (orc.dead) {

} else {

}
msg ("The orc is already dead,silly.")


this is incorrect, as it'll display 'The orc is already dead, silly.' every time you click on the 'orc' Object's 'fight' Verb, which is also wrong!

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

yes, all the 'add new scripts' are within the 'orc' Object's 'fight' Verb, we want to make a 'scripting chain/block' of actions/operations/events for our 'orc' Object's 'fight' Verb.

And sorry, I didn't realize that I give a few scripts to add into the 'fight' Verb, and then tell you to add in more scripts and/or change the scripts in the 'fight Verb again... thus you should do this instead:

it's not easy to add in more scripts or to change scripts within a Verb in the GUI~Editor, I'd recommend deleting all the scripts and re-adding in all the scripts, as you're likely to mess up trying to add or change them anyways, likely deleting the scripts anyways, laughs.

HegemonKhan
the Elements ( http://docs.textadventures.co.uk/quest/elements/ ) that can hold/contain/use/have scripting (actions/events/operations/orders):

Verbs, Functions, Commands, Turnscripts, Timers, Object's Script Attributes, etc

Scripting (actions/events/operations/orders):

run as script -> add new script -> (see below)

main categories/sections of the scripts:

Output
Objects
Scripts
Variables
Game State
Timers
Turnscripts
Effects

the scripts:

Output
-> 'print a message' Script
-> etc etc etc Scripts
Objects
-> 'Add to inventory' Script
-> etc etc etc Scripts
Scripts
-> 'Comment' Script
-> etc etc etc Scripts
Variables
-> 'Set object flag' Script
-> etc etc etc Scripts
Game State
-> 'Finish the game' Script
-> etc etc etc Scripts
Timers
-> etc etc etc Scripts
Turnscripts
-> etc etc etc Scripts
Effects
-> etc etc etc Scripts

you get the idea...

so, when I write this, for a quick sample example:

run as script -> add new script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> set variable orc.dead = [EXPRESSION] true

do you now understand it?

for a quick sample example

'orc' Object -> 'Verbs' Tab -> Add -> name: fight

choose the [run as script] option in the drop down box (it is defaultedly on the [print a message] option)

click on the (correct) 'add new script'

scroll down to the 'variables' category/section, and click on (add) the 'set a variable or attribute' Script

// type in what I have underlined:
set variable orc.dead = [EXPRESSION] true

// a Verb is actually a Script Attribute, so that is why we do this/go here to change/edit our 'orc' Object's 'fight' Verb, if we need to do so:
// 'orc' Object -> 'Attributes' Tab -> Attributes -> (find and click on our 'fight' Script Attribute in the list of Attributes for the 'orc' Object)

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

Support

Forums