Well, the title says it all really: I'm having trouble getting the game to accept changes to the player's armour class. (I want the change to be permanent, not temporary). The bonus should also be applied through a power.

I have tried to change the variables given in player.pkg:

However, none of this changes when I tell it to...

I am doing something very straightforward:

player.ac = player.ac + bonus

and the like, and I know that "bonus" is working properly, using:

msg_print(format("bonus = %s", bonus)

which gives the values as it should.

I thought it might just be the variables not updating properly, but I know that I'm doing that properly (in the extreme, I could just use PR_ARMOUR):

player.redraw = bor(player.redraw, PR_WIPE)

So, how can I get this to work properly? I don't get any error messages, so it recognises the player.foo variables, but it doesn't actually change them.

Thanks, -- The Falcon


OK. With help from Neil on the IRC, the problem is now solved.

It appears that player.to_a is the correct variable to use, and player.dis_to_a to let the player see the change to their AC.

This is applied in the power, to get the instantaneous change, however, it needs another function to make the bonus be applied on a permanent basis, rather than just temporarily. Otherwise, the AC will reset after every recalculation of the player's bonuses. Something like:

function foo()
   if (get_player_race() == "FOO") then
      player.to_a = player.to_a + bonus
      player.dis_to_a = player.dis_to_a + bonus
   end
end
add_hook_script(HOOK_CALC_BONUS, "foo", "foo")

where bonus has been added using add_loadsave and is altered in the power itself.

:)


Module Developers Discussion/problems with adding AC (last edited 2005-10-23 19:14:32 by TheFalcon)