Initial commit.

This commit is contained in:
Robert MacGregor 2016-02-22 12:04:31 -05:00
commit 23fed9edb7
157 changed files with 89351 additions and 0 deletions

758
scripts/weapons/MergeTool.cs Executable file
View file

@ -0,0 +1,758 @@
// Merge Tool v006
// Coded by Electricutioner
// Last modified: 6:22 PM 5/21/2006
// Idea by the T2 Construction Community
// * * Public Source Release * *
// Terms of Use:
// 1) You must agree to all terms of use before inclusion of this tool as aggregation or linked component
// in any software component.
// 2) You acknowledge the author of this tool is Electricutioner.
// 3) You will not remove the author's name (Electricutioner) from any location in the source.
// 4) You will not deactivate or remove the bottom-print notification with the author's name (Electricutioner).
// 5) All derivative works from this tool must be open source and the source for functioning versions
// of the derivative works must be available on request.
// 6) The author (Electricutioner) must be credited in the software/mod credits for contribution
// of the MIST.
// 7) You will make no attempt to reverse engineer the two proprietary functions (PointToEdge and MTCarbonCopier)
// nor attempt to reverse engineer the loader used to initialize those functions.
// 8) You will not make use of the two proprietary functions (PointToEdge and MTCarbonCopier) anywhere
// beyond their current use in the split subroutines.
// Installation notes are on the bottom of the file.
//Description:
//The merge tool is a weapon. You shoot it at two pieces you wish to merge, and if the two pieces
//are sufficiently compatable, their size will be analyzed, the first selected piece will be resized
//and repositioned to take up the volume of both, and then the second selected piece will be deconstructed.
//Isometric rotate is a mode. You shoot at a piece and it will rotate the piece 90 degrees on an axis.
//It will then resize and reposition the piece. The result is a piece taking up the exact same space, but
//with the "stretched" effect.
//Split is yet another mode. You shoot this at a piece, and it will cut the piece in half/on crosshair.
//It is not the exact "undo" of the merge operation, but it might allow correction of some mistakes, or
//quick fortification of structures. The piece that is split is duplicated identically, with all
//attributes maintained. Note: this uses a temporary file that can be safely deleted later.
//Variables:
$ElecMod::MergeTool::Tolerance = 0.05; //how many meters of tolerance do we give the pieces that we merge.
$ElecMod::MergeTool::HighTolerance = 0.25; //used for "high tolerance" mode on stubborn pieces
$ElecMod::MergeTool::Timeout = 2; //how many seconds until a selection times out when using the tool
//split portion
$ElecMod::MergeTool::MinimumPieceVolume = 0.125; //50 cm cube is smallest, consider revising this to 16
//Functions:
//this function rotates and rescales pieces to create the stretch effect
function MTIsometric(%client, %piece)
{
if (!isObject(%piece))
return;
if (!%client.isAdmin)
{
if (%client.guid != %piece.ownerguid)
{
messageClient(%client, 'MsgClient', "\c2IT: That piece isn't yours.");
return;
}
}
if (!%piece.isForcefield())
{
%piece.setCloaked(true);
%piece.schedule(290, "setCloaked", false);
}
%center = %piece.getEdge("0 0 0");
%currentSize = %piece.getRealSize();
//this used to be one operation, but it ceased to work properly (?)
%piece.setTransform(remoteRotate(%piece,"0 1 0 1.570796", %piece,"0 0 0"));
%piece.setRealSize(getWord(%currentSize, 2) SPC getWord(%currentSize, 1) SPC getWord(%currentSize, 0));
%piece.setEdge(%center, "0 0 0");
%currentSize = %piece.getRealSize();
%piece.setTransform(remoteRotate(%piece,"0 0 1 1.570796", %piece,"0 0 0"));
%piece.setRealSize(getWord(%currentSize, 1) SPC getWord(%currentSize, 0) SPC getWord(%currentSize, 2));
%piece.setEdge(%center, "0 0 0");
}
//This is the basic initiator function. If the piece called are compatable, nothing further needs to be called.
function MTMerge(%client, %piece1, %piece2, %hiTol)
{
if (!MTCheckCompatability(%client, %piece1, %piece2, %hiTol))
{
%piece1.setCloaked(false);
%piece2.setCloaked(false);
MTClearClientSelection();
return;
}
if (!%piece1.isForcefield())
%piece1.setCloaked(true);
if (!%piece2.isForcefield())
%piece2.setCloaked(true);
schedule(100, 0, "MTScaleShiftMerge", %piece1, %piece2);
if (isEventPending(%client.mergeschedule))
{
cancel(%client.mergeschedule);
MTClearClientSelection();
}
}
//This function checks if 4 corners of the objects are compatable. If an error is encountered it returns a 0 and
//terminates the merge. Otherwise, it returns a 1, and continues the merge process.
function MTCheckCompatability(%client, %piece1, %piece2, %hiTol)
{
//do the pieces exist?
if (!isObject(%piece1) || !isObject(%piece2))
{
messageClient(%client, 'MsgClient', "\c2MT: A piece appears to be missing.");
return;
}
//check if the owners are the same
if (%piece1.owner != %client || %piece2.owner != %client)
{
//with an exemption of admins
if (!%client.isAdmin)
{
//fix for when players leave the server and come back
if (%piece1.ownerGUID != %client.guid || %piece2.ownerGUID != %client.guid)
{
messageClient(%client, 'MsgClient', "\c2MT: One or more of those pieces do not belong to you.");
return;
}
}
}
//now we need to determine if at least 4 of the pieces axies match
//get all the 8 points of both pieces
%pos1[0] = %piece1.getEdge("1 1 -1");
%pos1[1] = %piece1.getEdge("-1 1 -1");
%pos1[2] = %piece1.getEdge("1 -1 -1");
%pos1[3] = %piece1.getEdge("-1 -1 -1");
%pos1[4] = %piece1.getEdge("1 1 1");
%pos1[5] = %piece1.getEdge("-1 1 1");
%pos1[6] = %piece1.getEdge("1 -1 1");
%pos1[7] = %piece1.getEdge("-1 -1 1");
%pos2[0] = %piece2.getEdge("1 1 -1");
%pos2[1] = %piece2.getEdge("-1 1 -1");
%pos2[2] = %piece2.getEdge("1 -1 -1");
%pos2[3] = %piece2.getEdge("-1 -1 -1");
%pos2[4] = %piece2.getEdge("1 1 1");
%pos2[5] = %piece2.getEdge("-1 1 1");
%pos2[6] = %piece2.getEdge("1 -1 1");
%pos2[7] = %piece2.getEdge("-1 -1 1");
//then we compare them to see which ones match
%k = 0;
for (%i = 0; %i < 8; %i++)
{
for (%j = 0; %j < 8; %j++)
{
if (!%hiTol && $ElecMod::MergeTool::Tolerance >= vectorDist(%pos1[%i], %pos2[%j]))
{
%k++;
}
else if (%hiTol && $ElecMod::MergeTool::HighTolerance >= vectorDist(%pos1[%i], %pos2[%j]))
{
%k++;
}
}
}
//if less then 4 match, they can't be compatable (if more then 4 match... something odd is going on)
if (%k < 4)
{
if (%k == 0)
messageClient(%client, 'MsgClient', "\c2MT: None of the corners are shared on those objects. Cannot merge.");
else
messageClient(%client, 'MsgClient', "\c2MT: Only " @ %k @ " corners of the required 4 are shared. Cannot merge.");
return;
}
else if (%k > 4)
{
messageClient(%client, 'MsgClient', "\c2MT: Warning: Detected match of over 4 corners (" @ %k @ "). Merging may fail to produce desired results.");
}
//if the check survived that, we continue...
return 1;
}
//this function, after the pieces are confirmed, checks to see which of the 6 sides is in contact, refers to another
//function to find the alter side, determines distance between them to find a new "real" scale, and determines the
//new world box center for the object. Piece 1 is resized and moved, piece 2 is deconstructed.
function MTScaleShiftMerge(%piece1, %piece2)
{
//find which axis is touching for a "this is the side we scale" discovery
//table:
//0: X
//1: -X
//2: Y
//3: -Y
//4: Z
//5: -Z
%p1S[0] = %piece1.getEdge("1 0 0");
%p1S[1] = %piece1.getEdge("-1 0 0");
%p1S[2] = %piece1.getEdge("0 1 0");
%p1S[3] = %piece1.getEdge("0 -1 0");
%p1S[4] = %piece1.getEdge("0 0 1");
%p1S[5] = %piece1.getEdge("0 0 -1");
%p2S[0] = %piece2.getEdge("1 0 0");
%p2S[1] = %piece2.getEdge("-1 0 0");
%p2S[2] = %piece2.getEdge("0 1 0");
%p2S[3] = %piece2.getEdge("0 -1 0");
%p2S[4] = %piece2.getEdge("0 0 1");
%p2S[5] = %piece2.getEdge("0 0 -1");
for (%i = 0; %i < 6; %i++)
{
for (%j = 0; %j < 8; %j++)
{
if ($ElecMod::MergeTool::Tolerance >= vectorDist(%p1S[%i], %p2S[%j]))
{
%side1 = %i;
%side2 = %j;
}
}
}
//echo("Sides:" SPC %i SPC %j);
//at this point %side1/2 will contain one of the numbers in the table above
//we get the non-shared side at this point
%ops1 = MTFindOpSide(%side1);
%ops2 = MTFindOpSide(%side2);
//this variable contains the new axis length that we are scaling on...
%newaxis = VectorDist(%p1S[%ops1], %p2S[%ops2]);
%currsize = %piece1.getRealSize();
if (%side1 == 0 || %side1 == 1)
%axis = "x";
if (%side1 == 2 || %side1 == 3)
%axis = "y";
if (%side1 == 4 || %side1 == 5)
%axis = "z";
//echo("Axis:" SPC %axis);
if (%axis $= "x")
{
%piece1.setRealSize(%newaxis SPC getWords(%currsize, 1, 2));
if (isObject(%piece1.pzone))
%piece1.pzone.setScale(%newaxis SPC getWords(%currsize, 1, 2));
}
if (%axis $= "y")
{
%piece1.setRealSize(getWord(%currsize, 0) SPC %newaxis SPC getWord(%currsize, 2));
if (isObject(%piece1.pzone))
%piece1.pzone.setScale(getWord(%currsize, 0) SPC %newaxis SPC getWord(%currsize, 2));
}
if (%axis $= "z")
{
%piece1.setRealSize(getWords(%currsize, 0, 1) SPC %newaxis);
if (isObject(%piece1.pzone))
%piece1.pzone.setScale(getWords(%currsize, 0, 1) SPC %newaxis);
}
if (%axis !$= "x" && %axis !$= "y" && %axis !$= "z")
{
error("MT: A scaling error has occured.");
return;
}
%newpos = VectorScale(VectorAdd(%p1S[%ops1], %p2S[%ops2]), 0.5);
%piece1.SetWorldBoxCenter(%newpos);
if (isObject(%piece1.pzone))
%piece1.pzone.setPosition(%piece1.getPosition());
if (!%piece1.isForcefield())
%piece1.setCloaked(false);
if (!%piece2.isForcefield())
%piece2.setCloaked(false);
//%piece2.delete(); //deleting is bad
//%piece2.getDataBlock().disassemble(0, %piece2.owner, %piece2); //disassemble is cleaner
//fixed disassemble to use object specific disassemble functions
//disassemble(0, %piece2.owner, %piece2);
%piece2.getDatablock().disassemble(0, %piece2);
}
//this function does something very simple, it finds whether a number is even or odd, and then adds or subracts
//and returns the initial input with that modification. I can't imagine where else this could be useful.
function MTFindOpSide(%side)
{
%evencheck = %side / 2;
if (%evencheck == mFloor(%evencheck))
%even = 1;
else
%even = 0;
if (%even)
return (%side + 1);
else
return (%side - 1);
}
//simply clears a client variable... woohoo...
function MTClearClientSelection(%client)
{
%client.mergePiece1 = "";
return;
}
//"weapon" datablocks and such
datablock ItemData(MergeTool)
{
className = Weapon;
catagory = "Spawn Items";
shapeFile = "weapon_sniper.dts";
image = MergeToolImage;
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "a MIST, by Electricutioner.";
computeCRC = true;
};
datablock ShapeBaseImageData(MergeToolImage)
{
className = WeaponImage;
shapeFile = "weapon_sniper.dts";
item = MergeTool;
usesEnergy = true;
minEnergy = 0;
stateName[0] = "Activate";
stateTransitionOnTimeout[0] = "ActivateReady";
stateSound[0] = SniperRifleSwitchSound;
stateTimeoutValue[0] = 0.1;
stateSequence[0] = "Activate";
stateName[1] = "ActivateReady";
stateTransitionOnLoaded[1] = "Ready";
stateTransitionOnNoAmmo[1] = "NoAmmo";
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "CheckWet";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.2; //reload timeout here
stateFire[3] = true;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateName[4] = "Reload";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.1;
stateAllowImageChange[4] = false;
stateName[5] = "CheckWet";
stateTransitionOnWet[5] = "Fire";
stateTransitionOnNotWet[5] = "Fire";
stateName[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
stateTransitionOnTriggerDown[6] = "DryFire";
stateSequence[6] = "NoAmmo";
stateName[7] = "DryFire";
stateSound[7] = SniperRifleDryFireSound;
stateTimeoutValue[7] = 0.1;
stateTransitionOnTimeout[7] = "Ready";
};
function MergeToolImage::onFire(%data,%obj,%slot)
{
serverPlay3D(SniperRifleFireSound, %obj.getTransform());
%client = %obj.client;
%pos = getWords(%obj.getEyeTransform(), 0, 2);
%vec = %obj.getEyeVector();
%targetpos = VectorAdd(%pos, VectorScale(%vec, 2000));
%piece = containerRaycast(%pos, %targetpos, $TypeMasks::StaticShapeObjectType | $TypeMasks::ForceFieldObjectType, %obj);
%cast = %piece;
%piece = getWord(%piece, 0);
if (!isObject(%piece))
return;
if (!Deployables.isMember(%piece))
{
messageClient(%client, 'MsgClient', "\c2MIST: That piece is part of the map and cannot be manipulated.");
return;
}
if (!%client.isAdmin)
{
if (%piece.ownerGUID != %client.guid)
{
messageClient(%client, 'MsgClient', "\c2MIST: That piece isn't yours.");
return;
}
}
if (%client.MTMode == 0)
{
if (!isObject(%client.mergePiece1))
{
%client.mergePiece1 = %piece;
if (!%piece.isForcefield())
{
%piece.setCloaked(true);
%piece.schedule(290, "setCloaked", false);
}
%client.mergeschedule = schedule($ElecMod::MergeTool::Timeout * 1000, 0, "MTClearClientSelection", %client);
}
else
{
if (%piece != %client.mergePiece1)
{
if (%client.MTSubMode == 1)
{
MTMerge(%client, %client.mergePiece1, %piece, 1);
%client.MTSubMode = 0;
MTShowStatus(%client);
}
else
{
MTMerge(%client, %client.mergePiece1, %piece, 0);
}
MTClearClientSelection(%client);
}
else
{
messageClient(%client, 'MsgClient', "\c2MT: You cannot merge a piece with itself.");
return;
}
}
}
if (%client.MTMode == 1)
{
MTIsometric(%client, %piece);
}
if (%client.MTMode == 2)
{
if (%client.MTSubMode > 4 || %client.MTSubMode == 1)
{
%client.MTSplitMode = 1; //crosshair split
}
else
{
%client.MTSplitMode = 0; //half split
}
if (%client.MTSubMode == 0)
%axis = "a";
if (%client.MTSubMode == 1)
%axis = "a";
if (%client.MTSubMode == 2)
%axis = "x";
if (%client.MTSubMode == 3)
%axis = "y";
if (%client.MTSubMode == 4)
%axis = "z";
if (%client.MTSubMode == 5)
%axis = "x";
if (%client.MTSubMode == 6)
%axis = "y";
if (%client.MTSubMode == 7)
%axis = "z";
MTSplit(%client, %cast, %axis);
}
}
function MergeToolImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this, %obj, %slot);
%obj.mountImage(MergeToolImage, 0);
MTShowStatus(%obj.client);
}
function MTShowStatus(%client)
{
if (%client.MTMode $= "")
%client.MTMode = 0;
if (%client.MTSubMode $= "")
%client.MTSubMode = 0;
switch (%client.MTMode)
{
case 0:
switch (%client.MTSubMode)
{
case 0:
%status = "<font:Arial:14>Mode: Merge. Fire the tool at two pieces. If possible, they will merge. Tolerance: " @ $ElecMod::MergeTool::Tolerance @ " meters.";
case 1:
%status = "<font:Arial:14>Mode: Merge. Fire the tool at two pieces. If possible, they will merge. Tolerance: " @ $ElecMod::MergeTool::HighTolerance @ " meters.";
}
case 1:
%status = "<spop><font:Arial:14>Mode: Isometric. Fire at a piece. It will be rotated isometrically.";
case 2:
switch (%client.MTSubMode)
{
case 0:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it in half. Axis: Automatic.";
case 1:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it on crosshair. Axis: Automatic.";
case 2:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it in half. Axis: X.";
case 3:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it in half. Axis: Y.";
case 4:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it in half. Axis: Z.";
case 5:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it on crosshair. Axis: X.";
case 6:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it on crosshair. Axis: Y.";
case 7:
%status = "<font:Arial:14>Mode: Split. Fire at a piece to split it on crosshair. Axis: Z.";
}
}
CommandToClient(%client, 'BottomPrint', "<font:Sui Generis:14>>>>M/I/S Tool<<<\n<font:Arial:14>" @ %status @ "\nCoded by Electricutioner.", 3, 3 );
}
//Split code begins here.
//The goal of this is to be a semi-inverse of the merge...
//The tool will be set to split mode, and aimed at an object. The object axies are checked, and if there is one that is
//disproportionally larger then the rest, it will be split on that axis. If two or more axies are similar, it does
//a check to determine the face where the raycast hits (reducing split possibilities by one axis) and either
//spliting on the remaining axis or using position points to find out in which quadrant of the face, the raycast hit.
//Once the axis is determined, the split axis has the difference halved, a "dominant" piece rescaled and repositioned
//in steps similar to the merge, and a new (nearly-identical) piece is created in the resulting void.
//startup function, the calling client, and the raycasted piece. Note: %piece contains all raycast operations.
function MTSplit(%client, %piece, %axis)
{
if(!MTSplitValidate(%client, %piece, %axis)) //validates the client selected piece as valid
return;
if (!%piece.isForcefield())
getWord(%piece, 0).setCloaked(true);
MTSplitScaleShift(%client, %piece, %axis); //split it up
}
//makes sure that the object can be split
function MTSplitValidate(%client, %piece, %axis)
{
if (!isObject(getWord(%piece, 0)))
{
messageClient(%client, 'MsgClient', "\c2ST: The piece to split is missing. You should not see this error.");
return;
}
//restricting to cubics and forcefields.
if (!isCubic(%piece) && !%piece.isForceField())
{
messageClient(%client, 'MsgClient', "\c2ST: That object is not cubic and it cannot be split.");
return;
}
%size = %piece.getRealSize();
%volume = 2 * getWord(%size, 0) * 2 * getWord(%size, 1) * 2 * getWord(%size, 2);
if (%client.MTSplitMode == 0) //half split
{
if ((%volume / 2) < ($ElecMod::MergeTool::MinimumPieceVolume))
{
messageClient(%client, 'MsgClient', "\c2ST: That piece is too small to split.");
return;
}
}
else
{
%hitPos = getWord(%piece, 1) SPC getWord(%piece, 2) SPC getWord(%piece, 3);
%edge = PointToEdge(getWord(%piece, 0), %hitPos);
//auto-axis determiner
if (%axis $= "a")
%axis = CalculateSplitAxis(PointToEdge(%piece, %hitPos));
switch$ (%axis)
{
case "x":
%ratio = getWord(%edge, 0);
%ratio = (%ratio + 1) / 2;
case "y":
%ratio = getWord(%edge, 1);
%ratio = (%ratio + 1) / 2;
case "z":
%ratio = getWord(%edge, 2);
%ratio = (%ratio + 1) / 2;
}
%masterSize = %volume * %ratio;
%slaveSize = %volume * (1 - %ratio);
//echo(%ratio SPC %axis SPC %masterSize SPC %slaveSize);
if (%masterSize < $ElecMod::MergeTool::MinimumPieceVolume || %slaveSize < $ElecMod::MergeTool::MinimumPieceVolume)
{
messageClient(%client, 'MsgClient', "\c2ST: A resultant piece from that split is too small. Aborting.");
return;
}
}
return 1; //we survived, thus we continue
}
//does the actual splitting
function MTSplitScaleShift(%client, %cast, %axis)
{
%piece = getWord(%cast, 0);
%copy = MTCarbonCopy(%piece); //Merge Tool Support functions
if (!%piece.isForcefield())
{
%piece.setCloaked(true);
%copy.setCloaked(true);
}
%hitPos = getWord(%cast, 1) SPC getWord(%cast, 2) SPC getWord(%cast, 3);
%size = %piece.getRealSize();
//auto axis determiner
if (%axis $= "a")
{
%axis = CalculateSplitAxis(PointToEdge(%piece, %hitPos));
//echo(%hitPos);
}
if (%client.MTSplitMode == 0) //split in half
{
%center = %piece.getWorldBoxCenter();
%sizeFactorMaster = 2;
%sizeFactorSlave = 2;
switch$ (%axis)
{
case "x":
%piece.setRealSize((getWord(%size, 0) / %sizeFactorMaster) SPC getWords(%size, 1, 2));
%copy.setRealSize((getWord(%size, 0) / %sizeFactorSlave) SPC getWords(%size, 1, 2));
%piece.setEdge(%center, "1 0 0");
%copy.setEdge(%center, "-1 0 0");
case "y":
%piece.setRealSize(getWord(%size, 0) SPC getWord(%size, 1) / %sizeFactorMaster SPC getWord(%size, 2));
%copy.setRealSize(getWord(%size, 0) SPC getWord(%size, 1) / %sizeFactorSlave SPC getWord(%size, 2));
%piece.setEdge(%center, "0 1 0");
%copy.setEdge(%center, "0 -1 0");
case "z":
%piece.setRealSize(getWords(%size, 0, 1) SPC getWord(%size, 2) / %sizeFactorMaster);
%copy.setRealSize(getWords(%size, 0, 1) SPC getWord(%size, 2) / %sizeFactorSlave);
%piece.setEdge(%center, "0 0 1");
%copy.setEdge(%center, "0 0 -1");
}
}
else
{
%edge = PointToEdge(%piece, %hitPos); //PointToEdge is in the Merge Tool support functions
switch$ (%axis)
{
case "x":
%ratio = getWord(%edge, 0);
%ratio = (%ratio + 1) / 2;
%center = %piece.getEdge("-1 0 0");
%piece.setRealSize(getWord(%size, 0) * %ratio SPC getWords(%size, 1, 2));
%copy.setRealSize(getWord(%size, 0) * (1 - %ratio) SPC getWords(%size, 1, 2));
%piece.setEdge(%center, "-1 0 0");
%copy.setEdge(%piece.getEdge("1 0 0"), "-1 0 0");
case "y":
%ratio = getWord(%edge, 1);
%ratio = (%ratio + 1) / 2;
%center = %piece.getEdge("0 -1 0");
%piece.setRealSize(getWord(%size, 0) SPC getWord(%size, 1) * %ratio SPC getWord(%size, 2));
%copy.setRealSize(getWord(%size, 0) SPC getWord(%size, 1) * (1 - %ratio) SPC getWord(%size, 2));
%piece.setEdge(%center, "0 -1 0");
%copy.setEdge(%piece.getEdge("0 1 0"), "0 -1 0");
case "z":
%ratio = getWord(%edge, 2);
%ratio = (%ratio + 1) / 2;
%center = %piece.getEdge("0 0 -1");
%piece.setRealSize(getWords(%size, 0, 1) SPC getWord(%size, 2) * %ratio);
%copy.setRealSize(getWords(%size, 0, 1) SPC getWord(%size, 2) * (1 - %ratio));
%piece.setEdge(%center, "0 0 -1");
%copy.setEdge(%piece.getEdge("0 0 1"), "0 0 -1");
}
}
if (isObject(%piece.pzone))
{
%piece.pzone.setScale(%piece.getScale());
%piece.pzone.setPosition(%piece.getPosition());
}
if (isObject(%copy.pzone))
{
%copy.pzone.setScale(%copy.getScale());
%copy.pzone.setPosition(%copy.getPosition());
}
if (!%piece.isForcefield())
{
%piece.schedule(290, "setCloaked", false);
%copy.schedule(290, "setCloaked", false);
}
}
function CalculateSplitAxis(%edge)
{
//echo("Calculating split axis from edge: " @ %edge);
%edge = mAbs(getWord(%edge, 0)) SPC mAbs(getWord(%edge, 1)) SPC mAbs(getWord(%edge, 2));
if (getWord(%edge, 0) < getWord(%edge, 1) && getWord(%edge, 0) < getWord(%edge, 2))
return "x";
if (getWord(%edge, 1) < getWord(%edge, 0) && getWord(%edge, 1) < getWord(%edge, 2))
return "y";
if (getWord(%edge, 2) < getWord(%edge, 0) && getWord(%edge, 2) < getWord(%edge, 1))
return "z";
}
// Installation notes:
// To install the MIST v6, follow these instructions:
// - In player.cs, navigate to the Pure armor datablock and add the line:
// max[MergeTool] = 1;
// Within the datablock.
// - In inventoryhud.cs, add the tool as a weapon to the inventory list.
// - Add to inventory.cs to grenade selection of the function ShapeBase::use
// if (%this.getMountedImage(0).getname() $= "MergeToolImage")
// {
// %this.client.MTSubMode++;
// if (%this.client.MTMode == 0 && %this.client.MTSubMode == 2)
// %this.client.MTSubMode = 0;
// if (%this.client.MTMode == 1 && %this.client.MTSubMode == 1)
// %this.client.MTSubMode = 0;
// if (%this.client.MTMode == 2 && %this.client.MTSubMode == 8)
// %this.client.MTSubMode = 0;
//
// MTShowStatus(%this.client);
// return;
// }
// and add this too, in mine selection of the same function
// if (%this.getMountedImage(0).getname() $= "MergeToolImage")
// {
// %this.client.MTMode++;
// %this.client.MTSubMode = 0;
// if (%this.client.MTMode >= 3)
// %this.client.MTMode = 0;
//
// MTShowStatus(%this.client);
// return;
// }
// add the following line to the function ShapeBase::clearInventory
// %this.setInventory(MergeTool,0);
// - Ensure that this file is executed by adding an exec() call to weapons.cs, server.cs, or any other
// location that is executed on startup.
// - Make sure that MergeToolSupport.cs is executed by adjusting the path below.
exec("scripts/do_not_delete/MergeToolSupport.cs");

File diff suppressed because it is too large Load diff

547
scripts/weapons/dragonmissile.cs Executable file
View file

@ -0,0 +1,547 @@
$WeaponSettings1[MissileTransformer] = "9 -1 TractorGun";
$WeaponSetting1[MissileTransformer,0] = "Travel Time: 1 second [35m]";
$WeaponSetting1[MissileTransformer,1] = "Travel Time: 2 seconds [120m]";
$WeaponSetting1[MissileTransformer,2] = "Travel Time: 3 seconds [255m]";
$WeaponSetting1[MissileTransformer,3] = "Travel Time: 4 seconds [440m]";
$WeaponSetting1[MissileTransformer,4] = "Travel Time: 5 seconds [675m]";
$WeaponSetting1[MissileTransformer,5] = "Travel Time: 6 seconds [960m]";
$WeaponSetting1[MissileTransformer,6] = "Travel Time: 7 seconds [1.3km]";
$WeaponSetting1[MissileTransformer,7] = "Travel Time: 8 seconds [1.7km]";
$WeaponSetting1[MissileTransformer,8] = "Travel Time: 9 seconds [2.1km]";
$WeaponSetting1[MissileTransformer,9] = "Travel Time: 10 seconds [2.6km]";
datablock ParticleData( D_GDebrisSmokeParticle )
{
dragCoeffiecient = 1.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
lifetimeMS = 750;
lifetimeVarianceMS = 100;
textureName = "particleTest";
useInvAlpha = true;
spinRandomMin = -60.0;
spinRandomMax = 60.0;
colors[0] = "0.4 0.4 0.4 1.0";
colors[1] = "0.3 0.3 0.3 0.1";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 1.1;
sizes[1] = 4.0;
sizes[2] = 3.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData( D_GDebrisSmokeEmitter )
{
ejectionPeriodMS = 5;
periodVarianceMS = 1;
ejectionVelocity = 2.0; // A little oomph at the back end
velocityVariance = 0.2;
thetaMin = 0.0;
thetaMax = 0.0;
particles = "D_GDebrisSmokeParticle";
};
datablock DebrisData(D_Debris)
{
emitters[0] = D_GDebrisSmokeEmitter;
explodeOnMaxBounce = true;
elasticity = 0.4;
friction = 0.2;
lifetime = 0.2;
lifetimeVariance = 1;
numBounces = 10;
};
datablock ParticleData(D_Dust)
{
dragCoefficient = 1.0;
gravityCoefficient = -0.01;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 2000;
lifetimeVarianceMS = 100;
useInvAlpha = true;
spinRandomMin = -90.0;
spinRandomMax = 500.0;
textureName = "particleTest";
colors[0] = "0.3 0.3 0.3 0.5";
colors[1] = "0.3 0.3 0.3 0.5";
colors[2] = "0.3 0.3 0.3 0.0";
sizes[0] = 5.2;
sizes[1] = 7.6;
sizes[2] = 7.0;
times[0] = 0.0;
times[1] = 0.7;
times[2] = 1.0;
};
datablock ParticleEmitterData(D_DustEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 15.0;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 85;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
lifetimeMS = 250;
particles = "D_Dust";
};
datablock ParticleData(D_ESmoke)
{
dragCoeffiecient = 0.4;
gravityCoefficient = -0.5; // rises slowly
inheritedVelFactor = 0.025;
lifetimeMS = 1750;
lifetimeVarianceMS = 0;
textureName = "particleTest";
useInvAlpha = true;
spinRandomMin = -200.0;
spinRandomMax = 200.0;
textureName = "special/Smoke/smoke_001";
colors[0] = "0.8 0.4 0.2 1.0";
colors[1] = "0.5 0.3 0.1 1.0";
colors[2] = "0.1 0.1 0.1 0.0";
sizes[0] = 2.0;
sizes[1] = 6.0;
sizes[2] = 2.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(D_ESmokeEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 8.25;
velocityVariance = 0.25;
thetaMin = 0.0;
thetaMax = 90.0;
lifetimeMS = 250;
particles = "D_ESmoke";
};
datablock ParticleData(D_Sparks)
{
dragCoefficient = 1;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 350;
textureName = "special/bigspark";
colors[0] = "0.56 0.36 0.26 1.0";
colors[1] = "0.56 0.36 0.26 1.0";
colors[2] = "1.0 0.36 0.26 0.0";
sizes[0] = 2.5;
sizes[1] = 2.5;
sizes[2] = 2.75;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(D_SparksEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 12;
velocityVariance = 6.75;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 60;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 100;
particles = "D_Sparks";
};
datablock ExplosionData(D_Explosion)
{
soundProfile = GrenadeExplosionSound;
faceViewer = true;
explosionScale = "0.9 0.9 0.9";
debris = D_Debris;
debrisThetaMin = 10;
debrisThetaMax = 50;
debrisNum = 50;
debrisVelocity = 20.0;
debrisVelocityVariance = 10.0;
emitter[0] = D_DustEmitter;
emitter[1] = D_ESmokeEmitter;
emitter[2] = D_SparksEmitter;
shakeCamera = true;
camShakeFreq = "10.0 6.0 9.0";
camShakeAmp = "20.0 20.0 20.0";
camShakeDuration = 0.5;
camShakeRadius = 20.0;
};
datablock TracerProjectileData(LHE):Mpm_G_PR {
Explosion = "D_Explosion";
};
function GameConnection::flukeattack(%cl)
{
%image = %cl.player.getMountedImage(0);
if (!IsObject(%image))
return "";
%image.onFire(%cl.player,0);
}
datablock ParticleData( LoadingP1 )
{
dragCoeffiecient = 0;
gravityCoefficient = 0.0;
inheritedVelFactor = -1.0;
constantAcceleration = -4;
lifetimeMS = 850;
lifetimeVarianceMS = 0;
windCoefficient = 0.0;
textureName = "flarebase";
useInvAlpha = false;
spinRandomMin = 0.0;
spinRandomMax = 0.0;
colors[0] = "0.20 0.20 1 1.0";
colors[1] = "0.20 0.20 1 1.0";
colors[2] = "0.20 0.20 1 1.0";
colors[3] = "0.2 0.2 1 0.0";
sizes[0] = 0.05;
sizes[1] = 0.1;
sizes[2] = 0.2;
sizes[3] = 0.8;
times[0] = 0.5;
times[1] = 0.7;
times[2] = 0.90;
times[3] = 1.0;
};
datablock ParticleEmitterData( LoadingE2 )
{
ejectionPeriodMS = 5;
periodVarianceMS = 1;
ejectionVelocity = 1.7; // A little oomph at the back end
velocityVariance = 0.0;
ejectionoffset = 0.8;
thetaMin = 0.0;
thetaMax = 180.0;
phiReferenceVel = "0";
phiVariance = "360";
particles = "LoadingP1";
};
datablock ParticleData( Loading1P )
{
dragCoeffiecient = 0;
gravityCoefficient = 0.0;
inheritedVelFactor = -1.0;
constantAcceleration = -4;
lifetimeMS = 850;
lifetimeVarianceMS = 0;
windCoefficient = 0.0;
textureName = "flarebase";
useInvAlpha = false;
spinRandomMin = 0.0;
spinRandomMax = 0.0;
colors[0] = "0.20 0.20 1 1.0";
colors[1] = "0.20 0.20 1 1.0";
colors[2] = "0.20 0.20 1 1.0";
colors[3] = "0.2 0.2 1 0.0";
sizes[0] = 0.05;
sizes[1] = 0.1;
sizes[2] = 0.2;
sizes[3] = 0.8;
times[0] = 0.5;
times[1] = 0.7;
times[2] = 0.90;
times[3] = 1.0;
};
datablock ParticleEmitterData( Loading1E )
{
ejectionPeriodMS = 5;
periodVarianceMS = 1;
ejectionVelocity = 1.7; // A little oomph at the back end
velocityVariance = 0.0;
ejectionoffset = 0.8;
thetaMin = 0.0;
thetaMax = 180.0;
phiReferenceVel = "0";
phiVariance = "360";
particles = "Loading1P";
};
datablock ParticleData( LoadingP )
{
dragCoeffiecient = 0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0;
lifetimeMS = 70;
lifetimeVarianceMS = 0;
windCoefficient = 0.0;
textureName = "flarebase";
useInvAlpha = false;
spinRandomMin = 0.0;
spinRandomMax = 0.0;
colors[0] = "0.20 0.20 1 1.0";
colors[1] = "0.20 0.20 1 1.0";
colors[2] = "0.20 0.20 1 1.0";
colors[3] = "0.2 0.2 1 0.0";
sizes[0] = 0.9;
sizes[1] = 1;
sizes[2] = 1;
sizes[3] = 0.9;
times[0] = 0.25;
times[1] = 0.5;
times[2] = 0.75;
times[3] = 1.0;
};
datablock ParticleEmitterData( LoadingE )
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 0.1; // A little oomph at the back end
velocityVariance = 0.0;
ejectionoffset = 1.5;
thetaMin = 0.0;
thetaMax = 5.0;
phiReferenceVel = "0";
phiVariance = "360";
particles = "LoadingP";
orientParticles = false;
orientOnVelocity = false;
};
datablock SeekerProjectileData(TransformerMissile):ShoulderMissile
{
casingShapeName = "weapon_missile_casement.dts";
directDamage =0;
directDamageType = $DamageType::SuperChaingun;
hasDamageRadius = False;
indirectDamage = 0;
damageRadius = 0;
radiusDamageType = $DamageType::SuperChaingun;
//muzzleVelocity = 50;
maxVelocity = 800;
//turningSpeed = 0.0;
acceleration = 50;
exhaustEmitter = LoadingE;
exhaustTimeMs = 10000;
exhaustNodeName = "muzzlePoint1";
lifetimems = 12000;
};
//make sure.
TransformerMissile.lifetimems = 12000;
datablock ShapeBaseImageData(MissileTransformer):NerfBallLauncherImage
{
className = WeaponImage;
shapeFile = "weapon_grenade_launcher.dts";
item = TransGun;
usesEnergy = true;
fireEnergy = 50;
minEnergy = 50;
ammo = "";
offset = "0 0 0";
emap = true;
projectile = TransformerMissile;
projectileType = SeekerProjectile;
projectileSpread = 30.0 / 1000.0;
stateSound[3] = MissileFireSound;
};
datablock ItemData(TransGun)
{
className = Weapon;
catagory = "Spawn Items";
shapeFile = "weapon_energy.dts";
image = MissileTransformer;
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "a trasportation gun";
};
function TransformerMissile::onCollision(%data, %projectile, %targetObject, %modifier, %position, %normal)
{
%client=%projectile.cl;
Cancel(%client.endobsch);
%client.player.setTransform(%position);
%client.player.schedule(100,blowup); // chunkOrama!
%client.player.schedule(100,scriptkill,$DamageType::Crash);
Parent::onCollision(%data, %projectile, %targetObject, %modifier, %position, %normal);
}
function TransformerMissile::onExplode(%data, %proj, %pos, %mod)
{
%client=%proj.cl;
Cancel(%client.endobsch);
%client.player.setTransform(%pos);
%client.player.schedule(100,blowup); // chunkOrama!
%client.player.schedule(100,scriptkill,$DamageType::Crash);
Parent::onExplode(%data, %proj, %pos, %mod);
}
// Bot fun!
function MissileTransformer::onFire(%data,%obj,%slot)
{
//parent::onFire(%data,%obj,%slot);
//%client = %obj.client;
//%p = TransformerMissile1.Create(%client.player.getMuzzlePoint(0),%client.player.getMuzzleVector(0),%client.player.getVelocity());
testobs(%obj.client);
}
function testobs(%client)
{
%p = TransformerMissile.Create(%client.player.getMuzzlePoint(0),%client.player.getMuzzleVector(0),%client.player.getVelocity());
%p.dir = %client.player.getMuzzleVector(0);
%p.rot = %client.player.getRotation();
%p.cl = %client;
%time = %client.player.weaponSet1+1;
if (%time $= "" || %time < 1 || %time > 10)
%time = 5;
if(!isObject(%p))
return"";
if ( !isObject( %client.comCam ) )
{
%client.comCam = new Camera()
{
dataBlock = CommanderCamera;
};
MissionCleanup.add(%client.comCam);
}
//commandToClient(%client, 'ControlObjectResponse', true, getControlObjectType(%p,%client.player));
//messageClient(%colObj.client, 'CloseHud', "", 'inventoryScreen');
%client.comCam.setTransform(%p.getTransform());
%client.comCam.setOrbitMode(%p,%p.getTransform(),0,10,-10);
%client.setControlObject(%client.comCam);
%client.moveprojectile = %p;
commandToClient(%client, 'CameraAttachResponse', true);
%client.player.startfade(0,0,1);
if (isObject(%client.player.getobjectMount()))
%client.player.unmount();
%client.player.setTransform(VectorAdd(%client.player.getTransform(),"0 0 -50000"));
schedule(750,0,"checkobs",%client);
%client.endobsch = schedule(%time*1000,0,"endobs",%client);
}
function checkobs(%client)
{
if (!isObject(%client.moveprojectile))
{
%pos = %client.comCam.getTransform();
Cancel(%client.endobsch);
%client.player.setTransform(%pos);
%client.player.schedule(100,blowup); // chunkOrama!
%client.player.schedule(100,scriptkill,$DamageType::Crash);
PlayExplosion(%pos,LHE,"0 0 1");
return "";
}
}
function endobs(%client)
{
if (!isObject(%client.moveprojectile))
{
%pos = %client.comCam.getTransform();
Cancel(%client.endobsch);
%client.player.setTransform(%pos);
%client.player.schedule(100,blowup); // chunkOrama!
%client.player.schedule(100,scriptkill,$DamageType::Crash);
PlayExplosion(%pos,LHE,"0 0 1");
return "";
}
%client.player.setTransform(getWords(%client.moveprojectile.getTransform(),0,2) SPC %client.moveporjectile.rot);
%client.player.startfade(0,0,0);
%client.player.setVelocity("0 0 0");
%client.player.applyImpulse(%client.player.getTransform(),VectorScale(%client.moveprojectile.dir,20000));
%client.setControlObject(%client.player);
%client.moveprojectile.delete();
//%client.comCam.delete();
}

707
scripts/weapons/modifiertool.cs Executable file
View file

@ -0,0 +1,707 @@
//Modifier Tool v001
//Parts by Electricutioner and CaptnPower
//Variables:
$ElecMod::MergeTool::Tolerance = 0.05; //how many meters of tolerance do we give the pieces that we merge.
$ElecMod::MergeTool::Timeout = 2; //how many seconds until a selection times out when using the tool
datablock AudioProfile(chsingleshot)
{
filename = "fx/vehicles/tank_chaingun.wav";
description = AudioDefault3d;
preload = true;
effect = AssaultChaingunFireEffect;
};
//Functions:
function MTMerge(%client, %piece1, %piece2)
{
if (!MTCheckCompatability(%client, %piece1, %piece2))
{
%piece1.setCloaked(false);
%piece2.setCloaked(false);
MTClearClientSelection();
return;
}
%piece1.setCloaked(true);
%piece2.setCloaked(true);
schedule(100, 0, "MTScaleShiftMerge", %piece1, %piece2);
if (isEventPending(%client.mergeschedule))
{
cancel(%client.mergeschedule);
MTClearClientSelection();
}
}
//This function checks if 4 corners of the objects are compatable.
function MTCheckCompatability(%client, %piece1, %piece2)
{
//do the pieces exist?
if (!isObject(%piece1) || !isObject(%piece2))
{
messageClient(%client, 'MsgClient', "\c2MT: A piece appears to be missing.");
return;
}
//check if the owners are the same
if (%piece1.owner != %client || %piece2.owner != %client)
{
//with an exemption of admins
if (!%client.isAdmin)
{
if (%piece1.ownerGUID != %client.guid || %piece2.ownerGUID != %client.guid)
{
messageClient(%client, 'MsgClient', "\c2MT: One or more of those pieces do not belong to you.");
return;
}
}
}
//now we need to determine if at least 4 of the pieces axies match
%pos1[0] = %piece1.getEdge("1 1 -1");
%pos1[1] = %piece1.getEdge("-1 1 -1");
%pos1[2] = %piece1.getEdge("1 -1 -1");
%pos1[3] = %piece1.getEdge("-1 -1 -1");
%pos1[4] = %piece1.getEdge("1 1 1");
%pos1[5] = %piece1.getEdge("-1 1 1");
%pos1[6] = %piece1.getEdge("1 -1 1");
%pos1[7] = %piece1.getEdge("-1 -1 1");
%pos2[0] = %piece2.getEdge("1 1 -1");
%pos2[1] = %piece2.getEdge("-1 1 -1");
%pos2[2] = %piece2.getEdge("1 -1 -1");
%pos2[3] = %piece2.getEdge("-1 -1 -1");
%pos2[4] = %piece2.getEdge("1 1 1");
%pos2[5] = %piece2.getEdge("-1 1 1");
%pos2[6] = %piece2.getEdge("1 -1 1");
%pos2[7] = %piece2.getEdge("-1 -1 1");
//then we compare them to see which ones match
%k = 0;
for (%i = 0; %i < 8; %i++)
{
for (%j = 0; %j < 8; %j++)
{
if ($ElecMod::MergeTool::Tolerance >= vectorDist(%pos1[%i], %pos2[%j]))
{
%k++;
}
}
}
//if less then 4 match, they can't be compatable (if more then 4 match... something odd is going on)
if (%k < 4)
{
if (%k == 0)
messageClient(%client, 'MsgClient', "\c2MT: None of the corners are shared on those objects. Cannot merge.");
else
messageClient(%client, 'MsgClient', "\c2MT: Only " @ %k @ " corners of the required 4 are shared.");
return;
}
//if the check survived that, we continue...
return 1;
}
//this function, after the pieces are confirmed, checks to see which of the 6 sides is in contact, refers to another
//function to find the alter side, determines distance between them to find a new "real" scale, and determines the
//new world box center for the object. Piece 1 is resized and moved, piece 2 is deconstructed.
function MTScaleShiftMerge(%piece1, %piece2)
{
//find which axis is touching for a "this is the side we scale" discovery
//table:
//0: X
//1: -X
//2: Y
//3: -Y
//4: Z
//5: -Z
%p1S[0] = %piece1.getEdge("1 0 0");
%p1S[1] = %piece1.getEdge("-1 0 0");
%p1S[2] = %piece1.getEdge("0 1 0");
%p1S[3] = %piece1.getEdge("0 -1 0");
%p1S[4] = %piece1.getEdge("0 0 1");
%p1S[5] = %piece1.getEdge("0 0 -1");
%p2S[0] = %piece2.getEdge("1 0 0");
%p2S[1] = %piece2.getEdge("-1 0 0");
%p2S[2] = %piece2.getEdge("0 1 0");
%p2S[3] = %piece2.getEdge("0 -1 0");
%p2S[4] = %piece2.getEdge("0 0 1");
%p2S[5] = %piece2.getEdge("0 0 -1");
for (%i = 0; %i < 6; %i++)
{
for (%j = 0; %j < 8; %j++)
{
if ($ElecMod::MergeTool::Tolerance >= vectorDist(%p1S[%i], %p2S[%j]))
{
%side1 = %i;
%side2 = %j;
}
}
}
//echo("Sides:" SPC %i SPC %j);
//at this point %side1/2 will contain one of the numbers in the table above
//we get the non-shared side at this point
%ops1 = MTFindOpSide(%side1);
%ops2 = MTFindOpSide(%side2);
//this variable contains the new axis length that we are scaling on...
%newaxis = VectorDist(%p1S[%ops1], %p2S[%ops2]);
%currsize = %piece1.getRealSize();
if (%side1 == 0 || %side1 == 1)
%axis = "x";
if (%side1 == 2 || %side1 == 3)
%axis = "y";
if (%side1 == 4 || %side1 == 5)
%axis = "z";
//echo("Axis:" SPC %axis);
if (%axis $= "x")
%piece1.setRealSize(%newaxis SPC getWords(%currsize, 1, 2));
if (%axis $= "y")
%piece1.setRealSize(getWord(%currsize, 0) SPC %newaxis SPC getWord(%currsize, 2));
if (%axis $= "z")
%piece1.setRealSize(getWords(%currsize, 0, 1) SPC %newaxis);
if (%axis !$= "x" && %axis !$= "y" && %axis !$= "z")
{
error("MT: A scaling error has occured.");
return;
}
%newpos = VectorScale(VectorAdd(%p1S[%ops1], %p2S[%ops2]), 0.5);
%piece1.SetWorldBoxCenter(%newpos);
%piece1.setCloaked(false);
%piece2.setCloaked(false);
//%piece2.delete(); //deleting is bad
disassemble(0, %piece2.owner, %piece2); //disassemble is cleaner
}
//this function does something very simple, it finds whether a number is even or odd, and then adds or subracts
//and returns the initial input with that modification. I can't imagine where else this could be useful.
function MTFindOpSide(%side)
{
%evencheck = %side / 2;
if (%evencheck == mFloor(%evencheck))
%even = 1;
else
%even = 0;
if (%even)
return (%side + 1);
else
return (%side - 1);
}
//simply clears a client variable... woohoo...
function MTClearClientSelection(%client)
{
%client.mergePiece1 = "";
}
//"weapon" datablocks and such
datablock ItemData(MergeTool)
{
className = Weapon;
catagory = "Spawn Items";
shapeFile = "weapon_sniper.dts";
image = MergeToolImage;
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "a merge tool";
computeCRC = true;
};
datablock ShapeBaseImageData(MergeToolImage)
{
className = WeaponImage;
shapeFile = "weapon_sniper.dts";
item = MergeTool;
usesEnergy = true;
minEnergy = 0;
stateName[0] = "Activate";
stateTransitionOnTimeout[0] = "ActivateReady";
stateSound[0] = SniperRifleSwitchSound;
stateTimeoutValue[0] = 0.1;
stateSequence[0] = "Activate";
stateName[1] = "ActivateReady";
stateTransitionOnLoaded[1] = "Ready";
stateTransitionOnNoAmmo[1] = "NoAmmo";
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "CheckWet";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.2; //reload timeout here
stateFire[3] = true;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateName[4] = "Reload";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.1;
stateAllowImageChange[4] = false;
stateName[5] = "CheckWet";
stateTransitionOnWet[5] = "Fire";
stateTransitionOnNotWet[5] = "Fire";
stateName[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
stateTransitionOnTriggerDown[6] = "DryFire";
stateSequence[6] = "NoAmmo";
stateName[7] = "DryFire";
stateSound[7] = SniperRifleDryFireSound;
stateTimeoutValue[7] = 0.1;
stateTransitionOnTimeout[7] = "Ready";
};
//modified below for calling of the modes
function MergeToolImage::onFire(%data,%obj,%slot)
{
serverPlay3D(chsingleshot, %obj.getTransform());
%client = %obj.client;
if (%obj.modifierMode==5){
%client.scaler=getword($WeaponSetting["modifier4",%client.player.modifierMode2],0);
messageclient(%client, 'MsgClient', "\c2Modifier Tool [Scaler] set to" SPC %client.scaler);
return;
}
%pos = %obj.getMuzzlePoint($WeaponSlot);
%vec = %obj.getMuzzleVector($WeaponSlot);
%targetpos = VectorAdd(%pos, VectorScale(%vec, 200));
%piece = containerRaycast(%pos, %targetpos, $TypeMasks::StaticShapeObjectType | $TypeMasks::ForceFieldObjectType, %obj);//changed to $allobjmask so it can see ff's
%piece = getWord(%piece, 0);
%dataBlockName = %piece.getDataBlock().getName();
if (
%dataBlockName $= "StationInventory" ||
%dataBlockName $= "GeneratorLarge" ||
%dataBlockName $= "SolarPanel" ||
%dataBlockName $= "SensorMediumPulse" ||
%dataBlockName $= "SensorLargePulse"
)
if (%piece.deployed != true)
return;
if (!isObject(%piece))
return;
if (!%client.isAdmin)
{
if (%piece.owner != %client)
{
messageClient(%client, 'MsgClient', "\c2MT: That piece isn't yours.");
return;
}
}
///here the code for the other cheks
if (%obj.modifierMode==1){
swaping(%piece,%obj,%obj.modifierMode2,0);
return;
}
else if (%obj.modifierMode==2){
swaping(%piece,%obj,%obj.modifierMode2,1);
return;
}
else if (%obj.modifierMode==3){
scaling(%piece,%client);
return;
}
else if (%obj.modifierMode==4){
nudging(%piece,%client);
return;
}
if (!isObject(%client.mergePiece1))
{
%client.mergePiece1 = %piece;
%piece.setCloaked(true);
%piece.schedule(290, "setCloaked", false);
%client.mergeschedule = schedule($ElecMod::MergeTool::Timeout * 1000, 0, "MTClearClientSelection", %client);
}
else
{
if (%piece != %client.mergePiece1)
{
MTMerge(%client, %client.mergePiece1, %piece);
MTClearClientSelection(%client);
}
else
{
messageClient(%client, 'MsgClient', "\c2MT: You cannot merge one piece into itself.");
return;
}
}
}
//to electricutioner make shure you keep this in ur next vertion
//cos your merge tool has becomed the modifier tool
function MergeToolImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this, %obj, %slot);
%obj.usingmodifier = true;
if (%obj.modifierMode2 $= "")
%obj.modifierMode2 = 0;
if (%obj.modifierMode $= "")
%obj.modifierMode = 0;
%obj.client.setWeaponsHudActive("sniperrifle");
%line = getWords($WeaponSettings2["modifier",%this.modifierMode],1,10);
%obj.mountImage(MergeToolImage, 0);
}
function MergeToolImage::onUnmount(%data, %obj, %slot) {
%obj.usingmodifier = false;
WeaponImage::onUnmount(%data, %obj, %slot);
}
//NUDGING
function nudging(%obj,%client){
%obj.setCloaked(true);
%obj.schedule(150, "setCloaked", false);
%dataBlock = %obj.getDataBlock();
%name = %dataBlock.getname();
%className = %dataBlock.className;
if (%obj.squaresize !$="")
return;
%Transform = %obj.getTransform();
%pos = posFromTransform(%Transform);
%dir = %obj.getForwardVector();
if (%client.player.modifierMode2==2)
%axis=realvec(%obj,"1 0 0");//x
if (%client.player.modifierMode2==3)
%axis=realvec(%obj,"-1 0 0");//-x
if (%client.player.modifierMode2==4)
%axis=realvec(%obj,"0 1 0");//y
if (%client.player.modifierMode2==5)
%axis=realvec(%obj,"0 -1 0");//-y
if (%client.player.modifierMode2==6)
%axis=realvec(%obj,"0 0 1");//z
if (%client.player.modifierMode2==7)
%axis=realvec(%obj,"0 0 -1");//-z
if (%client.scaler$="")//if the scaler dosnt exist
%client.scaler=0.1; //default 0.1
%NewPosition=vectorAdd(%pos,vectorScale(%axis,%client.scaler));
if (%client.player.modifierMode2==0) //up
%NewPosition=VectorAdd(%pos,VectorScale("0 0 1",%client.scaler));
if (%client.player.modifierMode2==1) //down
%NewPosition=VectorAdd(%pos,VectorScale("0 0 -1",%client.scaler));
if (%obj.originalpos $="")
%obj.originalpos=%NewPosition;
%dist=VectorDist(%NewPosition,%obj.originalpos);
if (%dist>8){
messageclient(%client, 'MsgClient', "\c2Piece is too far from original position.");
return;
}
if (%obj.isdoor==1){//only scale door that are fully closed and not moving
if (%obj.canmove == false){
messageclient(%client, 'MsgClient', "\c2You cannot move a door that is already moving.");
return;
}
if(%obj.state !$="closed" && %obj.state !$=""){
messageclient(%client, 'MsgClient', "\c2You can only move fully closed doors.");
return;
}
}
%obj.setTransform(%NewPosition);
//below is to make shure that all atatch parts will folow the main piece
checkAfterRot(%obj);
}
//SCALING
function scaling(%obj,%client){
%dataBlock = %obj.getDataBlock();
%name = %dataBlock.getname();
%className = %dataBlock.className;
if (%obj.squaresize !$="")
return;
%Transform = %obj.getTransform();
if (%client.player.modifierMode2==0 || %client.player.modifierMode2==4)//sets
%axis="1 1 1"; //the
if (%client.player.modifierMode2==1 || %client.player.modifierMode2==5)//right
%axis="1 0 0"; //vector
if (%client.player.modifierMode2==2 || %client.player.modifierMode2==6)//for
%axis="0 1 0"; //scaling
if (%client.player.modifierMode2==3 || %client.player.modifierMode2==7)//
%axis="0 0 1"; //
if (%client.player.modifierMode2>3)//inverts it
%axis=VectorScale(%axis,-1); //if its on a -scale
if (%client.scaler$="")//if the scaler dosnt exist
%client.scaler=0.1; //default 0.1
%multiplier=VectorScale(%axis,%client.scaler);//gets the multiplier
if (%obj.isdoor==1){//only scale door that are fully closed and not moving
if (%obj.canmove == false){
messageclient(%client, 'MsgClient', "\c2You cannot scale a door while it is moving.");
return;
}
if(%obj.state !$="closed" && %obj.state !$=""){
messageclient(%client, 'MsgClient', "\c2You can only scale doors while fully closed.");
return;
}
}
//so spines scale corectly
if (%classname $= "spine" || %classname $= "mspine" || %classname $= "spine2" || %classname $= "floor" || %classname $= "wall" || %classname $= "wwall" || %classname $= "floor" || %classname $= "door") {
%multiplier=VectorScale(%multiplier,"0.125 0.166666 1");
%size=Vectoradd(%obj.getScale(),%multiplier);
if (getword(%size,0)<0.001 || getword(%size,1)<0.001 || getword(%size,2)<0.001){ //just so
messageclient(%client, 'MsgClient', "\c2Piece is too small."); //it dont go
return; //to small
}
if (getword(%size,0)>100 || getword(%size,1)>100 || getword(%size,2)>100){ //just so
messageclient(%client, 'MsgClient', "\c2Piece is too big."); //it dont go
return; //to big
}
%obj.setScale(%size);
return;
}
//so if you hit a target its the decorations that scales
if (%name $="DeployedLTarget"){
%size=vectoradd(%obj.lMain.getScale(),%multiplier);
if (getword(%size,0)<0.001 || getword(%size,1)<0.001 || getword(%size,2)<0.001){
messageclient(%client, 'MsgClient', "\c2Piece is too small.");
return;
}
if (getword(%size,0)>100 || getword(%size,1)>100 || getword(%size,2)>100){ //just so
messageclient(%client, 'MsgClient', "\c2Piece is too big."); //it dont go
return; //to big
}
%obj.lMain.setScale(%size);
adjustLMain(%obj);
return;
}
//so both the logo and the projector scales at once
if (%name $="DeployedLogoProjector"){
%size=vectoradd(%obj.getScale(),%multiplier);
if (getword(%size,0)<0.01 || getword(%size,1)<0.01 || getword(%size,2)<0.01){//smaller then that
messageclient(%client, 'MsgClient', "\c2Piece is too small."); //and its to small to deconstruct
return;
}
if (getword(%size,0)>100 || getword(%size,1)>100 || getword(%size,2)>100){ //just so
messageclient(%client, 'MsgClient', "\c2Piece is too big."); //it dont go
return; //to big
}
%obj.setScale(%size);
if (%obj.holo !=""){
if (isobject(%obj.holo)){
%obj.holo.setScale(%size);
adjustHolo(%obj);
}
}
return;
}
%size=vectoradd(%obj.getScale(),%multiplier);
if (getword(%size,0)<0.001 || getword(%size,1)<0.001 || getword(%size,2)<0.001){
messageclient(%client, 'MsgClient', "\c2Piece is too small.");
return;
}
if (getword(%size,0)>100 || getword(%size,1)>100 || getword(%size,2)>100){ //just so
messageclient(%client, 'MsgClient', "\c2Piece is too big."); //it dont go
return; //to big
}
%obj.setScale(%size);
}
//SWAPPING
function swaping(%hitobj,%plyr,%mode,%mode2){
%sender=%plyr.client;
if ( %hitobj.ownerGUID != %sender.guid){
if (!%sender.isadmin && !%sender.issuperadmin){
if (%hitobj.ownerGUID !$=""){
messageclient(%sender, 'MsgClient', '\c2You do not own this.');
return;
}
}
}
if (%hitobj.squaresize !$="")
return;
%classname= %hitobj.getDataBlock().classname;
%objscale = %hitobj.scale;
%grounded = %hitobj.grounded;
%pwrfreq = %hitobj.powerFreq;
%Transform = %hitobj.getTransform();
//////////////
//forcefeild//
//////////////
if (%classname$="forcefield" && %mode2==1){
%db="DeployedForceField"@%mode;
%deplObj = new ("ForceFieldBare")() {
dataBlock = %db;
scale = %objscale;
};
%deplObj.setTransform(%Transform);
if (%hitobj.noSlow == true){
%deplObj.noSlow = true;
%deplObj.pzone.delete();
%deplObj.pzone = "";
}
if (%hitobj.pzone !$= "")
%hitobj.pzone.delete();
%hitobj.delete();
// misc info
addDSurface(%item.surface,%deplObj);
// [[Settings]]:
%deplObj.grounded = %grounded;
%deplObj.needsFit = 1;
// [[Normal Stuff]]:
// set team, owner, and handle
%deplObj.team = %plyr.client.team;
%deplObj.setOwner(%plyr);
// set power frequency
%deplObj.powerFreq = %pwrfreq;
// set the sensor group if it needs one
if (%deplObj.getTarget() != -1)
setTargetSensorGroup(%deplObj.getTarget(), %plyr.client.team);
// place the deployable in the MissionCleanup/Deployables group (AI reasons)
addToDeployGroup(%deplObj);
//let the AI know as well...
AIDeployObject(%plyr.client, %deplObj);
// increment the team count for this deployed object
$TeamDeployedCount[%plyr.team, %item.item]++;
// Power object
checkPowerObject(%deplObj);
return %deplObj;
}
///////////%objscale = %hitobj.scale;
//pads //%oldpos = %hitobj.position;
///////////%oldrot = %hitobj.rotation;
else if (%mode2==0 && ((%classname $= "decoration" && %hitobj.getDataBlock().getname() $="DeployedDecoration6") || %classname $= "crate" || %classname $= "floor" || %classname $= "spine" || %classname $= "mspine" || %classname $= "wall" || %classname $= "wwall" || %classname $= "Wspine" || %classname $= "Sspine" || %classname $= "floor" || %classname $= "door"))
{
%hitobj.setCloaked(true);
%hitobj.schedule(290, "setCloaked", false);
if (%hitobj.isdoor == 1 || %hitobj.getdatablock().getname() $="DeployedTdoor"){
if (%hitobj.canmove == false) //if it cant move
return;
if (%hitobj.state !$="closed" && %hitobj.state !$="")
return;
}
if (%hitobj.isobjective > 0)
return;
%db = getword($WeaponSetting["modifier1",%mode],0);
%count = $WeaponSettings["modifier1"]; //counts
if (%hitobj.getdatablock().getname() $="DeployedFloor")
%datablock="DeployedwWall";
else if (%hitobj.getdatablock().getname() $="DeployedMSpinering")
%datablock="DeployedMSpine";
else if (%hitobj.getdatablock().getname() $="DeployedTdoor"){
%datablock="DeployedMSpine";
}
else
%datablock=%hitobj.getdatablock().getname();
%team = %hitobj.team;
%owner = %hitobj.owner;
if (%hitobj.ownerGUID>0)
%ownerGUID = %hitobj.ownerGUID;
else
%ownerGUID = "";
if (%hitobj.isdoor == 1 || %hitobj.getdatablock().getname() $="DeployedTdoor"){
%issliding = %hitobj.issliding;
%state = %hitobj.state;
%canmove = %hitobj.canmove;
%closedscale = %hitobj.closedscale;
%openedscale = %hitobj.openedscale;
%oldscale = %hitobj.oldscale;
%moving = %hitobj.moving;
%toggletype = %hitobj.toggletype;
%powercontrol = %hitobj.powercontrol;
%Collision = %hitobj.Collision;
%lv = %hitobj.lv;
}
%scale = %hitobj.GetRealSize();
%deplObj = new ("StaticShape")() {
dataBlock = %db;
};
%deplObj.SetRealSize(%scale);
%deplObj.setTransform(%Transform);
//////////////////////////Apply settings//////////////////////////////
// misc info
addDSurface(%item.surface,%deplObj);
// [[Settings]]:
%deplObj.grounded = %grounded;
%deplObj.needsFit = 1;
// set team, owner, and handle
%deplObj.team = %team;
%deplObj.Ownerguid=%ownerGUID;
%deplObj.Owner=%owner;
// set power frequency
%deplObj.powerFreq = %pwrfreq;
%deplObj.OriginalPos = %hitobj.OriginalPos;
// set the sensor group if it needs one
if (%deplObj.getTarget() != -1)
setTargetSensorGroup(%deplObj.getTarget(), %plyr.client.team);
// place the deployable in the MissionCleanup/Deployables group (AI reasons)
addToDeployGroup(%deplObj);
//let the AI know as well...
AIDeployObject(%plyr.client, %deplObj);
// increment the team count for this deployed object
$TeamDeployedCount[%plyr.team, %item.item]++;
%deplObj.deploy();
// Power object
checkPowerObject(%deplObj);
if (%hitobj.isdoor == 1 || %hitobj.getdatablock().getname() $="DeployedTdoor"){
%deplObj.closedscale = %deplObj.getScale();
%deplObj.openedscale = getwords(%deplObj.getScale(),0,1) SPC 0.1;
%deplObj.isdoor = 1;
%deplObj.state = %state ;
%deplObj.canmove = %canmove ;
%deplObj.moving = %moving ;
%deplObj.toggletype = %toggletype ;
%deplObj.powercontrol = %powercontrol;
%deplObj.Collision = %Collision ;
%deplObj.lv = %lv ;
}
%hitobj.delete();
return %deplObj;
}
}

View file

@ -0,0 +1,288 @@
//--------------------------------------------------------------------------
// Nerf Ball Launcher
// ------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Nerf Ball Launcher Ball
// ------------------------------------------------------------------------
datablock AudioProfile(NerfBallBurnSound)
{
filename = "fx/armor/bubbletrail.wav";
description = ProjectileLooping3d;
preload = true;
};
datablock AudioProfile(NerfBallExplosionSound)
{
filename = "fx/weapons/cg_water2.wav";
description = AudioClosest3d;
preload = true;
};
//--------------------------------------------------------------------------
// Particle effects
//--------------------------------------
datablock ParticleData(NerfBallParticle)
{
dragCoeffiecient = 0.0;
gravityCoefficient = 0.15;
inheritedVelFactor = 0.5;
lifetimeMS = 3000;
lifetimeVarianceMS = 200;
spinRandomMin = -200.0;
spinRandomMax = 200.0;
textureName = "special/bubbles";
colors[0] = "0.0 0.5 1.0 0.3";
colors[1] = "0.0 0.4 1.0 0.2";
colors[2] = "0.0 0.3 1.0 0.1";
sizes[0] = 0.6;
sizes[1] = 0.3;
sizes[2] = 0.1;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(NerfBallEmitter)
{
lifetimeMS = 0; // No limit
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 1.0;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 90.0;
orientParticles = false;
orientOnVelocity = false;
particles = "NerfBallParticle";
};
datablock ParticleData(NerfBallExplosionParticle)
{
dragCoeffiecient = 0.0;
gravityCoefficient = 0.5;
inheritedVelFactor = 0.5;
lifetimeMS = 2000;
lifetimeVarianceMS = 200;
spinRandomMin = -200.0;
spinRandomMax = 200.0;
textureName = "special/bubbles";
colors[0] = "0.0 0.5 1.0 0.3";
colors[1] = "0.0 0.4 1.0 0.2";
colors[2] = "0.0 0.3 1.0 0.1";
sizes[0] = 0.6;
sizes[1] = 0.3;
sizes[2] = 0.1;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(NerfBallExplosionEmitter)
{
lifetimeMS = 200;
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 3.0;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 90.0;
orientParticles = false;
orientOnVelocity = false;
particles = "NerfBallExplosionParticle";
};
//--------------------------------------------------------------------------
// Explosion - Nerf Ball Launcher Ball
//--------------------------------------
datablock ExplosionData(NerfBallExplosion)
{
emitter[0] = NerfBallExplosionEmitter;
soundProfile = NerfBallExplosionSound;
};
//--------------------------------------------------------------------------
// Projectile - Nerf Ball Launcher Ball
//--------------------------------------
datablock GrenadeProjectileData(NerfBall)
{
projectileShapeName = "grenade_projectile.dts";
emitterDelay = -1;
directDamage = 0;
directDamageType = $DamageType::Default;
radiusDamageType = $DamageType::Default;
hasDamageRadius = false;
indirectDamage = 0;
damageRadius = 3.0; // used in onExplode()
kickBackStrength = 0;
useLensFlare = false;
sound = NerfBallBurnSound;
explosion = NerfBallExplosion;
velInheritFactor = 0.5;
texture[0] = "special/bubbles";
baseEmitter = NerfBallEmitter;
grenadeElasticity = 0.35;
grenadeFriction = 0.1;
armingDelayMS = 1500;
muzzleVelocity = 60;
drag = 0.1;
gravityMod = 3.0;
};
//--------------------------------------
// Nerf Ball Launcher
//--------------------------------------
datablock AudioProfile(NerfBallLauncherFireSound)
{
filename = "fx/vehicles/crash_ground_vehicle.wav";
description = AudioDefault3d;
preload = true;
effect = GrenadeFireEffect;
};
datablock AudioProfile(NerfBallLauncherReloadSound)
{
filename = "heavy_RF_uw.wav";
description = AudioClosest3d;
preload = true;
effect = GrenadeReloadEffect;
};
//--------------------------------------------------------------------------
// Ammo
//--------------------------------------
datablock ItemData(NerfBallLauncherAmmo)
{
className = Ammo;
catagory = "Ammo";
shapeFile = "ammo_grenade.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "some nerf ball launcher ammo";
computeCRC = true;
emap = true;
};
//--------------------------------------------------------------------------
// Weapon
//--------------------------------------
datablock ItemData(NerfBallLauncher)
{
className = Weapon;
catagory = "Spawn Items";
shapeFile = "weapon_grenade_launcher.dts";
image = NerfBallLauncherImage;
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "a nerf ball launcher";
computeCRC = true;
};
datablock ShapeBaseImageData(NerfBallLauncherImage)
{
className = WeaponImage;
shapeFile = "weapon_grenade_launcher.dts";
item = NerfBallLauncher;
ammo = NerfBallLauncherAmmo;
offset = "0 0 0";
emap = true;
projectile = NerfBall;
projectileType = GrenadeProjectile;
projectileSpread = 30.0 / 1000.0;
stateName[0] = "Activate";
stateTransitionOnTimeout[0] = "ActivateReady";
stateTimeoutValue[0] = 0.5;
stateSequence[0] = "Activate";
stateSound[0] = GrenadeSwitchSound;
stateName[1] = "ActivateReady";
stateTransitionOnLoaded[1] = "Ready";
stateTransitionOnNoAmmo[1] = "NoAmmo";
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Fire";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.05;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = NerfBallLauncherFireSound;
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.1;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateSound[4] = NerfBallLauncherReloadSound;
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Reload";
stateSequence[5] = "NoAmmo";
stateTransitionOnTriggerDown[5] = "DryFire";
stateName[6] = "DryFire";
stateSound[6] = GrenadeDryFireSound;
stateTimeoutValue[6] = 1.5;
stateTransitionOnTimeout[6] = "NoAmmo";
};
function NerfBall::onExplode(%data,%projectile,%pos,%mod) {
InitContainerRadiusSearch(%pos, %data.damageRadius, $TypeMasks::PlayerObjectType);
while ((%targetObject = containerSearchNext()) != 0) {
if (isObject(%targetObject)) {
if (%targetObject.getClassName() $= "Player")
applyNerf(%targetObject,%projectile.sourceObject,%pos);
}
}
}
// Bot fun!
function NerfBallLauncherImage::onFire(%data,%obj,%slot) {
%p = Parent::onFire(%data, %obj, %slot);
AIGrenadeThrown(%p);
}

250
scripts/weapons/nerfGun.cs Executable file
View file

@ -0,0 +1,250 @@
//--------------------------------------
// Nerf Gun
//--------------------------------------
//--------------------------------------------------------------------------
// Sounds
//--------------------------------------
datablock AudioProfile(NerfGunFireSound)
{
filename = "fx/armor/heavy_LF_uw.wav";
description = AudioDefault3d;
preload = true;
effect = BlasterFireEffect;
};
datablock AudioProfile(NerfGunDryFireSound)
{
filename = "fx/weapons/chaingun_dryfire.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(NerfBoltProjectileSound)
{
filename = "fx/weapons/ELF_hit.WAV";
description = ProjectileLooping3d;
preload = true;
};
datablock AudioProfile(NerfBoltExpSound)
{
filename = "fx/armor/heavy_LF_metal.wav";
description = AudioClosest3d;
preload = true;
};
//--------------------------------------------------------------------------
// Explosion
//--------------------------------------
datablock ParticleData(NerfBoltExplosionParticle1)
{
dragCoefficient = 2;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = -0.0;
lifetimeMS = 600;
lifetimeVarianceMS = 000;
textureName = "special/crescent4";
colors[0] = "0.1 1.0 0.1 1.0";
colors[1] = "0.1 1.0 0.1 1.0";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.25;
sizes[1] = 0.5;
sizes[2] = 1.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(NerfBoltExplosionEmitter)
{
ejectionPeriodMS = 7;
periodVarianceMS = 0;
ejectionVelocity = 2;
velocityVariance = 1.5;
ejectionOffset = 0.0;
thetaMin = 70;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 200;
particles = "NerfBoltExplosionParticle1";
};
datablock ParticleData(NerfBoltExplosionParticle2)
{
dragCoefficient = 2;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = -0.0;
lifetimeMS = 600;
lifetimeVarianceMS = 000;
textureName = "special/blasterHit";
colors[0] = "0.1 1.0 0.1 1.0";
colors[1] = "0.1 0.5 0.1 0.5";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.3;
sizes[1] = 0.90;
sizes[2] = 1.50;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(NerfBoltExplosionEmitter2)
{
ejectionPeriodMS = 30;
periodVarianceMS = 0;
ejectionVelocity = 1;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = false;
lifetimeMS = 200;
particles = "NerfBoltExplosionParticle2";
};
datablock ExplosionData(NerfBoltExplosion)
{
soundProfile = NerfBoltExpSound;
emitter[0] = NerfBoltExplosionEmitter;
emitter[1] = NerfBoltExplosionEmitter2;
};
//--------------------------------------------------------------------------
// Projectile
//--------------------------------------
datablock LinearFlareProjectileData(NerfBolt)
{
emitterDelay = -1;
directDamage = 0;
directDamageType = $DamageType::Default;
kickBackStrength = 0.0;
bubbleEmitTime = 1.0;
sound = NerfBoltProjectileSound;
velInheritFactor = 0.5;
explosion = "NerfBoltExplosion";
splash = BlasterSplash;
grenadeElasticity = 0.998;
grenadeFriction = 0.0;
armingDelayMS = 500;
muzzleVelocity = 100.0;
drag = 0.05;
gravityMod = 0.0;
dryVelocity = 100.0;
wetVelocity = 80.0;
reflectOnWaterImpactAngle = 0.0;
explodeOnWaterImpact = false;
deflectionOnWaterImpact = 0.0;
fizzleUnderwaterMS = 3000;
lifetimeMS = 3000;
scale = "0.1 0.1 0.1";
numFlares = 8;
flareColor = "0.1 1 0.1";
flareModTexture = "flaremod";
flareBaseTexture = "special/lightFalloffMono";
};
//--------------------------------------------------------------------------
// Weapon
//--------------------------------------
datablock ShapeBaseImageData(NerfGunImage)
{
className = WeaponImage;
shapeFile = "weapon_energy.dts";
item = NerfGun;
projectile = NerfBolt;
projectileType = LinearFlareProjectile;
usesEnergy = true;
fireEnergy = 4;
minEnergy = 4;
stateName[0] = "Activate";
stateTransitionOnTimeout[0] = "ActivateReady";
stateTimeoutValue[0] = 0.5;
stateSequence[0] = "Activate";
stateSound[0] = BlasterSwitchSound;
stateName[1] = "ActivateReady";
stateTransitionOnLoaded[1] = "Ready";
stateTransitionOnNoAmmo[1] = "NoAmmo";
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Fire";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.3;
stateFire[3] = true;
stateRecoil[3] = NoRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateSound[3] = NerfGunFireSound;
stateScript[3] = "onFire";
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Reload";
stateSequence[5] = "NoAmmo";
stateTransitionOnTriggerDown[5] = "DryFire";
stateName[6] = "DryFire";
stateTimeoutValue[6] = 0.3;
stateSound[6] = NerfGunDryFireSound;
stateTransitionOnTimeout[6] = "Ready";
};
datablock ItemData(NerfGun)
{
className = Weapon;
catagory = "Spawn Items";
shapeFile = "weapon_energy.dts";
image = NerfGunImage;
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "a nerf gun";
};
function NerfBolt::onCollision(%data,%projectile,%targetObject,%modifier,%position,%normal) {
if (isObject(%targetObject)) {
if (%targetObject.getClassName() $= "Player")
applyNerf(%targetObject,%projectile.sourceObject,%position);
}
Parent::onCollision(%data, %projectile, %targetObject, %modifier, %position, %normal);
}
// Bot fun!
function NerfGunImage::onFire(%data,%obj,%slot) {
%p = Parent::onFire(%data, %obj, %slot);
AIGrenadeThrown(%p);
}

243
scripts/weapons/superChaingun.cs Executable file
View file

@ -0,0 +1,243 @@
//--------------------------------------
// SuperChaingun
//--------------------------------------
//--------------------------------------------------------------------------
// Projectile
//--------------------------------------
datablock TracerProjectileData(SuperChaingunBullet)
{
doDynamicClientHits = true;
directDamage =0.0825 * 4;
directDamageType = $DamageType::SuperChaingun;
explosion = ChaingunExplosion;
splash = ChaingunSplash;
hasDamageRadius = true;
indirectDamage = 0.45 * 400;
damageRadius = 4.0 * 2;
radiusDamageType = $DamageType::SuperChaingun;
kickBackStrength = 1750;
sound = ChaingunProjectile;
dryVelocity = 425.0;
wetVelocity = 100.0;
velInheritFactor = 1.0;
fizzleTimeMS = 3000;
lifetimeMS = 3000;
explodeOnDeath = false;
reflectOnWaterImpactAngle = 0.0;
explodeOnWaterImpact = false;
deflectionOnWaterImpact = 0.0;
fizzleUnderwaterMS = 3000;
tracerLength = 15.0;
tracerAlpha = false;
tracerMinPixels = 6;
tracerColor = 211.0/255.0 @ " " @ 215.0/255.0 @ " " @ 120.0/255.0 @ " 0.75";
tracerTex[0] = "special/tracer00";
tracerTex[1] = "special/tracercross";
tracerWidth = 0.10;
crossSize = 0.20;
crossViewAng = 0.990;
renderCross = true;
decalData[0] = ChaingunDecal1;
decalData[1] = ChaingunDecal2;
decalData[2] = ChaingunDecal3;
decalData[3] = ChaingunDecal4;
decalData[4] = ChaingunDecal5;
decalData[5] = ChaingunDecal6;
hasLight = true;
lightRadius = 5.0;
lightColor = "0.5 0.5 0.175";
};
//--------------------------------------------------------------------------
// Weapon
//--------------------------------------
datablock ShapeBaseImageData(SuperChaingunImage)
{
className = WeaponImage;
shapeFile = "weapon_chaingun.dts";
item = SuperChaingun;
usesEnergy = true;
minEnergy = 0;
fireEnergy = 0;
projectile = SuperChaingunBullet;
projectileType = TracerProjectile;
emap = true;
casing = ShellDebris;
shellExitDir = "0.3 0.5 1.0";
shellExitOffset = "0.15 -0.56 -0.1";
shellExitVariance = 15.0;
shellVelocity = 4.0;
projectileSpread = 2.0 / 1000.0;
//--------------------------------------
stateName[0] = "Activate";
stateSequence[0] = "Activate";
stateSound[0] = ChaingunSwitchSound;
stateAllowImageChange[0] = false;
//
stateTimeoutValue[0] = 0.5;
stateTransitionOnTimeout[0] = "Ready";
stateTransitionOnNoAmmo[0] = "NoAmmo";
//--------------------------------------
stateName[1] = "Ready";
stateSpinThread[1] = Stop;
//
stateTransitionOnTriggerDown[1] = "Spinup";
stateTransitionOnNoAmmo[1] = "NoAmmo";
//--------------------------------------
stateName[2] = "NoAmmo";
stateTransitionOnAmmo[2] = "Ready";
stateSpinThread[2] = Stop;
stateTransitionOnTriggerDown[2] = "DryFire";
//--------------------------------------
stateName[3] = "Spinup";
stateSpinThread[3] = SpinUp;
stateSound[3] = ChaingunSpinupSound;
//
stateTimeoutValue[3] = 0.0;
stateWaitForTimeout[3] = false;
stateTransitionOnTimeout[3] = "Fire";
stateTransitionOnTriggerUp[3] = "Spindown";
//--------------------------------------
stateName[4] = "Fire";
stateSequence[4] = "Fire";
stateSequenceRandomFlash[4] = true;
stateSpinThread[4] = FullSpeed;
stateSound[4] = ChaingunFireSound;
//stateRecoil[4] = LightRecoil;
stateAllowImageChange[4] = false;
stateScript[4] = "onFire";
stateFire[4] = true;
stateEjectShell[4] = true;
//
stateTimeoutValue[4] = 0.01;
stateTransitionOnTimeout[4] = "Fire";
stateTransitionOnTriggerUp[4] = "Spindown";
stateTransitionOnNoAmmo[4] = "EmptySpindown";
//--------------------------------------
stateName[5] = "Spindown";
stateSound[5] = ChaingunSpinDownSound;
stateSpinThread[5] = SpinDown;
//
stateTimeoutValue[5] = 0.0;
stateWaitForTimeout[5] = true;
stateTransitionOnTimeout[5] = "Ready";
stateTransitionOnTriggerDown[5] = "Spinup";
//--------------------------------------
stateName[6] = "EmptySpindown";
stateSound[6] = ChaingunSpinDownSound;
stateSpinThread[6] = SpinDown;
//
stateTimeoutValue[6] = 0.5;
stateTransitionOnTimeout[6] = "NoAmmo";
//--------------------------------------
stateName[7] = "DryFire";
stateSound[7] = ChaingunDryFireSound;
stateTimeoutValue[7] = 0.5;
stateTransitionOnTimeout[7] = "NoAmmo";
};
datablock ItemData(SuperChaingun)
{
className = Weapon;
catagory = "Spawn Items";
shapeFile = "weapon_chaingun.dts";
image = SuperChaingunImage;
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
pickUpName = "a super chaingun";
computeCRC = true;
emap = true;
};
function SuperChaingunImage::onFire(%data,%obj,%slot) {
if (%obj.superChaingunMode == 1) {
%pos = %obj.getMuzzlePoint(%slot);
%vec = %obj.getMuzzleVector(%slot);
%res = containerRayCast(%pos,vectorAdd(%pos,vectorScale(%vec,2000)), $TypeMasks::PlayerObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticObjectType,%obj);
if (%res)
%hitLoc = getWords(%res,1,3);
else
%hitLoc = vectorAdd(%pos,vectorScale(%vec,2000));
%p = discharge(%pos,%vec);
%p.setEnergyPercentage(1);
createLifeLight(%hitLoc,1,1000);
addToShock(%p);
%p.schedule(1000,"delete");
zap(0,25,%hitLoc);
%obj.decInventory(%data.ammo,1);
}
else if (%obj.superChaingunMode > 1)
{
if (!(%obj.lasteffectpulse+2000 < getSimTime()))
return;
%obj.lasteffectpulse = GetSimTime();
%pos = %obj.getMuzzlePoint(%slot);
%vec = %obj.getMuzzleVector(%slot);
%res = containerRayCast(%pos,vectorAdd(%pos,vectorScale(%vec,2000)), $TypeMasks::PlayerObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticObjectType| $TypeMasks::ForceFieldObjectType ,%obj);
if (%res)
Aidpulse(getWords(%res,1,3),%obj.client,%obj.superChaingunMode-2);
}
else
//for (%i = 0; %i < 1; %i++)
//{
Parent::onFire(%data, %obj, %slot);
//}
}
function SuperChaingunImage::onMount(%this,%obj,%slot) {
%obj.usingSuperChaingun = true;
if (!%obj.superChaingunMode)
%obj.superChaingunMode = 0;
if (!%obj.superChaingunMode2)
%obj.superChaingunMode2 = 0;
displaySCGStatus(%obj);
WeaponImage::onMount(%this,%obj,%slot);
}
function SuperChaingunImage::onUnmount(%data, %obj, %slot) {
%obj.usingSuperChaingun = false;
WeaponImage::onUnmount(%data, %obj, %slot);
}
function displaySCGStatus(%obj) {
if (%obj.superChaingunMode == 1)
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Ions. Progression: " @ ($Ion::StopIon ? "disabled" : "enabled") @ ".<spop>",2,2);
else if (%obj.superChaingunMode == 2)
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Repair Pulse.<spop>",2,2);
else if (%obj.superChaingunMode == 3)
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Cloak Pulse.<spop>",2,2);
else if (%obj.superChaingunMode == 4)
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Deconstruction Pulse<spop>",2,2);
else if (%obj.superChaingunMode == 5)
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Electro-static Pulse.<spop>",2,2);
else if (%obj.superChaingunMode == 6)
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Morph Pulse.<spop>",2,2);
else
bottomPrint(%obj.client,"<spush><font:Sui Generis:14>>>>Super Chain Gun<<<<spop>\n<spush><font:Arial:14>Rapid fire bullets.<spop>",2,2);
}