<refusing to be driven crazy...>
Background for those who haven't been following
the bouncing ball: I'm incorporating Failed.Bard's dynamic forest system into the Regional Mod. A good part of that is the creation (and destruction) of the ambient vegetation, prey and predators (and possibly landmark features when I get the time).
The creation works the way I want... in poor nodes, starving, weak creatures are spawned. In rich nodes, powerful, healthy creatures are spawned. The creatures have default (yucky) scripting on them, but they work. And they can be killed. They spawn where and when I want them to, and in the proper number.
The problem: They refuse to be destroyed. Transition away and the "reg_node_sleep" script is dropped on the exiting area with a delay (currently set to 10 seconds for debugging). Reg_node_sleep check to be sure there are no PCs in the area (not in use) then destroys all the node-specific ambients (tagged reg_veg, reg_pry and reg_prd) and unsets the isNode identifier (freeing the area for reuse).
It all works except the destroy part.
The destroy part should be as simple as:
DestroyObjectsInAreaByTag( "reg_pry", OBJECT_SELF );
Except it doesn't work.
Hmmm... Ok. Perhaps the objects aren't coming back as valid for some reason?
Tried all kinds of loops with all kinds of delays. Here is the latest:
oObject = GetFirstObjectInArea( OBJECT_SELF);
// DestroyObjectsInAreaByTag( "reg_veg", OBJECT_SELF );
// Loop through all "reg_pry" tags in area - Destroy
iIndex = 0;
oTarget = GetNearestObjectByTag( "reg_pry", oObject);
while (oTarget != OBJECT_INVALID) {
if (GetIsObjectValid(oTarget)) {
sMessage = "Pry "+IntToString(iIndex)+" is a valid object type "+IntToString(GetObjectType(oTarget))+ " (creature is type "+IntToString(OBJECT_TYPE_CREATURE)+")";
SendMessageToPC( oPC, sMessage );
}
nPC = 0; // Just reusing var as counter
while (oTarget != OBJECT_INVALID ) {
sMessage = IntToString(nPC++)+" Trying to destroy pry " + IntToString( iIndex);
SendMessageToPC( oPC, sMessage );
DestroyObject( oTarget, 0.01f );
}
oTarget = GetNearestObjectByTag( "reg_pry", OBJECT_SELF, iIndex++ );
}
And a dump of the debug messages...
Pry Table is pry_tempforest
Max Pry # 5
Stage is 6
Pry chain is 1
Alpha Prey is reg_deer_06
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Stage is 6
Pry chain is 4
Alpha Prey is reg_deer_06
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
Beta is reg_deer_04
[Server] You are now in a No PVP area.
[Server] You are now in a No PVP area.
Putting node to sleep...
Pry 0 is a valid object type 1 (creature is type 1)
0 Trying to destroy pry 0
1 Trying to destroy pry 0
2 Trying to destroy pry 0
...
< snip >
...
6234 Trying to destroy pry 0
Script reg_node_sleep, OID: 800000ee, Tag: , ERROR: TOO MANY INSTRUCTIONS
Script reg_area_exit, OID: 800000ee, Tag: , ERROR: TOO MANY INSTRUCTIONS
Note that the object is valid and a creature. The only creatures in that area are ambients with the tag "reg_pry". So it is getting the right object, the object is valid... but it never destroys it.
And I have tried it with various delays...
Those stubborn deer have stumped me.
Edit: And yes, I realize the base object oObject will be destroyed in the middle of that loop, self destructing the whole thing. But "Destroy" has to work before that can happen :-P
Then I can use "DestroyObjectsInAreaByTag" ;-P
<...'cuz he can walk from here>
Modifié par Rolo Kipp, 22 novembre 2012 - 04:25 .