def spellReadTheGrimoire(caster):
iBonus=0
pPlayer = gc.getPlayer(caster.getOwner())
pPlot=caster.plot()
point = pPlot.getPoint()
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING1')):
iBonus=100
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING2')):
iBonus=iBonus+100
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING3')):
iBonus=iBonus+100
if caster.getReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1')):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH2')):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH3')):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1')):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY2')):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY3')):
iBonus=iBonus+5
if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HERO')):
iBonus=iBonus+10
iRnd = CyGame().getSorenRandNum(100, "Read the Grimoire")+iBonus
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_PROPHECY_MARK'), True)
if iRnd < 30:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
if iRnd >= 30 and iRnd < 40:
caster.cast(gc.getInfoTypeForString('SPELL_BURNING_BLOOD'))
if iRnd >= 40 and iRnd < 50:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
if iRnd >= 50 and iRnd < 60:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
if iRnd >= 60 and iRnd < 70:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_UNHOLY_TAINT'), True)
if iRnd >= 70 and iRnd < 80:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
if iRnd >= 80 and iRnd < 100:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING1'), True)
if iRnd >= 100 and iRnd < 110:
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_PIT_BEAST'))
if iRnd >= 110 and iRnd < 120:
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_SPECTRE'))
if iRnd >= 120 and iRnd < 130:
caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
if iRnd >= 130 and iRnd < 140:
caster.cast(gc.getInfoTypeForString('SPELL_MUTATION'))
if iRnd >= 140 and iRnd < 145:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STIGMATA'), True)
if iRnd >= 145 and iRnd < 150:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
if iRnd >= 150 and iRnd < 155:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
if iRnd >= 155 and iRnd < 160:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
if iRnd >= 160 and iRnd < 170:
caster.kill(True, PlayerTypes.NO_PLAYER)
if iRnd >= 170 and iRnd < 180:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_UNHOLY_TAINT'), True)
if iRnd >= 180 and iRnd < 185:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1'), True)
if iRnd >= 185 and iRnd < 190:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1'), True)
if iRnd >= 190 and iRnd < 200:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING1'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING2'), True)
if iRnd >= 200 and iRnd < 210:
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_BALOR'))
if iRnd >= 210 and iRnd < 220:
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_WRAITH'))
if iRnd >= 220 and iRnd < 230:
caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
if iRnd >= 230 and iRnd < 240:
caster.cast(gc.getInfoTypeForString('SPELL_WONDER'))
if iRnd >= 240 and iRnd < 245:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STIGMATA'), True)
if iRnd >= 245 and iRnd < 250:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
if iRnd >= 250 and iRnd < 255:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
if iRnd >= 255 and iRnd < 260:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WEAK'), True)
if iRnd >= 260 and iRnd < 265:
CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPELL1'),point)
CyAudioGame().Play3DSound("AS3D_SPELL_DEFILE",point.x,point.y,point.z)
for iX in range(pPlot.getX()-1, pPlot.getX()+2, 1):
for iY in range(pPlot.getY()-1, pPlot.getY()+2, 1):
pLoopPlot = CyMap().plot(iX,iY)
if pLoopPlot.isNone() == False:
pLoopPlot.changePlotCounter(100)
if iRnd >= 265 and iRnd < 270:
caster.kill(True, PlayerTypes.NO_PLAYER)
if iRnd >= 270 and iRnd < 275:
caster.cast(gc.getInfoTypeForString('SPELL_BURNING_BLOOD'))
if iRnd >= 275 and iRnd < 280:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_POTENCY'), True)
if iRnd >= 280 and iRnd < 285:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH2'), True)
if iRnd >= 285 and iRnd < 290:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY2'), True)
if iRnd >= 290 and iRnd < 295:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_UNHOLY_TAINT'), True)
if iRnd >= 295 and iRnd < 300:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING1'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING2'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING3'), True)
if iRnd >= 300 and iRnd < 310:
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_BALOR'))
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_BALOR'))
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_BALOR'))
if iRnd >= 310 and iRnd < 320:
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_WRAITH'))
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_WRAITH'))
caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_WRAITH'))
if iRnd >= 320 and iRnd < 330:
caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
if iRnd >= 330 and iRnd < 340:
caster.cast(gc.getInfoTypeForString('SPELL_WONDER'))
caster.cast(gc.getInfoTypeForString('SPELL_WONDER'))
caster.cast(gc.getInfoTypeForString('SPELL_WONDER'))
if iRnd >= 340 and iRnd < 345:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
if iRnd >= 345 and iRnd < 350:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
if iRnd >= 350 and iRnd < 355:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
if iRnd >= 355 and iRnd < 360:
CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPELL1'),point)
CyAudioGame().Play3DSound("AS3D_SPELL_DEFILE",point.x,point.y,point.z)
for iX in range(pPlot.getX()-1, pPlot.getX()+2, 1):
for iY in range(pPlot.getY()-1, pPlot.getY()+2, 1):
pLoopPlot = CyMap().plot(iX,iY)
if pLoopPlot.isNone() == False:
pLoopPlot.changePlotCounter(100)
if iRnd >= 360 and iRnd < 363:
caster.kill(True, PlayerTypes.NO_PLAYER)
if iRnd >= 363 and iRnd < 365:
caster.cast(gc.getInfoTypeForString('SPELL_BURNING_BLOOD'))
if iRnd >= 365 and iRnd < 370:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_VILE_TOUCH'), True)
if iRnd >= 370 and iRnd < 380:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_POTENCY'), True)
if iRnd >= 380 and iRnd < 385:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STIGMATA'), True)
if iRnd >= 385 and iRnd < 390:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SUNDERED'), True)
if iRnd >= 390 and iRnd < 395:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH2'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH3'), True)
if iRnd >= 395 and iRnd < 400:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY2'), True)
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY3'), True)
if iRnd >= 400 and iRnd < 405:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MAGIC_IMMUNE'), True)
if iRnd >= 405 and iRnd < 410:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FEAR'), True)
if iRnd >= 410 and iRnd < 420:
newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_WRAITH'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
newUnit.finishMoves()
newUnit.setHasCasted(True)
newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENRAGED'), True)
newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_BURNING_BLOOD'), True)
if iRnd >= 420 and iRnd < 430:
newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_BALOR'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
newUnit.finishMoves()
newUnit.setHasCasted(True)
newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENRAGED'), True)
newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_BURNING_BLOOD'), True)
if iRnd >= 430 and iRnd < 440:
caster.changeExperience(50, -1, False, False, False)
if iRnd >= 440 and iRnd < 443:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_TWINCAST'), True)
if iRnd >= 443:
caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)