MaxAstro
Spiral Knight
- Joined
- Dec 18, 2007
- Messages
- 645
This is basically the last barrier to me releasing my modmod, and I can't for the life of me figure it out.
I'm writing a spell for Amurite Wizards called Channel that allows them to act as living spellstaves. I got the basic mechanic working, and I've even managed to get it set up to target the strongest spellcaster on the tile.
The problem I am having is that I can't get the spell to consider the caster an invalid target. This means that if the caster is the strongest spellcaster on the tile, the spell we see that he has casted this turn (since he just cast Channel) and restore his ability to cast instantly. This makes it impossible to Channel for units weaker than the caster, which is less than ideal.
Can someone take a look at this code and tell me why it's still considering the caster a valid target?
EDIT: Here's the code.
I'm writing a spell for Amurite Wizards called Channel that allows them to act as living spellstaves. I got the basic mechanic working, and I've even managed to get it set up to target the strongest spellcaster on the tile.
The problem I am having is that I can't get the spell to consider the caster an invalid target. This means that if the caster is the strongest spellcaster on the tile, the spell we see that he has casted this turn (since he just cast Channel) and restore his ability to cast instantly. This makes it impossible to Channel for units weaker than the caster, which is less than ideal.
Can someone take a look at this code and tell me why it's still considering the caster a valid target?
EDIT: Here's the code.
Code:
def spellChannel(caster):
pPlot = caster.plot()
iBestValue = 0
pTarget = -1
for i in range(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
iTargetValue = 0
if pUnit.isHasCasted() and pUnit != caster and pUnit.getOwner() == caster.getOwner():
iTargetValue += pUnit.getLevel()
if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING1')):
iTargetValue += 10
if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING2')):
iTargetValue += 100
if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING3')):
iTargetValue += 1000
if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
iTargetValue += 5
if iTargetValue > iBestValue:
iBestValue = iTargetValue
pTarget = pUnit
if not pTarget == -1:
pTarget.setHasCasted(False)