So, I have been playing with some custom spells, thanks largely to the custom content creation tutorials and the Lexicon. The spell I have most wanted to make is a variation on Firebrand, at least in that there are a number of missiles based on a fraction of caster level, up to the number of available enemies. To make it, I modified DoMissileStorm() to better suit my purpose and that seems to work quite nicely.
However, I noticed that fairly frequently not all the missiles were appearing. The enemies were there, they were visible, there was line of sight, etc., but only one missile would show up despite multiple enemies in range. So, I added some debug code to the spell that sent a note to nwclientLog1.txt after the calls to GetFirstObjectInShape() and GetNextObjectInShape(). I haven't noticed anything unusual with GetFirstObjectInShape() and GetNextObjectInShape() often seems to work fine. But, when I notice too few missiles, I pause and check the log and see that GetNextObjectInShape() has returned 0x7f000000, which is the invalid object that fails the GetIsObjectValid() test and stops the loop. The problem is that there
are valid objects there, often right next to the initial target (which can be a creature or a location).
My call to the function was initially
location lTarget = GetSpellTargetLocation(); // outside the loop
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTarget, TRUE, OBJECT_TYPE_CREATURE);
and then I thought maybe something funky was going on with the vOrigin variable, so I changed the call to
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTarget, TRUE, OBJECT_TYPE_CREATURE, vFirstTarget);
where vFirstTarget is defined (also outside the loop as
vector vFirstTarget = GetPositionFromLocation(lTarget);
though I have also tested it with the location of the caster; neither is helpful.
Anyway, the issue is that sometimes GetNextObjectInShape() is saying there are no targets left when there are clearly some left. Initially, I was assuming that I had mucked up something else in my code. But, paying closer attention, I can see the same problem with (unmodified) Firebrand, where sometimes it just ignores all but one of the obvious targets.
Am I doing something wrong? Is this a known issue? Is there a fix. Any hints much appreciated.
Modifié par MrZork, 18 août 2010 - 08:55 .