Jump to content

Script triggers with OR()


Miloch

Recommended Posts

I always seem to forget this, but do they evaluate last-first or first-last? In other words, to target mages first, should it be:

IF
 OR(3)
See([GOODCUTOFF.0.0.MAGE_ALL])
See([GOODCUTOFF.0.0.CLERIC_ALL])
See([GOODCUTOFF])

Or the reverse of this?

Link to comment

Well, yes. And I suppose they do get evaluated first-last, and I got this reply by devSin via auto-email:

Top-down. You have what you want.
But either he wasn't sure and deleted his post or the forum hosed it. And testing seems to indicate the last evaluated trigger takes priority, so what I really want is the reverse:
IF
 OR(3)
See([GOODCUTOFF])
See([GOODCUTOFF.0.0.CLERIC_ALL])
See([GOODCUTOFF.0.0.MAGE_ALL])

Because with the reverse, my creature with this script targets Imoen (just a thief in my game) instead of me (a F/M/T). So if you have scripts of this nature, it might be wise to take a look at them.

Link to comment

All the stuff I can find looks like everyone uses top-down-within-the-OR as well.

Miloch, what you are seeing is that while the script order is top down, including the OR(), the OR() might be tossing the last evaluated-true as the result? In dialog and most scripting this would not matter, but for you combat script gurus, that would be something new to test, that is for sure.

Link to comment
All the stuff I can find looks like everyone uses top-down-within-the-OR as well.

Miloch, what you are seeing is that while the script order is top down, including the OR(), the OR() might be tossing the last evaluated-true as the result? In dialog and most scripting this would not matter, but for you combat script gurus, that would be something new to test, that is for sure.

 

That was my guess but that's a pretty sloppy way of coding OR() if it actually evaluates each one rather than simply skipping to the end once it hits a true statement.

Link to comment
But either he wasn't sure and deleted his post
It's one of those things where I read it and knew that it couldn't be right. It looks like most of my BG2 scripts are circa 2007, so I haven't even really payed attention since then, and targeting switched a while back to negation (where you don't need OR at all, but you have to do your targeting checks in separate blocks).

 

Everything is evaluated in OR, top-down. That's normal behavior.

 

Dialogue transitions are bottom-up, excepting that there are different "weights" for different transition types (anything but EXIT without reply -> reply -> EXIT without reply; or something).

Link to comment
targeting switched a while back to negation (where you don't need OR at all, but you have to do your targeting checks in separate blocks).
Well in fact I was doing it that way but it was exhibiting odd behaviour. Though it worked fine on my install, some folks with SCS reported the CREs would attack themselves or other enemies. Couldn't figure it out - obviously SCS doesn't make them do this, but I do know switching the targetting to OR in each block fixed it.

 

So this doesn't work:

IF
 Allegiance(Myself,ENEMY)
 !See([GOODCUTOFF.0.0.MAGE_ALL])
 !See([GOODCUTOFF.0.0.CLERIC_ALL])
 !See([GOODCUTOFF])
 False()
THEN
 RESPONSE #100
Continue()
END

IF
 Allegiance(Myself,ENEMY)
 GlobalLT("agm","LOCALS",5)
 !GlobalTimerNotExpired("agh","LOCALS")
THEN
 RESPONSE #100
IncrementGlobal("agm","LOCALS",1)
SetGlobalTimer("agh","LOCALS",ONE_ROUND)
ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

But this does:

IF
 Allegiance(Myself,ENEMY)
 GlobalLT("agm","LOCALS",5)
 !GlobalTimerNotExpired("agh","LOCALS")
 OR(3)
See([GOODCUTOFF])
See([GOODCUTOFF.0.0.CLERIC_ALL])
See([GOODCUTOFF.0.0.MAGE_ALL])
THEN
 RESPONSE #100
IncrementGlobal("agm","LOCALS",1)
SetGlobalTimer("agh","LOCALS",ONE_ROUND)
ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

Another oddity of the engine... it seems certain classes or races of creatures (golems, maybe others) can't cast spells using HaveSpell and Spell, even if they have the spells in their CRE files. Hence the need for the variable and ForceSpell above.

Link to comment

I recall some mods having ChangeClass(MAGE,Myself), or however it should be, in their first blocks. Spellcasting dragons, etc. Might be for this very reason. Might be not.

 

If you meant, Spell() causes a crash, then it is simple: they don't have casting animations.
Is it supposed to crash at all? Rats and peasants don't have attacking animation either, but they still can deliver damage in melee and not crash the game.
Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...