I have a cog for a saber throw MOD. This is the returning saber (the item):
The problem is that in some single player levels by LEC all works perfectly and "powerup" goes towards "player" that is me. In other levels (n.3,6,9 for example) "powerup" goes toward an empty precise point in the level, just like GetSourceRef() returns not the player but something different (a ghost?). Any idea?
------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
Code:
flags=0x240
symbols
thing powerup local
thing player local
sound pickupsnd=thrmlpu2.wav local
message created
message timer
message touched
message taken
message removed
message pulse
end
code
created:
player = GetSourceRef();
powerup = GetSenderRef();
SetPulse(0.2);
if(!IsMulti())
SetTimerEx(5, GetSenderRef(), GetThingSignature(GetSenderRef()), 0);
return;
timer:
// if this object is still the same (could have been taken and reassigned)
if(GetThingSignature(GetSenderID()) == GetParam(0))
{
DestroyThing(GetSenderID());
call stop_power;
}
return;
touched:
if(GetLocalPlayerThing() == player)
TakeItem(powerup, player);
return;
taken:
// Do effects.
PlaySoundThing(pickupsnd, powerup, 1.0, -1, -1, 0);
AddDynamicTint(player, 0.0, 0.0, 0.2);
// Cleanup in the saber cog because we tried very hard
// NOT to call its selected: event just above to avoid
// playing the mount animation, etc.
SendMessage(GetInvCog(player,117),user0); // Deactivate saber throw...
SendMessage(GetInvCog(player,10),user1); // Fast mount...
return;
removed:
call stop_power;
return;
pulse:
// Returning the saber now...
// Much faster if both the player and the saber is in the water
if((GetSectorFlags(GetThingSector(player)) & 2) && (GetSectorFlags(GetThingSector(powerup)) & 2))
SetThingVel(powerup, VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(powerup))), 6));
else
// Faster if only one of the parent or the saber is in the water
if((GetSectorFlags(GetThingSector(player)) & 2) || (GetSectorFlags(GetThingSector(powerup)) & 2))
SetThingVel(powerup, VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(powerup))), 4));
// Normal speed of return if both are out of the water
else
SetThingVel(powerup, VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(powerup))), 2));
return;
stop_power:
SetPulse(0);
return;
end
The problem is that in some single player levels by LEC all works perfectly and "powerup" goes towards "player" that is me. In other levels (n.3,6,9 for example) "powerup" goes toward an empty precise point in the level, just like GetSourceRef() returns not the player but something different (a ghost?). Any idea?
------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
Nemios, MOD developer.
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)