Forum
CS2D Scripts "Catch" an item thrown with spawnprojectile"Catch" an item thrown with spawnprojectile
8 replies 1
Check if someone's standing on the tile where the item should drop (OPT: check if it's a teammate/enemy)
use removeitem the moment it lands
equip it on the player who was standing where the item landed (NOTE: not all items can be equipped)
OPT: use setweapon for certain items.
Hope that helps.
Cheers.
Does the "projectile" hook trigger when a simple item lands?
x and y return impact position
Now will try to implement it
One solution is to use closeitems to check if there are any items with your thrown item ID around them (based on the notion that items of that ID aren't normally dropped or spawn on the map like items from Env_item entity or items from supply building.)
That works but it's really crude. It's probably faster & doesn't require so much computation if it meets the requirements though.
The second solution and a foolproof one at that is to get distance (since you have to calculate it to pass as one of the parameters for spawnprojectile command) and determine which tile it's going to land on.
Finally, the one I probably like best, is using projectilelist & projectile with "x","y","flydist" & "time" values to determine the landing point. You'll also get ID which you'll later use with removeitem (I think).
You may also use it to get "ground" projectiles and use that (don't want to think how cause no ( ͡° ͜ʖ ͡°))
Hope that helps.
Cheers.
1