Author Topic: Modifying the default tools?  (Read 1152 times)

How do I modify things like the Printer or Wrench .cs files? There is nothing in the Addons folder. Can someone help me?

it's under "base" not "Add-Ons" IIRC

it's under "base" not "Add-Ons" IIRC
After a brief search I couldn't find anything other than the models.

You can't edit their CS files, they're encrypted into the game, you can only create your own CS file that overwrites something from their particle, sound, projectile, explosion, item and image datablocks

They are .dso files, which are compiled forms of .cs files. Not exactly encrypted into the game.

But yeah, you'd have to modify them through your own .cs file.

I transcribed and mashed together some default code for some tools, if you want more functions or datablocks just ask
and keep in mind these should just be used as references and I may have made a few mistakes in the code (not super likely though)

Code: [Select]
datablock AudioProfile(hammerHitSound)
{
fileName = "base/data/sound/hammerHit.wav";
description = AudioClosest3d;
preload = true;
};
datablock ParticleData(hammerSparkParticle)
{
dragCoefficient = "4";
windCoefficient = "1";
gravityCoefficient = "0.998779";
inheritedVelFactor = "0.199609";
constantAcceleration = "0";
lifetimeMS = "400";
lifetimeVarianceMS = "300";
spinSpeed = "150";
spinRandomMin = "-150";
spinRandomMax = "150";
useInvAlpha = "0";
animateTexture = "0";
framesPerSec = "1";
textureName = "base/data/particles/star1";
animTexName[0] = "base/data/particles/star1";
colors[0] = "1.000000 1.000000 0.000000 0.000000";
colors[1] = "1.000000 1.000000 0.000000 0.466667";
colors[2] = "1.000000 1.000000 0.000000 0.000000";
colors[3] = "1.000000 1.000000 1.000000 1.000000";
sizes[0] = "0.149545";
sizes[1] = "0.0488311";
sizes[2] = "0";
sizes[3] = "1";
times[0] = "0";
times[1] = "0.498039";
times[2] = "1";
times[3] = "2";
};
datablock ParticleEmitterData(hammerSparkEmitter)
{
className = "ParticleEmitterData";
ejectionPeriodMS = "3";
periodVarianceMS = "0";
ejectionVelocity = "5";
velocityVariance = "3";
ejectionOffset = "0.5";
thetaMin = "0";
thetaMax = "90";
phiReferenceVel = "0";
phiVariance = "360";
overrideAdvance = "0";
orientParticles = "0";
orientOnVelocity = "1";
particles = "hammerSparkParticle";
lifetimeMS = "50";
lifetimeVarianceMS = "0";
useEmitterSizes = "0";
useEmitterColors = "0";
uiName = "Hammer Spark";
doFalloff = "1";
doDetail = "1";
};
datablock ParticleData(hammerExplosionParticle)
{
dragCoefficient = "9.99995";
windCoefficient = "1";
gravityCoefficient = "-0.15873";
inheritedVelFactor = "0.199609";
constantAcceleration = "0";
lifetimeMS = "500";
lifetimeVarianceMS = "300";
spinSpeed = "50";
spinRandomMin = "-50";
spinRandomMax = "50";
useInvAlpha = "0";
animateTexture = "0";
framesPerSec = "1";
textureName = "base/data/particles/cloud";
animTexName[0] = "base/data/particles/cloud";
colors[0] = "1.000000 1.000000 1.000000 0.200000";
colors[1] = "0.000000 0.000000 0.000000 0.000000";
colors[2] = "1.000000 1.000000 1.000000 1.000000";
colors[3] = "1.000000 1.000000 1.000000 1.000000";
sizes[0] = "0.497467";
sizes[1] = "0.997986";
sizes[2] = "1";
sizes[3] = "1";
times[0] = "0";
times[1] = "1";
times[2] = "2";
times[3] = "2";
};
datablock ParticleEmitterData(hammerExplosionEmitter)
{
className = "ParticleEmitterData";
ejectionPeriodMS = "3";
periodVarianceMS = "0";
ejectionVelocity = "10";
velocityVariance = "1";
ejectionOffset = "0";
thetaMin = "80";
thetaMax = "85";
phiReferenceVel = "0";
phiVariance = "360";
overrideAdvance = "0";
orientParticles = "0";
orientOnVelocity = "1";
particles = "hammerExplosionParticle";
lifetimeMS = "50";
lifetimeVarianceMS = "0";
useEmitterSizes = "0";
useEmitterColors = "0";
uiName = "Hammer Smoke";
doFalloff = "1";
doDetail = "1";
};
datablock ExplosionData(hammerExplosion)
{
className = "ExplosionData";
faceViewer = "1";
particleDensity = "10";
particleRadius = "1";
explosionScale = "1 1 1";
playSpeed = "1";
emitter[0] = "hammerExplosionEmitter";
emitter[1] = "hammerSparkEmitter";
debrisThetaMin = "0";
debrisThetaMax = "90";
debrisPhiMin = "0";
debrisPhiMax = "360";
debrisNum = "1";
debrisNumVariance = "0";
debrisVelocity = "2";
debrisVelocityVariance = "0";
delayMS = "0";
delayVariance = "0";
lifetimeMS = "400";
lifetimeVariance = "0";
offset = "0";
times[0] = "0";
times[1] = "1";
times[2] = "1";
times[3] = "1";
sizes[0] = "1 1 1";
sizes[1] = "1 1 1";
sizes[2] = "1 1 1";
sizes[3] = "1 1 1";
shakeCamera = "1";
cameraShakeFalloff = "1";
camShakeFreq = "20 22 20";
camShakeAmp = "0.5 0.5 0.5";
camShakeDuration = "0.5";
camShakeRadius = "10";
camShakeFalloff = "10";
lightStartRadius = "1.56863";
lightEndRadius = "0.392157";
lightStartColor = "0.598425 0.598425 0.000000 1.000000";
lightEndColor = "0.000000 0.000000 0.000000 1.000000";
};
AddDamageType("HammerDirect", '<bitmap:base/client/ui/ci/hammer> %1', '%2 <bitmap:base/client/ui/ci/hammer> %1', "0", "1");
datablock ProjectileData(hammerProjectile)
{
className = "ProjectileData";
scale = "1 1 1";
Explosion = "hammerExplosion";
hasLight = "0";
lightRadius = "3";
lightColor = "0.000000 0.000000 0.500000 1.000000";
hasWaterLight = "0";
waterLightColor = "1.000000 1.000000 1.000000 1.000000";
isBallistic = "0";
collideWithPlayers = "1";
velInheritFactor = "1";
muzzleVelocity = "50";
restVelocity = "1";
lifetime = "0";
armingDelay = "0";
fadeDelay = "2";
explodeOnDeath = "1";
explodeOnPlayerImpact = "0";
bounceAngle = "0";
minStickVelocity = "0";
ballRadius = "0";
bounceElasticity = "0";
bounceFriction = "0";
gravityMod = "0";
directDamage = $DamageType::HammerDirect;
radiusDamageType = $DamageType::HammerDirect;
directDamageType = "10";
radiusDamage = "0";
damageRadius = "0";
};
datablock ItemData(hammerItem)
{
category = "Tools";
className = "Weapon";
shapeFile = "base/data/shapes/Hammer.dts";
emap = "1";
renderWhenDestroyed = "1";
mass = "1";
drag = "0.5";
density = "0.2";
maxDamage = "1";
disabledLevel = "1";
destroyedLevel = "1";
repairRate = "0.0033";
rechargeRate = "0.4";
pickUpName = "an item";
friction = "0.599218";
elasticity = "0.199413";
sticky = "0";
gravityMod = "1";
maxVelocity = "-1";
dynamicType = "0";
lightType = "NoLight";
lightColor = "1.000000 1.000000 1.000000 1.000000";
lightTime = "1000";
lightRadius = "10";
uiName = "Hammer ";
iconName = "base/client/ui/itemIcons/Hammer";
doColorShift = "1";
colorShiftColor = "0.196850 0.196850 0.196850 1.000000";
canDrop = "1";
image = "hammerImage";
};
datablock ShapeBaseImageData(hammerImage)
{
className = "WeaponImage";
emap = "1";
shapeFile = "base/data/shapes/Hammer.dts";
Projectile = "hammerProjectile";
cloakable = "1";
mountPoint = "0";
offset = "0 0 0";
rotation = "1 0 0 0";
eyeOffset = "0.7 1.2 -0.15";
eyeRotation = "1 0 0 0";
correctMuzzleVector = "0";
firstPerson = "1";
usesEnergy = "0";
minEnergy = "2";
accuFire = "0";
lightType = "NoLight";
lightColor = "1.000000 1.000000 1.000000 1.000000";
lightTime = "1000";
lightRadius = "10";
shellExitDir = "0.707107 0 0.707107";
shellExitVariance = "20";
shellVelocity = "1";

doColorShift = "1";
colorShiftColor = "0.196850 0.196850 0.196850 1.000000";
firstPersonParticles = "1";
ammo = " ";
Item = "hammerItem";
melee = "1";
projectileType = "Projectile";
doRetraction = "0";
armReady = "1";
showBricks = "1";

stateName[0] = "Activate";
stateTimeoutValue[0] = "0";
stateTransitionOnTimeout[0] = "Ready";

stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "PreFire";
stateTimeoutValue[1] = "0";

stateName[2] = "PreFire";
stateScript[2] = "onPreFire";
stateTransitionOnTimeout[2] = "fire";
stateTimeoutValue[2] = "0.01";

stateName[3] = "Fire";
stateScript[3] = "onFire";
stateTransitionOnTimeout[3] = "CheckFire";
stateTimeoutValue[3] = "0.2";
stateFire[3] = "1";
stateSequence[3] = "fire";

stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTransitionOnTriggerDown[4] = "fire";
stateTimeoutValue[4] = "0";

stateName[5] = "StopFire";
stateScript[5] = "onStopFire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = "0.2";
stateSequence[5] = "StopFire";
};
function hammerImage::onPreFire(%this, %obj, %slot)
{
%obj.playThread("2", "armattack");
}
function hammerImage::onStopFire(%this, %obj, %slot)
{
%obj.playThread("2", "root");
}
function hammerImage::onFire(%this, %player, %slot)
{
%start = %player.getEyePoint();
%muzzleVec = %player.getMuzzleVector(%slot);
%muzzleVecZ = getWord(%muzzleVec, "2");
if(%muzzleVecZ < -0.9)
%range = 5.5;
else
%range = 5;

%vec = VectorScale(%muzzleVec, (%range * getWord(%player.getScale(), "2")));
%end = VectorAdd(%start, %vec);
%mask = $TypeMasks::FxBrickAlwaysObjectType | $TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType | $TypeMasks::StaticShapeObjectType | $TypeMasks::StaticObjectType;

if(%player.isMounted())
%raycast = containerRayCast(%start, %end, %mask, %player, %player.getObjectMount());
else
%raycast = containerRayCast(%start, %end, %mask, %player);

if(!%raycast)
return;
%hitObj = getWord(%raycast, "0");
%hitPos = getWords(%raycast, "1", "3");
%hitNormal = getWords(%raycast, "4", "6");

%projectilePos = VectorSub(%hitPos, VectorScale(%player.getEyeVector(), "0.25"));

%p = new projectile()
{
dataBlock = hammerProjectile;
initialVelocity = %hitNormal;
initialPosition = %projectilePos;
sourceObject = %player;
sourceSlot = %slot;
client = %player.client;
};
%p.setScale(%player.getScale());
missionCleanup.add(%p);
%this.onHitObject(%player, %slot, %hitObj, %hitPos, %hitNormal);
}
function hammerImage::onHitObject(%this, %player, %slot, %hitObj, %hitPos, %hitNormal)
{
%client = %player.client;
ServerPlay3D("hammerHitSound", %hitPos);
if(!isObject(%client))
return;
if(%hitObj.getType() & $TypeMasks::FxBrickAlwaysObjectType)
{
if(!isObject(%client))
return;
if(%hitObj.getType() & $TypeMasks::FxBrickAlwaysObjectType)
{
if(!isObject(%client))
return;
if(!%hitObj.willCauseChainKill())
{
if(getTrustLevel(%player, %hitObj) < $TrustLevel::Hammer)
{
if(%hitObj.stackBL_ID !$= "")
{
if(%hitObj.stackBL_ID != %client.getBLID())
{
%client.sendTrustFailureMessage(%hitObj.getGroup());
}
}
}
else
{
%hitObj.onToolBreak(%client);
$CurrBrickKiller = %client;
%hitObj.killBrick();
}
}
}
}
else if(%hitObj.getClassName() $= "Player")
{
if(miniGameCanDamage(%client,%hitObj) == 1)
{
%hitObj.Damage(%player, %hitPos, hammerProjectile.directDamage, $DamageType::HammerDirect);
}
}
else if(%hitObj.getClassName() $= "WheeledVehicle" || %hitObj.getClassName() $= "HoverVehicle" || %hitObj.getClassName() $= "FlyingVehicle")
{
%mount = %player;
for(%i=0;%i<100;%i++)
{
if(%mount == %hitObj)
return;
if(!%mount.isMounted())
break;
%mount = %mount.getObjectMount();
}
%doFlip = 0;
if(isObject(%hitObj.spawnBrick))
%vehicleOwner = findClientByBL_ID(%hitObj.spawnBrick.getGroup().bl_id);
else
%vehicleOwner = 0;

if(isObject(%vehicleOwner))
{
if(getTrustLevel(%player, %hitObj) >= $TrustLevel::VehicleTurnover)
%doFlip = 1;
}
if(miniGameCanDamage(%player, %hitObj) == 1)
%doFlip = 1;

if(miniGameCanDamage(%player, %hitObj) == 0)
%doFlip = 0;

if(%doFlip)
{
%impulse = VectorNormalize(%vec);
%impulse = VectorAdd(%impulse, "0 0 1");
%impulse = VectorNormalize(%impulse);
%force = (%hitObj.getDataBlock().mass * 5);
%impulse = VectorScale(%impulse, %force);
%hitObj.applyImpulse(%hitPos, %impulse);
}
}
}

Code: [Select]
datablock AudioProfile(wrenchHitSound)
{
fileName = "base/data/sound/wrenchHit.wav";
description = "AudioClose3d";
preload = true;
};
datablock AudioProfile(wrenchMissSound)
{
fileName = "base/data/sound/wrenchMiss.wav";
description = "AudioClose3d";
preload = true;
};
datablock ParticleData(wrenchSparkParticle)
{
dragCoefficient = "4";
windCoefficient = "1";
gravityCoefficient = "0.998779";
inheritedVelFactor = "0.199609";
constantAcceleration = "0";
lifetimeMS = "400";
lifetimeVarianceMS = "300";
spinSpeed = "150";
spinRandomMin = "-150";
spinRandomMax = "150";
useInvAlpha = "1";
animateTexture = "0";
framesPerSec = "1";
textureName = "base/data/particles/chunk";
animTexName[0] = "base/data/particles/chunk";
colors[0] = "0.200000 0.066667 0.000000 1.000000";
colors[1] = "0.000000 0.000000 0.000000 0.466667";
colors[2] = "0.000000 0.000000 0.000000 0.000000";
colors[3] = "1.000000 1.000000 1.000000 1.000000";
sizes[0] = "0.149545";
sizes[1] = "0.0488311";
sizes[2] = "0";
sizes[3] = "1";
times[0] = "0";
times[1] = "0.498039";
times[2] = "1";
times[3] = "2";
};
datablock ParticleEmitterData(wrenchSparkEmitter)
{
className = "ParticleEmitterData";
ejectionPeriodMS = "3";
periodVarianceMS = "0";
ejectionVelocity = "5";
velocityVariance = "3";
ejectionOffset = "0.5";
thetaMin = "0";
thetaMax = "90";
phiReferenceVel = "0";
phiVariance = "360";
overrideAdvance = "0";
orientParticles = "0";
orientOnVelocity = "1";
particles = "wrenchSparkParticle";
lifetimeMS = "50";
lifetimeVarianceMS = "0";
useEmitterSizes = "0";
useEmitterColors = "0";
uiName = "Wrench Oil";
doFalloff = "1";
doDetail = "1";
};
datablock ParticleData(wrenchExplosionParticle)
{
dragCoefficient = "2";
windCoefficient = "1";
gravityCoefficient = "0.495726";
inheritedVelFactor = "0.199609";
constantAcceleration = "0";
lifetimeMS = "500";
lifetimeVarianceMS = "300";
spinSpeed = "50";
spinRandomMin = "300";
spinRandomMax = "650";
useInvAlpha = "0";
animateTexture = "0";
framesPerSec = "1";
textureName = "base/data/particles/nut";
animTexName[0] = "base/data/particles/nut";
colors[0] = "1.000000 1.000000 0.000000 1.000000";
colors[1] = "1.000000 0.000000 0.000000 0.000000";
colors[2] = "1.000000 1.000000 1.000000 1.000000";
colors[3] = "1.000000 1.000000 1.000000 1.000000";
sizes[0] = "0.299091";
sizes[1] = "0.299091";
sizes[2] = "1";
sizes[3] = "1";
times[0] = "0";
times[1] = "1";
times[2] = "2";
times[3] = "2";
};
datablock ParticleEmitterData(wrenchExplosionEmitter)
{
className = "ParticleEmitterData";
ejectionPeriodMS = "3";
periodVarianceMS = "0";
ejectionVelocity = "2";
velocityVariance = "1";
ejectionOffset = "0.19";
thetaMin = "0";
thetaMax = "180";
phiReferenceVel = "0";
phiVariance = "360";
overrideAdvance = "0";
orientParticles = "0";
orientOnVelocity = "1";
particles = "wrenchExplosionParticle";
lifetimeMS = "50";
lifetimeVarianceMS = "0";
useEmitterSizes = "0";
useEmitterColors = "0";
uiName = "Wrench Nut";
doFalloff = "1";
doDetail = "1";
};
datablock ExplosionData(wrenchExplosion)
{
className = "ExplosionData";
faceViewer = "1";
particleDensity = "10";
particleRadius = "1";
explosionScale = "1 1 1";
playSpeed = "1";
emitter[0] = "wrenchExplosionEmitter";
emitter[1] = "wrenchSparkEmitter";
debrisThetaMin = "0";
debrisThetaMax = "90";
debrisPhiMin = "0";
debrisPhiMax = "360";
debrisNum = "1";
debrisNumVariance = "0";
debrisVelocity = "2";
debrisVelocityVariance = "0";
delayMS = "0";
delayVariance = "0";
lifetimeMS = "400";
lifetimeVariance = "0";
offset = "0";
times[0] = "0";
times[1] = "1";
times[2] = "1";
times[3] = "1";
sizes[0] = "1 1 1";
sizes[1] = "1 1 1";
sizes[2] = "1 1 1";
sizes[3] = "1 1 1";
shakeCamera = "0";
cameraShakeFalloff = "1";
camShakeFreq = "20 22 20";
camShakeAmp = "1 1 1";
camShakeDuration = "0.5";
camShakeRadius = "10";
camShakeFalloff = "10";
lightStartRadius = "1.56863";
lightEndRadius = "0.392157";
lightStartColor = "1.000000 0.496063 0.000000 1.000000";
lightEndColor = "0.000000 0.000000 0.000000 1.000000";
};
datablock ProjectileData(wrenchProjectile)
{
className = "ProjectileData";
scale = "1 1 1";
Explosion = "wrenchExplosion";
hasLight = "0";
lightRadius = "3";
lightColor = "0.000000 0.000000 0.500000 1.000000";
hasWaterLight = "0";
waterLightColor = "1.000000 1.000000 1.000000 1.000000";
isBallistic = "0";
collideWithPlayers = "1";
velInheritFactor = "1";
muzzleVelocity = "50";
restVelocity = "1";
lifetime = "0";
armingDelay = "0";
fadeDelay = "2";
explodeOnDeath = "1";
explodeOnPlayerImpact = "0";
bounceAngle = "0";
minStickVelocity = "0";
ballRadius = "0";
bounceElasticity = "0";
bounceFriction = "0";
gravityMod = "0";
directDamage = "10";
};
datablock ItemData(WrenchItem)
{
category = "Tools";
className = "Weapon";
shapeFile = "base/data/shapes/wrench.dts";
emap = "1";
renderWhenDestroyed = "1";
mass = "1";
drag = "0.5";
density = "0.2";
maxEnergy = "0";
maxDamage = "1";
disabledLevel = "1";
destroyedLevel = "1";
repairRate = "0.0033";
rechargeRate = "0.4";
inheritEnergyFromMount = "0";
isInvincible = "0";
firstPersonOnly = "0";
thirdPersonOnly = "0";
useEyePoint = "0";
observeThroughObject = "0";
pickUpName = "an item";
friction = "0.599218";
elasticity = "0.199413";
sticky = "0";
gravityMod = "1";
maxVelocity = "-1";
dynamicType = "0";
lightType = "NoLight";
lightColor = "1.000000 1.000000 1.000000 1.000000";
lightTime = "1000";
lightRadius = "10";
lightOnlyStatic = "0";
uiName = "Wrench";
iconName = "base/client/ui/itemIcons/wrench";
doColorShift = "1";
colorShiftColor = "0.464567 0.464567 0.464567 1.000000";
canDrop = "1";
image = "wrenchImage";
};
datablock ShapeBaseImageData(wrenchImage)
{
className = "WeaponImage";
emap = "1";
shapeFile = "base/data/shapes/wrench.dts";
Projectile = "wrenchProjectile";
cloakable = "1";
mountPoint = "0";
offset = "0 0 0";
rotation = "1 0 0 0";
eyeOffset = "0.7 1.2 -0.15";
eyeRotation = "1 0 0 0";
correctMuzzleVector = "0";
firstPerson = "1";
usesEnergy = "0";
minEnergy = "2";
accuFire = "0";
lightType = "NoLight";
lightColor = "1.000000 1.000000 1.000000 1.000000";
lightTime = "1000";
lightRadius = "10";
shellExitDir = "0.707107 0 0.707107";
shellExitVariance = "20";
shellVelocity = "1";

doColorShift = "1";
colorShiftColor = "0.464567 0.464567 0.464567 1.000000";
firstPersonParticles = "1";
ammo = " ";
nonLethal = "1";
Item = "wrenchItem";
melee = "1";
projectileType = "Projectile";
doRetraction = "0";
armReady = "1";
showBricks = "1";

stateName[0] = "Activate";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = "0";

stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "PreFire";
stateTimeoutValue[1] = "0";

stateName[2] = "PreFire";
stateScript[2] = "onPreFire";
stateTransitionOnTimeout[2] = "fire";
stateTimeoutValue[2] = "0.01";

stateName[3] = "Fire";
stateScript[3] = "onFire";
stateSequence[3] = "fire";
stateTransitionOnTimeout[3] = "CheckFire";
stateTimeoutValue[3] = "0.5";
stateFire[3] = "1";

stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTimeoutValue[4] = "0";

stateName[5] = "StopFire";
stateScript[5] = "onStopFire";
stateSequence[5] = "StopFire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = "0.01";
};
function WrenchImage::onPreFire(%this, %obj, %slot)
{
%obj.playThread("2", "wrench");
}
function WrenchImage::onStopFire(%this, %obj, %slot)
{
%obj.playThread("2", "root");
}
function WrenchImage::onFire(%this, %player, %slot)
{
%start = %player.getEyePoint();
%vec = VectorScale(%player.getMuzzleVector(%slot), (10 * getWord(%player.getScale(), "2")));
%end = VectorAdd(%start, %vec);
%mask = $TypeMasks::StaticObjectType | $TypeMasks::FxBrickAlwaysObjectType;
%raycast = containerRayCast(%start, %end, %mask);
if(!%raycast)
return;

%hitObj = getWord(%raycast, "0");
%hitPos = getWords(%raycast, "1", "3");
%hitNormal = getWords(%raycast, "4", "6");
%projectilePos = VectorSub(%hitPos, VectorScale(%player.getEyeVector(), "0.25"));
%p = new projectile()
{
dataBlock = "wrenchProjectile";
initialVelocity = "0 0 0";
initialPosition = %projectilePos;
sourceObject = %player;
sourceSlot = %slot;
client = %player.client;
};
%p.setScale(%player.getScale());
missionCleanup.add(%p);
%this.onHitObject(%player, %slot, %hitObj, %hitPos, %hitNormal);
}
function WrenchImage::onHitObject(%this, %player, %slot, %hitObj, %hitPos, %hitNormal)
{
%client = %player.client;
if(%hitObj.getType() & $TypeMasks::FxBrickAlwaysObjectType)
{
%adminOverride = 0;
if(!getTrustLevel(%player, %hitObj) >= $TrustLevel::Wrench)
{
if(%client.isAdmin)
{
%adminOverride = 1;
}
else
{
%client.sendTrustFailureMessage(%hitObj.getGroup());
ServerPlay3D("wrenchMissSound", %hitPos);
return;
}
}
if(!$Server::LAN)
{
if(%client.minigame)
{
if(isObject(%brickGroup = %hitObj.getGroup()))
{
if(isObject(%brickGroup.client))
{
if(isObject(%brickGroup.client.minigame))
{
if(%brickGroup.client.minigame != %client.minigame)
{
commandToClient(%client, 'CenterPrint', %brickGroup.name @ " is not in the minigame.", "1");
ServerPlay3D("wrenchMissSound", %hitPos);
return;
}
}
}
}
}
else
{
if(isObject(%brickGroup = %hitObj.getGroup()))
{
if(isObject(%brickGroup.client))
{
if(isObject(%brickGroup.client.minigame))
{
if(%brickGroup.client.miniGame.UseAllPlayersBricks)
{
if(%brickGroup.client.miniGame.owner != %brickGroup.client)
{
commandToClient(%client, 'CenterPrint', %brickGroup.name @ "\'s bricks are in a minigame right now.", "1");
ServerPlay3D("wrenchMissSound", %hitPos);
return;
}
}
}
}
}
}
}
if(%adminOverride)
{
%client.wrenchBrick = "";
%client.adminWrenchBrick = %hitObj;
}
else
{
%client.wrenchBrick = %hitObj;
%client.adminWrenchBrick = "";
}
if(%client.brickGroup == %hitObj.getGroup())
%allowNamedTargets = 1;
else
%allowNamedTargets = 0;
if(isObject(%hitObj.client))
%lanHeading = %hitObj.client.getPlayerName();
%netHeading = %hitObj.getGroup().name @ " - (BL_ID: " @ %hitObj.getGroup().bl_id @ ")";
if(%hitObj.getDataBlock().specialBrickType $= "Sound")
{
if($Server::Lan)
{
commandToClient(%client, 'openWrenchSoundDlg', %lanHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
else
{
commandToClient(%client, 'openWrenchSoundDlg', %netHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
%hitObj.sendWrenchSoundData(%client);
}
else if(%hitObj.getDataBlock().specialBrickType $= "VehicleSpawn")
{
if($Server::Lan)
{
commandToClient(%client, 'openWrenchVehicleSpawnDlg', %lanHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
else
{
commandToClient(%client, 'openWrenchVehicleSpawnDlg', %netHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
%hitObj.sendWrenchVehicleSpawnData(%client);
}
else if(%hitObj.getDataBlock().specialBrickType $= "BotSpawn")
{
if($Server::Lan)
{
commandToClient(%client, 'openWrenchBotSpawnDlg', %lanHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
else
{
commandToClient(%client, 'openWrenchBotSpawnDlg', %netHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
%hitObj.sendWrenchBotSpawnData(%client);
}
else
{
if($Server::Lan)
{
commandToClient(%client, 'openWrenchDlg', %lanHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
else
{
commandToClient(%client, 'openWrenchDlg', %netHeading, %allowNamedTargets, %adminOverride, $Server::WrenchEventsAdminOnly);
}
%hitObj.sendWrenchData(%client);
}
ServerPlay3D("wrenchHitSound", %hitPos);
}
else
{
ServerPlay3D("wrenchMissSound", %hitPos);
}
}
« Last Edit: November 21, 2016, 04:45:28 AM by Swollow »