Crash course on attributes?

ezekieljd
Can somebody just give me a quick rundown on how to use and MAKE attributes in Quest? Basically, I'm trying to give my player an attribute called "Security" that's almost exactly like eating food, where the player can take an item and gain a higher security clearance. Except if they drop it, they lose the security clearance. But I just don't understand how to MAKE these attributes!

TinFoilMkIV
first off, are you using the web editor or the downloaded editor?

Currently attributes can only be edited in the downloaded version of quest, the web editor won't let you create or change attributes.

ezekieljd
TinFoilMkIV wrote:first off, are you using the web editor or the downloaded editor?

Currently attributes can only be edited in the downloaded version of quest, the web editor won't let you create or change attributes.


Yep I'm using the downloaded version.

TinFoilMkIV
Try reading through this then
http://docs.textadventures.co.uk/quest/ ... butes.html

that's part of the basic quest tutorial where they start talking about attributes. You can also start from the beginning of it if you have problems following what they already setup.


Basically each object (rooms count as objects) has an attribute tab. You can create a new attribute with the + button that says add attribute. Then you name it and set what kind of info it holds. That's literally all there is to creating a new attribute. An attribute can hold pretty much anything, from a number value to a string of text and even code.

For your specific security example, you can use a boolean, which is a true/false value, and have it set to true while you have to specified item, then false if you lose that item for whatever reason. Also you'll want it to default to false, which I believe all boolean attributes do.

If you want various levels of security you can use an integer value and have your items add/subtract from your value and then just check if it's above the required level to enter an area.

HegemonKhan
HK's Attribute Comprehensive Guide:

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

within your question, due to not understanding Attributes (not your fault), you're describing a bit of a conflict between whether to use an Object, an Attribute, or an Object+Attribute.

So, let's just use an Attribute, as that is what you want to learn about using. Thus there's no 'dropping' as there's no 'item' (an Object) involved.

-----------

I like to describe quest's (and many other) code structure(s) in this way:

real world's tri-structure:

1. matter: the physical stuff, examples: 'HK' and 'Exekieljd'
2. energy~forces~waves: actions, example: talking
3. traits~characteristics~properties~data~info: male (HK is a male) or wet (water is wet) or bright (the sun is bright)

human's English language's tri-structure:

1. nouns
2. verbs
3. adjectives and~or adverbs

quest's code tri-structure:

Object-Oriented Programming (OOP)

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

1. OOP's OBJECTS: Elements (Objects, Exits, Functions, Verbs, Commands, Turnscripts, Timers, Object Types, etc): http://docs.textadventures.co.uk/quest/elements/

ya, the terminology is a bit confusing at this more technical level (hence my use of all caps OBJECT vs quest's Object), all you need to know is that the Elements (Objects, Exits, Verbs, Functions, etc) are your 'physical things', an Object is just one of those 'physical things'.

Objects: holds~contains Attributes and~or other Objects

Exits: connectors of Room Objects, holds~contains Attributes

Functions: holds~contains scripting and Attributes

Verbs: local ~ individual Object's Script Attributes: holds~contains scripting. Technically, this is actually a specialized (individual Objects) sub-Command

Commands: global, able to use input by the person playing the game, holds~contains scripting and Attributes

Turnscripts: basically (depending on the settings) an always activating~executing~running Function, on the quest engine's 'turn' underlying code

Timers: same as Turnscripts, except uses real time (seconds) for when (at intervals) it activates~executes~runs

Object Types: holds~contains Attributes and~or other Object Types (as Inherited Attributes)

etc Elements: too lazy to get into them

four types of Objects:

(1) Game Object: the 'game' Game Object: a special Object, which contains~holds the global settings (Attributes) for your game
(2) Player Objects: the controllable Objects (RPG term: pcs: playable characters) by the person playing the game: the default is the 'player' Player Object
(3) Room Objects: self-explanatory functionality (Exits connect Room Objects)
(4) (Other: non-player, non-room) Objects: these are everything else: npcs (RPG term: non-playable characters), furniture, trees, RPG items, equipment, etc

(5) 'Other'+Room Objects: have both functionalities

example of Objects and their Attributes:

<object name="room">
<inherit name="editor_room" />
<alias>home</alias>
<description>This is HK's home.</description>
<attr name="tidyness_state_string_attribute" type="string">messy</attr>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<alias>HK</alias>
<attr name="sex_string_attribute" type="string">male</attr>
<object name="sword_1">
<inherit name="editor_object" />
<alias>claymore</alias>
<attr name="damage_integer_attribute" type="int">50</attr>
</object>
</object>
</object>


the special 'game' Game Object in code below, corresponds to the GUI~Editor's:

'game' Game Object ( left side's 'tree of stuff', click on it to highlight~choose it ) -> (right side) -> various Tabs -> various options~settings (Attributes)

<game name="xxx">
<gameid>xxx</gameid>
<firstpublished>2015</firstpublished>
<version>1.0</version>
<author>xxx</author>
<category>xxx</category>
<description>xxx</description>
<subtitle>xxx</subtitle>
// etc Attributes
</game>


2. Scriptings (code lines of action~events):

http://docs.textadventures.co.uk/quest/functions/ (categorical order)
http://docs.textadventures.co.uk/quest/ ... tions.html (alphabetical order)
http://docs.textadventures.co.uk/quest/scripts/
http://docs.textadventures.co.uk/quest/ ... cript.html

the main containers of scriptings:

(GUI~Editor: run as script -> add a~new script -> etc)

(Objects) -> Script Attributes: http://docs.textadventures.co.uk/quest/ ... cript.html
Functions
Verbs (GUI~Editor): these are actually just an Object's Script Attributes (see two lines above)
Commands
Turnscripts
Timers

the two SUPER SCRIPTS, which especially when used together, lets you do 90% of everything that you want to do in~for your game:

(1) the GUI~Editor's 'set a variable or attribute' Script:

this let's you set~create, re-set, add~remove, and~or change~alter~adjust any Attribute (during the game)

run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> (set it up)

and, JUST FOR INITIAL CREATION~SET'ting ONLY (before the game begins):

'whatever' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: whatever)
Attribute Name: whatever
Attribute Type: (String, Boolean, Integer, Double, Script, Lists, Dictionaries, etc)
Attribute Value: (whatever, but depends upon the Attribute Type, of course)

in code:

Object_name.Attribute_name = Value_or_Expression

examples:

game.game_event_flag_state_integer_attribute = 0
game.game_event_flag_state_integer_attribute = game.game_event_flag_state_integer_attribute + 1
player.strength_integer_attribute = 3
player.offense = player.strength + player.endurance
player.damage_double_attribute = 37.21 // or it's: "37.21" // I haven't worked with Doubles at all, so I don't know if they need the double quotes or not
player.parent = room
player.parent = room2
orc.dead_boolean_attribute = false
orc.dead_boolean_attribute = true
HK.favorite_color_string_attribute = "black"
HK.favorite_colors_stringlist_attribute = split ("black;red", ";")

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

etc etc etc examples

(2) the GUI~Editor's 'if' Script:

this lets you act upon conditions~scenarios, the examples below will make more sense of this for you

run as script -> add a~new script -> scripts -> 'if' Script -> (set it up)

in code (example in optional full form):

OPERATORS:

Addiition: +
Subtraction: -
Multiplication: *
Division: /
Equals: =
Not Equals A: <>
Not Equals B: not Object_name.Attribute_name = Value_or_Expression
Greater Than: >
Lesser Than: <
Greater Than or Equals to: >=
Lesser Than or Equals to: <=
String Comparison: =
*Concatinating (literally putting things together): +
bitwise and: and
bitwise xor~or: or
bitwise not: not

*Concatinating:
Math: 5+4 ===> 9
Math: 5+5+5+5 ===> 20
Math: 5+"5" ===> ERROR!
Math: 5+"Mama" ===> ERROR!
Math: "Mama"+"Mia" ===> ERROR!
~VS~
Concatinating: "5"+"4" ===> "54"
Concatinating: "5"+"5"+"5"+"5" ===> "5555"
Concatinating: "5"+"Mia" ===> "5Mia"
Concatinating: "Mama"+"Mia" ===> "MamaMia"
Concatinating: "Mama"+""+"Mia" ====> "Mama Mia"


examples:

if (Object_name.Attribute_name OPERATOR Value_or_Expression) {
// whatever scripting
}
else if (Object_name.Attribute_name OPERATOR Value_or_Expression) {
// whatever scripting
}
// etc 'else ifs' if you want~need more
else {
// whatever scripting
}

if (orc.dead = true) {
msg ("The orc is already dead, silly.")
} else if (orc.dead = false) {
msg ("You attack and kill the orc.")
orc.dead = true
}

if (player.condition = "poisoned") {
player.life = player.life - 50
msg ("The poison damages you for 50 hp.")
} else if (player.condition = "paralyzed") {
msg ("You are paralyzed, unable to move, nor able to do anything.")
} else if (player.condition = "dead") {
msg ("You were killed or died.")
msg ("GAME OVER")
finish
}

if (player.strength_integer > 100) {
player.strength_integer = 100
} else if (player.strength_integer < 0) {
player.strength_integer = 0
}
if (player.strength_integer >= 67) {
player.strength_string = "strong"
} else if (player.strength_integer < 67 and player.strength_integer > 33) {
player.strength_string = "average"
} else if (player.strength_integer <= 33) {
player.strength_string = "weak"
}

if (not npc_1.parent = player.parent) {
msg ("Npc_1 follows along with you.")
npc_1.parent = player.parent
}


3. Attributes (data~properties~traits~characteristics): http://docs.textadventures.co.uk/quest/types/

Attributes are hard to describe, as they behave as a combination of both being 'physical things' and 'scriptings'

in the GUI~Editor (before the game begins):

'whatever' Element -> 'whatever' or the 'Attributes' Tab -> the options~settings (Attributes) || or Attributes -> Add -> (set them up)

in code (during the game: set~create, re-set, add~remove, and change~alter~adjust) examples:

Object_name.Attribute_name = Value_or_Expression

Attribute Types:

String Attributes: a collection of symbols (alphabet, numbers, and some of the other symbols too):

a
aaa
1
1234
a1a1
ifdsifhsdlkfhsdklf
dead
dead_boolean_attribute


(the Value must be encased in~by double quotes, or the textual parts within an Expression must be too)

player.condition = "poisoned"
player.alias = "HK"
player.strength_integer_as_a_string = "100"

game.greeting = "Hi, " + player.alias + " welcome to this game, have fun, but try not to die, as if you die in the game, then you die in real life, muwahaha! Good Luck! You'll need it..."

Object Attributes:

the Value must *NOT* have double quotes, it can't be the special~reserved (a Boolean Attribute's Values) 'true' nor 'false', and it must be an actual-existing Object in the game!

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

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

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

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

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


Boolean Attributes: literally as 'true' or 'false'

NO double quotes!

// the orc starts out alive (duh, lol):
orc.dead = false

// you kill the orc:
orc.dead = true

example of a built-in Boolean Attribute:
tv.switchedon=false // or (too lazy to look it up): tv.SwitchedOn=false
tv.switchedon=true // or (too lazy to look it up): tv.SwitchedOn=true

Integer Attributes: any non-decimal number

player.strength_integer = 100
game.event_flag_state = 0
player.strength_integer = player.strength_integer + 3

Double (Float~Floating Point) Attribute: any decimal number

player.damage_double = 45.2 // or: "45.2", as I've never used Doubles, so I don't know if it needs the double quotes or not.

List (Stringlists and Objectlists) Attributes: these are a bit more advanced, so not getting into them

Dictionary (Stringdictionaries, Objectdictionaries, and Scriptdictionaries) Attributes: these are even more advanced, so not getting into them

etc Attribute Types: too tired to get into them

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

anyways, finally about your question, conceptually about Attribute usage:

you're used to using and thinking in terms of Object (physical thing) usage, but these are very unweildy, such as:

imagine having actual individual 'silver and gold coins' Objects for your currency~transactions, the sheer quantity of them + having to move them around .. YUCK !!!!

INSTEAD, you want to use Attributes!

Your Objects have Attributes, which you can simply adjust, no moving of actual physical things around, nor in having those physical things. Attributes are awesome! see below, using the currency~transactions example (in code):

we're only moving the 'sword' Object around, no 'gold coins' and 'silver coins' extra Objects being moved around

shop_owner.cash = 500
player.cash = 100
sword.price = 50

Buying:

sword.parent = shop_owner

player.cash = player.cash - sword.price
shop_owner.cash = shop_owner.cash + sword.price
sword.parent = player

Selling:

sword.parent = player

player.cash = player.cash + (sword.price / 2)
shop_owner.cash = shop_owner.cash - (sword.price / 2)
sword.parent = shop_owner

*note: this should require 'if' scripting to check if you have enough 'cash' to buy the sword and the shop owner to buy the sword, of course, which I've left out, obviously.

----------

finally for your question specifically:

I would have your 'security' be an Integer Attribute on your 'player' Player Object, by creating~setting it to zero in the GUI~Editor:

'player' Player Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: player)
Attribute Name: security
Attribute Type: int (integer)
Attribute Value: 0

in code as scripting: player.security = 0

in code as creation tag:

<object name="player">
// blah code lines
<attr name="security" type="int">0</attr>
// blah code lines
</object>


anyways, conceptually what we're doing is 'flag stating', which probably makes more sense in the examples below:

player.security = 0 ~~~~~ you don't have any security clearance, no pretend security card
player.security = 1+ ~~~~~ you have higher levels of security clearance

let's say you 'push' Verb on a 'machine button' Object, which in its scripting, gives you: player.security = 1

than on a 'computer' Object, there's a 'hack' Verb, which if successful (using 'if' scripting), each time but increasing harder, increases your security by 1:
player.security = player.security + 1

and lastly, you got 'teleporter door' that are 'Locked' Objects~Exits that require levels of security clearance, example in pseudo-code:

if (player.security=0) {
-> msg ("You don't ahve clearance.")
} else if (player.security=1) {
-> msg ("You get into, are moved to, noobie areas~rooms of the game.")
} else if (player.security=2) {
-> msg ("You get into, are moved to, intermediate areas~rooms of the game.")
} else if (player.security=3) {
-> msg ("You get into, are moved to, hard areas~rooms of the game.")
} else if (player.security=4) {
-> msg ("You get into, are moved to, the last area~room of the game.")

adammadam
Hi! Can I ask you a question, I'm just trying to work out how to create basic attributes e.g. players damage = strength + base damage. I didn't exactly follow the info you put down, well when I tried typing in player.damage = player.base + player.strength or damage = base + strength, it doesn't seem to work, I'm probably doing something quite basic wrong. I've set up a basic "base" and "Strength" attribute which appear in game, so it's just a matter of combining these to create the "damage" attribute.
quest 3.png
quest 2.png
quest.png

The Pixie
When setting an attribute on the Attributes tab, you have to set it to a specific value, rather than a formula or another attribute.

What you can do is go to the Script tab of the game object and set your attribute there.
player.damage = player.strength + player.base

However, what you probably want is for player.damage to change when player.strength or player.base change, so you will also need that code in any script where they change so it gets recalculated.

adammadam
Thanks for your help!

Yeah what I ideally want is the player to start out with some base attributes, then to have some choices in different things at the start of the game which alter their attributes, then also get different things like weapons or illnesses throughout the game which alter attributes. And also the attributes to depend on the enemy e.g. if they resist an amount of damage..

So I understand putting all of these things in the game object section now not the player object. I'll have a go, I'll probably get stuck again quite soon :P But thanks for your help.

adammadam
So I guess I will need to delete all of the attributes I made under the player section and put them all in the game section since they will all be able to be changed throughout with scripts..

HegemonKhan
Are you using the desktop~offline version (and its the Text Adventure too, not the GameBook) ???

an Attribute:

Object_name.Attribute_name
~OR~
Object_name.Attribute_name = Value_or_Expression

is global, it can be used anywhere (so long as the Object that holds the Attribute, exists ~ still exists, of course).

your 'player' Player Object Attributes should be held (added~created) within your 'player' Player Object, and not your 'game' Game Object (use this for 'game.state ~ game.event' flag attributes and etc).

take a look at this guide to get you started:

http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/tutorial/
http://docs.textadventures.co.uk/quest/guides/
http://docs.textadventures.co.uk/quest/ ... ation.html (see this link)

---------

here's a sample game for you:

(hopefully this works... lol)

create a new game, open up the game file itself with notepad, wordpad, notepad++, or (apple) text editor, highlight and delete the entire code, copy and paste my code below into your game file, save it, and then play~test~study it.

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="xxx">
<gameid>d2b3cb55-fe14-4743a5bafb1e7056e656</gameid>
<version>1.0</version>
<firstpublished>2015</firstpubished>
<author>HegemonKhan</author>
<pov type="object">player</pov>
<start type="script">
character_creation_function
on ready {
attribute_function_1
on ready {
EnableTurnScript(global_turnscript)
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<statusattributes type="simplestringdictionary">level_integer_attribute=Level: !;experience_integer_attribute=Experience: !;cash_integer_attribute=Cash: !;strength_integer_attribute=!;endurance_integer_attribute=Endurance: !;dexterity_integer_attribute=Dexterity: !;agility_integer_attribute=Agility: !;speed_integer_attribute=Speed: !;luck_integer_attribute=Luck: !</statusattributes>
</object>
</object>
<object name="potion_1">
<inherit name="editor_object" />
<parent type="object">room</parent>
<alias>100 exp potion</alias>
<consume type="script">
game.pov.experience_integer_attribute = game.pov.experience_integer_attribute + 100
</consume>
</object>
<object name="potion_2">
<inherit name="editor_object" />
<parent type="object">room</parent>
<alias>300 exp potion</alias>
<consume type="script">
game.pov.experience_integer_attribute = game.pov.experience_integer_attribute + 300
</consume>
</object>
<object name="global_data_object">
<attr name="attribute_stringlist_attribute" type="simplestringlist">strength;endurance;dexterity;agility;speed;luck;level;experience;cash</attr>
<attr name="sex_stringlist_attribute" type="simplestringlist">male;female</attr>
<attr name="race_stringlist_attribute" type="simplestringlist">human;dwarf;elf</attr>
<attr name="class_stringlist_attribute" type="simplestringlist">warrior;wizard;thief</attr>
</object>
<verb>
<property>consume</property>
<pattern>consume</pattern>
<defaultexpression>"You can't consume that."</defaultexpression>
</verb>
<function name="character_creation_function">
msg ("Name?")
get input {
game.pov.alias=ToString(result)
show menu ("Sex?", global_data_object.sex_stringlist_attribute, false) {
game.pov.sex_string_attribute=ToString(result)
show menu ("Race?", global_data_object.race_stringlist_attribute, false) {
game.pov.race_string_attribute=ToString(result)
show menu ("Class?", global_data_object.class_stringlist_attribute, false) {
game.pov.class_string_attribute=ToString(result)
}
}
}
}
</function>
<function name="attribute_function_1">
foreach (attribute_variable, global_data_object.attribute_stringlist_attribute) {
if (not HasInt(game.pov,attribute_variable) {
set (game.pov,attribute_variable+"_integer_attribute",0)
}
}
firsttime {
attribute_function_2
} otherwise {
leveling_function
}
</function>
<function name="attribute_function_2">
if (game.pov.sex_string_attribute="male") {
game.pov.strength_integer_attribute = game.pov.strength_integer_attribute + 5
} else if (game.pov.sex_string_attribute="female") {
game.pov.agility_integer_attribute = game.pov.agility_integer_attribute + 5
}
if (game.pov.race_string_attribute="human") {
game.pov.endurance_integer_attribute = game.pov.endurance_integer_attribute + 3
} else if (game.pov.sex_string_attribute="dwarf") {
game.pov.dexterity_integer_attribute = game.pov.dexterity_integer_attribute + 5
} else if (game.pov.sex_string_attribute="elf") {
game.pov.speed_integer_attribute = game.pov.speed_integer_attribute + 5
}
if (game.pov.class_string_attribute="warrior") {
game.pov.luck_integer_attribute = game.pov.luck_integer_attribute + 6
} else if (game.pov.class_string_attribute="wizard") {
game.pov.luck_integer_attribute = game.pov.luck_integer_attribute + 4
} else if (game.pov.class_string_attribute="thief") {
game.pov.luck_integer_attribute = game.pov.luck_integer_attribute + 2
}
</function>
<function name="leveling_function"><![CDATA[
if (game.pov.experience_integer_attribute >= game.pov.level_integer_attribute * 100 + 100) {
game.pov.experience_integer_attribute = game.pov.experience_integer_attribute - (game.pov.level_integer_attribute * 100 + 100)
game.pov.level_integer_attribute = game.pov.level_integer_attribute + 1
attribute_function_2
leveling_function
}
]]></function>
<turnscript name="global_turnscript">
<enabled type="boolean">false</enabled>
<script>
attribute_function_1
</script>
</turnscript>
</asl>

adammadam
yes I am using the desktop offline version and text adventure version. Thanks for your help, the problem was kind of simple that I was trying to do it in the player object rather than under the game section, so it wasn't liking any of the changes I made until I started doing it in the right place! I've got past that hurdle it worked fine when I did it in the right section. Now I'm just reading through this guide http://docs.textadventures.co.uk/quest/ ... nced_.html Because I am trying to learn how to make a semi-complex combat system and it's more difficult than I thought it would be at first! I'm going to have to read how to flag any object as a weapon or something. like mace, sword, rusty dagger etc are all a "weapon" so this kind of thing would work for example player.damage = player.strength + weapon.damage rather than having to write it out a million times for every weapon in the game.. I'm just reading on anyway hopefully I'll learn how to do this and more in time!

HegemonKhan
I edited in extra stuff and a sample game to my previous post

--------

also, if interested, you can take a look at this too:

viewtopic.php?f=10&t=3348&start=120#p22483 (my combat system using Pertex' Combat Code Structure, so all credit goes to Pertex)

and an alternative equipment coding:

Chase's Wearables (Equipment) Library ( viewtopic.php?f=18&t=2901 )

and there's Sora's Stackable Library, but it needs some of its code lines to be converted to~for the newest version of quest and its syntax+etc still, so it's not useable unless you can do it yourself.

adammadam
thanks for the help, I've worn myself out a little by reading through a lot of stuff :P (my attention span isn't that great I guess) But I will definitely have a look at everything you put up in a while and let you know how I got on. Thanks.

HegemonKhan
adammadam wrote:I'm going to have to read how to flag any object as a weapon or something. like mace, sword, rusty dagger etc are all a "weapon" so this kind of thing would work for example player.damage = player.strength + weapon.damage rather than having to write it out a million times for every weapon in the game


just create a String Attribute on your weapon Objects called for example 'type_of_object' and set it's Value to 'weapon', you can now do a check 'if' Script for that Attribute and its Value:

<object name="sword">
<attr name="type_of_object" type="string">weapon</attr>
</object>

<object name="axe">
<attr name="type_of_object" type="string">weapon</attr>
</object>

<object name="potion">
<attr name="type_of_object" type="string">item</attr>
</object>

<object name="plate_mail">
<attr name="type_of_object" type="string">armor</attr>
</object>

<object name="room">
<attr name="type_of_object" type="string">room</attr>
</object>

<object name="player">
<attr name="type_of_object" type="string">playable_character</attr>
</object>

<object name="barmaid">
<attr name="type_of_object" type="string">non_playable_character</attr>
</object>

<object name="orc">
<attr name="type_of_object" type="string">monster</attr>
</object>


if (Object_name.type_of_object="weapon") {
// then do your damage scripting
} else if (Object_name.type_of_object="room") {
// then do... whatever scripting
}

this is a bit more advanced stuff... (not completed... got tired~lazy, might finish it up later)

<object name="player">
// lazy: blah attributes
</object>

<object name="orc">
// lazy: blah attributes
</object>

<object name="sword">
// lazy: blah attributes
</object>

<object name="axe">
// lazy: blah attributes
</object>

<function name="battle_turn_function">
self_damage_function (player,orc,sword)
on ready {
enemy_damage_function(player,orc,axe)
}
</function>

<function name="self_damage_function" parameter="self_parameter,enemy_parameter,weapon_parameter">
if (GetString (weapon_parameter,"type_of_object") = "weapon") {
enemy_parameter.current_life_integer_attribute = enemy_parameter.current_life_integer_attribute - (self_parameter.strength_integer_attribute + self_parameter.weapon_parameter.damage_integer_attribute)
}
</function>

<function name="enemy_damage_function" parameter="self_parameter,enemy_parameter,weapon_parameter">
if (GetString (weapon_parameter,"type_of_object") = "weapon") {
self_parameter.current_life_integer_attribute = self_parameter.current_life_integer_attribute - (enemy_parameter.strength_integer_attribute + enemy_parameter.weapon_parameter.damage_integer_attribute)
}
</function

adammadam
thanks you've been a great help!

HegemonKhan
if you're new to quest and~or especially to coding... then ignore my posts as you're going to be overwhelmed and~or scared from all my code (or just from my massive text wall posts, lol).

adammadam
After the tutorial I thought that was it, I missed all of this great help so I've got loads more to read through before I'll bother people with questions http://docs.textadventures.co.uk/quest/guides/ No doubt I'll get stuck again though a few times, so thanks for being there! Also I tried what you said, copy pasting your sample game code into a new game but it didn't really work so well sorry I think there's one or two things not working in it!

HegemonKhan
ya, I wrote it right then and was in a hurry (had to go somewhere), so there's likely a lot of errors~typos~missing lines~etc, laughs.

you may want to take a look at these too:

viewtopic.php?f=10&t=4946&start=15#p34198
viewtopic.php?f=10&t=5018&start=15#p35171

that 'how to' guide link is easy to miss~find as it's on the main wiki page... and 'how to' doesn't exactly convey: 'these are guides for you!"

and here's the other guides (Libraries and code samples):

viewforum.php?f=18

ask if you got any questions.

adammadam
yeah I am new to coding really, I mean the most I've done is editing xml files for the civilisation game, which I got pretty into and made a lot of changes to the game, but it's kind of basic. I don't mind though, it is a bit overwhelming at first and annoying to be patient having to learn so much when I want to get stuck in and make the game right away... but I'll keep at it.

Ideally (this is just an example with made up things) I think what I want is say the player has 0 defence against fire, 0 defence against cold, 0 magic attack and 0 physical attack. As standard. Then they can equip say a shield which gives them +1 defence against fire, then a sword which gives them +2 magic attack and +4 physical attack. Then you will see all their stats change in the upper right corner of the screen. And change again whatever else they equip. Then if they attack something which is also wearing armour and has +4 resistance to physical attack, then the player will do 0 physical damage as they'll cancel out, and +2 magic damage to the monster or whatever it is. Plus I'll add a lot more things into it eventually and some randomness too like a dice roll. And erm it will be turn based, other things will be in some cases having a free round where one side does damage and the other side can't attack, or having a bonus for a certain round if certain conditions are met... oh yeah and a decider on who attacks first.. lots of things eventually.

I'm not really up to the standard of being able to implement it right now but I only just discovered Quest yesterday, so I hope I will just work out how to do all of this with reading the guide eventually!

adammadam
thanks for the extra links

HegemonKhan
awesome, you play civilization? I LOVE civilization! (I love FFH2 mod for Civ4):

(if you can't tell from my name, I love the mongols, and thus play them in civ4, hehe. I'm a big history buff, and the mongols are awesome!)

(quest uses XML, so hopefully the code syntax~format is recognizable?)

(I'm trying to learn how to code in all of the RPG aspects, as I want to make a massive quest~text TES:skyrim~oblivion~morrowind game, laughs)

(not getting very far... learning to code is slow for me, sighs)

http://forums.civfanatics.com/showthread.php?t=171398

hehe :D

adammadam
yeah well I spent a long time making loads and loads of edits to the civ 4 xml files, I think I really improved the game tbh, at first I just focused on the WW2 era and made loads of new units, I made a limit for every unit so you can have 200 max infantry, 10 max medium tanks, 6 max heavy tanks, 20 max light tanks, 50 max machine guns etc etc, everything was limited except eventually when you've built everything you have the option for weaker reserve infantry or some weak frigate ships. Then I made most units more realistic or good at countering others, made some more fun invisible units like snipers.. I gave all the units the historical names they had so the American light tank was a stuart 37mm, the german machine gun was mg42 etc, and I gave them stats I thought were kind of realistic to their actual strengths.. like the Japanese tanks were just awful. I made 3 new civics Communism, Capitalism and Nazism and made each side favour the relevant one so Germany would always choose Nazism, Russia communism etc, and I made them love the sides which chose the same and hate the sides which chose a different one, so the alliances were always historically accurate. And I put them in the right place on the world map. After a while I think it got quite good, but then my laptop broke so all the changes were lost lol. I would have put accurate graphics and sounds too onto it eventually if I could and maybe even turned it into a mod to share if other people would have liked it. But yeah, meh, oh well.

adammadam
Ive actually never tried any mods on civ 4 though even though I spent so long changing it myself, I guess there are some really good ones, personally I actually just enjoyed changing the xml and seeing my changes come to life more than the game itself

HegemonKhan
you probably missed this link, but I've created a combat code that does a lot of the things that you want (as we seem to be interested in the same thing, hehe):

viewtopic.php?f=10&t=3348&start=120#p22483

so if you can follow~read~understand~study it, then it might be of help to you, at least for ideas.

adammadam
oh yeah it's a shame that it's not working properly but the code still has a lot of things I could read to learn from I think

HegemonKhan
do you mean: my combat code or Sora's Stackable Library (items) ???

(I can fix~convert my combat code up, for it to work, if it isn't)

adammadam
HegemonKhan wrote:do you mean: my combat code or Sora's Stackable Library (items) ???

(I can fix~convert my combat code up, for it to work, if it isn't)


yeah I meant the combat code I haven't tried the other one yet, but it's alright, I'm just reading through the guides again a bit today

HegemonKhan
alright, I'll get it converted~working, and repost it for you when I'm done (if I remember and~or am able to find time to do so... lol).

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

Support

Forums