Noobie HK's "Help Me!" Thread

HegemonKhan
I'm using the 5.2 version of Quest in TA mode

Hi, everyone, I am really loving this software, thank you so much Alex, as I can try to make a game with it, something I always been interested in doing, but was never able to, due to having *ZERO* coding-programming knowledge, as well as not much $$ to spend on non-free software or whatever, so again, thank you so much Alex for this great free text adventure game making software!

Like I've said, I'm a total noobie along with ZERO programming-coding ability-knowledge, but the tutorial has been really helpful as I've been trying to learn what I can, having some very small minor successes (but they're big ones for me, lol). I kinda get the basics used separately by themselves, but I'm so overwhelmed and confused by all the terms and stuff (values, attributes, variables, functions, scripts, commands, verbs, and etc), and thus I am especially confused with trying to use them together to actually do things, beyond their "stand alone" (specific and limited) uses in the tutorial. It's just all the cross-usage of all these things-terms confuses me, like if I do a script coding, if I also have to create attributes, functions, result, variables, commands, evaluate, etc as well along with the script. The tutorial works extremely well, I can understand it and follow along, but trying to apply what's in the tutorial to do stuff that isn't explained so directly in the tutorial, leaves me very lost.

For one example, I know that creating a start menu for a "character creation" (like picking race, class, etc) is quite advanced, though I'd like to understand how to do it (I've read the 3 threads-posts on it here in my fair searching and DL'ed pixie's (I think it is his-hers, my memory isn't the best, sighs) library on Race. But I don't know how to do the rest of the stuff, like make it apply to the player, the game, and whatever else (I can just make the most bare bones of the menu itself, lol).

If possible, more tutorials (of more things) would be extremely appreciated, as the tutorials are very step by step and well done, making it easy to understand what you're doing and how to do it, as at least for me, it's hard to apply what I understand to making-doing things on my own. (obviously, I got no coding-programming-designing-hacking-ingenuity-creativity skills, lol).

anyways, my first actual question-request for help is on something I noticed in the tutorial (I'm trying to be smart and keeping my learning very small, small steps at a time, hopefully working up to understanding better on how to do the more advanced stuff.. I hope), so, here it is:

it is about this specific part of the tutorial:

http://quest5.net/w/images/0/0c/Command.gif

and here's the ASL-Code that is provided as well:

(I'd prefer help-guidance through the GUI, as I don't really got the coding down well enough to follow along, nor can I match the coding up very well with the GUI's buttons-windows-panes-options)

<command name="saying">
<pattern>say #text_talk# to #object_troll#</pattern>
<script>
if (object_troll.parent=player.parent) {
msg ("You say: " + text_talk)
msg (object_troll.name + " ignores you.")
}
</script>
</command>

this "saying" command with the troll is in this larger section, here: http://quest5.net/wiki/Custom_commands

anyways, what I noticed was that the

say hi to troll ( say #text_talk# to #object_troll# ) with it's,
If,
expression object_troll.parent=player.parent ,
Then,
Print expression "You say: " + text_talk
Print expression object_troll.name + " ignores you."

> say hi to troll
You say: hi
troll ignores you.

also outputs this command with Bob:

> say hi to Bob
You say: hi
Bob ignores you.

what, I'd like to understand is why is it also applying the command "saying" ( say #text_talk# to #object_troll# ) to Bob, when shouldn't it be only applying to troll due to the:

#object_troll#
object_troll.parent
object_troll.name

I don't understand why-how it is applying to Bob as well. Is there something I didn't add that is understood that I was suppose to do also (beyond what was shown in the tutorial for this command "saying" with the object "troll"), like creating any attributes and-or also defining the attributes-to-variable-to-function-or-whatever (see, I'm quite confused, sighs). So, this is a small step in me trying to understand more about this software and its coding, while it's not really that important, I'd like to understand why-how this is happening (and-or especially, if it's the case, of what I'm doing-done wrong or not even doing).

I've done some various fiddling with the GUI's "code", but I can't figure out why it's applying to Bob. Like for example, I tried removing the "object_", but this didn't stop it from applying to Bob, and I also tried to change the "_" with a "."

Some of the fiddling, resulted in an error (I'd have to go back and reproduce this, which won't take long if need be) of something like "variable object isn't recognized" or something like this-to this effect, meh.

As, a quick 2nd question of mine:

what is the "_" for anyways? Is it needed, doing it's own thing, like how the "." does with the object.attribute (e.g. attribute thing I think with eggs.weight in the immediately following part of the tutorial) ? Or, is it just used as a way to distinguish from #text# (with the use of "say #text#" ) ?

I know you want the game upload (do I have to put it into a zip file first or can I just directly add the .aslx game file as an attachment?), but it's just the tutorial game and its sections-topics of coding (which can be easily+quickly reproduced), so I'm not going to upload it, unless you really need it. I've done only minor extra stuff to the tutorial game, in trying to do some thing and testing some things out, as well as just additional practice of the tutorial stuff, to try to get my brain to understand and memorize what and how to do stuff, and-or what the stuff does, lol.

yet for a 3rd time, thank you for this wonderful and free software, Alex! I love it, just need to now understand it better, to do more advanced stuff, hehe.

A huge fan of your Quest text adventure software,
HK

The Pixie
I think the tutorial is a bit confusing on this (and should be updated!). The pattern you are using is this:

say #text_talk# to #object_troll#

Quest will attempt to match this to the player text. The words "say" and "to" must match exactly, as you expect. The bits inside hashes, #, can vary. If the bit inside has the word "text" in it, then it will match any text at all, and that text will end up in a variable with the same name as what you put in the hashes, in this case text_talk. If the bit between hashes has the word object, then Quest will attempt to match that to an object that is present, and this object, whatever it is, will go in a variable with the same name as what you put between the hashes, in this case object_troll.

So the player types:

say hi to bob

Quest matches "say" and "to" directly. It then matches "hi" to the text, so now text_talk is set to "hi". Then it matches the object, as long as bob is here, and sets object_troll to be bob.

To be honest, it would have been better if the tutorial used this as the pattern:

say #text_talk# to #object_one#

Your game needs to check what object was matched, and the best way would be with a switch command.

Here is a modified version that you can copy-and-paste over the current version, then examine in the GUI.

 <command name="saying">
<pattern>say #text_talk# to #object_one#</pattern>
<script>
switch (object_one) {
case (troll) {
msg ("You say: " + text_talk)
msg ("The troll grunts but otherwise ignores you.")
}
case (bob) {
msg ("You say: " + text_talk)
msg ("Bob smiles back at you.")
}
default {
msg ("You say: " + text_talk + " but the " + object_one.name + " says nothing, possible because, you know, it cannot speak.")
}
}
</script>
</command>


It does not bother to check that the object is here, as Quest does that when pattern-matching. It uses a switch command to differentiate between objects, with a default for any you have not put in specific commands for.

sgreig
HegemonKhan wrote:what, I'd like to understand is why is it also applying the command "saying" ( say #text_talk# to #object_troll# ) to Bob, when shouldn't it be only applying to troll due to the:

#object_troll#
object_troll.parent
object_troll.name

I don't understand why-how it is applying to Bob as well.


Pixie has a point that the example could be clarified a bit. However, and I may well be wrong here, but I believe what's causing the confusion here is that the command is referring to an in-game object called object_troll, who has a name parameter assigned to it with a value of "Bob." Hence, when the code uses object_troll.name, it will replace it with the value Bob.

So, in a nutshell what I'm saying is, I think the troll object in the example is called Bob, and so they are one and the same.

Alex
Yes I don't recognise that bit of the tutorial... object_troll doesn't make sense as a variable name in a command. I've commented out this section for now - if somebody wants to update it please go ahead!

The Pixie
Done.

HegemonKhan
err, since I'm posting this, I guess "commented out" doesn't mean you closed this thread (lol) - [Edit: oh wait, you're refering to the tutorial with the troll coding, ah nvm then, my bad!}, as my idea was to make this thread, to put all of my questions in it, so to not clutter up the rest of the forum, and for a spot for my questions, as I know I'm not the only noobie here asking simple stuff, but I don't want my questions out of place in other threads, nor lost and not easy to re find again. so, hopefully this thread can stay open, as this is but my first question, as I'll definately have many more, laughs.

and thank you very much for the replies, thanks pixie and others, now i got to try to understand what you said, laughs,

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

as I'm really confused with all of the terms (due to being overwhelmed by them all), as in like:

an attribute is what, and what does it do and-or is used for within a game, when and do you need to use and-or create an attribute, how and when is it used in scripts, and etc etc etc.

a variable is what, and what does it do and-or is used for within a game, when and do you need to use and-or create an attribute, how and when is it used in scripts, and etc etc etc.

an expression is what, and... etc etc etc

a function... etc etc etc

a comand... etc etc etc

etc etc etc

what are all of the different scripts, what are they, what do they do, how do I use and-or set them (and their supporting parts, like creating attributes and-or lists, and etc) up?

what are all the different functions, what ... etc etc etc

etc etc etc

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

as I went through the tutorial it made sense, but now, everything is all jumbled together in my head, and I'm so confused. I can't even understand the terms, as it is like, you make this script, you make this expression, it creates a variable, you make the variable apply-create an attribute, it then becomes a value, you then apply the value into this script.. etc etc etc..

I'm just confused by the coding language and its terms, I don't know what, don't understand - no comprehension, in what I'm doing. now that I'm trying to apply all of it, beyond the clear step by step of the tutorial.

maybe for me, if I could ask about something I want to do, and then have one of you explain it to me step by step, in what I'm doing, what is happening, why I need to do this stuff (these steps, other stuff, and etc), and etc.

it feels like math, when you don't understand what you're doing, and you're just copying down the pattern-steps, but you don't understand them, and then when you hit a new problem that you don't recognize, you don't know how to match it out with the math equations... I hit calculus "102" (basic applications), and that was my math limit-breaking point, lol. but, these has been years ago, laughs.

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

anyways, my next question is on the character creation stuff, I'm trying to understand and get right (just the name and gender steps-stuff) on my own right now, but if I can't work it out on my own, maybe I could ask-get pixie (or whoever) to walk me through what pixie (or Pertex or whoever else) has done in their coding of it, so I can understand it, but let me first, try to figure it out on my own, as I don't want to bug you constantly with questions. I can do "trial and error", but it's a slow process, though I think I can understand what is going on by using this method, hopefully.

HegemonKhan
aight, I read through your post, pixie, and I understand it (yeah!):

switch ( IFs -plural- script )

If object_one = troll, then...
If object_one = Bob, then....
If object_one = "other", then...

(@Pixie, this needs a bit further coding, like with the defibrillator, as Bob is either dead or alive, wink. I'm just enjoying this small teasing of you, on forgetting, or not realizing, due to probably not needing to go through-use the tutorial, as I've been doing and needing, on this problem with Bob, hehe)

I already knew that it (the tutorial's "saying" command) coud be easily fixed-corrected, so, I was mostly just wondering why-what was going on with the coding-engine-whatever-matching pattern, of why it was applying to Bob too, and not just troll.

I understand what you said-explained about what is going on, but it's a lot of steps to follow, which since I'm a noob and not used to this coding language (steps and-or cross script-attributes-variables-stuff steps) is confusing for me to organize and follow-understand. I guess I need to write down what is going on, to slowly start to learn this stuff better, laughs.

(I think I probably sound like a student taking a coding computer class for his first time, lol)

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

@sgreig,

do I, can I, go and change Bob's parameter so it doesn't match up with object_troll (or vice versa, change object troll so it doesn't match up with Bob, only so it only matches up with troll), ??? ...if I understand your post correctly, that is... laughs

( and how-why did Bob get matched with = parameter = with object_troll ?? )

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

P.S.

a quick question:

what does the "_" (underscore), like in "object_troll" do and-or is for? Is it like the "." (dot) in player.alias or eggs.weight but with a different purpose, or does the "_" (underscore) have no purpose, and it's just to separate the "#text#" from the "#text_talk#" or the "troll" from "object_troll" ??

The Pixie
One of the strengths of Quest is that it lets you into programming gently - as long as you are not too ambitious as you start.

(@Pixie, this needs a bit further coding, like with the defibrillator, as Bob is either dead or alive, wink. I'm just enjoying this small teasing of you, on forgetting, or not realizing, due to probably not needing to go through-use the tutorial, as I've been doing and needing, on this problem with Bob, hehe)


Oh, sure, there is lots of scope here. You want him to respond to each different thing the player might say to him, like "Hi" and "You smell" and "Have a banana". Personally I would not have a command like that at all as it is too open-ended. Implementing "speak to bob" is much easier.

what does the "_" (underscore), like in "object_troll" do and-or is for? Is it like the "." (dot) in player.alias or eggs.weight but with a different purpose, or does the "_" (underscore) have no purpose, and it's just to separate the "#text#" from the "#text_talk#" or the "troll" from "object_troll" ??


In computer programmes, it is effectively just another letter that does the same as "a", but looks a bit like a space, so can be used to break up words in a name. To the computer, "object_troll" is just one word, to humans, it is two (actually, I think Quest would cope with "object troll", but it just looks wrong as a variable name!).

An attribute is a value that is attached to be object. It could be a string, such as the object's alias, or a number, like its weight, or a script.

A variable is something that can take a value, like object_troll and result. They are kind of like attributes that are not attached to an object. It is important to remember in Quest that variables are only temporary - when the script or function ends, they disappear.

An expression is some maths. An expression is used to assign a value to a variable or attribute, or to compare two things (like in an if statment). That said, sometimes you do not see what it is being assigned to. For example:
msg ("You say: " + text_talk)

The bit inside the brackets is an expression. Behind the scenes, Quest assigns that to a variable, and sends that to the msg script command.

A function is a piece of code for doing something. A script command is very similar, the difference being they are built-in, and their names are lower case.
s = ToString(34)
msg ("You say: " + text_talk)

Functions and script commands often return a value, and often have one or more parameters (that is, values sent to them; both examples above take one parameter).

A script is a function attached to an object (so is a type of attribute) (but cannot return a value or take parameters). If you add a script called "speak" to an object, when the player types "talk to fred", the "speak" script will be run. A script can use a special word, "this", to refer to the object it is attached to, to access its attributes.

A command is another entity altogether, a text pattern that Quest will attempt to match to what the player types. Quest has verbs too, which are similar, but particularly set up for setting up a specific object (use a verb for "speak to", for example). Commands and verbs will usually have script attributes that run when there is a pattern match.

So there are script, commands and script commands...

HegemonKhan
thanks pixie, but my confusion is more with the use-application of the terms within a script, I get lost on what is going on, with the sequence of the terms, what is what, what is being applied, what the inputs and outputs of the terms are, and etc.

I don't know of good examples to use, but let me start with this one, and hopefully this will better explain what my confusions are (as I'm failing to be clear in where-what my difficulties are in understanding the codings and how to do the codings on my own, I understand the simple individual codings in the tutorial, but I'm confused with scripts that use apply multiple simple scripts-codings from the tutorial together, maybe this makes more sense now, meh):

Pixie's Player Name and Gender Coding:

<start type="stript">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
msg ("Hi, " + player.alias)
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>


my attempt at understanding this coding:

[coding] = [my understanding of it]

Name Creation:

[msg ("Let's generate a character...")] = [an Attribute String (a "message")]

[msg ("First, what is your name?")] = [another Attribute String (a "message")]

User's typing input (e.g. HK)

[get input] = [takes the "HK" to be used for the next coding; result = HK or HK = result (whatever)]

[ { ] = [I presume this creates everything following as part, "children", of the, "main-parent", full-entire sequence, for it to work correctly)]

[player.gender = result] = [does this turn the "result=HK" into an attribute or a value or a parameter? it also does this: result=HK=player.gender, but I'm confused as to whether it is doing: HK -> result -> player.gender -> attribute/value/parameter, result -> HK -> attribute/value/parameter, result/HK -> HK/result -> value -> attribute/parameter, HK/result -> attribute/parameter -> value, or etc etc etc. I don't understand what is going on here, with what terms are being created-used-applied, and as what, as the inputs, outputs, or both input and output.]

[msg ("Hi, " + player.alias)] = [this is taking the player.alias=result=HK and inputting it into the message, but what is the player.alias=result=HK? an attribute, a value, a parameter, or something else?]

Gender Creation: I really don't understand this stuff

[show menu ("Your gender?", game.gender_list, false)]

[show menu] = [brings up the menu that will either be created in the following code or you create a gender list as an attribute for the Game Object.]

["Your gender?"] = a String attribute (a "message")

I don't understand the rest of the coding, and would be completely guessing... so I won't do so, lol. I could really use an explanation of what is going on here.

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

maybe what I need is an incremental series of connected examples (of simpler codes) creating a large script code, to show me how they're connected and build into that larger and larger script sequence.

like start off with a simple script or creation of an attribute/value/parameter, then provide this in a larger code sequence, and then a larger, so I can see how the terms are used-applied and-or are when are they being used as inputs, as outputs, and etc. Or however it works, as this is my confusion with the coding/scripts and its various pieces, all the terms, and how-when they're being used within the script/coding.

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

P.S.

I'm terribly sorry if this is confusing, as it's hard to ask for help about something that you don't even understand, to even to know how or what to be asking about as help, lol. It's hard to ask questions, when you don't even know what the questions are that you need to be asking about.

HegemonKhan
I'm really confused right now, and just wasting your time. I'm sorry. I am a total noobie, indeed. sighs.

let me go back and study the tutorial and other people's codings better on my own, as I'm just being very unclear to you guys as I fumble to ask for help. before I bug you guys, as I'm not making it easy on you guys at all, as I don't even understand what I need to be asking about, nor hot to ask about it, not knowing what to ask about, not knowing what I'm talking about, sighs.

The Pixie
Actually that is not a simple one to start with, but let us see how we get on. This is a script on the game object, so an attribute that can be run. In this case, as it is called start, it is run automatically when the game starts.

I will put a comment before each line, starting with // to say what that line means.

  <start type="script">
// Here "msg" is a script command, what string is sent to it will appear on the screen
msg ("Let's generate a character...")
// And again
msg ("First, what is your name?")
// Another script command, "get input". Waits for the player to type something,
// puts that text into a variable called "result",
// then runs its 'block'. The block is enclosed in curly braces.
get input {
// The "player" object has an attribute "alias" that is
// now set to the text in the "result" variable.
player.alias = result
// Now use "msg" to print to the screen, but this time the text is constructed
// by adding together two parts, using the plus sign.
msg ("Hi, " + player.alias)
// I have broken one line into two for simplicity
// The "Split" function breaks up a string of text into set of smaller strings,
// called a 'string list'.
// Here it will break up "Male;Female", and it will break the string wherever it
// find a semi-colon, as the second paramter is ";".
// The variable "options" will contain the output of the function.
options = Split ("Male;Female", ";")
// The "show menu" scrpt command will display a menu for the player.
// The "Your gender?" part will be the prompt or title.
// Then it will use the variable "options", which we just set. So the player will
// have the choice of "Male" or "Female".
// Finally we have "false", which tells Quest not to let the player cancel the menu
// choice.
// As with "get input", when the player makes a choice, the text goes into "result"
// and the block is run.
show menu ("Your gender?", options, false) {
// The "gender" attribute of "player" is now set to "Male" or "Female",
// as the player chose
player.gender = result
// Another menu, just like before, but here the two lines are combined
// You have the prompt, the string list with the option from the "Split"
// function, and "false" again.
show menu ("Your character class?", Split ("Warrior;Wizard;Priest;Thief", ";"), false) {
// The "class" attribute of "player" is now set.
player.class = result
// Print an empty line.
msg (" ")
// Print a summary to screen
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
// Print an empty line.
msg (" ")
// Print instructions.
msg ("Now press a key to begin...")
// The "wait" script command is kind of like "get input", but instead of the player
// typing a sentence, the player presses a single key. Once that happens,
// the code in that box runs
wait {
// This function clears the screen, as you probably guessed
ClearScreen
// This is the end of the "wait" block.
}
// This is the end of the second "show menu" block.
}
// This is the end of the first "show menu" block.
}
// This is the end of the "get input" block.
}
</start>

HegemonKhan
I know it is more advanced-complicated, but I didn't know of any better examples to use, the tutorial coding scripts are too simplistic, and I can't come up with my own example, so I just used yours of the character creation stuff, as I just needed an example, for me-us to work with.

Thank you very very much pixie, this was extremely helpful, but let me see if I understand it correctly (and I also have a few things I'm confused about too):

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

a confusion of mine:

there's a few seemingly extra code lines in this explanation post of the code, than in the original code of yours that I refered to:

(I'll bold and italicize the new code lines from the original code of yours. EDIT, oops, by putting it into the 'code' BBcode, I've lost the visual-ness of the bolded and italicized text, sorry about that!)

  <start type="script">
// Here "msg" is a script command, what string is sent to it will appear on the screen
msg ("Let's generate a character...")
// And again
msg ("First, what is your name?")
// Another script command, "get input". Waits for the player to type something,
// puts that text into a variable called "result",
// then runs its 'block'. The block is enclosed in curly braces.
get input {
// The "player" object has an attribute "alias" that is
// now set to the text in the "result" variable.
player.alias = result
// Now use "msg" to print to the screen, but this time the text is constructed
// by adding together two parts, using the plus sign.
msg ("Hi, " + player.alias)
// I have broken one line into two for simplicity
// The "Split" function breaks up a string of text into set of smaller strings,
// called a 'string list'.
// Here it will break up "Male;Female", and it will break the string wherever it
// find a semi-colon, as the second paramter is ";".
// The variable "options" will contain the output of the function.
[i][b]options = Split ("Male;Female", ";")[/b][/i]
// The "show menu" scrpt command will display a menu for the player.
// The "Your gender?" part will be the prompt or title.
// Then it will use the variable "options", which we just set. So the player will
// have the choice of "Male" or "Female".
// Finally we have "false", which tells Quest not to let the player cancel the menu
// choice.
// As with "get input", when the player makes a choice, the text goes into "result"
// and the block is run.
[b][i]show menu ("Your gender?", options, false) {[/i][/b]
[HK: original is, show menu ("Your gender?", game.gender_list, false) { ]
[HK: I'm guesing that the, options = Split ("Male;Female", ";"), is "I have broken one line into two for simplicity (pixie)", and this was taken out of the original code line, show menu ("Your gender?", game.gender_list, false) { , which internally does what you shown me in your explanation of breaking the one line into two for my simplicity]
// The "gender" attribute of "player" is now set to "Male" or "Female",
// as the player chose
player.gender = result
// Another menu, just like before, but here the two lines are combined
// You have the prompt, the string list with the option from the "Split"
// function, and "false" again.
[b][i]show menu ("Your character class?", Split ("Warrior;Wizard;Priest;Thief", ";"), false) {[/i][/b]
[HK: original is, show menu ("Your skill set?", game.class_list, false) { ]
[HK: I'm guesing that this is the same as with the gender above]
// The "class" attribute of "player" is now set.
player.class = result
// Print an empty line.
msg (" ")
// Print a summary to screen
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
// Print an empty line.
msg (" ")
// Print instructions.
msg ("Now press a key to begin...")
// The "wait" script command is kind of like "get input", but instead of the player
// typing a sentence, the player presses a single key. Once that happens,
// the code in that box runs
wait {
// This function clears the screen, as you probably guessed
ClearScreen
// This is the end of the "wait" block.
}
// This is the end of the second "show menu" block.
}
// This is the end of the first "show menu" block.
}
// This is the end of the "get input" block.
}
</start>


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

is the:

options = Split ("Male;Female", ";")

and I presume the implied coding line by you:

(HK: options =) Split ("Warrior;Wizard;Priest;Thief", ";")

(HK: I'm guesing that the first use of 'options =' gets applied to the 'Split ("Warrior;Wizard;Priest;Thief", ";")', which is why you left off the, 'options =')

done internally by your original code line, or do I need to write this "Options = Split (...)" into the coding, and you forgot to mention this with your original coding?

do I also need to create any lists (player.gender_list and player.class_list) or attributes/variables (player.gender=male or female, and player.class=warrior or priest or wizard or thief), under the Object -> Game -> Attributes -> Add New Attributes ???

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

Also, I think I've tried to do my own recreate of your original coding (but only using the name and gender sections), but it had a problem, in that the menu comes up immediately, not allowing me to input my character name, but maybe this is because I didn't write in the rest of the coding (class part and the ending }'s ), which is I'm guessing is needed to not cause the menu to override your input of your name, as it needs to be a-the block, to run it properly. If you wanna take a look at it, I can attach the file, but I'll have to reproduce it, only a few minutes though for me to do, lol

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

for reference, if I didn't match up the lines of the two versions of coding above.

The original code of yours that I refered to:

(I know the indenting is off, I copy and pasted wrongly, as can be seen, it didn't include the indentation of the lines)

<start type="stript">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
msg ("Hi, " + player.alias)
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>


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

anywas, about whether I understand (of the "algebra", of the input-output of) what is going on (if I get it right):

for this case's coding:

user's input: "HK" => text
get input: text => variable ("result")
[object.attribute ("player.alias")]
player.alias = result: variable ("result") => player.alias (what term is this line known as? an expression? a function? a variable? or something else? Or, should I be asking what script/function/variable option this would be in the GUI, instead?)
msg ("Hi, " + player.alias): "Hi HK" => text

err... I'll hold off on the gender and class parts... I got to think-examine those more first on how I put it into my own words, lol. I for the most part understand this, except the use of extra-different lines, which I menioned about above already. I get the message part of Lcase (gender) and Rcase (class) of just the way of it saying-outputing: " 'HK' is a 'male' + 'warrior' "

HegemonKhan
woot, I figured out what you were doing, hehe! small success for HK, lol. (And, that's awesome how the // puts in your comments to the GUI coding, hehe. Are the // the "Comment" script?)

either I can do:

for your new code:

options = Split ("Male;Female", ";")
show menu ("Your gender?", options, false) {

~OR~

show menu ("Your gender?", Split ("Male;Female", ";"), false) {

simple algebraic substitution, don't know why I didn't recognize this immediately at what you were doing, grr!

--------

but for the life of me, I'm confused with the basic string message->expression syntax, lol. I can't figure it out, how to get it to work, grr.

I created an extra category: player.race (human, elf, dwarf)

so I've got: player.alias, player.gender, player.race (human, elf, dwarf), and player.class.

I just can't figure out how to do the string (message->expression) syntax for it, lol. I'm confused with the +'s and the "s

(or is it impossible with having 3 LCases? I doubt though that this is so though)

How do I fix this:

msg (player.alias "is a" + LCase (player.gender) + " " + LCase (player.race) " + LCase (player.class).")

so that it works correctly?


--------

if you need the full game code, just to check if I got anything else wrong, but it seems like I got it all correct:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("Warrior;cleric;mage;theif" , ";"), false) {
player.class = result
msg (player.alias "is a" + LCase (player.gender) + " " + LCase (player.race) " + LCase (player.class).")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
</asl>


---------

(your old and new codes are different methods of doing it, I think, so my bad of comparing-contrasting the two codes of them together)

for your old code (I got it from one of your posts on the forum, I can find where it's at, if you wanna know):

show menu ("Your gender?", game.gender_list, false) {

my guess (which doesn't full-code work):

Object -> Game -> Attributes -> Add New Attributes -> male, female
game.gender_list=result

err... I don't know how to get the old code of yours to work, unfortunately. maybe you could explain how this old code works, like you did with your new code?

it's not even inputting the name right, but I guess this requires the rest of the code to be right, but it seems strange, of not recognizing the player.alias=result, as to me the rest of the code doesn't seem to impact the naming part, but it probably does, otherwise, I got a mystery of why the player.alias=result isn't recognized...

[EDIT: I got the old code to work now too, hehe. I was just making some small syntax mistakes, and needed to make game attribute string lists of the menu options: gender=male,female and class=warrior, priest, mage, theif.

here's my successful coding of your old code, I even figured out how to line up the coding too, from my copy a paste from ehre into the game's code, figured how to fix it properly via the GUI too, and then figured how to properly syntax name-identify the stuff, so it works properly, HK has another small success! woot!

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
msg ("Hi, " + player.alias)
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>
<gender_list type="list">male; female</gender_list>
<class_list type="list">warrior; cleric; mage; theif</class_list>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
</asl>

The Pixie

do I also need to create any lists (player.gender_list and player.class_list)...


That would be an alternative way to do it. Make player.gender_list be a string list, then:

show menu ("Your gender?", player.gender_list, false) {


... or attributes/variables (player.gender=male or female, and player.class=warrior or priest or wizard or thief), under the Object -> Game -> Attributes -> Add New Attributes ???


No need, as the script creates the attributes when it gives them a value.

I just can't figure out how to do the string (message->expression) syntax for it, lol. I'm confused with the +'s and the "s


Break it up into chunks, with a plus between each chunk. Each chunk is either some literal text, so needs quotes at the start and end, or not, so doesn't. Let us have a look:

msg (player.alias "is a" + LCase (player.gender) + " " + LCase (player.race) " + LCase (player.class).")

Here are the chunks:

player.alias
"is a"
LCase (player.gender)
" "
LCase (player.race)
LCase (player.class)
"."

I have changed them slightly, the second, fourth and last are literal text - exactly what the player will see - so need quotes. No quotes on anything else. Put them together with plus signs:

msg (player.alias + "is a" + LCase (player.gender) + " " + LCase (player.race) + LCase (player.class) + ".")

HegemonKhan
your code has two small problems in it:

HKis amale humanwarrior.

the one correction is (typo-simple mistake):

"is a" -> " is a "

but, for the 2nd problem of the no space created between human and warrior, I can't figure out how to fix it on my own. I don't know how to create a space between human and warrior.

jaynabonne
The same way as the others:

msg (player.alias + " is a " + LCase (player.gender) + " " + LCase (player.race) + " " + LCase (player.class) + ".")

HegemonKhan
thanks you jaynabonne, and pixie, and others too, thank all of you! I really am starting to understand this coding better now.

though, can I do the next level up of figuring out how to apply status attributes and also make them (along with the character creation stuff) apply throughout the game... laughs. got to go read and read and reread, and then try and try and try it out, lol

or, is there a more immediate thing to learn next instead?

what is a good progressive learn-order for learning coding, by the way?

what is good progression in script learning ??

examples of progressively harder-complex-larger scripts would be really helpful I think for us noobies, so we can kinda see how it works and how the different codings connect and are used-applied together.

jaynabonne
I would say just figure out things you want to do (and it sounds like the status attributes are a good one) and then figure out how to do them, asking questions as you go along. I think you'll start to get an idea of difficulty as you get into something, but I think if it's in line with the design of Quest (and status attributes are), then you should be able to get there. And you'll get more proficient as you get more experience. :) And anything with a tutorial is a good safe bet.

HegemonKhan
Before I get into trying to tackle status attributes (and altering them: e.g. combat, level ups, learning abilities-spells, etc), I figured to start with trying to set up flags just for the character creation stuff (gender, race, class) so that it will (can be) applied to the rest of the game, if I understand this stuff correctly. I am aware about how coding scripts' variables or whatever can be only localized (it's only applied to within that script, and so outside of the script it doesn't exist), but I'm a bit confused in understanding what is and isn't localized, as I'm trying just learning scripts and hardly understand them and their parts and applications in context yet. Anyways, I tried to work on making it (player's gender, race, and class) be available outside of the Object -> Game -> starting script by making flags (for the then later "IF has this flag" stripts, to apply the character creation stuff to the right of the game when it is needed. I'm sure there's probably a problem with this method that I don't realize yet like when I am trying to apply changes to the attributes like in combat scripts, and-or it's horribly an inefficent method, and there's a much better way to do it, but this isn't my concern at the moment), but I'm doing something wrong (or missing something) as it's not recognizing the sub race of "human/elf/dwarf" as a variable or object (or at least that's the error message that comes up anyways). So, could I get some help on how to get this to work? hopefully, I'm 100% doing this in the right direction, and I'm just missing a few simple things for it to work, or at worst, this is completely the incorrect approach, which I'd apologize for, as this is just my own (guessing) attempt at trying to get it to work. There are posts about this stuff here and there throughout the forum, but it's really a hassle switching between multiple posts to read and try to make sense of. So, if I could get any help here (so it's all together) on how to do this, it'd be much appreciated!

maybe my problem is simply that I'm doing the set object flag script wrong (or am missing a part-step to it), as I've just been doing this from memory, not checking the tutorial about doing them (at least I think I remember the tutorial having gone over setting object flags... but maybe I read about them on the forum-wiki posts, meh. My memory isn't the best, I have to keep looking stuff up, and-or seeing again what are the steps of doing stuff-scripts-commands-functions-etc, lol).

so here's my attempt at doing so, and hopefully it just needs some small tweeks/additions for it to work:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
msg (player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
if (HasAttribute(player, "male")) {
SetObjectFlagOn (player, "male")
}
else {
SetObjectFlagOn (player, "female")
}
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
switch (player.race) {
case (human) {
SetObjectFlagOn (player, "human")
}
case (elf) {
SetObjectFlagOn (player, "elf")
}
case (dwarf) {
SetObjectFlagOn (player, "dwarf")
}
}
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
switch (player.class) {
case (warrior) {
SetObjectFlagOn (player, "warrior")
}
case (cleric) {
SetObjectFlagOn (player, "cleric")
}
case (mage) {
SetObjectFlagOn (player, "mage")
}
case (thief) {
SetObjectFlagOn (player, "thief")
}
}
msg (player.alias + " is a " + LCase (player.gender) + " " + LCase (player.race) + " " + LCase (player.class) + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</object>
</object>
<turnscript name="turns script">
<enabled />
<script>
player.turns = player.turns + 1
</script>
</turnscript>
</asl>


I think this is probably relevant to my problem in my coding not working:

jaynabonne wrote:I see something running through both of your questions. Let's tackle the first one first.

A word about variables: a simple variable name used in a script, one which is not an object or an attribute of an object, is always a local variable to that script. In other words, it only exists within that script, and it goes away when the script exits. As you discovered, while you remain within the script, the variable exists. Once it exits... poof! And same named variables used in different scripts are actually different, unrelated variables.

What you need is a global place to store your data. You almost (perhaps accidentally) got the answer in your question: "So is there any way to create and add to a list that is remembered by the game?"

The answer is to store the list as an attribute of the global game object (you could also store it as an attribute of the player). Instead of using CombatMenu, use game.CombatMenu. The former is a local variable. The latter is a persistent attribute of the game object.

Keep in mind that if you do "new string list" every time you learn a new skill, then you will wipe out the old list. So you will need to check if the list already exists. If it does, then move onto to setting the new skill. Else create it first.

Your second question seems similar. You want a way to associate a value with the enemy. The answer is the same: use an attribute. You can create an integer attribute (for example) on the enemy, and then decrease it by your "dmg" amount. If the value goes to zero or negative, then move the enemy off to some hidden room (I call mine "Limbo" typically) so the player can no longer see it.

Hope that helps!


but, I still can't figure out how to adjust my coding to get it to work.

my guess is that I'm not connecting (as I don't know how to do so):

[player.race = result] to [switch (player.race)]
~or~
[player.race = result] to [case (human)]

Pertex
HegemonKhan wrote:... but I'm a bit confused in understanding what is and isn't localized...


This is rather easy. Just say you are living in your house in a city and you want to invite other people to your birthday party. If you pin your invitation (in Quest this would be your attribute or flag) inside your living room (in Quest this would be your room object), it's localized. Only people inside your house can read this invitation. But if you want to invite all the people of your town, you have to go to the townhall (in Quest this would be the game or player object) and publish your invitation there.

And you are right, it's a problem of your cases. result is a string variable so you have to test a string in your cases

instead of
case (human)


try:
case ("human")


same with other cases

HegemonKhan
ZOMG ZOMG, I think I just found the solution all on my own [EDIT: as I hadn't read your post yet at this moment, Pertex, which I just now have noticed and read, lol] (I hope, as I got to test it via seeing if I can apply the flag setting for something)! hehe.

I noticed via the coding:

if (HasAttribute(player, "male")) {
SetObjectFlagOn (player, "male")

and came up with the idea to try typing this into the switch GUI:

switch (player.race) {
case (human) {

in other words, I didn't type in the syntax correctly for it (the switch script GUI), so I did so, it looks like this:

switch (HasAttribute (player, "!") {
case ("human") {

and, no error came up! now, I just need to figure out how to test if my flag settings actually work... HK crosses his fingers....

here's the new full game code:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
msg (player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
if (HasAttribute(player, "male")) {
SetObjectFlagOn (player, "male")
}
else {
SetObjectFlagOn (player, "female")
}
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
switch (HasAttribute (player, "!")) {
case ("human") {
SetObjectFlagOn (player, "human")
}
case ("elf") {
SetObjectFlagOn (player, "elf")
}
case ("dwarf") {
SetObjectFlagOn (player, "dwarf")
}
}
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
switch (HasAttribute (player, "!")) {
case ("warrior") {
SetObjectFlagOn (player, "warrior")
}
case ("cleric") {
SetObjectFlagOn (player, "cleric")
}
case ("mage") {
SetObjectFlagOn (player, "mage")
}
case ("thief") {
SetObjectFlagOn (player, "thief")
}
}
msg (player.alias + " is a " + LCase (player.gender) + " " + LCase (player.race) + " " + LCase (player.class) + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</object>
</object>
<turnscript name="turns script">
<enabled />
<script>
player.turns = player.turns + 1
</script>
</turnscript>
</asl>

HegemonKhan
Thanks for the help Pertex! (but, I'm glad I was able to figure this out on my own, hehe!)

anyways, I just tested if I needed the:

HasAttribute (player, "!") for the GUI's switch's box

but it doesn't (so, I can still use the player.race for the GUI's switch's box), as it was only the GUI's switch's cases syntax that I had incorrect.

I'm guesing that from your post, the set flags will work, so I can apply the player.gender, player.race, and player.class to the rest of the game, right?

(this is really cool, I'm getting stuff right, doing stuff right, setting up stuff right, and am only merely messing up on the proper syntaxes, lol)

but now the hard part, creating the status attributes, and then changing them (e.g. combat, level ups, learning spells/abilities, and etc)...

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

P.S.

sorry for being unclear.

I understood what localization was, but didn't know what terms-things were localized within the script-block.

So, any attribute, object, and-or variable within a script-block is localized? Is there anything else that gets localized as well? And, is there anything that doesn't get localized too?

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

wait... the flag is localized? then will I not be able to call upon-apply-use my player being set to male/female, human/elf/dwarf, and warrior/cleric/mage/thief beyond the starting script to the rest of the game ???

as my thinking-plan was to be able to use:

(a very flimsy example only, as I got to figure out how to do all this type of stuff, lol)

If object player has the set flag "Warrior",
then starting stats are strength=5, intelligence=0, etc, at level up he/she gets +2 strength, +0.5 intelleigence, +20 HP, etc

if object player has the set flag "mage",
then starting stats are strength=0, intelligence=5, etc, at level up he/she gets +0.5 strength, +2 intelleigence, +5 HP, etc

and my player is properly refered to as the correct gender (and whatever else can be done via this...)

HegemonKhan
so, I've been trying to do this status attribute stuff, and am having trouble in figuring out how to set this up correctly.

ultimately, my end design, would need to be (for example) a "template" of max and current status attributes which then can be adjusted (via the character creation "Object -> Game -> Starting Script" choices, a character-player level up system, in-by combat, various "events", and-or etc, and temporary and permanent changes).

but for right now, I was-am just trying to figure out how to adjust the status attribute "strength" via the set flagged player.race human (which I want it to give the player the starting status attribute of strength = 5).

But, I think this is pertinent to figuring out how to do status attributes correctly:

viewtopic.php?f=10&t=3229#p21519

so, maybe my "guess-method set up" is the entirely wrong way to do this, so if I could get some help, I'd be thankful, as I am really confused, having trouble making sense of how to do this stuff with status attributes.

here's my own attempt at getting status attributes to work (by being effected by my character creation choices):

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
msg (player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
if (HasAttribute(player, "male")) {
SetObjectFlagOn (player, "male")
}
else {
SetObjectFlagOn (player, "female")
}
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
switch (player.race) {
case ("human") {
SetObjectFlagOn (player, "human")
}
case ("elf") {
SetObjectFlagOn (player, "elf")
}
case ("dwarf") {
SetObjectFlagOn (player, "dwarf")
}
}
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
switch (player.class) {
case ("warrior") {
SetObjectFlagOn (player, "warrior")
}
case ("cleric") {
SetObjectFlagOn (player, "cleric")
}
case ("mage") {
SetObjectFlagOn (player, "mage")
}
case ("thief") {
SetObjectFlagOn (player, "thief")
}
}
msg (player.alias + " is a " + LCase (player.gender) + " " + LCase (player.race) + " " + LCase (player.class) + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = ;strength = </statusattributes>
<strength type="int">0</strength>
<changedstrength type="script">
firsttime {
switch (GetBoolean (player, "!")) {
case ("human") {
player.strength = player.strength + 5
}
case ("elf") {
player.strength = player.strength + 0
}
case ("dwarf") {
player.strength = player.strength + 10
}
}
}
</changedstrength>
<race type="list">human; elf; dwarf</race>
</object>
</object>
<turnscript name="turns script">
<enabled />
<script>
player.turns = player.turns + 1
</script>
</turnscript>
</asl>


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

EDIT: I was just looking through the forum, and read again about pixie's PlayerRace file, and re-learned that this too (I think - hope) covers how to set up changes to the status attributes.

viewtopic.php?f=10&t=3166

I'm going to work on my status attributes using this forgotten file by pixie that I had already DL'ed and looked at in the past, lol.

here's pixie's PlayerRace.aslx code:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="PlayerRace">
<gameid>afc92fdb-8e64-4f7a-9f77-22f005737a40</gameid>
<version>1.0</version>
<start type="script">
show menu ("Choose race", game.race_options, false) {
if (result = "Human") {
msg ("So, you are a human...")
player.strength = 5
player.magic = 2
player.charm = 3
}
if (result = "Elf") {
msg ("So, you are an elf...")
player.strength = 2
player.magic = 5
player.charm = 4
}
if (result = "Pixie") {
msg ("So, you are a pixie...")
player.strength = 4
player.magic = 7
player.charm = 9
}
}
</start>
<race_options type="list">Human; Elf; Pixie</race_options>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
</asl>


I can't figure out why my coding won't work, as it seems like it should to be the same as pixie's PlayerRace coding...

is it because the set flag in the game script is localized, and so that's why the attribute/status attribute doesn't change from 0 to 5 ??? or is there some other reason it's not (I'm missing something, a step, or got the wrong syntax) ??? or must I have the coding that adjust the attributes be immediately following the game stript coding dealing with player.race (and then with player. class) ??? Is my attribute syntax or status attribute syntax incorrect ??? Do I need to make a list ???

Pertex
Strength works correctly. It shows 0 because you don't set this attribute and so the changed script cannot work. So I set strength =10 (initial value) after the input of name, gender, class and race. Then you have to edit your changedstrength script:

your code:
 switch (GetBoolean (player, "!")) {
case ("human") {
...


GetBoolean returns false or true, so you can't check a string value in the case.
! is not a attribute so you can't use it in GetBoolean
So I changed the code this way:
switch (GetString (player, "race")) {
case ("human") {
....


new version:

Pertex
Another thing I changed in your file is the start script:

         player.race = result
switch (player.race) {
case ("human") {
SetObjectFlagOn (player, "human")
}
case ("elf") {
SetObjectFlagOn (player, "elf")
}
case ("dwarf") {
SetObjectFlagOn (player, "dwarf")
}


With this code you are saving the race (same with class or gender) in two attributes: player.race and player.human/player.elf or player.dwarf. These are redundant informations which should be avoided. So just work with player.race and remove the other attributes like this:

HegemonKhan
thanks Pertex, though I have to look over what you did, to hopefully understand the coding better, hehe. This may or may not take me some time. it seems simple enough of what you did, I just need to grasp it fully, so I'll be able to use it for my future coding ventures.

with your changes, will I still be able to adjust my status attributes directly (through like a level up system, events, combat, and etc) and indirectly through what race (human, elf, dwarf) and class (warrior, cleric, mage, thief), such as also through a level up system, still later on in the game ???

I basically just want to make your standard rpg, meaning having the status attributes set up as a "template or blue print", so they can be easily manipulated throughout the game through many numerous and various means-ways-methods. As I don't want to create the status attributes as rigid, blocking me from having them be easily changed-manipulated by other codes.

As rpgs are the types of games that I'm interested in (yes, I know these are probably the most ambitious types of games, but this is my goal!), and I hate bothering you all with coding questions, but without learning more and more coding, I remain very limited in what I can do, obviously. And as I learn more coding, the more I'll be able to do-create my own coding on my own, so less bugging of you guys-girls, and more independence for me.

anyways, thanks again, Pertex, I am thankful for all the help (and patience) you guys-girls give to us noobies as we fumble our way in trying to do more with what quest allows us to do.

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

a quick response of my brief look at your coding (I'm still looking but its late here, and I need to get to bed, I'm very tired):

okay, I think I see a problem, but it's not your fault, as I didn't explain clearly what my goal was very well or not even at all, my apologies!

I wanted to see if I could set it up so that gender, race, and class could be used to manipulate my status attributes (such as strength, intelligence, HP, MP, agility, endurance, fatigue, and etc; your common rpg stuff). I want my initial-starting status attributes to be based upon the choices of gender, race, and class, and then for my starting attributes to be or be able to be adjusted like when I level up, an event occurs, through combat (such as spells, "Weakness Spell: strength down"), as well as having the ability to do temporary changes as well as permanent changes on-to the status atributes, and have (for which they, temp and perm, apply to of your) current and max status attributes. And-or etc anything else. I need to create a flexible coding system with my status attributes that allows me to easily apply various codes to change them over the entire game play.

So, that was my thinking in how I tried my attempted coding structure, as I was just trying to learn how to do it, via player.race "human", but once I had learned, I'd be doing the same for gender and class (and-or whatever else) too. So, that's why I wanted to try to set up the flags of "human" (and then also of elf, dwarf, warrior, cleric, mage, knight, male, female, and etc), so that I could then easily apply a code (to change those status attributes) by calling on the set flags. but, being a noob, my attempt was incorrect. though, if I understand your coding changes, they will-do have problems with what I want to accomplish (and again, this is *MY* fault, as I didn't clarify what I wanted to accomplish, and so you didn't know what I was trying and was wanting to accomplish), or maybe your coding does enable what I want, and I'm mistaken that it will have problems in doing so.

P.S.

did I set up my flags correctly (and my only problem was that I tried to call upon them wrongly by using the switch boolean in hoping to cut down on the steps needed without using it, instead of simply via the switch itself with more steps? can even to begin with in the first place, can the flags be called upon from outside of the starting script?

Do I need the redundency of "player.race" and "player.race.human" for what I want to do, or do I not need it, and thus this is redundency? Or, do I need to do something like this, but to do it differently, to do it correctly (and not have the redundency) ?

Pertex
Let's come back to your code. After running the startscript and choosing "human" in the menu you will have the attribute player.race set to "human" and you will have player.human set to true.
Later in the game you want to increase strengh for humans, so what will you script? Something like this:

if(GetBoolean(player,"human")){
player.strength=player.strength+10
}


The same thing can be done with

switch(GetString(player,"race")) {
case("human"){
player.strength=player.strength+10
}


So all things you can do with player.human can be done with player.race.

You can call or set attributes like player.race everywhere in your game. If you change the status attribute player.strength anywhere in your game it will immediately changed in the status pane.

HegemonKhan
thanks, after resting-sleeping, this makes complete sense now. I shouldn't have tried to look at what you did, when I was barely able to keep my eyes open, lol.

EDIT: I got it fully figured out now, thanks Pertex!

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

last question for this current topic (hopefully),

what about the player's reference to gender and articles in terms of the text, how do I apply my starting script choices, so that it applies to string-message references using the gender and article for the player? As I can't set the gender and article via the object -> player -> object (or whatever the corresponding tab is called, I can't name it off hand -from my memory- like this, yet), as my starting script is doing the decision on-of what gender my player will be. so how do i get the descriptors of gender and article to match up to what I choosen in the starting script?

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

my big mistake in this whole thing was in wanting to change the status attributes from the starting script (though it wasn't a complete waste, as I did learn how to adjust status attributes! thank you a lot Pertex, and indirectly pixie too via his posts), but I realize that for the game design, there's not much reason to do so, as instead, I should just use-create a level up system based upon the gender, race, and class, to adjust the status attributes, letting them start with 0 status attributes, and then at the first and subsequent level ups, do their status attributes change, based upon their gender, race, and-or class. And-or, I can create, I'm sure that it is code'able anyways, a level up system where you choose where to put your "attribute points" into which status attributes. Though this would be more complex coding than just a level up system that applies the status attribute points for you, vs you being able to choose where to put them, vs combining both being able to choose and having the game put them where to go or where they can go, hehe).

so, I guess my next task-challenge is to try to create a level up system (and then have it apply the status atribute changes).

Let me try to do what I can first... hopefully I won't have to ask-get much help... but no promises... not yet anyways... as I am still trying to learn the coding still, not yet having a grasp of it, as seen by me just trying (and failing) to set up the status attributes being changed, sighs.

Pertex
HegemonKhan wrote:
what about the player's reference to gender and articles in terms of the text, how do I apply my starting script choices, so that it applies to string-message references using the gender and article for the player? As I can't set the gender and article via the object -> player -> object (or whatever the corresponding tab is called, I can't name it off hand -from my memory- like this, yet), as my starting script is doing the decision on-of what gender my player will be. so how do i get the descriptors of gender and article to match up to what I choosen in the starting script?


Hmmm,do you really need gender and article of the player in your game? You can set this same as the other attributes player.article="xxxx"

HegemonKhan
hmm, not sure. I was jsut asking just in case if I would be using-needing the gender and article.

ah cool, that makes it easy then, laughs (should I need to use it). I can set it (the article, player.article) up along with when the gender (player.gender) is set up.

HegemonKhan
new topic-questions now:

I need some help now! (hopefully the help needed only requires getting a single expression line with the correct syntax)

Now, I'm starting on trying to apply-do more with the status attributes, in my working towards the stuff needed for making an rpg game. I'm just working on making a lvl up system first, but I'm having trouble with (again hopefully just the syntax of a single expression line) my attempt at making a 'lvlup' function (I'll bolden, italize, and underline the part I can't get the syntax right):

Script -> If... -> object (player) attribute (experience) = or is greater than [(player.level x 100) + 100]
-> Then, set variable or attribute (player.level) = player.level + 1
-> add script -> set variable or attribute (player.experience) = 0

I want this function effect (hopefully my above coding's math equation is on the right track to achieving this effect, lol):

experience = level

0 = 0
0 to 99 = 0
100+ = 1
0 = 1
0 to 199 = 1
200+ = 2
0 = 2
0 to 299 = 2
300+ = 3
0 = 3
etc

and here's my entire game file coding (see if I have any other problems, or if I just need help with the expression syntax):

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<showscore />
<showhealth />
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<age type="int">0</age>
<height type="int">0</height>
<weight type="int">0</weight>
<strength type="int">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="stringdictionary">age = ;height = ;weight = ;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = ;turns = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
<turns type="int">0</turns>
</object>
<object name="potion1">
<inherit name="editor_object" />
<alias>experience potion</alias>
<take />
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
RemoveObject (potion1)
</drink>
<alt>exppot; exp pot; exp potion; potion</alt>
</object>
</object>
<turnscript name="turns lvlup script">
<enabled />
<script>
lvlup
player.turns = player.turns + 1
</script>
</turnscript>
<function name="lvlup"><![CDATA[
if (player.experience = " + " " or " + > + " " + msg ((player.level * 100) + 100) + ".") {
player.level = player.level + 1
player.experience = 0
}
]]></function>
</asl>


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

P.S.

I haven't looked yet at what people ahve requested, so maybe this has already been mentioned, but here's my request:

when you do lots of scripting (as it gets indented more and more), it gets cut off on the right side, now I can expand the editor window to full screen, but that only helps in adding a little more space, and I also now that you can open up the script window too, but again, this can have the same problem, as it too only adds a little more space, and you can also move (expand-contract) the editor's sub windows, but again, only a little more space is achieved. I do know that you can just ignore the editor-GUI, and just go put in the coding itself (via the code view mode), but that's not too easy for us who still haven't learned all the coding language yet, especially for us noobs, who hardly, or if not at all, understand any of the actual coding stuff.

so, would it be possible to implement some left-right (horizontal) scrolling bars for the scripting of scripts ???

I know I could write out the code on like wordpad or MS word writing programs, copy, and then paste it over to the editor's script, but I also think you can be so indented over to the right side, that you can't even have the script box to paste in your code into like for the expression box at the end of an (for example) 'If..' script.

normally, this shouldn't come up much, and you can do things (separate the scripting) so you're not indenting scripting so much, but there may be times where it's unavoidable (such as doing a really long-complex script block for you advanced coders), but I was playing around (using) the 'wait for press key' script, and apparently this can only be used once per indentation spacing-times, and it's scripting box really indents the following script far over to the right as well, and this is how I had my script get indented far to the right, and found out that it gets cuts off, and with hardly anything to do about it.

The Pixie
Your if expression is seriously messed up; it like you are comparing to a string with the double quotes there. Here is a better version.

  <function name="lvlup"><![CDATA[
expneeded = player.level * 100 + 100
if (player.experience >= expneeded) {
player.level = player.level + 1
player.experience = player.experience - expneeded
}
]]></function>


First step is to work out how many XP are needed at this level.
Then it compares that to the current experience.
If the players experience is enough, it raises the level, and drops the player's experience (rather than setting to zero; consider if the potion gave 190 XP).

HegemonKhan
thank you pixie!

(I did wrong script choice, I really need to learn all of the other scripts and etc codes still, sighs-grr, and also due to my not realizing that I needed to make-set my math equation into a variable / attribute for it to work)

(I was debating whether to save the extra experience or not, that was a conscious choice of mine, though I probably wouldn't have figured out how to do it, saving the experience, as I didn't realize even that I needed to set up the equation as a vari-attr, so thank you for showing me how to do this, player.experience - expneeded, as well !! Though, now I think I do like to keep-save the experience, so I've changed my mind on this, laughs. As it would be a lot of wasted experience if I just set it to 0 after every lvl up)

quick question (well, nvm, as I'll go test it, lol): I presume that if I drank a potion that gave me 300 experience (100 exp for lvl 1 + 200 exp for lvl 2) that it would register in giving me first lvl 1 lvlup and then lvl 2 lvlup, right?

[HK EDIT: it works fine, with a loop, call function (lvlup), at the end of the (idented) function's, lvlup's, script block, otherwise it won't give the 2nd lvlup until after the next player turn ticks). In hindsight, DUH!, lol, HK is such an idiot!]

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

I also got my status attribute changes to work based upon gender, race, and class (yeah!, no problems with this, lol):

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<showscore />
<showhealth />
<start type="script">
msg ("What is your name?")
get input {
msg (" - " + result)
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + " " + player.gender + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<age type="int">0</age>
<height type="int">0</height>
<weight type="int">0</weight>
<strength type="int">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="stringdictionary">age = ;height = ;weight = ;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = ;turns = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
<turns type="int">0</turns>
</object>
<object name="potion1">
<inherit name="editor_object" />
<alias>experience potion</alias>
<take />
<alt>exppot; exp pot; exp potion; potion</alt>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
</object>
</object>
<turnscript name="turns lvlup script">
<enabled />
<script>
lvlup
player.turns = player.turns + 1
</script>
</turnscript>
<function name="lvlup"><![CDATA[
expneeded = player.level * 100 + 100
if (player.experience >= expneeded) {
player.level = player.level + 1
player.experience = player.experience - expneeded
switch (player.gender) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
}
case ("elf") {
player.agility = player.intelligence + 2
}
case ("human") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
}
]]></function>
</asl>


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

I think for the next two things (and also my #0 "drink" below to figure out) for me to work on are:

0. figure out how to get the "drink" verb (and-or also set it up as a command for universal use) for my potion to show up on the gui, lol. need to go back and read up on this, either in the tutorial or the forum posts. I've seen it shown how to be done, just wasn't paying attention at the time, and nor can't remember either, laughs.

e.g. "currenthitpoint = maximumhitpoint = health: excellent"

1. setting up the status attributes to give the correct textual descriptions
2. setting up having cur and max status attributes

then maybe, hmm...

3. monster / combat
4. temporary-vs-permament status attribute changes
5. status attribute equations (e.g. strength-endurance="effective" strength, and-or also e.g. "secondary-derived" stats)
6. spell / ability learning and casting-using
7. equiping and its (the equipments' ) attributes / stats (this also includes "secondary-derived" stats too)
8. whatever else I'm forgetting or not realizing I'll need to figure out, lol.
9. elemental damages and monster's/equipment's affinities; weak (vulnerable), strong (resistant), immune, absorb, reflect, normal-standard

The Pixie

... also due to my not realizing that I needed to make-set my math equation into a variable / attribute for it to work


If you mean where I set expneeded and used that for the comparison, then I did that to help make the code clearer. It would still work with:

if (player.experience >= player.level * 100 + 100) {

To get "Drink" to be shown in the GUI, just look at the Display verbs on the Object tab for that object.

For spells, look at this tutorial:
http://quest5.net/wiki/Using_Types

I will leave you to figure out the rest for now...

HegemonKhan
ah nvm then, I don't need to make it into a "set variable or attribute", lol. Then my problem was simplying choosing the wrong script (by my using of the GUI) of "object has variable or attribute equals" (or whatever it is called), so the problem being that dumb equals in it, as I was trying to figure out how to add the "greater than" onto it, lol. Anyways, thanks again, as it is good for me to know that I don't have to make a separate "set variable or attribute" script line, as I can apply it directly into the script's expression part.

ah, that's simple for getting the verb to appear as a choice, I just coudn't remember what I was to do, sighs. I try to practice doing stuff over and over, so I get it memorized-understood, as without doing so, it's like when I was taking math. I'd listen to the lecture and understand everything, but by not practicing doing the actual math problems over and over, I got confused and couldn't do them, despite having understood the lecture on how to do them so well. (this was when I was getting really lazy in doing school work, lol).

Thanks for the link. I have come across (read) that wiki part before, as well as other posts on the forum (probably by you, lol. As you've got a lot of such small libraries, hehe) about how to do such things. I just needed to re-find and read them again.

I try to do everything on my own first, and only ask when I'm stuck with something. As it helps me learn+understand the coding better. I don't like to just copy and paste your codes, as I'm not learning anything by that, and I can't always infer what is being done in the codings either, in how they get processed or what is going on with them.

HegemonKhan
Actually,

I've discovered that by taking out the expneeded = player.level * 100 + 100, the usage of expneeded in the rest of the scripts, produces very incorrect results-outputs, and I think the problem arises with the player.level = player.level + 1, as this seems to get applied to the rest of the script and-or as well with the looping of it as well, you end up get extra experience added, laughs.

I don't understand why it produces the different and incorrect results-outputs, as shouldn't there be no difference between:

(I'm going off of my memory, so this may be incorrect scripts, check the actual scripts I'll provide as the full game codes at the bottom)

expneeded = player.level * 100 + 100
player.level = player.level + 1
player.experience = player.experience - expneeded

and (vs)

player.level = player.level + 1
player.experience = player.experience - player.level * 100 + 100

...well...

I guess, by looking at this just now, that by using the expneeded, it ignores the player.level = player.level + 1, which produces the correct-wanted-desired results-outputs, whereas by not using the expneeded it applies the player.level = player.level + 1, which produces very incorrect-unwanted-undesired results-outputs

I'm sure the coding can be fixed to work without using the expneeded, but I can't figure it out myself.

so, if any of you experts are interested in this issue, as maybe a challenge, to fix-work out, I'll provide the two codes, so you can test and solve the problem, just for the fun of it, as I can just use the expneeded myself.

(or maybe I'm just messing up in my attempt to remove the usage of the expneeded, this could certainly be the case as well)

here's the code that uses the expneeded, which produces the correct results-outputs:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<showscore />
<showhealth />
<start type="script">
msg ("What is your name?")
get input {
msg (" - " + result)
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + " " + player.gender + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<age type="int">0</age>
<height type="int">0</height>
<weight type="int">0</weight>
<strength type="int">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="stringdictionary">age = ;height = ;weight = ;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = ;turns = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
<turns type="int">0</turns>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
<displayverbs>Look at; Take; drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
player.experience = player.experience + 300
</drink>
<displayverbs>Look at; Take; drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
</object>
</object>
<turnscript name="turns lvlup script">
<enabled />
<script>
lvlup
player.turns = player.turns + 1
</script>
</turnscript>
<function name="lvlup"><![CDATA[
expneeded = player.level * 100 + 100
if (player.experience >= expneeded) {
player.level = player.level + 1
player.experience = player.experience - expneeded
switch (player.gender) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
}
case ("elf") {
player.agility = player.intelligence + 2
}
case ("human") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
lvlup
}
]]></function>
</asl>


here's the coding (my attempt at changing it, so maybe I just simply messed up in doing so, and it's just human error by me):

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<showscore />
<showhealth />
<start type="script">
msg ("What is your name?")
get input {
msg (" - " + result)
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + " " + player.gender + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<age type="int">0</age>
<height type="int">0</height>
<weight type="int">0</weight>
<strength type="int">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="stringdictionary">age = ;height = ;weight = ;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = ;turns = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
<turns type="int">0</turns>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
player.experience = player.experience + 300
</drink>
</object>
</object>
<turnscript name="turns lvlup script">
<enabled />
<script>
lvlup
player.turns = player.turns + 1
</script>
</turnscript>
<function name="lvlup"><![CDATA[
if (player.experience >= player.level * 100 + 100) {
player.level = player.level + 1
player.experience = player.experience - player.level * 100 + 100
switch (player.gender) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
}
case ("elf") {
player.agility = player.intelligence + 2
}
case ("human") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
lvlup
}
]]></function>
</asl>


see how: the experience is all wrong now. (maybe, I'm just not setting up the syntax correctly, so that it reads-does-operates the math equation correctly, as well).

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

So, a small question-help that I need, now that I'm delving into the usage of math equations:

can someone help me in how to do the syntax to get the correct order of operations with the usage of math equations?

like for example (using the codes above), if I have:

player.experience - player.level * 100 + 100

how do I write it, in the syntax that the game understands, so that it does (the below add-on of, 25 * expneeded, is just an example only for how to write it, to do it correctly):

[ player.experence - ( ( player.level * 100 ) + 100 ) ] + [ 25 * expneeded ]

instead of the game doing this (for example), incorrectly:

[ ( player.experence - player.level ) * ( (100 + 100) + 25 ) ] * [ expneeded ]

The Pixie

expneeded = player.level * 100 + 100
player.level = player.level + 1
player.experience = player.experience - expneeded

and (vs)

player.level = player.level + 1
player.experience = player.experience - player.level * 100 + 100


The two differences are that:

1. in the second case player.experience uses player.level after it has incremented.

2. the extra hundred is being added when it should be taken away.

So, flip the lines and bracket the increment (or change it to minus):

player.experience = player.experience - (player.level * 100 + 100)
player.level = player.level + 1

For this, as * takes priority, you can get rid of all of the brackets, just change the add to minus:

[ player.experence - ( ( player.level * 100 ) + 100 ) ] + [ 25 * expneeded ]

... becomes...

player.experence - player.level * 100 - 100 + 25 * expneeded

There is a standard order of precedence common to most programming languages, so everything inside brackets is done first, then comparisons (equals, less than, etc.), multiply and divide are done next, finally plus and minus.

HegemonKhan
ah thank you pixie!

I had tried moving the, player.level = player.level + 1, line myself, but it caused trouble in-with the looping in with displaying the correct player's level, I think... (though I can't remember what were all the places I've tried to move the line to).

ah, okay, the syntax works the same as how we in the U.S. show the proceedure for math equations. I was worried that by using the brackets and-or parenthesis that it would cause other coding stuff, and thus couldn't be used for separating your operations in a math equation.

HegemonKhan
alright...

I think I'll work on getting the spells (creating a simple new object type) to work, as that is the easiest thing to do, lol. I had started on this, but I must have done something wrong, as I messed it up, I'll go back over it again and see if I can figure out what I've been doing wrong or missing, with more careful attention. So, hopefully I can figure out this on my own.

----

anyways, I was wondering, with what I currently know (almost nothing) any ideas on what the next thing I should tackle getting to know and understand?

(As I was looking at Pertex' combat library via in its code form by opening it with wordpad, and before I even get started on trying to understand that, laughs, *YIKES* - and I thought I was making some progress - my morale dropped to zero again lol, I clearly need to start understanding lists, stringlists, dictionaries, dictionarylists, scriptlists, parameters, how to code write a lot of scripts of like using the scopes and etc stuff, and whatever else I'm not naming down here, that I need to know, laughs)

or is this (the stuff-codings in Pertex' combat library) the next thing for me to be learning, as this is a big jump for me (lol), is there any more intermediate things for me still to learn or is this (Pertex' combat library stuff-codings) the next thing for me to work on understanding? If it is, what are the easiest pieces of it to start with, and then the gradually harder pieces on up?

----------

As all I know so far is creating basic status attributes, setting up a character creation system, and a basic lvlup function.

what would be a good next step thing for me to try to learn now?

----------

Also, a quick question, is this possible to code?

for your displayed status attributes:

hit points (hp): "current hp (curhp)" / "maximum hp (maxhp)"
magic points (mp): "curmp" / "maxmp"

hp: 250 / 500
mp: 100 / 200

(the / is just used as a-the separator of the two values)

(using-needing 6 attributes: hp, mp, curhp, curmp, maxhp, and maxmp)

instead of having:

curhp: 250
maxhp: 500
curmp: 100
maxmp: 200

(using-needing only 4 attributes: curhp, curmp, maxhp, and maxmp)

(and I also got to go back and read -I think it's katsune's thread~post- on how to set up and line up columns, lol)

The Pixie

Also, a quick question, is this possible to code?

for your displayed status attributes:

hit points (hp): "current hp (curhp)" / "maximum hp (maxhp)"
magic points (mp): "curmp" / "maxmp"

hp: 250 / 500
mp: 100 / 200


Yes. At the end of each turn (so in a turn script) set a status attribute that is a string.

hp_as_string = "hp: " + curhp + "/" + maxhp

Then have hp_as_string as the status attribute.

HegemonKhan
thanks pixie, (doh! I had the syntax right laughs, but I didn't know to create the string as a separate script first and in the game start too, as I think I did try to do the syntax for the player add attribute script msg, expression, but that wasn't working with the displayed status attribute of mine, "hp")

I just re-noticed that when you create a status attribute, it's second box-window says something like formatting text, is this an alternative method (place to type in the same string script: hp_as_string) to achieve the same thing, or no?

-------

laughs

it helps to remember to type in the object, lol:

hp = curhp + " / " + maxhp (took me awhile to realize why this wasn't working)

player.hp = player.curhp + " / " + player.maxhp

The Pixie
If you have currhp as the attribute, Quest defaults to:
currhp: 100

Using formatting text, you can change that. Say if it was money, you want "Money: ÂŁ100", you would use "Money: ÂŁ!", he exclamation mark stands for the value (do not use quotes).

HegemonKhan
ah okay, so that's what the format text box is for, hehe. I remember this in the tutorial about using the "!", anyways.

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

ok... I'm a bit confused now... I'm not sure what you are saying to do... sighs (sorry!), what do you mean by "string" ? Is the hp_as_string a coding language's command that creates a string?

(for testing only: player.curhp type "int"= 250 and player.maxhp type "int"= 500)

when I do:

player -> attributes -> add attribute -> hp -> [string script] -> "hp: " + curhp + " / " + maxhp
player -> attributes -> add status attribute -> hp
displayed during game play -> hp: "hp: " + curhp + " / " + maxhp (so, this isn't working obviously)

player -> attributes -> add attribute -> hp -> [print a message script] -> [expression] -> "hp: " + curhp + " / " + maxhp
player -> attributes -> add status attribute -> hp
displayed during game play -> hp: msg "hp: " + curhp + " / " + maxhp (so, this isn't working obviously)

player -> attributes -> add attribute -> hp -> [set variable or attribute script] (player.hp) = "hp: " + player.curhp + " / " + player.maxhp
player -> attributes -> add status attribute -> hp
displayed during game play -> player.hp: "hp: " + player.curhp + " / " + player.maxhp (so, this isn't working obviously)

what I've done, that works:

game -> "turns" turn script -> [set variable or attribute script] (player.hp) = [expression] player.curhp + " / " + player.maxhp
game -> "turns" turn script -> [set variable or attribute script] (player.turns) = [expression] player.turns + 1
player -> attributes -> add status attribute -> hp
(I do NOT do, nor do I also do: player -> attributes -> add attribute -> hp)
displayed during game play (turn 0) -> hp: ______ (I'm not sure how to, nor know why it's not reading-inputing the 250 / 500)
displayed during game play (turn 1) -> hp: 250 / 500 (it works)

The Pixie
Look at this:

<!--Saved by Quest 5.3.4721.18482-->
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing">
<gameid>e352a6d8-c005-4b44-8021-1cf6a3f13fde</gameid>
<description type="string"></description>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<curhp type="int">250</curhp>
<maxhp type="int">500</maxhp>
<hp>Hits: 500/500</hp>
<statusattributes type="stringdictionary">hp = !</statusattributes>
</object>
</object>
<turnscript name="TrackHits">
<enabled />
<script>
player.hp = "Hits: " + player.curhp + "/" + player.maxhp
</script>
</turnscript>
</asl>

HegemonKhan
interesting... (and thank you pixie, my confusion is seen by the coding pecularity that I discovered and show within this post)

your code: (using the ! mark)

1. <hp>Hits: 500/500</hp>
2. <statusattributes type="stringdictionary">hp = !</statusattributes>
3. player.hp = "Hits: " + player.curhp + "/" + player.maxhp
4. "successful result" = Hits: 500 / 500 (turn 0) -> Hits: 250 / 500 (turn 1)

my (new) own code: (NOT using the ! mark)

1. <hp>0 / 0</hp>
2. <statusattributes type="stringdictionary">hp = </statusattributes>
3. player.hp = player.curhp + " / " + player.maxhp
4. "successful result" = Hp: 0 /0 (turn 0) -> Hp: 250 / 500 (turn 1)

your combination and my combination are the only two that works, as if you switch around whether to give the ! or not, and whether to do: (player -> attribute tab -> add attribute) hp string 0 / 0 or hp string Hp: 0 / 0, and (turns turn script) player.hp = "Hits: " + player.curhp + "/" + player.maxhp or player.hp = player.curhp + " / " + player.maxhp, you will get failed results of either, hp: hp: 250 / 500 or 250 / 500 or hp: ___ or hp: hp: ____ or etc etc

here's my (new) own code:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = ;hp = </statusattributes>
<curhp type="int">250</curhp>
<maxhp type="int">500</maxhp>
<hp>0 / 0</hp>
</object>
</object>
<turnscript name="turns turn script">
<enabled />
<script>
player.hp = player.curhp + " / " + player.maxhp
player.turns = player.turns + 1
</script>
</turnscript>
</asl>

HegemonKhan
Edit: nevermind, I just found the problem, in the wiki guide it leaves off the <caption></caption>, which I didn't realize was needed until I just spotted it now in your library file.

Ignore this post, my apologizes. (Though, maybe the wiki guide should be fixed, so it doesn't stump another noob like me)

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

I have a small problem, which I can't figure out:

I'm working on doing these things, making object types and tabs:

http://quest5.net/wiki/Using_Types
http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced)
http://quest5.net/wiki/More_on_Tabs_(Advanced)

and for some reason, the GUI won't apply the "Spell" nor "Magic" for its tab name, the tab remains blank, and I can't figure out why; what I've done wrong. Also, the GUI won't apply the "Spell type" for its name for the drop down. So, if someone could help with this I'd be appreciative! (Or, does the tab remain blank and there's no caption for the drop down, when in the GUI ???)

from working on, http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced),

<tab>
<parent>_ObjectEditor</parent>
Spell
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
Spell type
<types>*=Not a spell; spell=Non-attack spell; attackspell=Attack spell</types>
<width>150</width>
</control>
</tab>


I am a bit confused from the library creation...

am I suppose to be doing all of this in the library file or in the game file?

as from your spell demo game file, you've got all of the types and tabs in your library file, and I done this too, but still my tab name remains blank when in the GUI.

here's my Game File:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="HK magic object type lib.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<object name="aura_spell">
<inherit name="editor_object" />
<inherit name="spell" />
<alias>aura</alias>
<drop type="boolean">false</drop>
<cast type="script">
if (this.parent = player) {
msg ("You cast " + this.alias + " and a blue glow surrounds you.")
}
else {
msg ("You haven't learned this spell yet.")
}
</cast>
</object>
</object>
<object name="spellbook">
<inherit name="editor_object" />
<inherit name="container_closed" />
<take />
<listchildren />
<drop />
<object name="fireball_spell">
<inherit name="editor_object" />
<alias>fireball</alias>
<drop type="boolean">false</drop>
<cast type="script">
if (this.parent = player) {
msg ("You cast " + this.alias + " and a big ball of fire shoots outwards.")
}
else {
msg ("You haven't learned this spell yet.")
}
</cast>
</object>
</object>
</object>
<verb>
<property>learn</property>
<pattern>learn</pattern>
<defaultexpression>"You can't learn " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>cast</property>
<pattern>cast</pattern>
<defaultexpression>"You can't cast " + object.article + "."</defaultexpression>
</verb>
</asl>


and here's my library file:

<?xml version="1.0"?>
<library>
<type name="spell">
<inventoryverbs type="list">Cast</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<learn type="script"><![CDATA[
if (not this.parent = player) {
this.parent = player
msg ("You've learned, and can now cast, the spell, " + this.alias + ".")
}
else {
msg ("You already know it.")
}
]]></learn>
</type>
<type name="attackspell">
<inherit name="spell"/>
</type>
<tab>
<parent>_ObjectEditor</parent>
Magic
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
Spell type
<types>*=Not a spell; spell=Non-attack spell; attackspell=Attack spell</types>
<width>150</width>
</control>
</tab>
</library>

// I've tried using "Spell" first for the tab's caption, and then I've tried "Magic", but both still get a blank tab name in the GUI.

// for the control, the caption "Spell type" for the drop down doesn't show up either.


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

Edit: nevermind, I just found the problem, in the guide it just states:

<tab>
<parent>_ObjectEditor</parent>
Spell
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
Spell type
<types>*=Not a spell; spell=Non-attack spell; attackspell=Attack spell</types>
<width>150</width>
</control>
</tab>


whereas, in your library file:

<tab>
<parent>_ObjectEditor</parent>
<caption>Spell</caption>
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
<caption>Spell type</caption>
<types>*=Not a spell; spell=Non-attack spell; attackspell=Attack spell</types>
<width>150</width>
</control>
</tab>


in the wiki guide, the <caption></caption> was left out, and I didn't realize this was needed until just now, spotting it in your library file.

The Pixie
Thanks for highlighting this problem on the Wiki. For some reason the Wiki software quietly removes <caption> and </caption> from the pages it displays, which I failed to notice. I have added a comment to note the problem.

Alex
You should use &lt; and &gt;, you can't really just paste arbitrary XML by the looks of it. Updated the page.

HegemonKhan
the wiki guide, *DOES* in its text-reading, mentions the use of captions, but I just assumed that the code was as it suppose to be (I guess I assumed that the tab block itself would code "Spell->Magic and Spell type" as the captions), and thus not realizing to connect the need for the use of the <caption></caption> with the text-reading mentioning of captions, so its mostly my own mistake of being a noob, not realizing this simple coding of the <caption></caption> being needed to be used. As, I should've known better, as code kinda requires everything to be in code, you can't just have "Spell", you got to tell what you want done with it or what you want it to be.

HegemonKhan
I'm at the stage now, where I'm making a big jump up in the coding, and so this section will likely have lots of questions by me, as I'll need massive amounts of help for slowly learning it.

HELP, New Topic! (on this new stage up for me, lots of questions coming your way, but slowly-gradually)

so, I've been looking at the various libraries and (wiki) guides, on:

Wearables = @Chase ( http://quest5.net/wiki/Clothing_Library2 )
Clothing = @Pixie ( viewtopic.php?f=10&t=2567 )
Combat (+Equipment) = @Pertex ( viewtopic.php?f=10&t=2660 )
Spells / Magic (+Monsters) = @Pixie ( http://quest5.net/wiki/Using_Types , http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced) ~ at bottom for his-her files)
Tabs = @Wiki ( http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced) , http://quest5.net/wiki/More_on_Tabs_(Advanced) )
Object Types = @Wiki ( http://quest5.net/wiki/Using_Types )

--

and I generally am now able to understand them now (though the scripting-functioning-commands-etc overwhelms me - I can copy-follow-understand it at each step by step, but I can't put it, the entire process, all together organized and structured in my head, I don't know how you can think up how to do all this and not forget any needed steps - I'm going need to make chart and diagrams to begin to understand it all together, lol).

so let me just start with some quick general questions:

Question 1:

for a combat+npc interaction system idea, I was thinking to give the same attributes to all: player, npcs (non-playable characters), and monsters (I may not use monsters, as they can fall under npcs, not sure if I'd need to have separate or not)

such as for the (for example) reasons:

Combat: player.dexterity - monster.agility = player's affective to hit percent chance
Stealing (npc interaction): player.agility - npc.perception = player's affective stealing percent chance / of getting caught or not

is setting up a new object type "(some name)" and giving it the attributes (agility, dexterity, perception, etc), then setting it as inherited for the various objects (player, npcs, and monsters), and-or also setting up a tab, the best method for this type of system?

Question 2:

Assuming-based upon Question 1, should I keep the player separate (in not giving him-her-it the object type with the atributes) from the npcs and monsters, or should I give the player the object type with the attributes instead of assigning-added the attributes normally via the object -> player -> attributes ??

question 3:

in regards to questions 1 and 2, and with setting up equipment (layed levels and body part equipment slots ~ head-helmet, chest-mail, waist-frauld, legs-greaves, feet-boots, arms-vambrace, hands-guantlets, back-cape-cloak, neck-necklace, fingers-rings, ears-earrings, etc) would all of this (or individually cases) be incorporated into a single tab or two tabs and-or no tabs? (do tabs' controls conflict with, for examples: an inherited object type with an attribute int set to 0, or with using functions?)

question 4:

Do I need to make object types for each equipment body part slot (head, feet, chest, waist, etc) ?? As I was looking at Pertex' combat library, you he-she seemed to only make a stringdictionary within an object type (see-reference at Question 5).

question 5: @Pertex, about your combat library

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>


what exactly are you doing here, what do your codes "say" ?

I'm guessing:

<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" --> (or whatever you want to have) is the string you put into <cmb_where type="string"></cmb_where> , right?

and the <cmb_mod type="stringdictionary"/> contains the string ???

or does the '_mod' (in <cmb_mod type="stringdictionary"/> ) means you're modifying the string script, as I see you using 'mod' elsewhere too (like on-in, '<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>' ) ??

as I got the same question with this too:

<object name="cmb_intern">
<cmb_attribs type="list">CMB_PA;CMB_AT;CMB_STR;CMB_HP;CMB_EXP</cmb_attribs>
<cmb_lvlexp type="stringdictionary">1=50;2=100;3=200;4=400;5=800;6=1500;7=3000</cmb_lvlexp>
<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>
</object>


is the '<cmb_lvlmod...' a modification of the '<cmb_lvlexp type...' ???

Question 6:

do I need to ?, or should I ? put the spell-magic stuff, "character" attributes stuff, body part equipment slots, all together (if they are to be put into tabs) in a single tab ??

jaynabonne
As I don't have any experience with tab, I'll only give my thoughts on questions 1 and 2...

I'm going to take a chance and get a bit theoretical here for a moment. In my opinion, the basic answer to question 1 is "yes", and the answer to question 2 is "it depends." Let me expand a bit on that...

While using types to give common attributes to objects is a good and handy feature of them, the general idea behind inheriting types (also known as "subclassing" in object-oriented circles) is that you want to define an "is-a" sort of relationship. For example, if you have trolls and demons and ogres and vampires and poisonous slugs, and you want them all to have similar properties but you also want them to be looked at as specific types of a generic class (e.g. "monsters"), then it makes sense to create that generic class type ("monster") and inherit from it. It's reasonable in the sense of "a troll is a monster" and "a demon is a monster", but it also helps if you want to have functionality that deals with things at the monster level, where you don't care what kind of monster it is. That's where the power really comes through, when you can write code geared toward an arbitrary monster (the inherited type) and then have all the monsters be handled the same way.

So, that is why I'd say the answer to 1 is "yes". Given what you have said, you do want to treat the monsters (at least on some level) the same, with the same set of attributes, etc. When you write code to deal with a battle, for instance, you won't care if it's an ogre or a slug - just knowing it's a monster will do.

For question 2, well... "it depends." It depends on what type of base object you want to define - you could just call it a "BaseCharacter", which would generally apply. And as far as having common attributes, it could save you from having to define them separately for the player. But what keeps nagging me is: is a player, on any level, the same as a monster? Will you ever have a context where you would generically swap in a player vs a monster? I can think of some. For example, you might want to have some code for healing, where a monster would heal via the same bit of code as a player (e.g. hit points go up by the healing rate, etc). Or you might want to have code that deals with how much can be equipped by a character - monster or plaeyr (this is all off the top of my head, mind you :) ). If that's the case, then I'd say it does make sense to have a common base type.

Another possibility: your battle system, rather than player vs monster, would be character vs character, where you could even have monsters (or whatever other non-player characters youhave ) battle each other. That would allow some to team up with the player and some not. But the battle logic would deal with just two base-level characters.

For me, the bottom line is: is there some common part of the player and the monsters where you'd want to treat the player or a monster in some generic way that is the same for both? Would you ever want to take that base type and perform some operations on it, just at the base type level? If so, then that generic core part (whatever you want to call it) would be a good base type. If the code for player and monsters will forever be separate, then there is no overlap, and it would make more sense (for me, from a design point of view) to keep them separate.

I hope that helps. :)

Pertex
HegemonKhan wrote:
question 5: @Pertex, about your combat library

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>


what exactly are you doing here, what do your codes "say" ?

I'm guessing:

<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" --> (or whatever you want to have) is the string you put into <cmb_where type="string"></cmb_where> , right?

Right. You can put in any value you want e.g "finger", "nose" or even "aaa". When equipping an item, the library checks all object of the type "cmb_equipment" if there is another item worn at this location and if so, it throws a message "You can't waer another item at this location.

HegemonKhan wrote:
and the <cmb_mod type="stringdictionary"/> contains the string ???


No, it contains a stringdictionary. It contains the attribute modificators, if this item is equipped. Something like
<cmb_mod type="stringdictionary">at = +3;str = +1;hp = 21</cmb_mod>

The script reads all this values and increases ( or decreases) the actual attributes of the player

HegemonKhan wrote:
or does the '_mod' (in <cmb_mod type="stringdictionary"/> ) means you're modifying the string script, as I see you using 'mod' elsewhere too (like on-in, '<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>' ) ??


Be careful! The name of attributes does not include any logic! cmb_mod is defined in type cmb_equipment and all equipment objects should inherit this type. Then all this items uses this stringdictionary and you can define attribute modificator for every item.

But this dictionary has nothing to do with cmb_lvlmod which is located within an object named cmb_intern and which saves permanent modifications of the player's attributes when achieving a new level.

HegemonKhan wrote:
as I got the same question with this too:

<object name="cmb_intern">
<cmb_attribs type="list">CMB_PA;CMB_AT;CMB_STR;CMB_HP;CMB_EXP</cmb_attribs>
<cmb_lvlexp type="stringdictionary">1=50;2=100;3=200;4=400;5=800;6=1500;7=3000</cmb_lvlexp>
<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>
</object>


is the '<cmb_lvlmod...' a modification of the '<cmb_lvlexp type...' ???


It's not a modification, it's just a structure to save values. cmb_lvlexp saves the values when the player level rises. If he got 50 experiencepoints he is level 1, with 100 exp he is level 2 and so on.
cmb_lvlmod says, that the player attribute at (attack) and pa (parade) increases by 1 if he is level 1. With level 2 his at is increased by 2 and he gets 100 additional hitpoints.

HegemonKhan
thanks Jaynabonne and Pertex!

Question 7:

Does it matter whether you do a script inside of the object type or outside as the game's function? Or, does it depend on how you set the rest of it* up?

*like for doing equipment or spells or combat or whatever?

for the specific examples I'm refering to:

Pixie did the scripting for the verb 'learn' and 'cast' for the object type 'spell' within the object type 'spell'

Chase does the scripting for the equipment-wearables (equipping-wear and unequipping-remove) as a game function, instead of within the object type 'equipment-wearables'

Pixie did the scripting for equipment-clothing_type (equipping-wear and unequipping-remove) within the object type 'eqiupment-clothing_type'

Pertex did all the scripting as game functions, outside of the object types 'cmb_fighter' and 'cmb_equipment'

Question 8:

I'm presuming that for Pertex' Combat Library's:

<object name="cmb_intern">
<cmb_attribs type="list">CMB_PA;CMB_AT;CMB_STR;CMB_HP;CMB_EXP</cmb_attribs>
<cmb_lvlexp type="stringdictionary">1=50;2=100;3=200;4=400;5=800;6=1500;7=3000</cmb_lvlexp>
<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>
</object>


is required, as it's used as an alternative to a level up system function (as I had made in my prior lessons here)

but is Pixie's Spell Library's:

  <object name="element_struct">
<elements type="list">fire; frost; storm; earthmight; shadow; rainbow; divine; necrotic</elements>
<opposedelements type="stringdictionary">fire = frost;frost = fire;storm = earthmight;earthmight = storm;shadow = rainbow;rainbow = shadow;necrotic = divine;divine=necrotic</opposedelements>
</object>


required? [Edit: nvm, I just remembered, that it is required, due to the 'elements' and 'opposedelements' being used within the functions, which I am going to assume I have gotten understood correctly?]

err...

since both seem to be required, maybe I should ask, why and-or how did both of you use an object has the parent of these attributes, instead of putting them elsewhere, like in the player or object type ??

Question 9:

about Pertex response to my question 5, obviously (lol) it would help for me (lol) to understand what are:

(1) strings (I'm guessing they're a 'sentence' of letters and-or numbers, or expression: a 'sentence' of letters, numbers, and-or stripting codes)
(2) lists (I'm guessing these are local "attributes/scripts", instead of being universal "attributes/scripts")
(3) dictionaries (I'm guessing this is universal "attributes/scripts", instead of being local "attributes/scripts")
(4) stringlists (I'm guessing this is a collection of strings, but locally. Their individual strings can be separated "split" or joined together "join")
(5) stringdictionaries (I'm guessing, see stringlist, but they're universal instead)
(6) objectlists (I'm guessing, see stringlist, but with objects instead)
(7) object dictionaries (I'm guessing, see objectlists, but they're universal instead)

and I've seen:

(8) Item Keys (Are these related to the stringdictionaries: "key" and "string" ?? )

where are these from (what scripting type?) and what are they?

question 10:

@Pertex, about your:

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>


and:

Pertex wrote:Right. You can put in any value you want e.g "finger", "nose" or even "aaa". When equipping an item, the library checks all object of the type "cmb_equipment" if there is another item worn at this location and if so, it throws a message "You can't waer another item at this location.


just to see if I understand (I haven't scanned-memorized, let alone understand, all your functions-script blocks, lol):

<cmb_where type="string"></cmb_where> is your string of whatever the body-equipment slots you want (why did you use a string, and not a list-stringlist or a stringdictionary?)

<cmb_activelvl type="int">1</cmb_activelvl> I'm going to guess this is the "equipment layer level" ?? (and you only assigned a single layer for this library-demo of yours, as the "1" can be easily changed to 2 or 3, for having multiple layers of equipment)

*******************
<cmb_mod type="stringdictionary"/> I still don't understand what this is for, or what it does... unless, does this become the parent (and universal, so it-"cmb_where" can be used in other functions) of the <cmb_where type="string"></cmb_where> ??

edit:

HK wrote:and the <cmb_mod type="stringdictionary"/> contains the string ???


Pertex wrote:No, it contains a stringdictionary. It contains the attribute modificators, if this item is equipped. Something like


<cmb_mod type="stringdictionary">at = +3;str = +1;hp = 21</cmb_mod>


Pertex wrote:The script reads all this values and increases ( or decreases) the actual attributes of the player


I'm still confused with this ( <cmb_mod type="stringdictionary"/> ):

does a game function input (the example you used of) your ( at = +3;str = +1;hp = 21 ) into the <cmb_mod type="stringdictionary"/> in the object type ( type name="cmb_equipment"> )

or is the ( <cmb_mod type="stringdictionary"/> ) merely the parent or source-container of the:

   <cmb_where type="string"></cmb_where> 
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>[/code

or, something else (which I obviously don't see) ????

******************

and your game functions do the "When equipping an item, the library checks all object of the type "cmb_equipment" if there is another item worn at this location and if so, it throws a message "You can't waer another item at this location (Pertex)."

The Pixie

Question 9:

about Pertex response to my question 5, obviously (lol) it would help for me (lol) to understand what are:

(1) strings (I'm guessing they're a 'sentence' of letters and-or numbers, or expression: a 'sentence' of letters, numbers, and-or stripting codes)
(2) lists (I'm guessing these are local "attributes/scripts", instead of being universal "attributes/scripts")
(3) dictionaries (I'm guessing this is universal "attributes/scripts", instead of being local "attributes/scripts")
(4) stringlists (I'm guessing this is a collection of strings, but locally. Their individual strings can be separated "split" or joined together "join")
(5) stringdictionaries (I'm guessing, see stringlist, but they're universal instead)
(6) objectlists (I'm guessing, see stringlist, but with objects instead)
(7) object dictionaries (I'm guessing, see objectlists, but they're universal instead)

and I've seen:

(8) Item Keys (Are these related to the stringdictionaries: "key" and "string" ?? )

where are these from (what scripting type?) and what are they?


I will just tackle this one for now.

You are right about strings, a string is just a sequence of characters, like a sentence.
Lists and dictionaries are collections, a way of storing a set of things together. A string list (which Quest often refers to as a stringlist) is a set of strings, but you can also have a set of scripts or objects.
A list is specifically a sequence, with a first item, a second item, etc. Just to confuse you, the first item is indexed as 0, the second as 1, etc. But the important point is that you select the thing you want using a number, which is the things position in the sequence.
With a dictionary, on the other hand, you select the thing you want using a string, and this string is its key. For an analogy think of a real dictionary. It contains a whole bunch of definitions. To find the definition of the word "house", you look up the word "house", which is the key for that definition.
A string dictionary uses a string for the key, and stores only strings, while an object dictionary uses a string for the key, and stores only objects.

Strings, lists and dictionaries can be set up as attributes on objects, or can be used as variables in functions (in which case they disappear when the function ends).

jaynabonne
For question 7, to me, the main functional difference between object-based scripts and functions is that with an object-based script member, the script (read: "behavior") can be different for each object or each object type (depending on where you vary the script), whereas a global function will have the same script/behavior invoked for each object. This means that for an object scrpit, you can let the object define how to handle a certain instance. The caller doesn't even know what script is being invoked - it just calls the script member for the object. This is how different objects in Quest are set up to respond to verbs in different ways. It would be impossible (or at least extremely messy) to handle all the varying cases with a direct function call.

So, if you have code that will always be the same for all objects, a (direct) function might make sense. If you want to have behavior that varies per object or per class of object, then a per-object (indirect) script is the way to go.

(Note - and this is more advanced - that there are other aspects of object scripts as well, such as encapsulation. That is, you can't invoke or even see an object script attribute without actually having an object to begin with, so it "hides" the implementation inside the object and constrains its use. If that doesn't make sense, don't worry about it. :) )

HegemonKhan
thanks Pixie and Jaynnabonne!

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

Question 11:

what then is the difference between lists and dictionaries?, as they seem to be pretty much the same thing, to me anyways.

-----------

Also, I've seen "slots" used, how do they work, and what scripting are they connected to?

From a part of Chase's Wearables Library:

	<function name="DoWear" parameters="object"><![CDATA[
if(not HasAttribute(object,"worn")) {
msg (DynamicTemplate("WearUnsuccessful", object))
} else if (object.parent = player and object.worn = true) {
msg (DynamicTemplate("AlreadyWearing", object))
} else if (not ListContains(ScopeInventory(), object)) {
msg (DynamicTemplate("WearUnsuccessful", object))
} else {
isLayerProblem = false
conflictedItem = null

if(HasAttribute(object,"wear_slots")) {
foreach(item, ScopeReachableInventory()) {
if(HasAttribute(item,"wear_slots")) {
if(item.worn = true) {
foreach(itemSlot,item.wear_slots) {
if(ListContains(object.wear_slots,itemSlot)) {
if(object.wear_layer < item.wear_layer) {
conflictedItem = item
isLayerProblem = true
} else if(object.wear_layer = item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}

if(conflictedItem = null) {
object.worn = True
object.original_drop = object.drop
object.original_alias = object.alias
object.drop = false

object.display = GetDisplayName(object)
object.alias = GetDisplayAlias(object) + " (worn)"

if(object.wearmsg = null) {
msg (DynamicTemplate("WearSuccessful",object))
} else {
msg(object.wearmsg)
}

//do after
if (HasScript(object, "onafterwear")) {
do(object, "onafterwear")
} else if(HasString(object, "onafterwear")) {
msg(object.onafterwear)
}
} else if(isLayerProblem = true) {
msg(DynamicTemplate("CannotWearOver",conflictedItem))
} else {
msg(DynamicTemplate("CannotWearWith",conflictedItem))
}

}
]]></function>


if(HasAttribute(object,"wear_slots")) {
foreach(item, ScopeReachableInventory()) {
if(HasAttribute(item,"wear_slots")) {
if(item.worn = true) {
foreach(itemSlot,item.wear_slots) {
if(ListContains(object.wear_slots,itemSlot)) {

I know now that this is a stringlist, and I guess that the slots are part of the coding of it, as the "slots" (or "_slots") doesn't seem to be defined or set anywhere else.

[nvm: the wear_slot is defined or set in the tab section, I guess. I thought it was or needed to be defined or set as the game stuff and not just through via the GUI's tabs creation)]

part of Chases Wearables Library:
		<control>
<mustinherit>wearable</mustinherit>
<caption>Wear Slot</caption>
<controltype>list</controltype>
<attribute>wear_slots</attribute>
<editprompt>Please enter the name for the wear location</editprompt>
</control>


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

@Jaynabonne,

would Pertex' Combat Library part of:

<object name="cmb_intern">
<cmb_attribs type="list">CMB_PA;CMB_AT;CMB_STR;CMB_HP;CMB_EXP</cmb_attribs>
<cmb_lvlexp type="stringdictionary">1=50;2=100;3=200;4=400;5=800;6=1500;7=3000</cmb_lvlexp>
<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>
</object>


be a type of "encapsulation" ?, an alternative and internal (hence his-her use of "_intern" I presume), as this is never seen, but acts as a lvl up system. A "hidden function" ?

and-or also, Pixie's part of his-her Spells Library:

  <object name="element_struct">
<elements type="list">fire; frost; storm; earthmight; shadow; rainbow; divine; necrotic</elements>
<opposedelements type="stringdictionary">fire = frost;frost = fire;storm = earthmight;earthmight = storm;shadow = rainbow;rainbow = shadow;necrotic = divine;divine=necrotic</opposedelements>
</object>


--------

@jaynabonne,

my point of asking about Question 7, is that, in my thinking (tell me if this type of thinking of mine is wrong!):

I'd rather put as much script into the object types as I can, as there's enough script already that is needed as game functions, just to help cut down on the clutter, why not put script that you only want to apply to the object types as part of the object types' script (and you'd know this script is for the object types, whereas it might be a little difficult to tell when the script is as game functions as to what it applies to or is for) ? Or, is there maybe some coding-"recalling-using-applying" issues, which I'm not aware of that would come up in having the script as child to an object type vs as a game function?

-----------

P.S.

@Pertex,

I think I understand now about Pertex Combat Library part, that I was confused by earlier:

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>


the ( <cmb_mod type="stringdictionary"/> ) is merely allowing for you to script a stringdictionary (of then whatever you want), for the objects that inherit the object type, correct? (is the <cmb_mod type="stringdictionary"/> separate from the cmb_wear and "head", "etc" ?)

Or, is this correct?:

StringDictionary -> cmb_where (key) and "head", "neck", "etc" (the string)

~(I had thought it was suppose to be an already created string dictionary with values, so that is why I was confused by it)

Pertex
HegemonKhan wrote:
question 10:

@Pertex, about your:

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>



just to see if I understand (I haven't scanned-memorized, let alone understand, all your functions-script blocks, lol):

<cmb_where type="string"></cmb_where> is your string of whatever the body-equipment slots you want (why did you use a string, and not a list-stringlist or a stringdictionary?)

You can only wear a item/weapon at one position of your body so you must only one string value per item.

HegemonKhan wrote:
<cmb_activelvl type="int">1</cmb_activelvl> I'm going to guess this is the "equipment layer level" ?? (and you only assigned a single layer for this library-demo of yours, as the "1" can be easily changed to 2 or 3, for having multiple layers of equipment)

No, cmb_activelvl defines the level the player must have to equip this weapon.

HegemonKhan wrote:
<cmb_mod type="stringdictionary"/> I still don't understand what this is for, or what it does... unless, does this become the parent (and universal, so it-"cmb_where" can be used in other functions) of the <cmb_where type="string"></cmb_where> ??


I am not sure if I understand your problem. <cmb_mod type="stringdictionary"/> defines a empty stringdictionary (same as cmb_where). I can't set values in the type cmb_equipment in the library, because I don't know, which modificator will be used be the specific item. If you look in the testcombat.aslx you will see, that this dictionary is set for every object inheriting cmb_equipment.
cmb_activelvl is set to 1 in the type but this is only a default value, which is set in the object again. So you could leave it empty in the type if you want or you could set a default for cmb_mod or cmb_where, too. As you wish.

HegemonKhan
sorry about still editting my previous post, as I think I now understand you, thank you very much!

from being edited into my previous post:

HK wrote:@Pertex,

I think I understand now about Pertex Combat Library part, that I was confused by earlier:

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>


the ( <cmb_mod type="stringdictionary"/> ) is merely allowing for you to script a stringdictionary (of then whatever you want), for the objects that inherit the object type, correct? (is the <cmb_mod type="stringdictionary"/> separate from the cmb_wear and "head", "etc" ? Edit: this is correct, as the cmb_wear would be indented if it was part of the stringdictionary, duh, sorry HK is not thinking clearly right now, lol. sorry for my prior confusion about this!)

Or, is this correct?:

StringDictionary -> cmb_where (key) and "head", "neck", "etc" (the string)

~(I had thought it was suppose to be an already created string dictionary with values, so that is why I was confused by it)


just a final check, this would be the correct understanding:

the ( <cmb_mod type="stringdictionary"/> ) is merely allowing for you to script a stringdictionary (of then whatever you want), for the objects that inherit the object type, correct?

Library File = enables you to create-set stringdictionaries for the objects with the inherited object type

Game File = you then go in and set the stringdictionaries for the various objects in your game:

Mace: at=8, pa=-3
Sword: ...
Shield: ---
etc

correct?

Pertex
HegemonKhan wrote:
just a final check, this would be the correct understanding:

the ( <cmb_mod type="stringdictionary"/> ) is merely allowing for you to script a stringdictionary (of then whatever you want), for the objects that inherit the object type, correct? (is the <cmb_mod type="stringdictionary"/> separate from the cmb_wear and "head", "etc" ?)

Right

HegemonKhan wrote:
Library File = enables you to create-set stringdictionaries for the objects with the inherited object type

Game File = you then go in and set the stringdictionaries for the various objects in your game:

Mace: at=8, pa=-3
Sword: ...
Shield: ---
etc

correct?

Ă„hhmm, right. But it's not a matter of library file and game file. You could copy the complete code from the library file to your game file and it would work, too. It's just easier to distribute code

jaynabonne
For your example, that would indeed be encapsulation - it's actually "data encapsulation", which is keeping all your data in one place, as opposed to "code encapsulation", which is putting code with it as well. :)

What you asked about putting the scripts with the objects always - normally, in theory, that's the way you'd want to go, as it keeps things together (the object data plus the code to operate on it). The only drawback that I have found to using object script attributes - and this is more of a Quest implementation detail than a design one, and to me it can be a huge drawback - is that the method for calling scripts attributes is much less conveninent than calling functions, in terms of passing parameters in and getting result values back.

To invoke a function, you can just call the function, pass in the arguments and get the result back:

result = MyFunction(arg1, arg2)

To use an object script with parameters, you have to create a dictionary and add the arguments in:

params = NewDictionary()
dictionary add(params, "arg1", arg1)
dictionary add(params, "arg2", arg2)
do (object, "MyScript", params)

And as far as returning a result... well, I have to admit that I am not sure. If there is a way to return a value from a script, it's definitely not easy (perhaps it sets some sort of "result" variable?). It's also possible that it's not possible. I haven't delved into that.

So, while scripts conceptually would be the way to go in terms of good code design, the implementation makes them a real pain to use as a generic replacement for functions.

Now... straying into "much more advanced territory"..

There is *another* construct in Quest, which is a "delegate". Delegates are better, in that you can invoke them with arguments in a standard way and get a result back (using the expression-friendly "RunDelegateFunction" as opposed to "rundelegate"), but you have to define a delegate signature for each one so that Quest knows how to invoke it. You also have to label the delegate member with the delegate type name. So to create a delegate, you have to:

1) Define the delegate signature (arguments and return type)
2) Label the script attribute with the delegate's type name.
3) Invoke the delegate with rundelegate (or RunDelegateFunction if you want a return value).

Not as simple as simply defining a function and calling it. (I would love to see this addressed somehow, but I don't have a good design alternative to offer yet. :) )

But if you do all that, then you can use something like this to invoke the delegate:

result = RunDelegateFunction(object, "MyDelegate", arg1, arg2)

which is definitely nicer than the script way. I hope I haven't given delegates a bum rap - I use them myself quite a bit, for the reasons shown above.

So, yes, in an ideal world, you'd be able to hook code off your objects and call it, to encapsulate it all. Unfortunately, it's not as easy in Quest as it could be, and sometimes a standard function is just less painful to chuck in rather than go through all the hoops for an object script or delegate attribute.

(By the way, if you'd like to have a discussion about delegates, start up a new thread for it, and we can continue there. It might make it more accessible for those looking for that topic in the future, rather than being interwoven in this thread.)

HegemonKhan
@Jaynabonne,

If I understand you, in my layman's terms:

if you're going to apply-use-implement the script into or for other things, then its better-easier for it to be a game function.

if the script is to be totally "stand alone" (not used-applied-implemented; nothing dependant upon it) then putting it into the object type works fine.

----------

I'm going to ignore delegates at the moment (and probably for a good while) as this is way beyond what I am trying to just learn about in coding at the moment. I still can't grasp-understand the scripting logic arguments (I'm not sure how to properly describe what I'm trying to say here lol) such as for the creation of equipment and-or spells, I mean, my brain isn't able to do-create the numerous logic arguments of the script blocks, functions, etc, then connecting and invoking them all together on my own. Too confusing for me at the moment.

I can copy and now for the most part understand the libraries people have made, but being able to create my own library on how to do any of this stuff on my own, is way beyond me at the moment. I'll probably need to make some visual aids to help me organize all of what's being done in each of these libraries. too many coding steps and interconnection of those steps, lol.

HegemonKhan
quick questions:

I've been using mostly Chase's library for setting up equipment:

<library>
<!--
Chase's Wearables Library v2.3
Based on: Pixie's Clothing Library (originally)

You may edit this library however you please.

I decided to include a UI, since not having a UI kinda bugged me.

v1.01
-Fixed a typo

v1.02
+Added Event Handlers
+Fixed drop bug

v1.03
+Added configurable wear/remove messages
-Removed redundant events

v1.04
=Fixed an issue with wearing multiple blank items
=Fixed the issue with wearing items without aliases

v2.0
=Rewritten to better support base systems, may have broken older usages
+Added wear layer support

v2.1
=Fixed an issue of an error being thrown when trying to wear something that is not wearable.

v2.2
=Fixed an issue where the custom remove message doesn't play if the item cannot be removed.

v2.3
=Fixed a significant bug where you could not wear something if a non-wearable item was in your inventory.

Chase
chasesan@gmail.com
-->

<dynamictemplate name="WearSuccessful">"You put " + object.article + " on."</dynamictemplate>
<dynamictemplate name="WearUnsuccessful">"You can't wear " + object.article + "."</dynamictemplate>
<dynamictemplate name="AlreadyWearing">"You are already wearing " + object.article + "."</dynamictemplate>
<dynamictemplate name="CannotWearOver">"You cannot wear that over " + object.display + "."</dynamictemplate>
<dynamictemplate name="CannotWearWith">"You cannot wear that while wearing " + object.display + "."</dynamictemplate>

<dynamictemplate name="RemoveSuccessful">"You take " + object.article + " off."</dynamictemplate>
<dynamictemplate name="RemoveUnsuccessful">"You can't remove " + object.article + "."</dynamictemplate>
<dynamictemplate name="RemoveFirst">"You can't remove that while wearing "+object.display+"."</dynamictemplate>

<template name="Wear">Wear</template>
<verbtemplate name="wear">wear</verbtemplate>
<verbtemplate name="wear">put on</verbtemplate>

<template name="Remove">Remove</template>
<verbtemplate name="remove">remove</verbtemplate>
<verbtemplate name="remove">take off</verbtemplate>

<command name="wear" template="wear">
<multiple>
return (ScopeInventory())
</multiple>
<script>
foreach (obj, object) {
DoWear(obj)
}
</script>
</command>

<command name="remove" template="remove">
<multiple>
return (ScopeInventory())
</multiple>
<script>
foreach (obj, object) {
DoRemove(obj)
}
</script>
</command>

<function name="DoWear" parameters="object"><![CDATA[
if(not HasAttribute(object,"worn")) {
msg (DynamicTemplate("WearUnsuccessful", object))
} else if (object.parent = player and object.worn = true) {
msg (DynamicTemplate("AlreadyWearing", object))
} else if (not ListContains(ScopeInventory(), object)) {
msg (DynamicTemplate("WearUnsuccessful", object))
} else {
isLayerProblem = false
conflictedItem = null

if(HasAttribute(object,"wear_slots")) {
foreach(item, ScopeReachableInventory()) {
if(HasAttribute(item,"wear_slots")) {
if(item.worn = true) {
foreach(itemSlot,item.wear_slots) {
if(ListContains(object.wear_slots,itemSlot)) {
if(object.wear_layer < item.wear_layer) {
conflictedItem = item
isLayerProblem = true
} else if(object.wear_layer = item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}

if(conflictedItem = null) {
object.worn = True
object.original_drop = object.drop
object.original_alias = object.alias
object.drop = false

object.display = GetDisplayName(object)
object.alias = GetDisplayAlias(object) + " (worn)"

if(object.wearmsg = null) {
msg (DynamicTemplate("WearSuccessful",object))
} else {
msg(object.wearmsg)
}

//do after
if (HasScript(object, "onafterwear")) {
do(object, "onafterwear")
} else if(HasString(object, "onafterwear")) {
msg(object.onafterwear)
}
} else if(isLayerProblem = true) {
msg(DynamicTemplate("CannotWearOver",conflictedItem))
} else {
msg(DynamicTemplate("CannotWearWith",conflictedItem))
}

}
]]></function>

<function name="DoRemove" parameters="object"><![CDATA[
if (not object.parent = player or not object.worn or not object.removeable) {
if(object.removemsg = null) {
msg (DynamicTemplate("RemoveUnsuccessful",object))
} else {
msg (object.removemsg)
}
} else {
conflictedItem = null
//check if we are wearing anything over it
if(HasAttribute(object,"wear_slots")) {
foreach(item, ScopeReachableInventory()) {
if(HasAttribute(item,"wear_slots")) {
if(item.worn = true) {
foreach(itemSlot,item.wear_slots) {
if(ListContains(object.wear_slots,itemSlot)) {
if(object.wear_layer < item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}

if(conflictedItem = null) {
if(object.removemsg = null) {
msg (DynamicTemplate("RemoveSuccessful",object))
} else {
msg(object.removemsg)
}

object.worn = false
object.drop = object.original_drop
object.alias = object.original_alias
object.original_drop = null
object.original_alias = null
object.display = null

//do after
if (HasScript(object, "onafterremove")) {
do(object, "onafterremove")
} else if(HasString(object, "onafterremove")) {
msg(object.onafterremove)
}
} else {
msg (DynamicTemplate("RemoveFirst", conflictedItem))
}
}
]]></function>

<type name="wearable">
<worn type="boolean">false</worn>
<removeable type="boolean">true</removeable>
<wear_layer type="int">2</wear_layer>
<inventoryverbs type="listextend">[Wear];[Remove]</inventoryverbs>
</type>
<!-- Interface -->
<tab>
<parent>_ObjectEditor</parent>
<caption>Wearable</caption>
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>

<control>
<controltype>title</controltype>
<caption>Wearable</caption>
</control>

<control>
<controltype>dropdowntypes</controltype>
<caption>Can be worn?</caption>
<types>*=Cannot be worn; wearable=Can be worn</types>
<width>150</width>
</control>

<control>
<mustinherit>wearable</mustinherit>
<controltype>checkbox</controltype>
<attribute>removeable</attribute>
<caption>Removeable?</caption>
</control>

<control>
<mustinherit>wearable</mustinherit>
<controltype>number</controltype>
<caption>Wear Layer</caption>
<attribute>wear_layer</attribute>
</control>

<control>
<mustinherit>wearable</mustinherit>
<caption>Wear Slot</caption>
<controltype>list</controltype>
<attribute>wear_slots</attribute>
<editprompt>Please enter the name for the wear location</editprompt>
</control>

<control>
<mustinherit>wearable</mustinherit>
<controltype>label</controltype>
<caption>If two objects have the same wear location, they will not be able to be worn at a same time. Any number items without wear locations can be worn.</caption>
<advanced/>
</control>

<!-- snip -->

<control>
<mustinherit>wearable</mustinherit>
<controltype>textbox</controltype>
<attribute>wearmsg</attribute>
<caption>Message to print when wearing (leave blank for default)</caption>
<nullable/>
</control>

<control>
<mustinherit>wearable</mustinherit>
<controltype>textbox</controltype>
<attribute>removemsg</attribute>
<caption>Message to print when removing or trying to remove (leave blank for default)</caption>
<nullable/>
</control>

<!-- Event Handlers from here down none/text/scripts -->

<control>
<mustinherit>wearable</mustinherit>
<controltype>title</controltype>
<caption>After Wearing</caption>
</control>

<control>
<mustinherit>wearable</mustinherit>
<selfcaption>After wearing the object</selfcaption>
<controltype>multi</controltype>
<attribute>onafterwear</attribute>
<types>null=None; string=Text; script=Run script</types>
<editors>string=textbox</editors>
<expand/>
</control>

<control>
<mustinherit>wearable</mustinherit>
<controltype>title</controltype>
<caption>After Removing</caption>
</control>

<control>
<mustinherit>wearable</mustinherit>
<selfcaption>After removing the object</selfcaption>
<controltype>multi</controltype>
<attribute>onafterremove</attribute>
<types>null=None; string=Text; script=Run script</types>
<editors>string=textbox</editors>
<expand/>
</control>

</tab>
</library>


but I'm also looking at Pertex' combat library too:

<library>
<!-- done by Pertex (pertex@gmx.de)-->
<object name="cmb_intern">
<cmb_attribs type="list">CMB_PA;CMB_AT;CMB_STR;CMB_HP;CMB_EXP</cmb_attribs>
<cmb_lvlexp type="stringdictionary">1=50;2=100;3=200;4=400;5=800;6=1500;7=3000</cmb_lvlexp>
<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>
</object>

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>

<type name="cmb_fighter">
<cmb_at type="int">1</cmb_at>
<cmb_pa type="int">1</cmb_pa>
<cmb_str type="int">1</cmb_str>
<cmb_hp type="int">100</cmb_hp>
<cmb_at_max type="int">1</cmb_at_max>
<cmb_pa_max type="int">1</cmb_pa_max>
<cmb_str_max type="int">1</cmb_str_max>
<cmb_hp_max type="int">100</cmb_hp_max>
<cmb_exp type="int">0</cmb_exp>
<cmb_level type="int">0</cmb_level>
<dead type="boolean">false</dead>
<equiped type="string"></equiped>
<cmb_script type="scriptdictionary">
<item key="killed">
msg("killed")
</item>
</cmb_script>
</type>

<command name="attack">
<pattern>attack #text#</pattern>
<script>
cmb_attack (player, text)
</script>
</command>

<command name="loot">
<pattern>loot #text#</pattern>
<script>
cmb_loot ( trim(text) )
</script>
</command>

<command name="equip">
<pattern>equip #text#</pattern>
<script>
cmb_equip ( trim(text) )
</script>
</command>

<command name="unequip">
<pattern>unequip #text#</pattern>
<script>
cmb_unequip ( trim(text) )
</script>
</command>

<command name="unequipall">
<pattern>unequip all</pattern>
<script>
foreach (x,ScopeInventory () ) {
if (InstrRev ( getString(x, "alias") , "(" )>2) {
cmb_unequip ( getString (x, "name"))
}
}
</script>
</command>

<command name="equiped">
<pattern>equiped</pattern>
<script>
found=false
foreach (x,ScopeInventory () ) {
if (InstrRev ( getString(x, "alias") , "(" )>2) {
text=""
foreach(y,x.cmb_mod ) {
text=concat (text,concat (y,StringDictionaryItem (x.cmb_mod,y),"="),",")
}
msg (x.name+ " - Level " + x.cmb_activelvl + ", modification: "+ text )
found=true
}
}
if (not found) {
msg("You don't have any equiped item.")
}
</script>
</command>

<command name="equipment">
<pattern>equipment</pattern>
<script>
found=false
foreach (x,ScopeInventory () ) {
if (DoesInherit (x, "cmb_equipment")) {
text=""
foreach(y,x.cmb_mod ) {
text=concat (text,concat (y,StringDictionaryItem (x.cmb_mod,y),"="),",")
}
msg (x.name+ " - Level " + x.cmb_activelvl + ", modification: "+ text )
found=true
}
}
if (not found) {
msg("None of your items in your inventory can be equiped.")
}
</script>
</command>

<function name="cmb_addStatus" parameters="attrib">
attrib = cmb_chkAttrib (attrib)
if (GetAttribute ( player , "statusattributes" )=null ) {
player.statusattributes = NewStringDictionary()
}
switch (attrib) {
case ("cmb_hp") {
dictionary add (player.statusattributes, "cmb_hp", "Health: !/"+ player.cmb_hp_max )
}
case ("cmb_at") {
dictionary add (player.statusattributes, "cmb_at", "AT: !" )
}
case ("cmb_pa") {
dictionary add (player.statusattributes, "cmb_pa", "PA: !" )
}
case ("cmb_str") {
dictionary add (player.statusattributes, "cmb_str", "Strength: !" )
}
case ("cmb_level") {
dictionary add (player.statusattributes, "cmb_level", "Level: !" )
}
case ("cmb_exp") {
dictionary add (player.statusattributes, "cmb_exp", "EP: !" )
}
}
</function>

<function name="cmb_refreshStatus" >
saveStatus = NewStringList()
foreach( x , player.statusattributes){
list add(saveStatus, x)
}

player.statusattributes = NewStringDictionary()

foreach( x , saveStatus){
cmb_addStatus (x)
}

</function>


<function name="cmb_setAttrib" parameters="object,attrib,value">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
set(object,attrib,value)
}
}
</function>


<function name="cmb_getAttrib" parameters="object,attrib" type="int">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
return (GetInt(object,attrib))
} else {
return(0)
}
}
</function>

<function name="cmb_incAttrib" parameters="object,attrib,value" type="boolean">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
cmb_setAttrib(object,attrib, cmb_getAttrib(object,attrib) + value)
return (true)
} else {
return (false)
}
} else {
return (false)
}
</function>

<function name="cmb_decAttrib" parameters="object,attrib,value" type="boolean">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
cmb_setAttrib(object,attrib,cmb_getAttrib(object,attrib) - value)
return (true)
} else {
return (false)
}
} else {
return (false)
}
</function>

<function name="cmb_equip" parameters="itemname" type="boolean">
found=false
item= getObject(itemname)
if (item=null) {
msg("What does " + itemname + " mean?")
} else if ( not DoesInherit (item, "cmb_equipment")) {
msg("You can't equip this item.")
} else {
if (cmb_chkObject(item)){
foreach (cmb_object, ScopeInventory()) {
if (item=cmb_object){
found=true
}
}
if ( not found) {
msg ("You don't have this in your inventory.")
}
}
}
if (found) {
if ( player.cmb_level >=item.cmb_activelvl ) {
dict_equiped = NewStringDictionary ()
string2dict ( player.equiped,dict_equiped)
if (item.cmb_where="dhand" and (DictionaryContains (dict_equiped,"lhand") or (DictionaryContains (dict_equiped,"rhand")))){
msg("1")
msg("You already are carrying something in your hands!")
} else if ((item.cmb_where="dhand" or item.cmb_where="rhand") and DictionaryContains (dict_equiped,"dhand")){
msg("2")
msg("You already are carrying something in your hands!")
} else if ( DictionaryContains (dict_equiped,item.cmb_where)) {
msg("You already have something equiped there!")
} else {
dictionary add( dict_equiped,item.cmb_where, itemname)
item.alias=GetDisplayAlias (item)+ " ("+item.cmb_where+")"
eval_mod(player,item.cmb_mod, true )
}
player.equiped=dict2string (dict_equiped)
cmb_refreshStatus
msg("Done")
} else {
msg("You are not experienced enough to equip this item.")
}
}

return (true)
</function>


<function name="cmb_unequip" parameters="itemname" type="boolean">
found=false
item= getObject(itemname)
if (item=null) {
msg("What does " + itemname + " mean?")
} else if ( not DoesInherit (item, "cmb_equipment")) {
msg("You can't unequip this item.")
} else {
if (cmb_chkObject(item)){
foreach (cmb_object, ScopeInventory()) {
if (item=cmb_object){
found=true
}
}
if ( not found) {
msg ("You don't have this in your inventory.")
}

}
}
if (found) {
dict_equiped = NewStringDictionary ()
string2dict ( player.equiped,dict_equiped)
pos=DictionaryContainsValue(dict_equiped, itemname)
if ( lengthof(pos) > 0) {
dictionary remove(dict_equiped, pos)
if (InstrRev ( getString(item,"alias") , "(" )>2) {
item.alias=Left ( item.alias , InstrRev ( getString (item, "alias") , "(" )-2 )
}
eval_mod(player,item.cmb_mod, false )
}

player.equiped=dict2string (dict_equiped)
cmb_refreshStatus
msg("Done")
}
return (true)
</function>

<function name="cmb_unequipIntern" parameters="itemname" type="boolean">
item= getObject(itemname)
if (item=null) {

} else {
dict_equiped = NewStringDictionary ()
string2dict ( player.equiped,dict_equiped)
pos=DictionaryContainsValue(dict_equiped, itemname)
if ( lengthof(pos) > 0) {
dictionary remove(dict_equiped, pos)
if (InstrRev ( getString(item,"alias") , "(" )>2) {
item.alias=Left ( item.alias , InstrRev ( getString(item,"alias") , "(" )-2 )
}
eval_mod(player,item.cmb_mod, false )
}

player.equiped=dict2string (dict_equiped)
cmb_refreshStatus
}
</function>


<function name="eval_mod" parameters="object,mod_dict,inc">
foreach ( x, mod_dict ) {
if (x="at" or x="pa" or x="hp" or x="str"){
y=stringdictionaryitem(mod_dict,x)
if (IsInt(y)) {
if (inc) {
cmb_incAttrib(object,x,toint(y))
} else {
cmb_decAttrib(object,x,toint(y))
}
}
}
}
</function>

<function name="cmb_loot" parameters="targetname">
target= getObject(targetname)
if (target=null){
msg("You can't see that here.")
} else{
found=false
if(cmb_chkObject(target) and cmb_isReachable(target)){
if (target.dead) {
foreach (cmb_object, AllObjects()) {
if (cmb_object.parent=target) {
MoveObject (cmb_object, target.parent)
found=true
}
}
destroy(target.name)
if (found) {
msg("You found something.")
} else {
msg("You could not found something interessting.")
}
} else {
msg("You cant loot now.")
}
} else {
msg("You cant loot " + target.alias)
}
}

</function>

<function name="cmb_fight" parameters="object, target" type="boolean">
vattack=0
vparade=0
if (cmb_chkFighter(object) and cmb_chkFighter(target)){
for (x ,1, cmb_getAttrib(object,"cmb_at")) {
vattack = vattack + cmb_dicesix()
}
for (x ,1 ,cmb_getAttrib(target,"cmb_pa")) {
vparade = vparade + cmb_dicesix()
}
msg("at: " + ToString(vattack) + ", pa: "+ToString(vparade))
if (vattack > vparade) {
damage=cmb_dice(object.cmb_str) + cmb_dice(vattack-vparade)
cmb_decAttrib (target, "cmb_hp", damage)
msg(object.name + " hits " + target.name + " for " + damage + " points.")
} else {
msg (object.name + " misses.")
}
return (true)
} else {
return (false)
}
</function>

<function name="cmb_attack" parameters="object, targetname" type="boolean">
returnvalue=false
target= getObject(targetname)

if(target=null){
msg("There is no " + targetname + " here.")
returnvalue=false
} else if (not cmb_isReachable(target)){
msg("There is no " + target.name + " here.")
returnvalue=false
} else if (GetBoolean ( target , "dead" ) ){
msg("Your target ist not alive any more.")
returnvalue=false
} else if(cmb_chkObject(object) and cmb_chkObject(target)){
if (cmb_fight(object, target)) {
if (cmb_getAttrib(target,"cmb_hp")>0) {
msg( target.name + " hits back.")
cmb_fight(target,object)
if (cmb_getAttrib(object,"cmb_hp")>0) {
msg("")
} else {
if (object=player){
msg( "A last strike hits you. You are dying.")
msg( "GAME OVER")
finish
} else {
msg( object.name + " dies.")
SetObjectFlagOn (target, "dead")
target.alias = GetDisplayAlias (target) +" (dead)"
cmb_addexp(target)
if (DictionaryContains(target.cmb_script, "killed")) {
invoke (ScriptDictionaryItem(target.cmb_script, "killed"))
}
}
}
} else {
if (target=player){
msg( "A last strike hits you. You are dying.")
msg( "GAME OVER")
finish
} else {
msg( target.name + " dies.")
SetObjectFlagOn (target, "dead")
target.alias = GetDisplayAlias (target) +" (dead)"
cmb_addexp(target)
if (DictionaryContains(target.cmb_script, "killed")) {
invoke (ScriptDictionaryItem(target.cmb_script, "killed"))
}
}
}
} else {
msg("Why do you want to do this?")
}
returnvalue=true
}
return (returnvalue)
</function>

<function name="cmb_addexp" parameters="object" >
found=false
new_level=0
if (object.cmb_exp>0){
player.cmb_exp=player.cmb_exp+object.cmb_exp
msg("You got "+object.cmb_exp+" exp.")
foreach(x,cmb_intern.cmb_lvlexp) {
if(player.cmb_exp >= ToInt( StringDictionaryItem(cmb_intern.cmb_lvlexp,x))){
new_level=toint(x)
found=true
}
}
}
if (found) {
player.cmb_level=new_level
msg("Level "+new_level)
cmb_refreshStatus
}
</function>

<function name="cmb_chkObject" parameters="object" type="boolean">
value = false
foreach (cmb_object, AllObjects()) {
if (object=cmb_object) {
value = true
}
}
return (value)
</function>

<function name="cmb_chkFighter" parameters="object" type="boolean">
if (DoesInherit (object, "cmb_fighter")) {
return (true)
} else {
return (false)
}
</function>

<function name="cmb_chkAttrib" parameters="attrib" type="string">
<![CDATA[
if (ucase(left(attrib,4))<> "CMB_") {
attrib="cmb_" + attrib
}
if ( ListContains ( cmb_intern.cmb_attribs , ucase(attrib) )) {
return (attrib)
} else {
return ("")
}
]]>
</function>

<function name="cmb_isReachable" parameters="object" type="boolean">
value=false
foreach (x,ScopeReachableNotHeld ()) {
if(x=object) {
value=true
}
}
return (value)
</function>

<function name="cmb_dicesix" type="int">
dice=cmb_dice(GetRandomInt(1,6))
return (dice)
</function>

<function name="cmb_dice" parameters="number" type="int">
dice=GetRandomInt(1,number)
return (dice)
</function>

<function name="dict2string" parameters="dict" type="string">
text=""
foreach (x, dict) {
text=concat (text,concat (x,StringDictionaryItem (dict,x),"="),";")
}
return (text)
</function>

<function name="string2dict" parameters="text, dict">
list=split(text, ";")
if (ListCount(list)>0) {
for(x, 0, ListCount(list)-1) {
if ( Instr(StringListItem ( list , x ),"=")>0) {
list2=split( StringListItem ( list , x ), "=")
dictionary add (dict,StringListItem ( list2 , 0 ), StringListItem ( list2 , 1 ))
}
}
}
</function>

<function name="concat" parameters="text1,text2,separator" type="string">
if ( LengthOf(text1)>0 and LengthOf(text2)>0 ){
return (text1 + separator + text2)
} else if ( LengthOf(text1)>0 ) {
return (text1)
} else {
return (text2)
}
</function>

<function name="DictionaryContainsValue" parameters="dict,value" type="string">
found=""
foreach (x,dict) {
if (StringDictionaryItem(dict,x)=value) {
found=x
}
}
return (found)
</function>

<function name="cmb_startTurnscript" >
create turnscript ("cmb_tscript")
SetTurnScript (cmb_tscript) {
cmb_checkItems
}
EnableTurnScript (cmb_tscript)
</function>

<function name="cmb_checkItems" >
foreach (x,ScopeAllObjectsNotHeld () ) {
pos=instr( GetString ( x , "alias" ) , "(" )
if ( pos >0) {
cmb_unequipIntern( GetString ( x , "name" ))
}
}
</function>


<function name="ScopeAllObjectsNotHeld" type="objectlist">
result = NewObjectList()
foreach (obj, AllObjects()) {
if (not Contains(player, obj) and Contains(player.parent, obj)) {
list add(result, obj)
}
}
return (result)
</function>


</library>


if I could get some help clarifying, understanding, and-or comparing-contrasting these two libraries, I'd be appreciative.

I think Chase already has implemented equipment layers ("clothing layers") and equipment body part locations, and-but he-she does it differently then Pertex has in his-her combat library.

So, if this is correct, then I'd just need to add in Pertex' equipment level stuff, (I'm not yet delving into the actual combat function stuff yet, lol), is this correct? (As I want to have a normal rpg-like "equipment system-screen" = equipment layers, equipment body part locations, and equipment level requirement too)

I can't tell, but I don't think, Chase has a way of enabling the string dictionary for attributes for the equipment objects, like Pertex has, is this correct?

will chase's library be able to implement the actual combat system-functions-commmands, or do I really need to use Pertex' library structure for this instead?

------

also,

should I just keep the equipment and spell libraries separate, but add them to my game file, or should I try to add the equipment and spell stuff together, like under the same tab (an all encompassing "npc" object type and-or a tab that handles even more stuff than just equipment and spells, such as like status attributes, "thieving", and maybe "diplomacy" - err of what can be scripted as child of object type, as I now know thanks to Jaynebonne, most main scripting will be the game functions) under one library, or not?

and so here's pixie's spell library as well:

<?xml version="1.0"?>
<library>


<!--
This library adds a basic magic system to quest. It allows for three types of spells:

nonattackspell: Instant effect
lastingspell: An on-going spell. These last until another spell is cast
attackspell: Instant effect, attacking anything of the "monster" type that is not dead

Attack spells must be of an element, and eight are already set up. Monsters
can be assigned to elements too; they will be immune to that element, but take
four-fold damage from the opposed element.

A "Magic" tab is added to the editor to make setting up spells and monsters as easy as possible.
-->

<!--
Adding new elements involves a bit of effort. This system requires that elements are added in pairs or opposites,
such as fire and frost.
1. Create a new type for both elements, named [elemem]_type
2. In the data section, the object element_struct needs both elements added to both "elements" and
"opposedelements", and for the latter you need to put them in both ways around (look at existing entries)
3. You need to add both elements to the tab, both for "monster" and for "attackspell". Again, see existing
entries.
-->


<!-- =================================================== -->
<!-- Templates -->

<!--
Using templates makes it easier to convert to other languages, but also for other users to word it how they want it.
When templates are in the library that uses them (as here) the way to change the language is to
modify the template in the library, so really the only benefit is that all the text is together here.
Also modify the default responses in the verbs!
-->

<template name="Learn">learn</template>
<template name="Cast">cast</template>

<template name="LookDead">Oh, and it is dead.</template>
<template name="SpellAlreadyKnown">Er, you already know that one!</template>
<template name="SpellNotKnown">Er, you don't know that one!</template>
<template name="NoMonstersPresent">No monsters present</template>

<dynamictemplate name="SpellEnds"><![CDATA["The <i>" + GetDisplayAlias(object) + "</i> spell ends."]]></dynamictemplate>
<dynamictemplate name="SpellCast"><![CDATA["You cast <i>" + GetDisplayAlias(object) + "</i>."]]></dynamictemplate>
<dynamictemplate name="SpellLearnt"><![CDATA["In a process that seems at once unfathomable, and yet familiar, the spell fades away, and you realise you are now able to cast the <i>" + GetDisplayAlias(object) + "</i> spell."]]></dynamictemplate>



<!-- =================================================== -->
<!-- Verbs -->

<verb>
<property>learn</property>
<pattern>[Learn]</pattern>
<defaultexpression>"You can't learn " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>cast</property>
<pattern>[Cast]</pattern>
<defaultexpression>"You can't cast " + object.article + "."</defaultexpression>
</verb>


<!-- =================================================== -->
<!-- Functions -->

<!--
Handles an attack on the given monster, using the given spell.
Monster loses hit points according to the spell's powerrating.
If they share an element, then no damage, if elements are opposed, damage is multplied by 4
Handles monsters with no elements too, but spell must have an element set.
-->
<function name="SpellAttackMonster" parameters="monster, spell"><![CDATA[
element = GetElement (monster)
handled = False
if (not element = Null) {
if (DoesInherit (spell, element + "_type")) {
msg ("... " + monster.ignoreselement)
handled = True
}
if (DoesInherit (spell, StringDictionaryItem (element_struct.opposedelements, element) + "_type")) {
monster.hitpoints = monster.hitpoints - 4 * spell.powerrating
handled = True
if (monster.hitpoints > 0) {
msg ("... " + monster.hurtbyelement)
}
else {
msg ("... " + monster.deathbyelement)
Death (monster)
}
}
}

if (not handled) {
monster.hitpoints = monster.hitpoints - spell.powerrating
if (monster.hitpoints > 0) {
msg ("... " + monster.hurt)
}
else {
msg ("... " + monster.death)
Death (monster)
}
}
]]></function>


<!--
Call this when a spell is cast, to ensure any on-going spells
are terminated.
-->
<function name="CancelSpell"><![CDATA[
if (HasObject (player, "currentspell")) {
spell = player.currentspell
msg (DynamicTemplate("SpellEnds", spell))
player.currentspell = null
if (HasScript (spell, "terminate")) {
do (spell, "terminate")
}
}
]]></function>


<!--
Call this when a monster dies for some housekeeping.
-->
<function name="Death" parameters="monster"><![CDATA[
monster.alias = monster.alias + " (dead)"
if (HasString (monster, "lookwhendead")) {
monster.look = monster.lookwhendead
}
else {
monster.look = monster.look + " [LookDead]"
}
monster.dead = True
]]></function>


<!--
Returns as a string the name of this object's element (or null).
-->
<function name="GetElement" parameters="obj" type="string"><![CDATA[
result = Null
foreach (element, element_struct.elements) {
type = element + "_type"
if (DoesInherit (obj, type)) {
result = element
}
}
return (result)
]]></function>


<!--
Describes casting
-->
<function name="DescribeCast" parameters="spell"><![CDATA[
if (HasString (spell, "description")) {
msg (DynamicTemplate("SpellCast", spell) + " " + spell.description)
}
else {
msg (DynamicTemplate("SpellCast", spell))
}
]]></function>


<!-- =================================================== -->
<!-- Object types -->

<type name="spell">
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<learn type="script"><![CDATA[
if (not this.parent = player) {
this.parent = player
this.inventoryverbs = Split ("Cast", " ")
msg (DynamicTemplate("SpellLearnt", this))
}
else {
msg ("[SpellAlreadyKnown]")
}
]]></learn>
</type>



<type name="attackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
// Check the player has the spell
// If so iterate through all objects in the room
// Apply attack to those with the monster type that are not dead
if (this.parent = player) {
DescribeCast (this)
flag = False
foreach (obj, ScopeVisibleNotHeld ()) {
if (DoesInherit (obj, "monster") and not GetBoolean (obj, "dead")) {
SpellAttackMonster (obj, this)
flag = True
}
}
if (not flag) {
msg ("... [NoMonstersPresent]")
}
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>


<type name="nonattackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>


<type name="lastingspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
player.currentspell = this
player.status = this.status
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>


<type name="fire_type">
</type>

<type name="frost_type">
</type>

<type name="storm_type">
</type>

<type name="earthmight_type">
</type>

<type name="shadow_type">
</type>

<type name="rainbow_type">
</type>

<type name="divine_type">
</type>

<type name="necrotic_type">
</type>

<type name="monster">
</type>


<!-- =================================================== -->
<!-- Data -->

<!--
This is a data store for elements (I call it a "struct" after the keyword in the C programming language)
If you add more elements to the name, you need to add them to both lists as well as creating a new type.
Note that your new type must end "_type", but that must not be included on these lists.
-->
<object name="element_struct">
<elements type="list">fire; frost; storm; earthmight; shadow; rainbow; divine; necrotic</elements>
<opposedelements type="stringdictionary">fire = frost;frost = fire;storm = earthmight;earthmight = storm;shadow = rainbow;rainbow = shadow;necrotic = divine;divine=necrotic</opposedelements>
</object>


<!-- =================================================== -->
<!-- Tabs -->

<tab>
<parent>_ObjectEditor</parent>
<caption>Magic</caption>
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>

<control>
<controltype>dropdowntypes</controltype>
<caption>Spell type</caption>
<types>*=None; nonattackspell=Non-attack spell; lastingspell=Lasting spell; attackspell=Attack spell; monster=Monster</types>
<width>150</width>
</control>



<control>
<controltype>title</controltype>
<caption>Non-Attack Spell</caption>
<mustinherit>nonattackspell</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>

<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>



<control>
<controltype>title</controltype>
<caption>Lasting Spell</caption>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Status when active</caption>
<attribute>status</attribute>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>script</controltype>
<caption>Cacel spell effect</caption>
<attribute>terminate</attribute>
<mustinherit>lastingspell</mustinherit>
</control>



<control>
<controltype>title</controltype>
<caption>Attack Spell</caption>
<mustinherit>attackspell</mustinherit>
</control>

<control>
<controltype>number</controltype>
<caption>Power of attack (1-10)</caption>
<attribute>powerrating</attribute>
<width>100</width>
<mustinherit>attackspell</mustinherit>
<minimum>0</minimum>
<maximum>10</maximum>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>attackspell</mustinherit>
</control>

<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; frost_type=Frost; storm_type=Storm; earthmight_type=Earthmight; shadow_type=Shadow; rainbow_type=Rainbow; necrotic_type=Necrotic; divine_type=Divine</types>
<width>150</width>
<mustinherit>attackspell</mustinherit>
</control>



<control>
<controltype>title</controltype>
<caption>Monster</caption>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; frost_type=Frost; storm_type=Storm; earthmight_type=Earthmight; shadow_type=Shadow; rainbow_type=Rainbow; necrotic_type=Necrotic; divine_type=Divine</types>
<width>150</width>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>number</controltype>
<caption>Hit points</caption>
<attribute>hitpoints</attribute>
<width>100</width>
<mustinherit>monster</mustinherit>
<minimum>0</minimum>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on injury</caption>
<attribute>hurt</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on death</caption>
<attribute>death</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on injury by opposed element</caption>
<attribute>hurtbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on death by opposed element</caption>
<attribute>deathbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on ignore</caption>
<attribute>ignoreselement</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Look (when dead)</caption>
<attribute>lookwhendead</attribute>
<mustinherit>monster</mustinherit>
</control>

</tab>
</library>

Icandoit
could you tell me where at in my game code I insert the following code for creating the character in the code below?
I am a newbie too and cant find where to put this code and I want my player to be able to enter their own info. Thanks so very very much!

<start type="stript">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
msg ("Hi, " + player.alias)
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>

HegemonKhan
(All coding directly in this post, is Pixie's codes, credit goes to him-her, not me)

@Icandoit,

Quick Answer to your question:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>
<gender_list type="list">male; female</gender_list>
<class_list type="list">warrior; cleric; mage; theif</class_list>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
</asl>


you can replace, remove, and-or add whatever you want, to these lines (just follow the format):

<gender_list type="list">male; female</gender_list>
<class_list type="list">warrior; cleric; mage; theif</class_list>

for examples:

<gender_list type="list">male; female; transvestite; asexual</gender_list> (there's not many more options for gender, lol)

<class_list type="list">warrior; cleric; mage; theif; barbarian; ranger; druid; rogue; wizard; ninja</class_list>
~OR~
<class_list type="list">engineer; chemist; biologist; zoologist; mathematician</class_list>
~OR~
<class_list type="list">warrior; theif</class_list>
~OR~
<class_list type="list">doctor; nurse</class_list>

you could also add in more lists and showmenus, such as "what is your race? (human, elf, dwarf, orc, etc)" or whatever else, but it'll take a bit more work, you may need help too on this, which I can help you with (you can see the bottom of this post, but I use an alternative character creation method. I can show you though also with this, "using the lists", method as well).

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

this is long as it is an explanation of understanding stuff, but follow it (hopefully it will make sense, lol) and you'll get to where you put your character creation ("CC") script block into the Code, via the Code View mode.

@Icandoit,

In the GUI (?general? user interface = the noob-friendly mode with the click on-buttons-menus-windows and stuff):

you got the left side, which has your outline-tree of stuff:

Objects
->Game
->->Verbs
->->Commands
->Room
->->Player
Functions
Timers
Walkthrough
Advanced
->Included Libraries
->->English.aslx
->->Core.aslx
->Templates
->Dynamic Templates
->Object Types
->Javascript

in the Code View (there's a small button at the top of the GUI which toggles to this mode and the GUI mode, it's between the play and ? buttons, and looks like a piece of paper), it looks like this:

<asl version="520">

<include ref="English.aslx"/>
<include ref="Core.aslx"/>

<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
</game>

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

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

</asl>


In the GUI, click on the 'Game' on the left side (the outline-tree of stuff).

this brings up, on the right side, the stuff we can do for the:

Object -> Game

what you see on the right side in the GUI, corresponds to what goes within this section of the Code (in Code View mode):

  <game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
</game>


so, (in the GUI mode and on its right side) try clicking now on the: Setup (if you aren't already on this tab button screen)

Object -> Game -> Setup

you'll see:

Game name: ________ (for me, the-my game file is called, "Testing Game Stuff")
Game ID: some long collection-"sentence" of letters and numbers (this is known as a 'string' in the game coding, btw) that the quest game engine creates for identification - it's like a your game file's "car license plate" - we don't touch this in other words
Version: ___ (for me and you, it should initially be 1.0, unless you changed it)
Author: ____
Category: ____
Description: ______

Do you notice how this matches up with the Code View above? (try typing in the author and selecting a category in teh GUI, then take a look at the code, via the Code view. the description is for when-if you uploaded your game to Alex' site, for other people to download, they can see this "description" when they look at whether they want to download your game or not, so this description in the Object -> Game -> Setup -> Description, is more like a "game box' cover's" description, so it doesn't appear within the actual playing of the game, nor in its code view mode too - I think lol)

Whatever you do in this GUI's:

Object -> Game -> (tab 1) Setup, or (tab 2) Script, or (tab 3) Options, or (tab 4) Display, or (tab 5) Attributes

corresponds to what is in between this Code (in Code View mode):

<game name="____">
(the GUI's Object -> Game -> 5 Tabs' changes go here, and also up above for the game name too, lol)
</game>

now, back in the GUI, click on the: Script tab (instead of the Setup tab)

Object -> Game -> Script

which you'll see:

Start Script: _____ (its a script selection pull down menu bar)
Turns Script: _____ (its a big box with an add button)

if you were to create the character creation via the GUI, you'd do it via the Start Script:

Object -> Game -> Script -> Start Script

so, in Code View mode, it'll look like this (this is where you'll be putting it):

(the indentation must be exact, you must line up each line to the other lines correctly)

each (or 1) indent = 2 spaces

(I put in empty space lines, just so you can see the blocks and what sections, larger blocks, they're inside of)

also the indenting is *WRONG* here, as each line needs to be 1 more indent, 2 spaces, over to the right:
<game name="Testing Game Stuff">

<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>

<start type="stript">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
msg ("Hi, " + player.alias)
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>

</game>


*CORRECT* Identation and-of the Full Code in Code View:
<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("Let's generate a character...")
msg ("First, what is your name?")
get input {
player.alias = result
show menu ("Your gender?", game.gender_list, false) {
player.gender = result
show menu ("Your skill set?", game.class_list, false) {
player.class = result
msg (" ")
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
msg (" ")
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
</start>
<gender_list type="list">male; female</gender_list>
<class_list type="list">warrior; cleric; mage; theif</class_list>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
</asl>


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

P.S.

@Icandoit,

I've done this character creation stuff so many times, I know it inside and out, so I can help you with it, so please ask away about it, if you have any other questions about creating a character creation, or are confused with any part of this post of mine in trying to explain this to you, if anything confuses you in this post, ask about it!

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

P.S.S.

@Icandoit,

some alternative things you can do:

you can replace these (see below) to [(see below), as they do the same thing (the 'split' is the easier-quicker method):

game.gender_list
~TO~
split ("male;female" , ";")

game.class_list
~TO~
split ("warrior;cleric;mage;thief" , ";")

and by using the 'split' method, you don't need to create the lists (so you can delete these lines directly via in your Code View mode):

<gender_list type="list">male; female</gender_list>
<class_list type="list">warrior; cleric; mage; theif</class_list>

Or, via the GUI, these lists are found, here (and delete these attrbute lists below):

Object -> Game -> Attributes (Tab) -> Attributes (big box at button with add button) ->

Name (value)
gender_list (male,female)
class_list (warrior, cleric, mage, thief)

here's how the Code (in Code View mode) looks in this alternate form-method:

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + LCase (player.gender) + " " + LCase (player.race) + " " + LCase (player.class) + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
</asl>


I can help if you're confused by this.

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

my own way of doing the character creation (this will need some explaining for you, which I can do for you):

(doh! I forgot to use the 'LCase' method, it makes doing the string message expression a bit easier, lol and meh)

in Code (in Code View mode):

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</object>
</object>
<turnscript name="turns turn script">
<enabled />
<script>
player.turns = player.turns + 1
</script>
</turnscript>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("what is your race?", split ("human;elf;dwarf;orc" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;wizard;thief" , ";"), false) {
player.class = result
msg ("")
msg (player.alias + " is a " + " " + player.gender + " " + player.race + " " + player.class + ".")
msg ("")
msg ("(press a key to continue)")
wait {
ClearScreen
}
}
}
}
}
</function>
</asl>


I can help if you're confused by this.

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

P.S.S.S.

you can right click on any of your .aslx files, and select (or just open the .aslx files with) notepad or wordpad, and open them (in Code View mode), make changes, and then save it, to change your game.

also, use my code boxes on this post, as it allows you to copy them, then you can paste them directly into your game via the Code View mode, with the correct indentation kept in place for you.

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

P.S.S.S.S.

here's pixie's wiki guide on character creation:

http://quest5.net/wiki/Character_Creation

and here's a thread with 3 links for character creation:

viewtopic.php?f=10&t=3306

and there's more stuff to learn, but we'll get to that after you get the basic character creation script block down, wink.

more stuff:

here's pixie's extremely useful explanation of the character creation script block:

(you can copy and paste this code below directly into your game's code - at the correct spot of course, in code view, and then go into the GUI, and look at it, those "//_____" are the "Comment" scripts, and they're really awesome, as you can use them to leave notes to yourself about whatever parts of the code you want, such as you might understand the coding now, but come back to it after doing other stuff, and you might not have a clue anymore with what your coding does or how it words, so these "Comment" scripts in the GUI, or as the "//_____" in the Code View mode, are really useful, especially for us noobs, hehe)

  <start type="script">
// Here "msg" is a script command, what string is sent to it will appear on the screen
msg ("Let's generate a character...")
// And again
msg ("First, what is your name?")
// Another script command, "get input". Waits for the player to type something,
// puts that text into a variable called "result",
// then runs its 'block'. The block is enclosed in curly braces.
get input {
// The "player" object has an attribute "alias" that is
// now set to the text in the "result" variable.
player.alias = result
// Now use "msg" to print to the screen, but this time the text is constructed
// by adding together two parts, using the plus sign.
msg ("Hi, " + player.alias)
// I have broken one line into two for simplicity
// The "Split" function breaks up a string of text into set of smaller strings,
// called a 'string list'.
// Here it will break up "Male;Female", and it will break the string wherever it
// find a semi-colon, as the second paramter is ";".
// The variable "options" will contain the output of the function.
options = Split ("Male;Female", ";")
// The "show menu" scrpt command will display a menu for the player.
// The "Your gender?" part will be the prompt or title.
// Then it will use the variable "options", which we just set. So the player will
// have the choice of "Male" or "Female".
// Finally we have "false", which tells Quest not to let the player cancel the menu
// choice.
// As with "get input", when the player makes a choice, the text goes into "result"
// and the block is run.
show menu ("Your gender?", options, false) {
// The "gender" attribute of "player" is now set to "Male" or "Female",
// as the player chose
player.gender = result
// Another menu, just like before, but here the two lines are combined
// You have the prompt, the string list with the option from the "Split"
// function, and "false" again.
show menu ("Your character class?", Split ("Warrior;Wizard;Priest;Thief", ";"), false) {
// The "class" attribute of "player" is now set.
player.class = result
// Print an empty line.
msg (" ")
// Print a summary to screen
msg (player.alias + " was a " + LCase (player.gender) + " " + LCase (player.class) + ".")
// Print an empty line.
msg (" ")
// Print instructions.
msg ("Now press a key to begin...")
// The "wait" script command is kind of like "get input", but instead of the player
// typing a sentence, the player presses a single key. Once that happens,
// the code in that box runs
wait {
// This function clears the screen, as you probably guessed
ClearScreen
// This is the end of the "wait" block.
}
// This is the end of the second "show menu" block.
}
// This is the end of the first "show menu" block.
}
// This is the end of the "get input" block.
}
</start>


and if you go back to the first page of this thread of mine, and scroll down, you can see my own posts asking the others here, to help explain to me the character creation script block, hehe (you can see how dumb-noob I was just a month ago, lol).

Icandoit
Thank you so very very much, I now have that part working!

I do have another question. Is there a way to change the direction names? Meaning instead of 'north' 'south' etc to something like "enter" or something like that. I am trying to make it says something like "To enter nter Becky's Palace enter 'here' or something like that. In other words can I rename the 'north' 'south' commands? Thanks again for all your help, this site is awesome!

HegemonKhan
I haven't worked that much with this stuff yet, so I may not be able to help you, but others can do so. However, I'll see what I can do, lol.

Do you know about the wiki's tutorial? as it goes through much of this basic stuff. if not, here's the tutorial link:

http://quest5.net/wiki/Tutorial

these are also extremely useful links too:

http://quest5.net/wiki/Main_Page
http://quest5.net/wiki/How_to

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

What you want to deal with (and-or read about) are: Exits and probably also Commands ("GoTo" #room# - I'll have to see how to do this correctly as I haven't yet worked with a GoTo command yet)

here's some links about the Exits and Commands:

http://quest5.net/wiki/Creating_a_simple_game (a part-section of the tutorial)
http://quest5.net/wiki/Using_lockable_exits (a part-section of the tutorial)
http://quest5.net/wiki/Custom_commands (a part-section of the tutorial)

http://quest5.net/wiki/Multiple_choices ... %22_script (this could be needed-useful in creating a GoTo command. A part-section of the tutorial)

(or, maybe you'd have to create a sort of teleporter type of room and-or object, instead. I just haven't worked on room traveling stuff yet myself, so I'm not sure how and-or of the ways that this can be done, with a GoTo command, a teleporter room and-or object, or whatever other means-methods of traveling to-from-between-amongst rooms, beyond the 12 directions of the Rooms' Exits)

http://quest5.net/wiki/Port_and_starboard (there is this, but its not for you to deal with, as its too advanced for you, and maybe for me myself too lol)

http://quest5.net/wiki/Implement_a_Lift (there is this, so it can be done, but I'd have to try to understand its parts, to be able to help you with creating a GoTo command, or whatever. This is too advanced for you to work with, and might be for me as well too)

If you download other peoples games, they have GoTo type of commands (or whatever), so it's definately quite possible to implement, and thus also keeping your 12 (compass + up/down + in/out) directions intact for their very own extremely useful purposes.

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

http://quest5.net/wiki/Creating_a_simple_game (a part-section of the tutorial)

this mostly tells how to do what you want with the Exits:

also, on each of the exits, you can make a script messages for going-entering and leaving-exiting (You enter the spooky castle, your legs trembling. you exit the spooky castle, the bright sun eases your terror from what you experienced inside the spooky castle)

each of your rooms can have up to 12 directions (and you can rename all 12 directions):

(1) NW, (2) N, (3) NE, (4) E, (5) SE, (6) S, (7) SW, (8) W, (9) In (or renamed to your "enter"), (10) Out (or renamed to "exit"), (11) Up, (12) Down

so for examples (if you don't want the compass direction names):

(1) Wasteland, (2) Grassland, (3) Plains, (4) Forest, (5) Mountains, (6) Desert, (7) Tundra, (8) Swamp, (9) In (or renamed to your "enter"), (10) Out (or renamed to "exit"), (11) Cloud World, (12) Underworld

or (If I knew all the ship names... lol... like if you want a pirate-ship or a startrek-spaceship like games)

(1) Port, (2) Starboard, (3) Galley, (4) Brig, (5) Captain's Quarters, (6) Crew Quarters, (7) Deck, (8) Cargo Hold, (9) Embark (10) Disembark, (11) Sail From Home, (12) Sail To Home

----------

Now I haven't worked with this yet, but I believe you can go beyond these 12 directions (and you probably also want to keep them, as they're useful), by creating a command, GoTo, and then you can just type in the name of the room (place) you want to go to, though it will involve a bit of coding to do so (I'm sure, err hopefully, I can figure it out, for you if need be or maybe someone else can help you out with it instead, and-or if I can't figure it out on my own).

HegemonKhan
Help Needed

A quick side help (as I've been trying to work on a goto command from or due to trying to help Icandoit's request for help), as I don't understand using commands well enough, yet (hardly at all actually):

I don't know how to get or set up the goto command's (typed in) input by you (the game player; User), to produce or to result in the desired~correct movement to the object (room) place.

how do you set up a command [ goto ?#?____?#? ] , to move the player to that specific room that you typed in for the [ goto ] command ?

for example:

goto ____ -> you are now in that room _____
goto ?#object#? -> you are now in that object:room:name~alias mountain/forest
-> goto mountain -> player.parent = mountain
-> goto forest -> player.parent = forest

-----------

I have found~created an indirect method, using the command [ goto ], to simply call a function, which then uses a menu and a list for choosing your goto destination. ( just type: goto )

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
<alias>homeland</alias>
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
<object name="room1">
<inherit name="editor_room" />
<alias>grassland</alias>
</object>
<command name="goto">
<pattern>goto</pattern>
<script>
location
</script>
</command>
<object name="room2">
<inherit name="editor_room" />
<alias>plains</alias>
</object>
<function name="location">
show menu ("Destination?", split ("homeland;grassland;plains" , ";"), false) {
switch (result) {
case ("homeland") {
MoveObject (player, room)
}
case ("grassland") {
MoveObject (player, room1)
}
case ("plains") {
MoveObject (player, room2)
}
}
}
</function>
</asl>

Icandoit
Thank you again for all your help. I think I found a very simple solution. I went the exit code for the room i was trying to go to and renamed the alias name to what I wanted but left the inherit name southwest. I ran it and it worked. I know this may not be the proper way to do it but it worked. haha.

I will say I appreciate all the help you have given me as it made a lot of sense and helped me understand a lot more about this program and the way the code works.

My next task is to figure out how to get the wording to be in the center of the screen instead of on the left side when the game is played. I dont know if <center></center> command will work or not but I am going to try it to see if it works.

Thank you so much my friend, I'm sure I will have more questions! lol

Icandoit
Okay, the <center></center> didnt work. How would I get everything that shows up on the screen when the game is played to be centered? Thanks, and I hope I am not being too big a pain! lol.

Pertex
Your goto command:

  <command name="goto">
<pattern>goto #text#</pattern>
<script>
player.parent = GetObject(text)
</script>
</command>

jaynabonne
Pertex wrote:Your goto command:

  <command name="goto">
<pattern>goto #text#</pattern>
<script>
player.parent = GetObject(text)
</script>
</command>


That seems a bit dangerous to me - the user can type in anything, and just about anything except a small set of input values will cause a Quest exception. And the user has to type in the internal object name for the room...

Pertex
Sure, it should be a short example how to do it, I don't want to do HegemonKhan's work :D

HegemonKhan
Thanks Pertex!

I didn't know how to connect to the command and its input for it, I didn't know whether to use #text# or #object#, whether I needed to use Get Input or not, so now I know how the command works (though it involved a script I haven't learned of yet, but I see now how the connection works with the command and its input), I just need to learn all these other scripts still, as I've held off on them as I'm still not quite ready for dealing (working on understanding) with the item-list iteration, scopes, objects, and etc script stuff.

And, indeed, I don't want you guys doing everything for me, lol. I just couldn't figure out how to connect the script with the command, but now I do, thanks to Pertex. I'm sure I can't yet work out how to effectively limit a goto command yet, as it surely involves all that item-list iteration, scopes, and etc scripts, which I haven't worked on learning, after I get done all the equipment, spells, monster/npc, combat stuff, and their functions, then I'll get to work on all these scripts that I need to get understanding.

-----------

P.S.

HegemonKhan is too long to write out,

HK (or hege or khan) is quite fine to use, as I myself never write out HegemonKhan, lol

Icandoit
Can you tell me how to center the input on the screen during the game. For example, when I created the character (that is working now and I really thank you for the help on that) it appears on the left side of the screen as text input. I would like that to be centered on my screen but don't know how to do that. Help? lol.

jaynabonne
Icandoit wrote:Can you tell me how to center the input on the screen during the game. For example, when I created the character (that is working now and I really thank you for the help on that) it appears on the left side of the screen as text input. I would like that to be centered on my screen but don't know how to do that. Help? lol.


Just a suggestion: if I were you, I'd start a new thread for this. As it is right now, it's buried in this thread, which not everyone may be following...

A clarification: do you mean that you want to center the *output * text on the screen? If so, then I think the answer (currently) is no. I looked at the HTML, and the divOutput that is used is hard-coded to text-align:left. (Perhaps that will be configurable in the future.) You can only override individual msg output lines that you generate yourself. The ones generated down in the core can't be overridden. So I think you're stuck...

HegemonKhan
Some quick questions with using-creating tabs (with coding, such as with created object types):

I presume you can code everything into the game, without using any created tabs, as they just serve as a quick way to set up your objects and etc in the game via the GUI. (Also, tabs are a way of creating coding, and so are an alternative to normal coding). Is all this correct, or no?

Do the tabs have any confliction with the coding?

I'm basically asking what is the relationship between tabs and coding (such as via the created object types).

for examples (in the various libraries: Pertex' Combat Library, Pixe's Spell~Magic Library, and Chase's Equipables Library):

I've seen the tabs create the coding (there's no coding outside of the tabs), such as with attributes and their values.
I've seen coding in the game, not used (set up) with the tabs at all.
I've seen coding set up both in the tab and outside of the tab.

So, I'm confused as to what, when, and~or if, coding, goes into the tab, outside of the tab, or into both the tab and outside of the tab.

What coding can or must be done in only (requiring only of via through) the tabs?
What coding can or must be done in the outside coding (such as with the object types)?
What coding can be done in either the tab or outside of the tab?
what coding can or must be done in both the tabs and outside of the tabs?

What coding should (or must) I put into (or use the) the tabs (for) ?
What coding should (or must) I put into (or use the) object types (for) ?
what coding should (or must) I put into both (or use both of the) the tabs and the object types (for) ?

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

just a progress check of where-what I'm currently at, and trying to do, in slowly learning the coding more and more.

I'm trying to slowly create my own library of this stuff (spells~magic, equipment, combat, pc vs npc, and eventually storage (to organize the player's inventory, items, thievery, relationship: ally - friendly - neutral - hostile -enemy, and etc), but I'm still just working with trying to set up the object types and tabs, before moving onto the hard part of me creating my own combat coding (well the functions and all of that stuff beyond just the object types and tabs) and then hopefully able to customize the spells and equipment or at least create it without having to copy-look up pixie and chase libraries, as I really don't like using someone else's work, and I want to be able to do this stuff myself, creating libraries on my own, instead of having to copy the coding of someone else's library. I want to be able to eventually create (code) these various systems of coding all on my own.

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

P.S.

I'm also a bit confused with the templates as well.

(I get the specific examples of what I'm talking about, if need be, but for now, I'm being lazy, lol)

in one library, the inventoryverbs~displayverbs, uses the templates, as seen by the brackets.
in another library, the inventoryverbs~displayverbs, don't use the templates.
but both libraries have templates of the inventoryverbs~displayverbs set up.

So, I'm confused as to when, how, and-or why you use templates (via the brackets) vs (seemingly) not using the templates (but then why are the templates set up then..?)

Pertex
This is just my opinion, but I wouldn't create tabs for your library. As you said you are learning how to code so you should concentrate on coding. Creating tabs is complex and sometimes annoying because you can't do all the things what you want to do. And if you really get all this stuff coded (spells~magic, equipment, combat, pc vs npc, and eventually storage to organize the player's inventory, items, thievery, relationship: ally - friendly - neutral - hostile -enemy) you would need dozen of tabs.

The Pixie
Tabs are a convenience when you are creating a game, but have zero impact on the game itself; your players will have no way of telling how you set the values on attributes. And the game author can set those attributes via the attributes tab, rather than your custom tab, or directly in the code view; it is all the same.


Types are important during the game (er, except editor_object and editor_room, which disappear when you publish your game; be aware of that, but leave that to one side for now). Things in Quest have all the attributes that are set in their types, so if a type sets "scenery" to "true", then all objects of that type also have "scenery" set to "true" - unless you specifically set it for that object. You do not have to use types at all, but if you have several things that are similar, using types makes it easy, because you just set up the type once, rather than doing it for each one. Okay, you could copy-and-paste, but if you later realise you made a mistake or want them to do something else, you can change the type, and they will all get updated at once (that said, the way I do it is to create an object first, and get that working, then realise I want others like it, so create a type from that object).


Templates are a way to make it easy to convert to other languages. If you are creating libraries for your own use, do not bother. If you really want to know... There are two types of templates; templates and dynamic templates. Quest handles them very differently.

A template uses the square brackets notation. When Quest reads your game file, it goes through it one line at a time. If it finds a template definition, it will make a note of it. If it finds square brackets, it will compare that against the templates it has noted and make the substitution (and this can even be in code). This means that your definition must appear in the code before the template is used. Now suppose someone wants to use your library for a German game. His German templates have to go into the code after the English templates (so the English ones are replaced by the German), but before the templates are actually used (otherwise it is too late). If you have a library file with templates at the top, and template uses scattered through it, well, there is no way for the German writer to insert his templates without modifying your file. So for a library you are sharing, there is not a lot of point in using templates (but it is vital for libraries that are part of Quest itself; these have the templates defined in another file, so the German author can insert his templates between the two). Now I did not realise all this for some time, so some of my libraries do use templates, and some do not.

Dynamic templates are handled very differently; Quest only handles them as and when the player needs to see that text, so they do not need to be defined before they appear in the code, and the hypothetical German author can set up his own dynamic templates after the library file has been included (so his dynamic templates will overwrite the ones in the library). So it makes sense to use dynamic templates in libraries you intend to share. However, I do not think dynamic templates can be used everywhere that templates can (for example for command patterns and displayverbs), so you end up with some libraries that are partly set up for other languages, and partly not.

jaynabonne
I'd like to chime in with respect to tabs.

There are two views on the Quest code: the GUI (graphical user interface) view and "code view". "Code view" is a direct view onto the code, allowing direct manipulation of the code in a text format. The GUI view attempts to provide a more "user friendly" view on the code using graphical menus, tables, value entry, checkboxes, drop-down lists, etc. And, yes, tabs. :)

It's analagous to an operating system like Windows, where you can view the file system graphically and operate on icons, or you can drop down to a command prompt and do everything textually. To delete a file at the command prompt, you would type "del filename", whereas in the GUI, you'd click on the file icon and hit the "Del" key.

In both of these examples (Quest and WIndows), the GUI is more handy for things that it does well, but in both these examples, you inevitably can do more in the direct mode. The GUI only exposes some functionality (though Quest does a fairly good job for the majority of authors).

From what I have seen, tabs are largely (or even solely?) used to set attribute values on objects, in a handy, convenient way.

If your goal is to learn coding, then you can largely eschew the GUI view. I use it for doing straightforward things like creating new objects, rooms, exits, etc, especially since I can't remember all the attributes to use, and it is much more efficient for such things. It's very handy for setting attributes on objects. But I never write script code in the GUI view (short of perhaps an initial dummy "msg" to give me an empty script to use). For me, code view is much easier to use for writing scripts. It's up to you how you want to use the two modes.

You would possibly add tabs to your code if you wanted to be able to edit values in GUI mode, especially if you wanted to someday provide it for others to use, others who might not ever venture into the direct code view. It's a "pretty" interface on top of the code, an alternate way that is meant to be easier. You can do everything in code view that can be done with the GUI and tabs. (The opposite is not true.)

A note: I have dozens of libraries of code that I have created, and I've yet to create a single tab. I plan to explore that someday, but it hasn't been a priority yet.

I hope that helps.

HegemonKhan
maybe it would be better, just to show my work on trying to create my own libraries, without using-copying as much of the other (Pertex, Pixie, and Chase) libraries as I can, or at the very least I learn-memorize-understand how to code all of them, without having to look at any of the libraries, on how to do something, or what I'm missing or forgotten to code into it. I'm not sure how much I can change-improve-make more efficient upon the libraries, even if I ever learn enough to get to that point.

here's just the start of it, still kinda in brainstorm mode, and trying to make sense of what coding needs or should be done via the tabs, via the object types (trying to be aware of what jaynebonne explained of how implemented code needs to be done as functions and not as part of the object types), and-or outside of the tabs+object types, as the normal coding, like of functions.

(also, I'm not sure how to code as code, instead of as doing it via the tabs, so if you see any syntax of coding wrong, please let me know, as I still haven't learned much of all the coding syntax and scripts and etc, also I'm not sure what attributes or what ever that I need to code into the object types or into as the game functions, especially when I'm using tabs to do stuff too. I'm just working on the brainstorming outline of object types and tabs and etc, before I get working on trying to create-set up all the functions)

so, here's so far what I got (I know it's not much, right now, as I find myself confused with what should be done as tabs, as object types, and as outside coding like game functions, ):

(this is just a "super file" so I have all my work in-at one place-file, just to make it easier for me, though I am trying to code as much as I can as actually being a "super library"... if it is even possible to do so... lol)

<?xml version="1.0"?>
<library>
<type name="storage">
<open type="boolean">true</open>
<close type="boolean">true</close>
<take type="boolean">false</take>
<drop type="boolean">false</drop>
<give type="boolean">false</give>
<use type="boolean">false</use>
<inherit name="container_base"/>
<inventoryverbs type="list">Open;Close</inventoryverbs>
</type>

<object name="item_storage">
<parent>player</parent>
<inherit name="storage"/>
</object>

<type name="item">
</type>

<type name="useable_item">
<take type="boolean">true</take>
<drop type="boolean">true</drop>
<give type="boolean">true</give>
<use type="boolean">true</use>
</type>

<type name="battle_item">
</type>

<type name="quest_item">
</type>

<type name="gear">
<take type="boolean">true</take>
<drop type="boolean">true</drop>
<give type="boolean">true</give>
<use type="boolean">false</use>
<equipable type="boolean">true</equipable>
<unequipable type="boolean">true</unequipable>
<equipable_layer type="int">3</equipable_layer>
<equipable_slots type="list">Head;Face;Ears;Neck;Shoulders;Arms;Hands;Fingers;Chest;Back;Waist;Legs;Feet</equipable_slots>
<equipped type="boolean">false</equipped>
<inventoryverbs type="listextend">Equip;Unequip</inventoryverbs>
</type>

<type name="fire">
</type>
<type name="water">
</type>
<type name="air">
</type>
<type name="earth">
</type>

<type name="spell">
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<take type="boolean">false</take>
<drop type="boolean">false</drop>
<give type="boolean">false</give>
<use type="boolean">false</use>
<learn type="script"><![CDATA[
if (not this.parent = ???) {
this.parent = ???
this.inventoryverbs = Split ("Cast;Teach" , ";")
msg (Dynamictemplate("Spell_Learned" , this))
}
else {
msg ("[Spell_Already_Learned]")
}
]]></learn>
</type>

<type name="char">
<dead type="boolean">false</dead>
<cur_hp type="int">0</cur_hp>
<max_hp type="int">0</max_hp>
<min_hp type="int">0</min_hp>
</type>

<type name="pc">
<inherit name="char"/>
</type>

<type name="npc">
<inherit name="char"/>
</type>

<tab>
<parent>_ObjectEditor</parent>
<caption>???</caption>
<mustnotinherit>editor_room</mustnotinherit>

<control>
<controltype>title</controltype>
<caption>???</caption>
<mustinherit>???</mustinherit>
</control>

<control>
<mustinherit>defaultplayer</mustinherit>
<controltype>dropdowntypes</controltype>
<caption>Character Type</caption>
<types>*=None; pc=Playable Character</types>
<width>150</width>
</control>

<control>
<mustnotinherit>defaultplayer</mustnotinherit>
<controltype>dropdowntypes</controltype>
<caption>Character Type</caption>
<types>*=None; npc=Non-Playable Character</types>
<width>150</width>
</control>
</tab>
</library>

<!--
??? = unfinished~unnamed
pc = playable character
npc = non-playable character
char = character
gear = equipment
hp = hit~health points = life
mp = mana~magic points = magic

some kind of player inventory unmoveable storage container "book" objects to organize your inventory's "items" (objects:

spells, items, gear, etc)
-->


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

P.S.

I'll paste more of my coding as I do-add more of it, so you can see what I'm trying to do, how I'm thinking and trying to come up with stuff or how to do stuff, as it's hard to explain, and especially to explain my problems-issues-confusions, so maybe through via my coding you can understand better than what I try to say in words here. So you can see my own progress of work and mf (attempting) to learn to do this stuff on my own, lol.

LoopydoA
:!: Please help me! I am using a mac to use textadventures, and whenever I try to select which exit I want something to unlock, nothing appears! and I have 15 exits in this game! What is wrong??? :oops:

HegemonKhan
quick question:

is there a way to have the game recognize a value as a percent chance?

for examples:

player.dexterity (100) - target.speed (75) = 25 = 25% chance of player hitting the target with a physical attack = 25% player.accuracy

player.agility (100) - target.speed (25) = 75 = 75% chance of player dodging the target's physical attack upon the player = 75% player.evasion

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

P.S.

after getting depressed at being completely lost, clueless, and overwhelmed, I'm just trying to do a combat system, which isn't easy, so here's what I've got so far. Can you take a look at it and see if I'm kinda going in the right direction (it could be made workable), or not at all. I don't know~understand yet any of the codes that iterate, check, "call upon", and etc of other scripts~objects~etc, the codes seen in Pixie's and Pertex' libraries, nor do I know hardly any codes at all, so my attempt is pretty limited. If I could get help as to what is the proper syntax for the codes I'd be appreciative, but let me try to work on how to code a combat system, though maybe a few directional pointers would be okay, but not much else, as I figure in order to learn this stuff, I got to try to do (and think of how to do) such coding systems, on my own, if I'm ever going to learn this stuff. If I can't make any real progress, I guess I'll then just take parts of the various libraries, and work on just that part, getting it understood and down, and go step by step (or rather part by part) like that.

<?xml version="1.0"?>

<library>

<verb name="battle">
<script>
battle_system
</script>
</verb>

<command name="battle">
<script>
battle_system
</script>
</command>

<turnscript name="battle_turns"
</turnscript>

<function name="battle_system"
<enable name="battle_turns"/>
<foreach (battle_turns; turns)
<get input/>
</function>

<!--
player.dmg_rat = player.cur_str - target.cur_end
target.dmg_rat = target.cur_str - player.cur_end

player.acr_rat = player.cur_dex - target.cur_spd
target.acr_rat = target.cur_dex - player.cur_spd

player.evd_rat = player.cur_agi - target.cur_spd
target.evd_rat = target.cur_agi - player.cur_spd
-->

<type name="char_char">

<dead type="boolean">false</dead>

<take type="boolean">false</take>
<drop type="boolean">false</drop>

<cur_hp type="int">0</cur_hp>
<max_hp type="int">0</max_hp>
<min_hp type="int">0</min_hp>

<cur_str type="int">0</cur_str>
<max_str type="int">200</max_str>
<min_str type="int">0</min_str>

<cur_end type="int">0</cur_end>
<max_end type="int">200</max_end>
<min_end type="int">0</min_end>

<cur_dex type="int">0</cur_dex>
<max_dex type="int">200</max_dex>
<min_dex type="int">0</min_dex>

<cur_agi type="int">0</cur_agi>
<max_agi type="int">200</max_agi>
<min_agi type="int">0</min_agi>

<cur_spd type="int">0</cur_spd>
<max_spd type="int">200</max_spd>
<min_spd type="int">0</min_spd>

</type>

<type name="pc_char">

<inherit name="char_char"/>

</type>

<type name="npc_char">

<inherit name="char_char"/>
<displayverbs type="listextend">Battle</displayverbs>

</type>

<tab>

<parent>_ObjectEditor</parent>
<caption>???</caption>
<mustnotinherit>editor_room</mustnotinherit>

<control>

<mustinherit>defaultplayer</mustinherit>
<controltype>dropdowntypes</controltype>
<caption>Character Type</caption>
<types>*=None; pc_char=Playable Character</types>
<width>150</width>

</control>

<control>

<mustnotinherit>defaultplayer</mustnotinherit>
<controltype>dropdowntypes</controltype>
<caption>Character Type</caption>
<types>*=None; npc_char=Non-Playable Character</types>
<width>150</width>

</control>

<control>

<controltype>number</controltype>
<caption>HP Amount</caption>
<attribute>cur_hp;max_hp</attribute>
<width>150</width>
<mustinherit>char_char</mustinherit>
<minimum>0</minimum>

</control>

<control>

<controltype>number</controltype>
<caption>Strength Amount (0-200)</caption>
<attribute>cur_str</attribute>
<width>150</width>
<mustinherit>char_char</mustinherit>
<minimum>0</minimum>
<maximum>200</maximum>

</control>

<control>

<controltype>number</controltype>
<caption>Endurance Amount (0-200)</caption>
<attribute>cur_end</attribute>
<width>150</width>
<mustinherit>char_char</mustinherit>
<minimum>0</minimum>
<maximum>200</maximum>

</control>

<control>

<controltype>number</controltype>
<caption>Dexterity Amount (0-200)</caption>
<attribute>cur_dex</attribute>
<width>150</width>
<mustinherit>char_char</mustinherit>
<minimum>0</minimum>
<maximum>200</maximum>

</control>

<control>

<controltype>number</controltype>
<caption>Agility Amount (0-200)</caption>
<attribute>cur_agi</attribute>
<width>150</width>
<mustinherit>char_char</mustinherit>
<minimum>0</minimum>
<maximum>200</maximum>

</control>

<control>

<controltype>number</controltype>
<caption>Speed Amount (0-200)</caption>
<attribute>cur_spd</attribute>
<width>150</width>
<mustinherit>char_char</mustinherit>
<minimum>0</minimum>
<maximum>200</maximum>

</control>

</tab>

</library

Pertex
It's difficult to say something about a combatsystem which is not well-conceived. I think this is your problem at the moment. How will a combat proceed? What should the player input? How should the enemy react? Is it turn based or is it fully automated?
Best thing is taking a sheet of paper and "playing" an example. Something like

>attack orc
You hit the orc.
Orc hits you.
>attac orc
You hit the orc.
Orc hits you.
>attac orc
You hit the orc.
Orc is dead.


A fully automated system would look like this

>attack orc
You hit the orc.
Orc hits you.
You hit the orc.
Orc hits you.
You hit the orc.
Orc is dead.


Then you can add all possible commands in the battle like

>attack orc
You hit the orc.
Orc hits you.
>cast fireball on orc
You hit the orc.
Orc is burning.
>equip sword
You are carrying a sword now.
Orc hits you critically.


Or perhaps you want to use a menu instead of typing each command:

>attack orc
+-----------------+
| show Menu |
+-----------------+
| attack |
| cast fireball |
| equip item |
| drink potion |
+-----------------+
[player chooses 'attack':]
You hit the orc.
Orc hits you.
...


A system with a turnscript as you described above would look like this

>attack orc
You hit the orc.
Orc hits you.
>examine flower
It's a rose.
You hit the orc.
Orc hits you.
>eat apple
It tastes good.
You hit the orc.
Orc is dead.


If you use a turnscript, the battle script is executed after every turn the player does even if the players input is senseless.

So you can see: Coding is not just writing code. First it is finding the right algorithm to do something.

Alex
@LoopydoA It's probably better to ask questions in your own new thread, rather than hiding them inside this one.

But you want to ensure that you give your exits a name - select the exit in the tree and enter a name for it. Then it will appear in the list.

HegemonKhan
chuckles, I am liking my work (it's not bad, lol), but like I could ever code it... (I still can't even code in a spell system, combat system, or a equipment system, like respectively Pixie, Pertex, and Chase do in their libraries)

but, here it is, if anyone wants to take a look at it (and~or the challenge of trying to code it, this is free for anyone to use, with the only requirement of making your code of it free for all of us to use, wink. But, let me not get too boastful, let's see if this system is good or not! HK awaits the feedback on what people think of this combat system-sequence outline without code)

NPC (non-hostile):

Talk; Steal; Fight; Give; Use; Cast (limited; only certain spells)

all of these can trigger hostility, and "Fight" (obviously) *WILL* trigger hostility

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

NPC (hostile):

Attack (physical damage), Defend (reduces physical damage, and enables a bonus to Attack in next combat turn), Cast, Item, Run

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

Other Battle Stuff:

>battle turns (rounds) are set up somehow
>player's choice lasts until you choose again
>*npc's choice* lasts until it chooses again
>npcs can't Run nor (use an) Item
>show a menu may be required to prevent you from doing any non-battle actions, inputs, and etc
>not sure how I want to handle multiple hostile npcs (battle each individually or all at once), and especially no idea if this would even be possible to code, either way, well I think anything is probably possible to code... Quest is powerful!
>instead of using show a menu, a possible alternative for battles, is to move the player and the npc(s) to a "battle room", and thus there's no non-battle stuff to do.
>player.turns would be the game-player turns as normal, and game.turns could be the battle turns (enabled upon entering the "battle room")

*I think this AI could be coded by a call function, of a function that uses a random number and switch

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

Player Attack Calculation Sequence:

1. Npc's Evasion
2A. Npc's Parry (If: No Shield and Yes Weapon, Percent Chance)
2B. Npc's Block (If: Yes Shield, Percent Chance)
3. Player's Accuracy (To Hit Percent Chance; Attack Rating)
4. Npc's Physical Resistance
5. Player's Physical Damage (Bonus if Player chose Defend last round; and Penalty if Npc chose Defend)

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

Npc Attack Calculation Sequence:

1. Player's Evasion
2. Player's Parry
3. Player's Block
4. NPC's Accuracy
5. Player's Damage Resistance
6. Npc's Damage (Penalty if Player chose Defend; and Bonus if Npc chose Defend last round)

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

Player Cast On Npc Calculation Sequence:

1. NPC's Spell "evasion"
2. Player's Spell "accuracy"
3. NPC's Magical Resistance/Immunity/Vulnerability/Relection/Absorption
4. (If permitting; depends on #3) Player's Magical Damage On Npc, or (If Npc has Reflection) On Player, or (If Npc has Absorption) than Npc receives HP instead of losing it.

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

NPC Cast On Player Calculation Sequence:

1. Player's Spell "evasion"
2. NPC's Spell "accuracy"
3. Player's Magical Resistance/Immunity/Vulnerability/Relection/Absorption
4. (If permitting; depends on #3) Npc's Magical Damage On Player, or (If Player has Reflection) On NPC, or (If Player has Absorption) than Player receives HP instead of losing it.

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

Player Defend, Run, Item, and Cast On Player:

>are self explanatory (I hope I'm not overlooking something)

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

Npc Defend and Cast On Npc:

>are self explanatory (I hope I'm not overlooking something)

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

Battle Sequence:


Round (0 or 1):

1. "Initiative" is calculated (determines who goes first)
>If Player has "Initiative", see 2A1
>If Not, see 2B1

2A1a. Player: (If) Run (determines if player can escape the battle)
2A1b. Player: (If Not Run) Attack/Defend/Cast/Item
2A2. "Quickness" is calculated (determines if player can go again)
>If Player has "Quickness", see 2A1 [but it's now Round (1 or 2) instead]
>If Not, see 2A3
2A3. Npc: Attack/Defend/Cast
2A4. "Quickness" is calculated (determines if npc can go again)
>If Npc has "Quickness", see 2A3 [but it's now Round (1 or 2) instead]
>If Not, see 1 [but it's now Round (1 or 2) instead]

2B1. Npc: Attack/Defend/Cast
2B2. "Quickness" is calculated (determines if npc can go again)
>If Npc has "Quickness", see 2B1 [but it's now Round (1 or 2) instead]
>If Not, see 2B3
2B3a. Player: (If) Run (determines if player can escape the battle)
2B3b. Player: (If Not Run) Attack/Defend/Cast/Item
2B4. "Quickness" is calculated (determines if player can go again)
>If Player has "Quickness", see 2B3 [but it's now Round (1 or 2) instead]
>If Not, see 1 [but it's now Round (1 or 2) instead]


Round (1 or 2):

>See Round (0 or 1)


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

thanks Pertex, btw, as it is helpful to get some structure first to try to code, before just trying to code as I go, with no guide structure in place. though, even if this structure-sequence-outline is good... coding it... arg, HK bangs his head onto his desk.
I think I'm going to just take your libraries and work on understanding inside and out, part by part, and hope that I then will have enough of a grasp on how to construct my own libraries~systems for my own goals~ideas for my own game creations, lol.

Chase
Don't get to discouraged at not being able to replicate our libraries, or even parts of our libraries. I assume all three of us have been programming for many years, which is a very abstract science.

I don't think anyone will volunteer to program your code for you. More so if you impose requirements (or is that just me).

If I was going to write a combat system, it would probably be pretty simple. Probably opposed rolls, dt/dr based.

HegemonKhan
I know I know... I'm just so excited to make a game, but don't yet know enough of the coding, sighs. I can follow the libraries, part by part, though it gets a bit jumbled for me to track and follow along, and I haven't learned the (I wish I knew what to call it...) "Script scripting", all the iteration and item calling-checking, stuff... my biggest problem is just my brain has troubled to think-know all the "bits" that are needed to do something, like with the various spells, equipment, and combat systems. when I see it, I can understand it, but I can't come up with it on my own, "oh, I need to do this function, which then implements this function, which needs this part of it defined in another function...I need to make these expressions, turn on these flags and or booleans" and etc.

I was just sort of impressed with being able to come up with a combat structure-sequence, so I was just happy and joking, if anyone wants to take it, code it, then let us enjoy that code. HK goes through many mood swings, if he gets something, no matter how small it is, he feels so triumphant, but then if he fails to create a spell, equipment, or combat system on his own, he gets depressed. laughs. Actually, I'd rather not to get such total help, as I'd like to learn, so that I can do it on my own. I think that I may be able to code my combat sequence, one day, after I learn all this boring coding stuff that I need to be able to code these various systems, like of combat, or whatever other common rpg game mechanics.

anyways, I know what I need to do next, but it's boring (HK wants to be able to learn to make all these systems right now so he can then go make a game, lol, but he can't do that, not even close), I need to go and just get familar with all the different scripts, understanding them, along with understanding how they are used and able to follow along more clearly with each part by part of your libraries. I need to learn all this parameter and line-script-item stuff of like ~ "foreach (x, 1, item, _elem)".

---------

just ignore all my commentary, I'm just a noob trying to slowly learn to code enough of this stuff (which is advanced for me) to have the ability to make a decently normal rpg game, hehe. I'm too eager to make a game, I got to learn the more boring of the coding stuff first, before I can do the cool stuff of making systems, which can then allow me to make my own rpg game.

HegemonKhan
I think I can do this, setting up my combat sequence~system, as I've got some concrete ideas of how to do it, the details may take awhile though for me to figure out, if it's as complex (or even worse; more complex than) as Pertex' Combat Library, lol.
Details as in its scripting. But, I really think I've got some ideas that will work for their purposes, and that I would be able to code as well. I'll have to play around with it tomarrow (as it is midnight here and I'm sleepy), but here's a not quite complete set up for my playing-testing-working on setting up my combat sequence~system, or at least it's "skeleton" anyways, as the "details", the actual script blocks on the combat stuff, will likely take me awhile to learn, if it's anything like Pertex' Lib.

so, here it is (the other noobs may appreciate this too), but remember that there's still a few more things I need to add to it before its ready for my combat testing with it (I'll post my updated final version of just this foundation game code tomarrow):

[I need to rework the "cc" (cc = character creation) function, as the stat values I gave are horrible (I just wanted to get the script block done), I'll need to get better values in, when I actually get working~playing~testing with creating my combat script calculations, obviously]

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
</object>
<turnscript name="player_game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
player.turns = player.turns + 1
</script>
</turnscript>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">0</cur_mp>
<max_mp type="int">0</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<inherit name="surface" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
switch (player.gender) {
case ("male") {
player.cur_hp = player.cur_hp + 30
player.max_hp = player.max_hp + 30
player.str = player.str + 30
player.end = player.end + 30
player.int = player.int + 30
player.spi = player.spi + 30
}
case ("female") {
player.cur_mp = player.cur_mp + 30
player.max_mp = player.max_mp + 30
player.dex = player.dex + 30
player.agi = player.agi + 30
player.spd = player.spd + 30
player.men = player.men + 30
}
}
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
player.race = result
switch (player.race) {
case ("human") {
player.cur_hp = player.cur_hp + 20
player.max_hp = player.max_hp + 20
player.cur_mp = player.cur_mp + 20
player.max_mp = player.max_mp + 20
player.str = player.str + 20
player.end = player.end + 20
player.dex = player.dex + 20
player.agi = player.agi + 20
player.spd = player.spd + 20
player.int = player.int + 20
player.spi = player.spi + 20
player.men = player.men + 20
}
case ("dwarf") {
player.cur_hp = player.cur_hp + 30
player.max_hp = player.max_hp + 30
player.cur_mp = player.cur_mp + 10
player.max_mp = player.max_mp + 10
player.str = player.str + 30
player.end = player.end + 30
player.dex = player.dex + 10
player.agi = player.agi + 10
player.spd = player.spd + 10
player.int = player.int + 10
player.spi = player.spi + 10
player.men = player.men + 10
}
case ("elf") {
player.cur_hp = player.cur_hp + 10
player.max_hp = player.max_hp + 10
player.cur_mp = player.cur_mp + 30
player.max_mp = player.max_mp + 30
player.str = player.str + 10
player.end = player.end + 10
player.dex = player.dex + 30
player.agi = player.agi + 30
player.spd = player.spd + 30
player.int = player.int + 30
player.spi = player.spi + 30
player.men = player.men + 30
}
}
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
switch (player.class) {
case ("warrior") {
player.cur_hp = player.cur_hp + 30
player.max_hp = player.max_hp + 30
player.str = player.str + 30
player.end = player.end + 30
player.dex = player.dex + 30
player.agi = player.agi + 20
player.spd = player.spd + 20
}
case ("cleric") {
player.cur_hp = player.cur_hp + 10
player.max_hp = player.max_hp + 10
player.cur_mp = player.cur_mp + 30
player.max_mp = player.max_mp + 30
player.agi = player.agi + 10
player.spd = player.spd + 10
player.spi = player.spi + 30
player.men = player.men + 30
}
case ("mage") {
player.cur_mp = player.cur_mp + 30
player.max_mp = player.max_mp + 30
player.agi = player.agi + 10
player.spd = player.spd + 10
player.int = player.int + 30
player.men = player.men + 30
}
case ("thief") {
player.cur_hp = player.cur_hp + 20
player.max_hp = player.max_hp + 20
player.str = player.str + 10
player.end = player.end + 10
player.dex = player.dex + 30
player.agi = player.agi + 30
player.spd = player.spd + 30
}
}
msg (player.alias + " is a " + player.gender + " " + player.race + " " + player.class + ".")
msg ("")
msg ("(Press a key to continue)")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
player.hp = player.cur_hp + " / " + player.max_hp
player.mp = player.cur_mp + " / " + player.max_mp
</function>
<function name="game_over">
if (player.cur_hp = 0) {
msg (player.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (player.exp >= player.lvl * 100 + 100) {
player.exp = player.exp - (player.lvl * 100 + 100)
player.lvl = player.lvl + 1
}
]]></function>
</asl>


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

P.S.

I'm a bit confused on the container types (base_container, container, open_container, closed_container, and surface), I know (read) about them on the wiki, but I'm still a bit confused.

is "container" a (or like a) boolean (with its properties as core-internal quest data) ??? what are its properies ???

what is the "base_Container", what are its properties ???

what exactly is the "surface", what are its properies ??? (is the "surface" effected by whether I also have "container" or not ??)

as I'm not sure what a "container" vs "base_container" is (and atm I forgot which inherits which too, lol)

--

the reason I'm asking is that the attributes look a bit weird-wrong (in my game code above). is the container tab effected by my setting of the container types as inherited properties from new object types (as it still shows, "Not A Container" as its tab's control type's dropdowntypes' types' option-choice), does it matter what the container tab says, and-or do I have my container types wrong on my new object types? (or is the object types, the problem due to localness?). It still lets me place an object as the child though of my "orc" object.

---

also, I'm thinking that I may want to make all my npcs as surface (or open) containers, as I'm sure objects can be coded with equipment too. this would also enable stealing of it, such as is implemented in the TES games (Morrowind, Oblivion, Skyrim), if I remember-got correctly lol, being able to steal their weapons or armors. My interest is to create as open a game as them, as is possible with Quest, as a text adeventure, anyways.

Pertex
You can find the container types in CoreTypes.aslx in the Questdirectory/core (open it with a texteditor). There you can see all container types.

npcs as container? Why? Even normal object can "carry" objects

HegemonKhan
err... if all objects can "carry" other objects... than I guess I don't need to make the npcs as containers, lol. But, then what's the point of the container types? I'm confused... now, laughs.

(Are container types, merely for implementing open~openable and close~closeable? what then is the point of the surface type? is it merely to deal with the scope?)

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

I just want my npcs to be able to have objects on them for stealing (their items and even their equipped equipment) and for equipment (so they can wear equipment too).

I'm debating of whether to have my npcs with separate (different selection of items) "drop (upon kill, when dead) items" and "stolen (upon steal, when alive) items", joined (same selection of items, or to just have only the "stolen items". (Or, maybe I'll do both "drop items" and "stolen items" with the "stolen items" yielding unique items and-or equipment).

---------

I'm right now, in the difficult attempt of creating the game mechanics equations, then I'll try to code a battle sequence, lol.

I've just created one equation so far, which I'm relatively happy with:

player weapon damage = [player weapon physical damage + player weapon physical damage (player strength / 100) - target armor class (target endurance / 100) + player weapon elemental damage - target armor elemental resistance*] x2 for a Critical Hit**

*I still need to work in the vulnerability, immunity, absorption, or reflection

**Critical Hit = RandomChance [ReturnInt (player luck)]

max hit points = 999
max mana points = 999
max weapon physical damage = 100
max strength = 100
max armor class = 100
max endurance = 100
max weapon elemental damage = 50 (25 x 2 due to elemental vulnerability of target)
max luck = 100
resistance = 1/2 damage
vulnerability = 4/2 damage
immunity = 0/2 damage
absorption = increased (hit or mana ~ not sure which I want to do) points instead of receiving damage (decreased hit points)
reflection = 1/2 damage, but it is returned upon the attacker for unprevented damage; the initial defender takes no damage
critical hit = 4/2 damage

this yields the damage range of:

500 = [100 + 100 (100 / 100) - 0 (0 / 100) + 25(2)] x2
250 = [100 + 100 (100 / 100) - 0 (0 / 100) + 25(2)]
200 = [100 + 100 (100 / 100) - 0 (0 / 100) + 0]
100 = [100 + 100 (100 / 100) - 100 (100 / 100) + 0]
0 = [100 + 100 (0 / 100) -100 (100 / 100) + 0]
0 = -100*** = [0 + 0 (0 / 100) - 100 (100 / 100) + 0]

***I might keep this, causing 100 damage to the attacker, or not, hmm...

and my magical damage equations will be similar too, just replace strength with Intelligence or Spirituality~Piety and endurance with mentality.

Pertex
HegemonKhan wrote:
(Are container types, merely for implementing open~openable and close~closeable? what then is the point of the surface type? is it merely to deal with the scope?)

That's it. And it's a matter of visibility of objects in container. A surface displays the following in the room description:
You can see a table (on which there is an apple).


And objects in normal objects can only be accessed with a script.

HegemonKhan
.
@Pertex, (and~or if anyone else wants to chime in about a combat system, please do so!)

If I may inquire about your combat library, I've got a few questions to ask of you.

A little background first though. I think that I almost understand the general idea of it, at least the basic skeleton structure of creating a combat system. Though, I'm a bit confused about a few things with what you're doing in your combat library. I want to create my own combat system, but 1st I need to learn how to go about it, so I've been trying to understand yours, as I can't find any other peoples' works on combat for me to look at. Pixie does has a part on combat in his-her spell library, but it deals with using attack~damage spells, and so it's quite different from your physical~weapon combat system in your library.

so, let me take a stab at seeing how well I hope I am understanding of a combat system and what you're doing in your library, and then I'll ask my questions about the parts I'm confused with, so that way, you can see where I'm stuck and~or confused, in understanding a (and yours specifically too) combat system in its general structure, as well as my specific questions on parts of it, of your library. so... here it~I go...

(actually, I ask my questions first, and then give what I hope is the correct general structure of a combat system afterwards at the end~bottom of this post, sorry about the change up of order from what I said in the above paragraph!)

----------

1A. I'm unsure whether only the monsters inherit this object type, 'cmb_fighter', if only the player inherits this object type, 'cmb_fighter', or if both player and monsters inherit this object type, 'cmb_fighter'

1B. as, there's also the object, 'cmb_intern', too, which I'm unsure with the 'cmb_attribs' of it, if that's only used for the player or for the monsters or for both player and monsters.

2. first, there's: 'cmb_chkObject' and 'cmb_chkFighter' functions

what are these or what do they do? I think I uderstand correctly that they get the equipment and~or the two battling objects (player and~or monster), but I'm unsure what~which does what~which.

'cmb_chkObject' :

player's equipment?
monster's equipment?
player's and monster's equipment?
the player?
the monster?
the player and the monster?
the player and the player's equipment?
the monster and the monster's equipment?
the player, player's equipment, the monster, and the monster's equipment?

'cmb_chkFighter' :

player's equipment?
monster's equipment?
player's and monster's equipment?
the player?
the monster?
the player and the monster?
the player and the player's equipment?
the monster and the monster's equipment?
the player, player's equipment, the monster, and the monster's equipment?

3. I finally found possibly where 'cmb_object' and 'getObject' gets defined, which is in 'cmb_equip'

does 'cmb_object' only refer to the equipment objects in your inventory, or just the monsters' inventories, or both player's and monsters' inventories, or does 'cmb_object' also refer to the monsters themselves and~or even the player too?

4. I still can't find where or how the 'target' gets defined (or is this a code? but I type it in to the wiki search and I get no page on it), though I've found something on it in the 'cmb_loot', but this doesn't deal with the 'cmb_fight' nor 'cmb_attack', sighs.
As 'target', 'targetname', and 'target.name' gets used in 'cmb_attack' (and only 'target' and 'target.name') is used in 'cmb_fight'

as there's the 'target' and 'object', especial in the 'cmb_attack', with the 'target=player -> dead -> game over' and 'object=player -> dead -> game over', so how or where does the 'target' and 'object'get defined between defining the player as 'target=player and as 'object=player' ??? And this is also as "vs" the monster being killed within the same script block of 'cmb_attack'

'target' :

player?
monster?
player and~or monster?

'object' :

player?
monster?
player and~or monster?
player equipment?
monster equipment?
player and player equipment?
monster and monster equipment?
player, player equipment, monster, and~or monster equipment?

as I'm confused with... 'cmb_fight' and 'cmb_attack' .. due to mainly #'s 2 and 4, and see below

5. so we got the command, 'attack', which calls upon the function, 'cmb_attack', based upon the player's (user's) text input.

so the 'cmb_attack' is the battle system, between the player and the monster, so its mostly just, "is monster here?", "what monster?", "is player here?", "is monster dead?", "is monster reachable~attackable", "monster has died", and "player is dead ~ game over". However, ther's this part of the 'cmb_attack' that seems to have a portion of the fight sequence:

	} else if(cmb_chkObject(object) and cmb_chkObject(target)){
if (cmb_fight(object, target)) {
if (cmb_getAttrib(target,"cmb_hp")>0) {
msg( target.name + " hits back.")
cmb_fight(target,object)
if (cmb_getAttrib(object,"cmb_hp")>0) {
msg("")


which means that the 'cmb_fight' isn't the sole nor entire battle sequence function.

[HK Edit: ooo, I was jsut looking at this, the code above, and I think I correctly realize that this is how fight turns are done: player does the fight sequence via the 'cmb_fight' , and then monster does the fight sequence via the 'cmb_fight', which is what this code does, YEAH! YEAH! I hope, laughs]

---

which then gets us to the: 'cmb_fight', as the main battle sequence function:

this sets up the attack, 'vattack', and the defend/parry/parade, 'vparade', but I presume this is for both the player and monster, enabling the player to be on 'vparade' and 'vattack' and the monster to be on 'vattack' and 'vparade', but how is this done, as I can't see how or where, the player and monster gets defined as 'target' and~or 'object', as well as in relation to what the 'cmb_chkObject' and 'cmb_chkFighter' are exactly doing as well, sighs.

6. there's a lot of booleans used with return values. I presume that these, the 'handled', not handled', 'false', and 'true' are used to tell whether the function has been done~completed (such as with "the battle is over") and~or to utilize it in another function.

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

so the general format/structure/system for (physical) combat seems to be:

command attack (calls the battle system fo player vs monster) based upon what the player (user) types in as input

the attack function (the battle system) has to then check that indeed the player's input is that of a monster that can be attacked, as well as checking for the player, the player's equipment, and~also the monster's equipment, so it can actually then get all of these things, in order to actually carry out the function, the battle.

However, a battle system, needs the actual fight sequence function, lol.

so we've got a fight sequence function, which just like the attack function, has to check and get the player, monster, player's equipment, and~or the monsters equipment. But, being that its the fight sequence function, it also has to set up the attributes of the fight, like the attack and defend values, as well as to set up how the player and monster actually fights each other, and lose hps based off of it, both for the player and monster, the player has to be set up to attack, defend, and lose hp, and so does the monster have to be set up to attack, defend, and lose hp.

However, as seems to be the case in Pertex' library (if I understand it correctly), part of this fight sequence may be done within the attack function too, but I'm not sure what is exactly going on with it and~or how it is done or how it works.

lastly, for all parts of this entire process of it all, booleans, ints, handles, values, trues, and falses needs to be set up as the various functions' returns, in order for the game engine to know whether it has been done~completeed or not yet.

is this the general structure~system of creating a combat system?

Pertex
HegemonKhan wrote:
is this the general structure~system of creating a combat system?


No, this is the structure of MY combat system. Perhaps your system will look totally different. Let me tell it this way: if I get the task to inform you about something I can send an email or snailmail, phone you, write it in the forum or other ways. I can choose how to do it, the main point is, that you get the information.

HegemonKhan wrote:
1B. as, there's also the object, 'cmb_intern'

This is not a room, player or monster object, it's just a data object to store global and not changing attributes while the game is running

HegemonKhan wrote:
1B. as, there's also the object, 'cmb_intern'

This is the type for all fighting objects like player or monsters, they have the same attributes so you only need one type for them.

HegemonKhan wrote:
2. first, there's: 'cmb_chkObject' and 'cmb_chkFighter' functions


cmb_chkObject is a simple function to check if the parameter of a function is an existing object. Hmm, now checking the lib again, I find that this function is partially unnecessary and partially bad written :-)

cmb_chkFighter is a function to check if the named object is a fighter, so both, player and the monster

HegemonKhan wrote:
3. I finally found possibly where 'cmb_object'

cmb_object is a temporary variable used in different functions. After leaving the function it is reseted again.

HegemonKhan wrote:
4. I still can't find where or how the 'target' gets defined

target and object are defined in the parameterlist of the function:


<function name="cmb_attack" parameters="object, targetname" type="boolean">


If this function is called elsewhere in the lib or the game file for example like

cmb_attack (player, "orc")

and the program steps into this function, it "maps" player to the parameter variable object and "orc" to the parameter variable targetname. So in the function you can work with object which contains the player object and with targetname, which cantains the string "orc".
And with

target= getObject(targetname)

it tries to find an object with the name "orc". If it found one object it is saved in the local variable target.

5. seemed to be clear now?

6. yes

Rest:
If you type "attack troll", the function cmb_attack (player, "troll") is called. In this function it's first checked if the input and the targetobject are correct. Then the fighting routine cmb_fight is called first with player as attacker ond troll as defender. If this is done the fighting routine cmb_fight is called a second time. This time the troll re-attacks the player. After this and checking if one of the fighter is dead, the function is finished. Now you can type "attack troll" again to start the next round of the battle

HegemonKhan
[HK Edit: your library is so clear and easy now!, now that I understand how parameters work, lol. thank you!]

ah, thank you very much! I think I get it now! I was mainly stuck up on trying to understand how the command's parameters connected to the functions parameters, as the parameters was something that was still confusing me a lot, which I was about to ask about next, but you've answered it just now, hehe. I just need to hopefully make sense and understand the parameters use fully now... hopefully, lol. I never realized that the parameters acted like a sort of "placeholder" between parameters, of the left side of the comma and the right side of the comma. So, I was trying to figure out the wrong thing, in how the command could go from parameters (player , text) to the function's parameters of (object , targetname). I was looking for and wondering why there wasn't a 'targetname = text' or something like this, and then also trying to figure out how or where you had connected player=object or player=target and monster=object or monster=target.

I don't like bugging you guys-girls, but I was stuck on trying to understand the only example of a combat system, yours-Pertex, for like ~3 days, and had given up trying to understand it on my own, and nor was I able to figure out a way to create my own combat system all on my own, as I didn't understand enough about coding to do so, I probably still won't, but at least now, I think I should, hopefully, be able to understand better about functions, commands, and their parameters, to hopefully now be able to at least try to come up with a combat system on my own, regardless of whether or not it fails, as that would be a step forward for me, in of itself.

Unfortunately, I'm not able to just fumble around entirely on my own, in trying to create something on my own. I'm not that smart, sighs. It'd be like trying to create a boat, without ever seeing what a boat looks like, for me. Thus, by understanding Pertex' Library, I'd have at least a general idea, of a way of making a combat system, and then hopefully, with that I can then try to create my own, not something entirely different, but hopefully something different enough, that I could call my own, at least to a small degree. I hope as I understand more coding that it'll help me towards being able to code things entirely on my own and own created designs~structures~formats etc.

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

P.S.

a real quick question about commands, as I still am just slighly confused with them:

is there any difference between:

(code from Pertex' library)

<command name="attack">
<pattern>attack #text#</pattern>
<script>
cmb_attack (player, text)
</script>
</command>


and

<command name="attack">
<pattern>attack #object#</pattern>
<script>
cmb_attack (player, object)
</script>
</command>


(or is it suppose to be: )

<command name="attack">
<pattern>attack #object#</pattern>
<script>
cmb_attack (player, text)
</script>
</command>


(or can it be ? : )

<command name="attack">
<pattern>attack #text#</pattern>
<script>
cmb_attack (player, object)
</script>
</command>

Pertex
The last 2 examples doesn't make sense.
#object# in the pattern gives you an object variable named object for the use in the script, #text# in the pattern gives you a string variable text in the script. So if you use attack #object# and you type in an object that does not exist, you get the message "I can't see that".
If you use attack #text#, no message appears and you can check the text by script if there is a object with this name. if not you can exit your own message or do something else.

HegemonKhan
aight, thanks, again. I wasn't clear on how the pattern worked and when in regards to the parameters. I understand now.

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

here's my "work in progress" rough draft so far, using Pertex' Combat Library as a guide:

<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (player , text)
</script>
</command>

<function name="battle_system" parameters="protagonist , text_input" type="boolean">
return_value = false
enemy = GetObject (text_input)
if (enemy = null) {
msg ("There is no " + enemy.alias + " here.")
return_value = false
} else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value = false
} else if (GetBoolean (enemy , "dead")) {
msg ("enemy.alias + " is already dead".")
return_value = false
} else if (not DoesInherit (enemy , npc_char)) {
msg ("You can not battle that!")
return_value = false
} else if (GetBoolean (enemy , hostile) = false) {
msg ("enemy.alias + " is not hostile".")
return_value = false
} else if (char_exists (protagonist) and char_exists (enemy)){

(under construction)
if (battle_sequence (attacker , defender)) {
if (???function needs to be created??? (defender , "cur_hp") > 0) {
msg (defender.alias + " fights back.")
battle_sequence (defender , attacker)
if (???function needs to be created??? (attacker , "cmb_hp") > 0) {
msg ("")
} else {
if (attacker = player) {
msg ("You have been killed.")
msg ("GAME OVER")
finish
} else {
msg (defender.name + " is killed.")
SetObjectFlagOn (defender , "dead")
defender.alias = GetDisplayAlias (defender) + " (dead)"
cmb_addexp(target)
if (DictionaryContains(target.cmb_script, "killed")) {
invoke (ScriptDictionaryItem(target.cmb_script, "killed"))
}
}
}
} else {
if (target=player){
msg( "A last strike hits you. You are dying.")
msg( "GAME OVER")
finish
} else {
msg( target.name + " dies.")
SetObjectFlagOn (target, "dead")
target.alias = GetDisplayAlias (target) +" (dead)"
cmb_addexp(target)
if (DictionaryContains(target.cmb_script, "killed")) {
invoke (ScriptDictionaryItem(target.cmb_script, "killed"))
}
}
}
} else {
msg("Why do you want to do this?")
}
returnvalue=true
}
return (returnvalue)

</function>

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">

(under construction)
vattack=0
vparade=0
if (cmb_chkFighter(object) and cmb_chkFighter(target)){
for (x ,1, cmb_getAttrib(object,"cmb_at")) {
vattack = vattack + cmb_dicesix()
}
for (x ,1 ,cmb_getAttrib(target,"cmb_pa")) {
vparade = vparade + cmb_dicesix()
}
msg("at: " + ToString(vattack) + ", pa: "+ToString(vparade))
if (vattack > vparade) {
damage=cmb_dice(object.cmb_str) + cmb_dice(vattack-vparade)
cmb_decAttrib (target, "cmb_hp", damage)
msg(object.name + " hits " + target.name + " for " + damage + " points.")
} else {
msg (object.name + " misses.")
}
return (true)
} else {
return (false)
}

</function>

<function name="npc_reachable" parameters="object" type="boolean">
value=false
foreach (x , ScopeReachableNotHeld ()) {
if (x = object) {
value=true
}
}
return (value)
</function>

<function name="char_exists" parameters="object" type="boolean">
value = false
foreach (x , AllObjects ()) {
if (object = x) {
value = true
}
}
return (value)
</function>

<function name="combat_player_critical_hit"><![CDATA[
player.critical_hit = RandomChance (GetInt (player , luck))
]]></function>

hostility idea:

npcs have an "anger" attribute value
if ("anger" >= 50) {
SetObjectFlagOn (npc_char_object , "hostile")
}

<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
</object>
<turnscript name="player_game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
player.turns = player.turns + 1
</script>
</turnscript>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<inherit name="surface" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
<"anger" type="int">0</"anger">
<script>
if ("anger" >= 50) {
SetObjectFlagOn (this , "hostile")
}
</script>
</type>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + player.gender + " " + player.race + " " + player.class + ".")
msg ("")
msg ("(Press a key to continue)")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
player.hp = player.cur_hp + " / " + player.max_hp
player.mp = player.cur_mp + " / " + player.max_mp
</function>
<function name="game_over">
if (player.cur_hp = 0) {
msg (player.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (player.exp >= player.lvl * 100 + 100) {
player.exp = player.exp - (player.lvl * 100 + 100)
player.lvl = player.lvl + 1
lvlup
}
]]></function>
</asl>

HegemonKhan
it took me awhile to trouble shoot my messed up syntax, argh, always syntax... lol

----------

anyways, I have a quick question that came up:

how do I adjust the attack command and attack function codes to get it to work with an object that uses an alias?

I set the orc object as:

name = orc1
alias = orc

I've been trying, but can't find a way to do it. I tried quite a few combinations, so I've given up, I just can't figure it out.

the problem is with the first check ' if (enemy=null) { ' as it doesn't recognize that the object (alias) orc is the object (name) orc1 when you use the GUI's hyperlinks to do the attack command, which can be seen by it outputing the message ' There is no " + target + " here '

though, if you type in the command ' fight orc1 ' then it works correctly, giving you the message ' enemy.name + " is not hostile '

[ for fun, learning, and curiousity, I tried ' fight player ' which gives the message ' There is no " + enemy.name + " in your vicinity ' , as it can't find the player object in the places pane, hehe) ]

(the game code below, needs to be adjusted by giving the orc object an alias and then the subsequent coding needs to be changed from ' name to alias ' , as this is the original game code, which works, as it doesn't have the orc object having an alias)

This utilizes Pertex' Library combat system structure, with me trying to make my own system as unique as I can do so in my current coding knowledge ability. I can't make my own structures on my own yet, I don't understand coding well enough to think of ways to structure the coding on my own. But, I'm trying to work towards that, just got a long ways of learning to go, laughs.

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
</object>
<object name="orc">
<inherit name="editor_object" />
<inherit name="npc_char" />
</object>
</object>
<turnscript name="player_game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
player.turns = player.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (player, text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + player.gender + " " + player.race + " " + player.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
player.hp = player.cur_hp + " / " + player.max_hp
player.mp = player.cur_mp + " / " + player.max_mp
</function>
<function name="game_over">
if (player.cur_hp = 0) {
msg (player.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup">
if (player.exp >= player.lvl * 100 + 100) {
player.exp = player.exp - (player.lvl * 100 + 100)
player.lvl = player.lvl + 1
lvlup
}
</function>
<function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value=false
} else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.name + " in your vicinity.")
return_value=false
} else if (GetBoolean (enemy , "dead")) {
msg (enemy.name + " is already dead.")
return_value=false
} else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value=false
} else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.name + " is not hostile.")
return_value=false
}
</function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x, ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
</asl>


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

@ Pertex: and one other question too:

are these functions neccessary (as I don't fully understand their purpose nor your combat system in its entirety yet, so I mainly just don't understand why they are needed, as I'm not sure what they do or accomplish, as surely they're probably are needed)? :

I'm bolding the functions or the parts that I'm asking about

from Pertex' Combat Library:

chkObject
chkFighter*

<function name="cmb_attack" parameters="object, targetname" type="boolean">
} else if(cmb_chkObject(object) and cmb_chkObject(target)){

<function name="cmb_fight" parameters="object, target" type="boolean">
if (cmb_chkFighter(object) and cmb_chkFighter(target)){

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

P.S.

*I know this is needed for the cmb_attack, I myself already know (and thus have it) it needs to be utilized in my own coding:

<function name="battle_system" parameters="protagonist , target" type="boolean">
} else if (not Doesinherit (enemy , "npc_char")) {

but is it needed in~for these spots:

<function name="cmb_attack" parameters="object, targetname" type="boolean">
} else if(cmb_chkObject(object) and cmb_chkObject(target)){

<function name="cmb_fight" parameters="object, target" type="boolean">
if (cmb_chkFighter(object) and cmb_chkFighter(target)){

Pertex
You could extend the function battle_system like this:

    <function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
Foreach (obj, AllObjects()){
if (obj.alias=target) {
enemy=obj
}
}
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value=false
...


Second point: If you don't know if something is necessary, then remove it! You will notice missing things when you are testing your library

HegemonKhan
thanks!

(and ya, I'll test it, lol - sorry for asking this question, but I was just looking at it via the code, and couldn't understand what it was for, and thus if I would need to use it or not, without having done the physical testing of it, so let me do that, and if I don't understand still of why it is needed, if it is needed, then I'll come back and ask if it could be explained to me, hopefully)

--------

BUT,

I'm having a bit of trouble following the code for using an alias, if you could help me through what is going on with it, I'd be appreciative, as I guess I'm still having a bit of trouble with understanding parameters and~or the basic code algebra, arg!

this is my attempt at understanding (comprehending) what is going on with the code:

name = orc1
alias = orc

command/GUI_hyperlink: fight orc

command fight #text#

orc -> text

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

<function name="battle_system" parameters="protagonist , target" type="boolean">

text -> target

(orc = target)

enemy = GetObject (target)

enemy = GetObject (orc)

enemy = orc1

------

enemy = orc1, but orc1 doesn't exist on the places pane, only orc exists on the places pane,
therefore: enemy = null

-----

if (enemy = null) {

okay, enemy = null, so we then check:

Foreach (obj, AllObjects()){
if (obj.alias=target) {

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

[ if (orc1.alias=orc) ]
[ if (orc=orc) ]

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

if yes, then:

(obj = orc1)

enemy=obj

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

so, now it's:

enemy = orc1 (from GetObject (orc))

obj = orc1 (from GetObject (orc))

orc1 = orc1 (from GetObject (orc))

therefore: enemy is not = null

-------

if (enemy = null) {
msg ("There is no " + target + " here.")

"otherwise, there's no such object for the enemy to be defined as that, and so enemy = null, and the message is sent"

Pertex
HegemonKhan wrote:
<function name="battle_system" parameters="protagonist , target" type="boolean">

text -> target

(orc = target)

enemy = GetObject (target)

enemy = GetObject (orc)

enemy = orc1


No, enemy is null. GetObject (orc) where orc is the alias will return no value

HegemonKhan
okay and thank you!

as I had thought the orc was being given as the object itself, I didn't know the game identified the "orc" as just an "alias", so I didn't recognize the the inconsistency/incongruency of: (and thus now I understand why it doesn't work:) GetObject (Alias=orc): object =/= alias,

**(wait, then how does orc1 work? is a "name" an~the identifier of the object ??, but just not the alias now obviously)

--------

but, then how is this now working? :

Foreach (obj, AllObjects()){
if (obj.alias=target) {
enemy=obj

is the enemy = orc or orc1 as the obj ?

and does this, enemy=obj, need to be connected to the target, or is the enemy=obj merely a "set attribute or variable", as just an alternative attempt to the prior attempt of, enemy = GetObject (target) ??

sorry for being so slow, but I'm having trouble understanding this code logic, my brain hasn't quite caught on to how to think about this stuff correctly, sighs.

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

could GetObject be replaced with GetAttribute (target, alias) or GetDisplayAlias (target), or does it have to be getting an object (GetObject) for use in the rest of the combat codings ???

HegemonKhan
here's my updated progress of my still in-progress (incompleted; under construction) draft on my combat system:

Could I get some feedback and review of it?, if this can work or if it's completely wrong, and etc comments, and~or ideas too!

(I have a few questions with the nested functions, such as can I use the return_value of the battle_system function within the protagonist_battle turn function, such as in regards to enemy.cur_hp <= 0, and other like~similar questions as this question)

<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov , text)
</script>
</command>

<function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
foreach (obj, AllObjects()){
if (obj.alias=target) {
enemy=obj
}
}
}
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value=false
} else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value=false
} else if (GetBoolean (enemy , "dead")) {
msg (enemy.alias + " is already dead.")
return_value=false
} else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value=false
} else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value=false

} else if (char_exists (protagonist) and char_exists (enemy)) {
if (battle_sequence (protagonist , enemy)) {
if (GetInt (enemy , "cur_hp") > 0) {
msg (enemy.alias + " fights back.")
battle_sequence (enemy , protagonist)
if (GetInt (protagonist , "cmb_hp") > 0) {
msg ("")
} else {
if (protagonist = game.pov) {
game_over
} else {
msg (enemy.alias + " is killed.")
SetObjectFlagOn (enemy , "dead")
enemy.alias = GetDisplayAlias (enemy) + " (dead)"
cmb_addexp (enemy)
if (DictionaryContains (enemy.cmb_script, "killed")) {
invoke (ScriptDictionaryItem (enemy.cmb_script, "killed"))
}
}
}
} else {
if (protagonist=player) {
game_over
} else {
msg (enemy.alias + " is killed.")
SetObjectFlagOn (enemy, "dead")
enemy.alias = GetDisplayAlias (enemy) +" (dead)"
cmb_addexp (enemy)
if (DictionaryContains (enemy.cmb_script, "killed")) {
invoke (ScriptDictionaryItem (enemy.cmb_script, "killed"))
}
}
}
} else {
msg("Why do you want to do this?")
}
return_value=true
}
return (return_value)
</function>

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">
if (char_exists (protagonist) and char_exists (enemy)) {
if (GetInt (protagonist , spd) > GetInt (enemy , spd)) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else if (GetInt (protagonist , spd) = GetInt (enemy , spd)) {
if (RandomChance (50) = true) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
} else if (GetInt (protagonist , spd) < GetInt (enemy , spd)) {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
}
battle_sequence
</function>

<function name="npc_reachable" parameters="object" type="boolean">
value=false
foreach (x , ScopeReachableNotHeld ()) {
if (x=object) {
value=true
}
}
return (value)
</function>

<function name="char_exists" parameters="object" type="boolean">
value = false
foreach (x , AllObjects ()) {
if (object=x) {
value = true
}
}
return (value)
</function>

<function name="protagonist_battle_turn">
show menu ("What is your battle choice?" , split ("Attack;Cast;Item;Run" , ";") , false) {
switch (result) {
case ("Attack") {
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy , "cur_hp") > 0) {
if (RandomChance (GetInt (protagonist , spd) - GetInt (enemy , spd)) = true) {
msg ("You get an extra turn!")
protagonist_battle_turn
} else {
msg ("Your turn is over.")
}
} else {
msg ("Enemy is dead")
}
</function>

<function name="enemy_battle_turn">
GetRandomInt ( 1 , 2 ) {
switch (result) {
case (1) {
}
case (2) {
}
}
if (RandomChance (GetInt (enemy , spd) - GetInt (protagonist , spd)) = true) {
enemy_battle_turn
}
</function>

<function name="combat_player_critical_hit">
player.critical_hit = RandomChance (GetInt (game.pov , luck))
</function>


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

P.S.

I just spotted someone writing a wiki page on making a combat system, it seems like Pixie wrote it, but I am not entirely sure.
While, my system is based off of Pertex' Combat Library and thus quite a bit different, I may need to use the idea with the weapon type, and~or other parts of it, as they are some neat ideas, but I'm not sure if I'll need to, and~or if I'd even be able to integrate them into my combat system.

here's the link to it: ( http://quest5.net/wiki/Simple_Combat_System_(Advanced) )

But~so, I thought, I'd just give a heads up for others who may not know about it yet, hehe :D

Pertex
Do you have a prototype where you can test your code?

HegemonKhan
I have game files of where I can test it, but I haven't yet, I'm just really brainstorming via coding only, then I'll work out all the probably massive amounts of problems with it, laughs. I'm not in testing mode yet, I'm just trying to get an idea of the combat system down, and then I'll work on seeing if it works at all, and~or trouble shooting the parts with don't. I'm just trying to think of getting down the code structure of combat, and then once I got that, then it's a matter of actually going into the code and testing it, to get it working correctly, or what needs to be changed for it to work correctly.

Are you already seeing huge problems with it? I was hoping to just be on the general right track, but maybe I'm completely off too. So, it'd be good to know, if this can be made to work, or if there's no way that this can be made to work.

-----

though, I don't think I could even really test it, until I've at least got the combat actions filled in, and the handles-true-false-value-checks too. Integrating the combat actions will take a bit of work, such as with "Fight", I'd have to set up the damage, dodge, to hit, block, equipment, and etc. Then, I'd have to figure out how to implement spells for the "Cast". Then, using items for the "Items", and then a way of ending the combat system, for "Run". So, it's be awhile before it can really be ready just to do a testing of it.

Also, much of the code is incompleted, as I copy and pasted your (Pertex') combat library code as a foundation and reference, slowly adjusting it as I need to to match my new coding of it, so it's really not testable yet. For example, you've split the player and monster battle turns via the Attack function, whereas I'm trying to implement that all within the Fight function. But, I'm slowly adjusting and~or removing your code for the Attack function, as to match what I'm doing, but I haven't completed doing so yet, as I've still got a long ways to go. So, again, this really isn't ready for testing, not even priliminary testing. I guess you could just target pieces of it for testing if you want to test it now, but I'll be doing that as well myself, once I get my coding brainstorm done, in order to trouble shoot it. Working with individual pieces only will make the trouble shooting easier, then in trying to trouble shoot the entire code, obviously. I'm jut not at this point yet, as I want to just get some kind of code down first, and then I'll see if it works even at all or not. Then figure out how to adjust it, if it can be adjusted to get it to work.

-----

you can use this as a foundation testing game file, but I haven't transfered (copy and pasted) over from other notepad file that has my worked on code, just yet. So, until I do, you'll have to do it, if you want to check it.

my testing game code:

<!--Saved by Quest 5.3.4762.29157-->
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
</object>
<turnscript name="player_game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
player.turns = player.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (player, text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + player.gender + " " + player.race + " " + player.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
player.hp = player.cur_hp + " / " + player.max_hp
player.mp = player.cur_mp + " / " + player.max_mp
</function>
<function name="game_over">
if (player.cur_hp = 0) {
msg (player.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (player.exp >= player.lvl * 100 + 100) {
player.exp = player.exp - (player.lvl * 100 + 100)
player.lvl = player.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
foreach (obj, AllObjects()){
if (obj.alias=target) {
enemy=obj
}
}
}
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value=false
} else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.name + " in your vicinity.")
return_value=false
} else if (GetBoolean (enemy , "dead")) {
msg (enemy.name + " is already dead.")
return_value=false
} else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value=false
} else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.name + " is not hostile.")
return_value=false
}
</function>

<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x, ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
</asl>


and my additional coding work of the combat system and sequence functions (which I haven't copy and pasted over to the testing game file yet, sorry! I've been working on this new coding stuff, and just hadn't yet copy and pasted it over, currently):

<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov , text)
</script>
</command>

<function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
foreach (obj, AllObjects()){
if (obj.alias=target) {
enemy=obj
}
}
}
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value=false
} else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value=false
} else if (GetBoolean (enemy , "dead")) {
msg (enemy.alias + " is already dead.")
return_value=false
} else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value=false
} else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value=false

} else if (char_exists (protagonist) and char_exists (enemy)) {
if (battle_sequence (protagonist , enemy)) {
if (GetInt (enemy , "cur_hp") > 0) {
msg (enemy.alias + " fights back.")
battle_sequence (enemy , protagonist)
if (GetInt (protagonist , "cmb_hp") > 0) {
msg ("")
} else {
if (protagonist = game.pov) {
game_over
} else {
msg (enemy.alias + " is killed.")
SetObjectFlagOn (enemy , "dead")
enemy.alias = GetDisplayAlias (enemy) + " (dead)"
cmb_addexp (enemy)
if (DictionaryContains (enemy.cmb_script, "killed")) {
invoke (ScriptDictionaryItem (enemy.cmb_script, "killed"))
}
}
}
} else {
if (protagonist=player) {
game_over
} else {
msg (enemy.alias + " is killed.")
SetObjectFlagOn (enemy, "dead")
enemy.alias = GetDisplayAlias (enemy) +" (dead)"
cmb_addexp (enemy)
if (DictionaryContains (enemy.cmb_script, "killed")) {
invoke (ScriptDictionaryItem (enemy.cmb_script, "killed"))
}
}
}
} else {
msg("Why do you want to do this?")
}
return_value=true
}
return (return_value)
</function>

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">
if (char_exists (protagonist) and char_exists (enemy)) {
if (GetInt (protagonist , spd) > GetInt (enemy , spd)) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else if (GetInt (protagonist , spd) = GetInt (enemy , spd)) {
if (RandomChance (50) = true) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
} else if (GetInt (protagonist , spd) < GetInt (enemy , spd)) {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
}
battle_sequence
</function>

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">
vattack=0
vparade=0
if (cmb_chkFighter(object) and cmb_chkFighter(target)){
for (x , 1 , cmb_getAttrib(object,"cmb_at")) {
vattack = vattack + cmb_dicesix()
}
for (x , 1 , cmb_getAttrib(target,"cmb_pa")) {
vparade = vparade + cmb_dicesix()
}
msg("at: " + ToString(vattack) + ", pa: "+ToString(vparade))
if (vattack > vparade) {
damage=cmb_dice(object.cmb_str) + cmb_dice(vattack-vparade)
cmb_decAttrib (target, "cmb_hp", damage)
msg(object.name + " hits " + target.name + " for " + damage + " points.")
} else {
msg (object.name + " misses.")
}
return (true)
} else {
return (false)
}
</function>

<function name="npc_reachable" parameters="object" type="boolean">
value=false
foreach (x , ScopeReachableNotHeld ()) {
if (x=object) {
value=true
}
}
return (value)
</function>

<function name="char_exists" parameters="object" type="boolean">
value = false
foreach (x , AllObjects ()) {
if (object=x) {
value = true
}
}
return (value)
</function>

<function name="protagonist_battle_turn">
show menu ("What is your battle choice?" , split ("Attack;Cast;Item;Run" , ";") , false) {
switch (result) {
case ("Attack") {
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy , "cur_hp") > 0) {
if (RandomChance (GetInt (protagonist , spd) - GetInt (enemy , spd)) = true) {
msg ("You get an extra turn!")
protagonist_battle_turn
} else {
msg ("Your turn is over.")
}
} else {
msg ("Enemy is dead")
}
</function>

<function name="enemy_battle_turn">
GetRandomInt ( 1 , 2 ) {
switch (result) {
case (1) {
}
case (2) {
}
}
if (RandomChance (GetInt (enemy , spd) - GetInt (protagonist , spd)) = true) {
enemy_battle_turn
}
</function>

<function name="combat_player_critical_hit">
player.critical_hit = RandomChance (GetInt (game.pov , luck))
</function>

HegemonKhan
here's the game code for testing with the added coding into it...

<!--Saved by Quest 5.3.4762.29157-->
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
</object>
<turnscript name="player_game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
player.turns = player.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (player, text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men =

;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + player.gender + " " + player.race + " " + player.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
player.hp = player.cur_hp + " / " + player.max_hp
player.mp = player.cur_mp + " / " + player.max_mp
</function>
<function name="game_over">
if (player.cur_hp = 0) {
msg (player.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (player.exp >= player.lvl * 100 + 100) {
player.exp = player.exp - (player.lvl * 100 + 100)
player.lvl = player.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
foreach (obj, AllObjects()){
if (obj.alias=target) {
enemy=obj
}
}
}
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value=false
} else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.name + " in your vicinity.")
return_value=false
} else if (GetBoolean (enemy , "dead")) {
msg (enemy.name + " is already dead.")
return_value=false
} else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value=false
} else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.name + " is not hostile.")
return_value=false
} else if (char_exists (protagonist) and char_exists (enemy)) {
if (battle_sequence (protagonist , enemy)) {
}
}
</function>

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">
if (char_exists (protagonist) and char_exists (enemy)) {
if (GetInt (protagonist , spd) > GetInt (enemy , spd)) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else if (GetInt (protagonist , spd) = GetInt (enemy , spd)) {
if (RandomChance (50) = true) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
} else if (GetInt (protagonist , spd) < GetInt (enemy , spd)) {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
}
battle_sequence
</function>

<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x, ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>

<function name="char_exists" parameters="object" type="boolean">
value = false
foreach (x , AllObjects ()) {
if (object=x) {
value = true
}
}
return (value)
</function>

<function name="protagonist_battle_turn">
show menu ("What is your battle choice?" , split ("Attack;Cast;Item;Run" , ";") , false) {
switch (result) {
case ("Attack") {
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy , "cur_hp") > 0) {
if (RandomChance (GetInt (protagonist , spd) - GetInt (enemy , spd)) = true) {
msg ("You get an extra turn!")
protagonist_battle_turn
} else {
msg ("Your turn is over.")
}
} else {
msg ("Enemy is dead")
}
</function>

<function name="enemy_battle_turn">
GetRandomInt ( 1 , 2 ) {
switch (result) {
case (1) {
}
case (2) {
}
}
}
if (RandomChance (GetInt (enemy , spd) - GetInt (protagonist , spd)) = true) {
enemy_battle_turn
}
</function>

</asl>


HOWEVER,

for some reason it gives an error with this line:

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">

having problems with this:

parameters="protagonist , enemy"

with the:

" mark before protagonist

Error: name can't begin with the " character

and I've no idea why, as it's the same for all other functions, which work, no errors.

I'm guessing it has soemthing to do with the rest of the coding, otherwise this is extremely weird... maybe a bug...

------

if I take out this script block, I get no loading up errors of the game file:

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">
if (char_exists (protagonist) and char_exists (enemy)) {
if (GetInt (protagonist , spd) > GetInt (enemy , spd)) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else if (GetInt (protagonist , spd) = GetInt (enemy , spd)) {
if (RandomChance (50) = true) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
} else {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
} else if (GetInt (protagonist , spd) < GetInt (enemy , spd)) {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
}
battle_sequence
</function>


I've just narrowed it down, it's not the function element line, something is wrong or incomplete with the nexted scripts, maybe I need to set the return values, or maybe it's something else, but it's something to do with the nested script block, and not the function element line.

as the game will load up with out any errors when I remove the nested script block, leaving just this:

<function name="battle_sequence" parameters="protagonist , enemy" type="boolean">
</function>


can someone help me as to what I need to put into or change with the nested script block, to get it to be able to be loaded by the game without errors? As I'm not sure what I need to do to get it to work, as I haven't worked out the code yet as to where I need to put the return values, or if its something else I need, then I don't know what it would be, and thus would need help too.

HegemonKhan
I got it to work, finally, I must have had my formating of it wrong, I went and did~checked it line by line, and got to a line that was having the error, and then I went into the code view script and added in the codes that way, and now it works, so I figure I must not have done the right format syntax of it correctly with the "elses, else ifs, and the proper places of the { 's "

here's the game loadable code:

<!--Saved by Quest 5.3.4762.29157-->
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
</object>
<turnscript name="player_game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
player.turns = player.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (player, text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<turns type="int">0</turns>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + player.gender + " " + player.race + " " + player.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
player.hp = player.cur_hp + " / " + player.max_hp
player.mp = player.cur_mp + " / " + player.max_mp
</function>
<function name="game_over">
if (player.cur_hp = 0) {
msg (player.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (player.exp >= player.lvl * 100 + 100) {
player.exp = player.exp - (player.lvl * 100 + 100)
player.lvl = player.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="protagonist , target" type="boolean">
return_value = false
enemy = GetObject (target)
if (enemy = null) {
foreach (obj, AllObjects()) {
if (obj.alias=target) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + target + " here.")
return_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.name + " in your vicinity.")
return_value = false
}
else if (GetBoolean (enemy , "dead")) {
msg (enemy.name + " is already dead.")
return_value = false
}
else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value = false
}
else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.name + " is not hostile.")
return_value = false
}
else if (char_exists (protagonist) and char_exists (enemy)) {
if (battle_sequence (protagonist , enemy)) {
}
}
</function>
<function name="battle_sequence" parameters="protagonist , enemy" type="boolean"><![CDATA[
if (char_exists (protagonist) and char_exists (enemy)) {
if (GetInt (protagonist , spd) > GetInt (enemy , spd)) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
}
else if (GetInt (protagonist , spd) = GetInt (enemy , spd)) {
if (RandomChance (50) = true) {
protagonist_battle_turn
enemy_battle_turn
battle_sequence
}
else {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
}
else if (GetInt (protagonist , spd) < GetInt (enemy , spd)) {
enemy_battle_turn
protagonist_battle_turn
battle_sequence
}
else {
}
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x, ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="char_exists" parameters="object" type="boolean">
value = false
foreach (x, AllObjects ()) {
if (object=x) {
value = true
}
}
return (value)
</function>
<function name="protagonist_battle_turn"><![CDATA[
show menu ("What is your battle choice?", split ("Attack;Cast;Item;Run" , ";"), false) {
switch (result) {
case ("Attack") {
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy , "cur_hp") > 0) {
if (RandomChance (GetInt (protagonist , spd) - GetInt (enemy , spd)) = true) {
msg ("You get an extra turn!")
protagonist_battle_turn
}
else {
msg ("Your turn is over.")
}
}
else {
msg ("Enemy is dead")
}
]]></function>
<function name="enemy_battle_turn">
GetRandomInt (1, 2) {
switch (result) {
case (1) {
}
case (2) {
}
}
}
if (RandomChance (GetInt (enemy , spd) - GetInt (protagonist , spd)) = true) {
enemy_battle_turn
}
</function>
</asl>


now... I got to test it's actual functioning~execution within the game, lol, ...

need to complete my RandomInt for the seletion of the AI combat_choice-actions of Attack or Cast, meh. I'll get around to it...

I removed the RandomInt, so I could see if I have any other problems, and yep, here's another problem I got:

Error running script: Error compiling expression 'char_exists (protagonist) and char_exists (enemy)': Unknown object or variable 'protagonist'

I haven't yet figured out why (or how to fix it) it has a problem with the "protagonist", as I'm pretty sure I got it set up for the most part the same as Pertex' Combat Library Coding, but obviously not quite, there's something incorrect, missing, or wrong.

----------

P.S.

you have to change the boolean 'hostile' on the object type ' npc_char ' to true, to get past that check in the ' battle_system" function, to get to where my error is with the ' protagonist '

HegemonKhan
.
.
Help, I can't trouble shoot this problem, I need help desparately!

for some reason, I can't get it to recognize the game.pov/player as an attribute/variable, despite Pertex' Combat Library having it set up the same way, with his/her working without the error, whereas mine isn't, grr. Maybe, it's due to the 5.3 's implementation over to the game.pov, and I just don't know how to get it to check/recognize for this object, or maybe it's because it requires the additional/entire coding for it to work. Otherwise, I've no idea why, regardless, I need help with this!

it fails heres, unable to recognize the "selfname/self" (game.pov/player):

<function name="battle_system" parameters="selfname , textname" type"boolean"> (Pertex' Attack Function):
.
..
...
....
.....if (battle_sequence (selfname , enemy)) { (Pertex' Fight Function)
</function>

<function name="battle_sequence" parameters="self , enemy" type="boolean"> (Pertex' Fight Function)

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

here's my code:

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl =

;exp = ;cash = </statusattributes>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov , text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
</type>
<type name="pc_char">
<inherit name="char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men =

;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile />
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="selfname , textname" type="boolean">
return_value = false
enemy = GetObject (textname)
if (enemy = null) {
foreach (obj, AllObjects()) {
if (obj.alias=textname) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + textname + " here.")
return_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value = false
}
else if (GetBoolean (enemy , "dead")) {
msg (enemy.alias + " is already dead.")
return_value = false
}
else if (not Doesinherit (enemy , "npc_char")) {
msg ("You can not battle that!")
return_value = false
}
else if (GetBoolean (enemy , "hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value = false
}
if (battle_sequence (selfname , enemy)) {
return_value = true
}
return (return_value)
</function>
<function name="battle_sequence" parameters="self , enemy" type="boolean"><![CDATA[
if (GetInt (self , spd) > GetInt (enemy , spd)) {
self_battle_turn
enemy_battle_turn
battle_sequence
}
else if (GetInt (self , spd) = GetInt (enemy , spd)) {
if (RandomChance (50) = true) {
self_battle_turn
enemy_battle_turn
battle_sequence
}
else {
enemy_battle_turn
self_battle_turn
battle_sequence
}
}
else if (GetInt (self , spd) < GetInt (enemy , spd)) {
enemy_battle_turn
self_battle_turn
battle_sequence
}
else {
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x, ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="self_battle_turn"><![CDATA[
show menu ("What is your battle choice?", split ("Attack;Cast;Item;Run" , ";"), false) {
switch (result) {
case ("Attack") {
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy , "cur_hp") > 0) {
if (RandomChance (GetInt (self , spd) - GetInt (enemy , spd)) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
}
}
else {
msg (enemy.alias + " is dead.")
}
]]></function>
<function name="enemy_battle_turn">
if (RandomChance (GetInt (enemy , spd) - GetInt (self , spd)) = true) {
enemy_battle_turn
}
</function>
</asl>


and here's Pertex' Combat Library Code:

<library>
<!-- done by Pertex (pertex@gmx.de)-->
<object name="cmb_intern">
<cmb_attribs type="list">CMB_PA;CMB_AT;CMB_STR;CMB_HP;CMB_EXP</cmb_attribs>
<cmb_lvlexp type="stringdictionary">1=50;2=100;3=200;4=400;5=800;6=1500;7=3000</cmb_lvlexp>
<cmb_lvlmod type="stringdictionary">1=at=1,pa=1;2=at=2,hp=100;3=str=4,at=1;4=at=2;5=pa=2;6=at=2;7=at=1</cmb_lvlmod>
</object>

<type name="cmb_equipment">
<cmb_mod type="stringdictionary"/>
<cmb_where type="string"></cmb_where>
<!-- "head", neck", "body", "arms", "rhand", "lhand", "dhand", "legs", "feet" -->
<cmb_activelvl type="int">1</cmb_activelvl>
</type>

<type name="cmb_fighter">
<cmb_at type="int">1</cmb_at>
<cmb_pa type="int">1</cmb_pa>
<cmb_str type="int">1</cmb_str>
<cmb_hp type="int">100</cmb_hp>
<cmb_at_max type="int">1</cmb_at_max>
<cmb_pa_max type="int">1</cmb_pa_max>
<cmb_str_max type="int">1</cmb_str_max>
<cmb_hp_max type="int">100</cmb_hp_max>
<cmb_exp type="int">0</cmb_exp>
<cmb_level type="int">0</cmb_level>
<dead type="boolean">false</dead>
<equiped type="string"></equiped>
<cmb_script type="scriptdictionary">
<item key="killed">
msg("killed")
</item>
</cmb_script>
</type>

<command name="attack">
<pattern>attack #text#</pattern>
<script>
cmb_attack (player, text)
</script>
</command>

<command name="loot">
<pattern>loot #text#</pattern>
<script>
cmb_loot ( trim(text) )
</script>
</command>

<command name="equip">
<pattern>equip #text#</pattern>
<script>
cmb_equip ( trim(text) )
</script>
</command>

<command name="unequip">
<pattern>unequip #text#</pattern>
<script>
cmb_unequip ( trim(text) )
</script>
</command>

<command name="unequipall">
<pattern>unequip all</pattern>
<script>
foreach (x,ScopeInventory () ) {
if (InstrRev ( getString(x, "alias") , "(" )>2) {
cmb_unequip ( getString (x, "name"))
}
}
</script>
</command>

<command name="equiped">
<pattern>equiped</pattern>
<script>
found=false
foreach (x,ScopeInventory () ) {
if (InstrRev ( getString(x, "alias") , "(" )>2) {
text=""
foreach(y,x.cmb_mod ) {
text=concat (text,concat (y,StringDictionaryItem (x.cmb_mod,y),"="),",")
}
msg (x.name+ " - Level " + x.cmb_activelvl + ", modification: "+ text )
found=true
}
}
if (not found) {
msg("You don't have any equiped item.")
}
</script>
</command>

<command name="equipment">
<pattern>equipment</pattern>
<script>
found=false
foreach (x,ScopeInventory () ) {
if (DoesInherit (x, "cmb_equipment")) {
text=""
foreach(y,x.cmb_mod ) {
text=concat (text,concat (y,StringDictionaryItem (x.cmb_mod,y),"="),",")
}
msg (x.name+ " - Level " + x.cmb_activelvl + ", modification: "+ text )
found=true
}
}
if (not found) {
msg("None of your items in your inventory can be equiped.")
}
</script>
</command>

<function name="cmb_addStatus" parameters="attrib">
attrib = cmb_chkAttrib (attrib)
if (GetAttribute ( player , "statusattributes" )=null ) {
player.statusattributes = NewStringDictionary()
}
switch (attrib) {
case ("cmb_hp") {
dictionary add (player.statusattributes, "cmb_hp", "Health: !/"+ player.cmb_hp_max )
}
case ("cmb_at") {
dictionary add (player.statusattributes, "cmb_at", "AT: !" )
}
case ("cmb_pa") {
dictionary add (player.statusattributes, "cmb_pa", "PA: !" )
}
case ("cmb_str") {
dictionary add (player.statusattributes, "cmb_str", "Strength: !" )
}
case ("cmb_level") {
dictionary add (player.statusattributes, "cmb_level", "Level: !" )
}
case ("cmb_exp") {
dictionary add (player.statusattributes, "cmb_exp", "EP: !" )
}
}
</function>

<function name="cmb_refreshStatus" >
saveStatus = NewStringList()
foreach( x , player.statusattributes){
list add(saveStatus, x)
}

player.statusattributes = NewStringDictionary()

foreach( x , saveStatus){
cmb_addStatus (x)
}

</function>


<function name="cmb_setAttrib" parameters="object,attrib,value">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
set(object,attrib,value)
}
}
</function>


<function name="cmb_getAttrib" parameters="object,attrib" type="int">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
return (GetInt(object,attrib))
} else {
return(0)
}
}
</function>

<function name="cmb_incAttrib" parameters="object,attrib,value" type="boolean">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
cmb_setAttrib(object,attrib, cmb_getAttrib(object,attrib) + value)
return (true)
} else {
return (false)
}
} else {
return (false)
}
</function>

<function name="cmb_decAttrib" parameters="object,attrib,value" type="boolean">
if (cmb_chkObject(object)){
attrib=cmb_chkAttrib(attrib)
if (LengthOf(attrib)>0) {
cmb_setAttrib(object,attrib,cmb_getAttrib(object,attrib) - value)
return (true)
} else {
return (false)
}
} else {
return (false)
}
</function>

<function name="cmb_equip" parameters="itemname" type="boolean">
found=false
item= getObject(itemname)
if (item=null) {
msg("What does " + itemname + " mean?")
} else if ( not DoesInherit (item, "cmb_equipment")) {
msg("You can't equip this item.")
} else {
if (cmb_chkObject(item)){
foreach (cmb_object, ScopeInventory()) {
if (item=cmb_object){
found=true
}
}
if ( not found) {
msg ("You don't have this in your inventory.")
}
}
}
if (found) {
if ( player.cmb_level >=item.cmb_activelvl ) {
dict_equiped = NewStringDictionary ()
string2dict ( player.equiped,dict_equiped)
if (item.cmb_where="dhand" and (DictionaryContains (dict_equiped,"lhand") or (DictionaryContains (dict_equiped,"rhand")))){
msg("1")
msg("You already are carrying something in your hands!")
} else if ((item.cmb_where="dhand" or item.cmb_where="rhand") and DictionaryContains (dict_equiped,"dhand")){
msg("2")
msg("You already are carrying something in your hands!")
} else if ( DictionaryContains (dict_equiped,item.cmb_where)) {
msg("You already have something equiped there!")
} else {
dictionary add( dict_equiped,item.cmb_where, itemname)
item.alias=GetDisplayAlias (item)+ " ("+item.cmb_where+")"
eval_mod(player,item.cmb_mod, true )
}
player.equiped=dict2string (dict_equiped)
cmb_refreshStatus
msg("Done")
} else {
msg("You are not experienced enough to equip this item.")
}
}

return (true)
</function>


<function name="cmb_unequip" parameters="itemname" type="boolean">
found=false
item= getObject(itemname)
if (item=null) {
msg("What does " + itemname + " mean?")
} else if ( not DoesInherit (item, "cmb_equipment")) {
msg("You can't unequip this item.")
} else {
if (cmb_chkObject(item)){
foreach (cmb_object, ScopeInventory()) {
if (item=cmb_object){
found=true
}
}
if ( not found) {
msg ("You don't have this in your inventory.")
}

}
}
if (found) {
dict_equiped = NewStringDictionary ()
string2dict ( player.equiped,dict_equiped)
pos=DictionaryContainsValue(dict_equiped, itemname)
if ( lengthof(pos) > 0) {
dictionary remove(dict_equiped, pos)
if (InstrRev ( getString(item,"alias") , "(" )>2) {
item.alias=Left ( item.alias , InstrRev ( getString (item, "alias") , "(" )-2 )
}
eval_mod(player,item.cmb_mod, false )
}

player.equiped=dict2string (dict_equiped)
cmb_refreshStatus
msg("Done")
}
return (true)
</function>

<function name="cmb_unequipIntern" parameters="itemname" type="boolean">
item= getObject(itemname)
if (item=null) {

} else {
dict_equiped = NewStringDictionary ()
string2dict ( player.equiped,dict_equiped)
pos=DictionaryContainsValue(dict_equiped, itemname)
if ( lengthof(pos) > 0) {
dictionary remove(dict_equiped, pos)
if (InstrRev ( getString(item,"alias") , "(" )>2) {
item.alias=Left ( item.alias , InstrRev ( getString(item,"alias") , "(" )-2 )
}
eval_mod(player,item.cmb_mod, false )
}

player.equiped=dict2string (dict_equiped)
cmb_refreshStatus
}
</function>


<function name="eval_mod" parameters="object,mod_dict,inc">
foreach ( x, mod_dict ) {
if (x="at" or x="pa" or x="hp" or x="str"){
y=stringdictionaryitem(mod_dict,x)
if (IsInt(y)) {
if (inc) {
cmb_incAttrib(object,x,toint(y))
} else {
cmb_decAttrib(object,x,toint(y))
}
}
}
}
</function>

<function name="cmb_loot" parameters="targetname">
target= getObject(targetname)
if (target=null){
msg("You can't see that here.")
} else{
found=false
if(cmb_chkObject(target) and cmb_isReachable(target)){
if (target.dead) {
foreach (cmb_object, AllObjects()) {
if (cmb_object.parent=target) {
MoveObject (cmb_object, target.parent)
found=true
}
}
destroy(target.name)
if (found) {
msg("You found something.")
} else {
msg("You could not found something interessting.")
}
} else {
msg("You cant loot now.")
}
} else {
msg("You cant loot " + target.alias)
}
}

</function>

<function name="cmb_fight" parameters="object, target" type="boolean">
vattack=0
vparade=0
if (cmb_chkFighter(object) and cmb_chkFighter(target)){
for (x ,1, cmb_getAttrib(object,"cmb_at")) {
vattack = vattack + cmb_dicesix()
}
for (x ,1 ,cmb_getAttrib(target,"cmb_pa")) {
vparade = vparade + cmb_dicesix()
}
msg("at: " + ToString(vattack) + ", pa: "+ToString(vparade))
if (vattack > vparade) {
damage=cmb_dice(object.cmb_str) + cmb_dice(vattack-vparade)
cmb_decAttrib (target, "cmb_hp", damage)
msg(object.name + " hits " + target.name + " for " + damage + " points.")
} else {
msg (object.name + " misses.")
}
return (true)
} else {
return (false)
}
</function>

<function name="cmb_attack" parameters="object, targetname" type="boolean">
returnvalue=false
target= getObject(targetname)

if(target=null){
msg("There is no " + targetname + " here.")
returnvalue=false
} else if (not cmb_isReachable(target)){
msg("There is no " + target.name + " here.")
returnvalue=false
} else if (GetBoolean ( target , "dead" ) ){
msg("Your target is not alive any more.")
returnvalue=false
} else if(cmb_chkObject(object) and cmb_chkObject(target)){
if (cmb_fight(object, target)) {
if (cmb_getAttrib(target,"cmb_hp")>0) {
msg( target.name + " hits back.")
cmb_fight(target,object)
if (cmb_getAttrib(object,"cmb_hp")>0) {
msg("")
} else {
if (object=player){
msg( "A last strike hits you. You are dying.")
msg( "GAME OVER")
finish
} else {
msg( object.name + " dies.")
SetObjectFlagOn (target, "dead")
target.alias = GetDisplayAlias (target) +" (dead)"
cmb_addexp(target)
if (DictionaryContains(target.cmb_script, "killed")) {
invoke (ScriptDictionaryItem(target.cmb_script, "killed"))
}
}
}
} else {
if (target=player){
msg( "A last strike hits you. You are dying.")
msg( "GAME OVER")
finish
} else {
msg( target.name + " dies.")
SetObjectFlagOn (target, "dead")
target.alias = GetDisplayAlias (target) +" (dead)"
cmb_addexp(target)
if (DictionaryContains(target.cmb_script, "killed")) {
invoke (ScriptDictionaryItem(target.cmb_script, "killed"))
}
}
}
} else {
msg("Why do you want to do this?")
}
returnvalue=true
}
return (returnvalue)
</function>

<function name="cmb_addexp" parameters="object" >
found=false
new_level=0
if (object.cmb_exp>0){
player.cmb_exp=player.cmb_exp+object.cmb_exp
msg("You got "+object.cmb_exp+" exp.")
foreach(x,cmb_intern.cmb_lvlexp) {
if(player.cmb_exp >= ToInt( StringDictionaryItem(cmb_intern.cmb_lvlexp,x))){
new_level=toint(x)
found=true
}
}
}
if (found) {
player.cmb_level=new_level
msg("Level "+new_level)
cmb_refreshStatus
}
</function>

<function name="cmb_chkObject" parameters="object" type="boolean">
value = false
foreach (cmb_object, AllObjects()) {
if (object=cmb_object) {
value = true
}
}
return (value)
</function>

<function name="cmb_chkFighter" parameters="object" type="boolean">
if (DoesInherit (object, "cmb_fighter")) {
return (true)
} else {
return (false)
}
</function>

<function name="cmb_chkAttrib" parameters="attrib" type="string">
<![CDATA[
if (ucase(left(attrib,4))<> "CMB_") {
attrib="cmb_" + attrib
}
if ( ListContains ( cmb_intern.cmb_attribs , ucase(attrib) )) {
return (attrib)
} else {
return ("")
}
]]>
</function>

<function name="cmb_isReachable" parameters="object" type="boolean">
value=false
foreach (x,ScopeReachableNotHeld ()) {
if(x=object) {
value=true
}
}
return (value)
</function>

<function name="cmb_dicesix" type="int">
dice=cmb_dice(GetRandomInt(1,6))
return (dice)
</function>

<function name="cmb_dice" parameters="number" type="int">
dice=GetRandomInt(1,number)
return (dice)
</function>

<function name="dict2string" parameters="dict" type="string">
text=""
foreach (x, dict) {
text=concat (text,concat (x,StringDictionaryItem (dict,x),"="),";")
}
return (text)
</function>

<function name="string2dict" parameters="text, dict">
list=split(text, ";")
if (ListCount(list)>0) {
for(x, 0, ListCount(list)-1) {
if ( Instr(StringListItem ( list , x ),"=")>0) {
list2=split( StringListItem ( list , x ), "=")
dictionary add (dict,StringListItem ( list2 , 0 ), StringListItem ( list2 , 1 ))
}
}
}
</function>

<function name="concat" parameters="text1,text2,separator" type="string">
if ( LengthOf(text1)>0 and LengthOf(text2)>0 ){
return (text1 + separator + text2)
} else if ( LengthOf(text1)>0 ) {
return (text1)
} else {
return (text2)
}
</function>

<function name="DictionaryContainsValue" parameters="dict,value" type="string">
found=""
foreach (x,dict) {
if (StringDictionaryItem(dict,x)=value) {
found=x
}
}
return (found)
</function>

<function name="cmb_startTurnscript" >
create turnscript ("cmb_tscript")
SetTurnScript (cmb_tscript) {
cmb_checkItems
}
EnableTurnScript (cmb_tscript)
</function>

<function name="cmb_checkItems" >
foreach (x,ScopeAllObjectsNotHeld () ) {
pos=instr( GetString ( x , "alias" ) , "(" )
if ( pos >0) {
cmb_unequipIntern( GetString ( x , "name" ))
}
}
</function>


<function name="ScopeAllObjectsNotHeld" type="objectlist">
result = NewObjectList()
foreach (obj, AllObjects()) {
if (not Contains(player, obj) and Contains(player.parent, obj)) {
list add(result, obj)
}
}
return (result)
</function>


</library>

Pertex
The problem is here:
<function name="battle_system" parameters="selfname , textname" type="boolean">


remove the blanks in the parameterlist, then it works: parameters="selfname,textname"

HegemonKhan
Thank you so much Pertex! Wow... all it was, is the space... lol... (and AGAIN syntax~formatting... HK GROWLES!)

except... I'm baffled, as I got such spaces, everywhere, and they seem to be working fine...

"___(space),(space)___"

this is vexingly perplexing, pertex!, lol (your name is fun!)

-----------

and an additional quick question: (again about parameters)

with the parameters, does it cause any problems if you keep using the same words over and over within nested functions, and~or if you instead constantly use different words too? Is there any connection between different functions' parameters, besides as "place holders", i.e. 2 parameter entries are required or 1 parameter entry is required or 5 parameter entries are required)

could I change the parameters in the:

Command: Fight (player.text)

to instead

Command: Fight (self,enemy),

or is the:

"text" required, as it is a special case, needed to call on the inputed text by the user?

"player" required, as it is a special case, needed to call on the player object / game.pov ?

--------

P.S.

so the comma "," has to be here:

(self, ___)

but, what about the "other side" ?, does the comma have to be here:

(___,enemy)

or can it be here ? :

(___, enemy)

HegemonKhan
.
.
Trouble Shooting Help Needed!

Quest Crashes when I try to fight the orc, I don't have the battle_system nor do I have the battle_sequence completed, and I suspect that this is why Quest is crashing, and~or it is due to what coding I have, has faulty syntax~formatting. As these two (there's a few more, smaller, functions too) functions use the return values, and etc, which I hope this is why it is crashing. I've been able to trouble shoot out the loading errors of my game file, and other errors with fighting the orc, but now after getting all these errors fixed, now I'm getting into these crashing errors in regards to my attempt at coding a combat system.

could anyone just look over the coding I have and see if I've done anything wrong, and~or if you spot anything missing, could you inform me of what I need to have where. I'll try to trouble shoot this as best as I can, but this is probably going to be too big for my to try to narrow down what my problems are, which are causing the crash, as I don't know coding as well as others yet, so it's much harder for me to try to trouble shoot, and also, I can try to keep doing the coding too, as maybe if I get it completed, and as well as possibly getting it set up the right way, maybe that will fix the crashing in of itself as well.

I don't understand using functions' returning values yet, so if I could get help on these, I'd be appreciative, and hopefully it is these (missing) returns on the functions which is causing the crashes when trying to fight the orc.

here's my game file (remember that it crashes when you fight the orc):

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<ac type="int">0</ac>
<ar type="int">0</ar>
</type>
<type name="pc_char">
<inherit name="char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile />
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
return_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
return_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value = false
}
else if (GetBoolean (enemy,"dead")) {
msg (enemy.alias + " is already dead.")
return_value = false
}
else if (not Doesinherit (enemy,"npc_char")) {
msg ("You can not battle that!")
return_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value = false
}
if (battle_sequence (self,enemy)) {
return_value = true
}
return (return_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
self_battle_turn (self,enemy)
enemy_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
self_battle_turn (self,enemy)
enemy_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else {
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
self.defending = false
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
}
else if msg ("Enemy Parry") {
msg (enemy.alias + "parried your attack!")
}
else if msg ("Enemy Block") {
msg (enemy.alias + "blocked your attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
}
else if (RandomChance (GetInt (enemy,"ac") = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
}
else if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd / 2 + wd * (GetInt (self,"str) - GetInt (enemy,"end")) / 100)
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
}
case ("Defend") {
self.defending = true
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
}
}
else {
msg (enemy.alias + " is dead.")
}
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
enemy.defending = false
result = GetRandomInt (1,3)
switch (result) {
case (1) {
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
}
else if msg ("Self's Parry") {
msg ("You have parried the attack!")
}
else if msg ("Self Block") {
msg ("You have blocked the attack!")
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
}
else if (RandomChance (GetInt (self,"ac") = true) {
msg ("You resisted the attack!")
}
else if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * wd / 2 + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * wd + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * wd / 2 + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * wd + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
}
case (2) {
enemy.defending = true
}
case (3) {
(Cast)
}
}
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
enemy_battle_turn
}
]]></function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
<function name="attack_rating_ar_vs_ac">
</function>
</asl>


I'll keep trying to trouble shoot this... I guess by trying to add line by line, and hope I can find what's causing the crashings...

---------

[EDIT HK: SOLVED, so ignore this text below]

P.S.

err... I forgot that I've got this loading error still... if someone could help me with this one too... (I had just removed the code that caused this, in trying to find out what it was, which then revealing to me the crashing error, when trying to fight the orc.

I forgot that I had this loading error to deal with... I'll try to work on this myself, but still if people could look over my code, as well as look at this loading error too (but don't tell me how to fix it yet, as I want to try to do so myself!), it'd be appreciated!

[EDIT HK: SOLVED, so ignore this text above]

-------

[EDIT HK]:

P.S.S.

found it, at least the loading error, anyways. I forgot one quotation mark on one of my attributes:

(self,"str) -> (self,"str")

GROWLES... at least I got this loading error fixed~solved, and luckily there's now no more~other loading errors... now it is figuring out all the stuff that is wrong and~or missing from the code, which is causing teh crash upon fighting the orc... laughs

so, here's the new code, without the loading error:

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<ac type="int">0</ac>
<ar type="int">0</ar>
</type>
<type name="pc_char">
<inherit name="char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile />
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
return_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
return_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value = false
}
else if (GetBoolean (enemy,"dead")) {
msg (enemy.alias + " is already dead.")
return_value = false
}
else if (not Doesinherit (enemy,"npc_char")) {
msg ("You can not battle that!")
return_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value = false
}
if (battle_sequence (self,enemy)) {
return_value = true
}
return (return_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
self_battle_turn (self,enemy)
enemy_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
self_battle_turn (self,enemy)
enemy_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else {
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
self.defending = false
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
}
else if msg ("Enemy Parry") {
msg (enemy.alias + "parried your attack!")
}
else if msg ("Enemy Block") {
msg (enemy.alias + "blocked your attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
}
else if (RandomChance (GetInt (enemy,"ac") = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
}
else if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
}
case ("Defend") {
self.defending = true
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
}
}
else {
msg (enemy.alias + " is dead.")
}
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
enemy.defending = false
result = GetRandomInt (1,3)
switch (result) {
case (1) {
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
}
else if msg ("Self's Parry") {
msg ("You have parried the attack!")
}
else if msg ("Self Block") {
msg ("You have blocked the attack!")
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
}
else if (RandomChance (GetInt (self,"ac") = true) {
msg ("You resisted the attack!")
}
else if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * wd / 2 + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * wd + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * wd / 2 + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * wd + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
}
case (2) {
enemy.defending = true
}
case (3) {
(Cast)
}
}
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
enemy_battle_turn
}
]]></function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
<function name="attack_rating_ar_vs_ac">
</function>
</asl>

HegemonKhan
OMG OMG OMG!

I think my code may be working... and thus doing endless looping (as I haven't addressed this yet in my coding)... which is causing the "crash"... I hope this is the problem! As it'd mean that I figured out the cause of the "crash", and so is or can be easily fixed.. hopefully... HK crosses his fingers... so could someone maybe try to look this over, to see if the "crashing" is indeed merely due to my code doing endless looping.

I have my battle sequence code loop back again, for "new combat rounds" and also if their (self or enemy) spd is high enough, they get to do their combat turn again, so two type of spots where I do have looping, without any coding to stop it yet, laughs. I so hope this is merely my problem with the "crashing" when trying to fight the orc! HK is eager to see if someone can verify this, and~or when he~HK~himself can verify this, as he works slowly towards this aspect of the code, of the return values, of which I presume is the way that the looping is to be stopped.

(I can't remember if Pertex' Combat code has any looping call back~upon functions, I'll have to check, if not, I'll have to figure out how to stop the looping effect I have in my coding on my own, or until I get stuck and ask someone on how to do it, lol)

Pertex
1. avoid any spaces!
2. Sorry, I don't understand your question about parameter
3. There are some bugs in your code :D
else if msg ("Enemy Parry") {
doesn't make sense

and in function self_battle_turn you have to move all code into the show menu block.
        if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
...
must be in the show menu block

Try to correct this code, then we will see what happens

HegemonKhan
thanks for these pointers, Pertex, though I'm sure there's more problems too... I do have to address my looping code...

-----------

this is a (future) code that checks if a weapon will be used to stop the attack or not:

else if msg ("Enemy Parry") {

this is a (future) code that checks if a shield will be used to stop the attack or not:

else if msg ("Enemy Block") {

and more incomplete such (future) codes too:

case ("Cast") { ~~~ magic implementation
case ("Item") { ~~~ item implementation
case ("Run") { ~~~ escape battle implementation
<function name="attack_rating_ar_vs_ac"> ~~~ I want to have the ar* vs ac* (like my other codes, such as str vs end, dex vs spd, agi vs spd, and etc), instead of just having the ac, for this code.

*AR = Attack Rating (I'm using this though as a counter to the AC and given from~as the weapon's attribute, separate from the To Hit chance using dex vs spd, as usually AR determines To Hit Chance and also usually dex gives a multiplier to AR, such as in Diablo 2 game)

*AC = Armor Class (see about AR, this should explain my use in it, I hope)

>
so, all of these codes above are just used as notes to myself so I don't forget, I need to complete this code at some point (as it involves equipment, magic, and items ~ I still have a lot of coding to do, lol. I want to use equipment, weapons and armor, in my combat system, but I haven't gotten to that yet, not even sure how I want or am going to do it, at this point)

-----------

thanks about telling me I need to nest the code within the show menu, saved me a lot of trouble figuring that out, in trouble shooting!

as can be seen:

I still have a lot of trouble with the correct syntax and~or formatting, chuckles... not very funny... though... source of a lot of my difficulties in trying to learn to code and to get the code right~correct...

---------

hmm about the parameters... about my parameter questions...

let me get back to you on this, as I'm too tired to try to explain my questions, in (hopefully) making more sense, right now.

HK is hungry... needs to eat... as it's an hr past noon and HK's tummy is growling noisily and loudly... lol

-----------

EDIT HK:

P.S.

Did I format the self_combat_turn show menu section correctly ? :

  <function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
self.defending = false
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
}
else if msg ("Enemy Parry") {
msg (enemy.alias + "parried your attack!")
}
else if msg ("Enemy Block") {
msg (enemy.alias + "blocked your attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
}
else if (RandomChance (GetInt (enemy,"ac") = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
}
else if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) /

100)
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) /

100)
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) /

100)
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
}
case ("Defend") {
self.defending = true
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
}
}
else {
msg (enemy.alias + " is dead.")
}
}
]]></function>


and I'm a bit unclear with the return values... but I'll see if I can make sense of it on my own for now... but if not, can you help me with doing them? where to place them, and how to set up the returns correctly, as I'm going quite a bit deep with in nested scripts utilizing the return values, so I'm confused a bit on how to do this. But again, let me try to work on this myself, for now

Pertex
OK, perhaps you use "else if msg ("Enemy Block")" as a marker but the syntax is totally wrong which causes bugs. You must change these lines! Best is to comment these lines with //

HegemonKhan
ah thanks, didn't know using msg would cause problems, I'll use the // commenting code for now on, now that I know better.

anyways, I've updated my coding, (I filled in the code for those msg notes, though they still aren't complete as I need check coding lines to see if you/monster got a weapon and its parrying undecided-upon attribute for parrying or a shield and its blocking undecided-upon attribute for blocking), I'm going to work on the magic combat option next, which will look just like the attack stuff, but using the magic attributes of int (intelligence), spi (spirituality), and men (mentality) and~or etc other attributes. I also added in the ar to the ac lines, thus removing the note function of "attack_rating_ar_vs_ac" at the bottom of my previous code posting. I also added in some preliminary object types for when I get to doing equipment and spells. I'm still tryig to work on and figure out my own design for them, as I don't want to just copy pixie's, chase's, and yours-pertex's such libraries on equipment and spells. I want to try to design my own, as best as I can, anyways. the structure will be generally the same, as I can't come up with my own entirely unique structure for systems yet, and I'm not even sure if there's other or even worse, better structures to think up of, lol. Your structures in your libraries, are so well done, it's hard not to use these best structure designs of yours, lol.

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc_char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = ;ar = ;ac = </statusattributes>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc_char" />
<alias>orc</alias>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
hp_mp_cur_max
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">100</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">100</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<ac type="int">0</ac>
<ar type="int">0</ar>
</type>
<type name="pc_char">
<inherit name="char" />
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;turns = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = </statusattributes>
</type>
<type name="npc_char">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile />
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
</type>
<type name="gear">
<weight type="int">0</weight>
<take type="boolean">true</take>
<give type="boolean">true</give>
<equipped type="boolean">false</equipped>
<equipable type="boolean">true</equipable>
<unequipable type="boolean">true</unequipable>
<equipable_layer type="int">3</equipable_layer>
<equipable_slots type="list"></equipable_slots>
<inventoryverbs type="listextend">Equip;Unequip</inventoryverbs>
</type>
<type name="weapon_gear">
<inherit name="gear" />
<wd type="int">0</wd>
<ar type="int">0</ar>
</type>
<type name="armor_gear">
<inherit name="gear" />
<ac type="int">0</ac>
</type>
<type name="spell">
<drop type="boolean">false</drop>
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
</type>
<type name="fire">
</type>
<type name="water">
</type>
<type name="air">
</type>
<type name="earth">
</type>
<type name="light">
</type>
<type name="dark">
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="hp_mp_cur_max">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
return_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
return_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value = false
}
else if (GetBoolean (enemy,"dead")) {
msg (enemy.alias + " is already dead.")
return_value = false
}
else if (not Doesinherit (enemy,"npc_char")) {
msg ("You can not battle that!")
return_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value = false
}
if (battle_sequence (self,enemy)) {
return_value = true
}
return (return_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
self_battle_turn (self,enemy)
enemy_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
self_battle_turn (self,enemy)
enemy_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
battle_sequence (self,enemy)
}
else {
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
self.defending = false
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
}
else if (RandomChance (Get Int (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
}
else if (RandomChance (GetInt (enemy,"ac") - GetInt (self,"ar")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
}
else if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd / 2 + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * wd + wd * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
}
case ("Defend") {
self.defending = true
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
}
}
else {
msg (enemy.alias + " is dead.")
}
}
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
enemy.defending = false
result = GetRandomInt (1,3)
switch (result) {
case (1) {
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
}
else if (RandomChance (GetInt (self,"ac") - GetInt (enemy,"ar")) = true) {
msg ("You resisted the attack!")
}
else if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * wd / 2 + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * wd + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * wd / 2 + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * wd + wd * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
}
case (2) {
enemy.defending = true
}
case (3) {
(Cast)
}
}
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
enemy_battle_turn
}
]]></function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>

Pertex
Ok, the problem of your crash is a infinite loop. battle_sequence calls battle_sequence calls battle_sequence..., Show menu does not wait for the player input(even if the menu is shown) so you have to "stop" the scripts with "on ready"

     <function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
self_battle_turn (self,enemy)

enemy_battle_turn (self,enemy)
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
self_battle_turn (self,enemy)

enemy_battle_turn (self,enemy)
on ready {
battle_sequence (self,enemy)
}
}
else {
enemy_battle_turn (self,enemy)

self_battle_turn (self,enemy)
on ready {
battle_sequence (self,enemy)
}
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
enemy_battle_turn (self,enemy)

self_battle_turn (self,enemy
on ready {
battle_sequence (self,enemy)
}
}
else {
}
return (true)
]]></function>


Then there is a wrong spelling with getint. You typed "get int" with a blank. And if you comment
 case (3) {
// (Cast)

you should not get any messages any more.

HegemonKhan
thanks, Pertex!

woot, no more crashing, except I need to complete the combat codings, chuckles... :D

my other scripts seem to be working, I just need to work more on getting the combat code done... at least having it recognize that the orc is dead, and ending the combat system. (As I checked my game, I forgot to give the orc some life, laughs, and it keeps attacking me too, I got a lot of code that I still haven't gotten to yet, but at least, thanks you you pertex, I'm removing some of these other problems, hehe.

----------

could you explain more about the ' on ready ' and in regards to scripts running on the same level, for me? the wiki doesn't really explain this stuff thoroughly enough in detail.

for example:

do I need to have ' on ready ' only for the ' battle_sequence (a call on function) '

or do I need to have it before~for the ' enemy_battle_turn or self_battle_turn (the 2nd battle turn) '

or do I also need it (meaning for both of the turns, and the call on function) before~for the ' enemy_battle_turn or self_battle_turn (the 1st battle turn) '

I also have more call on functions, allowing the player ("self") or the monster~npc ("enemy") to do their ' combat_turn ' again. Do I need to have on ready before~for these as well ?

do I need to put an ' on ready ' before~for the show menu script ?

---------

I do not want everything happening at once... I want it to be sequential, line by line...

for example, with all of the checks scripts in the ' battle_system ' are they all running at the same time ? do I need to have~use an ' on ready ' everywhere, for every single line?

or, was I suppose to nest (indent) each time, when I didn't and should have?

where~when is the ' on ready ' needed and when is it not?

---------

P.S.

if you're confused by my coding at all, or can't figure out what I'm doing, ask away, I can and will gladly explain my coding, so you can better follow and understand it, so it's easier to spot problems for me and~or know what I'm trying to do with it.

I probably should have made this into a library file with the // comments throughout, to explain it, sorry about that... I just hoped you could follow it along, figuring that by knowing coding well, it wouldn't be too hard to get~see~understand another person's coding. For me, a noob, it takes awhile as I got to also understand the coding itself, too, and not just what the person is trying to do with their codings, it's harder for me to recognize things, as I'm still learning how to code.

---------

I can't do much more now, as I've realized I've got to figure out how or what I want implement, before I can even try to code it into my combat system. So, I won't be having hopefully too many more questions for awhile, as I work on what I need to do on my end, as I got a lot of stuff to work on, long before this combat system is done and (truly) testable, without problems of big chunks of incomplete or missing coding blocks and etc.

I have to figure out my game design and mechanics that I want, and then how would I go about implementing them into my combat system. So, it'll be awhile before I can work more on the actual coding of my combat system.

I'm trying to figure out how I should do equipment, weapons, armors, spells, and etc. Different types of damage (fire, water, air, earth, light, dark) and resistances, on weapons, armors, and~or as spells, I need to figure out a storage system too, as I need that for having a parent source, for learning spells, and etc. HK is getting way too ambitious... lol. How to cast spells in the combat system, and outside of it, separating the various spells, and etc. I also want my equipment to be more complex, such as sword type weapons doing bonus damage to animals, axe type weapons doing bonus damage to demons, blunt type weapons doing bonus damage to undead. and etc... laughs. Also, trying to think of how I should do projectile weapons, as well.

if anyone, wants to offer ideas, or feedback on any of these things, I'd appreciate it. Especially if it could be in comparison to my combat system, what would be the best choices of designs or mechanics, based upon the combat system that I'm slowly putting into place.

Pertex
You need the 'on ready 'function after the self_battle_turn function, because you are using 'show menu' there. The 'show menu' function only executes the code in the script block, when you choose something from the menu. But all code which is not in this block and behind the show menu is executed immediately. So while showing the menu the program continues with function battle_sequence and so on. The 'on ready' in front of battle_sequence stops the program and waits until the menu is closed and the menu script is executed.

HegemonKhan
thanks Pertex,

before I wander on my ambition of all this other stuff, I'm going to try to first get my combat system at least functioning, get all the return values done, end combat properply, when orc is dead, and etc. then, I can work on the other stuff, figuring out their designs~mechanics, and then work on implementing them with and into the combat system I have.

HegemonKhan
.
.
Help Needed (the last, I think+hope for getting this functional, now for) !!!

I think I've got this combat system of mine, nearly functional, except I'm having trouble figuring out where to put my return values of true, as I've got a bit of a complex system, which my brain is having trouble mapping out for where to put the return values of true at, also, I've realized that the return values of true, don't end the combat system either, so I think the way to end the combat system is to make it as a turnscript, which can then be enabled and disabled, which can then~thus utilize the return values of true, but I need help with those return values of true, and also with exactly how or where or what to place~do with the turn script, as I got:

Command: fight #text#
-> script
>--> Function: battle_system (game.pov,text)
-> script
command

Function: battle_system (self,text)
-> Function: battle_sequence (self,enemy)

Function: battle_sequence (self,enemy)
-> Function: self_battle_turn (self,enemy)
-> Function: enemy_battle_turn (self,enemy)

Function: self_battle_turn (self,enemy)

Function: enemy_battle_turn (self,enemy)

and then the turnscript, where do I put it (and~or what do I need to change with the other functions or command):

Turnscript: battle_rounds_and_battle_toggle
(I'd like to use the turnscript to implement a break~message telling what battle round it is via by turns, as well as using the turnscript to end the entire battle system)

I also, would like the user to be able to see the battle_system process (meaning that ehre's breaks, with messages, so they can see~know what has happened,

[EDIT HK: SOLVED, the text below, I nested the show menu inside of "WAIT" function]

and thus also for the show menu not to come up, immediately and interfere with the left pane and right panes' display of stuff)

{EDIT HK: SOLVED, the text above]

here's my code:

(I added in a lot of junk as I was trying to brainstorm on setting up my equipment, storage, spells, and etc, but I could use suggestions on this too, though let's work on the problem of getting this combat system at least functional, for now... heh)

(also, I've tried my best to try to put the return values of true in, and etc, but I'm really confused now. I may have to map this out visually, if no one can help me, as it might be too confusing for them too, lol)

So, I hope it just needs to be "cleaned up" with getting all the return false and true values set up where they need to be, and then in how and where (and what needs to be changed and~or moved around) to implement in a turnscript, so that I can enable and disable it via the return values of true false, which will thus be how I end the full combat system, out of the combat action.

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<btrns type="int">0</btrns>
<brnds type="int">0</brnds>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc" />
<cur_hp type="int">100</cur_hp>
<max_hp type="int">100</max_hp>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<str type="int">100</str>
<end type="int">100</end>
<dex type="int">100</dex>
<agi type="int">100</agi>
<spd type="int">100</spd>
<hc type="int">100</hc>
<pd type="int">100</pd>
<pr type="int">100</pr>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc" />
<hostile type="boolean">true</hostile>
<alias>orc</alias>
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">25</str>
<end type="int">25</end>
<dex type="int">25</dex>
<agi type="int">25</agi>
<spd type="int">25</spd>
<hc type="int">25</hc>
<pd type="int">25</pd>
<pr type="int">25</pr>
<exp type="int">100</exp>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
sa
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">0</cur_mp>
<max_mp type="int">0</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<hc type="int">0</hc>
<pd type="int">0</pd>
<fd type="int">0</fd>
<wd type="int">0</wd>
<ad type="int">0</ad>
<ed type="int">0</ed>
<ld type="int">0</ld>
<dd type="int">0</dd>
<pr type="int">0</pr>
<fr type="int">0</fr>
<wr type="int">0</wr>
<ar type="int">0</ar>
<er type="int">0</er>
<lr type="int">0</lr>
<dr type="int">0</dr>
<wt type="int">0</wt>
<ht type="int">0</ht>
<cur_arrow type="int">0</cur_arrow>
<cur_bolt type="int">0</cur_bolt>
<cur_bullet type="int">0</cur_bullet>
<max_arrow type="int">0</max_arrow>
<max_bolt type="int">0</max_bolt>
<max_bullet type="int">0</max_bullet>
<arrows type="int">0</arrows>
<bolts type="int">0</bolts>
<bullets type="int">0</bullets>
<cur_shuriken type="int">0</cur_shuriken>
<cur_throwing_axe type="int">0</cur_throwing_axe>
<cur_javelin type="int">0</cur_javelin>
<max_shuriken type="int">0</max_shuriken>
<max_throwing_axe type="int">0</max_throwing_axe>
<max_javelin type="int">0</max_javelin>
<shurikens type="int">0</shurikens>
<throwing_axes type="int">0</throwing_axes>
<javelins type="int">0</javelins>
<cur_throwing_knife type="int">0</cur_throwing_knife>
<max_throwing_knife type="int">0</max_throwing_knife>
<throwing_knives type="int">0</throwing_knives>
</type>
<type name="pc">
<inherit name="char" />
<escaped type="boolean">false</escaped>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = ;hc = ;pd = ;fd = ;wd = ;ad = ;ed = ;ld = ;dd = ;pr = ;fr = ;wr = ;ar = ;er = ;lr = ;dr = ;wt = ;ht = ;arrows = ;bolts = ;bullets = ;shurikens = ;throwing_axes = ;javelins = ;throwing_knives = </statusattributes>
</type>
<type name="npc">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
<hostility type="script">
if (this.hostile = true) {
this.alias = this.displayalias + "(hostile)"
this.displayverbs = split ("Look;Use;Cast;Fight", ";")
}
</hostility>
<death type="script">
if (this.dead = true) {
this.alias = this.displayalias + "(dead)"
game.pov.exp = game.pov.exp + this.exp
this.displayverbs = split ("Look;Steal;Give;Use;Cast", ";")
}
</death>
</type>
<type name="storage">
<inherit name="container_closed" />
<drop type="boolean">false</drop>
<inventoryverbs type="list">Look; Open; Close</inventoryverbs>
</type>
<type name="gear">
<wt type="int">0</wt>
<take type="boolean">true</take>
<give type="boolean">true</give>
<equipped type="boolean">false</equipped>
<equipable type="boolean">true</equipable>
<unequipable type="boolean">true</unequipable>
<equipable_layer type="int">3</equipable_layer>
<equipable_slots type="list"></equipable_slots>
<inventoryverbs type="listextend">Equip;Unequip</inventoryverbs>
</type>
<type name="weapon">
<inherit name="gear" />
<pd type="int">0</pd>
<hc type="int">0</hc>
</type>
<type name="one_handed">
<inherit name="weapon" />
<equipable_slots type="list">right_hand</equipable_slots>
</type>
<type name="two_handed">
<inherit name="weapon" />
<equipable_slots type="list">left_hand;right_hand</equipable_slots>
</type>
<type name="sword">
</type>
<type name="axe">
</type>
<type name="blunt">
</type>
<type name="spear">
<inherit name="two_handed" />
</type>
<type name="staff">
<inherit name="two_handed" />
</type>
<type name="dagger">
<inherit name="one_handed" />
</type>
<type name="whip">
<inherit name="one_handed" />
</type>
<type name="bow">
<inherit name="two_handed" />
</type>
<type name="crossbow">
<inherit name="two_handed" />
</type>
<type name="gun">
</type>
<type name="throwing">
</type>
<type name="armor">
<inherit name="gear" />
<pr type="int">0</pr>
</type>
<type name="shield">
<inherit name="armor" />
<equipable_slots type="list">left_hand</equipable_slots>
</type>
<type name="clothing">
<inherit name="gear" />
</type>
<type name="headwear">
<equipable_slots type="list">head</equipable_slots>
</type>
<type name="facewear">
<inherit name="clothing" />
<equipable_slots type="list">face</equipable_slots>
</type>
<type name="earwear">
<inherit name="clothing" />
<equipable_slots type="list">ear</equipable_slots>
</type>
<type name="neckwear">
<inherit name="clothing" />
<equipable_slots type="list">neck</equipable_slots>
</type>
<type name="shoulderwear">
<inherit name="armor" />
<equipable_slots type="list">shoulder</equipable_slots>
</type>
<type name="armwear">
<equipable_slots type="list">arm</equipable_slots>
</type>
<type name="handwear">
<equipable_slots type="list">hand</equipable_slots>
</type>
<type name="fingerwear">
<inherit name="clothing" />
<equipable_slots type="list">finger</equipable_slots>
</type>
<type name="chestwear">
<equipable_slots type="list">chest</equipable_slots>
</type>
<type name="backwear">
<inherit name="clothing" />
<equipable_slots type="list">back</equipable_slots>
</type>
<type name="waistwear">
<equipable_slots type="list">waist</equipable_slots>
</type>
<type name="legwear">
<equipable_slots type="list">leg</equipable_slots>
</type>
<type name="footwear">
<equipable_slots type="list">foot</equipable_slots>
</type>
<type name="arrow">
<cur_arrow type="int">0</cur_arrow>
</type>
<type name="arrow_case">
<inherit name="backwear" />
<max_arrow type="int">0</max_arrow>
</type>
<type name="bolt">
<cur_bolt type="int">0</cur_bolt>
</type>
<type name="bolt_case">
<inherit name="backwear" />
<max_bolt type="int">0</max_bolt>
</type>
<type name="bullet">
<cur_bullet type="int">0</cur_bullet>
</type>
<type name="bullet_case">
<inherit name="backwear" />
<max_bullet type="int">0</max_bullet>
</type>
<type name="spell">
<drop type="boolean">false</drop>
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
</type>
<type name="fire">
</type>
<type name="water">
</type>
<type name="air">
</type>
<type name="earth">
</type>
<type name="light">
</type>
<type name="dark">
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="sa">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
game.pov.arrows = game.pov.cur_arrow + " / " + game.pov.max_arrow
game.pov.bolts = game.pov.cur_bolt + " / " + game.pov.max_bolt
game.pov.bullets = game.pov.cur_bullet + " / " + game.pov.max_bullet
game.pov.shurikens = game.pov.cur_shuriken + " / " + game.pov.max_shuriken
game.pov.javelins = game.pov.cur_javelin + " / " + game.pov.max_javelin
game.pov.throwing_axes = game.pov.cur_throwing_axe + " / " + game.pov.max_throwing_axe
game.pov.throwing_knives = game.pov.cur_throwing_knife + " / " + game.pov.max_throwing_knife
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
return_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
return_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
return_value = false
}
else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
return_value = false
}
else if (not Doesinherit (enemy,"npc")) {
msg ("You can not battle that!")
return_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
return_value = false
}
else if (battle_sequence (self,enemy) = true) {
self.escaped = false
enemy.hostile = false
self.defending = false
enemy.defending = false
return_value = true
}
return (return_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
if (enemy.dead = true) {
return (true)
}
if (self.escaped = true) {
return (true)
}
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
self_battle_turn (self,enemy)
on ready {
enemy_battle_turn (self,enemy)
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
self_battle_turn (self,enemy)
on ready {
enemy_battle_turn (self,enemy)
}
on ready {
battle_sequence (self,enemy)
}
}
else {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
on ready {
battle_sequence (self,enemy)
}
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
enemy_battle_turn (self,enemy)
self_battle_turn (self,enemy)
on ready {
battle_sequence (self,enemy)
}
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
self.defending = false
if (enemy.dead = true) {
return (true)
}
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
}
else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
}
else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
}
else if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
}
}
case ("Defend") {
self.defending = true
}
case ("Cast") {
}
case ("Item") {
}
case ("Run") {
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
return (true)
}
}
else if (GetInt (enemy,"cur_hp") <= 0) {
enemy.dead = true
msg (enemy.alias + " is dead.")
return (true)
}
}
}
return (false)
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
enemy.defending = false
if (enemy.dead = true) {
return (true)
}
result = GetRandomInt (1,3)
switch (result) {
case (1) {
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
}
else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
msg ("You resisted the attack!")
}
else if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
}
}
case (2) {
enemy.defending = true
}
case (3) {
// (Cast)
}
}
if (GetInt (self,"cur_hp") > 0) {
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
msg (enemy.alias + " gets an extra battle turn!")
enemy_battle_turn
}
else {
msg (enemy.alias + " 's battle turn is over.")
return (true)
}
}
else if (GetInt (self,"cur_hp") <= 0) {
msg (self.alias + " has died.")
msg ("GAME OVER")
finish
}
]]></function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>

HegemonKhan
my best attempt at trying to trouble shoot my code, so here's the updated code of mine:

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<btrns type="int">0</btrns>
<brnds type="int">0</brnds>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc" />
<escaped type="boolean">false</escaped>
<cur_hp type="int">100</cur_hp>
<max_hp type="int">100</max_hp>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<str type="int">100</str>
<end type="int">100</end>
<dex type="int">100</dex>
<agi type="int">100</agi>
<spd type="int">100</spd>
<hc type="int">100</hc>
<pd type="int">100</pd>
<pr type="int">100</pr>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc" />
<hostile type="boolean">true</hostile>
<dead type="boolean">false</dead>
<alias>orc</alias>
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">25</str>
<end type="int">25</end>
<dex type="int">25</dex>
<agi type="int">25</agi>
<spd type="int">25</spd>
<hc type="int">25</hc>
<pd type="int">25</pd>
<pr type="int">25</pr>
<exp type="int">100</exp>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
sa
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">0</cur_mp>
<max_mp type="int">0</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<hc type="int">0</hc>
<pd type="int">0</pd>
<fd type="int">0</fd>
<wd type="int">0</wd>
<ad type="int">0</ad>
<ed type="int">0</ed>
<ld type="int">0</ld>
<dd type="int">0</dd>
<pr type="int">0</pr>
<fr type="int">0</fr>
<wr type="int">0</wr>
<ar type="int">0</ar>
<er type="int">0</er>
<lr type="int">0</lr>
<dr type="int">0</dr>
<wt type="int">0</wt>
<ht type="int">0</ht>
<cur_arrow type="int">0</cur_arrow>
<cur_bolt type="int">0</cur_bolt>
<cur_bullet type="int">0</cur_bullet>
<max_arrow type="int">0</max_arrow>
<max_bolt type="int">0</max_bolt>
<max_bullet type="int">0</max_bullet>
<arrows type="int">0</arrows>
<bolts type="int">0</bolts>
<bullets type="int">0</bullets>
<cur_shuriken type="int">0</cur_shuriken>
<cur_throwing_axe type="int">0</cur_throwing_axe>
<cur_javelin type="int">0</cur_javelin>
<max_shuriken type="int">0</max_shuriken>
<max_throwing_axe type="int">0</max_throwing_axe>
<max_javelin type="int">0</max_javelin>
<shurikens type="int">0</shurikens>
<throwing_axes type="int">0</throwing_axes>
<javelins type="int">0</javelins>
<cur_throwing_knife type="int">0</cur_throwing_knife>
<max_throwing_knife type="int">0</max_throwing_knife>
<throwing_knives type="int">0</throwing_knives>
</type>
<type name="pc">
<inherit name="char" />
<escaped type="boolean">false</escaped>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = ;hc = ;pd = ;fd = ;wd = ;ad = ;ed = ;ld = ;dd = ;pr = ;fr = ;wr = ;ar = ;er = ;lr = ;dr = ;wt = ;ht = ;arrows = ;bolts = ;bullets = ;shurikens = ;throwing_axes = ;javelins = ;throwing_knives = </statusattributes>
</type>
<type name="npc">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
<hostility type="script">
if (this.hostile = true) {
this.alias = this.displayalias + "(hostile)"
this.displayverbs = split ("Look;Use;Cast;Fight", ";")
}
</hostility>
<death type="script">
if (this.dead = true) {
this.alias = this.displayalias + "(dead)"
game.pov.exp = game.pov.exp + this.exp
this.displayverbs = split ("Look;Steal;Give;Use;Cast", ";")
}
</death>
</type>
<type name="storage">
<inherit name="container_closed" />
<drop type="boolean">false</drop>
<inventoryverbs type="list">Look; Open; Close</inventoryverbs>
</type>
<type name="gear">
<wt type="int">0</wt>
<take type="boolean">true</take>
<give type="boolean">true</give>
<equipped type="boolean">false</equipped>
<equipable type="boolean">true</equipable>
<unequipable type="boolean">true</unequipable>
<equipable_layer type="int">3</equipable_layer>
<equipable_slots type="list"></equipable_slots>
<inventoryverbs type="listextend">Equip;Unequip</inventoryverbs>
</type>
<type name="weapon">
<inherit name="gear" />
<pd type="int">0</pd>
<hc type="int">0</hc>
</type>
<type name="one_handed">
<inherit name="weapon" />
<equipable_slots type="list">right_hand</equipable_slots>
</type>
<type name="two_handed">
<inherit name="weapon" />
<equipable_slots type="list">left_hand;right_hand</equipable_slots>
</type>
<type name="sword">
</type>
<type name="axe">
</type>
<type name="blunt">
</type>
<type name="spear">
<inherit name="two_handed" />
</type>
<type name="staff">
<inherit name="two_handed" />
</type>
<type name="dagger">
<inherit name="one_handed" />
</type>
<type name="whip">
<inherit name="one_handed" />
</type>
<type name="bow">
<inherit name="two_handed" />
</type>
<type name="crossbow">
<inherit name="two_handed" />
</type>
<type name="gun">
</type>
<type name="throwing">
</type>
<type name="armor">
<inherit name="gear" />
<pr type="int">0</pr>
</type>
<type name="shield">
<inherit name="armor" />
<equipable_slots type="list">left_hand</equipable_slots>
</type>
<type name="clothing">
<inherit name="gear" />
</type>
<type name="headwear">
<equipable_slots type="list">head</equipable_slots>
</type>
<type name="facewear">
<inherit name="clothing" />
<equipable_slots type="list">face</equipable_slots>
</type>
<type name="earwear">
<inherit name="clothing" />
<equipable_slots type="list">ear</equipable_slots>
</type>
<type name="neckwear">
<inherit name="clothing" />
<equipable_slots type="list">neck</equipable_slots>
</type>
<type name="shoulderwear">
<inherit name="armor" />
<equipable_slots type="list">shoulder</equipable_slots>
</type>
<type name="armwear">
<equipable_slots type="list">arm</equipable_slots>
</type>
<type name="handwear">
<equipable_slots type="list">hand</equipable_slots>
</type>
<type name="fingerwear">
<inherit name="clothing" />
<equipable_slots type="list">finger</equipable_slots>
</type>
<type name="chestwear">
<equipable_slots type="list">chest</equipable_slots>
</type>
<type name="backwear">
<inherit name="clothing" />
<equipable_slots type="list">back</equipable_slots>
</type>
<type name="waistwear">
<equipable_slots type="list">waist</equipable_slots>
</type>
<type name="legwear">
<equipable_slots type="list">leg</equipable_slots>
</type>
<type name="footwear">
<equipable_slots type="list">foot</equipable_slots>
</type>
<type name="arrow">
<cur_arrow type="int">0</cur_arrow>
</type>
<type name="arrow_case">
<inherit name="backwear" />
<max_arrow type="int">0</max_arrow>
</type>
<type name="bolt">
<cur_bolt type="int">0</cur_bolt>
</type>
<type name="bolt_case">
<inherit name="backwear" />
<max_bolt type="int">0</max_bolt>
</type>
<type name="bullet">
<cur_bullet type="int">0</cur_bullet>
</type>
<type name="bullet_case">
<inherit name="backwear" />
<max_bullet type="int">0</max_bullet>
</type>
<type name="spell">
<drop type="boolean">false</drop>
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
</type>
<type name="fire">
</type>
<type name="water">
</type>
<type name="air">
</type>
<type name="earth">
</type>
<type name="light">
</type>
<type name="dark">
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="sa">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
game.pov.arrows = game.pov.cur_arrow + " / " + game.pov.max_arrow
game.pov.bolts = game.pov.cur_bolt + " / " + game.pov.max_bolt
game.pov.bullets = game.pov.cur_bullet + " / " + game.pov.max_bullet
game.pov.shurikens = game.pov.cur_shuriken + " / " + game.pov.max_shuriken
game.pov.javelins = game.pov.cur_javelin + " / " + game.pov.max_javelin
game.pov.throwing_axes = game.pov.cur_throwing_axe + " / " + game.pov.max_throwing_axe
game.pov.throwing_knives = game.pov.cur_throwing_knife + " / " + game.pov.max_throwing_knife
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
first_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
first_value = false
}
else if (not Doesinherit (enemy,"npc")) {
msg ("You can not battle that!")
first_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
first_value = false
}
else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
first_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
first_value = false
}
else if (battle_sequence (self,enemy) = true) {
msg ("The battle is over.")
first_value = true
}
return (first_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
return (true)
}
}
on ready {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
return (true)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
return (true)
}
}
on ready {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
return (true)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
}
]]></function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (self.alias + " has " + self.cur_mp + " MP left.")
msg (" ")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
second_value = false
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
second_value = true
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
second_value = true
}
else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
second_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
second_value = true
}
else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
second_value = true
}
else if (second_value = false) {
if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
}
}
case ("Defend") {
if (self.defending = false) {
self.defending = true
}
}
case ("Cast") {
self.defending = false
}
case ("Item") {
self.defending = false
}
case ("Run") {
self.defending = false
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn
}
else {
msg ("Your battle turn is over.")
return (false)
}
}
else if (GetInt (enemy,"cur_hp") <= 0) {
msg (enemy.alias + " is dead.")
msg ("You have won the battle!")
enemy.defending = false
enemy.dead = true
return (true)
}
}
}
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (self.alias + " has " + self.cur_mp + " MP left.")
msg (" ")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
msg (" ")
result = GetRandomInt (1,3)
switch (result) {
case (1) {
third_value = false
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
third_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
third_value = true
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
third_value = true
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
third_value = true
}
else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
msg ("You resisted the attack!")
third_value = true
}
else if (third_value = false) {
if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
}
}
case (2) {
if (enemy.defending = false) {
msg (enemy.alias + " has choosen to defend itself.")
enemy.defending = true
}
}
case (3) {
enemy.defending = false
// (Cast)
}
}
if (GetInt (self,"cur_hp") > 0) {
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
msg (enemy.alias + " gets an extra battle turn!")
enemy_battle_turn
}
else {
msg (enemy.alias + " 's battle turn is over.")
return (true)
}
}
else if (GetInt (self,"cur_hp") <= 0) {
msg (self.alias + " has died.")
msg ("GAME OVER")
finish
}
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>


I'll keep trying, but right now, I need help with fixing up the rest of this code, I think I'm close, but I can't figure out these last problems I have, at least at this moment I can't, so any help would be greatly appreciated !!!

HegemonKhan
.
.
Veni, Vidi, Vici !!! (I came, I saw, I CONQUERED !!!!)
.
.
HK's functional combat system:

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc" />
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">100</str>
<end type="int">100</end>
<dex type="int">100</dex>
<agi type="int">100</agi>
<spd type="int">100</spd>
<hc type="int">100</hc>
<pd type="int">100</pd>
<pr type="int">100</pr>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc" />
<hostile type="boolean">true</hostile>
<dead type="boolean">false</dead>
<alias>orc</alias>
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">25</str>
<end type="int">25</end>
<dex type="int">25</dex>
<agi type="int">25</agi>
<spd type="int">25</spd>
<hc type="int">25</hc>
<pd type="int">25</pd>
<pr type="int">25</pr>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
sa
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<hp type="int">0</hp>
<hc type="int">0</hc>
<pd type="int">0</pd>
<pr type="int">0</pr>
</type>
<type name="pc">
<inherit name="char" />
<statusattributes type="stringdictionary">hp = ;str = ;end = ;dex = ;agi = ;spd = ;hc = ;pd = ;pr = </statusattributes>
</type>
<type name="npc">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="sa">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
</function>
<function name="battle_system" parameters="self,text" type="boolean">
first_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
first_value = false
}
else if (not Doesinherit (enemy,"npc")) {
msg ("You can not battle that!")
first_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
first_value = false
}
else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
first_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
first_value = false
}
else if (battle_sequence (self,enemy) = true) {
msg ("The battle is over.")
first_value = true
}
return (first_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
second_value = false
if (enemy.dead = false) {
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy.dead = false) {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
}
}
else {
second_value = true
}
return (second_value)
]]></function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
third_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
fourth_value = false
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
fourth_value = true
}
else if (fourth_value = false) {
if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
}
}
case ("Defend") {
if (self.defending = false) {
self.defending = true
}
}
case ("Cast") {
self.defending = false
}
case ("Item") {
self.defending = false
}
case ("Run") {
self.defending = false
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn (self,enemy)
}
else {
msg ("Your battle turn is over.")
third_value = false
}
}
else if (GetInt (enemy,"cur_hp") <= 0) {
msg (enemy.alias + " is dead.")
msg ("You have won the battle!")
enemy.defending = false
enemy.dead = true
third_value = true
wait {
ClearScreen
}
}
}
}
return (third_value)
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
fifth_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
result = GetRandomInt (1,3)
switch (result) {
case (1) {
sixth_value = false
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
msg ("You resisted the attack!")
sixth_value = true
}
else if (sixth_value = false) {
if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
}
}
case (2) {
if (enemy.defending = false) {
msg (enemy.alias + " has choosen to defend itself.")
enemy.defending = true
}
}
case (3) {
enemy.defending = false
msg ("Cast")
}
}
if (GetInt (self,"cur_hp") > 0) {
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
msg (enemy.alias + " gets an extra battle turn!")
wait {
enemy_battle_turn (self,enemy)
}
}
else {
msg (enemy.alias + " 's battle turn is over.")
fifth_value = true
}
}
else if (GetInt (self,"cur_hp") <= 0) {
msg (self.alias + " has died.")
msg ("GAME OVER")
finish
}
return (fifth_value)
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>


-------

@Pertex (and anyone),

copy and paste my code, and try it out, hehe, it works, hehe :D

Pertex
Congratulations!!
So now it's time to examine your code and try some refactoring. Here is a version of your game where I removed the type of the functions and the return values. They are not really necessary. Then I have redone your battle_sequence function. It's a bit shorter now :D
If you look at the functions self_battle_turn and enemy_battle_turn (I did not change there anything) you can see, that most of the code is the same. So you could create a new function for the duplicated code and call it from both functions.

HegemonKhan
thanks Pertex!

yep, I need to streamline my code (though just getting it functional was a huge triumph for me, hehe) now. I want to try to do it myself as much as I can, as it is good practice for me, to try to see, understand, and come up with better ways of doing the code, but if I need help, I'll take a look at what you've done. Thank you for doing so! But, I want to work on learning to do so myself, so you don't have to do so for me, hehe. Also, as I learn to do coding better (more efficiently and shorter), that helps for all and any type of coding, as I'm understanding the coding process better by learning to code better. Seeing ways of doing coding that I hadn't seen when I was just trying to put the code together for it to be functional.

though, right now, I'm sick, we've got a flu epidemic across the U.S., and now I've got it too, argh!

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

a quick legend/key for some of my abbreviations, for anyone who is interested, for my code (I was just trying to do the code, so I haven't really made it that followable, like a library, to help others out. I'm still working on it too, as I got more to add and implement, once I learn how to do so. Once, I get it all done, I'll make it into a good library for everyone to use and understand)

(these are just preliminary abbrevs, as how to name things is a decision process unto itself, lol. keeping them short as possible, while still knowing that they mean, while not confusing people, or having the same name problem, lol)

01. cc = character creation function
02. sa = status attributes (mainly for implementing/displaying of ' cur / max ' stats) function
03. char = character object type ("pcs", "npcs", "monsters", etc., so, not a room, item, equipment, spell, etc)
04. pc = playable character object type ("player" characters / game.povs)
05. npc = non-playable character ("people", "monsters", and etc, so not a "player" character / not a game.pov, I'm going to have a hostility system, so any npc can be friendly or hostile, instead of having an actual "monster/enemy" type set aside)
06. hp = hit points (life) stat attribute
07. mp = mana points (magic) stat attribute
08. str = strength (physical damage, carry weight / equipment requirement, etc) stat attribute
09. end = endurance (physical defense, and etc) stat attribute
10. dex = dexterity (weapon~attack skill, think of this as "if your attack connects or not, do you 'whiff' or not", so not to gete confused with hc, and etc) stat attribute
11. agi = agility (dodging/evading, and etc) stat attribute
12. spd = speed (who goes first in battle, extra battle turns, escaping from battle, and etc) stat attribute
13. hc = hit chance (think of this more as piercing their armor or not, so not to get confused with dex, and etc) stat attribute
14. pd = physical damage stat attribute
15. fp = fire damage stat attribute
16. wp = water damage stat attribute
17. ap = air damage stat attribute
18. ed = earth damage stat attribute
19. ld = light damage stat attribute
20. dd = dark damage stat attribute
21. pr = physical resistance stat attribute
22. fr = fire resistance stat attribute
23. wr = water resistance stat attribute
24. ar = air resistance stat attribute
25. er = earth resistance stat attribute
26. lr = light resistance stat attribute
27. dr = dark resistance stat attribute
28. defending = boolean (reduces damage done for that character and increases the damage done by that character, if they chosoe to attack on the next turn)
29. escaped = boolean, run from battle (not completed/implemented yet)
30. hostile = boolean, any npc can be friendly or a(n) "monster/enemy", based upon a hostility scale (0-100), but not completed
31. dead = boolean
32. crit_hit = critical hit (bonus damage based upon luck)
33. luck = luck stat attribute
34. lvl = level stat attribute
35. exp = experience stat attribute
36. cash = cash stat attribute (currency)
37. lvlup = level up function

HegemonKhan
.
.
Some quick questions on using dictionaries (or if I need to be using the Lists Instead) and about some other stuff too:

I'm not still entirely clear on using dictionaries (do I need to use lists instead?), especially script dictionaries (if these are even the correct usage for what I want to do below), so if you guys~girls could just check these attempts of mine, letting me know if it'll work this way or not, and also, I don't know how to write out the item~script part of~for the syntax~format for a script dictionary, either.

if you guys~girls could just check over me code, telling me if it'll work or not, looking for any problems, and~or help explain how to do things correctly too.

~Thank You, HK.

<library>
<!-- Commands -->

<command name="help_command">
<pattern>help</pattern>
<script>
help_function
</script>
</command>

<command name="statistics_command">
<pattern>stats</pattern>
<script>
statistics_function
</script>
</command>

<command name="explore_command">
<pattern>explore</pattern>
<script>
explore_function
</script>
</command>

<command name="travel_command">
<pattern>goto</pattern>
<script>
travel_function
</script>
</command>

<command name="storage_command">
<pattern>storage</pattern>
<script>
storage_function
</script>
</command>

<command name="equipment_command">
<pattern>gear</pattern>
<script>
equipment_function
</script>
</command>

<!-- Functions -->

<function name="help_function">
</function>

<function name="statistics_function">
</function>

<function name="explore_function">
switch (game.pov.parent) {
case ("homeland") {
if (firsttime) {
ScriptDictionaryItem (dictionary_structures.homeland_events_script_dictionary,"homeland_discovery")
} otherwise {
ScriptDictionaryItem (dictionary_structures.homeland_events_script_dictionary,GetRandomInt(1,max_value))
}
}
}
</function>

<function name="travel_function">
show menu ("Where do you wish to travel?",dictionary_structures.travel_script_dictionary,true) {
ScriptDictionaryItem (dictionary_structures.travel_script_dictionary,result)
}
</function>

<function name="storage_function">
</function>

<function name="equipment_function">
</function>

<function name="travel_script_dictionary_function"><![CDATA[
if (boolean_structures.homeland_discovered = true) {
dictionary add (dictionary_structures.travel_script_dictionary,"homeland", etc etc and script (if (game.pov.parent <> homeland) then script (game.pov.parent = homeland))
}
]]></function>

<function name="game_turns_function">
game.turns = game.turns + 1
</function>

<!-- Turnscripts -->

<turnscript name="game_turns_turnscript">
travel_script_dictionary_function
game_turns_function
</turnscript>

<!-- Object Structures (Data Storage) -->

<object name="dictionary_structures">
<parent>null</parent>
<travel_script_dictionary type="scriptdictionary">
<item key="homeland"><![CDATA[
if (game.pov.parent = homeland) {
msg ("You are already here at the homeland! Try again.")
wait {
travel_function
}
} else if (game.pov.parent <> homeland) {
game.pov.parent = homeland
]]></item>
</travel_script_dictionary>
<homeland_events_script_dictionary type="scriptdictionary">
<item key="homeland_discovery">
boolean_structures.homeland_discovered = true
msg ("You've discovered the homeland! Now, you can truly explore, and also travel to, the homeland!")
</item>
</homeland_events_script_dictionary>
</object>
</library>

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