49
« on: July 25, 2011, 03:10:54 PM »
see here this is what i have there is no "ondoor" or "oncontent"
// ============================================================
// Project : CityRPG
// Author : Iban
// Description : Police Baton Code file
// ============================================================
// Table of Contents
// 1. Datablocks
// 2. Functions
// ============================================================
// ============================================================
// Section 1 : Datablocks
// ============================================================
datablock itemData(CityRPGBatonItem : hammerItem)
{
category = "Weapon";
uiName = "Baton";
image = CityRPGBatonImage;
colorShiftColor = "0.898039 0.898039 0.000000 1.000000";
// CityRPG Properties
noSpawn = true;
canArrest = true;
};
datablock shapeBaseImageData(CityRPGBatonImage : hammerImage)
{
// SpaceCasts
raycastWeaponRange = 6;
raycastWeaponTargets = $TypeMasks::All;
raycastDirectDamage = 25;
raycastDirectDamageType = $DamageType::HammerDirect;
raycastExplosionProjectile = hammerProjectile;
raycastExplosionSound = hammerHitSound;
item = CityRPGBatonItem;
projectile = hammerProjectile;
colorShiftColor = "0.898039 0.898039 0.000000 1.000000";
showBricks = 0;
};
// ============================================================
// Section 2 : Functions
// ============================================================
// Section 2.1 : Visual Functionality
function CityRPGBatonImage::onPreFire(%this, %obj, %slot)
{
%obj.playThread(2, "armAttack");
}
function CityRPGBatonImage::onStopFire(%this, %obj, %slot)
{
%obj.playThread(2, "root");
}
function CityRPGBatonImage::onHitObject(%this, %obj, %slot, %col, %pos, %normal)
{
if(%col.getClassName() $= "fxDTSBrick")
{
%client = %obj.client;
%brickData = %col.getDatablock();
if(isObject(%col.door) && %col.door.closed)
{
%col.fakeKillBrick(%vec, 3, %client);
%col.doorDestroy();
}
}
else if(%col.getClassName() $= "Player")
{
%client = %obj.client;
if((%col.getType() & $typeMasks::playerObjectType) && isObject(%col.client))
{
if(%col.client.getWantedLevel())
{
if(%col.getDatablock().maxDamage - (%col.getDamageLevel() + 25) < %this.raycastDirectDamage)
{
%col.setDamageLevel(%this.raycastDirectDamage + 1);
%col.client.arrest(%client);
}
else
commandToClient(%client, 'CenterPrint', "\c3" @ %col.client.name SPC "\c6has resisted arrest!", 3);
}
else if(CityRPGData.getData(%col.client.bl_id).valueBounty > 0)
commandToClient(%client, 'CenterPrint', "\c3" @ %col.client.name SPC "\c6is not wanted alive.", 3);
else
%doNoEvil = true;
}
}
if(%doNoEvil) { %this.raycastDirectDamage = 0; }
parent::onHitObject(%this, %obj, %slot, %col, %pos, %normal);
if(%doNoEvil) { %this.raycastDirectDamage = 25; }
}
function CityRPGBatonItem::onPickup(%this, %item, %obj)
{
%item.delete();
for(%a = 0; %a < %obj.getDatablock().maxTools; %a++)
{
if(!isObject(%obj.tool[%a]) || %obj.tool[%a].getName() !$= "CityRPGLBItem")
if(%freeSpot $= "" && %obj.tool[%a] $= "") { %freeSpot = %a; }
else
%alreadyOwns = true;
}
if(%freeSpot !$= "" && !%alreadyOwns)
{
%obj.tool[%freeSpot] = CityRPGLBItem.getID();
messageClient(%obj.client, 'MsgItemPickup', "", %freeSpot, %obj.tool[%freeSpot]);