Blockland Forums > Modification Help
Item hit event
<< < (2/5) > >>
Demian:

--- Quote from: lordician on December 23, 2010, 09:20:09 AM ---How else did you want to hit the brick?
Raycasts?

--- End quote ---
That might be better. Can you limit the range of raycasts? I'm making a keycard and it would be pretty confusing if you could hit bricks very far away with such an item.
lordician:

--- Quote from: Demian on December 23, 2010, 09:22:46 AM ---That might be better. Can you limit the range of raycasts? I'm making a keycard and it would be pretty confusing if you could hit bricks very far away with such an item.

--- End quote ---
Of course you can.
Will you work with Spaceguy's raycast script then it should be obvious how.
Demian:
I copypasted the Support_RaycastingWeapons.cs from Space Guy's Buster Gun and added it to the server.cs executions along with the Event_onKeycardhit.cs which contains the code you provided and the cards of course.

It's not working. The event does appear on the list, but it's not working.

Currently my keycard projectile looks like this. Yes I changed the projectile name in the event script.

--- Code: ---datablock ProjectileData(keyCardProjectile)
{
   directDamage = 0;

   muzzleVelocity = 200;
   velInheritFactor = 1;

   armingDelay = 0;
   lifetime = 1000;
   fadeDelay = 100;
   bounceElasticity = 0;
   bounceFriction = 0;
   isBallistic = false;
   gravityMod = 0;

   hasLight = false;
   lightRadius = 1.0;
   lightColor = "0 0 0";

   uiName = "";
};
--- End code ---
The large values are just for testing.

Help?
lordician:
Now you work with raycasts, you have to adept the function for the event.
Like this,

--- Code: ---registerInputEvent(fxDTSBrick,onToolHit,"Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "Minigame Minigame");
function ToolProjectile::onHitObject(%this,%obj,%slot,%col,%pos,%normal,%shotVec,%crit)
{
parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal,%shotVec,%crit);
if(%col.getClassName() $= "fxDTSBrick")
{
$InputTarget_["Self"] = %col;
$InputTarget_["Player"] = %obj.client.player;
$InputTarget_["Client"] = %obj.client;
if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj.client);
}
else
{
if(getMiniGameFromObject(%col) == getMiniGameFromObject(%obj.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%col);
}
else
{
$InputTarget_["MiniGame"] = 0;
}
}
%col.processInputEvent(onToolHit,%obj.client);
}
}

--- End code ---
That should do the trick.
Demian:

--- Quote from: lordician on December 23, 2010, 01:58:28 PM ---Now you work with raycasts, you have to adept the function for the event.
-snip-
That should do the trick.

--- End quote ---
Doesn't work. Am I doing it right?


--- Code: ---registerInputEvent(fxDTSBrick,onKeycardHit,"Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "Minigame Minigame");

function keyCardProjectile::onHitObject(%this,%obj,%slot,%col,%pos,%normal,%shotVec,%crit)
{
parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal,%shotVec,%crit);
if(%col.getClassName() $= "fxDTSBrick")
{
$InputTarget_["Self"] = %col;
$InputTarget_["Player"] = %obj.client.player;
$InputTarget_["Client"] = %obj.client;
if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj.client);
}
else
{
if(getMiniGameFromObject(%col) == getMiniGameFromObject(%obj.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%col);
}
else
{
$InputTarget_["MiniGame"] = 0;
}
}
%col.processInputEvent(onKeycardHit,%obj.client);
}
}
--- End code ---
Navigation
Message Index
Next page
Previous page

Go to full version