| Blockland Forums > Modification Help |
| Can you drop/remove/throw an item datablock? |
| << < (2/3) > >> |
| phflack:
--- Quote from: xS K I D z on September 25, 2017, 10:14:32 PM ---moveMap.bind(keyboard, "x", dropTool); --- End quote --- that's the client side, letting them bind /dropTool to a key you'll probably want to look at the server side, serverCmdDropTool(%client, %slot) I did some testing and came up with this ingame function dropOther(%c,%i){%p=%c.player;%o=%p.tool[%p.currTool];%p.tool[%p.currTool]=%i;serverCmdDropTool(%c,%p.currTool);%p.tool[%p.currTool]=%o;messageClient(%c,'MsgItemPickup','',%p.currTool,%o);} more pretty version --- Code: ---function dropOtherItem(%client, %item) { if(!isObject(%player = %client.player)) return; %oldTool = %player.tool[%player.currTool]; %player.tool[%player.currTool] = %item; serverCmdDropTool(%client, %player.currTool); %player.tool[%player.currTool] = %oldTool; messageClient(%client, 'MsgItemPickup', '', %player.currTool, %oldTool); } --- End code --- it works by swapping out the tool, using the droptool command, and swapping it back note that this would work best if you're not trying to drop the same item, and if your item doesn't have an initial delay/equip animation input is the tool ID, ie, for hammer use nameToID("HammerItem") as the input |
| SUSHI:
For reference, the dropTool function looks something like this: --- Code: ---function serverCmdDropTool(%client, %slot) { %player = %client.getControlObject(); if(!isObject(%player)) return; %tool = %player.tool[%slot]; if(!isObject(%tool) || !%tool.canDrop) return; %playerTransform = %player.getTransform(); %playerRotation = rotFromTransform(%playerTransform); %playerPoint = posFromTransform(%playerTransform); %playerEyeVector = %player.getEyeVector(); %playerScale = %player.getScale(); %playerHeight = getWord(%playerScale, 2); %dropPoint = vectorAdd(%playerPoint, "0 0" SPC %playerHeight * 1.5); %dropDelta = vectorAdd(%dropPoint, %playerEyeVector); %item = new item() { dataBlock = %tool; }; missionCleanup.add(%item); %item.setTransform(%dropDelta SPC %playerRotation); %item.setScale(%playerScale); %item.setCollisionTimeout(%player); %itemVelocity = vectorScale(%playerEyeVector, 20.0 * %playerHeight); %item.setVelocity(%itemVelocity); %item.schedulePop(); %item.minigame = %client.minigame; %item.bl_id = %client.getBLID(); %toolImage = %tool.image; %mountSlot = %toolImage.mountPoint; %mounted = %player.getMountedImage(%mountSlot); if(isObject(%mounted) && %mounted.getID() == %toolImage.getID()) %player.unmountImage(%mountSlot); if(%tool.className $= "Weapon") %player.weaponCount -= 1; messageClient(%client, 'MsgItemPickup', '', %slot, 0); %player.tool[%slot] = 0; } --- End code --- |
| phflack:
useful, where is the code from? for dropping any item, can probably just rename the function and get rid of everything after %item.bl_id |
| Conan:
--- Quote from: phflack on September 26, 2017, 03:46:23 AM ---useful, where is the code from? for dropping any item, can probably just rename the function and get rid of everything after %item.bl_id --- End quote --- decompiled dso's, aka default code, you can ask any serious modder around here for *cough* some information |
| phflack:
was wondering if it was posted anywhere, besides decompiling it myself |
| Navigation |
| Message Index |
| Next page |
| Previous page |