function Player::GetLookTarget(%this,%dist)
{
%start = %this.getEyePoint();
%vec = %this.getEyeVector();
%end = vectorAdd(%start,vectorScale(%vec,%dist));
%ray = containerRaycast(%start,%end,$TypeMasks::PlayerObjectType,%this);
%col = firstWord(%ray);
if(!isObject(%col))
return -1;
return %col;
}
function Player::Special_Stab(%this)
{
%obj = %this.GetLookTarget(5);
if(%obj != -1)
{
%obj.kill();
}
}
now, to explain so eepos doesnt beat me up:
function Player::Special_Stab(%this)naming the function and setting parameters
%obj = %this.GetLookTarget(5);setting the target object to be the first thing that container raycast function picks up at distance 5
if(%obj != -1) checks if the player does exist because that container raycast function returns -1 if there is no object
%obj.kill(); kills the target because they exist
for more info on container raycasts, i think there is a vector topic about it or something