Friday, April 30, 2010

Why units refuse to lose their abilities

So, if when {CLEAR_VARIABLE unit.abilities}-ed a unit, it didn't always drop their ability. This was very troubling. I had Dwarvish Guardsmen with bucklers that refused to give up steadfast along with Fencers wearing armor who could still skirmish. This totally wasn't the case ever for player characters. This code, inserted into the start event of the tutorial, confirmed it.

Hypothesis #1: It has to do with the fact these NPCs are canrecruit=no.

Nope. Tested it in the Tutorial. It did the same for Konrad (if I made him a Dwarvish Guardsman).

Hypothesis #2: There's a [modification] that needs to be removed.

Nope. Not in the save file.

Hypothesis #3: Abilities of regular-ish units need to be removed via [object]/[effect].

Damn, this one worked, but there's no way to just clear them all like that.

Then I talked to zookeeper who, as always, had brilliant insight. In IRC:

zookeeper: could it be that removal works on abilities which are no inherent to the unit type?
zookeeper: that'd be my first guess; that the game would see something missing and would recalculate it...like if you removed unit.hitpoints then the game would recalculate it (probably means fill them up to max)

Oh, so I just put a dummy [abilities] container in after clearing it and it worked fine. It turns out that PCs never had an inherent ability, so it was never an issue.

I was really scared this would be a roadblock, but it turned out not to be, thanks to good ol' zoo.

No comments:

Post a Comment