Plop in a folder in add-ons as server.cs, add a description.txt and you're good.
Enable and edit settings through RTB prefs.
Use events to give bricks, set a max on bricks, and remove bricks. LoseonDeath allows you to make it so that bricks are lost upon death. Health and HP give the bricks variable HP and the repair wrench lets you repair them at Repair rate.
$BrickPickupHealth=20;
if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
if(!$BrickPickup_set)
{
if(!$RTB::RTBR_ServerControl_Hook)
{
exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");
}
RTB_registerPref("BrickPickup", "BrickPickup", "Pref::RTB::BrickPickup", "bool", "BrickPickup", 0, 0, 0);
RTB_registerPref("LoseOnDeath", "BrickPickup", "Pref::RTB::BrickPickupdie", "bool", "BrickPickup", 0, 0, 0);
RTB_registerPref("HP", "BrickPickup", "Pref::RTB::BrickPickupHP", "bool", "BrickPickup", 0, 0, 0);
RTB_registerPref("Delete", "BrickPickup", "Pref::RTB::BrickPickupDelete", "bool", "BrickPickup", 0, 0, 0);
RTB_registerPref("HealthMod", "BrickPickup", "Pref::RTB::BrickPickupHealth", "int 0 5000", "BrickPickup", 20, 0, 0);
RTB_registerPref("Repair", "BrickPickup", "Pref::RTB::BrickPickupRepair", "int 0 5000", "BrickPickup", 20, 0, 0);
$BrickPickup_set=1;
}
}
package BrickPickup
{
function fxDTSBrick::onPlant(%brick, %brick2)
{
//if($classon||%brick.client.nobuild){
schedule(75,0,"BPPlantCheck",%brick);
//}
parent::onPlant(%brick, %brick2);
}
function servercmdBrickPickup(%client){
if(%client.issuperadmin){
if($BrickPickup==0){
announce("Bricks must now be picked up to be placed! /bp to see what bricks you have!");
$BrickPickup=1;
}else{
announce("Bricks may now be freely placed!");
$BrickPickup=0;
}
}
}
function servercmdBrickRemoveOnDeath(%client){
if(%client.issuperadmin){
if($BrickPickupdie==0){
announce("Bricks are now lost upon death!");
$BrickPickupdie=1;
}else{
announce("Bricks are now kept upon death!");
$BrickPickupdie=0;
}
}
}
function servercmdnobuild(%client,%name){
if(%client.issuperadmin){
%victim=findclientbyname(%name);
if(%victim){
%victim.nobuild++;
centerprint(%client, "Nobuild turned on for" SPC %victim.name,3);
if(%victim.nobuild > 1){
%victim.nobuild=0;
centerprint(%client, "Nobuild turned off for" SPC %victim.name,3);
}
}
}
}
function BPPlantCheck(%brick,%i)
{
if($Pref::RTB::BrickPickup){
if(!%client.player.haspickupbricks && $Pref::RTB::BrickPickupdie){
%client.RemoveAllBricks();
}
%client.player.haspickupbricks=1;
if(%i>5){return;}//hasnt been planted, abort.
if(!%brick.isplanted){
schedule(75,0,"BPPlantCheck",%brick,%i++);//loop through untill it is planted
return;
}
if(%brick.client.nobuild){
centerprint(%brick.client,"You arent a builder!",3);
%brick.delete();
return;
}
if(!%brick.client.Canbuild[%brick.getdatablock().uiName]){
centerprint(%brick.client,"Not enough minerals!",3);
servercmdbp(%brick.client);
%brick.delete();
return;
}
%brick.client.Canbuild[%brick.getdatablock().uiName]--;
servercmdbp(%brick.client);
%brick.wasbuiltbp=1;
}
}
function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal){
//echo("colloded");
if(%col.getclassname()$="FxDTSBrick"&&$Pref::RTB::BrickPickupHP){
if(%col.wasbuiltbp){
if(!%col.brickhp){
%col.brickhp=%col.getdatablock().getvolume()*$Pref::RTB::BrickPickupHealth;
}
%max=%col.getdatablock().getvolume()*$Pref::RTB::BrickPickupHealth;
//echo("T" @ %col.brickhp @ %this.directdamage*8);
%col.brickhp-=%this.directdamage*8;
//echo(%col.brickhp SPC %max*0.50);
if(%col.brickhp <= %max*0.50){// if its less that 50% alive
%col.setcolorfx(5);
}else{
%col.setcolorfx(0);
}
if(%col.brickhp<=0){
if(!$Pref::RTB::BrickPickupDelete){
%col.killbrick();
}else{
%col.delete();
}
}
}
}
Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
};
activatepackage("BrickPickup");
registerOutputEvent("GameConnection", "PickupBrick", "datablock fxDTSBrickData" TAB "int 0 2000 1", 0);
function GameConnection::PickupBrick(%client,%id,%amount){
if(!%client.player.haspickupbricks && $Pref::RTB::BrickPickupdie){
%client.RemoveAllBricks();
}
%client.player.haspickupbricks=1;
%okay=1;
%i=1;
while(%i<=%client.CanBuildN){
if(%client.CanBuildListing[%i]$=%id.uiName){
%okay=0;
}
%i++;
}
if(%okay){
%client.CanBuildN++;
%client.CanBuildListing[%client.canBuildN]=%id.uiName;
}
%client.Canbuild[%id.uiName]+=%amount;
if(%client.Canbuild[%id.uiName]>%client.CanbuildMax[%id.uiName]&&%client.CanbuildMax[%id.uiName]>0){
%client.Canbuild[%id.uiName]=%client.CanbuildMax[%id.uiName];
}
servercmdbp(%client);
}
registerOutputEvent("GameConnection", "RemoveAllBricks", "", 0);
function GameConnection::RemoveAllBricks(%client){
%i=1;
while(%i<=%client.CanBuildN){
%client.CanBuild[%client.CanBuildListing[%i]]=0;
%i++;
}
%client.CanBuildN=0;
centerprint(%client,"Bricks Removed!",5);
}
registerOutputEvent("GameConnection", "PickupBrickMax", "datablock fxDTSBrickData" TAB "int 0 2000 1", 0);
function GameConnection::PickupBrickMax(%client,%id,%amount){
%client.CanbuildMax[%id.uiName]=%amount;
}
function servercmdbp(%client){
%i=1;
while(%i<=%client.CanBuildN){
%mesg = %mesg @ "\c0" @ %client.CanBuildListing[%i] @ "\c6:\c3" @ %client.CanBuild[%client.CanBuildListing[%i]] @ " ";
%i++;
}
centerprint(%client,%mesg,5);
}
AddDamageType("BPrepairwrench", '<bitmap:add-ons/ci/repairwrench> %1', '%2 <bitmap:add-ons/ci/repairwrench> %1',1,1);
datablock ProjectileData(BPrepairwrenchProjectile)
{
//projectileShapeName = "~/data/shapes/arrow.dts";
directDamage = 0;
directDamageType = $DamageType::BPrepairwrench;
radiusDamageType = $DamageType::BPrepairwrench;
explosion = wrenchExplosion;
//particleEmitter = as;
muzzleVelocity = 60;
velInheritFactor = 1;
impactImpulse = 0;
verticalImpulse = 0;
armingDelay = 0;
lifetime = 170;
fadeDelay = 100;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = false;
gravityMod = 0.0;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(BPrepairwrenchItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "base/data/shapes/wrench.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "BPrepairwrench";
iconName = "./repairwrench";
doColorShift = true;
colorShiftColor = "0.671 0.471 0.471 1.000";
// Dynamic properties defined by the scripts
image = BPrepairwrenchImage;
canDrop = true;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BPrepairwrenchImage)
{
// Basic Item properties
shapeFile = "base/data/shapes/wrench.dts";
emap = true;
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
offset = "0 0 0";
//eyeOffset = "0.1 0.2 -0.55";
// When firing from a point offset from the eye, muzzle correction
// will adjust the muzzle vector to point to the eye LOS point.
// Since this weapon doesn't actually fire from the muzzle point,
// we need to turn this off.
correctMuzzleVector = false;
eyeOffset = "0.7 1.2 -0.25";
// Add the WeaponImage namespace as a parent, WeaponImage namespace
// provides some hooks into the inventory system.
className = "WeaponImage";
// Projectile && Ammo.
item = BPrepairwrenchItem;
ammo = " ";
projectile = BPrepairwrenchProjectile;
projectileType = Projectile;
//melee particles shoot from eye node for consistancy
melee = true;
doRetraction = false;
//raise your arm up or not
armReady = true;
//casing = " ";
doColorShift = true;
colorShiftColor = "0.671 0.471 0.471 1.000";
// Images have a state system which controls how the animations
// are run, which sounds are played, script callbacks, etc. This
// state system is downloaded to the client so that clients can
// predict state changes and animate accordingly. The following
// system supports basic ready->fire->reload transitions as
// well as a no-ammo->dryfire idle state.
// Initial start up state
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.5;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = swordDrawSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "PreFire";
stateAllowImageChange[1] = true;
stateName[2] = "PreFire";
stateScript[2] = "onPreFire";
stateAllowImageChange[2] = false;
stateTimeoutValue[2] = 0.1;
stateTransitionOnTimeout[2] = "Fire";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "CheckFire";
stateTimeoutValue[3] = 1.0;
stateFire[3] = true;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateWaitForTimeout[3] = true;
//stateTransitionOnTriggerUp[3] = "StopFire";
stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTransitionOnTriggerDown[4] = "Fire";
stateName[5] = "StopFire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.2;
stateAllowImageChange[5] = false;
stateWaitForTimeout[5] = true;
stateSequence[5] = "StopFire";
stateScript[5] = "onStopFire";
};
function BPrepairwrenchImage::onPreFire(%this, %obj, %slot)
{
//messageAll( 'MsgClient', 'repairwrench prefired!!!');
//Parent::onFire(%this, %obj, %slot);
%obj.playthread(2, armattack);
}
function BPrepairwrenchImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
//messageAll( 'MsgClient', 'stopfire');
}
function BPrepairwrenchProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(!isobject(%col)){
return;
}
if(%col.getclassname() !$="Player"){
if(%col.getclassname() $= "FxDTSBrick"&&%col.wasbuiltbp){
if(!%col.brickhp){
%col.brickhp=%col.getdatablock().getvolume()*$Pref::RTB::BrickPickupHealth;
}
%max=%col.getdatablock().getvolume()*$Pref::RTB::BrickPickupHealth;
if(%col.brickhp<%max){
%col.brickhp+=$Pref::RTB::BrickPickupRepair;
if(%col.brickhp <= %max*0.50){// if its less that 50% alive
%col.setcolorfx(5);
}else{
%col.setcolorfx(0);
}
if(%col.brickhp>%max){
%col.brickhp=%max;
}
bottomprint(%obj.client,"<just:center> You repaired a brick to" SPC %col.brickhp @ "/" @ %max SPC "hp.",2);
return;
}
}
return;
}
Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
}