How is this recursive?
Projectile spawns Projectile which spawns Projectile which spawns Projectile... ...which crashes BL.
Put echoes inside the loops and any other useful functions (e.g. projectiledata::onadd), post a traced console log of that.
In a brand new BL folder, with nothing but the standard HEGrenade (the latest version available on RTB) and the following script:
function vectorClampF(%vector, %min, %max) {
return vectorScale(vectorNormalize(%vector), mClampF(vectorLen(%vector), %min, %max));
}
package projectileStuff {
function projectileData::onExplode(%this, %obj, %pos) {
if(isObject(%this.subProjectile)) {
%inheritVel = vectorScale(%obj.getVelocity(), %this.subProjectile.velInheritFactor);
if(%this.subProjectileCount $= "")
%this.subProjectileCount = 1;
for(%i = 0; %i < %this.subProjectileCount; %i++) {
%vel = mCos(mDegToRad(getRandom(0, 359))) SPC mSin(mDegToRad(getRandom(0, 359))) SPC mCos(mDegToRad(getRandom(0, 179)));
%vel = vectorNormalize(%vel);
%vel = vectorScale(%vel, %this.subProjectile.muzzleVelocity);
%vel = vectorAdd(%vel, %inheritVel);
%vel = vectorClampF(%vel, 0, 200);
%p = new projectile() {
dataBlock = %this.subProjectile.getID();
initialPosition = %pos;
initialVelocity = %vel;
sourceObject = %obj.sourceObject;
sourceSlot = %obj.sourceSlot;
client = %obj.client;
};
missionCleanup.add(%p);
echo("NEW PROJECTILE #" @ %i + 1 @ " DUMP (onExplode)");
echo(%p.getID());
%p.dump();
}
echo("OLD PROJECTILE DUMP (onExplode)");
echo(%obj.getID());
%obj.dump();
%obj.delete();
return;
}
parent::onExplode(%this, %obj, %pos);
}
function projectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal) {
echo("DUMP BEFORE COLLISION");
%obj.dump();
return parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
}
function projectile::onAdd(%this) {
%val = parent::onAdd(%this);
echo("DUMP AFTER ADD");
%this.dump();
return %val;
}
function projectile::onRemove(%this) {
echo("DUMP BEFORE REMOVE");
%this.dump();
return parent::onRemove(%this);
}
};
activatePackage(projectileStuff);
I got the following output.
==>HEGrenadeProjectile.subProjectile=HEGrenadeProjectile;
==>trace(true);
Console trace is on.
Leaving ConsoleEntry::eval() - return
Entering toggleConsole(1)
Entering [CanvasCursor]GuiCanvas::popDialog(Canvas, ConsoleDlg)
Entering [CanvasCursor]GuiCanvas::checkCursor(Canvas)
Entering cursorOff()
Leaving cursorOff() - return
Entering [CanvasCursor]GuiCanvas::checkTabFocus(Canvas)
Leaving [CanvasCursor]GuiCanvas::checkTabFocus() - return
Leaving [CanvasCursor]GuiCanvas::checkCursor() - return
Leaving [CanvasCursor]GuiCanvas::popDialog() - return
Leaving toggleConsole() - return
Entering toggleConsole(0)
Leaving toggleConsole() - return 0
Entering mouseFire(0)
Leaving mouseFire() - return 0
Entering Armor::onTrigger(44, 7006, 0, 0)
Leaving Armor::onTrigger() - return 7006
Entering hegrenadeImage::onFire(691, 7006, 0)
Entering WeaponImage::onFire(691, 7006, 0)
Entering [projectileStuff]Projectile::onAdd(7176)
Entering Projectile::onAdd(7176)
Leaving Projectile::onAdd() - return -49.1702 2.5118 2.48114
DUMP AFTER ADD
Member Fields:
dataBlock = "hegrenadeProjectile"
initialPosition = "-49.1702 2.5118 2.48114"
initialVelocity = "29.2626 -5.39691 -3.81771"
position = "-49.1702 2.5118 2.48114"
rotation = "1 0 0 0"
scale = "1 1 1"
sourceObject = "7006"
sourceSlot = "0"
Tagged Fields:
client = "6119"
originPoint = "-49.1702 2.5118 2.48114"
Methods:
addScheduledEvent() -
... Standard projectile methods, we all know what they are, no need making this longer than it needs to be...
ToggleEventEnabled() -
Leaving [projectileStuff]Projectile::onAdd() - return -49.1702 2.5118 2.48114
Leaving WeaponImage::onFire() - return 7176
Entering messageClient(6119, 32, 65, 3, 0)
Leaving messageClient() - return
Entering ServerCmdUnUseTool(6119)
Entering WeaponImage::onUnMount(691, 7006, 0)
Leaving WeaponImage::onUnMount() - return 691
Leaving ServerCmdUnUseTool() - return 691
Leaving hegrenadeImage::onFire() - return 691
Entering clientCmdServerMessage(32 MsgItemPickup, 65 , 3, 0)
Entering defaultMessageCallback(32 MsgItemPickup, 65 , 3, 0, , , , , , , , )
Entering onServerMessage()
Leaving onServerMessage() - return
Leaving defaultMessageCallback() - return
Entering handleItemPickup(32 MsgItemPickup, 65 , 3, 0, )
Leaving handleItemPickup() - return
Leaving clientCmdServerMessage() - return
Entering ServerCmdUseTool(6119, 3)
Leaving ServerCmdUseTool() - return 3
Entering hegrenadeProjectile::OnCollision(689, 7176, 6111, 1, -37.075539 0.281174 0.000001, 0.000000 0.000000 1.000000)
Entering ServerPlay3D(hegrenadeBounceSound, -37.9334 0.439387 0.231595 1 0 0 0)
Leaving ServerPlay3D() - return 7006
Leaving hegrenadeProjectile::OnCollision() - return 7006
...A ton more onCollisions just with different positions...
Entering hegrenadeProjectile::OnCollision(689, 7176, 6111, 1, -31.338066 -0.776994 0.000000, 0.000000 0.000000 1.000000)
Entering ServerPlay3D(hegrenadeBounceSound, -31.3381 -0.776994 2.49594e-07 1 0 0 0)
Leaving ServerPlay3D() - return -31.338066 -0.776994 0.000000
Leaving hegrenadeProjectile::OnCollision() - return -31.338066 -0.776994 0.000000
Entering [projectileStuff]ProjectileData::onExplode(689, 7176, -31.338066 -0.776994 0.010000)
Entering vectorClampF(21.5871 -19.3492 7.72059, 0, 200)
Leaving vectorClampF() - return 21.5871 -19.3492 7.72059
Entering [projectileStuff]Projectile::onAdd(7178)
Entering Projectile::onAdd(7178)
Leaving Projectile::onAdd() - return -31.3381 -0.776994 0.01
DUMP AFTER ADD
Member Fields:
dataBlock = "hegrenadeProjectile"
initialPosition = "-31.3381 -0.776994 0.01"
initialVelocity = "21.5871 -19.3492 7.72059"
position = "-31.3381 -0.776994 0.01"
rotation = "1 0 0 0"
scale = "1 1 1"
sourceObject = "7006"
sourceSlot = "0"
Tagged Fields:
client = "6119"
originPoint = "-31.3381 -0.776994 0.01"
Methods:
addScheduledEvent() -
...
ToggleEventEnabled() -
Leaving [projectileStuff]Projectile::onAdd() - return -31.3381 -0.776994 0.01
NEW PROJECTILE #1 DUMP (onExplode)
7178
Member Fields:
dataBlock = "hegrenadeProjectile"
initialPosition = "-31.3381 -0.776994 0.01"
initialVelocity = "21.5871 -19.3492 7.72059"
position = "-31.3381 -0.776994 0.01"
rotation = "1 0 0 0"
scale = "1 1 1"
sourceObject = "7006"
sourceSlot = "0"
Tagged Fields:
client = "6119"
originPoint = "-31.3381 -0.776994 0.01"
Methods:
addScheduledEvent() -
...
ToggleEventEnabled() -
OLD PROJECTILE DUMP (onExplode)
7176
Member Fields:
dataBlock = "hegrenadeProjectile"
initialPosition = "-31.3381 -0.776994 2.49594e-07"
initialVelocity = "0 0 1"
position = "-31.3381 -0.776994 2.49594e-07"
rotation = "1 0 0 0"
scale = "1 1 1"
sourceObject = "7006"
sourceSlot = "0"
Tagged Fields:
client = "6119"
originPoint = "-49.1702 2.5118 2.48114"
Methods:
addScheduledEvent() -
...
ToggleEventEnabled() -
Entering [projectileStuff]Projectile::onRemove(7176)
DUMP BEFORE REMOVE
Member Fields:
dataBlock = "hegrenadeProjectile"
initialPosition = "-31.3381 -0.776994 2.49594e-07"
initialVelocity = "0 0 1"
position = "-31.3381 -0.776994 2.49594e-07"
rotation = "1 0 0 0"
scale = "1 1 1"
sourceObject = "7006"
sourceSlot = "0"
Tagged Fields:
client = "6119"
originPoint = "-49.1702 2.5118 2.48114"
Methods:
addScheduledEvent() -
...
ToggleEventEnabled() -
Add-Ons/Script_ProjectileStuff/server.cs (0): Unknown command onRemove.
Leaving [projectileStuff]Projectile::onRemove() - return
That is the log from the time I added the subProjectile field to the HEGrenadeProjectile datablock, to the time the server crashed.