Jump to content
Sign in to follow this  
Zed Nocear

Trigger OnCreation() in BG1

Recommended Posts

The description of "0x0036 OnCreation()" in IESDP for BG1 and BG2 is the same:

Returns true only if the active creature came into existance in the last script round. If this is in an area script this returns true when the player enters the area for the first time.

At least for area scripts in BG1 this is not exactly true.

 

They are many creatures in BG1 spawned in 7. chapter on areas they are already visited in 5. chapter. The code, that creates these creatures has often trigger OnCreation() and it doesn't disallow to spawn these creatures.

 

For examples the BG1 plot always requests to talk to duke Eltan in 5. chapter in Flaming Fist Headquarters on area AR0608. In the same area in 7. chapter the "healer" Rashad appears, although the script block in AR0608.BCS, which creates Rashad has trigger OnCreation():

IF
OnCreation()
Global("Chapter","GLOBAL",7)
Global("Rashadspawn","GLOBAL",0)
THEN
RESPONSE #100
	SetGlobal("Rashadspawn","GLOBAL",1)
	CreateCreature("RASHAD",[568.293],0) // Rashad 
	ActionOverride("ELTAN",DestroySelf())
	CreateCreature("DELTAN2",[581.268],0) // Duke Eltan 
	SmallWait(2)
	ActionOverride("ELTAN2",Face(6))
	Continue()
END

Share this post


Link to post

actually it is correct. If you were to remove the chapter check global, Rashad would be spawned whenever the player first enters that given area. This is why there are global chapter checks in place to prevent certain npcs from spawning when they should not be.

 

perhaps a better wording would be...

 

OnCreation() returns true only if the active creature came into existence in the last script round. If this is in an area script this returns true when the player enters the area for the first time. Unless other conditions are present and they are not yet met, it will then return false until all conditions are true and the player enters the area again.

Share this post


Link to post
...
Isn't the OnCreation() then true the first time it's checked, which will then last that round and will then never be true again, ever ?

As in the above script, the condition is checked last... so if we switched the order of the above conditions, it would never become true in the game, as the house needs to be went into, to get to chapter 6(the return to Candle Keep).

Share this post


Link to post

the specific trigger would be true yes, but the block can't fire in the example provided because when the player is first in that area it is within chapter 5. However, when the player enters the area again in chapter 7 the creature is created. So it stands to reason then that either OnCreation() is true at every instance of a player entering an area OR it is true only at the first instance of entering the area and the creature is held in a invisible limbo state until the other triggers become true. But if the second were to be the case, then that fails normal scripting logic as we know it.

 

There are only two area scripts which use OnCreation() (in BG ToTSC) without any additional triggers required to be true. One is in AR2600 when the player first starts and it is used to set a timer for Tethoril. Without investigating I don't know if that timer gets reset every time the player goes into a sub area and back out. The other use is in AR2631 and it starts the cutscene where the player is in the candlekeep jail which leads into a conversation first with Ulraunt and then Tethoril which takes the player via cutscene to another area with no ability to get back to AR2631.

 

So, I would recommend testing OnCreation() to see what actually does happen.

 

try this in place of the example above and see what happens

IF
OnCreation()
THEN
RESPONSE #100
	CreateCreature("RASHAD",[568.293],0) // Rashad
END

Share this post


Link to post

OnCreation() is simply something firing for the first time. Usually, this means its script is cold-fired (it isn't already running). It will only be true this once (until the next time the script is purged).

 

For an area script, depending on master area setup (and other loading rot), this will often be true every single time you enter an area (but only the instant you enter the area; it will be false the rest of the time you spend in the area).

 

I seem to remember some silly caveat with its behavior in BG/TotSC, but I don't recall exactly what it was.

Share this post


Link to post

Hi!

 

i think OnCreation() causes a scriptblock to be executed absolutely instantly, that means: before the player actually enters the area. So that's why it's mostly used in combination with CreateCreature(), because without OnCreation() (in a small room like a tavern for example) the player may see how the creature is spawned in the first one or two seconds after he entered the area.

 

Greetings!

Share this post


Link to post
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...