Author Topic: Lilboarder's Help Topic  (Read 1550 times)

Okay, so I have had many generic Blockland function questions and what not. So I decided just to make a general thread where I can post my questions and other stuff I'm working on, in hope of someone helping me  :cookieMonster:.


Questions

1. What is the function for dropping an item? Would %client.dropTool(); do anything? How can I call that function on a raycast collision? I have right now %col.dropTool(); but it didn't seem to do anything.

2. How do I simulate picking up an item on collision with a raycast?

3. How do I set the scale of the player through a playertype?


That's all for now, I will update with any new questions and any and all help is appreciated. Thanks!
« Last Edit: May 28, 2009, 05:34:17 PM by lilboarder32 »

1. serverCmddropTool(%client, %client.player.currTool);
2. No. Those don't have collision, I believe Blockland uses its bounding box to determine if a player is close enough to pick it up.

Is there a way to detect the bounding box? Or even have the raycast hit the brick and manipulate the spawned item?

Is there a way to detect the bounding box?
I don't think so, and it may simply be within a radius of the spawnpoint of the item, which is more likely.
Or even have the raycast hit the brick and manipulate the spawned item?
Yes, with brick events. You would need to make onRaycastHit, though. For projectiles you would just use the default onProjectileHit. The ouputs you'd use are spawnItem and setItem.

I don't think so, and it may simply be within a radius of the spawnpoint of the item, which is more likely.
Yes, that makes sense.
Yes, with brick events. You would need to make onRaycastHit, though. For projectiles you would just use the default onProjectileHit. The ouputs you'd use are spawnItem and setItem.
What if I didn't want to use events. Could I use the raycast like this somehow?:

Code: [Select]
function WhateverImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::FxDtsBrickType))
{
%item = (someway to detect the item datablock of the brick);
%col.deleteTool(someway to remove the spawned item from the brick, as if your picking it up);
%client.addItem(%item); (Add the item to the players inventory?)
}
}
« Last Edit: May 23, 2009, 01:59:43 AM by lilboarder32 »

Looks like you're using spacecasts, thought so. And yes, that's basically how it would work, we just need to look up some variables and commands. Give me a minute.
%Item: Records the ID number of the item spawn, the spawn has an ID of the brick on it as well. You could try looping through mission cleanup item spawns to find the brick.
Player::pickup(%this,%item) - Use this it triggers when you take an item from a brick, %this is the brick, %item is duh.
« Last Edit: May 23, 2009, 02:25:10 AM by Amade »

How would I define %item though? You said it records the ID, but that's just a variable... What do you mean by that?

When an item is spawned on a brick, it gets several dynamic fields, including the ID number of the spawn (item = ID). The spawn gets the ID of the brick (brick = ID).

To get the item, I just realised you don't need a loop.

Assuming %obj is the player that created the raycast and %col is the brick:
Code: [Select]
%obj.addItem(%col.item.datablock);Assuming %this is the brick and %item is the datablock the spawn uses, what you want to use is:
Code: [Select]
Player::pickup(%col,%col.item.datablock);Not sure how to target %obj with that, though.

Recieved a syntax error with
Code: [Select]
%obj.addItem(%col.item.datablock); It put the halt at:
Code: [Select]
%obj.addItem(%col.item.datablock)##;##

serverCmddropTool(%client, %client.player.currTool);

What the hell is that stuff?

What the hell is that stuff?
Thats the current equiped tool
--
Pretty sure raycasts collide with items, seeing as there is a typemask.
$TypeMasks::ItemObjectType

Thats the current equiped tool
--
Pretty sure raycasts collide with items, seeing as there is a typemask.
$TypeMasks::ItemObjectType

Yes, it does collide with items. But how would I be able to simulate picking it up? I have right now:
Code: [Select]
package Accio
{
function AccioImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::ItemObjectType))
{
%obj.addItem(%col.getDatablock());
%col.pickup(%col,%col.getDatablock());
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
};
The %col.pickup(%col,%col.getDatablock()); was just to try and simulate picking the item up... Any suggestions or help?

This is basically event_additem but will not require event_additem. Check that first line, I probably messed up on the function or arguments.
Code: [Select]
function WhateverImage::onRaycastHitObject(%this, %obj, %col, %fade, %pos, %normal)
{
   for(%loop = 0; %loop < %obj.getDatablock().maxTools; %loop++)
   {
      %tool = %obj.tool[%loop];
      if(%tool == 0)
      {
         %obj.tool[%loop] = %image;
         %obj.weaponCount++;
         messageClient(%obj.client,'MsgItemPickup','',%loop,%col.item.getdatablock);
         break;
      }
   }
}

Ok, getting closer. I fixed up the arguments and function and it makes the sound when you recieve an item on collision with the raycast, but does not actually add the item.

What I just posted is for bricks, are you trying to get it from the spawn?