How to make RPG status effects?

MrOrangeHorseman

I'm trying to include status effects(such as Poison and Burning) in my text adventure game. How do I do this? Could I make "tiers" (eg: Sleep I, Poison II, Burning III) of status effects?


hegemonkhan

here's a link that might help:

http://textadventures.co.uk/forum/quest/topic/scfqhpml7u_c1ptmsl4mlg/programming-diseases-on-web-version (it's a bit of a ways down for specifically doing conditions, but you might want to start from the beginning of the thread anyways)

otherwise, you can try to jump into learning Attributes and the 'if' Script, to understand well on how to do this stuff:

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


there's a few different ways of doing this (explained already in the top/first link, but oh well):

  1. using Boolean Attributes:

cumbersome (negative/con): you have a Boolean Attribute for every status-effect / condition, for examples (using scripting and just the 'player' Player Object):

(their initial/starting states):
player.normal = true
player.poisoned = false
player.petrified = false
player.paralyzed = false
player.asleep = false
player.dead = false
player.unconscious = false
player.silenced = false
player.confused = false
player.stunned = false
etc etc etc

able to have multiple effects/states (status effects / conditions) at the same time (positive/pro):

player.normal = false
player.poisoned = true
player.petrified = false
player.paralyzed = false
player.asleep = true
player.dead = false
player.unconscious = false
player.silenced = true
player.confused = false
player.stunned = false

simplistic (most people easily grasp the concept of Boolean Attribute usage, 'true' or 'false', whereas they struggle a bit more with String Attributes and their use of 'string matching') (positive/pro)

Boolean Attribute usage:

if (player.flying) { // this shorthand syntax is understood by quest as being: if (player.flying = true) {
  msg ("you're flying, you're flying! Weee! you're flying like superman!")
} else { // since this is Booleans (dualism of choices / only 2 choices), you don't need to use an 'else if'. but conceptually you're doing this: else if (player.flying = false) {
  msg ("you can't fly, you silly, it's impossible! People can't fly like superman.")
}

vs

String Attribute usage:

// player.action = "flying"
if (player.action = "flying") {
  msg ("you're flying!")
} else if (player.action = "falling") {
  msg ("you're falling!")
} else if (player.action = "swimming") {
  msg ("you're swimming!")
} else if (player.action = "walking") {
  msg ("you're walking!")
} else if (player.action = "running") {
  msg ("you're running!")
} else {
  msg ("blah blah blah")
}
// what is going on:
// player.action = "flying"
// if (player.action = "flying") {
// if ("flying" = "flying")
// if ("f" = "f")
// if ("l" = "l")
// if ("y" = "y")
// etc etc ifs until all the letters are compared or there's a mismatch (a failed letter to letter comparison)
// if ALL of the letter matching succeeds, which in this case it does ("flying" = "flying"), then the condition is TRUE: if ("flying" = "flying) ---> TRUE
// and thus it does its nested scripting for being TRUE, which would be the 'msg ("you're flying")', all following 'else ifs' and/or 'else' (of THAT/THIS 'if' block) is skipped over, as the 'if' block has executed one of its conditions

but let's take a look at this:

// player.action = "walking"
if (player.action = "flying") {
  msg ("you're flying!")
} else if (player.action = "falling") {
  msg ("you're falling!")
} else if (player.action = "swimming") {
  msg ("you're swimming!")
} else if (player.action = "walking") {
  msg ("you're walking!")
} else if (player.action = "running") {
  msg ("you're running!")
} else {
  msg ("blah blah blah")
}
// what is going on:
// player.action = "walking"
// if (player.action = "flying") {
// if ("walking" = "flying")
// if ("w" = "f")
// FAILURE, move to the next condition (the first 'else if'):
// else if (player.action = "falling")
// else if ("walking" = "falling")
// if ("w" = "f")
// FAILURE, move to the next condition (the second 'else if'):
// else if (player.action = "swimming") {
// else if ("walking" = "swimming") {
// if ("w" = "s")
// FAILURE, move to the next condition (the third 'else if'):
// else if (player.action = "walking") {
// else if ("walking" = "walking") {
// if (each of the letters: if w=w if a=a if l=l etc etc etc, which is a full match)
// SUCCESS, run its nested scripting, which is 'msg ("you're walking")
// all following 'else ifs' and/or 'else' (of THAT/THIS 'if' block) is skipped over, as the 'if' block has executed one of its conditions

and one last example:

// player.action = "reading"
if (player.action = "flying") {
  msg ("you're flying!")
} else if (player.action = "falling") {
  msg ("you're falling!")
} else if (player.action = "swimming") {
  msg ("you're swimming!")
} else if (player.action = "walking") {
  msg ("you're walking!")
} else if (player.action = "running") {
  msg ("you're running!")
} else {
  msg ("blah blah blah")
}
// all conditions (the 'if' and all 'else ifs') fail, except the catch-all/default 'else' condition, and thus its nested scripting is done, which is 'msg ("blah blah blah")
// for the 'running' condition, the 'if ("r" = "r") succeeds, but the next letter fails: if ("e" = "u"), and so it moves to the next/last condition, the 'else' condition
  1. using String Attributes:

non-cumbersome (only a single String Attribute is needed) (positive/pro):

(initial/starting state)
player.status_effects_or_condition = "normal"

UN-able to have multiple states/effects (well with using a single String Attribute, anyways, though using multiple String Attributes, ie 'player.status_effect_or_condition_1 = "sleep", player.status_effect_or_condition_2 = "poisoned", etc etc etc' would be a bit logically weird as well as can be seen) (negative/con):

player.status_effects_or_condition = "normal"
or
player.status_effects_or_condition = "poisoned"
or
player.status_effects_or_condition = "confused"
or
etc etc etc

limited to only a single state/effect at a time

  1. using String List Attributes

more overhead, but for large scale and/or complexity, more efficient and easier to implement (though learning List Attributes is more advanced than the basic Attributes of: String Attributes, Boolean Attributes, Object Attributes, Integer:int:non-decimal-numbers Attributes, and Double/Floats/Floating-Points/decimal-numbers Attributes) and non-cumbersome and able to have multiple effects/states at the same time (net positive/pro, especially at the larger scale and/or greater complexity)

(initial/starting effects/states)
player.status_effects_or_conditions = NewStringList () // creates a String List (and thus it's empty of items)
list add (player.status_effects_or_condition, "normal")

manipulation methods:

list add / list remove (NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE, "NAME_OF_LIST_ITEM")

or (this over-rides/writes/re-writes your old list (the 'split' is also a quick way of creating a list too), so at a technical level it's different from merely removing/adding the list's items via 'list add / list remove', but are otherwise the same thing)

player.status_effects_or_condition = split ("item1;item2;item3;etc etc etc", ";")


as for then using them:

you'd use the 'if' Script, for example (using String Attributes):

<turnscript name="global_turnscript">
  <enabled />
  <script>
    if (player.status_effects_or_condition = "poisoned") {
      player.current_life_integer_attribute = player.current_life_integer_attribute - 50
    } else if (player.status_effects_or_condition = "dead") {
      msg ("You died or were killed.")
      msg ("GAME OVER")
      finish
    }
    // etc 'else ifs' for your various effects/states/status-effects/conditions
  </script>
</turnscript>

or you can use the special 'changed' Script Attribute too, for example (using the 'game' Game Settings/Etc Object and a custom 'game.turns_integer_attribute' counter Integer Attribute):

<turnscript name="global_turnscript">
  <enabled />
  <script>
    game.turns_integer_attribute = game.turns_integer_attribute + 1
  </script>
</turnscript>

<game name="xxx">
  <attr name="statusattributes" type="simplestringdictionary">turns_integer_attribute = Turns: !</attr> // this will display them during game play on the 'whatever it is called' pane on the right side
  <attr name="turns_integer_attribute" type="int">0</attr>
  <attr name="changedturns_integer_attribute" type="script">
     if (player.status_effects_or_condition = "poisoned") {
      player.current_life_integer_attribute = player.current_life_integer_attribute - 50
    } else if (player.status_effects_or_condition = "dead") {
      msg ("You died or were killed.")
      msg ("GAME OVER")
      finish
    }
    // etc 'else ifs' for your various effects/states/status-effects/conditions
  </attr>
</game>

--------

for more detailed explanation see my 'attributes and if script' link/guide

ask if you got any questions or need any help with any of this stuff

(using String List Attributes is a different beast, if you want to use them, let me know, and I'll make a post on using them)

hegemonkhan

yes, you can make tiers, for example (using String Attributes again):

player.status_effect = "normal"
or
player.status_effect = "poisoned_1"
or
player.status_effect = "poisoned_2"
or
player.status_effect = "poisoned_3"
or
player.status_effect = "rust_1"
or
player.status_effect = "rust_2"
or
player.status_effect = "rust_3"

// and then using them (just quick simple scripting example):

if (player.status_effect = "normal") {
  msg ("You're healthy")
} else if (player.status_effect = "poisoned_1") {
  player.current_life_integer_attribute = player.current_life_integer_attribute - 50
} else if (player.status_effect = "poisoned_2") {
  player.current_life_integer_attribute = player.current_life_integer_attribute - 100
} else if (player.status_effect = "poisoned_3") {
  player.current_life_integer_attribute = player.current_life_integer_attribute - 500
} else if (player.status_effect = "rust_1") {
  player.weapon.durability = player.weapon.durability - 50
} else if (player.status_effect = "rust_2") {
  player.weapon.durability = player.weapon.durability - 100
} else if (player.status_effect = "rust_3") {
  player.weapon.durability = player.weapon.durability - 500
}  

hegemonkhan

I love RPGs! I too am forever slowly trying to learn/make a TES (skyrim, oblivion, morrowind, etc) like RPG with quest... far too ambitious and beyond my coding ability, but oh well, lol.

if interested, I can give a lot of RPGs for ideas for you, as I've played a lot of RPGs...

if you don't know about this epic fan-made mod for Civ4/BtS, you should take a look at it, as they got some really cool ideas/mechanics/features:

Fall from Heaven II

https://forums.civfanatics.com/threads/mod-fall-from-heaven-ii.171398/
https://forums.civfanatics.com/forums/civ4-fall-from-heaven.190/
http://kael.civfanatics.ne.t/
https://forums.civfanatics.com/resources/ffh-2-manual.8635/ (if you don't mind downloading this manual, it shows a lot of FFH2's features)

move the dot/period from the between the 'e' and 't' in the '.net'

the links aren't allowed... so just google search it... nvm (only the '.net' is blocked)


The Pixie

I would handle these as integer attributes, and to set the status to Poison II, for example, do:

player.poison = 2

RPGs are very complex; keep it simple where you can. If you are interested, I have a library and a set of tutorials on how to use, which might help in general, though not this specific issue:
https://github.com/ThePix/quest/wiki/CombatLib


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

Support

Forums