Author Topic: Projectile item source  (Read 1243 times)

Hello,

How would I know what tool/weapon a projectile would come from, when all I know is the projectile object handler?


Pretty sure you can't figure out what weapon it came from, only the client/player

Pretty sure you can't figure out what weapon it came from, only the client/player
Yep, I know that. That's why I asked – was wondering if anyone knew a workaround.

Why don't you just say exactly what you're trying to do?

Why don't you just say exactly what you're trying to do?
if you mean get what image fired the projectile you could make it so upon creating a projectile you loop through the items the player has in their inventory (starting with their currently selected item) and then check if those item images use the projectile

Why don't you just say exactly what you're trying to do?
What I want to do is make the script know what WeaponImage fired the projectile that killed/damaged someone, so that I can do different things for each WeaponImage. The projectile does not store this information.

Couldn't you achieve the same by getting the player that killed / damaged someone and seeing what they're holding / if it relates to the projectile?

Couldn't you achieve the same by getting the player that killed / damaged someone and seeing what they're holding / if it relates to the projectile?
When the projectile hits, the person could have changed weapon.

When the projectile hits, the person could have changed weapon.
Yeah but in that case, you wouldn't be able to do anything to it anyway.. Depends what it is you want to do to the weaponimage I suppose

ok so package projectileData::onAdd and make it get whatever weapon the client is holding and then store that weapon image on the projectile

ok so package projectileData::onAdd and make it get whatever weapon the client is holding and then store that weapon image on the projectile
I'll try that.
EDIT: Yay, it works.
Code: [Select]
function Projectile::onAdd(%this)
{
%player = %this.sourceObject;
%this.weaponImage = %player.tool[%player.currTool];
}

Cheers!
« Last Edit: November 05, 2015, 04:49:51 PM by Quartz »