Using DO

Forgewright
12 Apr 2020, 18:25
weapon_eagle_short_sword.bonus = Set player.strength = player.strength + 2
 
weapon_eagle_short_sword.no_bonus = Set player.strength = player.strength -2

When I use :
do (object, "bonus")
in a equip function, it will make player.strength = 2 now be player.strength = 4<-----I checked it works

then when I use:
do (object, "no_bonus")

in an unequip function, it will make player.strength = 4 now player.strength = 0<---------I checked...wtf

Why would the unequip function make the player.strength = 0 instead of back to 2?

I didn't want to paste a bunch of scripts (yet). From this information, should this work?


hegemonkhan
12 Apr 2020, 18:37

looks like a coding oversight on the equipment library file... just a matter of tracking it down... got to find the 'unequip' (or whatever) function(s) or areas in the entire library code, which is setting it to '0', instead of its old value

(might need pixie or mrangel or whoever to dive into pixie's equipment library file to find it)


unless, it's something from your own game's coding... (try to check you own game's coding to see if it's a mistake on your end, otherwise, it's a mistake on pixie's equipment library file's end)


edit:

looking at your code... it's a bit strange (at least to me)

I'd do it like this:

player.strength = player.strength + 2
weapon_eagle_short_sword.bonus = player.strength

player.strength = player.strength - 2
weapon_eagle_short_sword.no_bonus = player.strength


Forgewright
12 Apr 2020, 18:47

I am creating everything from scratch as far as combat. Copying some of pixie's stuff but adding a lot to it. Unless the equipment library file you are referring to is in Quest. I have done a lot of backtracking so far. But I wanted to make sure certain pieces of code were correct.
I am calling a command that calls specific functions according to the kind of weapon used.

if what i have posted is correct then it is on my end as I have been adding and changing code. It use to work in it's simpler days.


mrangel
12 Apr 2020, 19:06

That looks like your unequip code is being called more than once, or something else is modifying strength.

Might be easier to debug if you can link to the game in question.


Forgewright
12 Apr 2020, 19:33

Forgewright
12 Apr 2020, 21:54

found it.

if (player.onehanded = object) {
  msg ("You put away your " + GetDisplayAlias(player.onehanded) + ".")
  list add (player.onehanded.inventoryverbs, "Equip")
  list remove (player.onehanded.inventoryverbs, "Unequip")
  player.onehanded.listalias = Replace(player.onehanded.listalias, " (equipped)", "")
  do (player.onehanded, "no_bonus")
  player.onehanded = null
  do (object, "no_bonus")
  foreach (obj, GetDirectChildren(player.parent)) {
    if (HasBoolean(obj, "dead")) {
      if (not obj.dead) {
        if (ListContains (player.attackers, obj)) {
          msg ("{colour:red:<i>You are still in battle!}")
          do_attack (obj, obj, player, false)
        }
      }
    }
  }
}
else {
  msg ("The " + GetDisplayAlias(object) + " is not equipped.")
}

This line:

do (object, "no_bonus")

I left it in from another script I used to make this one. Was running no_bonus twice.