Creating rpg stats
LeftUnscarred
24 Aug 2018, 14:22i am a complete and total noob when it comes to quest. i wan tot make rpg stats for combat like if your strength is so high u can wield a certain weapon and stats for armor to give protection when it comes to being damaged. i also want to make stats for like worldly thing like i have a trap that can be disarmed if u have a disarming stat of lets say 7 or higher i cant get the stats to work at all and i'm basically a complete noob when it comes to coding or using quest in general anyone have any ideas to help me?

DarkLizerd
24 Aug 2018, 20:21You sound like you are getting in a little over your head... But keep swimming, you will bet the hang of it...
- Strength stats and wielding different weapons:
start with: player.Str=10 For example.
Stats for weapons: (just str minimums)
Dagger: 8
Short Sword: 12
Long Sword: 15
2-H Sword: 17
Basterd Sword: 18
When the player want to wield the weapon, check his strength...
if (player.Str>weapon.Str) {
// then you can use it
msg ("You weild it.")
// or get more fancy with the wording... (preferred)
}
else {
msg ("It is too heavy for you to use in combat.")
}
So... the player can use the dagger, but not any of the swords.
So, the same with any other skills you need
- Traps:
player.TrapSkill=3
A simple trap may be 1-5
Harder:5-10
Complex:10+
(Also, on a complex trap there could be several interlocking traps... IE: 2 or 3 traps that need to be disarmed to disarm the main trap)
Then a simple compare like for the weapons...
jmnevil54
25 Aug 2018, 01:12You would go to the game start script. Or you would go to the player's attributes.
player.hp = 25
player.attack = 3
player.defense = 2
player.armour = 0
And so on.
hegemonkhan
25 Aug 2018, 06:1790% of everything you want to do in your game, requires you to learn about:
- Attribute usage
- the 'if' Script usage
this is not easy to learn for first time (new to coding), but once you do, as stated already, it opens up 90% of everything that you want to have within your game
here's just a quick example:
create ("animal") // creates an 'animal' Object
string_list_variable = Split ("lion;deer", ";") // creating a string list, as lists have items, and thus selection of those items
animal.type = StringListItem (string_list_variable, GetRandomInt (0,1)) // this selects one of the 2 ("lion" or "deer") items, and stores it in the 'type' String Attribute of the 'animal' Object
// either:
//
// animal.type = "lion"
// or
// animal.type = "deer"
// now, we check what type of animal, and have different events (in this example, the scripts are 'msg' Scripts which display their content/text/VARIABLES to the person playing the game) based upon what type the animal is:
if (animal.type = "lion") {
msg ("You run as fast as you can, and hope that you're faster than your buddy")
} else if (animal.type = "deer") {
msg ("Ah, it's a cute deer, you get out your phone, and take pictures of it")
}
here's a bunch of links/guides to help you get started with learning to use quest and to code with quest:
http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c
specifically, click on the 'hk attributes and if script guide' link and scroll down about halfway, looking for my 'the two super scripts' section, to get to the part on Attribute usage and then further down (to the end of the post of mine), for the part on the 'if' script usage
you may want to read the first part of the post, as I try to explain the terms and concepts involved, for a better understanding of all of this coding stuff.
also, you may want to first start with my ~ 'quest and code structure' link, as it helps with understanding quest's code structure, so you can directly put/write in code into your entire game code (if you learn this, it makes everything so much easier and faster, as well as being able to edit and/or troubleshoot any errors in your code, than in trying to use quest's GUI/Editor)
ask if you need any help, about anything, or need anything explained further and/or better
hegemonkhan
25 Aug 2018, 06:26(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)
here's another quick example:
create ("test")
test.alias = "test #1"
test.score = GetRandomInt (0,100)
// high to low checking:
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 you don't like the '-1' Value used in my example above (I like doing it this way, even though it's a bit more confusing, as it's less operations, I like being efficient with my code, if I can - within my limited coding ability, lol), you can do this too instead (it's the same as the above):
// high to low checking:
if (test.score >= 90) {
test.grade = "A"
} else if (test.score >= 80) {
test.grade = "B"
} else if (test.score >= 70) {
test.grade = "C"
} else if (test.score >= 60) {
test.grade = "D"
} else {
test.grade = "F"
}
// and... if you want/need to do...
// low to high checking:
if (test.score < 60) {
test.grade = "F"
} else if (test.score < 70) {
test.grade = "D"
} else if (test.score < 80) {
test.grade = "C"
} else if (test.score < 90) {
test.grade = "B"
} else {
test.grade = "A"
}
msg ("Test Name: " + test.alias)
msg ("Test Score: " + test.score)
msg ("Test Grade: " + test.grade)
// output/display:
Test Name: test #1
Test Score: [random selection of: 0 to 100]
Test Grade: [depending upon score, will have corresponding letter grade of: A to F)
LeftUnscarred
27 Aug 2018, 13:12DarkLizerd how would i code that to not let him be able to put it in his inventory then i got the stats runing for strength now but he can pick up every object no matter if i set the strength to 0 or not and could i use the same thing in issueing damage to a npc cause im really trying to make a dnd themed game i have only got 1 race and class rn but i want to get the stats situated before i do more i also want to know how to be able to make a new race and class for a diffrent character story but i dont know how to change the variables of the character either
im a total noob at this im sorry lol

DarkLizerd
28 Aug 2018, 03:50Set a "carry" limit...
player.CarryMax= player.Str*5 (or so, could be what you want...)
and player.Carry is the total weight of everything you are carrying right now.
Then, when the player picks something up:
if (player.Carry + thing.weight> player.CarryMax) {
msg ("You can't pick that up until you drop something else. ")
}
else {
player.Carry=player.Carry + thing.weight
(then add it to your inventory)
}
Then when the player drops it:
player.Carry=player.Carry - thing.weight
thing.weight is the weight of the "thing" you are trying to pick-up...
So, picking up a sword it would be sword.weight, getting a shield, shield.weight…
Altho, I think Quest may already have a lot of this already built in... But I'm not sure...
Altho, the better Quest programmers here, would use a loop checking for the total weight of everything you are carrying...
My background is in Basic, so that is how I think...
There is also the combat.lib that has most of the combat details already worked out... (Not my creation, so I can't help you there.)
You are doing good working this out for one race and one class (for now). Once you get that worked out, adding races and classes (IF you got the basics right) should be a cakewalk...)
mrangel
28 Aug 2018, 07:36There's already a tickbox somewhere on the features tab for making weight limits. I think once you've enabled it, you'd need to set the player's maxvolume to something based on their strength. For example, after modifying the player's strength, you could have the line:
game.pov.maxvolume = game.pov.strength * 5
.
There's no need to write code that replicates what the game already does.
However, it seems to me the OP was asking more about limiting which objects the player can pick up. So you can't pick up any object heavier than your strength, separate from your maximum encumbrance.
For that, you would either have to put a 'take' script on every object, or modify the core function DoTake
. Or, an alternative might be to create a turnscript:
foreach (object, ScopeReachableInventory()) {
if (HasInt (object, "required_strength")) {
if (object.required_strength > game.pov.strength) {
msg ("You are not strong enough to carry "+GetDisplayName(object)+". You drop it.")
if (GetBoolean (object, "worn")) {
RemoveGarment (object)
}
DoDrop(object)
}
}
}
Putting this in a turnscript means that you can pick up a too-heavy object but will immediately drop it again. It may behave oddly in some cases, though. What happens if a curse reduces the player's strength? This script will make them immediately drop items that are now too heavy… but in the case of cursed objects that can't be dropped, it might say "You drop it" and then not actually do so. How would you want it to behave in that case?
LeftUnscarred
28 Aug 2018, 12:10mrangel i would want it to maybe say that u try to drop this object but it wont let youmaybe even cause damage to happen scince your cursed im gonna try to work on getting the weight/strength thing working before i worry about that as i have no cursed objects in play now i need to find out how to code a npc health in so i dont one shot them with my dagger
ive been using if statements alot to kill someone like when i want tot kill someone i make a ver to attack the person and its like if object is visible then require object "knife" and say a mesege he has been killed, and make that object invisible so he cant be killed again
recently i have made a room i call a trash can that instead of making the object invisible i move them to the trashcan room but i still 1 shot all the creatures i create and i would like a turned based thing so they can attack back
right now i have it set that if object is in room then deal 1 damage to player for the turn script in the room but i would like to make that vary and i want to stop 1 shoting all the creatures and give them a heath bar that is noticible to the other player so they know when the creature is dead i also want to see about why i cant use the object when equipped it changes the name of the object to include worn in the name but i cant get the item to work when i try to use it on the creature that way is there a nother way i can code an attack on that creature
LeftUnscarred
28 Aug 2018, 12:42now when i try to go in the game and pick up the object i get the error code
Error running script: Error compiling expression 'player.strength = >3': SyntaxError: Unexpected token ">"; expected one of "-",
i cant find a way to fix that i have my strength set to 10 and the dagger set to 3 did i set it wrong i used the
player attribute equals(>3)
did i code that wrong i couldnt find a way to have it greater then or equal to so i typed in the grater then sign was that wrong
LeftUnscarred
28 Aug 2018, 13:10ok i tried to run it as an expression but i got the error code
Error running script: Error compiling expression 'player.str>dagger.str': CompareElement: Operation Greaterthan' is not defined for types 'Object' and 'Object'
whats wrong now
edited
ok i see what i did wrong there i didnt give the full atribbute name
i still need help with the first post i made today tho
mrangel
28 Aug 2018, 19:39recently i have made a room i call a trash can that instead of making the object invisible i move them to the trashcan room
This seems to be pretty common.
My preferred method is to move an object to null
(outside of any room) - this is what the RemoveObject
function actually does. If you have a lot of objects (especially if you're cloning them) this can end up making save files pretty large, as the stats of all the removed objects are still saved every time. But it means that if you remove an object and want it back, you can just move it back into a valid room.
With regard to combat, and calculating heath for monsters, I think someone else asked about that fairly recently. I posted some code off the top of my head, but haven't tested it properly myself yet.
But what you really need to master is using functions.
You want to make a function called DoAttack
or similar which takes 2 parameters; an attacker and a target. You can use the stats of the attacker and target to work out what the chance of hitting is, roll dice, work out the amount of damage dealt, and subtract that from the target's "health" attribute.
Your attack command will probably end up calling DoAttack (player, object)
; and the turnscript to make enemies attack would call DoAttack (enemy, player)
.
It's best to put things like this in a function, because then if you decide to change the mechanics, you only need to change them in one place. It also means that if the player decides to attack an ally, or if you later have monsters that might fight each other, it becomes a whole lot easier. This does, however, mean that the player and monsters should probably have the same attributes to represent statistics and health.
LeftUnscarred
28 Aug 2018, 23:28lol ummmm mrangel im a noob i have o clue what u said can u lead me step by step srry i get the feeling im an idiot at this
hegemonkhan
28 Aug 2018, 23:50(filler for getting my edited post, updated/posted)
@ Left Unscarred:
you're asking for doing some complex/advanced stuff (combat/RPG-stat-handling/skill-checking), which is going to be difficult for us to help you (and it forces us to create your game for you as you don't know how to apply our help on your own), when you don't even know the basics for doing this stuff:
- Attribute usage
- the 'if' Script usage
which, especially together, will enable you, yourself (and with some minor help from us), to do all of this stuff that you want to do in your game
I'd suggest you first learn about using Attributes, and then, in using them, with the 'if' Script, in learning to use the the 'if' Script
it's not easy to learn this stuff for the very first time, but in learning this stuff, it opens up 90% of everything that you want to do within your game
I have some links for helping with this stuff, here:
http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c
specifically, check out my 'hk attribute and if script guide' link (and scroll down past the first half as this just explains the basics of coding, though you should read this too, along with the other link 'quest structure and coding basics' too, to get to the rest of the post on using Attributes and then the 'if' Script)
also, here's a step by step walkthrough demo game guide to learning to use Attributes (including the built-in 'statusattributes' String Dictionary Attributes):
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375
HK edit:
here's another link that helps with the coding basics (quest code structure and its coding basics, Attribute usage, and the if' script usage):
http://textadventures.co.uk/forum/quest/topic/mu7itzjqv0yxrkdwgsbmzg/how-to-make-npc-confront-you-with-chioces#46cdb25b-4767-40a6-8bf4-3cd84e805781
try to follow and learn from these links, and ask us for help as you get stuck or need help with something or need something more or better explained
LeftUnscarred
28 Aug 2018, 23:51ok thanks hegemonkahn ill go read thoes
hegemonkhan
29 Aug 2018, 00:31I was a total noob at coding (and game making) myself, but through quest, I've learned to code, and am taking programming classes in college now
you can see my own struggles with learning to code (and game making) with quest, when I first started out, having found quest ~ 5+ years ago:
(learning to code, and game make, is NOT easy !!! I know what it's like... being a total noob to all of this stuff, and everything doesn't make any sense and is so OVER-whelming)
https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread
it's a good laugh, going back and looking at how stupid I too was, not even understand the terms/Elements/Data-Types and etc...
I've come a long way since then, and it's all thanks to quest and the helpful members here over the years.
LeftUnscarred
29 Aug 2018, 00:46lol i think i understand the termenology some but using it in my own way is what i dont know how to do hegemonkhan the artical u have me looking at is helping alot but mainly just with knowing terminology i havent read it all yet but ill try to post on here again if i have an issue
LeftUnscarred
29 Aug 2018, 01:45hey hegemonkhan i was looking through an old thing u did and i found what i wanted but theres an issue
heres what you wrote
and lastly, for testing of our status attributes for changing Attributes' Values:
'room' Room Object -> 'Objects' Tab -> Add -> (see below, repeat as needed)
Object Name: increase_game_strength
Object Name: decrease_game_strength
Object Name: increase_player_strength
Object Name: decrease_player_strength
Object Name: increase_game_current_life
Object Name: decrease_game_current_life
Object Name: increase_game_maximum_life
Object Name: decrease_game_maximum_life
Object Name: increase_player_current_life
Object Name: decrease_player_current_life
Object Name: increase_player_maximum_life
Object Name: decrease_player_maximum_life
'increase_game_strength' Object -> 'Verbs' Tab -> add -> Verb Name: increase -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable game.strength = [expression] game.strength + 10
'decrease_game_strength' Object -> 'Verbs' Tab -> add -> Verb Name: decrease -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable game.strength = [expression] game.strength - 10
'increase_player_strength' Object -> 'Verbs' Tab -> add -> Verb Name: increase -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable player.strength = [expression] player.strength + 10
'decrease_player_strength' Object -> 'Verbs' Tab -> add -> Verb Name: decrease -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable player.strength = [expression] player.strength - 10
'increase_game_current_life' Object -> 'Verbs' Tab -> add -> Verb Name: increase -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable game.current_life = [expression] game.current_life + 100
'decrease_game_current_life' Object -> 'Verbs' Tab -> add -> Verb Name: decrease -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable game.current_life = [expression] game.current_life - 100
'increase_game_maximum_life' Object -> 'Verbs' Tab -> add -> Verb Name: increase -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable game.maximum_life = [expression] game.maximum_life + 100
'decrease_game_current_life' Object -> 'Verbs' Tab -> add -> Verb Name: decrease -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable game.maximum_life = [expression] game.maximum_life - 100
'increase_player_current_life' Object -> 'Verbs' Tab -> add -> Verb Name: increase -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable player.current_life = [expression] player.current_life + 100
'decrease_player_current_life' Object -> 'Verbs' Tab -> add -> Verb Name: decrease -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable player.current_life = [expression] player.current_life - 100
'increase_player_maximum_life' Object -> 'Verbs' Tab -> add -> Verb Name: increase -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable player.maximum_life = [expression] player.maximum_life + 100
'decrease_player_current_life' Object -> 'Verbs' Tab -> add -> Verb Name: decrease -> (see below)
add new script -> variables -> 'set a variable or attribute' Script -> set variable player.maximum_life = [expression] player.maximum_life - 100
and hopefully this all works for you! save your game file, and play~study~test it! (HK crosses fingers that he's got no mistakes, lol)
this is what i needed i know how to set the atributes just fine. my issue is changing them when i hit the monster or when it hits me i have my stuff set up but this makes me make a new object for each room is there a way i can set the verb inside my object like to attack the human i have a verb made in the human running this code
if (Got(KNIFE)) {
HUMAN.HP = - player.attack
if (HUMAN.HP = 0) {
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
}
else {
if (not Got(KNIFE)) {
player.hp = - 2
}
}
i have my player.attack set too 2 cause my knife changes that the human.hp is set to 10 but if i try to attack him with that code it kills him instantly instead of just causing him to be at 8 hp actually looking at it it makes his hp equal -2 after i do that so i think thats how he dies and gets "thrown away" what is wrong with the code i just want to be able to change his health correctly based on what my attack which is set b y my knife when i pick it up and set again when i drop it??
hegemonkhan
29 Aug 2018, 03:40(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)
ya, once you got down the concepts... it's still another step in actually understanding them well enough to apply them on your own... I had the same issue too. I thought I understood stuff, as I understood the examples given to me, but when I went to try to do something on my own of those things I thought I understood, I learned that I really didn't understand those things, as I wasn't able to apply those things to the things that I wanted to do on my own in my game.
ah, okay....
this is what you got:
if (Got(KNIFE)) {
HUMAN.HP = - player.attack
if (HUMAN.HP = 0) {
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
} else {
if (not Got(KNIFE)) {
player.hp = - 2
}
}
you need to change it to this:
(however, you got another mistake, a logic mistake, and it can be cleaned up a bit too, see the next section below this one)
if (Got(KNIFE)) {
HUMAN.HP = HUMAN.HP - player.attack // LOGIC ISSUE (this allows for your 'HUMAN.HP' to be reduced below '0')
if (HUMAN.HP = 0) { // LOGIC ISSUE (this is ONLY checking if HUMAN.HP equals EXACTLY '0', yet as your code is currently, the above line can drop your hp below '0', thus having a 'LOGIC ISSUE', which will cause in-game errors: you don't die despite having life/hp below 0, you can ONLY die if you have exactly '0' life/hp)
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
} else {
if (not Got(KNIFE)) { // this line isn't needed, as the 'else' itself handles it already
player.hp = player.hp - 2
}
}
here's the fully fixed code:
if (Got(KNIFE)) {
HUMAN.HP = HUMAN.HP - player.attack
if (HUMAN.HP < 1) {
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
} else {
player.hp = player.hp - 2
// not sure if how you want to handle this as not sure exactly what design/method you're doing (look at the 'HUMAN.HP' above)
}
or (alternative, controlling and easily editing/changing the range/bounds of stats/Attributes):
// These Attributes need to be created/added/set (you can change the Values of them to whatever you want, and/or change their label/name, but then you got to match the rest of the code to whatever names/labels you give these Attributes):
//
// HUMAN.HP_minimum = 0
// HUMAN.HP_maximum = 999
if (Got(KNIFE)) {
HUMAN.HP = HUMAN.HP - player.attack
if (HUMAN.HP < HUMAN.HP_minimum) {
HUMAN.HP = HUMAN.HP_minimum
} else if (HUMAN.HP > HUMAN.HP_maximum) {
HUMAN.HP = HUMAN.HP_maximum
}
if (HUMAN.HP = HUMAN.HP_minimum) {
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
} else {
player.hp = player.hp - 2
// not sure if how you want to handle this as not sure exactly what design/method you're doing (look at the 'HUMAN.HP' above)
}
why you're instantly dying:
HUMAN.HP = - player.attack
// and:
player.hp = -2
// you're directly setting your 'HUMAN.HP' to directly have/be/set-to (whatever is) as the negative of the Value being stored within the 'player.attack' Attribute, instead of decrementing (subtracting) it by (whatever is) the Value being stored within the 'player.attack' Attribute
// and:
// you're directly setting your 'player.hp' to have negative 2 life (HP), instead of decrementing (subtracting) it by 2
// you're STORING the '-2' Value into the 'player.hp' Attribute
concept of how it works:
The Assignment Operation (a programming operation):
storing a direct/literal Value (or ultimately a Value after/from calculating/evaluating/completing an expression) ON THE RIGHT SIDE (required) of the Assignment Operator (=), INTO the VARIABLE, ON THE LEFT SIDE (required) of the Assignment Operator (=)
// VARIABLE <=(stored into)== VALUE_OR_EXPRESION
directly in code (slightly different syntax than in the GUI/Editor):
VARIABLE = VALUE_OR_EXPRESSION
in GUI/Editor (slightly different syntax than directly in code):
set variable VARIABLE = [EXPRESSION] VALUE_OR_EXPRESSION
examples (I'll use the GUI/Editor's syntax to make it easier for you):
set variable player.strength = [EXPRESSION] 100
// the '100' Integer Value is STORED INTO the 'strength' Integer Attribute of the default 'player' Player Object
// quest is able to parse the Value, knowing what Data Type is the Value (String, Integer, Double, Boolean, Script, Object reference/pointer, List, Dictionary, etc), and thus makes the Attribute into the same Data Type (which is required: Attribute Type MUST match the Value Type) automatically for you
set variable player.strength = [EXPRESSION] 50
// the '50' Integer Value is STORED INTO the 'strength' Integer Attribute of the default 'player' Player Object (which the '50' Value replaces/over-rides/over-writes the old '100' Value stored into the 'player.strength' Attribute)
now let's look at some more complex expressions...
Arithmetic Operations:
Addition:
set variable player.strength = [EXPRESSION] player.strength + 5
// creating the Attribute and setting its initial Value of the 'player.strength' Attribute:
//
// set variable player.strength = [EXPRESSION] 0
set variable player.strength = [EXPRESSION] player.strength + 5
// how it works (Assignment Operation):
//
// initial Value: player.strength = 0
//
// old Value: player.strength = 0
//
set variable player.strength = [EXPRESSION] player.strength + 5
// set variable player.strength (NEW) = [EXPRESSION] player.strength (OLD: 0) + 5
// set variable player.strength (NEW) = [EXPRESSION] (0) + 5
// set variable player.strength (NEW) = [EXPRESSION] 5
//
// new value: player.strength = 5
//
// old value: player.strength = 5
//
set variable player.strength = [EXPRESSION] player.strength + 5
// set variable player.strength (NEW) = [EXPRESSION] player.strength (OLD: 5) + 5
// set variable player.strength (NEW) = [EXPRESSION] (5) + 5
// set variable player.strength (NEW) = [EXPRESSION] 10
//
// new value: player.strength = 10
//
// old value: player.strength = 10
//
set variable player.strength = [EXPRESSION] player.strength + 5
// set variable player.strength (NEW) = [EXPRESSION] player.strength (OLD: 10) + 5
// set variable player.strength (NEW) = [EXPRESSION] (10) + 5
// set variable player.strength (NEW) = [EXPRESSION] 15
//
// new value: player.strength = 15
//
// old value: player.strength = 15
//
set variable player.strength = [EXPRESSION] player.strength + 5
// set variable player.strength (NEW) = [EXPRESSION] player.strength (OLD: 15) + 5
// set variable player.strength (NEW) = [EXPRESSION] (15) + 5
// set variable player.strength (NEW) = [EXPRESSION] 20
//
// you get the idea now....
Subtraction:
set variable player.strength = [EXPRESSION] player.strength - 7
Multiplication:
set variable player.strength = [EXPRESSION] player.strength * 3
Division:
set variable player.strength = [EXPRESSION] player.strength / 2
Modulus (Division, but it finds/gets/returns the REMAINDER):
set variable player.strength = [EXPRESSION] player.strength % 4
example of a more complex expression (in code, for this example, I'm lazy):
create ("katana") // creates a 'katana' Object
katana.damage = 50 // set variable katana.damage = [EXPRESSION] 50
player.weapon = katana // the 'player.weapon' Attribute is an Object reference/pointer to the 'katana' Object
// in GUI/Editor: set variable player.weapon = [EXPRESSION] katana
player.strength = GetRandomInt (0,100) // randomly selects a Value from '0' to '100', which gets STORED INTO the 'player.strength' Attribute, the 'GetRandomInt (MIN_VALUE,MAX_VALUE)' is one of the built-in Randomization Functions
// in GUI/Editor: set variable player.strength = [EXPRESSION] GetRandomInt (0,100)
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// in GUI/Editor: set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// if player.strength = 100:
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (100) / 100 = (50) + (50) * 1 = (50) + 50 = 100
// if player.strength = 0:
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (0) / 100 = (50) + (50 * 0) = (50) + 0 = 50
// if player.strength = 50:
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (50) / 100 = (50) + (50) * 1/2 = (50) + 25 = 75
// if player.strength = 75:
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (75) / 100 = (50) + (50) * 3/4 = (50) + 75/2 = (50) + ~37 = ~87
// if player.strength = 25:
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (25) / 100 = (50) + (50) * 1/4 = (50) + 25/2 = (50) + ~12 = ~62
hegemonkhan
29 Aug 2018, 04:08P.S.
to do the 'code box' in posts:
m```
(paste code and/or wall of text, lol, here)
m```
but without the m's in front of it!
those weird characters/symbols is the keyboard key in the upper left corner of the keyboard, to the left of the '1' key of the horizontal row of numbers at top of keyboard, and above the left TAB key, and the tilde (~) character is shared with this same key (if you hold down shift and press this key, you get the tilde character/symbol), otherwise, you get these weird characters/symbols, which is how to do the 'code box' in posts on this site
which will look like this:
(paste code and/or wall of text, lol, here)
and the reason why using the code boxes are so nice, is because it preserves the formatting of it
hegemonkhan
29 Aug 2018, 04:48for some more advanced design methods:
create and put an (un-drop-able) 'action' (and if want an 'info') Object(s) within the 'player' Player Object, and create/add whatever Verbs (Verbs are actually just Script Attributes with extra coding for the 'Verb' features: hyperlink buttons and etc handling. Also Verbs are just specialized Commands, in that their parent Object is used for their scripting, instead of being able to use whatever Object: Verbs use static Objects, Commands can use dynamic Objects) for it (them):
(but you then got to use the scripting to handle what Objects to look/get and etc handling of what you want to do)
<object name="room">
<inherit name="editor_room" />
</object>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_room" />
<attr name="parent" type="object">room</attr>
</object>
<object name="info">
<attr name="parent" type="object">player</attr>
<attr name="drop" type="boolean">false</attr>
<attr name="take" type="boolean">false</attr>
<inventoryverbs type="stringlist">
<value>stats</value>
<value>skills</value>
<value>appearance</value>
<value>equipment</value>
<value>magic</value>
<value>items</value>
<value>storage</value>
</inventoryverbs>
<attr name="stats" type="script">
// whatever scripting
</attr>
<attr name="skills" type="script">
// whatever scripting
</attr>
<attr name="appearance" type="script">
// whatever scripting
</attr>
<attr name="equipment" type="script">
// whatever scripting
</attr>
<attr name="magic" type="script">
// whatever scripting
</attr>
<attr name="items" type="script">
// whatever scripting
</attr>
<attr name="storage" type="script">
// whatever scripting
</attr>
</object>
<object name="action">
<attr name="parent" type="object">player</attr>
<attr name="drop" type="boolean">false</attr>
<attr name="take" type="boolean">false</attr>
<inventoryverbs type="stringlist">
<value>talk</value>
<value>explore</value>
<value>skills</value>
<value>equipment</value>
<value>magic</value>
<value>items</value>
<value>storage</value>
<value>fight</value>
</inventoryverbs>
<attr name="talk" type="Script">
// whatever scripting
</attr>
<attr name="explore" type="Script">
// whatever scripting
</attr>
<attr name="skills" type="Script">
// whatever scripting
</attr>
<attr name="equipment" type="script">
// whatever scripting
</attr>
<attr name="magic" type="script">
// whatever scripting
</attr>
<attr name="items" type="script">
// whatever scripting
</attr>
<attr name="storage" type="script">
// whatever scripting
</attr>
<attr name="fight" type="Script">
// whatever scripting
</attr>
</object>
<verb>
<property>talk</property>
<pattern>talk</pattern>
<defaultexpression>You can't talk to that!</defaultexpression>
</verb>
<verb>
<property>explore</property>
<pattern>explore</pattern>
<defaultexpression>You can't explore here!</defaultexpression>
</verb>
<verb>
<property>stats</property>
<pattern>stats</pattern>
<defaultexpression>You can't view the stats of that!</defaultexpression>
</verb>
<verb>
<property>skills</property>
<pattern>skills</pattern>
<defaultexpression>You can't view the skills of that!</defaultexpression>
</verb>
<verb>
<property>appearance</property>
<pattern>appearance</pattern>
<defaultexpression>You can't view the appearance of that!</defaultexpression>
</verb>
<verb>
<property>equipment</property>
<pattern>equipment</pattern>
<defaultexpression>You can't view the equipment of that!</defaultexpression>
</verb>
<verb>
<property>magic</property>
<pattern>magic</pattern>
<defaultexpression>You can't view the magic of that!</defaultexpression>
</verb>
<verb>
<property>items</property>
<pattern>items</pattern>
<defaultexpression>You can't view the items of that!</defaultexpression>
</verb>
<verb>
<property>storage</property>
<pattern>storage</pattern>
<defaultexpression>You can't view the storage of that!</defaultexpression>
</verb>
<verb>
<property>fight</property>
<pattern>fight</pattern>
<defaultexpression>You can't fight that!</defaultexpression>
</verb>
so in your inventory pane as Objects and their verb buttons:
info object
-> stats verb button
-> skills verb button
-> appearance verb button
-> equipment verb button
-> magic verb button
-> items verb button
-> storage verb button
action object
-> talk verb button
-> explore verb button
-> equipment verb button
-> magic verb button
-> items verb button
-> storage verb button
-> fight verb button
or, you can just use/create Commands, as well
this was only a brief post of more advanced options/methods, but you'll need help with how to do the scripting for them, which I didn't get into within this post (I am lazy).
I can go into much more complete detail on this stuff, if you're interested, just let me know, and I will help with the scripting.
LeftUnscarred
29 Aug 2018, 12:37hey hegemonkhan thank you for your help. i toticed you gave me the fixed code of
if (Got(KNIFE)) {
HUMAN.HP = HUMAN.HP - player.attack
if (HUMAN.HP < 1) {
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
} else {
player.hp = player.hp - 2
// not sure if how you want to handle this as not sure exactly what design/method you're doing (look at the 'HUMAN.HP' above)
}
well i copy pasted that into the code view of the editor and it changed the code to me writing a call function
heres what the code looks like
if (Got(KNIFE)) {
HUMAN.HP = HUMAN.HP - player.attack
if (HUMAN.HP < 1) {
MoveObject (HUMAN, TRASH CAN)
msg ("The human has died and gone to a better place")
}
it looks the excast same but it makes it into a call function script i dont know if that was intended but its now saying it dont recognize the function and i have absolutely no clue what to do to make a function work any help will be appreciated

DarkLizerd
29 Aug 2018, 20:332 open braces {
but only 1 close }
Too easy to over look in an unforgiving language like Quest...
BASIC does not have that problem... Just different ones...
hegemonkhan
30 Aug 2018, 04:05@ Left Unscarred:
let's create a new text adventure game, to practice/learn how to do simple combat, so, you can understand at how to do this stuff correctly.
-
create a new text adventure game
-
save it as whatever, and save it somewhere you can easily find it (such as the desktop)
-
create/add the needed Attributes for simple combat to your 'player' Player Object:
'player' Player Object -> 'Attributes' Tab -> Attributes (box at the bottom) -> Add -> (see below)
(Object Name: player)
Attribute Name: currency
Attribute Type: int
Attribute Value: 0
(Object Name: player)
Attribute Name: condition
Attribute Type: string
Attribute Value: normal
(Object Name: player)
Attribute Name: life
Attribute Type: string
Attribute Value: 999/999
(Object Name: player)
Attribute Name: life_current
Attribute Type: int
Attribute Value: 999
(Object Type Name: character_type)
Attribute Name: life_minimum
Attribute Type: int
Attribute Value: 0
(Object Name: player)
Attribute Name: life_maximum
Attribute Type: int
Attribute Value: 999
(Object Name: player)
Attribute Name: weapon_alias
Attribute Type: string
Attribute Value: unarmed
(Object Name: player)
Attribute Name: weapon
Attribute Type: object
Attribute Value: unarmed // we need to create/add an 'unarmed' Object, we'll do/cover this further down
(Object Name: player)
Attribute Name: changedweapon
Attribute Type: script
Attribute Value: (see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
this.weapon_alias = GetDisplayAlias (this.weapon.name)
(Object Name: player)
Attribute Name: changedlife_current
Attribute Type: script
Attribute Value: (see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
if (this.life_current > this.life_maximum) {
this.life_current = this.life_maximum
} else if (this.life_current < this.life_minimum) {
this.life_current = this.life_minimum
}
this.life = this.life_current + "/" + this.life_maximum
if (this.life_current = this.life_minimum) {
this.condition = "dead"
msg ("You're dead")
}
(Object Name: player)
Attribute Name: changedlife_maximum
Attribute Type: script
Attribute Value: (see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
if (this.life_maximum <= this.life_minimum) {
msg ("ERROR: game.pov.life_maximum can't be lesser than or equal to game.pov.life_minimum")
finish
} else if (this.life_current > this.life_maximum) {
this.life_current = this.life_maximum
}
this.life = this.life_current + "/" + this.life_maximum
(Object Name: player)
Attribute Name: changedlife_minimum
Attribute Type: script
Attribute Value: (see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
if (this.life_minimum >= this.life_maximum) {
msg ("ERROR: game.pov.life_minimum can't be greater than or equal to game.pov.life_maximum")
finish
}
'player' Player Object -> 'Attributes' Tab -> Status Attributes (box at the top) -> Add -> (see below, repeat as needed)
(Object Name: player)
(Status Attribute Item 1)
(item 1 input: key, as a string): Attribute Name: life
(item 1 output: value, as a string): Format String: Life: !
(Object Name: player)
(Status Attribute Item 2)
(item 2 input: key, as a string): Attribute Name: currency
(item 2 output: value, as a string): Format String: Currency: !
(Object Name: player)
(Status Attribute Item 3)
(item 3 input: key, as a string): Attribute Name: condition
(item 3 output: value, as a string): Format String: Condition: !
(Object Name: player)
(Status Attribute Item 4)
(item 4 input: key, as a string): Attribute Name: weapon_string
(item 4 output: value, as a string): Format String: Weapon: !
- create/add the needed Objects for our simple combat:
'room' Room Object -> 'Objects' Tab -> Add -> (see below, repeat as needed)
Object Name: katana
Object Name: club
Object Name: orc
'Objects' main/root/top Object (we do NOT want to add the 'unarmed' Object to a Room Object, nor to another other Object) -> 'Objects' Tab -> Add -> (see below, repeat as needed)
Object Name: unarmed
for all of these 4 Objects, set them as:
'(unarmed/katana/club/orc)' Object -> 'Setup' Tab -> Type: Object
- create/add the needed Attributes for simple combat to your 'orc' enemy/monster/hostile-npc Object:
'orc' Object -> 'Attributes' Tab -> Attributes (box at the bottom) -> Add -> (see below, repeat as needed)
(Object Name: orc)
Attribute Name: currency
Attribute Type: int
Attribute Value: 100
(Object Name: orc)
Attribute Name: condition
Attribute Type: string
Attribute Value: normal
(Object Name: orc)
Attribute Name: weapon
Attribute Type: object
Attribute Value: club
(Object Name: orc)
Attribute Name: life_current
Attribute Type: int
Attribute Value: 500
(Object Name: orc)
Attribute Name: life_maximum
Attribute Type: int
Attribute Value: 500
(Object Name: orc)
Attribute Name: life_minimum
Attribute Type: int
Attribute Value: 0
- create/add the needed Verb for simple combat to your 'orc' enemy/monster/hostile-npc Object:
'orc' Object -> 'verbs' Tab -> Add -> (see below, repeat as needed)
Verb Name: fight
change the drop-down box to: [run a script]
(see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
if (game.pov.condition = "dead") {
msg ("You are dead, silly")
} else if (this.condition = "dead") {
msg ("The " + GetDisplayAlias (this.name) + " is already dead, silly")
} else {
ClearScreen
msg ("Player's Life: " + game.pov.life)
msg (GetDisplayAlias (this.name) + "'s Life: " + this.life_current + "/" + this.life_maximum)
this.life_current = this.life_current - game.pov.weapon.damage
msg ("You attack the " + GetDisplayAlias (this.name) with your " + game.pov.weapon.name + ", doing " + game.pov.weapon.damage + " damage to the " + GetDisplayAlias (this.name))
msg ("Player's Life: " + game.pov.life)
msg (GetDisplayAlias (this.name) + "'s Life: " + this.life_current + "/" + this.life_maximum)
if (this.life_current < this.life_minimum) {
this.life_current = this.life_minimum
}
if (this.life_current = this.life_minimum) {
this.condition = "dead"
msg ("You killed the " + GetDisplayAlias (this.name) + "!")
} else {
game.pov.life_current = game.pov.life_current - this.weapon.damage
msg ("The " + GetDisplayAlias (this.name) + " attacks you with its " + GetDisplayAlias (this.weapon.name) + ", doing " + this.weapon.damage + " damage to you")
if (game.pov.condition = "dead") {
msg ("The " + GetDisplayAlias (this.name) + " killed you!")
} else {
invoke (this.fight) // this calls/does/activates the 'fight' Verb (which is actually a 'fight' Script Attribute of the 'this' (this = orc) Object: this.fight, but which also has extra code for Verb functionality) again: we're looping the 'this.fight' Verb/Script_Attribute, which will continue until one of you is dead
}
}
}
Verb Name: loot
change the drop-down box to: [run a script]
(see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
if (this.condition = "dead") {
firsttime {
weapon_variable = this.weapon
MoveObject (weapon_variable, player)
this.weapon = unarmed
game.pov.currency = game.pov.currency + this.currency
this.currency = 0
msg ("You loot the dead " + GetDisplayAlias (this.name) + "'s corpse, taking its " + GetDisplayAlias (this.weapon.name) + ", and its + this.currency + " currency")
} otherwise {
msg ("You already looted the dead " + GetDisplayAlias (this.name) + "'s corpse, silly")
}
} else {
msg ("The " + GetDisplayAlias (this.name) + "'s still alive, silly")
}
- removing the default 'take' Verb from the 'orc' Object:
'orc' Object -> 'Object' Tab -> Display Verbs -> Take -> Delete
- create/add the needed Attributes for simple combat to the 'unarmed', 'katana', and 'club' Objects:
'(unarmed/katana/club)' Object -> 'Attributes' Tab -> Attributes (box at the bottom) -> Add -> (see below, repeat as needed)
(Object Name: unarmed)
Attribute Name: damage
Attribute Type: int
Attribute Value: 10
(Object Name: club)
Attribute Name: damage
Attribute Type: int
Attribute Value: 50
(Object Name: katana)
Attribute Name: damage
Attribute Type: int
Attribute Value: 100
- create/add the needed Verbs for simple combat to the 'unarmed', 'katana', and 'club' Objects:
'(unarmed/katana/club)' Object -> 'Verbs' Tab -> Add -> (see below, repeat as needed)
Verb Name: equip
change the drop-down box to: [run a script]
(see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
list add (player.weapon.inventoryverbs, "equip")
list remove (player.weapon.inventoryverbs, "unequip")
list add (player.weapon.inventoryverbs, "drop")
if (not this.parent = game.pov.name and not this = unarmed) {
MoveObject (this.name, game.pov.name)
}
game.pov.weapon = this
list remove (this.inventoryverbs, "equip")
list remove (this.inventoryverbs, "drop")
if (not this = unarmed) {
list add (this.inventoryverbs, "unequip")
}
msg ("You equip the " + GetDisplayAlias (this) + " weapon")
Verb Name: unequip
(do NOT add this 'unequip' Verb to the 'unarmed' Object)
change the drop-down box to: [run a script]
(see below, click on the 'code view' button in the script button menu at the bottom of the screen to go into code view for this specific Script Attribute, so you can just copy and paste my code below into it)
list add (this.inventoryverbs, "equip")
list remove (this.inventoryverbs, "unequip")
list add (this.inventoryverbs, "drop")
this.weapon = unarmed
msg ("You unequip the " + this.name + " weapon")
hopefully this is complete and there's no errors... HK crosses his fingers....
(let me know if there's any issues with it!)