Page 1 of 1

[SOLVED]PickUp/Drop object/item script

Posted: Sun Aug 18, 2019 7:06 pm
by Bishop
Hello, I need drop mounted item...I have this script with mouse 0 button1 - dropItem and
button0 - RayCastObject
....pick up item works great but when I want to drop an item it doesn't work.
function serverCmdRayCastObject(%client,%obj)
   %range = 4;
   $control = %client.getControlObject();
   %eyePos = $control.getEyePoint();
   %eyeVec = $control.getEyeVector();
   %mask = $TypeMasks::StaticShapeObjectType|$TypeMasks::ItemObjectType;
   %dirScaled = VectorScale(%eyeVec, %range);
   %endPoint = VectorAdd(%eyePos, %dirScaled);
   %result = containerRayCast(%eyePos, %endPoint, %mask, %client.getControlObject(), false);
   if (getWordCount(%result) > 0 && getWord(%result, 0) !$= "0")
        %obj = getWord(%result, 0);
        if (%obj.internalName $= "Item")
            ItemText.schedule(500, "setText", ""); 
         if (%obj.parentGroup $= "InteractiveItems")
            ItemText.setText( SPC "PICKED UP");
            ItemText.schedule(2000, "setText", "");
            $control.mountObject (%obj, 0);
          if (%obj.isMounted ())
            echo("is Mounted");
            $control.unmountObject (%obj);
//.     Drop Items command 
function serverCmddropItem (%client, %obj)
   ItemText.setText("ITEM DROPED");
   ItemText.schedule(1000, "setText", "");
//------------------------------------------------------------------------------ unmount works this way but I need Drop an item only when I press the mouse button.

Re: Drop object/item script

Posted: Tue Aug 20, 2019 6:57 pm
by Duion
There is a hotkey to throw the weapon you are holding, just press it. You can modify the throw function and reduce the force and maybe remove the throw sound and it should be pretty good.

Re:[SOLVED]PickUp/Drop object/item script

Posted: Fri Aug 23, 2019 4:33 pm
by Bishop
@ Duion Thanks,....I only use Empty project template for my projects so I'm putting together from the ground simple game mechanics scripts everything as needed by the project.....slowly and step by step....while looking in the documentation and net.
......after a short pause, i finally put it together and a script for a pick up and drop objects / items works great....serverCmdRayCastObject(%client, %obj) function takes care of mounting item to mount node and serverCmddropItem(%client, %obj) takes care of drop(unmount) item....This..
%control = %client.getControlObject();
%mountedItem = %control.getMountedObject(0);
if (%mountedItem.isMounted())
} was crucial that drop / unmount work.