|
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Mariel
Joined: 15 Oct 2008 Posts: 78 Location: In your dreams
|
Posted: Wed Aug 26, 2009 11:23 pm Post subject: Muddling around with a leveling system |
|
|
Okay so maybe the answer is obvious and I'm missing it because it is three a.m. and I am not totally conscious but also I am new to scripting so maybe my technique just sucks ANYWAY
I'm trying to write an after-battle script that will check the character's gained levels (if any), multiply them by five, and add them to the Ctr stat.
Here it is thus far:
Code: | Plotscript, levelCheck, begin
variable (who)
who :=(hero by slot(0)) #Finds first hero
variable (levels)
levels :=(herolevelled (who)) #Returns first hero new levels
variable (current)
current := get hero stat (who,9,current stat) #Finds existing Ctr stat
variable (growth)
growth :=(current + (levels * 5)) #Totals new Ctr points
set hero stat (who,9,growth,current stat)
end |
now, the test character has 0 Ctr stat to start with. After a fight in which it levels once, the Ctr stat now equals 15. Also, no additional fighting raises it further. Clearly, I hath failed somewhere. Anyone care to tell me where?
(9 = Ctr stat) _________________ "I think civility flew out the window the second I found the lawnmower. With dignity and humanity splattered on the walls." |
|
Back to top |
|
|
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner
Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Wed Aug 26, 2009 11:41 pm Post subject: |
|
|
This may not be your real problem, but you don't want hero by slot. Just use the number 0. _________________
|
|
Back to top |
|
|
Mariel
Joined: 15 Oct 2008 Posts: 78 Location: In your dreams
|
Posted: Thu Aug 27, 2009 5:04 am Post subject: |
|
|
Thanks! That was helpful. Apparently I also needed an append number command in there, it's working now.
Edit: Argh, just kidding.
Okay, it looks like this now:
Code: | Plotscript, levelCheck, begin
variable (levels)
levels :=append number(levels,herolevelled (0)) #Returns first hero new levels
variable (current)
current :=append number(current,get hero stat (0,9,current stat)) #Finds existing Ctr stat
variable (rise)
rise :=append number(rise,levels * 5)
variable (growth)
growth :=(rise + current) #Totals new Ctr points
If (levels >> 0) then(
set hero stat (0,9,growth,current stat))
end
|
The monster I am testing this on gives about thirty seven experience points.
So, when the character levels once, it gets five ctr. One battle later, and the Ctr is at twelve. With one more battle it levels a second time and ends up with twenty ctr. With another battle, the ctr was at 30.
This is very confusing. I did not think I was trying to do a difficult thing. :[ _________________ "I think civility flew out the window the second I found the lawnmower. With dignity and humanity splattered on the walls." |
|
Back to top |
|
|
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Aug 27, 2009 7:38 am Post subject: |
|
|
Whoa, append number is completely wrong. It acts on plotstrings. Anyway, going back to your nearly correct original script:
Using 0 as the slot is open to problems too. All those commands expect a slot number, but the player could place the leader into any of the slots 0-3. The correct way to find the slot of the leader of your party is find hero(hero by rank (0)). But usually won't need to write this, because you're checking all the heroes in the party, or something like that.
You need to set both the current stat and maximum stat to the same value. For stats other than HP and MP, the current stat is the value that you see on the status screen and that applies when you go into battle, but it's reset to the maximum value after battle or on level up.
Use less brackets, they make your script much harder to read. It's also messy to use so many unnecessary temporary variables; it looks like assembly code!
I recommend using stat:ctr instead of '9'. You'll haven't to export an .hsi file form your game and include it at the top of your script file.
I don't know why you saw 15 instead of 5; my guess is that you specified an invalid hero and got garbage. _________________ "It is so great it is insanely great." |
|
Back to top |
|
|
Mariel
Joined: 15 Oct 2008 Posts: 78 Location: In your dreams
|
Posted: Thu Aug 27, 2009 9:00 am Post subject: |
|
|
How would I set current stat and maximum stat to the same value? I must admit I do not entirely understand the difference between them. The both have the same definition in the plotscripting dictionary so I don't know when to use either of them.
Thank you for your advice though. I do have an Hsi file, but since I was thinking of changing the name of the Ctr stat and I wasn't sure what I would change it to, I thought it best to use the number instead so I don't have to change my scripts afterwards.
Once I got the script to work I was going to have it run four times, one for each hero slot.
I know it's still messy, but here is what it is right now:
Code: | Plotscript, levelCheck, begin
if (herolevelled (0)), then (
variable (levels)
levels :=append number(levels,herolevelled (0)) #Returns first hero new levels
variable (current)
current :=(get hero stat (0,9,current stat)) #Finds existing Ctr stat
variable (rise)
rise :=append number(rise,levels * 5)
variable (growth)
growth :=(rise + current) #Totals new Ctr points
set hero stat (0,9,growth,current stat))
end |
Having an if statement seems to fix some of my problems. I admit I don't completely understand what the append number command does, but it won't work without it.
At the moment, the script works fine except for when a character goes up two levels in the same battle. It is supposed to give them ten Ctr points but still only gives them five.
I know I look completely noobish, but I'm self-teaching with trial and error here so I really appreciate any advice. _________________ "I think civility flew out the window the second I found the lawnmower. With dignity and humanity splattered on the walls." |
|
Back to top |
|
|
Bob the Hamster OHRRPGCE Developer
Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Thu Aug 27, 2009 9:35 am Post subject: |
|
|
Mariel wrote: | How would I set current stat and maximum stat to the same value? I must admit I do not entirely understand the difference between them. The both have the same definition in the plotscripting dictionary so I don't know when to use either of them. |
For HP and MP, the difference between current and max is obvious. For other stats, current is what actually gets used. max is what current gets reset to after each battle.
To make things easier, you might want to add a helper script like this:
Code: |
script, set both stats, who, stat, value, begin
set hero stat (who, stat, value, current stat)
set hero stat (who, stat, value, maximum stat)
end
|
Mariel wrote: |
Code: | Plotscript, levelCheck, begin
if (herolevelled (0)), then (
variable (levels)
levels :=append number(levels,herolevelled (0)) #Returns first hero new levels
variable (current)
current :=(get hero stat (0,9,current stat)) #Finds existing Ctr stat
variable (rise)
rise :=append number(rise,levels * 5)
variable (growth)
growth :=(rise + current) #Totals new Ctr points
set hero stat (0,9,growth,current stat))
end |
Having an if statement seems to fix some of my problems. I admit I don't completely understand what the append number command does, but it won't work without it.
|
Very important! As TMC said, you do not want to use append number here at all. not at all! it is only used for building strings that visually represent numbers. it is never used for anything else.
Here is what is happening:
Code: |
rise :=append number(rise,levels * 5)
|
levels is multiplied by 5
that number is converted into a string and appended to whichever string ID happens to be the same as the value rise
the append number function returns zero, which is assigned into rise.
That is not what you want to do, and if it appears to be working sometimes, that is just an accident.
Mariel wrote: | I know I look completely noobish, but I'm self-teaching with trial and error here so I really appreciate any advice. |
No worries, trial and error is a good way to learn, and we are glad to help :)
Here is how I think I would write the script to do what you are trying to do.
Code: |
Plotscript, levelCheck, begin
variable(hero)
variable (levels)
variable (current)
variable (rise)
variable (growth)
for(hero, 0, 3) do(
if(hero by slot(hero) >> -1) then ( # only do this if a hero exists in this slot
if (herolevelled (hero)), then (
levels := herolevelled (hero)
current := get hero stat (hero, 9, current stat) #Finds existing Ctr stat
rise := levels * 5
growth := rise + current #Totals new Ctr points
set both stats (hero, 9, growth)
)
)
)
end
script, set both stats, who, stat, value, begin
set hero stat (who, stat, value, current stat)
set hero stat (who, stat, value, maximum stat)
end
|
I realize I need to fix the documentation for herolevelled(), because it currently makes you think that you need to use "find hero", when really it should just say that it needs the hero's position in the battle party. |
|
Back to top |
|
|
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Thu Aug 27, 2009 9:54 am Post subject: |
|
|
Okay, James posted that while I was thinking about how to reply, so hopefully that cleared stuff up. The one thing I still want to add is that, when thinking about the difference between "current" and "maximum" stat, it might be helpful to think of it this way:
"Maximum" stats are like permanent, 'true' stats, and the OHR assumes that all non-HP/non-MP stats should be restored to their permanent, 'true' values after every battle. Then on level-ups, the 'true', permanent stat is increased.
On the other hand, "current" stats are like temporary, 'affected' stats, and the OHR assumes that such a stat should be used for the upcoming battle, but should be restored to its 'true' value afterwards.
Thus, if you want temporary effects on a stat, you should alter the current stat. If you want permanent effects, you need to alter the maximum stat. In this sense, it works a lot like HP and MP. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
|
Mariel
Joined: 15 Oct 2008 Posts: 78 Location: In your dreams
|
Posted: Fri Aug 28, 2009 6:38 am Post subject: |
|
|
Thank you so much, both of you. I understand it a lot better now. I see what I was doing wrong.
I wish there was some place I could find the definitions of certain phrases.. the plotscripting dictionary is wonderful, but it assumes that you know certain 'duh' things, like what the difference between current and max stats, or what a menu handle is... and it's not like you can put them in google to find out, all you get is gamer scores and hardware stores. _________________ "I think civility flew out the window the second I found the lawnmower. With dignity and humanity splattered on the walls." |
|
Back to top |
|
|
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Fri Aug 28, 2009 7:24 am Post subject: |
|
|
Just ask here! I remember now that you had some issues with 'append number'. If you found that last bit helpful, I'll also mention a bit about the difference between strings and variables.
A variable is a slot that will store a number. You can give the slot an easy-to-understand name, like 'growth', to refer to it by. But if you want growth to represent a number, you cannot do "growth:=anything involving strings", because strings are not numbers. Unfortunately, Hspeak won't stop you from doing so (maybe it should have a warning for expected data inconsistencies? But how would it know?)
A string is a word/text that can be shown visually on the screen. That's all that it can do. Unfortunately, there are two easily confusable issues here. The first is that text can have numbers in it. That's what 'append number' is for, so you can make text like "I am on level 53". In that string, the 53 is not helpful for any math (there is no command to take that string and multiply the 53 by something, for example). It is just a visual representation, nothing more.
The other issue with strings is that they also have to be given names so we can refer to them in a script, but we don't give them 'word' names like "growth". We give them numbers (in the plotscript dictionary, these are the String IDs). So yeah, variables get word names to store numbers, and strings get number names to store words. Isn't it grand?
I'll post something about handles in a moment. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
|
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Fri Aug 28, 2009 7:55 am Post subject: |
|
|
Honestly, I'm not sure why they use the word 'handle' for menu handles. If you are familiar with how NPC references work, a menu handle is basically just a 'menu reference'.
Basically, the issue is that if we want scripts to do things to menues (or heroes, or npcs, or anything), then the things have to have a name. Unfortunately, the name can't be the name or ID of the thing in custom, because want if you want to have two copies of the same menu on the screen? (or two of the same-name hero in the party, or two copies of an NPC, and so on...)
To fix this problem, all 'things' that plotscripting can affect are given special inner-game names on the fly. These names are really numbers, since a computer thinks with numbers instead of words. The name-number of a menu that is open is called its 'menu handle'. The name-number of an NPC that is on the current map somewhere is called its 'NPC Reference'. Heroes are a special case, which I'll discuss below.
If we want scripts to be able to affect things, they have to know the name-number of what they're affecting. That's why lots of commands say you have to give them a menu handle, or an NPC reference. On the other hand, the author also needs to be able to find out what the name-number of something is if he wants to affect it, so there are lots of commands that return handles and references. Since the name-number is, in fact, a number, it is usually best to store it in a nicely named variable:
Code: | variable(my great menu)
my great menu:=some command that returns a menu handle for an active menu
#now the variable 'my great menu' is storing the name-number of an active menu
close menu(my great menu)
|
One thing about these name-numbers. To prevent the computer from thinking too hard, once you 'deactivate' something (destroy an NPC, close a menu, etc), the computer forgets about its name-number. So if you close a menu and then reopen it right away, it will very likely have a different menu handle. So you will need a command to get the menu handle and store it in a variable again.
Finally, heroes. Since the player is only allowed to have 60 total heroes at any given time (4 in the active party, 56 in the 'reserve'), rather than come up with name-numbers for all of them, the computer just affects them based on their slot (60 slots, 0-59), since no two heroes can be in the same slot at once. So a hero's slot is its name-number. But since the player is free to mess with what heroes are in what slots, we need the command 'find hero' to find out what slot the player has put a hero in. The confusion becomes even worse when we consider that the player is allowed to leave slots empty. For example, if the player put their heroes in slots 0,1,3 (leaving slot 2 empty), there is the potential for trouble when trying to affect heroes. And so we have commands like 'rank in caterpillar' to figure out if the hero third in line on screen is actually in the fourth slot (slot 3).
I hope some of that was helpful, either to you or others reading. Some of the developers were discussing trying to better document the issues regarding hero names/slots/places in line on screen, so hopefully the wiki will continue to improve on explaining these things. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
|
Bob the Hamster OHRRPGCE Developer
Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Aug 28, 2009 8:06 am Post subject: |
|
|
You have struck on an important reason why plotscripting can be so confusing. The command names and their documentation can be pretty inconsistent about how things are named.
handles and references are a great example. They are both the same concept, but for menus and slices, they are usually called "handles" and for NPCs they are called "references".
But there are other places, like the ways of referring to heroes, where different terms are used, and they actually are different in important ways. For example, hero ID, hero party position, and hero caterpillar position are all very different things, and mixing them can produce unexpected results... but to add to the confusion, sometimes I call "party position" "battle slot", or I call "caterpillar position" "walkabout position".
The vocabulary is tangled. |
|
Back to top |
|
|
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Fri Aug 28, 2009 8:13 am Post subject: |
|
|
Clearly, my terminology (name-number) is superior to all of your cryptically opaque nomenclatures.
Haha, I'm actually pretty happy with that explanation for being written in one go. Maybe instead of writing rediculously stuffy theoretical BS for Hamsterspeak I ought to try and start a series on 'plotscripting explanations for newbies' and actually clean up explanations like those for publication. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
|
Bob the Hamster OHRRPGCE Developer
Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Aug 28, 2009 11:34 am Post subject: |
|
|
msw188 wrote: | Clearly, my terminology (name-number) is superior to all of your cryptically opaque nomenclatures.
Haha, I'm actually pretty happy with that explanation for being written in one go. Maybe instead of writing rediculously stuffy theoretical BS for Hamsterspeak I ought to try and start a series on 'plotscripting explanations for newbies' and actually clean up explanations like those for publication. |
...and after publication, put them on the Wiki too :)
I am currently working on 'Ways to refer to a hero in a script' |
|
Back to top |
|
|
Pepsi Ranger Reality TV Host
Joined: 05 Feb 2003 Posts: 493 Location: South Florida
|
Posted: Sat Aug 29, 2009 10:02 am Post subject: |
|
|
msw188 wrote: | Haha, I'm actually pretty happy with that explanation for being written in one go. Maybe instead of writing rediculously stuffy theoretical BS for Hamsterspeak I ought to try and start a series on 'plotscripting explanations for newbies' and actually clean up explanations like those for publication. |
Just a reminder, this topic was already started a couple years ago. I'd love to see it finished someday...hint hint.
http://www.castleparadox.com/ohr/viewtopic.php?t=5628 _________________ Progress Report:
The Adventures of Powerstick Man: Extended Edition
Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.
Tightfloss Maiden
Currently Updating: Chapter 2 |
|
Back to top |
|
|
Mariel
Joined: 15 Oct 2008 Posts: 78 Location: In your dreams
|
Posted: Sun Aug 30, 2009 9:10 pm Post subject: |
|
|
msw188 wrote: | ... I ought to try and start a series on 'plotscripting explanations for newbies' and actually clean up explanations like those for publication. |
Yes, yes please.
Everything you've said has been extremely helpful. Plotscripting is really interesting to me, but I feel like I've been handed a box full of new tools and a little list that says what they do... but not how to make them do it. I'm trying hard to learn, sifting through old help topics and reading the dictionary. I was going to check the old HamsterSpeaks next. For someone coming into this cold, with very little programming experience, it's very confusing.
I want to work on custom menus for my game, but the handles were tripping me up. I understand them a little better now, after your post. Do you guys know of any games with complex menu systems that provide the .txt of the scripts as well? I'd like to study them. I learned a lot by reading through the vikings scripts but that was mostly moving the characters around for cutscenes, no menu stuff. _________________ "I think civility flew out the window the second I found the lawnmower. With dignity and humanity splattered on the walls." |
|
Back to top |
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|