Hello, I'm very new to scripting in IE engine and I'm currently playing with the IWD in BG2 modification (no enhanced edition for me!)
I'm used to playing BGT with SCS install and I want to increase the AI difficulty in the IWD in BG2 mod (just for personal entertainment, nothing else)
My current problem is with a mage script, the monster seems to rest whenever I go out of his sight (so he starts his sequence from the beginning, doing the buff things again and regaining all his spells whenever he's out of sight), but I can't find where the problem is!
The script:
IF
!Global("#save_loc_init","LOCALS",1)
THEN
RESPONSE #100
SetGlobal("#save_loc_init","LOCALS",1)
SaveObjectLocation("LOCALS","#saved_loc",Myself)
Continue()
END
IF
StateCheck(Myself,STATE_PANIC)
THEN
RESPONSE #100
RandomWalkContinuous()
END
IF
Allegiance(Myself,NEUTRAL)
OR(7)
AttackedBy([GOODCUTOFF.0.0.0.0.SUMMONED],DEFAULT)
AttackedBy([PC],DEFAULT)
AttackedBy([FAMILIAR],DEFAULT)
AttackedBy([ALLY],DEFAULT)
AttackedBy([CONTROLLED],DEFAULT)
AttackedBy([CHARMED],DEFAULT)
SpellCastOnMe([GOODCUTOFF.0.0.0.0.SUMMONED],0)
THEN
RESPONSE #100
Enemy()
Shout(ALERT)
SetGlobal("inafight","LOCALS",1)
Continue()
END
IF
HitBy([GOODCUTOFF],CRUSHING)
THEN
RESPONSE #100
Shout(ALERT)
SetGlobal("inafight","LOCALS",1)
Continue()
END
IF
See(NearestEnemyOf(Myself))
Global("rest","LOCALS",0)
THEN
RESPONSE #100
Shout(ALERT)
SetGlobalTimer("rtime","LOCALS",SIX_HOURS)
SetGlobal("rest","LOCALS",1)
SetGlobal("inafight","LOCALS",1)
Continue()
END
IF
Global("rest","LOCALS",1)
!GlobalTimerNotExpired("rtime","LOCALS")
!See(NearestEnemyOf(Myself))
THEN
RESPONSE #100
SetGlobal("rest","LOCALS",0)
SetGlobal("inafight","LOCALS",0)
SetGlobal("prebuff","LOCALS",0)
SetGlobal("trigger","LOCALS",0)
SetGlobal("contingency","LOCALS",0)
SetGlobal("redefend","LOCALS",0)
ApplySpell(Myself,RESTORE_FULL_HEALTH) // SPIN746.SPL (No such index)
Rest()
END
IF
See(NearestEnemyOf(Myself))
Global("prebuff","LOCALS",0)
HaveSpell(WIZARD_ARMOR) // SPWI102.SPL (Armure)
!StateCheck(Myself,STATE_REALLY_DEAD)
THEN
RESPONSE #100
ReallyForceSpell(Myself,WIZARD_ARMOR) // SPWI102.SPL (Armure)
RemoveSpell(WIZARD_ARMOR) // SPWI102.SPL (Armure)
Continue()
END
IF
See(NearestEnemyOf(Myself))
Global("prebuff","LOCALS",0)
HaveSpell(WIZARD_BLUR) // SPWI201.SPL (Flou)
!StateCheck(Myself,STATE_REALLY_DEAD)
THEN
RESPONSE #100
ReallyForceSpell(Myself,WIZARD_BLUR) // SPWI201.SPL (Flou)
RemoveSpell(WIZARD_BLUR) // SPWI201.SPL (Flou)
Continue()
END
IF
See(NearestEnemyOf(Myself))
Global("prebuff","LOCALS",0)
THEN
RESPONSE #100
SetGlobal("prebuff","LOCALS",1)
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
See(NearestEnemyOf(Myself))
StateCheck(Myself,STATE_SILENCED)
HaveSpell(WIZARD_VOCALIZE) // SPWI219.SPL (Vocaliser)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(Myself,WIZARD_VOCALIZE) // SPWI219.SPL (Vocaliser)
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_STINKING_CLOUD) // SPWI213.SPL (Nuage puant)
See(NearestEnemyOf(Myself))
!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
Allegiance(Myself,ENEMY)
THEN
RESPONSE #150
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_STINKING_CLOUD) // SPWI213.SPL (Nuage puant)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_HOLD_PERSON) // SPWI306.SPL (Immobilisation des personnes)
OR(2)
See(NearestEnemyOf(Myself))
See([PC.0.0.FIGHTER])
!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_HOLD_PERSON) // SPWI306.SPL (Immobilisation des personnes)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_HORROR) // SPWI205.SPL (Horreur)
OR(2)
See(NearestEnemyOf(Myself))
See([PC.0.0.FIGHTER])
!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_HORROR) // SPWI205.SPL (Horreur)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_BURNING_HANDS) // SPWI103.SPL (Mains ardentes)
See(NearestEnemyOf(Myself))
Range(NearestEnemyOf(Myself),5)
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_BURNING_HANDS) // SPWI103.SPL (Mains ardentes)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_CHARM_PERSON) // SPWI104.SPL (Charme-personne)
See(NearestEnemyOf(Myself))
!StateCheck(LastSeenBy(Myself),STATE_CHARMED)
!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_CHARM_PERSON) // SPWI104.SPL (Charme-personne)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_COLOR_SPRAY) // SPWI105.SPL (Vapeur colorée)
See(NearestEnemyOf(Myself))
!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_COLOR_SPRAY) // SPWI105.SPL (Vapeur colorée)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_MELF_ACID_ARROW) // SPWI211.SPL (Flèche acide de Melf)
See(NearestEnemyOf(Myself))
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW) // SPWI211.SPL (Flèche acide de Melf)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveSpell(WIZARD_LIGHTNING_BOLT) // SPWI308.SPL (Eclair)
See(NearestEnemyOf(Myself))
Allegiance(Myself,ENEMY)
THEN
RESPONSE #100
SetGlobalTimer("castspell","LOCALS",ONE_ROUND)
Spell(LastSeenBy(Myself),WIZARD_LIGHTNING_BOLT) // SPWI308.SPL (Eclair)
RESPONSE #50
Continue()
END
IF
!GlobalTimerNotExpired("castspell","LOCALS")
HaveAnySpells()
See(NearestEnemyOf(Myself))
!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
THEN
RESPONSE #100
RunAwayFrom(NearestEnemyOf(Myself),30)
END
IF
See(NearestEnemyOf(Myself))
THEN
RESPONSE #100
AttackReevaluate(NearestEnemyOf(Myself),30)
END
IF
AttackedBy([ANYONE],DEFAULT)
THEN
RESPONSE #100
Attack(LastAttackerOf(Myself))
END
IF
OR(2)
Allegiance(Myself,ENEMY)
Allegiance(Myself,NEUTRAL)
!See(NearestEnemyOf(Myself))
Heard([ANYONE],ALERT)
InMyGroup(LastHeardBy(Myself))
OR(2)
!Class(Myself,INNOCENT)
CheckStatGT(Myself,1,LEVEL)
THEN
RESPONSE #100
Shout(ALERT)
MoveToObject(LastHeardBy(Myself))
END
IF
!GlobalTimerNotExpired("#return_to_loc","LOCALS")
THEN
RESPONSE #100
MoveToSavedLocationn("#saved_loc","LOCALS")
SetGlobalTimer("#return_to_loc","LOCALS",ONE_ROUND)
END
For now many varables are not put to any use as I want to start simple and go with increasing difficulty (better targeting, etc...)
I've taken some inspiration from stratagems scripting (for now it's very basic but I'm satisfied with the call for help ) for the "rest" part but it does not seems to work properly. If anyone is willing to help, I'll greatly appreciate it!