Combat System using the GUI.

Hi there! I was wondering if anyone knows how to implement a combat system into a game. The game is post apocalyptic, so no magic, and will involve many different types of enemies and potential weapons. If this isn't possible, I understand, I was just wondering if anyone knew how to do this. If it is not possible using the GUI, i'm open to trying out the coding aspect, but I don't really understand what i'm doing.

Additionally, I was wondering if anyone knew how to implement a radiation system, involving curing radiation, and making death occur when the radiation level gets too high. Thanks in advance.


This will take you through combat:
https://github.com/ThePix/quest/wiki/The-Zombie-Apocalypse-(on-the-web-version)

If you can use the desktop version, do so. The only way it is more complicated is that it allows you to do more complicated stuff a bit easier. The coding is the same in both.


you can almost do anything you want through the GUI/Editor, it's just a lot more difficult to help and walk people through the instructions with it (it's a lot more typing for us trying to help others with how to do stuff with it), compared to how fast code can be typed, copied, and pasted for people to use. Though, code is NOT easy to learn, especially when starting out with trying to learn it for your very first time.

also, I personally am not that familiar with the GUI/Editor and its various script options and etc other features/capabilities, and as well not familiar with all of quest's built-in stuff, which the GUI/Editor has a lot of controls for setting/changing/working with. It's a pain to have to open up quest to see how to do things in the GUI/Editor for almost everything, for me.


combat is one of the most complex things there is to code-for/put-into games (it's one of a game's main systems), and even the most simplistic combat system (which it certainly can be, it doesn't have to be complex and advanced combat system), is still not easy to do, especially if you don't understand the basic fundamentals needed.


the basic fundamentals (the 'bread and butter') of game-making and/or coding, is learning/understanding Attribute and the 'if' Script usage.

with these two things, esepcially when used together, you can do 90% of everything you want to do for/in your game, its: game making/design.

in the GUI/Editor, these two "SUPER SCRIPTS" are accessed via (I'm not familiar with exactly the GUI/Editor's scripting options, but you should be able to figure them out / match up what I got below, with the GUI/Editor's scripting options):

  1. Attribute usage (creating/adding/setting, re-setting/changing/modifying/altering/adjusting):

run as script -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

  • since I don't know the GUI/Editor's scripting options, I cheat using this '[EXPRESSION]' scripting option, so I can do/type-in the GUI/Editor's script --- note that it's slightly different in format/syntax than coding directly. If you can figure out the right option: [xxxx], then use that instead of my use of the '[EXPRESSION]' scripting option)

for example:

let's say I want to have a 'strength' Integer Attribute for/on (contained by/within) the 'player' Player Object, and for it to have the Value of '100', via scripting (during the game, like maybe you found a super secret elixir item that upon drinking, gives you 100 str permanently), see below:

'elixir' Object -> 'Verb' Tab -> Add -> Verb Name: consume -> (see below)

set variable player.strength = [EXPRESSION] 100
(directly in code, it'd look like this: player.strength = 100, so you can see there's a bit of a difference, and there's other differences too for other scriptings too, such as needing the double quotes for strings or not)

let's say we want them to have 0 str, well it's done the same way:

set variable player.strength = [EXPRESSION] 0

some other examples (some of the other Attribute/data Types):

Integer Attributes:

set variable player.current_life = [EXPRESSION] 999
set variable player.maximum_life = [EXPRESSION] 999
set variable player.current_mana = [EXPRESSION] 99
set variable player.maximum_mana = [EXPRESSION] 99
set variable player.strength = [EXPRESSION] 90
set variable player.endurance = [EXPRESSION] 30

set variable orc.current_life = [EXPRESSION] 500
set variable orc.maximum_life = [EXPRESSION] 500

set variable game.state = [EXPRESSION] 0
set variable game.state = [EXPRESSION] 1
set variable game.state = [EXPRESSION] 2

set variable player.age = [EXPRESSION] 18
set variable player.age = [EXPRESSION] 10
set variable player.age = [EXPRESSION] 30

Boolean Attributes:

set variable orc.dead = [EXPRESSION] false // conceptually: the orc is alive
set variable orc.dead = [EXPRESSION] true // conceptually: the orc is dead
(choose whichever works better for you: the above/'dead' or/vs below/'alive', you don't use both 'dead' and 'alive' custom-for-this-example Boolean Attributes)
set variable orc.alive = [EXPRESSION] false // conceptually: the orc is dead
set variable orc.alive = [EXPRESSION] true // conceptually: the orc is alive

String Attributes:

set variable player.life = [EXPRESSION] "unknown"
set variable player.mana = [EXPRESSION] "unknown"
set variable player.life = [EXPRESSION] "999/999"
set variable player.mana = [EXPRESSION] "99/99"

set variable game.intro = [EXPRESSION] "blah blah blah blah blah blah...."

set variable player.condition = [EXPRESSION] "normal"
set variable player.condition = [EXPRESSION] "poisoned"
set variable player.condition = [EXPRESSION] "asleep"
set variable player.condition = [EXPRESSION] "confused"
set variable player.condition = [EXPRESSION] "petrified"
set variable player.condition = [EXPRESSION] "paralyzed"
set variable player.condition = [EXPRESSION] "silenced"
set variable player.condition = [EXPRESSION] "stunned"
set variable player.condition = [EXPRESSION] "dead"
set variable player.condition = [EXPRESSION] "unconscious"
set variable player.condition = [EXPRESSION] "cursed"
set variable player.condition = [EXPRESSION] "blinded"
set variable player.condition = [EXPRESSION] "crippled"

set variable player.sex = [EXPRESSION] "male"
set variable player.sex = [EXPRESSION] "female"

Object Attributes:

set variable player.right_hand = [EXPRESSION] sword // you have to have an actual 'sword' Object created/existing already
set variable player.left_hand = [EXPRESSION] shield // you have to have an actual 'sword' Object created/existing already

set variable player.parent = [EXPRESSION] room // you have to have an actual 'room' Room Object created/existing already
set variable player.parent = [EXPRESSION] room_2 // you have to have an actual 'room_2' Room Object created already


for Integer/Double Attributes:

and we can also do arithmetic (increments/decrements) expressions/operations too:

Addition: set variable player.strength = [EXPRESSION] player.strength + 5 // it increases your str by: +5
Subtraction: set variable player.strength = [EXPRESSION] player.strength - 77 // it decreases your str by: -77
Multiplication: set variable player.strength = [EXPRESSION] player.strength * 2 // it increases your str by: x2
Division: set variable player.strength = [EXPRESSION] player.strength / 3 // it decreases your str by: /3

  1. the 'if' Script

run as script -> add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE OPERATOR VALUE_OR_EXPRESSION

and there's also the use of negation: not

for some examples (in direct code, hopefully though you can match it up with doing it in the GUI/Editor):

if (test.score > 89) {
  test.grade = "A"
} else if (test.score > 79) {
  test.grade = "B"
} else if (test.score > 69) {
  test.grade = "C"
} else if (test.score > 59) {
  test.grade = "D"
} else {
  test.grade = "F"
}

if (player.alignment_integer_attribute > 66) {
  player.alignment_string_attribute = "good"
} else if (player.alignment_integer_attribute > 33) {
  player.alignment_string_attribute = "neutral"
} else {
  player.alignment_string_attribute = "evil"
}

if (player.current_life < 1) {
  msg ("You died or were killed.")
  msg ("GAME OVER")
  finish
}

if (player.condition =  "dead") {
  msg ("You died or were killed.")
  msg ("GAME OVER")
  finish
}

if (player.condition =  "poisoned") {
  player.current_life = player.current_life - 50
}

anyways... ask away as you got questions and/or need help with anything, doing or about anything

and here's a more detailed guide, but it's a bit more code heavy, but it does have how to do the stuff through the GUI/Editor for you too:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

again, ask if you need help on/with anything


p.s.

here's a step by step game creation guide walkthrough for you, to learn the basics of Attribute (including the use of the 'statusattributes') usage:

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375

ask if you got any questions or need help with anything


Thank you all! This has helped tremendously! Combat system has been essentially implemented, just working on the radiation mechanic now.


I am not always for re-inventing the wheel, but sometimes, that is the only way to get what you want and understanding what you have...
Build it your self.
But keep in mind to use variables everywhere to expand it later.
Start with just you and 1 other creature and just 1 weapon.
DnD uses a D20 for attack.
start with 10 or better to hit, 1d6 for damage.
then you and it whack each other until some one is dead...
(oops, forgot HP and 0 HP=dead)
Then add armor, does armor make you harder to hit (like DnD) or does it reduce the damage you receive?
Next, every creature, has stats. (strength, dexterity...)
How does that affect combat?
In DnD, Str adds to ToHit and Damage...
Dex add to defense...
Maybe you want Dex bonus to hit and Str bonus for damage...
Next is the combat loop, do you always hit first, or is it random?
Do you want to enter your attack commands first, then let the program decide who hit first?
Or do both of you swing at the same time, and possibly kill each other in the same round?
Then, as you think of more things to add, work them in...


Hello everybody! I'm still experiencing some issues. Namely, no matter what I do in the zombie apocalypse guide, I simply can't get firearms to work, and two, I am constantly met with this error when trying to attack with a spade. I've spent the last half hour trying to fix it and have no idea what has occurred.

Error running script: Error compiling expression 'GetRandomInt(1, 20) + weapon.attack - target.defence': ArithmeticElement: Operation 'Add' is not defined for types 'Int32' and 'Object'

Any ideas?


Either the weapon has no attack set or the target has no defence set. The weapon attacks should be in the start script of the game object. The player also needs a defence, also in the start script.

So first check the start script of the game object. You should have lines like this (not necessarily together or in this order, and you might have changed the numbers):

spade.attack = 3
player.defence = 0
pistol.attack = 0

The defence for the monsters will be in the function that creates them, and should look like this:

obj.defence = 0

If that all looks right, could you copy and paste the entire scripts from the function and the start script into a post?


I reverted my version back before I added firearms in, so that I could get melee weapons working first. I've checked everything, and it does appear that everything is in order.

Here is the entire start script.
https://pastebin.com/DrFcdmYt

and here is the zombie function (I renamed them Morts)
https://pastebin.com/UzDSte3p

EDIT: Oh my. I appear to have made a rather stupid mistake. Thank you so much for all the help. I do still appear to have some issues with firearms, but i'll try to sort them out myself before bothering you.


When you get an error in the game, click on the Debugger before you stop your game,
look under the player entry to look at all your player variables...
Look for the last bolded entry...
that would show you where the program crashed.
make sure you do not have a player.attack entry and a player.Attack entry...
(It would be nice if Quest was not case sensitive... but...)


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

Support

Forums