How do I make status attributes affect certain abilities/skills?

Hi again,
I guess it's a easy question, but I can't find the easy way.
So, here's the main problem. My player has in certain rooms the option to search the area for loot. If the player search the area he can find some items. This works fine, but now I wanted to give the player a luck or search experience attribute and this attribute should increase the number of looted objects.

I could imagine making a if script for every single level and then I tried to get the hang of the "for" or "foreach" functions but I don't understand it.
I thouht something easy like, as the player search area he'll find for each Luck Lv. +2 more gold, should be possible. I can't figure it out.

Thanks for the help!
Greetings Curt


(filler for getting my edited post, updated/posted, grr)


this is actually quite advanced stuff... as you could make this be like diablo's item/drop system (recursion and diminishing returns) and/or a leveled loot system like in morrowind/oblivion/skyrim ... though you don't have to have such complex systems as well.


here's a guide on Attributes and the 'if' Script usage:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

here's a guide on using List and Dictionary Attributes:

http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk


here's a very "simple" example design:

your 'luck' Integer Attribute provides a percent chance of getting each item (which is iterated through via the 'foreach') within a room's 'search/drop item list'

and your 'luck' Integer Attribute provides modifier of +2 gold per luck amount (psuedo-code: new_gold = old_gold + luck * 2) when you search

<game name="example_game">


  <attr name="start" type="script">

    do (action_button_object, "cheat")

  </attr>

</game>

<object name="room">

  <inherit name="editor_room" />

  <attr name="search_objectlist_attribute" type="objectlist">

    <value>katana</value>
    <value>claymore</value>

  </attr>

</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="luck" type="int">0</attr>

  <attr name="gold" type="int">0</attr>

</object>

<object name="action_button_object">

  <attr name="parent" type="object">player</attr>

  <attr name="alias" type="string">actions</attr>

  <attr name="cheat" type="script">

    <![CDATA[

      msg ("Luck? (0 to 100)")
      get input {
        if (IsInt (result)) {
          input_integer_variable = ToInt (result)
          if (input_integer_variable >= 0 and input_integer_variable <= 100) {
            player.luck = input_integer_variable
          }
        }
      }

    ]]>

  </attr>

  <attr name="search" type="script">

    firsttime {

      // handles the gold:

      game.pov.gold = game.pov.gold + game.pov.luck * 2

      // handles the items:

      room_object_variable = game.pov.parent
      if (HasAttribute (room_object_variable, "search_objectlist_attribute")) {
        foreach (item_object_variable, room_object_variable.search_objectlist_attribute) {
          if (RandomChance (game.pov.luck)) {
            clone_object_variable = CloneObject (item_object_variable)
            clone_object_variable.original_object_attribute = item_object_variable
            clone_object_variable.parent = game.pov
          }
        }
      }
    }

    otherwise {
      msg ("You've already searched here, sorry")
    }

  </attr>

</object>

<object name="equipment_object">

  <object name="weapon_object">

    <object name="melee_object">

      <object name="sword_object">

        <object name="katana">
        </object>

        <object name="claymore">
        </object>

      </object>

    </object>

  </object>

</object>

<verb>
  <property>cheat</property>
  <pattern>cheat</pattern>
  <defaultexpression>You can't cheat here!</defaultexpression>
</verb>

<verb>
  <property>search</property>
  <pattern>search</pattern>
  <defaultexpression>You can't search here!</defaultexpression>
</verb>

Gold = Gold * Luck + Gold
Gold/3 = 1 * 2 + 1

Or, at least I think that's what it is.


hegemonkhan, it's.... complicated.
I think i understood your design, but it's so much ^^... I dream so much of working with quest, normal?

I came up with the same idea as jmnevil54

jmnevil54, I thought the same..
I want try somthing easy soundin' like:

room.loot_gold = player.search_skill + room.lootable_gold

As the player search he will get...
(How to code it correct?)

Is...

player.gold = player.gold + room.loot_gold
player.gold = player.gold + player.search_skill
...enough?


It's enough if you want it to be enough. It depends on how you scale everything, from the player's skills, to the gold found in an area/on a monster's body.


K.V.

You could put this in a turn script on the game object, making sure it's enabled:

player.parent.loot_gold = player.search_skill + player.parent.lootable_gold

NOTES:

1. player.parent is the room the player is currently in.

2. If your game allows you to play as objects other than the player object, you should use game.pov in place of player. game.pov covers any object which is being controlled by the actual person playing the game.

So player.parent should be game.pov.parent in such cases.

(I will use player.parent in all the examples here, to keep it as simple is I can. I just told mentioned the game.pov thing to avoid setting you up for future errors.)


This would probably belong in the ontake script for something which is worth some gold:

player.gold = player.gold + player.parent.loot_gold

This one confuses me.

When would this happen?

player.gold = player.gold + player.search_skill

It seems like (maybe) you meant to set that on a room's loot_gold attribute, perhaps in the room's beforeenter script:

player.parent.loot_gold = player.parent.loot_gold + player.search_skill

Resources:

http://docs.textadventures.co.uk/quest/tutorial/custom_attributes.html

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

http://docs.textadventures.co.uk/quest/tutorial/status_attributes.html

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

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

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


Say you set an attribute "gold" on any room that can be searched and on the player for how much she is carrying. The SEARCH command would be:

if (HasInt(player.parent, "gold")) {
  n = player.parent.gold + player.luck * 2
  msg ("You find " + n + " gold!")
  player.gold = player.gold + n
  player.parent.gold = null
}
else {
  msg("You find nothing here.")
}

player.parent is the current room, so if the room has a "gold" attribute set, the value n is set to that plus twice the luck. It adds that to the "gold" attribute of the player, gives a message, and then sets the "gold" attribute of the room to null so the player cannot keepgetting more and more gold by searching twenty times.


Yes, I set a gold attribute to the room and it fills slowly up over time if it reaches 0.
I gonna try out these methods from Pixie and K.V., thank ya...


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

Support

Forums