Hello.
While working on my project, updating it to support multiple Summoned Associates,
and while testing for the "particular" things (you know, the "unexpected")... I have
stumbled on a funny bug.
Given a long enough spawn delay, it is possible for you to change Area before your
new Summoned Associate has actually spawned.
What will happen when the associate will be spawned? _Where_ will it spawn?
Look at this composite screenshot:
SummonBugSorry it is a big image -- may take a moment to load. But it is worth.
From top left to bottom right:
1) I right click the ground to cast a Gate spell.
I modified this Gate to spawn the Balor after 20 seconds.
2) The Gate spell is commenced. Visual effects playing.
But the Balor will not spawn before 20 seconds.
I am about to change Area. The Transition is right behind me.
3) In the new Area. I remain near the Transition and take a look at the void.
4) 20 seconds have elapsed. The Balor is finally spawned -- Haha.
He is standing right in the middle of a place nobody can travel to/from.
5) Resting. I put the balor out of his misery. The poor thing could not reach
me. It would be stuck there forever, until I changed Area again.
What happened?
It turns out that the NWN engine has frankensteined pieces of 2 locations to
craft the new location to spawn the Balor at.
His effective spawning location received the Area of my PC (his Master), but it
retained the coordinates vector and the facing of the point I clicked on the ground
when I cast the spell (the spawn_at location employed in the spellscript).
The result: the composed location likely points to where the Master is not.
Possibly in a place where nobody can reach, and from which the Balor will never get out.
It is even possible to spawn the Balor at a location that is way out of the Area physical
borders -- whis can happen if you cast the spell in a big Area (say, 8x8), then move
to a smaller Area (say, 2x2). And maybe the Balor will spawn at coordinates x6 y6, way out
of the perception range of anybody.
To query the Balor current location is no use. His Area is truly your same Area.
To rely on LineOfSight checks or Distance checks is a risk. The Balor could well be next
to you, and within "eye contact", but simply stuck inside an inaccessible "pit" tile.
The solution can take place in the OnSpawn script of the creature.
You must remember the very Area of the location you applied the EffectSummonCreature() to.
Alternatively the Area of the Master, at spellcast time, will do.
Once the Balor spawns, you compare his current Area with the Area you saved.
If they do not match, you are sure the Master of the creature did change Area _before_
the creature could spawn.
At that point, execute a JumpToObject() (or other Jump* call) to bring the Summoned
Associate to its Master.
This will bring the associate to the Master even if he spawned in some accessible place
of your new Area.
Without this fix, in that case he would eventually Heartbeat-jump to the Master position.
But before he does so, he could be well attacked by people you are not supposed to meet
yet, simply because you are at the other end of the Area.
So... do jump him as he spawns, and you avoid all exploits.
This bug is lurking within the original summoning spells too, of course.
A delay of 3.0 seconds is barely enough to be able to trigger it. Though highly unlikely,
it is still possible to do it. Higher delays will just increase the chance by far.
Not to mention the use of instant/cheat spellcasting through ActionCastSpellAtLocation().
-fox
Modifié par the.gray.fox, 12 novembre 2010 - 02:35 .