Attack Player Error (subtraction error) [SOLVED-ISH]


EDIT
So I figured out the problem. I had the damage and bonusdamage scripts on only the Zombie Types and not the Monster Type. So I created them and set them both as a 0 Integer and it removed the error. Sorry about that! Now if I can just figure out how to get everything from missing so much.




So this error is randomly happening out of nowhere and I'm not sure why since I haven't messed with these scripts in a while.

Error running script: Error compiling expression 'this.damagebonus - player.agility / 2': ArithmeticElement: Operation 'Subtract' is not defined for types 'Object' and 'Int32'
Error running script: Error compiling expression 'this.damagebonus - player.agility / 2': ArithmeticElement: Operation 'Subtract' is not defined for types 'Object' and 'Int32'

^ these are the errors I'm getting. Subtract not defined.

So I have a

Monster Type
Female_Zombie_Type
Male_Zombie_Type 

^ Zombie Type inherits the Monster Type. Monster Type has this attack script.

bonus = this.damagebonus - player.agility / 2
damage = this.damage - player.defense / 3
if (damage < 1) {
  if (player.ghost=True) {
    if (RandomChance(47)) {
      damage = 1
    }
    else {
      damage = 0
    }
  }
  else {
    if (RandomChance(50)) {
      damage = 1
    }
    else {
      damage = 0
    }
  }
}
if (player.ghost=False) {
  if (RandomChance(40 + bonus * 5)) {
    msg (this.attackplayerhit)
    player.health = player.health - damage
  }
  else {
    msg (this.attackplayermissed)
  }
}
else {
  if (RandomChance(37 + bonus * 5)) {
    msg (this.attackplayerhit)
    player.health = player.health - damage
  }
  else {
    msg (this.attackplayermissed)
  }
}

And when I remove the agility and defense it says if (RandomChance(40 + bonus * 5)) {} is not defined. Anyone know a possible solution? I would be very grateful.

It's been a long while since something has stumped me like this.

Anonynn.


just note that:

any/all Attribute(s) given-to/used-with the Object Types / Types, their Values are locked-in, so if you were to try to change those Values for within some action, it'll cause an error

to handle it, so that it doesn't cause an error, you got to set/create the Attribute upon the Object in use, as that will over-ride/over-write the same inherited Attribute from the Object Type / Type, that it is using, allowing you to now change it's Value, within any such action within your game

there is a good reason for the Object Types / Types (as Inherited by Objects) Attributes Values to be locked (but not going to try to explain it here, as it's complicated), but it also causes these other problems/issues to deal with as well...

this causes using Object Types / Types somewhat less useful, as you got to give every Object those Attributes manually anyways, if you're going to use changing Values of those Attributes within any action within your game. There's two main reasons to use Object Types / Types: (1) any Attribute who's Value will never be changed within actions in your game, and/or (2) a way to ensure that you have that Attribute on the Object, instead of having to have the script check for it, but still, you're going to have scripting anyways, as you'll need a script to set/create that Attribute on the Object, so that you can change its Value within some action in your game, so it might just be better to check if the Attribute exists within the script, instead... best most-efficient game/code and/or data-structuring mechanics/organization is very complicated... lol


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

Support

Forums