I'm trying to create a local thing, basically a particle effect on your own backpack after you drop it.
Originally I was assigning an id to the dropped backpack via SetThingUserData() in kyle.cog under the killed: message when the backpack was dropped, at the same time it'd send out a trigger to a local cog to create the particle effect on the backpack.
The trouble is, I was struggling to get it to be able to handle more than one backpack. I was using SetThingPulse() to create a pulse to generate the particle effect with CreateThing(). SetThingPulse can supposedly handle multiple things, but I need each CreateThing to reference a different thing...
The (GetPlayerNum(player) == GetParam(0)) If statements are basically there to differentiate which pack belongs to who. SetThingUserData() to zero on a thing causes a few hiccups, so for the host who has a GetPlayerNum of zero, I've used the number 253 instead.
Anyway... I wrote that up, then decided that aside from the trouble of getting it to handle multiple things, it might be a cleaner solution to just put the pulse in the backpacks class cog, which would be called by it's template when it was created.
These are the two messages that I've added into the pow_backpack.cog class cog.
The problems with this 2nd solution are:
a) The created: message in the class cog will likely be run before kyle.cog gets a chance to assign an ID to it via SetThingUserData(). The class cog needs this ID to determine if it's one of the local player's backpacks.
b) The CreateThing pulse doesn't create local things.
If anyone's got any ideas, it'd be a great help.
Thanks
Originally I was assigning an id to the dropped backpack via SetThingUserData() in kyle.cog under the killed: message when the backpack was dropped, at the same time it'd send out a trigger to a local cog to create the particle effect on the backpack.
The trouble is, I was struggling to get it to be able to handle more than one backpack. I was using SetThingPulse() to create a pulse to generate the particle effect with CreateThing(). SetThingPulse can supposedly handle multiple things, but I need each CreateThing to reference a different thing...
Code:
# Jedi Knight Cog Script # # BPACK_PULSE.COG # # # # GHORG # # flags=0x240 symbols message trigger message pulse thing pak local template bpck_effects=+smallcoreflow local end # ======================================================================================== code trigger: if (GetSourceRef() == 327350) { if ((GetPlayerNum(player) == 0) && (GetParam(0) == 253)) { pak = GetParam(1); CaptureThing(pak); SetThingPulse(pak, 0.5); } if (GetPlayerNum(player) == GetParam(0)) { CaptureThing(GetParam(1)); SetThingPulse(GetParam(1), 0.5); } } return; pulse: // CreateThingAtPosNR(bpck_effects, GetThingSector(pak), GetThingPos(pak), '0 0 0'); CreateThing(bpck_effects, pak); return; end
The (GetPlayerNum(player) == GetParam(0)) If statements are basically there to differentiate which pack belongs to who. SetThingUserData() to zero on a thing causes a few hiccups, so for the host who has a GetPlayerNum of zero, I've used the number 253 instead.
Anyway... I wrote that up, then decided that aside from the trouble of getting it to handle multiple things, it might be a cleaner solution to just put the pulse in the backpacks class cog, which would be called by it's template when it was created.
These are the two messages that I've added into the pow_backpack.cog class cog.
Code:
created: player = GetLocalPlayerThing(); powerup = GetSenderRef(); if ((GetPlayerNum(player) == 0) && (GetThingUserData(powerup) == 253)) { SetThingPulse(powerup, 0.5); } if (GetPlayerNum(player) == GetThingUserData(powerup)) { SetThingPulse(powerup, 0.5); } Return;
Code:
pulse: CreateThing(bpck_effects, GetSenderRef()); Return;
The problems with this 2nd solution are:
a) The created: message in the class cog will likely be run before kyle.cog gets a chance to assign an ID to it via SetThingUserData(). The class cog needs this ID to determine if it's one of the local player's backpacks.
b) The CreateThing pulse doesn't create local things.
If anyone's got any ideas, it'd be a great help.
Thanks