Author Topic: Spawning a fake dropped item  (Read 904 times)

Is there a way to have a player "drop" an item without actually dropping it?
In other words, throwing an item, but the item remains in the player's inventory.
Also, the fake dropped item can be picked up by other players.

It would also be nice if I could control how long the dropped item remains before it fades out.

I think the global variable for fade time is either $Pref::Item::Poptime or maybe $Item::Poptime.  I'd have to look it up, it's been a while.
It's $Game::Item::PopTime, I just looked it up.  Remember it's in milliseconds, so 1000 = 1 second
« Last Edit: August 04, 2011, 12:45:13 AM by Gadgethm »

My guess is that the commands to remove a tool from the inventory and toss and item from the player are separate. You could probably just use the toss command.

I would look into the grenade scripts, and see if there's a separate command for removing the item. If so, just delete it.

The simplest way to do it would be to package the throw command, check (and store into a variable) what item the player is throwing before calling parent, then call parent, and if that variable exists, add the item back into the inventory after the parent is called.

You can spawn an item like so:
Code: (A project of mine) [Select]
%item = new Item()
{
dataBlock = "slyrCTF_Flag" @ %image.colorID @ "Item";

position = %this.getEyeTransform();

spawnBrick = %brick;
canPickup = 1;
};
missionCleanup.add(%item);

You can spawn an item like so:
Code: (A project of mine) [Select]
%item = new Item()
{
dataBlock = "slyrCTF_Flag" @ %image.colorID @ "Item";

position = %this.getEyeTransform();

spawnBrick = %brick;
canPickup = 1;
};
missionCleanup.add(%item);
Wouldn't that spawn an item on a brick, not physically "drop" it?

It would spawn an item wherever position is. So in my function, %this is a player, and it spawns the item at the player's eye node. The spawnBrick part is specific to my mod. To make the item actually be thrown, you'd have to add velocity to it in the direction the player is facing.

I'll try it out. Thanks.

Also, I would use Initial Velocity for the velocity, right?

I'm guessing this works in the same way spawning a projectile from a player would.

Also, I would use Initial Velocity for the velocity, right?

I'm guessing this works in the same way spawning a projectile from a player would.
I've never used initialVelocity before, but it would probably work. I used %item.setVelocity("x y z"); after I'd created the item.

And yes, it works in about the same way.