Jump to content

[SOLVED] How to detect imprisonment/freedom by script


argent77

Recommended Posts

I want one of my creatures to split into two child creatures when it dies. However, the script below is also triggered when I free it from imprisonment. This can be exploited to create an endless amount of child creatures by continuously imprison and free the parent creature.

Is there a way to detect that the creature has been restored by the Freedom spell, so I can prevent the script from triggering in this case? (Btw, I've coded it for the Enhanced Editions of the games.)

IF
  Die()
THEN
  RESPONSE #100
    ReallyForceSpellDeadRES("a7!spwn",Myself) // Spawn child creature
    ReallyForceSpellDeadRES("a7!spwn",Myself) // Spawn child creature
END
Link to comment

 

I want one of my creatures to split into two child creatures when it dies. However, the script below is also triggered when I free it from imprisonment. This can be exploited to create an endless amount of child creatures by continuously imprison and free the parent creature.

 

Is there a way to detect that the creature has been restored by the Freedom spell, so I can prevent the script from triggering in this case? (Btw, I've coded it for the Enhanced Editions of the games.)

 

IF
  Die()
THEN
  RESPONSE #100
    ReallyForceSpellDeadRES("a7!spwn",Myself) // Spawn child creature
    ReallyForceSpellDeadRES("a7!spwn",Myself) // Spawn child creature
END

Would

IF

Die()

!SpellCastOnMeRES("Spin917",[ANYONE])

THEN

work? I never used the function in conjunction with Die() or Spin917, just use it for a lot of other spells to be cast or not cast. Just a thought...

Disregard - it will probably not work, as the block is already triggered before the spell is cast, its execution is just delayed by the immediate imprisonment effect, meaning the block is executed when imprisonment ends...means there is probably no way to detect which spell is cast on me after i am dead??

Link to comment

Well, you can make the Freedom to provide a timed immunity to Imprisonment, say 18 seconds... should solve the problem. Unless the player flees... after all it's a freaking 9th level spell providing a 1 timed effect to counter a same level spell.

Or just suggest heavily to subscribing to the use of the Spell Revision that already gives the immunity.

 

Also the child creatures can make an count of themselves*. Aka, use a global that is used as the count sum, and then a local that is set based on the global and increase the global if the creature doesn't have one. And do a kill self if the local is bigger than 2 or what ever... .

 

Also it would be advisable to use this instead:

IF
  Die()
THEN
  RESPONSE #100
    ReallyForceSpellDeadRES("a7!spwn",Myself) // Spawn child creature
    WAIT(1)
    ReallyForceSpellDeadRES("a7!spwn",Myself) // Spawn child creature
END
Or you would you rather make the spell itself summon 2 creatures... and have the delay there.

 

The child creatures script*...

IF
  OnCreation()
THEN
  RESPONSE #100
    IncrementGlobal(a7!childbirts,GLOBAL,1)
END

IF
  Global(a7!childbirts,GLOBAL,1)
  Global(a7!childbirts_result,LOCAL,0)
THEN
  RESPONSE #100
  SetGlobal(a7!childbirts_result,LOCAL,1)
END

IF
  Global(a7!childbirts,GLOBAL,2)
  Global(a7!childbirts_result,LOCAL,0)
THEN
  RESPONSE #100
  SetGlobal(a7!childbirts_result,LOCAL,2)
END

IF
  GlobalGT(a7!childbirts,GLOBAL,2)
  Global(a7!childbirts_result,LOCAL,0)
THEN
  RESPONSE #100
  Kill(Myself)
END
Link to comment

@Roxanne

It wouldn't work anyway as Freedom automatically targets the caster.

 

@Jarno

The child spawning mechanism is used universally for certain types of creatures and works already perfectly well (as shown below). I've been testing it for quite some time without issues, except for the Die() trigger returning true when freeing them from their imprisoned state.

 

 

387ks7sw6fnx.gif

 

 

Link to comment

How about modifying freedom to set a global var and using it as an inhibitor in the spawner? Removed/reset with a delay.

1) Should maybe such a global be set by imprisonment rather than by freedom?

2) When would you reset the global to 0?

Link to comment

I found an even better solution that seems to work so far in my tests. I merely had to add "StateCheck(Myself, STATE_REALLY_DEAD)" to the script to exclude the imprisonment state (which apparently counts as dead, but not really dead). It works now as intended. :)

Thanks for all suggestions so far.

Link to comment

I found an even better solution that seems to work so far in my tests. I merely had to add "StateCheck(Myself, STATE_REALLY_DEAD)" to the script to exclude the imprisonment state (which apparently counts as dead, but not really dead). It works now as intended. :)

Question: What happens to a single player character game(so no NPCs) when the players char is imprisoned ?

In vanilla ToB, it ended the game... does this still happen ?

Link to comment

Question: What happens to a single player character game(so no NPCs) when the players char is imprisoned ?

In vanilla ToB, it ended the game... does this still happen ?

I'm pretty certain Charname dies in BG2EE as well when imprisoned and he was the only one (left). However, you can set the game up so that it doesn't end automatically if Charname dies and one or more party members are still alive.

 

Link to comment

I believe the technical term is "mostly dead."

The black knight told it best... "It's just a flesh wound."

 

I'm pretty certain ...

Be sure... in that you try to check it with a player char that is casted an Imprisonment.. popping out Kangaxx should give a fairly certain try of it. Cause that's the only spell it casts. The reason being that it doesn't need defenses cause he is immune to all of them, yes, the defense spells ... should be. Technically might not, but it should.
Link to comment

If you are coding for the EEs, Opcode 232 can be made to trigger at the moment of death without the split second delay that happens during scripting. I don't know whether it triggers during imprisonment/petrification or not.

This opcode works great in principle, but unfortunately doesn't handle petrification and imprisonment in a way I could manage. It works well enough for imprisonment as the spawning action is triggered after being imprisoned and is therefore ineffective. However, petrification can't be handled correctly without patching "Stone to Flesh" and similar spells.

 

You can also use a custom spellstate for detection purposes. IIRC I already added something like that to Imprisonment in one of last patches.

That probably requires patching either Imprisonment or Freedom. I want to avoid something like this if possible, as there are several variants of the Imprisonment spell in the game already and mods may add even more.

Link to comment

Archived

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

×
×
  • Create New...