Jump to content

Some way to quickly force a script re-run?


temnix

Recommended Posts

Sometimes I want a creature to stop what it's doing, look around, hopefully choose a new target. I don't like monsters' habit of focusing on some one or two characters and following them around no matter what everyone around throws at them. I'd like to give monsters reality checks sometimes.

 

Usually when I want a creature to reconsider what it's doing, I apply a 1-second Feeblemind to it. It checks its scripts hierarchy and runs the most urgent one from the beginning. But a full second, plus the time it takes the creature to get going again, is rather slow. The lost second by itself doesn't do anything, it's wasted as an awkward pause. Now, there is no way, I think, to force a script re-run from the opcodes, but there probably is from scripts. Maybe there is a special suitable action for it, or maybe ClearAllActions() can do it. This action forces an immediate re-run of the script triggers, am I right?

 

Well, I was hoping for some way to single out a creature, any creature, so that baldur.bcs to home in on it and force, for example, this action. But Ardanis says there is no way to select just anyone from that high level. A backdoor in creature scripts might still do it. Let's say we were to put this in all of them:

 

IF

 

CheckSpellState(Myself,BACKDOOR)

 

THEN

 

ClearAllActions()

ApplySpellRES("BACKDOOR",Myself) /// A spell that removes the spell state

 

END

 

If this was in every creature's script, we could use a Set State effect from anywhere to discipline creatures on the spot.

 

What do you think? And what would be the Weidu command to edit all creature scripts? (Or edit all scripts, the spell state won't come up for an area or a trap.)

Link to comment

https://gibberlings3.github.io/iesdp/scripting/actions/bgeeactions.htm#134 ?

 

and...

 

 

OUTER_SET cre_index = 0

COPY_EXISTING_REGEXP ~^.*\.cre$~ ~override~ // open all cre files to read their script offset

  // do PATCH stuff to all cre files (e.g. read GENERAL script and store it in an array construct)

// WeiDU offset constants
//SCRIPT_OVERRIDE 0x248
//SCRIPT_CLASS 0x250
//SCRIPT_RACE 0x258
//SCRIPT_GENERAL 0x260
//SCRIPT_DEFAULT 0x268

  READ_ASCII  SCRIPT_GENERAL  genscript  ELSE ~notset~
  TEXT_SPRINT $cre_genscripts_array(~%cre_index%~) ~%genscript%~
  SET cre_index = cre_index + 1

BUT_ONLY_IF_IT_CHANGES // but we aren't actually changing any cre files, so we won't leave anything in the override folder

ACTION_PHP_EACH cre_genscripts_array AS index => genscript BEGIN

  ACTION_IF NOT (~%genscript%~ STR_EQ ~notset~) THEN BEGIN

    EXTEND_BOTTOM ~%genscript%~ ~mymod/universal_script_block_addition.baf~ EVALUATE_BUFFER // eval only needed if you use variables in your script

  END

END
Link to comment

The trouble with that(#134) is that it locks the creature to attack in melee, while it could just do different things.

 

I don't know, but maybe:

IF
  !TimerExpired("blah")
THEN
  RESPONSE #100
Attack()
END

//things that take priority from attacking

IF
TimerExpired("blah")
THEN
RESPONSE #100
StartTimer("blah",6)
Attack()
END
Link to comment

Archived

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

×
×
  • Create New...