Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Skills increasing with practice?

Hi, everybody! New user here, and I have a question--I couldn't dig this up via search, although there may be a very simple way to do it and it's just using different terms than I'm searching for!

Ok, so long ago and far away--by which I mean last year--I started building a game with the StoryNexus engine. It was neat, I had fun, the company then had to scale back on development and all my friends recommended trying again with Twine.

And so far I'm loving it, and it can do very neat things and I'm excited!

One thing, however, that I'm still trying to work out, is how to increase skills with practice--or rather, how to do it elegantly.

Say my character is a hunter and has the Hunter skill, which I've set as the variable $hunter and which is displayed on the sidebar via StoryMenu.

The obvious way to do this is to just increase the Hunter skill by one point every time he hunts something, using <<set $hunter += 1>>

But this rapidly gets to be a very large number. Spend a little time poking mammoths with a stick and you've got a skill in the 50s...and then I have no way of differentiating between poking hamsters and poking mammoths.

My first thought is to introduce a second variable, something like $hunter_skill, say. So you poke your hamster and $hunter_skill increases by 1, poke a mammoth and it increases by 10, and when said skill hits 10 (or whatever) it increases $hunter by 1, which duly shows up on the sidebar, and resets $hunter_skill to 0.

And furthermore, if I have poked a dozen hamsters, I figure I should derive no more benefit from hamster poking, so presumably I would use an IF statement using the visited() command to remove all increase of skill once we have crossed this grim hamster-strewn horizon.

This all seems a little unwieldy, but I guess I could make it work. But is there a more elegant way?

Perhaps each creature gets a difficulty, and work out a set of code that assigns increases based on the relation of the $hunter skill to the difficulty? (i.e. a hamster is 5 points below your skill level, so no increase for you, but the rare Polar Vortex Lungfish is 20 points higher, so you get a big increase if you win?)

Anyway, advice very much requested--I'm an illustrator, not a programmer!

Comments

  • I think you're on the right track. I don't see any reason you couldn't do it just the way you've outlined. If you want to streamline your code a little bit, you might consider using arrays to organize your variables. Sharpe has a great little tutorial about that here: http://twinery.org/forum/index.php/topic,1516.0.html

    He calls them Javascript objects, I know them as arrays, but anyways, they're like container variables with a set of variables inside. It's a way to organize variables pertaining to a single person/object/idea under an umbrella structure/name.

    They're not necessary by any means, but for the kind of game you seem to be writing I would imagine they would probably be of use.

    Here's another great tutorial on the topic as well: http://www.glorioustrainwrecks.com/node/5034
  • Sounds like a cool game!

    You'll really want to use JavaScript objects for this. See a guide I wrote here: Objects are Your Friends: How & Why to Use JavaScript Objects for Total Newbies

    You'll want something like this for your hunter player character:
    <<set $hunter = {
    skill: 0,
    }>>
    To add to his skill, you can use:
    <<set $hunter.skill += 1>>
    From there, if you don''t want to increase in "level" or whatever each time you add to the skill, you can set a conditional branch to only "level up" after the $hunter.skill object property reaches a certain value. Let's add another property to the object, something like this:
    <<set $hunter = {
    skill: 0,
    level: 1,
    }>>
    Then, you can "level up" kinda like this:
    <<if $hunter.skill gte 200 and $hunter.skill lt 300>>

    <<set $hunter.level = 2>>

    <<elseif $hunter.skill gte 300 and $hunter.skill lt 400>>

    <<set $hunter.level = 3>>

    <<elseif $hunter.skill gte 400 and $hunter.skill lt 500>>

    <<set $hunter.level = 4>>

    etc., etc., etc.,

    <<else>>

    set max level

    <<endif>>
    You would run that code after every kill, probably. It will increase the $hunter object's level each 100 points that are added to $hunter.skill.

    Here's my own pre-alpha RPG "level up" code that I <<display>> after each monster is killed (with the "nobr" tag no quotes on the passage so there's not a huge span of white space!):
    <<if $player.XP gte 100 and $player.XP lt 300>>

    <<if $fanfare2 eq 0>>
    <<set $fanfare2 = 1>>
    Congratulations!<br>
    You have reached level 2!<br><br>
    You have learned a new spell: "Heal!"<br><br>
    <<set $player.level = 2>>
    <<set $player.attack = 2>>
    <<set $player.damage = 2>>
    <<set $player.maxHP = 55>>
    <<set $player.maxMP = 12>>
    <<set $player.levelUp = 300>>
    <<endif>>

    <<elseif $player.XP gte 300 and $player.XP lt 700>>

    <<if $fanfare3 eq 0>>
    <<set $fanfare3 = 1>>
    Congratulations!<br>
    You have reached level 3!<br><br>
    <<set $player.level = 3>>
    <<set $player.attack = 4>>
    <<set $player.damage = 4>>
    <<set $player.maxHP = 60>>
    <<set $player.maxMP = 14>>
    <<set $player.levelUp = 700>>
    <<endif>>

    <<elseif $player.XP gte 700 and $player.XP lt 1500>>

    <<if $fanfare4 eq 0>>
    <<set $fanfare4 = 1>>
    Congratulations!<br>
    You have reached level 4!<br><br>
    You have learned a new spell: "Fireball!"<br><br>
    <<set $player.level = 4>>
    <<set $player.attack = 6>>
    <<set $player.damage = 6>>
    <<set $player.maxHP = 65>>
    <<set $player.maxMP = 16>>
    <<set $player.levelUp = 1500>>
    <<endif>>

    <<elseif $player.XP gte 1500 and $player.XP lt 3100>>

    <<if $fanfare5 eq 0>>
    <<set $fanfare5 = 1>>
    Congratulations!<br>
    You have reached level 5!<br><br>
    <<set $player.level = 5>>
    <<set $player.attack = 8>>
    <<set $player.damage = 8>>
    <<set $player.maxHP = 70>>
    <<set $player.maxMP = 18>>
    <<set $player.levelUp = 3100>>
    <<endif>>

    <<elseif $player.XP gte 3100 and $player.XP lt 6300>>

    <<if $fanfare6 eq 0>>
    <<set $fanfare6 = 1>>
    Congratulations!<br>
    You have reached level 6!<br><br>
    <<set $player.level = 6>>
    <<set $player.attack = 10>>
    <<set $player.damage = 10>>
    <<set $player.maxHP = 75>>
    <<set $player.maxMP = 20>>
    <<set $player.levelUp = 6300>>
    <<endif>>

    <<elseif $player.XP gte 6300>>

    <<if $fanfare7 eq 0>>
    <<set $fanfare7 = 1>>
    Congratulations!<br>
    You have reached level 7!<br><br>
    <<set $player.level = 7>>
    <<set $player.attack = 12>>
    <<set $player.damage = 12>>
    <<set $player.maxHP = 80>>
    <<set $player.maxMP = 22>>
    <<set $player.levelUp = "MAX">>
    <<endif>>

    <<endif>>
    Hope that helps! :)

    However, before asking a question about JS objects, please read the guide first. You'd think I wouldn't have to say that, but . . . ;)
  • Looper ninja'ed me. ;)
  • loopernow wrote:
    He calls them Javascript objects, I know them as arrays, but anyways, they're like container variables with a set of variables inside.


    Looper, the way I understand it, and I could very well be wrong, but you'll notice the Glorious Trainwreck's seems to agree, the difference between what L in that link calls arrays and what I am calling an object is pretty substantial.

    This is what the GT link you gave calls an array (or list, I don't really know the difference) and it won't work:
    <<set $foo=[
    number: 111,
    ]>>

    <<print $foo.number>>
    This is what I call an object and it will work:
    <<set $foo={
    number: 111,
    }>>

    <<print $foo.number>>
    So, that's the difference between array/lists and objects, as I see it. :)
  • Fair 'nuf. I don't use lists/arrays much, so I'm just going to believe you. Seems like objects are a little more specific/complex. :)
  • Thank you for the feedback! I think I have it sort of worked out with the hidden variables...it's not like this is a heavy-combat game, so no need to go too nuts.

    Yet. *grin*
  • The problem is, once you realise how customisable and flexible twine is, it's very easy to spend a lot more time writing code than it is writing story...at least, that's how my experience has been so far!  ::)
  • Hee! At the moment, I'm sinking into the mire of figuring out how to make saving games work...very little story is getting written!
  • bawpie wrote:

    The problem is, once you realise how customisable and flexible twine is, it's very easy to spend a lot more time writing code than it is writing story...at least, that's how my experience has been so far!  ::)


    "Here is a simple minimal system that lets me focus on writing."
    "I could use CSS to give my game its own look."
    "Let's use some macros to add more interesting mechanics."
    "The built-in macros are a bit limited, I'll add a custom macro."
    "Hmm, I only have 3 actual story passages yet."

    (What I actually did was start modifying the tools as well, but I don't think most authors are tempted to do that.)
  • RedWombat wrote:

    Hee! At the moment, I'm sinking into the mire of figuring out how to make saving games work...very little story is getting written!


    Unless you want something really fancy, SugarCube would probably give you all the save support you need.
  • I just switched to it, actually! But now I've got some other problems related to it--the lack of support for the either() function is tripping me up, and I'm really not liking the way the Actions are all on one line and not a bulleted list. So I need to figure out how to work around that...
  • One way I have seen this handled is to assign each thing you kill a set number of experience points and calculate the hunter's skill level based on how many experience points they have.

    <<set $hamster = {
    name: "Harry",
    hp: 10,
    experience: 3
    }>>
    <<set $mammoth = {
    name: "Marty",
    hp: 100,
    experience: 30
    }>>
    <<set $hunter = {
    name: "Robin",
    hp: 100,
    experience: 0,
    skill: 0
    }
    Each time the hunter kills a creature (say a mammoth) you add the creature's experience points to the hunter's experience.

    <<set $hunter.experience += $mammoth.experience>>
    The hunters skill level is calculated based on the hunters current experience points via any means that you like, most often it is a sliding scale which levels out at some point.
    eg.  level 1 is between 0 and 100 exp; 2 is 101 -> 200; 3 is 201 -> 400; 4 is 401 -> 800; 5 is 801 -> 1600, ect until they reach level 10 at with point becomes 100k more experience per level
  • RedWombat wrote:

    I just switched to it, actually! But now I've got some other problems related to it--the lack of support for the either() function is tripping me up


    Answered elsewhere.


    RedWombat wrote:

    and I'm really not liking the way the Actions are all on one line and not a bulleted list. So I need to figure out how to work around that...


    Probably answered elsewhere, but I'll toss my hat in as well.  It's easily changed via CSS.

    That said, the all on one line behavior is a holdover from the old versions of Sugarcane and Jonah (pretty sure they both did that).  I assume that the styling for an <<actions>> list in their new incarnations has been changed.  I wouldn't have an issue changing the default styling (back) to a bulleted list, if that's what people wanted.
  • And let me thank you for developing a system that answered all those save issues!

    I'm a little scared of getting into the CSS at this point--I'm already spending all these hours tinkering with the macros, as noted above, and not writing! (I mean, I have a huge chunk of game written, thankfully, it's just porting it over. But now I'm fiddling with things and not even doing that...*grin*) Still, if that's what it takes, I guess I'll have to figure out how to get in and do that, but I have no idea what's involved.
  • RedWombat wrote:

    And let me thank you for developing a system that answered all those save issues!

    I'm a little scared of getting into the CSS at this point--I'm already spending all these hours tinkering with the macros, as noted above, and not writing! (I mean, I have a huge chunk of game written, thankfully, it's just porting it over. But now I'm fiddling with things and not even doing that...*grin*) Still, if that's what it takes, I guess I'll have to figure out how to get in and do that, but I have no idea what's involved.


    You might be interested in my work-in-progress guide to the basics of CSS: CSS is Your Friend: The Basics of Changing Twine's Default Appearance For Newbs
  • Sharpe wrote:

    You might be interested in my work-in-progress guide to the basics of CSS: CSS is Your Friend: The Basics of Changing Twine's Default Appearance For Newbs


    I'm still waiting for The Computer is Your Friend: Keeping Your Twine Stories Free of Commie Influences.

    Did you ever write for Paranoia, by the way? You mentioned writing for GURPS.
  • Pursuant to Central Processing Unit directive 720.05.11/225.3, I can neither confirm, nor deny that I ever wrote for Mongoose.

    Though that would be awesome. :)
  • The latest SugarCube release removes the special CSS styling for the <<actions>> macro's unordered list.  Get your bullets on.
  • That is awesome! Thank you so much! (Wow, you're fast...)
Sign In or Register to comment.