basic combat help!

adammadam
Hi, I have been reading the how to guides, after a lot of time reading and messing around with things, I'm still not sure how to make the players damage remove health from the enemy myself though. Right now I am just trying to work out how to make a basic combat system and my game looks like this right now
q2.png
q3.png
q1.png

adammadam
so what is working is when I "attack monster" in game, it gives the message "you attack monster". When I look at the monster in game it says "it looks alive". When I set the monsters health to zero and play the game again, looking at the monster says "it looks dead". Which is great those things are working. But what isn't working is when I start a new game with the monsters health on 10, attack the monster, it says "you attack monster" but then it never dies, I can keep on attacking it, I'm guessing its health is never going down.

This is something really basic I know... after this I want to learn how to make it a turn based combat in which the enemy attacks back and the player cant escape from until it's resolved (or maybe an option to flee in certain circumstances...) I'm a looong way away from that I think though! :/

adammadam
and this part "the monster is already dead" or "you attack" is working, which is great!

But just not the actual combat bit :?

I'm sure I'm just being stupid but I'm not used to coding, at all.

Also I tried copy pasting some different things in the code view from the help guide and things people have posted here, but I can't get any of it to work!
q4.png

adammadam
or is this anywhere near the correct thing to do..
q5.png

adammadam
I've fixed one error -"You attack " + object.article + "." instead of object.name and it as a message not expression.. and I put in object in the other two boxes so the text is all working properly now, if I try to "attack table" it says the right message, if I attack the monster when it's alive or when it's dead it says the appropriate thing, it's just the actual doing damage part I have no clue about!

HegemonKhan
I don't know how the built-in 'health' percent Attribute works as it confuses me, lol, so, I just create my own 'life~hp' Attribute.

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

VARIABLES:

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

I don't know the GUI~Editor very well, so I don't know what drop down options you choose and etc to set it up, so you got to figure that out on own, or you can choose the ' [expression] ' drop down choice, and type~code in the Attribute Expression yourself as I do (see below)

Variables:

these are local~temporary for use only in its own script block, not 'save-able ~ load-able' and thus can't be used anywhere in your game code.

Variable_name
~OR~
Variable_name=Value_or_Expression

Attributes:

these are global~permanent (so long as the Object that they're attached to, exists or still exists, of course), they are 'save-able ~ load-able' and thus can be used anywhere in your game code, their use is not limited to their own script block.

Object_name.Attribute_name
~OR~
Object_name.Attribute_name=Value_or_Expression

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

String Attributes:

strings are just a collection of symbols (alphabet, numbers, and other various symbols like an underscore, but not all symbols are allowed)

as a (String) Attribute's Value, when directly writing in code (as I show below this code box), they must have double quotes surrounding~encasing them (as without the double quotes, quest will see them as Object Attributes, and not as String Attributes)

however, when writing their Values in the GUI~Editor's text box, you do NOT need to encase them in double quotes if they're just Values, but if you're doing an Expression, then you do got to use the double quotes for the textual parts, like how you do when writing in expressions in code.

example strings:

a
abc
1
123
abc123
dead
normal
poisoned
abc_123
kadfnsjbvojbsogn


player.condition="normal"
player.condition="poisoned"
game.static_greeting="Hi, how are you?"
game.dynamic_greeting="Hi, how are you " + player.alias + "?"
game.state="0"
game.state="1"
orc.dead="false"
orc.dead="true"
HK.favorite_color="black"

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

the secret trick to writing dynamic (String) Expressions:

break them up into two chunks:

1. "textual parts"
2. +Object_name.Attribute_name+

for example:

player.alias="HK"
player.age_integer=18 // I wish I was 18 again, lol
player.age_string="adult"
player.sex="male"
player.race="human"
player.class="warrior"

msg (player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + ".")

// outputs: HK is a 18 year old adult male human warrior.

the chunks:

player.alias +
" is a "
+ player.age_integer +
" year old "
+ player.age_string +
" {empty space: an empty space, aka the spacebar key, counts as a symbol~string just as an underscore, and as the letter 'a', does} "
+ player.sex +
" {space} "
+ player.race +
" {space} "
" player.class +
" {period~dot, as my eyes are bad and can't see it, lol} "

OR, you can just use the text processor commands:

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

msg ("{player.alias} is a {player.age_integer} year old {player.age_string} {player.sex} {player.race} {player.class}.")

just to see it better:

msg ( " {player.alias} is a {player.age_integer} year old {player.age_string} {player.sex} {player.race} {player.class} . " )

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

Integer Attributes:

these are non-decimal numbers

player.strength = 100

player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100 - (orc.armor.resistance + orc.armor.resistance * orc.endurance / 100)

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

Double (Floats~Floating Points) Attributes:

these are decimal numbers

(I've never used them, so I don't know if their Values are within double quotes or not)

player.damage = "54.2"
~OR~
player.damage = 54.2

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

Boolean Attributes:

their values are only: 'true' or 'false', NO double quotes

orc.dead=false
orc.dead=true
player.flying=false
player.flying=true

their shortened usage is:

orc.dead
not orc.dead

if (orc.dead) { msg ("The orc is dead.") }
else if (not orc.dead) { msg ("The orc is alive.") }

orc.dead --------> understood as its Value being 'true' --------> true
not orc.dead --------> not (understood as its Value being 'true' ) --------> not (true) -------> false

their full-form usage is:

if (orc.dead=true) { msg ("The orc is dead.") }
else if (orc.dead=false) { msg ("The orc is alive.") }

~OR~

if (orc.dead=true) { msg ("The orc is dead.") }
else if (not orc.dead=true) { msg ("The orc is alive.") }

-----------

Object Attributes:

their Values must NOT have double quotes (as that would tell the quest engine that they're String Attributes, and not Object Attributes), and their Values can't be 'false' or nor 'true' as these are special~reserved for Boolean Attributes.

game.pov = player
player.parent = room
player.right_hand = sword
player.left_hand = shield

and they must be actually existing Objects of course (see below)

<game name="xxx">
</game>

<object name="player">
</object>

<object name="room">
</object>

<object name="sword">
</object>

<object name="shield">
</object>

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

String List Attributes:

http://docs.textadventures.co.uk/quest/ ... split.html
http://docs.textadventures.co.uk/quest/ ... _menu.html

HK.favorite_colors=split ("black;red", ";")
global_data_object.sex_stringlist_attribute = split ("male;female", ";")
game.primary_pigment_colors=split ("red;blue;yellow", ";")

show menu ("Sex?", split ("male;female", ";"), false) { scripts }
~OR~
show menu ("Sex?", global_data_object.sex_stringlist_attribute, false) { scripts }

show menu ("Favorite Primary Pigment Color?", split ("red;blue;yellow", ";"), false) { scripts }
~OR~
show menu ("Favorite Primary Pigment Color?", game.primary_pigment_colors, false) { scripts }

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

etc Attributes:

too tired~lazy

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

these are the math computational expressions:

Addition:

Object_name.Integer_Attribute_name = Object_name.Integer_Attribute_name + Value_or_Expression

Subtraction:

Object_name.Integer_Attribute_name = Object_name.Integer_Attribute_name - Value_or_Expression

Multiplicatin:

Object_name.Integer_Attribute_name = Object_name.Integer_Attribute_name * Value_or_Expression

Division:

Object_name.Integer_Attribute_name = Object_name.Integer_Attribute_name / Value_or_Expression

------

conceptually of how it works (using addition):

initial: player.strength=0

-------

old: player.strength=0

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

new: player.strength=5

------

old: player.strength=5

player.strength(new)=player.strength(old:5)+5
player.strength(new)=5+5=10

new: player.strength=10

------

old: player.strength=10

player.strength(new)=player.strength(old:10)+5
player.strength(new)=10+5=15

new: player.strength=15


---------

as to why its not working for you... you're confusing (messing up) a few things... and it'll take a bit of time to explain all of these things...

so, let's first just do it in the simpliest way, as a starting example, of what you do for it to work:

'player' Player Object -> 'Attributes' Tab -> Attributes (NOT Status Attributes) -> Add -> (see below, repeat as needed)

(Object Name: player)
Attribute Name: life
Attribute Type: int (integer)
Attribute Value: 999

(Object Name: player)
Attribute Name: damage
Attribute Type: int (integer)
Attribute Value: 100

'room' Room Object -> 'Objects' Tab -> Add -> Object Name: orc

'orc' Object -> 'Attributes' Tab -> Attributes (NOT Status Attributes) -> Add -> (see below, repeat as needed)

(Object Name: orc)
Attribute Name: life
Attribute Type: int (integer)
Attribute Value: 500

(Object Name: orc)
Attribute Name: damage
Attribute Type: int (integer)
Attribute Value: 50

'orc' Object -> 'Verbs' Tab -> Add -> Verb Name: fight -> [run as script] -> (see below)

add new script -> print a message -> [expression] -> "{player.name} has {player.life} life left."
add a script -> print a message -> [expression] -> "{orc.name} has {orc.life} life left."
add a script -> variables -> 'set a variable or attribute' Script -> Set variable orc.life = [expression] orc.life - player.damage
add a script -> print a message -> [expression] -> "{player.name} does {player.damage} damage to {orc.name}, it now has only {orc.life} life left."
add a script -> variables -> 'set a variable or attribute' Script -> Set variable player.life = [expression] player.life - orc.damage
add a script -> print a message -> [expression] -> "{orc.name} does {orc.damage} damage to {player.name}, it now has only {player.life} life left."

obviously, we want some more stuff with this, but this is the basic.

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

as to your issues....

---

issue 1, choose either 'dead' or 'alive' for your Boolean Attribute, but don't use both, as can be seen:

Object_name.dead = false ---> conceptually: alive
Object_name.dead = true ---> conceptually: dead
~OR~
Object_name.alive = false ---> conceptually: dead
Object_name.alive = true ---> conceptually: alive

or, if you rather, don't use a Boolean Attribute (as it's limited to only two opposing Values: true~false), and instead use a String Attribute such as using 'condition' (or 'status_effects' ) as the String Attribute's Name, as it can have an unlimited number of single Values:

Object_name.condition = "normal"
Object_name.condition = "dead"
Object_name.condition = "unconscious"
Object_name.condition = "poisoned"
Object_name.condition = "asleep"
Object_name.condition = "stunned"
Object_name.condition = "paralyzed"
Object_name.condition = "petrified"
Object_name.condition = "silenced"

if (player.condition="dead") {
// having the 'player' be able to be 'dead' is for having a team~party (as the other characters can revive dead characters), as then we'd check if all of your characters are dead, and end game if so.
// if you don't have a team~party, then (generally) there's really no reason for this, as you'd just check if life<=0, ending the game if it is.
msg ("You died or were killed.")
msg ("GAME OVER")
} else if (player.condition="poisoned") {
player.life = player.life - 50
msg ("The poison does 50 damage to your life.")
} else if (...etc...) { scripts }


or... if you need~want an unlimited number of multiple values, then you need to use a List Attribute (adding and removing values from the list):

player.condition=split ("normal;alive",";")

// you get poisoned:

list remove (player.condition, "normal")
list add (player.condition, "poisoned")
// in code, it would now look like this: player.condition=split ("alive;poisoned", ";")

// or, you get killed:

list remove (player.condition, "alive")
list add (player.condition, "dead")
// in code, it would now look like this: player.condition=split ("normal;dead", ";")

// or, you get poisoned and killed:

list remove (player.condition, "normal")
list add (player.condition, "poisoned")
list remove (player.condition, "alive")
list add (player.condition, "dead")
// in code, it would now look like this: player.condition=split ("poisoned;dead", ";")

if (ListContains (player.condition, "poisoned") and ListContains (player.condition, "dead")) {
player.life = player.life - 50
msg ("You are dead, yet the poison still remains as well.")
msg ("You need another character to revive you and cure you of your poison.")
}


----

issue 2:

adammadam wrote:so what is working is when I "attack monster" in game, it gives the message "you attack monster". When I look at the monster in game it says "it looks alive". When I set the monsters health to zero and play the game again, looking at the monster says "it looks dead". Which is great those things are working. But what isn't working is when I start a new game with the monsters health on 10, attack the monster, it says "you attack monster" but then it never dies, I can keep on attacking it, I'm guessing its health is never going down.


for the part that is working, you got it set up correctly for your 'if (monster.health>0)...' scripting:

Object_name.Attribute_name = Value_or_Expression

Object_name = monster
Attribute_name = health
Attribute_name = dead
Attribute_name = alive
// though, you shouldn't have both 'dead' and 'alive' Boolean Attributes, as I've already said above.

but you are confused a bit with how to set up the 'attack' Command properly:

delete your 'attack' Command, as this is a bit more advanced, let's just stick with using the GUI~Editor's Verb usage for now, your 'attack' Verb.

you're still learning quest and~or coding... so you don't want to be trying to do~use too many things (especially the more advanced things) all at once.

------

issue 3,everything else looks fine (I think), so just MAKE SURE that your 'health' and 'damage' Attributes on your 'monster' Object and 'player' Player Object, are indeed (set to~as) the Attribute Type: int

HegemonKhan
if you want to know about using Commands....

the GUI~Editor's 'Verbs' are actually a sub-type Command in technicality, only working on a specific Object, whereas Commands are general~broad, not tied to a specific Object. The GUI~Editor's 'Verbs' is much more noob-friendly:

Object Name: orc
Verb Name: 'fight' -> [run as script] -> (add your fighting scripts)
Verb Name: 'kiss' -> [print a message] (this is the same as: run as script -> output -> print a message) -> You kiss the orc, eww, yuck!
Verb name: 'talk' -> etc etc etc

Object Name: ogre
Verb Name: 'fight' -> [run as script] -> (add your fighting scripts)
Verb Name: 'kiss' -> [print a message] (this is the same as: run as script -> output -> print a message) -> You kiss the ogre, eww, yuck!
Verb name: 'talk' -> etc etc etc

------

whereas Commands:

take in the person playing the game 's typed-in input and sets it to the 'Pattern' 's Parameter, which the scripting then uses that Parameter.

for example:

Command Name: fight_command
Command Pattern: fight #object#; attack #object#; strike #object#

Command Name: kiss_command
Command Pattern: smooch #object#; kiss #object#

the Command Pattern explained:

the first word is required as it's the activator for what command you want to use. so, when the person playing the game, types in 'fight' or 'attack' or 'strike', the game engine uses the 'fight_command' Command, whereas if the person playing the game, types in 'smooch' or 'kiss', the game engine uses the 'kiss_command'. So, be careful about not having any conflicts, obviously.

the ' #object# ' or ' #text# ' (I'll get into the difference between them later) is the Parameter (a temporary~local Variable used by the Command), and this is what it does (below the code box: 'the person types in during game play: ... ' part):

<object name="orc">
<alias>orcy</alias>
</object>

<object name="ogre">
<alias>ogry</alias>
</object>


the person types in during game play:

fight orc

quest via my 'fight_command' Comamnd, will set up this Variable:

text = #text# = "orc"
~OR~
object = #object# = orc

and for multiple #text# and~or #object# :

text = #text# = "orc"
text2 = #text2# = "ogre"
text3 = #text3 = "troll"
~ AND~OR ~
object = #object# = "orc"
object2 = #object2# = "ogre"
object3 = #object3# = "troll"

[HK Edit: nevermind, I guess you can type in whatever you want between the #....#, my bad], so ignore this below:
You have to use 'text' or 'object' between the ' #....# ', as this tells quest whether to look+get an Object or Text, so you can't do: #monster#

which will be used by the scripting (script -> add new script) for example (using #object# ):

add new script -> output -> print a message -> [expression] -> "The monster's name is " + object.alias + "."
// outputs: The monster's name is orcy.

but, what if the person playing the game, types in: fight ogre ???

well, this is what Commands are for, general~dynamic usage !!!

quest via my 'fight_command' Comamnd, will set up this Variable:

text = #text# = "ogre"
~OR~
object = #object# = ogre

which will be used by the scripting (script -> add new script) for example (using #object#):

add new script -> output -> print a message -> [expression] -> "The monster's name is " + object.alias + "."
// outputs: The monster's name is ogry.

the #text# vs #object# tells the quest engine~Command, what to look for and get:

an Object or just a mere text

I personally use #text# as using the #object# still confuses me (I still get errors~issues with it, due to still not understanding how to use it properly, lol), and if I need it to be an Object, I can just do this:

VARIABLE_name = GetObject (text)

wihtout any problems, unlike me trying to use #object#.

lastly, here's further what you can do with the Command's Pattern, some examples:

multiple #text# and~or #object#
and for our own human use~grammer or whatever: add-in words that are part of the required Pattern's syntax

craft #object1# and #object2# and #object3#
// the person would ahve to type in (for example): craft bread and jelly and peanut_butter
// 'msg' scripting output: "You made a peanut butter and jelly sandwich! Wow, you're so awesome!")

craft #object1#, #object2#, and #object3#
// the person would ahve to type in (for example): craft bread, jelly, and peanut_butter
// 'msg' scripting output: "You made a peanut butter and jelly sandwich! Wow, you're so awesome!")

craft #object1# + #object2# + #object3#
// the person would ahve to type in (for example): craft bread + jelly + peanut_butter
// 'msg' scripting output: "You made a peanut butter and jelly sandwich! Wow, you're so awesome!")

craft #object1# #object2# #object3#
// the person would ahve to type in (for example): craft bread jelly peanut_butter
// 'msg' scripting output: "You made a peanut butter and jelly sandwich! Wow, you're so awesome!")

adammadam
yes this is working great. Thank you it's really so nice having someone helping than being stuck not knowing what to do for ages
quest7.png

HegemonKhan
sorry, about all the help mostly in code, as it's much faster+easier for me, than trying to demonstrate through using the GUI~Editor... but it seems you're able to understand coding already a bit, as you're not saying my posts are scaring you, lol. Though, they still may be overwhelming you, due to providing too much information all at once.

So, if you got any questions about anything, ask.

adammadam
it is all a lot to take in for me tbh (not your messages in particular but just the entire Quest software), I was mostly struggling with getting some kind of combat working, I'm making a lot of progress on my own now though after you helped me get over that. Everything that you typed really helps to understand some of the concepts as well

HegemonKhan
ya, the overwhelming info is a big hurdle (it just takes time, and take it slowly building up your knowledge), if you want to see how I started out (for laughs), as I was just so confused by all of the terms, haha, and my progression:

viewtopic.php?f=10&t=3348

my noobie thread from like 2-3 years ago, hehe.

adammadam
you know what's weird right now is the "print expression" keep on changing themselves back to "print message" in the last screenshot I put up, it's wrong because they're set to print message.. but they were on expression. Anytime I leave it (say by clicking on another thing, to look at another room) and then come back to it, they've all changed from being expression to message!

edit: actually it doesn't seem to matter that it's doing this though. it's probably something that's meant to happen I didn't understand..

adammadam
have you finished many games yet on this by now?

adammadam
well I think it's nice that you got help years ago and now you're helping people on here

HegemonKhan
there's quite some differences between the GUI~Editor vs in-code when it comes to its structure (which makes comparing~converting~studying them, a bit of an annoyance, as they're quite a bit alien~different from one another, lol. So even though you can do something in the GUI~Editor and then look at it in Code, and vice versa, it still doesn't really match up that well, and the thus the memorization is a waste of time, at least for me it was, lol).

in code:

msg ("text")
~OR~
msg ("text" + VARIABLE)

is the same as in the GUI~Editor:

run as script -> add a~new script -> output -> print a message

though, the GUI~Editor breaks it up further (to make it more user-friendly, as it puts in the double quotes for you ~ which causes a good bit of confusion as to the proper syntax of writing in the GUI~Editor vs writing in-code), with the selection of:

run as script -> add a~new script -> output -> print a message -> print ( [message] or [expression] )

if you select the [message] drop down choice (which is the same as if you just did ' [print a message] instead of this ' [run as script] -> add a~new script -> output -> print a message -> [message] ' that I'm showing in this very part, lol), then you can only write in text for it:

Hi, my name is HK.
// in code: msg ("Hi, my name is HK.")

if you selecte the [expression] drop down choice, then you can write in text and~or VARIABLES:

"Hi, my name is " + player.alias + "."
// in code: msg ("Hi, my name is " + player.alias + ".")

----------

I actually haven't been playing that many games, jsut too busy, and I got a list of friends who want me to try their games too, like Xanmag, and etc.

sighs, so much to do, so little time, esepcially the older and older you get.

oh, oh, you mean actually finshed created my own games, haha, right?

no real games, except my 'rock, paper, scissors' game, if you wanna call it a game, lol:

viewtopic.php?f=5&t=4094 (I just felt I needed to give something back to this very helpful community and great software, and this was something I was able to do, lol)

I'm trying to do a skyrim level of RPG coding game, which is taking a long time, as I got to learn how to do the coding of it, laughs.

I kinda get 'character creation', 'equipment', 'magic', 'explore and travel', 'leveling up', and a few more etc such coding, but actually designing the game's code systems of these is very difficult, especially with my limited coding knowledge~tactics~methods that I have to use.

I haven't even yet worked on dialogue coding (beyond the most basic). Nor, have I tried to do story~plot, which will be pathetic as I'm not a writer~author, lol. I'm just for right now, trying to learn to code, laughs, being not a coder either, lol.

right now, I'm still working on 'character creation', which you can see my progress so far here:

viewtopic.php?f=18&t=4988 (I don't like the popup windows of 'show menu', so trying and wanting to do everything via 'get input', as I want to leave the verb hyperlinks and buttons, for other uses)

-----

oh yes, I literally learned to code all thanks to quest and all the helpful people here, I wouldn't be where I am today without all their help! I'm now working on learning the basics of other languages, using 'codecademy' site right now, jsut finished the entire course on 'python', and am now starting with the 'javascript' course. I also dabbled a bit with 'applescript' (for apple computers) and looked at 'assembly' language... I think I kinda get the gist of it... but wow... that's way beyond me... too much hexadecimal~etc numbering systems and dealing with memory usage (hex values) in the processor or whatever... is still very confusing and scary for me right now.

adammadam
personally I'm trying to make something which is more like a gamebook I guess, more written descriptions of things, maybe similar to a fighting fantasy or lone wolf book, but I wanted a fairly advanced combat system and character customisation as well. I've got it working pretty well now although the only problem is I'm probably doing really overly complex workarounds for things, but oh well it gives more options to put in different text at every different point too. I'll share what I've done with everyone when I've made a bit more progress!

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

Support

Forums