mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-15 08:24:51 +00:00
re-export new GameData folder from fresh QoL install, updated DynamixThreeSpaceBlenderAddon
This commit is contained in:
parent
7d10fb7dee
commit
27663875ea
7280 changed files with 105217 additions and 119370 deletions
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
package LakObjHud {
|
||||
function setupObjHud(%gameType)
|
||||
{
|
||||
switch$ (%gameType)
|
||||
{
|
||||
case LakRabbitGame:
|
||||
// set separators
|
||||
objectiveHud.setSeparators("56 156");
|
||||
objectiveHud.disableHorzSeparator();
|
||||
|
||||
// Your score label ("SCORE")
|
||||
objectiveHud.scoreLabel = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenLeftProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "4 3";
|
||||
extent = "50 16";
|
||||
visible = "1";
|
||||
text = "SCORE";
|
||||
};
|
||||
// Your score
|
||||
objectiveHud.yourScore = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "60 3";
|
||||
extent = "90 16";
|
||||
visible = "1";
|
||||
};
|
||||
// Rabbit label ("RABBIT")
|
||||
objectiveHud.rabbitLabel = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenLeftProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "4 19";
|
||||
extent = "50 16";
|
||||
visible = "1";
|
||||
text = "RABBIT";
|
||||
};
|
||||
// rabbit name
|
||||
objectiveHud.rabbitName = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "60 19";
|
||||
extent = "90 16";
|
||||
visible = "1";
|
||||
};
|
||||
|
||||
objectiveHud.add(objectiveHud.scoreLabel);
|
||||
objectiveHud.add(objectiveHud.yourScore);
|
||||
objectiveHud.add(objectiveHud.rabbitLabel);
|
||||
objectiveHud.add(objectiveHud.rabbitName);
|
||||
}
|
||||
parent::setupObjHud(%gameType);
|
||||
}
|
||||
};
|
||||
activatePackage(LakObjHud);
|
||||
|
|
@ -0,0 +1,372 @@
|
|||
// #name = Arena Support
|
||||
// #version = 1.0
|
||||
// #date = Febuary 19, 2002
|
||||
// #author = Teribaen
|
||||
// #warrior = Teribaen
|
||||
// #email = teribaen@planettribes.com
|
||||
// #description = Adds an objective HUD and admin commands for the Arena gametype
|
||||
// #readme = scripts/teribaen/arena_support_info.txt
|
||||
// #status = Release
|
||||
// ------------------------------------------------------------------ //
|
||||
|
||||
$ArenaSupport::LocalVersion = 1.0;
|
||||
$ArenaSupport::RemoteVersion = 0;
|
||||
|
||||
$ArenaSupport::TeamCount = 2;
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaVersionMsg()
|
||||
// Recieves version information from the Arena server
|
||||
|
||||
function arenaVersionMsg( %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6 )
|
||||
{
|
||||
%version = detag(%a1);
|
||||
%versionString = detag(%a2);
|
||||
|
||||
echo( "arenaSupport got remote arena version: "@%versionString@" ("@%version@")" );
|
||||
|
||||
$ArenaSupport::RemoteVersion = %version;
|
||||
|
||||
// Put this below the objectiveHud arena label for a few seconds
|
||||
objectiveHud.arenaLabel[2].setValue( %versionString );
|
||||
$ArenaSupport::versClearSchedule = schedule( 15000, 0, arenaClearVersionBox );
|
||||
|
||||
// Respond to the server with our version information
|
||||
commandToServer( 'ArenaSupportHello', $ArenaSupport::LocalVersion );
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================== //
|
||||
// | | //
|
||||
// | ARENA HUD | //
|
||||
// | | //
|
||||
// ========================================================================== //
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaServerState()
|
||||
// Receive information about the server setup
|
||||
|
||||
function arenaServerState( %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6 )
|
||||
{
|
||||
%teamCount = detag(%a1);
|
||||
|
||||
echo( "arenaSupport got teamCount: "@%teamCount );
|
||||
|
||||
$ArenaSupport::TeamCount = %teamCount;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// BEGIN PACKAGE [ ArenaHUD ]
|
||||
// ------------------------------------------------------------------ //
|
||||
|
||||
package ArenaHUD
|
||||
{
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// setupObjHud()
|
||||
// On entering a game prepare the objective hud based on the gametype
|
||||
|
||||
function setupObjHud( %gameType )
|
||||
{
|
||||
echo( "setupObjHud called for ArenaHUD" );
|
||||
|
||||
if ( %gameType $= ArenaGame )
|
||||
{
|
||||
// Set the dividing lines between controls
|
||||
objectiveHud.setSeparators( "48 150 202" );
|
||||
objectiveHud.enableHorzSeparator();
|
||||
|
||||
// Arena Label ("ARENA")
|
||||
objectiveHud.arenaLabel[1] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "4 3";
|
||||
extent = "42 16";
|
||||
visible = "1";
|
||||
text = "ARENA";
|
||||
};
|
||||
|
||||
// Arena Version (Just displays a string from server)
|
||||
objectiveHud.arenaLabel[2] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjHudCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "4 19";
|
||||
extent = "42 16";
|
||||
visible = "1";
|
||||
};
|
||||
|
||||
// Team Names Column
|
||||
objectiveHud.teamName[1] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenLeftProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "56 3";
|
||||
extent = "90 16";
|
||||
visible = "1";
|
||||
};
|
||||
objectiveHud.teamName[2] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjHudLeftProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "56 19";
|
||||
extent = "90 16";
|
||||
visible = "1";
|
||||
};
|
||||
|
||||
// Team State Column (%alive/%total)
|
||||
objectiveHud.arenaState[1] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "156 3";
|
||||
extent = "43 16";
|
||||
visible = "1";
|
||||
};
|
||||
objectiveHud.arenaState[2] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjHudCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "156 19";
|
||||
extent = "43 16";
|
||||
visible = "1";
|
||||
};
|
||||
|
||||
// Team Scores Column
|
||||
objectiveHud.teamScore[1] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjGreenCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "209 3";
|
||||
extent = "26 16";
|
||||
visible = "1";
|
||||
};
|
||||
objectiveHud.teamScore[2] = new GuiTextCtrl() {
|
||||
profile = "GuiTextObjHudCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "209 19";
|
||||
extent = "26 16";
|
||||
visible = "1";
|
||||
};
|
||||
|
||||
// Add our controls to the parent hud object
|
||||
for(%i = 1; %i <= 2; %i++)
|
||||
{
|
||||
objectiveHud.add( objectiveHud.arenaLabel[%i] );
|
||||
objectiveHud.add( objectiveHud.teamName[%i] );
|
||||
objectiveHud.add( objectiveHud.arenaState[%i] );
|
||||
objectiveHud.add( objectiveHud.teamScore[%i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
Parent::setupObjHud( %gameType );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// swapTeamLines()
|
||||
// Swap the objective hud lines to put the player's team on top
|
||||
|
||||
function swapTeamLines()
|
||||
{
|
||||
if ( $ArenaSupport::TeamCount != 2 )
|
||||
return;
|
||||
|
||||
// Formatting constants
|
||||
%bLeft = "GuiTextObjHudLeftProfile";
|
||||
%bCenter = "GuiTextObjHudCenterProfile";
|
||||
%gLeft = "GuiTextObjGreenLeftProfile";
|
||||
%gCenter = "GuiTextObjGreenCenterProfile";
|
||||
|
||||
// Swap the vertical positions of the hud lines
|
||||
%teamOneY = getWord( objectiveHud.teamName[1].position, 1 );
|
||||
%teamTwoY = getWord( objectiveHud.teamName[2].position, 1 );
|
||||
|
||||
if(%teamOneY > %teamTwoY)
|
||||
{
|
||||
// If team one was on the second line, now it'll be on the first
|
||||
%newTop = 1;
|
||||
%newBottom = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If team one was on the first line, now it'll be on the second
|
||||
%newTop = 2;
|
||||
%newBottom = 1;
|
||||
}
|
||||
|
||||
// Swap the controls specific to Arena
|
||||
if( isObject( objectiveHud.arenaState[1] ) )
|
||||
{
|
||||
%locatX = firstWord( objectiveHud.arenaState[1].position );
|
||||
objectiveHud.arenaState[1].position = %locatX SPC %teamTwoY;
|
||||
objectiveHud.arenaState[2].position = %locatX SPC %teamOneY;
|
||||
|
||||
// Swap profiles so top line is green (don't bother with labels)
|
||||
objectiveHud.arenaState[%newTop].setProfile( %gCenter );
|
||||
objectiveHud.arenaState[%newbottom].setProfile( %bCenter );
|
||||
}
|
||||
|
||||
// Swap built-in controls
|
||||
Parent::swapTeamLines();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// DispatchLaunchMode()
|
||||
// Use this builtin function to add our callbacks
|
||||
|
||||
function DispatchLaunchMode()
|
||||
{
|
||||
echo( "DispatchLaunchMode() adding callbacks for ArenaHUD" );
|
||||
|
||||
addMessageCallback( 'MsgArenaVersion', arenaVersionMsg );
|
||||
addMessageCallback( 'MsgArenaServerState', arenaServerState );
|
||||
addMessageCallback( 'MsgArenaAddTeam', arenaAddTeam );
|
||||
addMessageCallback( 'MsgArenaTeamState', arenaTeamState );
|
||||
|
||||
Parent::DispatchLaunchMode();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// END PACKAGE [ ArenaHUD ]
|
||||
// ------------------------------------------------------------------ //
|
||||
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaAddTeam()
|
||||
// Add a team to the arena objective hud
|
||||
|
||||
function arenaAddTeam( %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6 )
|
||||
{
|
||||
%teamNum = detag(%a1);
|
||||
if ( %teamNum > 2 )
|
||||
return;
|
||||
|
||||
%teamName = detag(%a2);
|
||||
%score = detag(%a3);
|
||||
if( %score $= "" )
|
||||
%score = 0;
|
||||
|
||||
%aliveCount = detag(%a4);
|
||||
%totalCount = detag(%a5);
|
||||
if( %aliveCount $= "" )
|
||||
%aliveCount = 0;
|
||||
if( %totalCount $= "" )
|
||||
%totalCount = 0;
|
||||
|
||||
if ( $ArenaSupport::TeamCount == 2 )
|
||||
{
|
||||
objectiveHud.teamName[%teamNum].setValue( %teamName );
|
||||
objectiveHud.teamScore[%teamNum].setValue( %score );
|
||||
objectiveHud.arenaState[%teamNum].setValue( %aliveCount @ "/" @ %totalCount );
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaTeamState()
|
||||
// Update the alive/total player count for a team on the arena hud
|
||||
|
||||
function arenaTeamState( %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6 )
|
||||
{
|
||||
%teamNum = detag(%a1);
|
||||
if ( %teamNum > 2 )
|
||||
return;
|
||||
|
||||
%aliveCount = detag(%a2);
|
||||
%totalCount = detag(%a3);
|
||||
|
||||
if( %aliveCount $= "" )
|
||||
%aliveCount = 0;
|
||||
if( %totalCount $= "" )
|
||||
%totalCount = 0;
|
||||
|
||||
if ( $ArenaSupport::TeamCount == 2 )
|
||||
objectiveHud.arenaState[%teamNum].setValue( %aliveCount @ "/" @ %totalCount );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaClearVersionBox()
|
||||
// Clears the objhud version box (under the arena label)
|
||||
|
||||
function arenaClearVersionBox()
|
||||
{
|
||||
objectiveHud.arenaLabel[2].setValue( "" );
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// Always execute the ArenaHUD package
|
||||
|
||||
activatePackage( ArenaHUD );
|
||||
|
||||
|
||||
|
||||
// ========================================================================== //
|
||||
// | | //
|
||||
// | CONSOLE ADMIN COMMANDS | //
|
||||
// | | //
|
||||
// ========================================================================== //
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaForceRoundEnd();
|
||||
|
||||
function arenaForceRoundEnd( %teamIndex )
|
||||
{
|
||||
if ( %teamIndex $= "" )
|
||||
%teamIndex = 0;
|
||||
|
||||
commandToServer( 'ArenaForceRoundEnd', %teamIndex );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaSetCurrentRoundLimit();
|
||||
|
||||
function arenaSetCurrentRoundLimit( %newRoundLimit )
|
||||
{
|
||||
commandToServer( 'ArenaSetCurrentRoundLimit', %newRoundLimit );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaSetCurrentTimeLimit();
|
||||
|
||||
function arenaSetCurrentTimeLimit( %newTimeLimit )
|
||||
{
|
||||
commandToServer( 'ArenaSetCurrentTimeLimit', %newTimeLimit );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaEnableDebugging();
|
||||
|
||||
function arenaEnableDebugging()
|
||||
{
|
||||
commandToServer( 'ArenaEnableDebugging' );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// arenaDisableDebugging();
|
||||
|
||||
function arenaDisableDebugging()
|
||||
{
|
||||
commandToServer( 'ArenaDisableDebugging' );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ //
|
||||
// SADsetJoinPassword();
|
||||
|
||||
function SADsetJoinPassword( %newPassword )
|
||||
{
|
||||
commandToServer( 'SetJoinPassword', %newPassword );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========================================================================== //
|
||||
// | | //
|
||||
// | VOTING/MENU SUPPORT | //
|
||||
// | | //
|
||||
// ========================================================================== //
|
||||
|
||||
|
||||
2511
docs/base/@vl2/z_scripts/support.vl2/autoload.cs
Normal file
2511
docs/base/@vl2/z_scripts/support.vl2/autoload.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1 @@
|
|||
if( !$AutoloadExecuted ) exec("autoload.cs");
|
||||
757
docs/base/@vl2/z_scripts/support.vl2/support/PJColorSelector.cs
Normal file
757
docs/base/@vl2/z_scripts/support.vl2/support/PJColorSelector.cs
Normal file
|
|
@ -0,0 +1,757 @@
|
|||
// #name = Tribes 2 Color Selector
|
||||
// #version = 1.0.1
|
||||
// #date = June 14, 2002
|
||||
// #author = Mark Dickenson ([AKA]PanamaJack)
|
||||
// #email = akapanamajack@planettribes.com
|
||||
// #web = http://www.planettribes.com/pj
|
||||
// #description = RGB Dialog
|
||||
// #acknowledgements = none
|
||||
// #status = working
|
||||
|
||||
//
|
||||
// You can now use an RGB Dialog for setting colors of text in the game.
|
||||
//
|
||||
// setRGBcolor(%variable, %function)
|
||||
//
|
||||
// %variable - The variable you want the new color value stored
|
||||
//
|
||||
// %function - The routine you want to execute when dialog closes
|
||||
// This is usually an update routine for updating
|
||||
// a display. (optional)
|
||||
//
|
||||
// example: setRGBcolor("$mycolor", "Showmyupdate();");
|
||||
//
|
||||
// In the above example the RGB Dialog will open and the Red, Green and Blue
|
||||
// sliders will be set to the color in $mycolor.
|
||||
//
|
||||
// When the dialog is closed either by clicking on the CANCEL or SELECT button the
|
||||
// previous or new color values will be stored in $mycolor. You MUST place the variable name
|
||||
// within QUOTES!
|
||||
//
|
||||
// And when the dialog is closed either by clicking the CANCEL or SELECT button the
|
||||
// Showmyupdate() function is called. You would use this to cause the RGB Dialog to update
|
||||
// a display when the dialog closes. It is an optional argument so you can leave it off.
|
||||
//
|
||||
// Example of use in a Button GUI.
|
||||
//
|
||||
// new ShellBitmapButton() {
|
||||
// profile = "ShellButtonProfile";
|
||||
// horizSizing = "center";
|
||||
// vertSizing = "bottom";
|
||||
// position = "0 55";
|
||||
// extent = "130 30";
|
||||
// minExtent = "26 27";
|
||||
// command = "setRGBcolor(\"$PJColor::PopupTeam\", \"PJshowPopupTeam();\");";
|
||||
// visible = "1";
|
||||
// helpTag = "0";
|
||||
// text = "Set Team Color";
|
||||
// maxLength = "255";
|
||||
// };
|
||||
//
|
||||
// The above will execute the setRGBcolor command when the button is pressed. $PJColor::PopupTeam is the
|
||||
// HEX code color information being passed to the routine for the initial slider setup and where the
|
||||
// color codes will be stored. The PJshowPopupTeam(); that is enclosed in quotes is the routine
|
||||
// you would like the Dialog to execute when the Select or Cancel button is clicked.
|
||||
//
|
||||
// If you want to change the default colors there is a file called PJRGBColors.pj in the prefs directory.
|
||||
// Load this into any text editor and you can change all 12 of the preset colors to anything you wish.
|
||||
// The colors are standard HEX codes that are used by most web browsers.
|
||||
//
|
||||
|
||||
if(!isObject(PJColorGlobal))
|
||||
new ScriptObject(PJColorGlobal){};
|
||||
|
||||
function setRGBcolor(%variable, %routine) {
|
||||
|
||||
eval("PJColorGlobal.color = " @ %variable @ ";");
|
||||
PJColorGlobal.variable = %variable;
|
||||
|
||||
PJMakeRGBdlg();
|
||||
PJRBGOK.command = %variable @ " = PJMakeRGB(); RGBonSleep(); " @ %routine;
|
||||
PJRGBCANCEL.command = %variable @ " = $PJOldColor; RGBonSleep(); " @ %routine;
|
||||
//PJPushDialog(PJRGBDlg, 2, 4, 7, 0, 0, 0, 1, PJSoundEffects.PJFontDlg1, PJSoundEffects.PJFontDlg2, 0, $PJPref::GeneralAnimationSpeed, 1);
|
||||
canvas.pushDialog(PJRGBDlg);
|
||||
|
||||
$PJOldColor = PJColorGlobal.color;
|
||||
|
||||
PJsetRGBColor();
|
||||
}
|
||||
|
||||
function PJsetRGBColor(){
|
||||
|
||||
$PJRed = HexToDecimal(getSubStr(PJColorGlobal.color, 0, 2));
|
||||
GMH_PJRedSlider.setValue ( $PJRed * 0.00390625);
|
||||
|
||||
$PJGreen = HexToDecimal(getSubStr(PJColorGlobal.color, 2, 2));
|
||||
GMH_PJGreenSlider.setValue ( $PJGreen * 0.00390625);
|
||||
|
||||
$PJBlue = HexToDecimal(getSubStr(PJColorGlobal.color, 4, 2));
|
||||
GMH_PJBlueSlider.setValue ( $PJBlue * 0.00390625);
|
||||
|
||||
}
|
||||
|
||||
function PJMakeRGB() {
|
||||
|
||||
%color = DecimalToHex($PJRed);
|
||||
%color = %color @ DecimalToHex($PJGreen);
|
||||
%color = %color @ DecimalToHex($PJBlue);
|
||||
|
||||
return %color;
|
||||
}
|
||||
|
||||
function RGBonSleep() {
|
||||
|
||||
//PJPopDialog(PJRGBDlg, 2, 4, 7, 0, 0, 0, 1, PJSoundEffects.PJRGBDlg1, PJSoundEffects.PJRGBDlg2, 0, $PJPref::GeneralAnimationSpeed, 1);
|
||||
canvas.popDialog(PJRGBDlg);
|
||||
}
|
||||
|
||||
function PJRGBDlg::onWake(%this){
|
||||
|
||||
|
||||
}
|
||||
|
||||
function PJRGBDlg::onSleep(%this){
|
||||
|
||||
PJRGBDlg.schedule(2000, delete);
|
||||
}
|
||||
|
||||
$PJHex = "0123456789ABCDEF";
|
||||
|
||||
function HexToDecimal(%hex) {
|
||||
|
||||
%hex = strupr(%hex);
|
||||
|
||||
%number = StrStr($PJHex, getSubStr(%hex, 0, 1)) * 16;
|
||||
%number = %number + StrStr($PJHex, getSubStr(%hex, 1, 1));
|
||||
|
||||
return %number;
|
||||
}
|
||||
|
||||
function DecimalToHex(%decimal) {
|
||||
|
||||
%hex1 = mfloor(%decimal / 16);
|
||||
%hex2 = %decimal - (%hex1 * 16);
|
||||
|
||||
%hex = getSubStr($PJHex, %hex1, 1) @ getSubStr($PJHex, %hex2, 1);
|
||||
|
||||
return %hex;
|
||||
|
||||
}
|
||||
|
||||
function setPJRedColor() {
|
||||
|
||||
$PJRed = mfloor(GMH_PJRedSlider.getValue() * 256);
|
||||
%color = PJMakeRGB();
|
||||
PJ_RGBShowMe.setText("<just:center><color:" @ %color @">** Current Color **");
|
||||
|
||||
}
|
||||
|
||||
function setPJGreenColor() {
|
||||
|
||||
$PJGreen = mfloor(GMH_PJGreenSlider.getValue() * 256);
|
||||
%color = PJMakeRGB();
|
||||
PJ_RGBShowMe.setText("<just:center><color:" @ %color @">** Current Color **");
|
||||
|
||||
}
|
||||
|
||||
function setPJBlueColor() {
|
||||
|
||||
$PJBlue = mfloor(GMH_PJBlueSlider.getValue() * 256);
|
||||
%color = PJMakeRGB();
|
||||
PJ_RGBShowMe.setText("<just:center><color:" @ %color @">** Current Color **");
|
||||
|
||||
}
|
||||
|
||||
function PJMakeRGBdlg() {
|
||||
|
||||
new GuiControlProfile ("GuiRGBProfile"){
|
||||
fontType = "Univers Condensed Bold";
|
||||
fontSize = 28;
|
||||
fontColor = "169 215 250";
|
||||
};
|
||||
|
||||
//--- OBJECT WRITE BEGIN ---
|
||||
new GuiControl(PJRGBDlg) {
|
||||
profile = "DlgBackProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "0 0";
|
||||
extent = "640 480";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
|
||||
new ShellPaneCtrl() {
|
||||
profile = "ShellDlgPaneProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "center";
|
||||
position = "134 58";
|
||||
extent = "372 364";
|
||||
minExtent = "48 92";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
text = "Select Color";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
noTitleBar = "0";
|
||||
|
||||
new ShellBitmapButton(PJRGBCANCEL) {
|
||||
profile = "ShellButtonProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "57 304";
|
||||
extent = "128 38";
|
||||
minExtent = "32 38";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "";
|
||||
helpTag = "0";
|
||||
text = "Cancel";
|
||||
simpleStyle = "0";
|
||||
};
|
||||
new GuiTextCtrl() {
|
||||
profile = "ShellTextCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "25 60";
|
||||
extent = "320 22";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
text = "Red";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
};
|
||||
new ShellSliderCtrl(GMH_PJRedSlider) {
|
||||
profile = "ShellSliderProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "27 75";
|
||||
extent = "320 24";
|
||||
minExtent = "12 24";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
variable = "value";
|
||||
altCommand = "setPJRedColor();";
|
||||
helpTag = "0";
|
||||
range = "0.000000 0.996094";
|
||||
ticks = "256";
|
||||
value = "0.996094";
|
||||
usePlusMinus = "1";
|
||||
};
|
||||
new GuiTextCtrl() {
|
||||
profile = "ShellTextCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "25 95";
|
||||
extent = "320 22";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
text = "Green";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
};
|
||||
new ShellSliderCtrl(GMH_PJGreenSlider) {
|
||||
profile = "ShellSliderProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "27 110";
|
||||
extent = "320 24";
|
||||
minExtent = "12 24";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
variable = "value";
|
||||
altCommand = "setPJGreenColor();";
|
||||
helpTag = "0";
|
||||
range = "0.000000 0.996094";
|
||||
ticks = "256";
|
||||
value = "0";
|
||||
usePlusMinus = "1";
|
||||
};
|
||||
new GuiTextCtrl() {
|
||||
profile = "ShellTextCenterProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "25 130";
|
||||
extent = "320 22";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
text = "Blue";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
};
|
||||
new ShellSliderCtrl(GMH_PJBlueSlider) {
|
||||
profile = "ShellSliderProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "27 145";
|
||||
extent = "320 24";
|
||||
minExtent = "12 24";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
variable = "value";
|
||||
altCommand = "setPJBlueColor();";
|
||||
helpTag = "0";
|
||||
range = "0.000000 0.996094";
|
||||
ticks = "256";
|
||||
value = "0";
|
||||
usePlusMinus = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb1) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "top";
|
||||
position = "40 171";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb1a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "67 171";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"000000\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb2) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "240 204";
|
||||
extent = "23 16";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb2a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "272 204";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"333333\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb3) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "240 238";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb3a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "272 238";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"666666\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb4) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "240 272";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb4a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "272 272";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"999999\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb5) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "140 171";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb5a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "168 171";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"CCCCCC\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb6) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "140 204";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb6a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "168 204";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"FFFFFF\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb7) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "140 238";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb7a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "168 238";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"FF0000\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb8) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "140 272";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb8a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "168 272";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"00FF00\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb9) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "240 171";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb9a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "272 171";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"0000FF\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb10) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "40 204";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb10a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "67 204";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"FFFF00\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb11) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "40 238";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb11a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "67 238";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"00FFFF\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new GuiMLTextCtrl(rgb12) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "40 272";
|
||||
extent = "23 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
};
|
||||
new ShellRadioButton(rgb12a) {
|
||||
profile = "ShellRadioProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "67 272";
|
||||
extent = "35 30";
|
||||
minExtent = "26 27";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "PJColorGlobal.color = \"FF00FF\";";
|
||||
helpTag = "0";
|
||||
longTextBuffer = "0";
|
||||
maxLength = "255";
|
||||
groupNum = "1";
|
||||
};
|
||||
new ShellBitmapButton(PJRBGOK) {
|
||||
profile = "ShellButtonProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "194 304";
|
||||
extent = "128 38";
|
||||
minExtent = "32 38";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
command = "";
|
||||
helpTag = "0";
|
||||
text = "Select";
|
||||
simpleStyle = "0";
|
||||
};
|
||||
new GuiMLTextCtrl(PJ_RGBShowMe) {
|
||||
profile = "GuiRGBProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "top";
|
||||
position = "87 29";
|
||||
extent = "200 28";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
lineSpacing = "2";
|
||||
allowColorChars = "0";
|
||||
maxChars = "-1";
|
||||
deniedSound = "InputDeniedSound";
|
||||
text = "** Current Color **";
|
||||
};
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
|
||||
for (%i = 1; %i <= 12; %i++){
|
||||
|
||||
%temp = rgb @ %i;
|
||||
%tempa = %temp @ a;
|
||||
%temp.setText("<color:" @ getWord($RGBColors, %i - 1) @ ">**");
|
||||
%tempa.command = "PJColorGlobal.color = \"" @ getWord($RGBColors, %i - 1) @ "\"; PJsetRGBColor();";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$RGBColors = "000000 333333 666666 999999 CCCCCC FFFFFF FF0000 00FF00 0000FF FFFF00 00FFFF FF00FF";
|
||||
|
||||
if(isFile("prefs/PJRGBColors.pj")){
|
||||
|
||||
exec("prefs/PJRGBColors.pj");
|
||||
|
||||
} else {
|
||||
|
||||
export("$RGBColors", "prefs/PJRGBColors.pj", false);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,291 @@
|
|||
// #autoload
|
||||
// #name = Enhanced Recordings
|
||||
// #version = 1.0.1
|
||||
// #date = November 20, 2002
|
||||
// #author = Mark Dickenson ([AKA]PanamaJack)
|
||||
// #warrior = Panama Jack
|
||||
// #email = panamajack@planettribes.com
|
||||
// #web = http://www.planettribes.com/pj
|
||||
// #category = Support
|
||||
// #description = Support for adding more information to demo recordings.
|
||||
// #acknowledgements = none
|
||||
// #status = working
|
||||
|
||||
// This script will add extra useful information to all REC files when they are created. This will allow scripters to
|
||||
// retreive useful information about the recording. Scripters can also ADD their own special information to any
|
||||
// recording that can only be procecessed by their scripts if a client has them installed.
|
||||
//
|
||||
// The standard information that is stored in each recording is easy to use and is stored in the following variables.
|
||||
//
|
||||
// Variable Description
|
||||
//----------------------------------------------------------------------------------------------
|
||||
//
|
||||
// NewRecordingData.clientid - The client id of the person who made the recording.
|
||||
//
|
||||
// NewRecordingData.playername - The Name of the Player including their Tribes Tag (if any) who made the recording.
|
||||
//
|
||||
// NewRecordingData.friendlyteam - The name of the team the Player was on.
|
||||
//
|
||||
// NewRecordingData.guid - The GUID of the player who made the recording.
|
||||
//
|
||||
// NewRecordingData.servername - The name of the Server where the recording was made.
|
||||
//
|
||||
// NewRecordingData.serverip - The IP Address of the server where the recording was made.
|
||||
//
|
||||
// NewRecordingData.date - The Date and Time the recording was made (IE: NOV-12-2002 10:30PM)
|
||||
//
|
||||
// NewRecordingData.mapname - The name of the Map where the recording was started.
|
||||
//
|
||||
// NewRecordingData.ruleset - The Ruleset or MOD running on the server (IE: Base, Variant, Shifter, ect).
|
||||
//
|
||||
// NewRecordingData.gametype - The Gamtype being played (IE: Cpature the Flag, Team Rabbit 2, ect).
|
||||
//
|
||||
// NewRecordingData.tourneymode - The mode the server was running "Free for All" or "Tournament". FFA = 0, Tournament = 1
|
||||
//
|
||||
// All of the above data is accessable by any client sided script after a demo starts and will be standard in all recordings when this script is used.
|
||||
//
|
||||
|
||||
// Something to store all of the variables in.
|
||||
|
||||
new scriptobject(NewRecordingData){
|
||||
elements = 0;
|
||||
tourneymode = 0;
|
||||
FirstInfo = 0;
|
||||
};
|
||||
|
||||
|
||||
// 1, clientid, playername, friendlyteam, guid
|
||||
// 2, servername, serverip, date, mapname
|
||||
// 3, ruleset, gametype,tourneymode(0 - Tourney Off/ 1 - Tourney On)
|
||||
|
||||
function readplayerinfo(%group, %arg1, %arg2, %arg3, %arg4){
|
||||
|
||||
if(%group == 1){
|
||||
NewRecordingData.clientid = %arg1; //
|
||||
NewRecordingData.playername = %arg2; //
|
||||
NewRecordingData.friendlyteam = %arg3;
|
||||
NewRecordingData.guid = %arg4;
|
||||
}
|
||||
if(%group == 2){
|
||||
NewRecordingData.servername = %arg1; //
|
||||
NewRecordingData.serverip = %arg2; //
|
||||
NewRecordingData.date = %arg3; //
|
||||
NewRecordingData.mapname = %arg4; //
|
||||
}
|
||||
if(%group == 3){
|
||||
NewRecordingData.ruleset = %arg1; //
|
||||
NewRecordingData.gametype = %arg2; //
|
||||
NewRecordingData.tourneymode = %arg3; //
|
||||
}
|
||||
}
|
||||
|
||||
// This function is how you would add your own data to the REC file. You must be very carefull about what you place in here.
|
||||
//
|
||||
// %variable = This is a special variable that is looked for by this script to determine if the script that will use the added REC information has been installed.
|
||||
// I could have used a file check but this needed to be very, very fast and checking for a file would cause enough delay to cause problems if there
|
||||
// were a large number of added entries to the REC file. You MUST use a variable for this entry and place it inside QUOTES.
|
||||
//
|
||||
// EXAMPLE: addRecordingInfo("$MyVariable", ... RIGHT
|
||||
// EXAMPLE: addRecordingInfo("MyScriptObject.Variable", ... RIGHT
|
||||
//
|
||||
// EXAMPLE: addRecordingInfo($MyVariable, ... WRONG
|
||||
// EXAMPLE: addRecordingInfo(1, ... WRONG
|
||||
//
|
||||
// This script will look for that variable and check to see if it equals 0 or 1. If the variable equals 0 or is missing your information in the REC file will
|
||||
// not be processed and it will be bypassed. If the variable equals 1 then the script will process your data frrom the REC file.
|
||||
//
|
||||
// Just add a unique variable to the end of the script that will be using the information from the REC file you added. Make sure it is equal to 0.
|
||||
//
|
||||
//
|
||||
// %function = This is the Function you would like to call to procecss the added data. This function name MUST be inclosed in QUOTES and should not include
|
||||
// ANY parenthesis or semi-colons.
|
||||
//
|
||||
// EXAMPLE: addRecordingInfo("MyScriptObject.Variable", "myfunction", ... RIGHT
|
||||
//
|
||||
// EXAMPLE: addRecordingInfo("MyScriptObject.Variable", "myfunction()", ... WRONG
|
||||
// EXAMPLE: addRecordingInfo("MyScriptObject.Variable", "myfunction();", ... WRONG
|
||||
//
|
||||
// %arg0-%arg4 = These 5 arguments contain the data you would like to store in the REC file. Be very carfull because the total data size of these arguments
|
||||
// cannot exceed 250 characters or they will be discarded. The arguments work very similarly to the %variable and %function listed above.
|
||||
// The arguments can be variables, text, functions or a combination of any as long as they are enclosed in QUOTES. If you wish to save just a text
|
||||
// string it must be enclosed in two sets of quotes IE: "\"My Text\""
|
||||
//
|
||||
// VARIABLE EXAMPLE: "$anothervariable" RIGHT
|
||||
// FUNCTION EXAMPLE: "myfunction()" RIGHT
|
||||
// EXPRESSION EXAMPLE: "$clTeamScore[$PlayerList[NewRecordingData.clientid].teamId,0]" RIGHT
|
||||
// TEXT EXAMPLE: "\"Test Text\"" RIGHT
|
||||
// NUMERIC EXAMPLE: "2" RIGHT
|
||||
//
|
||||
// Each argument is called and the information returned from the argument is saved in the REC file.
|
||||
//
|
||||
// FINAL EXAMPLE: addRecordingInfo("MyScriptObject.Variable", "myfunction", "$anothervariable", "myfunction()", "$clTeamScore[$PlayerList[NewRecordingData.clientid].teamId,0]", "\"Test Text\"", "2");
|
||||
//
|
||||
//
|
||||
// When a REC file is played back this information is retrieved frrom the recording and processed.
|
||||
//
|
||||
// The data that was stored as the %variable is retrieved and processed. If the variable is equal to 1 then the script that will use the data is present and the following data is proceessed.
|
||||
// If the variable is equal to 0 or not present then the data is bypassed and the next set of data is checked.
|
||||
//
|
||||
// If the variable equalled 1 then the reset of the data is retrieved from the REC file and the function that was included in the %function is called and the argument data is passed to it.
|
||||
//
|
||||
// IE: myfunction(%arg0, %arg1, %arg2, %arg3, %arg4);
|
||||
//
|
||||
// It is thin upto your function to proceess the data.
|
||||
//
|
||||
|
||||
|
||||
function addRecordingInfo(%variable, %function, %arg0, %arg1, %arg2, %arg3, %arg4){
|
||||
|
||||
if(%variable $= "" || %function $= ""){
|
||||
error("Either the variable Variable or Function Variable is missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
NewRecordingData.variable[NewRecordingData.elements] = %variable;
|
||||
NewRecordingData.func[NewRecordingData.elements] = %function;
|
||||
|
||||
NewRecordingData.arguments[NewRecordingData.elements @ "_0"] = %arg0;
|
||||
NewRecordingData.arguments[NewRecordingData.elements @ "_1"] = %arg1;
|
||||
NewRecordingData.arguments[NewRecordingData.elements @ "_2"] = %arg2;
|
||||
NewRecordingData.arguments[NewRecordingData.elements @ "_3"] = %arg3;
|
||||
NewRecordingData.arguments[NewRecordingData.elements @ "_4"] = %arg4;
|
||||
|
||||
NewRecordingData.elements++;
|
||||
}
|
||||
|
||||
// Get the current Map Name and Gametype and store for later use.
|
||||
// This is part of the basic information prestored in all REC files for any scripter to use.
|
||||
|
||||
function RecMissionCheck(%msgType, %msgString, %bitmapName, %mapName, %missionType) {
|
||||
|
||||
if(NewRecordingData.FirstInfo == 0){
|
||||
NewRecordingData.mapname = detag(%mapName);
|
||||
NewRecordingData.gametype = detag(%missionType);
|
||||
NewRecordingData.FirstInfo= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the players Client ID and Player Name and store them for later use.
|
||||
|
||||
function RecJoin(%msgType, %msgString, %clientName, %clientId, %targetId, %isAI, %isAdmin, %isSuperAdmin, %isSmurf, %guid) {
|
||||
|
||||
if(StrStr(%msgString, "Welcome to Tribes") != -1) {
|
||||
NewRecordingData.clientid = %clientId;
|
||||
NewRecordingData.playername = detag(%clientName);
|
||||
}
|
||||
}
|
||||
|
||||
// All of the lovely function that need to be hooked into...
|
||||
|
||||
package PJPackagedRecording {
|
||||
|
||||
// Reset the FirstInfo and tourneymode flags when the player leave a server.
|
||||
|
||||
function DisconnectedCleanup() {
|
||||
|
||||
parent::DisconnectedCleanup();
|
||||
|
||||
NewRecordingData.FirstInfo = 0;
|
||||
NewRecordingData.tourneymode = 0;
|
||||
}
|
||||
|
||||
// Reset the FirstInfo and tourneymode flags when the Map CHanges.
|
||||
|
||||
function DebriefGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
|
||||
NewRecordingData.FirstInfo = 0;
|
||||
NewRecordingData.tourneymode = 0;
|
||||
}
|
||||
|
||||
// Set the Tourney Mode flag is the server is in Tournament mode.
|
||||
|
||||
function clientCmdPickTeamMenu( %teamA, %teamB ){
|
||||
|
||||
NewRecordingData.tourneymode = 1;
|
||||
|
||||
parent::clientCmdPickTeamMenu( %teamA, %teamB );
|
||||
}
|
||||
|
||||
// Get the Server Name, Server IP Address and the RuleSet(MOD) and store.
|
||||
|
||||
function GMJ_Browser::onSelect( %this, %address ) {
|
||||
|
||||
parent::onSelect( %this, %address );
|
||||
|
||||
%info = GMJ_Browser.getServerInfoString();
|
||||
NewRecordingData.servername = strlwr(getRecord( %info, 0));
|
||||
NewRecordingData.serverip = strlwr(getRecord( %info, 1));
|
||||
NewRecordingData.ruleset = strlwr(getRecord( %info, 2 ));
|
||||
}
|
||||
|
||||
// Adds the new Recoding Information to the REC file.
|
||||
|
||||
function saveDemoSettings(){
|
||||
|
||||
parent::saveDemoSettings();
|
||||
|
||||
if(NewRecordingData.elements > 0){
|
||||
addDemoValue("NewDemoData");
|
||||
for(%i = 0; %i < NewRecordingData.elements; %i++){
|
||||
addDemoValue(NewRecordingData.variable[%i]);
|
||||
addDemoValue(NewRecordingData.func[%i]);
|
||||
eval("NewRecordingData.scripthold = " @ NewRecordingData.arguments[%i @ "_0"] @ ";");
|
||||
%temp = NewRecordingData.scripthold;
|
||||
for(%i1 = 1; %i1 < 5; %i1++){
|
||||
if(NewRecordingData.arguments[%i @ "_" @ %i1] $= "")
|
||||
%arg = "\"<BLANK>\"";
|
||||
else %arg = NewRecordingData.arguments[%i @ "_" @ %i1];
|
||||
|
||||
eval("NewRecordingData.scripthold = " @ %arg @ ";");
|
||||
%temp = %temp TAB NewRecordingData.scripthold;
|
||||
}
|
||||
addDemoValue(%temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retreives the Recording information from the REC file and calls the associated functions if the required scripts are installed.
|
||||
|
||||
function loadDemoSettings(){
|
||||
|
||||
parent::loadDemoSettings();
|
||||
|
||||
%start = 0;
|
||||
|
||||
for(%total = 0; $DemoValue[%total] !$= ""; %total++) {
|
||||
if($DemoValue[%total] $= "NewDemoData")
|
||||
%start = %total + 1;
|
||||
}
|
||||
|
||||
if(%start != 0){
|
||||
for(%i = %start; %i < %total; %i++){
|
||||
NewRecordingData.scripthold = 0;
|
||||
eval("NewRecordingData.scripthold = " @ $DemoValue[%i] @ ";");
|
||||
if(NewRecordingData.scripthold $= "1"){
|
||||
for(%i1 = 0; %i1 < 5; %i1++){
|
||||
%a[%i1] = getField($DemoValue[%i + 2], %i1);
|
||||
if(%a[%i1] $= "<BLANK>")
|
||||
%a[%i1] = "";
|
||||
}
|
||||
call($DemoValue[%i + 1], %a[0], %a[1], %a[2], %a[3], %a[4]);
|
||||
}
|
||||
%i = %i + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
activatepackage(PJPackagedRecording);
|
||||
|
||||
// Setup the Basic Rocording Data that is saved in every recording.
|
||||
// This is to establish a standard that all Scripters can pull data from without everyone duplicating the same data being stored in the REC file.
|
||||
|
||||
addRecordingInfo(1, "readplayerinfo", 1, "NewRecordingData.clientid", "NewRecordingData.playername", "$clTeamScore[$PlayerList[NewRecordingData.clientid].teamId,0]", "$playerlist[NewRecordingData.clientid].guid");
|
||||
addRecordingInfo(1, "readplayerinfo", 2, "NewRecordingData.servername", "NewRecordingData.serverip", "formatTimeString(\"M-d-yy h:nnA\")", "NewRecordingData.mapname");
|
||||
addRecordingInfo(1, "readplayerinfo", 3, "NewRecordingData.ruleset", "NewRecordingData.gametype", "NewRecordingData.tourneymode");
|
||||
|
||||
addMessageCallBack('MsgLoadInfo', RecMissionCheck);
|
||||
addMessageCallback('MsgClientJoin', RecJoin);
|
||||
332
docs/base/@vl2/z_scripts/support.vl2/support/PJFontSelector.cs
Normal file
332
docs/base/@vl2/z_scripts/support.vl2/support/PJFontSelector.cs
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
|
||||
// #name = Tribes 2 Font Selector
|
||||
// #version = 1.0.1
|
||||
// #date = June 14, 2002
|
||||
// #author =Mark Dickenson ([AKA]PanamaJack)
|
||||
// #email = akapanamajack@planettribes.com
|
||||
// #web = http://www.planettribes.com/pj
|
||||
// #description = Font Selector
|
||||
// #acknowledgements = none
|
||||
// #status = working
|
||||
|
||||
//
|
||||
// You can now use a Font Selector Dialog for setting the font and size of text in the game.
|
||||
//
|
||||
//
|
||||
// PJSelectFont(%font, %size, %function);
|
||||
//
|
||||
//
|
||||
// %font - The variable the font name is stored.
|
||||
//
|
||||
// %size - The variable the font size is stored.
|
||||
//
|
||||
// %function - The routine you want to execute when dialog closes
|
||||
// This is usually an update routine for updating
|
||||
// a display. (optional)
|
||||
//
|
||||
// example: PJSelectFont("$PJPref::FlagPopupFont", "$PJPref::FlagPopupFontSize", "PJsetFlagPopupFont();");
|
||||
//
|
||||
// In the above example the Font Selection Dialog will open.
|
||||
//
|
||||
// When the dialog is closed either by clicking on the CANCEL or SELECT button the
|
||||
// font data is stored in the variables you indicated. You MUST place the variable name
|
||||
// within QUOTES! If CANCEL was selected nothing will change.
|
||||
//
|
||||
// And when the dialog is closed either by clicking the CANCEL or SELECT button the
|
||||
// function is called if one has been provided in the %function variable.
|
||||
// It is an optional argument so you can leave it off.
|
||||
//
|
||||
// Example of use in a Button GUI.
|
||||
//
|
||||
// new ShellBitmapButton() {
|
||||
// profile = "ShellButtonProfile";
|
||||
// horizSizing = "center";
|
||||
// vertSizing = "bottom";
|
||||
// position = "0 55";
|
||||
// extent = "130 30";
|
||||
// minExtent = "26 27";
|
||||
// command = "PJSelectFont(\"$PJPref::FlagPopupFont\", \"$PJPref::FlagPopupFontSize\", \"PJsetFlagPopupFont();\");";
|
||||
// visible = "1";
|
||||
// helpTag = "0";
|
||||
// text = "Set Speed Hud Font";
|
||||
// maxLength = "255";
|
||||
// };
|
||||
//
|
||||
// The above will execute the PJSelectFont command when the button is pressed. $PJPref::FlagPopupFont and
|
||||
// $PJPref::FlagPopupFontSize are the font name and sizebeing passed to the routine for the initial setup
|
||||
// and where the font and size will be stored. The PJshowPopupTeam(); that is enclosed in quotes is the routine
|
||||
// you would like the Dialog to execute when the Select or Cancel button is clicked.
|
||||
|
||||
if(!isObject(PJFontGlobal))
|
||||
new ScriptObject(PJFontGlobal){};
|
||||
|
||||
// find installed fonts
|
||||
|
||||
%path = "fonts/*.gft";
|
||||
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) ) {
|
||||
%temp =getSubStr(%file, 6, 256);
|
||||
%location = StrStr(%temp, "_");
|
||||
%fontname = getSubStr(%temp, 0, %location);
|
||||
%temp = getSubStr(%temp, %location + 1, 256);
|
||||
%location = StrStr(%temp, ".");
|
||||
%fontsize = getSubStr(%temp, 0, %location);
|
||||
|
||||
if(PJFontGlobal.FontTotal[%fontname] < 1) {
|
||||
PJFontGlobal.TotalFonts++;
|
||||
PJFontGlobal.Fontname[PJFontGlobal.TotalFonts] = %fontname;
|
||||
}
|
||||
|
||||
PJFontGlobal.FontTotal[%fontname]++;
|
||||
%temp = PJFontGlobal.FontTotal[%fontname];
|
||||
PJFontGlobal.FontSize[%fontname @ %temp] = %fontsize;
|
||||
|
||||
}
|
||||
|
||||
for(%font = 1; %font <= PJFontGlobal.TotalFonts; %font++) {
|
||||
%fontname = PJFontGlobal.Fontname[%font];
|
||||
%temp = PJFontGlobal.FontTotal[%fontname];
|
||||
|
||||
for (%i = 1; %i <= %temp; %i++) {
|
||||
for (%j = %i+1; %j <= %temp; %j++) {
|
||||
if (PJFontGlobal.FontSize[%fontname @ %i] > PJFontGlobal.FontSize[%fontname @ %j]) {
|
||||
%temp2 = PJFontGlobal.FontSize[%fontname @ %j];
|
||||
PJFontGlobal.FontSize[%fontname @ %j] = PJFontGlobal.FontSize[%fontname @ %i];
|
||||
PJFontGlobal.FontSize[%fontname @ %i] = %temp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function PJselectFont(%fontvariable, %sizevariable, %routine) {
|
||||
|
||||
PJMakeFontDlg();
|
||||
|
||||
eval("PJFontGlobal.font = " @ %fontvariable @ ";");
|
||||
PJFontGlobal.fontvariable = %fontvariable;
|
||||
eval("PJFontGlobal.size = " @ %sizevariable @ ";");
|
||||
PJFontGlobal.sizevariable = %sizevariable;
|
||||
|
||||
PJFontOK.command = "PJFontGlobal.type = 1; PJFontonSleep(); " @ %routine;
|
||||
PJFontCANCEL.command = "PJFontGlobal.type = 0; PJFontonSleep(); " @ %routine;
|
||||
//PJPushDialog(PJFontDlg, 2, 4, 7, 0, 0, 0, 1, PJSoundEffects.PJFontDlg1, PJSoundEffects.PJFontDlg2, 0, $PJPref::GeneralAnimationSpeed, 1);
|
||||
canvas.pushDialog(PJFontDlg);
|
||||
PJFontDlg.getObject(0).setVisible(1);
|
||||
PJFontText.setText("<just:center><color:00df30>Make Font and Size Selection");
|
||||
PJFontList.clear();
|
||||
for( %i = 1; %i <= PJFontGlobal.TotalFonts; %i++ ){
|
||||
PJFontList.add( PJFontGlobal.Fontname[%i], %i - 1);
|
||||
if(PJFontGlobal.font $= PJFontGlobal.Fontname[%i])
|
||||
%font = %i - 1;
|
||||
}
|
||||
|
||||
PJFontList.sort(true);
|
||||
|
||||
// PJFontList.sort();
|
||||
PJFontList.setSelected( %font );
|
||||
PJFontGlobal.font = PJFontGlobal.FontName[%font + 1];
|
||||
|
||||
PJFontSizeList.clear();
|
||||
%fontname = PJFontGlobal.Fontname[%font + 1];
|
||||
%temp = PJFontGlobal.FontTotal[%fontname];
|
||||
for(%i1 = 1; %i1 <= %temp; %i1++) {
|
||||
PJFontSizeList.add( PJFontGlobal.FontSize[%fontname @ %i1], %i1 - 1 );
|
||||
if(PJFontGlobal.size $= PJFontGlobal.FontSize[%fontname @ %i1])
|
||||
%size = %i1 - 1;
|
||||
}
|
||||
|
||||
PJFontSizeList.setSelected( %size );
|
||||
PJFontGlobal.size = PJFontGlobal.FontSize[%fontname @ %size + 1];
|
||||
|
||||
PJUpdateFontDisplay();
|
||||
}
|
||||
|
||||
function PJFontDlg::onWake(%this){
|
||||
|
||||
|
||||
}
|
||||
|
||||
function PJFontDlg::onSleep(%this){
|
||||
|
||||
if(PJFontGlobal.type){
|
||||
eval(PJFontGlobal.fontvariable @ " = PJFontGlobal.font;");
|
||||
eval(PJFontGlobal.sizevariable @ " = PJFontGlobal.size;");
|
||||
}
|
||||
}
|
||||
|
||||
function PJFontList::onSelect( %this, %id, %text ) {
|
||||
|
||||
PJFontGlobal.font = %text;
|
||||
|
||||
PJFontSizeList.clear();
|
||||
%fontname = PJFontGlobal.Fontname[%id + 1];
|
||||
%temp = PJFontGlobal.FontTotal[%fontname];
|
||||
for(%i1 = 1; %i1 <= %temp; %i1++) {
|
||||
PJFontSizeList.add( PJFontGlobal.FontSize[%fontname @ %i1], %i1 - 1 );
|
||||
}
|
||||
|
||||
PJFontSizeList.setSelected( 0 );
|
||||
PJFontGlobal.size = PJFontGlobal.FontSize[%fontname @ "1"];
|
||||
PJUpdateFontDisplay();
|
||||
}
|
||||
|
||||
function PJFontSizeList::onSelect( %this, %id, %text ) {
|
||||
|
||||
PJFontGlobal.size = %text;
|
||||
PJUpdateFontDisplay();
|
||||
}
|
||||
|
||||
function PJfontonSleep() {
|
||||
|
||||
//PJPopDialog(PJFontDlg, 2, 4, 7, 0, 0, 0, 1, PJSoundEffects.PJFontDlg1, PJSoundEffects.PJFontDlg2, 0, $PJPref::GeneralAnimationSpeed, 1);
|
||||
canvas.popDialog(PJFontDlg);
|
||||
PJFontDlg.getObject(0).setVisible(0);
|
||||
|
||||
PJFontDlg.schedule(2000, 0, delete);
|
||||
}
|
||||
|
||||
function PJUpdateFontDisplay() {
|
||||
|
||||
PJFontDisplay.setValue("<just:center><font:" @ PJFontGlobal.font @ ":" @ PJFontGlobal.size @ "><color:ccdf30>1234 AaBbCcDdEe");
|
||||
|
||||
}
|
||||
|
||||
function PJMakeFontDlg() {
|
||||
|
||||
new GuiControlProfile ("GuiFontProfile"){
|
||||
fontType = "Univers Bold";
|
||||
fontSize = 18;
|
||||
fontColor = "169 215 250";
|
||||
};
|
||||
|
||||
//--- OBJECT WRITE BEGIN ---
|
||||
new GuiControl(PJFontDlg) {
|
||||
profile = "DlgBackProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "0 0";
|
||||
extent = "640 480";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
|
||||
new ShellPaneCtrl() {
|
||||
profile = "ShellDlgPaneProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "center";
|
||||
position = "134 64";
|
||||
extent = "372 240";
|
||||
minExtent = "48 92";
|
||||
visible = "0";
|
||||
helpTag = "0";
|
||||
text = "Set Font Selection";
|
||||
noTitleBar = "0";
|
||||
|
||||
new ShellBitmapButton(PJFontCANCEL) {
|
||||
profile = "ShellButtonProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "57 175";
|
||||
extent = "128 38";
|
||||
minExtent = "32 38";
|
||||
visible = "1";
|
||||
command = "$PJSelectedFont = \"\"; $PJSelectedFontSize = \"\"; PJfontonSleep();";
|
||||
helpTag = "0";
|
||||
text = "Cancel";
|
||||
simpleStyle = "0";
|
||||
};
|
||||
|
||||
new ShellPopupMenu(PJFontList) {
|
||||
profile = "ShellPopupProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "50 50";
|
||||
extent = "205 36";
|
||||
minExtent = "49 36";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
text = "Font Type";
|
||||
maxLength = "255";
|
||||
maxPopupHeight = "200";
|
||||
buttonBitmap = "gui/shll_pulldown";
|
||||
rolloverBarBitmap = "gui/shll_pulldownbar_rol";
|
||||
selectedBarBitmap = "gui/shll_pulldownbar_act";
|
||||
noButtonStyle = "0";
|
||||
};
|
||||
|
||||
new ShellPopupMenu(PJFontSizeList) {
|
||||
profile = "ShellPopupProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "265 50";
|
||||
extent = "65 36";
|
||||
minExtent = "49 36";
|
||||
visible = "1";
|
||||
hideCursor = "0";
|
||||
bypassHideCursor = "0";
|
||||
helpTag = "0";
|
||||
text = "Font Size";
|
||||
maxLength = "255";
|
||||
maxPopupHeight = "200";
|
||||
buttonBitmap = "gui/shll_pulldown";
|
||||
rolloverBarBitmap = "gui/shll_pulldownbar_rol";
|
||||
selectedBarBitmap = "gui/shll_pulldownbar_act";
|
||||
noButtonStyle = "0";
|
||||
};
|
||||
|
||||
new ShellFieldCtrl() {
|
||||
profile = "ShellFieldProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "top";
|
||||
position = "0 90";
|
||||
extent = "300 85";
|
||||
minExtent = "16 18";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
|
||||
new GuiMLTextCtrl(PJFontDisplay) {
|
||||
profile = "ShellTextCenterProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "center";
|
||||
position = "4 4";
|
||||
extent = "298 83";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
maxLength = "255";
|
||||
};
|
||||
};
|
||||
|
||||
new ShellBitmapButton(PJFontOK) {
|
||||
profile = "ShellButtonProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
position = "194 175";
|
||||
extent = "128 38";
|
||||
minExtent = "32 38";
|
||||
visible = "1";
|
||||
command = "PJfontonSleep();";
|
||||
helpTag = "0";
|
||||
text = "Select";
|
||||
simpleStyle = "0";
|
||||
};
|
||||
new GuiMLTextCtrl(PJFontText) {
|
||||
profile = "GuiFontProfile";
|
||||
horizSizing = "center";
|
||||
vertSizing = "top";
|
||||
position = "179 35";
|
||||
extent = "250 22";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
};
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
}
|
||||
|
||||
|
||||
$PJSelectedFont1 = "univers condensed";
|
||||
$PJSelectedFontSize1 = "16";
|
||||
|
||||
150
docs/base/@vl2/z_scripts/support.vl2/support/bind_manager.cs
Normal file
150
docs/base/@vl2/z_scripts/support.vl2/support/bind_manager.cs
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
// #autoload
|
||||
// #name = Bind Manager
|
||||
// #version = 1.1.1
|
||||
// #date = September 27, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Management script for adding new keybinds for Tribes 2 scripts.
|
||||
// #credit = This script contains code originally written by Wegbert (FixRemap.cs)
|
||||
// #status = Release
|
||||
// #include = support/callback.cs
|
||||
// #include = support/map.cs 1.0.7
|
||||
|
||||
// This support function allows user scripts to register new keybinds.
|
||||
// Usage:
|
||||
// To add a bind to the moveMap:
|
||||
// BindManager.addBind( %description, %functionName);
|
||||
// To add a bind to the obeserverMap:
|
||||
// BindManager.addObsBind( %description, %functionName);
|
||||
|
||||
// %description is the friendly name that will appear in the options dialog's control bind list.
|
||||
// %functionName is the name of the function to call.
|
||||
// These map directly to the $RemapName[] and $RemapCmd[] arrays, respectively
|
||||
|
||||
if (!isObject(bindManager)) {
|
||||
|
||||
new ScriptObject(bindManager) {
|
||||
class = "bindManager";
|
||||
obsBinds = Container::newVectorMap();
|
||||
mainBinds = Container::newVectorMap();
|
||||
vehicleBinds = Container::newVector();
|
||||
};
|
||||
}
|
||||
|
||||
function bindManager::addBind(%this, %description, %func, %vehicleCopy) {
|
||||
|
||||
%new = %this.mainBinds.add(%func,%description);
|
||||
|
||||
if (%vehicleCopy && %new) {
|
||||
%this.vehicleBinds.pushBack(%func);
|
||||
}
|
||||
}
|
||||
|
||||
function bindManager::addObsBind(%this, %description, %func) {
|
||||
|
||||
%this.obsBinds.add(%func,%description);
|
||||
}
|
||||
|
||||
function rebindBrokenMapping(%actionMap, %device, %action, %cmd, %newIndex) {
|
||||
|
||||
%actionMap.bind(%device, %action, %cmd);
|
||||
OP_RemapList.setRowById(%newIndex, buildFullMapString(%newIndex ));
|
||||
}
|
||||
|
||||
package BindMgrPkg {
|
||||
|
||||
function OptionsDlg::onWake(%this) {
|
||||
|
||||
if (isObject(bindManager)) {
|
||||
|
||||
%count = bindManager.mainBinds.size();
|
||||
|
||||
for (%i = 0; %i < %count; %i++) {
|
||||
%func = bindManager.mainBinds.keys.valueAt(0);
|
||||
%desc = bindManager.mainBinds.value(%func);
|
||||
$RemapName[$RemapCount] = %desc;
|
||||
$RemapCmd[$RemapCount] = %func;
|
||||
$RemapCount++;
|
||||
bindManager.mainBinds.remove(%func);
|
||||
}
|
||||
|
||||
%count = bindManager.obsBinds.size();
|
||||
|
||||
for (%i = 0; %i < %count; %i++) {
|
||||
%func = bindManager.obsBinds.keys.valueAt(0);
|
||||
%desc = bindManager.obsBinds.value(%func);
|
||||
$ObsRemapName[$ObsRemapCount] = %desc;
|
||||
$ObsRemapCmd[$ObsRemapCount] = %func;
|
||||
$ObsRemapCount++;
|
||||
bindManager.obsBinds.remove(%func);
|
||||
}
|
||||
}
|
||||
parent::onWake(%this);
|
||||
}
|
||||
|
||||
function clientCmdSetPilotVehicleKeys() {
|
||||
|
||||
parent::clientCmdSetPilotVehicleKeys();
|
||||
|
||||
%vec = bindManager.vehicleBinds;
|
||||
%size = %vec.size();
|
||||
|
||||
for (%x=0; %x < %size; %x++) passengerKeys.copyBind(moveMap,%vec.valueAt(%x));
|
||||
}
|
||||
|
||||
function clientCmdSetPassengerVehicleKeys() {
|
||||
|
||||
parent::clientCmdSetPassengerVehicleKeys();
|
||||
|
||||
%vec = bindManager.vehicleBinds;
|
||||
%size = %vec.size();
|
||||
|
||||
for (%x=0; %x < %size; %x++) {
|
||||
echo(%vec.valueAt(%x));
|
||||
passengerKeys.copyBind(moveMap,%vec.valueAt(%x));
|
||||
}
|
||||
}
|
||||
|
||||
function RemapInputCtrl::onInputEvent(%this, %device, %action) {
|
||||
|
||||
Parent::onInputEvent( %this, %device, %action );
|
||||
|
||||
if (isPackage(FixRemapLoad)) return;
|
||||
|
||||
warn("Remap active");
|
||||
if (%this.mode !$= "consoleKey") {
|
||||
|
||||
switch$ (OP_ControlsPane.group) {
|
||||
|
||||
case "Observer":
|
||||
%actionMap = observerMap;
|
||||
%cmd = $ObsRemapCmd[%this.index];
|
||||
default:
|
||||
%actionMap = moveMap;
|
||||
%cmd = $RemapCmd[%this.index];
|
||||
}
|
||||
|
||||
%prevMap = %actionMap.getCommand( %device, %action );
|
||||
if (%prevMap !$= %cmd && %prevMap !$= "") {
|
||||
|
||||
%mapName = getMapDisplayName( %device, %action );
|
||||
if (%mapName $= "escape") return;
|
||||
|
||||
%prevMapIndex = findRemapCmdIndex( %prevMap );
|
||||
if (%prevMapIndex == -1) {
|
||||
|
||||
if (MessageBoxOKDlg.isAwake()) Canvas.popDialog(MessageBoxOKDlg);
|
||||
|
||||
MessageBoxYesNo( "FIXREMAP WARNING",
|
||||
"\"" @ %mapName @ "\" is bound to the function \"" @ %prevMap @ "\"! The function may exist in a user script. See FixRemap.txt in your T2 autoexec dir for more details. Do you still want to undo this mapping?",
|
||||
"rebindBrokenMapping(" @ %actionMap @ ", " @ %device @ ", \"" @ %action @ "\", \"" @ %cmd @ "\", " @ %this.index @ ");", "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
activatePackage(BindMgrPkg);
|
||||
477
docs/base/@vl2/z_scripts/support.vl2/support/callback.cs
Normal file
477
docs/base/@vl2/z_scripts/support.vl2/support/callback.cs
Normal file
|
|
@ -0,0 +1,477 @@
|
|||
// #name = Callback Handler
|
||||
// #version = 1.2.0
|
||||
// #date = June 1, 2001
|
||||
// #category = Support
|
||||
// #author = Lorne Laliberte
|
||||
// #warrior = Writer
|
||||
// #email = writer@t2scripts.com
|
||||
// #email = t2beta@cdnwriter.com
|
||||
// #web = http://www.t2scripts.com
|
||||
// #web = http://www.cdnwriter.com
|
||||
// #description = This callback class provides a sophisticated event handler for scripts
|
||||
// #status = release
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Usage notes and examples:
|
||||
//
|
||||
// Assuming you use the default callback object, you can call the functions
|
||||
// like so:
|
||||
//
|
||||
// callback.preserveOrder(foo, true);
|
||||
//
|
||||
// -> sets the trigger named "foo" to preserveOrder mode
|
||||
//
|
||||
// %order_mode = callback.preserveOrder(foo);
|
||||
//
|
||||
// -> get the current preserveOrder mode of "foo"
|
||||
//
|
||||
// callback.add(foo, bar);
|
||||
//
|
||||
// -> attaches function bar() to a trigger named "foo"
|
||||
//
|
||||
// callback.add(foo, "echo(\"hello world\");");
|
||||
//
|
||||
// -> would echo hello world whenever foo is triggered
|
||||
//
|
||||
// callback.delete(foo, bar);
|
||||
//
|
||||
// -> detaches the bar() function from a trigger named "foo"
|
||||
//
|
||||
// If you detach a function from a trigger with multiple functions attached,
|
||||
// the order of the functions that remain will only be preserved if
|
||||
// preserveOrder mode is enabled for that trigger.
|
||||
//
|
||||
// Let's say we have functions A, B, C, D and E attached to trigger FOO.
|
||||
//
|
||||
// When we do callback.delete(FOO, B) with preserveOrder mode disabled
|
||||
// (which is the default for all triggers), the last function in the list
|
||||
// replaces the function we detach, so the list would become:
|
||||
//
|
||||
// A, E, C, D
|
||||
//
|
||||
// If preserveOrder mode is enabled for FOO, the functions are all "shifted"
|
||||
// to the left to overwrite the detached function, and the list would become:
|
||||
//
|
||||
// A, C, D, E
|
||||
//
|
||||
// This preserves the order (duh :) but is slower, so it's usually best not to
|
||||
// enable preserveOrder mode unless you have to.
|
||||
//
|
||||
// my_cb.delete();
|
||||
//
|
||||
// -> deletes a callback object named my_cb -- calling this destroys
|
||||
// all the callbacks in that object permanently and irrevocably.
|
||||
//
|
||||
// Incidentally, if you ever need a unique callback object (not sure why but
|
||||
// if you think of something let me know :), you can use:
|
||||
//
|
||||
// %object_id = new ScriptObject(my_cb) { class=callback; };
|
||||
//
|
||||
// -> sets up a new callback object named "my_cb" and stores its ID in a
|
||||
// variable named %object_id -- you can then access all the member
|
||||
// functions using either my_cb or %object_id. So, my_cb.add()
|
||||
// and %object_id.add() both operate on the same "my_cb" object
|
||||
//
|
||||
// callback.trigger(foo, 500, Jeff, 23);
|
||||
//
|
||||
// -> fires the trigger named "foo" and passes (500, Jeff, 23) as
|
||||
// arguments to all the functiona that are attached to it
|
||||
//
|
||||
// callback.triggerUntil(5, foo, "%1 $= mute;", %bar); ********
|
||||
//
|
||||
// -> fires the trigger named "foo" and starts calling each of the
|
||||
// attached functions, passing the contents of the local variable %bar
|
||||
// to each function, stopping as soon as one of the functions returns
|
||||
// the string "mute"
|
||||
//
|
||||
// %awonderfulthingabouttriggers = callback.count(foo);
|
||||
//
|
||||
// -> gets the number of functions currently attached to the trigger
|
||||
// named "foo"
|
||||
//
|
||||
// %atriggersawonderfulthing = callback.count();
|
||||
//
|
||||
// -> gets the number of triggers that are active (have functions atached
|
||||
// to them)
|
||||
//
|
||||
// %test = callback.returned(bar, "%1 <= 5;");
|
||||
//
|
||||
// -> returns true if any of the functions attached to bar returned a
|
||||
// value that resolves to an integer equal to or less than 5 the last
|
||||
// time the trigger named "bar" was fired
|
||||
//
|
||||
// %winniethepooh = callback.matchingReturns(foo, false);
|
||||
//
|
||||
// -> get the number of functions attached to the trigger named "foo" that
|
||||
// returned a value that resolves to false
|
||||
//
|
||||
// note: callback.returned and callback.matchingreturns both require a pattern as
|
||||
// their second argument, but if the second argument doesn't contain a "%1"
|
||||
// anywhere in it, the functions will peform a string test by default.
|
||||
|
||||
|
||||
if(!isObject(callback))
|
||||
{
|
||||
// Set up our callback class to contain this script's properties and members
|
||||
// and invoke a default instance of the class as the named object "callback"
|
||||
new ScriptObject(callback)
|
||||
{
|
||||
class = callback;
|
||||
// no default properties yet, will invoke them as needed at run-time
|
||||
};
|
||||
}
|
||||
|
||||
// use this to enable or disable preserveCallbackOrder mode
|
||||
function callback::preserveOrder(%this, %trigger_name, %enable)
|
||||
{
|
||||
if(%enable || %enable $= "")
|
||||
%this.ordered[%trigger_name] = true;
|
||||
else
|
||||
%this.ordered[%trigger_name] = false;
|
||||
}
|
||||
|
||||
// use this to determine whether a trigger is currently in preserveCallbackOrder mode
|
||||
function callback::isOrdered(%this, %trigger_name)
|
||||
{
|
||||
return %this.ordered[%trigger_name] == true; // cast return to a bool :)
|
||||
}
|
||||
|
||||
|
||||
// attach a function to a named trigger
|
||||
//
|
||||
// returns true if function gets attached (i.e. was not attached already)
|
||||
// returns false if function was already attached or could not be
|
||||
function callback::add(%this, %trigger_name, %function)
|
||||
{
|
||||
if(%function $= "" || %trigger_name $= "")
|
||||
return false;
|
||||
|
||||
// Only add this function only if it isn't already attached to this event
|
||||
if(%this.index[%trigger_name, %function])
|
||||
return false;
|
||||
|
||||
// (I return false in case someone wants to test whether a function by that
|
||||
// name was already attached to this trigger.)
|
||||
|
||||
// If this is a new trigger name, add it to the master trigger list
|
||||
if(!%this.count[%trigger_name])
|
||||
%this.triggerList[%this.triggerCount++] = %trigger_name;
|
||||
|
||||
// Increment count of functions attached to this trigger.
|
||||
// Since we'll be adding an element to the end of the %this.func array, we
|
||||
// can use the same value for the index into our %this.func array.
|
||||
// Storing that index in our %this.index array makes it easier to
|
||||
// quickly determine which element to access in the %this.func array
|
||||
// when we only know the event and the function. (Otherwise we'd have to
|
||||
// iterate through the %this.func array looking for a match.)
|
||||
%index = %this.index[%trigger_name, %function] = %this.count[%trigger_name]++;
|
||||
|
||||
// Add this function to the trigger
|
||||
%this.func[%trigger_name, %index] = %function;
|
||||
|
||||
// Set flag if this function is a statement (which determines whether we'll pass any args to it).
|
||||
// This is a speed optimization to avoid having to call strStr() each time a function is triggered.
|
||||
%this.isStatement[%trigger_name, %index] = (strStr(%function, ";") != -1);
|
||||
|
||||
// return true to indicate function did not previously exist and has been attached
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// deletes any callback object, including the default one named "callback"
|
||||
// in case I ever need to get past the "callback" deletion protection in ::delete()
|
||||
function callback::destruct(%this)
|
||||
{
|
||||
Parent::delete(%this);
|
||||
}
|
||||
|
||||
|
||||
// detach a function from a named trigger -- note that the order of the attached functions
|
||||
// is not preserved unless preserveCallbackOrder mode has been enabled for this trigger
|
||||
//
|
||||
// returns true if callback function was detached
|
||||
// returns false if function wasn't attached to begin with
|
||||
function callback::delete(%this, %trigger_name, %function)
|
||||
{
|
||||
// if this function is called with no arguments, we call ScriptObject's
|
||||
// delete() member to delete the callback object itself
|
||||
if(%function $= "" && %trigger_name $= "" && %this.getName() !$= "callback")
|
||||
return Parent::delete(%this);
|
||||
|
||||
if(%function $= "" || %trigger_name $= "")
|
||||
return false;
|
||||
|
||||
// return false if function wasn't attached or there are no functions to detach
|
||||
if(!%this.count[%trigger_name] || !%this.index[%trigger_name, %function])
|
||||
return false;
|
||||
|
||||
// Get the index of the function to detach
|
||||
%index = %this.index[%trigger_name, %function];
|
||||
|
||||
// If the function we're detaching was called by the trigger we're detaching
|
||||
// it from -- in other words, if a triggered function is detaching itself --
|
||||
// the function we're replacing it with wouldn't get called until the next
|
||||
// time the callbacks are triggered.
|
||||
|
||||
// %this.indexBeingTriggered holds the index of the function currently being
|
||||
// triggered...if it matches the index of the function we're detaching, we
|
||||
// set %this.indexBeingTriggered to 0 to tell the trigger routine to process
|
||||
// the replacement function after we move it into this index.
|
||||
|
||||
if(%index == %this.indexBeingTriggered)
|
||||
%this.indexBeingTriggered = 0;
|
||||
|
||||
// check for optional preserveOrder mode
|
||||
if(%this.ordered[%trigger_name])
|
||||
{
|
||||
// preseveOrder mode is on, so we'll shrink the array by shifting it
|
||||
// a linked list would be faster but I don't think it's worth the storage hit
|
||||
for(%i = %index; %i <= %this.count[%trigger_name]; %i++)
|
||||
{
|
||||
// get next function in the array and move it into this spot
|
||||
// (or clear this spot if it was the last one)
|
||||
%replacement =
|
||||
%this.func[%trigger_name, %i] = %this.func[%trigger_name, %i + 1];
|
||||
|
||||
// do the same for the isStatement flag
|
||||
%this.isStatement[%trigger_name, %i] = %this.isStatement[%trigger_name, %i + 1];
|
||||
|
||||
// if we reached the end, there is no replacement function
|
||||
// (so we don't need to adjust its index value :)
|
||||
if(%replacement $= "")
|
||||
break;
|
||||
|
||||
// otherwise, adjust the replacement function's index value to reflect its new position in array
|
||||
%this.index[%trigger_name, %replacement] = %i;
|
||||
}
|
||||
// adjust callback count (number of functions attached to this trigger)
|
||||
%this.count[%trigger_name]--;
|
||||
|
||||
// return true to say "function was attached, we detached it" :)
|
||||
return true;
|
||||
}
|
||||
|
||||
// okay, optional preserveCallbackOrder mode is disabled for this trigger
|
||||
|
||||
// get index of last element in the array
|
||||
%last = %this.count[%trigger.name];
|
||||
|
||||
// move the function at the end of the array into the detached function's spot
|
||||
%replacement = %this.func[%trigger_name, %last];
|
||||
%this.func[%trigger_name, %index] = %replacement;
|
||||
|
||||
// do the same for the isStatement flag
|
||||
%this.isStatement[%trigger_name, %index] = %this.isStatement[%trigger_name, %last];
|
||||
|
||||
// update the index of the function we just moved
|
||||
%this.index[%trigger_name, %replacement] = %index;
|
||||
|
||||
// clear out the last array element
|
||||
%this.func[%trigger_name, %last] = "";
|
||||
%this.isStatement[%trigger_name, %last] = "";
|
||||
|
||||
// clear flag to show the function we detached isn't attached any more
|
||||
%this.index[%trigger_name, %function] = "";
|
||||
|
||||
// adjust callback count (number of functions attached to this trigger)
|
||||
%this.count[%trigger_name]--;
|
||||
|
||||
// return true to say "function was attached, we detached it" :)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// call all the functions attached to a named trigger and pass from 0 to 9 parameters to each function
|
||||
//
|
||||
// Note: use <object>.trigger(<trigger_name>, <parameter1>, <parameter2>, <etc>)
|
||||
// wherever you want a trigger that functions can be attached to
|
||||
//
|
||||
// returns the trigger name to allow for statements like returnedFromTrigger(callback.trigger(foo), true);
|
||||
function callback::trigger(%this, %trigger_name, %p0, %p1, %p2, %p3, %p4, %p5, %p6, %p7, %p8, %p9, %p10, %p11, %p12, %p13, %p14)
|
||||
{
|
||||
if(!%this.count[%trigger_name])
|
||||
{
|
||||
%this.returnCount[%trigger_name] = 0; // = "" instead?
|
||||
return %trigger_name;
|
||||
}
|
||||
|
||||
// call every attached function in turn
|
||||
%i = 1;
|
||||
while(%i <= %this.count[%trigger_name])
|
||||
{
|
||||
%this.indexBeingTriggered = %i;
|
||||
%function = %this.func[%trigger_name, %i];
|
||||
|
||||
%this.returnValue[%trigger_name, %i] = "";
|
||||
%this.returnValue[%trigger_name, %function] = "";
|
||||
|
||||
if(%this.isStatement[%trigger_name, %i])
|
||||
{
|
||||
// this function is a statement so don't pass any parameters
|
||||
eval("%r=" @ %function); // eval only returns values properly when the statement is a function call
|
||||
%this.returnValue[%trigger_name, %i] = %r;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this function is not a statement so pass the parameters to it
|
||||
%this.returnValue[%trigger_name, %i] = eval(%function @ "(" @ "\"" @ expandEscape(%p0) @ "\""
|
||||
@ ",\"" @ expandEscape(%p1) @ "\""
|
||||
@ ",\"" @ expandEscape(%p2) @ "\""
|
||||
@ ",\"" @ expandEscape(%p3) @ "\""
|
||||
@ ",\"" @ expandEscape(%p4) @ "\""
|
||||
@ ",\"" @ expandEscape(%p5) @ "\""
|
||||
@ ",\"" @ expandEscape(%p6) @ "\""
|
||||
@ ",\"" @ expandEscape(%p7) @ "\""
|
||||
@ ",\"" @ expandEscape(%p8) @ "\""
|
||||
@ ",\"" @ expandEscape(%p9) @ "\""
|
||||
@ ",\"" @ expandEscape(%p10) @ "\""
|
||||
@ ",\"" @ expandEscape(%p11) @ "\""
|
||||
@ ",\"" @ expandEscape(%p12) @ "\""
|
||||
@ ",\"" @ expandEscape(%p13) @ "\""
|
||||
@ ",\"" @ expandEscape(%p14) @ "\""
|
||||
@ ");");
|
||||
}
|
||||
|
||||
// Reprocess this index (%i) if callback function detached itself (and a new function replaced it at this index)
|
||||
if(%this.indexBeingTriggered)
|
||||
%i++;
|
||||
}
|
||||
|
||||
// set number of functions that returned...in this case, it's always all of them
|
||||
%this.returnCount[%trigger_name] = %this.count[%trigger_name];
|
||||
|
||||
return %trigger_name;
|
||||
}
|
||||
|
||||
|
||||
// call all the functions attached to a named trigger, passing from 0 to 9
|
||||
// parameters to each function, and stopping at the first function where
|
||||
// the return value is evaluated (using %test and %value) into a true result.
|
||||
//
|
||||
// %test is a string "pattern" where %1 stands for the value returned by the function
|
||||
// %test can be any statement that eval() can handle, but it must resolve to either true or false
|
||||
//
|
||||
// Example: "%1 $= true;" would test for a string match between the value returned from the
|
||||
// triggered function and the boolean value True.
|
||||
//
|
||||
// Note: if %test doesn't contain a %1 in it, the function will assume you're passing a
|
||||
// string that you want tested against the return values, so "mute" or "%1 $= mute;" are the same.
|
||||
//
|
||||
// returns true if an attached function returned %value, otherwise returns false
|
||||
function callback::triggerUntil(%this, %test, %trigger_name, %p0, %p1, %p2, %p3, %p4, %p5, %p6, %p7, %p8, %p9, %p10, %p11, %p12, %p13, %p14)
|
||||
{
|
||||
if(!%this.count[%trigger_name])
|
||||
{
|
||||
%this.returnCount[%trigger_name] = 0;
|
||||
return %trigger_name;
|
||||
}
|
||||
|
||||
// call every attached function in turn
|
||||
%i = 1;
|
||||
while(%i <= %this.count[%trigger_name])
|
||||
{
|
||||
%this.indexBeingTriggered = %i;
|
||||
%function = %this.func[%trigger_name, %i];
|
||||
|
||||
if(%this.isStatement[%trigger_name, %i])
|
||||
{
|
||||
// This function is a statement so don't pass any parameters
|
||||
eval("%retval=" @ %function); // eval only returns values properly when the statement is a function call
|
||||
%this.returnValue[%trigger_name, %i] = %retval;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This function is not a statement so pass the parameters to it
|
||||
%retval =
|
||||
%this.returnValue[%trigger_name, %i] = eval(%function @ "(" @ "\"" @ expandEscape(%p0) @ "\""
|
||||
@ ",\"" @ expandEscape(%p1) @ "\""
|
||||
@ ",\"" @ expandEscape(%p2) @ "\""
|
||||
@ ",\"" @ expandEscape(%p3) @ "\""
|
||||
@ ",\"" @ expandEscape(%p4) @ "\""
|
||||
@ ",\"" @ expandEscape(%p5) @ "\""
|
||||
@ ",\"" @ expandEscape(%p6) @ "\""
|
||||
@ ",\"" @ expandEscape(%p7) @ "\""
|
||||
@ ",\"" @ expandEscape(%p8) @ "\""
|
||||
@ ",\"" @ expandEscape(%p9) @ "\""
|
||||
@ ",\"" @ expandEscape(%p10) @ "\""
|
||||
@ ",\"" @ expandEscape(%p11) @ "\""
|
||||
@ ",\"" @ expandEscape(%p12) @ "\""
|
||||
@ ",\"" @ expandEscape(%p13) @ "\""
|
||||
@ ",\"" @ expandEscape(%p14) @ "\""
|
||||
@ ");");
|
||||
}
|
||||
|
||||
// Stop at first function whose return value causes a true result from evaluating %test
|
||||
|
||||
if( strstr(%test, ";") == -1 ) // allow for optional default $= test
|
||||
%t = (%test $= %retval);
|
||||
else // string is a statement, so replace any placeholders and evaluate it
|
||||
eval("%t=" @ strreplace(%test, "%1", "\"" @ expandEscape(%retval) @ "\""));
|
||||
|
||||
if( %t )
|
||||
{
|
||||
// set number of functions that returned
|
||||
%this.returnCount[%trigger_name] = %i;
|
||||
return %i;
|
||||
}
|
||||
|
||||
// Reprocess this index (%i) if callback function detached itself (and a new function replaced it at this index)
|
||||
if(%this.indexBeingTriggered)
|
||||
%i++;
|
||||
}
|
||||
|
||||
// set number of functions that returned -- should be all of them if we've made it this far
|
||||
%this.returnCount[%trigger_name] = %this.count[%trigger_name];
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// return the number of functions attached to a trigger,
|
||||
// or the number of triggers that exist if no trigger name is specified
|
||||
function callback::count(%this, %trigger_name)
|
||||
{
|
||||
if(%trigger_name $= "")
|
||||
return %this.triggerCount;
|
||||
else
|
||||
return %this.count[%trigger_name];
|
||||
}
|
||||
|
||||
|
||||
// check to see if a specific return value was among the values returned
|
||||
// by the functions attached to a trigger
|
||||
//
|
||||
// %test is a statement that will evaluate to either true or false, where %1 is used
|
||||
// to represent the value returned by each function. Example: "%1 > 5;"
|
||||
function callback::returned(%this, %trigger_name, %test)
|
||||
{
|
||||
if( strstr(%test,"%1") == -1 )
|
||||
%test = %test @ " $= %1;";
|
||||
|
||||
for( %i = 1; %i <= %this.returnCount[%trigger_name]; %i++)
|
||||
{
|
||||
eval("%t=" @ strreplace(%test, "%1", "\"" @ expandEscape(%this.returnValue[%trigger_name, %i]) @ "\""));
|
||||
if( %t )
|
||||
return true; // match found
|
||||
}
|
||||
return false; // match not found
|
||||
}
|
||||
|
||||
|
||||
// count how many functions attached to an event returned a specific return value
|
||||
//
|
||||
// %test is a statement that will evaluate to either true or false, where %1 is used
|
||||
// to represent the value returned by each function. Example: "%1 > 5;"
|
||||
function callback::countMatchingReturns(%this, %test)
|
||||
{
|
||||
if( strstr(%test,"%1") == -1 )
|
||||
%test = %test @ " $= %1;";
|
||||
|
||||
%found = 0;
|
||||
for( %i = 1; %i <= %this.returnCount[%trigger_name]; %i++)
|
||||
{
|
||||
eval("%t=" @ strreplace(%test, "%1", "\"" @ expandEscape(%this.returnValue[%trigger_name, %i]) @ "\""));
|
||||
if( %t )
|
||||
%found++; // another match found
|
||||
}
|
||||
return %found; // return number of matching return values
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
// #name = Data Struct - Circular Queue
|
||||
// #version = 1.0.0
|
||||
// #date = January 2, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Handy buffer data structure.
|
||||
// #category = Support
|
||||
// #status = Release
|
||||
|
||||
// It breaks ::delete() to have the class have a constructor function
|
||||
// in it's own namespace. So I put it in another one...
|
||||
|
||||
function Container::newCircularQueue(%size) {
|
||||
|
||||
if (%size == 0) return "";
|
||||
|
||||
%x = new ScriptObject() {
|
||||
class = CircularQueue;
|
||||
front = 0;
|
||||
back = 0;
|
||||
count = 0;
|
||||
size = %size;
|
||||
};
|
||||
return %x;
|
||||
}
|
||||
|
||||
function CircularQueue::clear(%this) {
|
||||
|
||||
for (%i = 0; %i < %this.size; %i++) {
|
||||
%this.array[%i] = "";
|
||||
}
|
||||
%this.front = %this.back = %this.count = 0;
|
||||
}
|
||||
|
||||
function CircularQueue::pushBack(%this, %value) {
|
||||
|
||||
%overflow = false;
|
||||
|
||||
%tmp = %this.back;
|
||||
|
||||
%this.back++;
|
||||
%this.back %= %this.size;
|
||||
|
||||
if (%tmp == %this.front && (%this.count != 0)) {
|
||||
%this.front++;
|
||||
%this.front %= %this.size;
|
||||
%overflow = true;
|
||||
%this.lastOverFlow = %this.array[%tmp];
|
||||
}
|
||||
else %this.count++;
|
||||
|
||||
%this.array[%tmp] = %value;
|
||||
|
||||
return %overflow;
|
||||
}
|
||||
|
||||
function CircularQueue::popFront(%this) {
|
||||
|
||||
%retVal = "";
|
||||
|
||||
if (%this.count == 0) return "";
|
||||
else {
|
||||
%retVal = %this.array[%this.front];
|
||||
%this.front++;
|
||||
%this.front %= %this.size;
|
||||
%this.count--;
|
||||
}
|
||||
|
||||
return %retVal;
|
||||
}
|
||||
|
||||
function CircularQueue::size(%this) {
|
||||
|
||||
return %this.size;
|
||||
}
|
||||
|
||||
function CircularQueue::count(%this) {
|
||||
|
||||
return %this.count;
|
||||
}
|
||||
|
||||
function CircularQueue::isFull(%this) {
|
||||
|
||||
return (%this.count == %this.size);
|
||||
}
|
||||
|
||||
function CirularQueue::getLastOverFlow(%this) {
|
||||
|
||||
return %this.lastOverFlow;
|
||||
}
|
||||
303
docs/base/@vl2/z_scripts/support.vl2/support/date_support.cs
Normal file
303
docs/base/@vl2/z_scripts/support.vl2/support/date_support.cs
Normal file
|
|
@ -0,0 +1,303 @@
|
|||
// #name = Date Support
|
||||
// #version = 0.7.0
|
||||
// #date = April 2, 2002
|
||||
// #author = Andrew "Yogi" Weiland, Daryl "Stinkfist" Chance
|
||||
// #warrior = Yogi, Stinkfist
|
||||
// #email = yogi@tribalwar.com, stinkfist@teamwarfare.com
|
||||
// #web = http://yogi.inquisition.nu
|
||||
// #category = Support
|
||||
// #description = A date API that requires no outside support
|
||||
// #status = almost there!
|
||||
|
||||
// This script takes the results from getFileModify time
|
||||
// and getFileCreateTime and makes them real usable.
|
||||
// These functions return a 64 bit integer in the format: HIGH:LOW,
|
||||
// which is the number of 100-nanosecond intervals since Jan 1, 1601.
|
||||
// Thanks to Tim Gift for answering my question on it
|
||||
// Sound crazy? Well, it's the standard NT time stamp format.
|
||||
// to get this in a usable format, multiply by:
|
||||
// (2^32/10^7)/8640 or 0.004971
|
||||
// This will give you the number of days since Jan 1, 1601
|
||||
|
||||
// Usage:
|
||||
// date(formatString, [epoch time]);
|
||||
// Returns a string formatted according to characters in the format string.
|
||||
// The format string recognizes the following characters:
|
||||
// d - Day of the month (w/ leading zero)
|
||||
// D - 3 letter day of the week (Fri)
|
||||
// F - Textual month, long (January)
|
||||
// j - Day of the month (no leading zero)
|
||||
// l - Day of the week, long (Friday)
|
||||
// L - 1 (one) if leap year, 0 (zero) if not
|
||||
// m - Month number (w/ leading zero)
|
||||
// M - Textual month, short (Jan)
|
||||
// n - Month number (no leading zero)
|
||||
// t - Number of days in given month
|
||||
// Y - Year (4 digits 2002)
|
||||
// y - Year (2 digits 02)
|
||||
// z - Day of the year
|
||||
// U - Days since epoch (in this case the epoch is Jan 1, 1601.
|
||||
// Note: this script will only generate dates AFTER Jan 1, 2001)
|
||||
//
|
||||
// For example:
|
||||
// date("l m j, Y");
|
||||
// Will generate: Saturday Apr 6, 2002
|
||||
// date("m/d/y");
|
||||
// Will generate: 06/06/02
|
||||
//
|
||||
// PHP enthusiasts will notice this is the exact same format that PHP's date()
|
||||
// function uses.
|
||||
//
|
||||
// The optional parameter [epoch time] is the number of days since Jan 1, 1601
|
||||
// If you pass the function this parameter it will evaluate the format string
|
||||
// based on the date that the epoch time passed corresponds to. Note that even
|
||||
// though you can pass any date to this function, it will only give you dates
|
||||
// AFTER Jan 1, 2001 (which is the first of the year that T2 was released).
|
||||
//
|
||||
// addDays(month, day, year, days)
|
||||
// Adds "days" number of days to the date (month, day, year) passed to the function.
|
||||
// It returns a date in epoch format that can be passed to date() for formatting.
|
||||
//
|
||||
// subtractDays(month, day, year, days)
|
||||
// Subtracts "days" number of days from the date (month, day, year) passed to the
|
||||
// function. Note that "days" is a positive number.
|
||||
// daysBetween(m1, d1, y1, m2, d2, y2)
|
||||
// Returns the number of days between 2 dates.
|
||||
//
|
||||
// convertEpoch(month, day, year)
|
||||
// Converts the date passed to the function to the epoch time
|
||||
//
|
||||
// The rest of the functions are dubbed "Use at your own risk"
|
||||
// They are unsupported and are mainly support functions for the script
|
||||
// but, are good functions none the less.
|
||||
//
|
||||
|
||||
|
||||
|
||||
$T2EPOCH = 146096; // Jan, 1 2001 - first month of year that T2 was released...simplifies code.
|
||||
|
||||
|
||||
// performs like PHP's date() function
|
||||
function date(%format, %dateint) {
|
||||
|
||||
if (%format $="") %format ="mdY";
|
||||
|
||||
%dateint = (%dateint $= "") ? getCurrentDate() : %dateint;
|
||||
if (%dateint < $T2EPOCH) %dateint=getCurrentDate(); // Idiot proofing, no dates before Jan 1, 2001
|
||||
|
||||
%days = %dateint - $T2EPOCH;
|
||||
|
||||
%ly = isLeapYear(2001 + mfloor(%days / 365)) ? 366 : 365;
|
||||
for (%year = 2001; %days > %ly; %days -= %ly) {
|
||||
%year++;
|
||||
%ly = isLeapYear(%year) ? 366 : 365;
|
||||
}
|
||||
|
||||
for (%months = 1; %months <= 12; %months++ ) {
|
||||
// are the leftover days greater then the current month? sub them
|
||||
// choose appropriate days in month too
|
||||
if (%days > daysPerMonth(%months, %year))
|
||||
%days -= daysPerMonth(%months, %year);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return formatDate(%months, %days, %year, %format);
|
||||
}
|
||||
|
||||
|
||||
// Add %days number of days to m d y
|
||||
// Returns time in epoch time
|
||||
function addDays(%month, %day, %year, %days) {
|
||||
%d = convertEpoch(%month, %day, %year);
|
||||
%d += %days;
|
||||
return %d;
|
||||
}
|
||||
|
||||
// Subtract %days number of days (passed as a POSITIVE number) from m d y
|
||||
// Returns time in epoch time
|
||||
function subtractDays(%month, %day, %year, %days) {
|
||||
return addDays(%month, %day, %year, -%days);
|
||||
}
|
||||
|
||||
// # of days between dates
|
||||
function daysBetween(%m1, %d1, %y1, %m2, %d2, %y2) {
|
||||
return abs(convertEpoch(%m2, %d2, %y2) - convertEpoch(%m1, %d1, %y1));
|
||||
}
|
||||
|
||||
// Converts a m d y to the epoch time
|
||||
function convertEpoch(%month, %day, %year) {
|
||||
%r = 0;
|
||||
for (%x=2001; %x < %year; %x++) %r += (isLeapYear(%x)) ? 366 : 365;
|
||||
for (%y=1; %y < %month; %y++) %r += daysPerMonth(%y, %year);
|
||||
%r += %day + $T2EPOCH;
|
||||
return %r;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// "Private" functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// return # of days since Jan 1, 1601 to today
|
||||
function getCurrentDate() {
|
||||
%filename = "omgihopethisnameisnttaken.unf";
|
||||
%outfile = new FileObject();
|
||||
%outfile.openForWrite(%filename);
|
||||
%outfile.writeLine("Colosus is my bitch");
|
||||
%outfile.close();
|
||||
%time = getFileCreateTime(%filename);
|
||||
//echo(%time);
|
||||
%date = convertTime(%time);
|
||||
%outfile.delete();
|
||||
deleteFile(%filename);
|
||||
|
||||
return %date;
|
||||
}
|
||||
|
||||
// Convert a high:low to days
|
||||
function convertTime(%time) {
|
||||
%high = getSubStr(%time, 0, strpos(%time, ":"));
|
||||
%date = mfloor(0.004971 * %high);
|
||||
return %date;
|
||||
}
|
||||
|
||||
|
||||
function formatDate(%month, %day, %year, %format) {
|
||||
%q="";
|
||||
for (%x=0; %x < strlen(%format); %x++) {
|
||||
%f = getSubStr(%format, %x, 1);
|
||||
switch$(%f) {
|
||||
case "D" :
|
||||
if (strcmp("d", %f)==0) %q = %q @ ((%day < 10) ? "0" @ %day : %day);
|
||||
else %q = %q @ getDayOfWeek(%month, %day, %year, 0);
|
||||
case "F" :
|
||||
%q = %q @ getMonth(%month, 1);
|
||||
case "j" :
|
||||
%q = %q @ %day;
|
||||
case "L" :
|
||||
if (strcmp("l", %f)==0) %q = %q @ getDayOfWeek(%month, %day, %year, 1);
|
||||
else %q = %q @ isLeapYear(%year);
|
||||
case "M" :
|
||||
if (strcmp("m", %f) == 0) %q = %q @ ((%month < 10) ? "0" @ %month : %month);
|
||||
else %q = %q @ getMonth(%month, 0);
|
||||
case "n" :
|
||||
%q = %q @ %month;
|
||||
case "t" :
|
||||
%q = %q @ daysPerMonth(%month, %year);
|
||||
case "Y" :
|
||||
if (strcmp("y", %f) == 0) %q = %q @ getSubStr(%year, 2, 2);
|
||||
else %q = %q @ %year;
|
||||
case "z" :
|
||||
%d = 0;
|
||||
for (%y=0; %y < %month; %y++) %d += daysPerMonth(%y, %year);
|
||||
%q = %q @ (%d + %day);
|
||||
case "U" :
|
||||
%q = %q @ convertEpoch(%month, %day, %year);
|
||||
default:
|
||||
%q = %q @ %f;
|
||||
}
|
||||
}
|
||||
return %q;
|
||||
}
|
||||
|
||||
|
||||
// Find out how many days there are this month
|
||||
// another one by stinky, BOOYA
|
||||
function daysPerMonth(%month, %year) {
|
||||
%months[0] = "0 31 28 31 30 31 30 31 31 30 31 30 31";
|
||||
%months[1] = "0 31 29 31 30 31 30 31 31 30 31 30 31";
|
||||
return getWord(%months[isLeapYear(%year)], %month);
|
||||
}
|
||||
|
||||
// one liner by stinky, BOOYA
|
||||
function isLeapYear(%year) {
|
||||
return (%year % 4 == 0) && ((%year % 100 != 0) || (%year % 400 == 0));
|
||||
}
|
||||
|
||||
// Get the month name. Long==1 for long name
|
||||
function getMonth(%month, %long) {
|
||||
%long = (%long $= "" || !%long) ? 0 : 1; // stick with this
|
||||
%months[0] = "0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec";
|
||||
%months[1] = "0 January February March April May June July August September October November December";
|
||||
return getWord(%months[%long], %month);
|
||||
}
|
||||
|
||||
// Based on the doomsday algorithm
|
||||
function getDayOfWeek(%month, %day, %year, %long) {
|
||||
%long = (%long $= "" || !%long) ? 0 : 1; // stick with this
|
||||
%days[0] = "Mon Tue Wed Thu Fri Sat Sun";
|
||||
%days[1] = "Monday Tuesday Wednesday Thursday Friday Saturday Sunday";
|
||||
%q = getDoomsDay(%month, %day, %year);
|
||||
return getWord(%days[%long], %q);
|
||||
}
|
||||
|
||||
// omg, doomsday!!!
|
||||
function getDoomsDay(%month, %day, %year) {
|
||||
%leapYear = isLeapYear(%year);
|
||||
%oddMonth = %month % 2;
|
||||
%doomsdayDayOfWeek = dayOfWeek(%year);
|
||||
if(%oddMonth==1) {
|
||||
if(%month==1) {
|
||||
if(isLeapYear(%year)) %doomsdayOfMonth = 32;
|
||||
else %doomsdayOfMonth = 31;
|
||||
}
|
||||
else if(%month==5) %doomsdayOfMonth = 9;
|
||||
else if(%month==7) %doomsdayOfMonth = 11;
|
||||
else if(%month==9) %doomsdayOfMonth = 5;
|
||||
else %doomsdayOfMonth = 7;
|
||||
}
|
||||
|
||||
else {
|
||||
if(%month == 2) {
|
||||
if(isLeapYear(%year)) %doomsdayOfMonth = 29;
|
||||
else %doomsdayOfMonth = 28;
|
||||
}
|
||||
else %doomsdayOfMonth = %month;
|
||||
}
|
||||
|
||||
if(%day < %doomsdayOfMonth) {
|
||||
%daysFromDoomsday = %doomsdayOfMonth - %day;
|
||||
%offsetFromDoomsdayDayOfWeek = %daysFromDoomsday % 7;
|
||||
if(%offsetFromDoomsdayDayOfWeek > %doomsdayDayOfWeek) return (%doomsdayDayOfWeek - %offsetFromDoomsdayDayOfWeek)+7;
|
||||
else return %doomsdayDayOfWeek - %offsetFromDoomsdayDayOfWeek;
|
||||
}
|
||||
else {
|
||||
%daysFromDoomsday = %day - %doomsdayOfMonth;
|
||||
%offsetFromDoomsdayDayOfWeek = %daysFromDoomsday % 7;
|
||||
return (%doomsdayDayOfWeek + %offsetFromDoomsdayDayOfWeek) % 7;
|
||||
}
|
||||
}
|
||||
|
||||
// omg more doomsday
|
||||
function dayOfWeek(%year) {
|
||||
%day = 0;
|
||||
%yearCounter = 1898;
|
||||
|
||||
if(%year < 1898) {
|
||||
while(%yearCounter!=%year) {
|
||||
if(isLeapYear(%yearCounter))
|
||||
%day += 2;
|
||||
else
|
||||
%day++;
|
||||
%yearCounter--;
|
||||
}
|
||||
return (7-(%day % 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
while(%yearCounter!=%year)
|
||||
{
|
||||
%yearCounter++;
|
||||
if(isLeapYear(%yearCounter))
|
||||
%day += 2;
|
||||
else
|
||||
%day++;
|
||||
|
||||
}
|
||||
return %day % 7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
485
docs/base/@vl2/z_scripts/support.vl2/support/docking_tools.cs
Normal file
485
docs/base/@vl2/z_scripts/support.vl2/support/docking_tools.cs
Normal file
|
|
@ -0,0 +1,485 @@
|
|||
// #name = Hud Docking Support
|
||||
// #version = 0.0.2
|
||||
// #date = October 6, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Additional events and features for docking HUDs to one another.
|
||||
// #status = Beta
|
||||
// #include = support/map.cs
|
||||
// #include = support/vector.cs
|
||||
// #include = support/callback.cs
|
||||
|
||||
// Key functions:
|
||||
|
||||
// DockManager.dock(%docker, %dside, %target, %cside, offset);
|
||||
// * Docks the %dside side of the docking control (%docker) to the %tside side of the
|
||||
// target control (%target). Valid values for %dside and %tside are "L", "R", "T" and "B"
|
||||
// (for Left, Right, Top and Bottom).
|
||||
|
||||
// DockManager.undock(%docker, %axis);
|
||||
// * demoves a docking entry for control %docker in the specified axis ("H" or "V" for
|
||||
// Horizontal or Vertical).
|
||||
|
||||
// DockManager.isValidDockTarget(%docker, %target);
|
||||
// * returns true if the control %target is a valid dock target for %docker.
|
||||
|
||||
// DockManager.updateDockedControls(%target, %axis);
|
||||
// * refreshes the positions of all controls docket to control %target in the specified axis.
|
||||
|
||||
// Callbacks
|
||||
|
||||
// EventHorizMove(%name, ...)
|
||||
// * The HUD with name %name had an effective change in it's horizontal postion.
|
||||
// This could be caused by a call to resize(), setPosition, or setExtent. It is also
|
||||
// called for setVisible, to allow HUDs to collapse.
|
||||
// * This is never called for nameless GUI controls.
|
||||
// * While some invocations provide other parameters besides, they are subject to
|
||||
// change and should not be used in client script at this time.
|
||||
|
||||
// EventVertMove(%name, ...)
|
||||
// * exactly the same as EventHorizMove except it is triggered for vertical moves.
|
||||
|
||||
// ==========================================================================================
|
||||
|
||||
|
||||
if (!isObject(DockManager)) {
|
||||
new ScriptObject("DockManager") {
|
||||
class = "DockManager";
|
||||
};
|
||||
}
|
||||
|
||||
DockManager.dockMap["H"] = Container::newVectorMap();
|
||||
DockManager.dockMap["V"] = Container::newVectorMap();
|
||||
|
||||
DockManager.dockTargets["H"] = Container::newVectorMap();
|
||||
DockManager.dockTargets["V"] = Container::newVectorMap();
|
||||
|
||||
//=============================================================================
|
||||
// New GUI control methods
|
||||
//=============================================================================
|
||||
|
||||
function DockManager::isValidDockTarget(%this, %control, %target) {
|
||||
|
||||
if (%control $= %target) {
|
||||
//error("Error: Cannot dock an object to itself");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (%control = %target.dockTo[%axis]; %control !$= ""; %control = %control.dockTo[%axis]) {
|
||||
//echo(%control);
|
||||
if (!stricmp(%control,%control)) {
|
||||
//error("Error: Attempt to create circular docking chain by docking" SPC %control SPC "to" SPC %target);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DockManager::dock(%this, %control, %ctrlSide, %target, %tgtSide, %offset) {
|
||||
|
||||
if (!%this.isValidDockTarget(%target)) return;
|
||||
|
||||
%ctrlSide = strupr(%ctrlSide);
|
||||
if (strpos("TBLR", %ctrlSide) == -1) {
|
||||
error("Illegal control docking side specifier \"" @ %ctrlSide @ "\"");
|
||||
return;
|
||||
}
|
||||
|
||||
%tgtSide = strupr(%tgtSide);
|
||||
if (strpos("TBLR", %tgtSide) == -1) {
|
||||
error("Illegal control docking side specifier \"" @ %ctrlSide @ "\"");
|
||||
return;
|
||||
}
|
||||
|
||||
if (((%ctrlSide $= "L" || %ctrlSide $= "R") && (%tgtSide !$= "L" && %tgtSide !$= "R")) ||
|
||||
((%ctrlSide $= "T" || %ctrlSide $= "B") && (%tgtSide !$= "T" && %tgtSide !$= "B"))) {
|
||||
|
||||
error("Cannot dock" SPC %ctrlSide SPC "side of" SPC %control SPC "to" SPC %tgtSide SPC "of" SPC %target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (%ctrlSide $= "L" || %ctrlSide $= "R") %axis = "H";
|
||||
else %axis = "V";
|
||||
|
||||
// Can only dock to one parent - remove control from old parent.
|
||||
%info = %this.getDockInfo(%control,%axis);
|
||||
if (isObject(%info)) {
|
||||
%oldTarget = %info.control;
|
||||
if (%oldTarget !$= "") {
|
||||
%vec = %this.dockTargets[%axis].value(%oldTarget);
|
||||
if (isObject(%vec)) {
|
||||
%idx = %vec.findFirstIndex(%control);
|
||||
if (%idx >= 0) {
|
||||
%tmp = %vec.valueAt(%idx);
|
||||
if (isObject(%tmp)) %tmp.delete();
|
||||
%vec.removeAt(%idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
%info.delete();
|
||||
}
|
||||
|
||||
//warn("@" SPC %target);
|
||||
%this.setDockInfo(%control, %ctrlSide, %target, %tgtSide, %axis, %offset);
|
||||
|
||||
//warn("*" SPC %tgtSide SPC %ctrlSide);
|
||||
|
||||
%vec = %this.dockTargets[%axis].value(%target);
|
||||
if (!isObject(%vec)) {
|
||||
%vec = Container::newVector();
|
||||
%this.dockTargets[%axis].add(%target,%vec);
|
||||
//Callback.add(EventHorizMove, "GuiControl::onMove", %target, %axis);
|
||||
}
|
||||
%vec.pushBack(%control);
|
||||
}
|
||||
|
||||
function DockManager::getDockInfo(%this, %control, %axis) {
|
||||
|
||||
if ((%axis !$= "H") && (%axis !$= "V")) {
|
||||
error("DockManager::getDockInfo - > invalid axis specification \"" @ %axis @ "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
return %this.dockMap[%axis].value(%control);
|
||||
}
|
||||
|
||||
function DockManager::setDockInfo(%this, %control, %ctrlSide, %target, %tgtSide, %axis, %offset) {
|
||||
|
||||
if ((%axis !$= "H") && (%axis !$= "V")) {
|
||||
error("DockManager::setDockInfo - > invalid axis specification \"" @ %axis @ "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
%info = %this.getDockInfo(%control,%axis);
|
||||
if (!isObject(%info)) {
|
||||
%info = new ScriptObject(%axis @ "Dock_" @ %control @ "_2_" @ %target) {
|
||||
|
||||
control = %control;
|
||||
ctrlSide = %ctrlSide;
|
||||
target = %target;
|
||||
tgtSide = %tgtSide;
|
||||
offset = (%offset ? %offset : 0);
|
||||
};
|
||||
}
|
||||
else {
|
||||
%info.control = %control;
|
||||
%info.ctrlSide = %ctrlSide;
|
||||
%info.target = %target;
|
||||
%info.tgtSide = %tgtSide;
|
||||
%info.offset = (%offset ? %offset : 0);
|
||||
}
|
||||
|
||||
%this.dockMap[%axis].add(%control, %info);
|
||||
}
|
||||
|
||||
function DockManager::unDock(%this, %control, %axis) {
|
||||
|
||||
if ((%axis !$= "H") && (%axis !$= "V")) {
|
||||
error("DockManager::unDock - > invalid axis specification \"" @ %axis @ "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
%info = %this.getDockInfo(%control,%axis);
|
||||
if (isObject(%info)) {
|
||||
%this.dockMap[%axis].remove(%control);
|
||||
%vec = %this.dockTargets[%axis].value(%info.target);
|
||||
if (isObject(%vec)) {
|
||||
%vec.removeAt(%vec.findFirstIndex(%control));
|
||||
}
|
||||
%info.delete();
|
||||
}
|
||||
}
|
||||
|
||||
function DockManager::updateDockedControls(%this, %control, %axis) {
|
||||
|
||||
// Get the list of data structures describing controls docked to this parent
|
||||
// on the changed axis
|
||||
%grp = %this.dockTargets[%axis];
|
||||
if (!isObject(%grp)) return;
|
||||
%vec = %grp.value(%control);
|
||||
if (!isObject(%vec)) return;
|
||||
|
||||
// Pick out each docked control and move it appropriately
|
||||
for (%i = 0; %i < %vec.size(); %i++) {
|
||||
%child = %vec.valueAt(%i);
|
||||
if (isObject(%child)) { // Don't bother going on if the HUD doesn't exist
|
||||
%info = %this.getDockInfo(%child,%axis);
|
||||
if (isObject(%info)) {
|
||||
%this.align(%child,%info.ctrlSide,%control,%info.tgtSide,%info.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DockManager::onHorizMove(%this, %parent, %L, %R) {
|
||||
|
||||
%this.updateDockedControls(%parent, "H");
|
||||
}
|
||||
|
||||
function DockManager::onVertMove(%this, %parent, %T, %B) {
|
||||
|
||||
%this.updateDockedControls(%parent, "V");
|
||||
}
|
||||
|
||||
// I don't use the setPosition, etc. calls here to avoid looping
|
||||
function DockManager::align(%this, %child, %childSide, %parent, %parentSide, %offset) {
|
||||
|
||||
// If opposite sides are docked together, this will shove the docked hud to the OTHER side
|
||||
// of the hud it is docked to. Otherwise, it keeps it aligned.
|
||||
|
||||
if (%childSide $= "T") {
|
||||
if (%parentSide $= "T")
|
||||
%child.position = %child.getLeft() SPC (%parent.getTop() + %offset);
|
||||
else //%parentSide $= "B"
|
||||
%child.position = %child.getLeft() SPC ((%parent.visible ? %parent.getBottom() : %parent.getTop()) + %offset);
|
||||
}
|
||||
else if (%childSide $= "B") {
|
||||
if (%parentSide $= "T")
|
||||
%child.position = %child.getLeft() SPC ((%parent.visible ? %parent.getTop() : %parent.getBottom()) - %child.getHeight() + %offset);
|
||||
else //%parentSide $= "B"
|
||||
%child.position = %child.getLeft() SPC (%parent.getBottom() - %child.getHeight() + %offset);
|
||||
}
|
||||
else if (%childSide $= "L") {
|
||||
if (%parentSide $= "L")
|
||||
%child.position = (%parent.getLeft() + %offset) SPC %child.getTop();
|
||||
else //%parentSide $= "R"
|
||||
%child.position = ((%parent.visible ? %parent.getRight() : %parent.getLeft()) + %offset) SPC %child.getTop();
|
||||
}
|
||||
else { //%childSide $= "R"
|
||||
if (%parentSide $= "L")
|
||||
%child.position = ((%parent.visible ? %parent.getLeft() : %parent.getRight()) - %child.getWidth() + %offset) SPC %child.getTop();
|
||||
else //"R"
|
||||
%child.position = (%parent.getRight() - %child.getWidth() + %offset) SPC %child.getTop();
|
||||
}
|
||||
}
|
||||
|
||||
function GuiControl::getLeft(%this) {
|
||||
|
||||
return getWord(%this.position,0);
|
||||
}
|
||||
|
||||
function GuiControl::getRight(%this) {
|
||||
|
||||
return getWord(%this.position,0) + getWord(%this.extent,0);
|
||||
}
|
||||
|
||||
function GuiControl::getTop(%this) {
|
||||
|
||||
return getWord(%this.position,1);
|
||||
}
|
||||
|
||||
function GuiControl::getBottom(%this) {
|
||||
|
||||
return getWord(%this.position,1) + getWord(%this.extent,1);
|
||||
}
|
||||
|
||||
function GuiControl::getWidth(%this) {
|
||||
|
||||
return getWord(%this.extent,0);
|
||||
}
|
||||
|
||||
function GuiControl::getHeight(%this) {
|
||||
|
||||
return getWord(%this.extent,1);
|
||||
}
|
||||
|
||||
function GuiControl::setPosition2(%this, %position) {
|
||||
|
||||
%this.setPosition(getWord(%position,0),getWord(%position,1));
|
||||
}
|
||||
|
||||
function GuiControl::setExtent2(%this, %extent) {
|
||||
|
||||
%this.setExtent(getWord(%extent,0),getWord(%extent,1));
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::getLeft(%this) {
|
||||
|
||||
return GuiControl::getLeft(%this);
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::getRight(%this) {
|
||||
|
||||
return GuiControl::getRight(%this);
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::getTop(%this) {
|
||||
|
||||
return GuiControl::getTop(%this);
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::getBottom(%this) {
|
||||
|
||||
return GuiControl::getBottom(%this);
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::getWidth(%this) {
|
||||
|
||||
return GuiControl::getWidth(%this);
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::getHeight(%this) {
|
||||
|
||||
return GuiControl::getHeight(%this);
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::setPosition2(%this, %position) {
|
||||
|
||||
%this.setPosition(getWord(%position,0),getWord(%position,1));
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::setExtent2(%this, %extent) {
|
||||
|
||||
%this.setExtent(getWord(%extent,0),getWord(%extent,1));
|
||||
}
|
||||
|
||||
package DockManagerPkg {
|
||||
|
||||
function GuiControl::setVisible(%this, %val) {
|
||||
|
||||
%oldVal = %this.visible;
|
||||
parent::setVisible(%this,%val);
|
||||
if (%val != %oldVal) {
|
||||
%name = %this.getName();
|
||||
//if (%name !$= "") Callback.trigger("Event_"@%name@"_Vis",%flag);
|
||||
if (%name !$= "") {
|
||||
Callback.trigger("EventHorizMove",%name);
|
||||
Callback.trigger("EventVertMove", %name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GuiControl::resize(%this, %x, %y, %w, %h) {
|
||||
|
||||
// This causes a UE. Apparently calling other methods from an overloaded
|
||||
// method before calling the parent is a Bad Thing. Perhaps it affects %this.
|
||||
//if (%this.getWidth() != %w) %xChanged = true;
|
||||
//if (%this.getHeight() != %h) %yChanged = true;
|
||||
|
||||
%ex = %this.extent;
|
||||
parent::resize(%this, %x, %y, %w, %h);
|
||||
%name = %this.getName();
|
||||
if (%name !$= "") {
|
||||
%xChanged = (%w != getWord(%ex,0));
|
||||
%yChanged = (%h != getWord(%ex,1));
|
||||
|
||||
if (%xChanged) Callback.trigger("EventHorizMove",%name,%x, %x + %w);
|
||||
if (%yChanged) Callback.trigger("EventVertMove", %name,%y, %y + %h);
|
||||
}
|
||||
}
|
||||
|
||||
function GuiControl::setPosition(%this, %x, %y) {
|
||||
|
||||
%ps = %this.position;
|
||||
parent::setPosition(%this, %x, %y);
|
||||
%name = %this.getName();
|
||||
if (%name !$= "") {
|
||||
%xChanged = (%x != getWord(%ps,0));
|
||||
%yChanged = (%y != getWord(%ps,1));
|
||||
|
||||
if (%xChanged) Callback.trigger("EventHorizMove",%name, %x, %this.getRight());
|
||||
if (%yChanged) Callback.trigger("EventVertMove", %name, %y, %this.getBottom());
|
||||
}
|
||||
}
|
||||
|
||||
function GuiControl::setExtent(%this, %w, %h) {
|
||||
|
||||
%ex = %this.extent;
|
||||
parent::setExtent(%this, %w, %h);
|
||||
|
||||
%name = %this.getName();
|
||||
if (%name !$= "") {
|
||||
%xChanged = (%w != getWord(%ex,0));
|
||||
%yChanged = (%h != getWord(%ex,1));
|
||||
|
||||
if (%xChanged) {
|
||||
%x = %this.getLeft();
|
||||
Callback.trigger("EventHorizMove",%name, %x, %x + %w);
|
||||
}
|
||||
if (%yChanged) {
|
||||
%y = %this.getTop();
|
||||
Callback.trigger("EventVertMove",%name, %y, %y + %h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::setVisible(%this, %val) {
|
||||
|
||||
%oldVal = %this.visible;
|
||||
parent::setVisible(%this,%val);
|
||||
if (%val != %oldVal) {
|
||||
%name = %this.getName();
|
||||
//if (%name !$= "") Callback.trigger("Event_"@%name@"_Vis",%flag);
|
||||
if (%name !$= "") {
|
||||
Callback.trigger("EventHorizMove",%name);
|
||||
Callback.trigger("EventVertMove", %name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::resize(%this, %x, %y, %w, %h) {
|
||||
|
||||
%ex = %this.extent;
|
||||
parent::resize(%this, %x, %y, %w, %h);
|
||||
%name = %this.getName();
|
||||
if (%name !$= "") {
|
||||
%xChanged = (%w != getWord(%ex,0));
|
||||
%yChanged = (%h != getWord(%ex,1));
|
||||
|
||||
if (%xChanged) Callback.trigger("EventHorizMove",%name,%x, %x + %w);
|
||||
if (%yChanged) Callback.trigger("EventVertMove", %name,%y, %y + %h);
|
||||
}
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::setPosition(%this, %x, %y) {
|
||||
|
||||
%ps = %this.position;
|
||||
%this.position = (%x SPC %y);
|
||||
%name = %this.getName();
|
||||
if (%name !$= "") {
|
||||
%xChanged = (%x != getWord(%ps,0));
|
||||
%yChanged = (%y != getWord(%ps,1));
|
||||
|
||||
if (%xChanged) Callback.trigger("EventHorizMove",%name, %x, %this.getRight());
|
||||
if (%yChanged) Callback.trigger("EventVertMove", %name, %y, %this.getBottom());
|
||||
}
|
||||
}
|
||||
|
||||
function GuiNoMouseCtrl::setExtent(%this, %w, %h) {
|
||||
|
||||
%ex = %this.extent;
|
||||
%this.extent = (%w SPC %h);
|
||||
|
||||
%name = %this.getName();
|
||||
if (%name !$= "") {
|
||||
%xChanged = (%w != getWord(%ex,0));
|
||||
%yChanged = (%h != getWord(%ex,1));
|
||||
|
||||
if (%xChanged) {
|
||||
%x = %this.getLeft();
|
||||
Callback.trigger("EventHorizMove",%name, %x, %x + %w);
|
||||
}
|
||||
if (%yChanged) {
|
||||
%y = %this.getTop();
|
||||
Callback.trigger("EventVertMove",%name, %y, %y + %h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function playGui::add(%this, %ctrl) {
|
||||
|
||||
parent::add(%this,%ctrl);
|
||||
Callback.trigger("EventHorizMove",%name, %ctrl.getLeft(), %ctrl.getRight());
|
||||
Callback.trigger("EventVertMove", %name, %ctrl.getTop(), %ctrl.getBottom());
|
||||
}
|
||||
};
|
||||
|
||||
activatePackage(DockManagerPkg);
|
||||
|
||||
Callback.add(EventHorizMove,"DockManager.onHorizMove");
|
||||
Callback.add(EventVertMove,"DockManager.onVertMove");
|
||||
208
docs/base/@vl2/z_scripts/support.vl2/support/events.cs
Normal file
208
docs/base/@vl2/z_scripts/support.vl2/support/events.cs
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
// #name = Utility Events
|
||||
// #version = 1.0.4
|
||||
// #date = September 27, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Callbacks for commonly used, miscellaneous events.
|
||||
// #status = Release
|
||||
// #include = support/callback.cs
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Included callbacks:
|
||||
|
||||
// onPlayGuiWake : called when playGui opens
|
||||
// onLoadingGuiWake : called when loadingGui opens
|
||||
// onGameGuiWake : called when gameGui (the join screen) opens
|
||||
// onChatGuiWake : called when the IRC gui opens
|
||||
// onDebriefGuiWake : called when map summary gui opens
|
||||
// onScriptBrowserGuiWake : called when the support script browser opens
|
||||
// onSetFoV(%fov) : player Field of View changed. Passes the FoV setting.
|
||||
// onToggleZoom(%val) : player toggled zoom on or off
|
||||
// : on or off value in %val (boolean).
|
||||
// onAmmoHudSetVisible(%val) : the ammo count display was toggled on or off.
|
||||
// : on or off value in %val (boolean).
|
||||
// onCmdDisplayHuds : server sent command for client to display HUDs.
|
||||
// onCmdToggleHuds(%val) : server sent commant showing/hiding play HUDs.
|
||||
// : on or off value in %val (boolean).
|
||||
// onCmdWeaponsHudBitmap : server send a weapon HUD bitmap name.
|
||||
// (%slot, %name, %bitmap)
|
||||
// onCmdSetWeaponsHudActive : server sent a command selecting a weapon in the weaponHUD.
|
||||
// onCmdSetInventoryHud : server sent an inventory HUD update
|
||||
// (%slot, %amount, %addItem)
|
||||
// onCmdVehicleMount : player got in a vehicle (see vehicle_callbacks for more
|
||||
// : detailed callbacks).
|
||||
// preLoadDemoSettings : called just before settings are loaded for a demo playback
|
||||
// postLoadDemoSettings : called just after settings are loaded for a demo playback
|
||||
// onQuit : game is about to exit. Can be muted.
|
||||
// onPreConnect : called just before a connection to a server is processed
|
||||
// onPreLocalConnect : called just before a connection to a listen server is processed
|
||||
// onDisconnectedCleanup : cleanup notice when leaving a server
|
||||
// onUse(%item) : player issued a "use()" command. Can be muted to stop the function.
|
||||
// onThrow(%item) : player issued a "throw()" command. Can be muted to stop the function.
|
||||
// onUseKit : player used a repair kit. Can be muted to stop the function.
|
||||
|
||||
package EventsPkg {
|
||||
|
||||
//GUI wake events
|
||||
function PlayGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
Callback.trigger("onPlayGuiWake");
|
||||
}
|
||||
|
||||
function LoadingGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
Callback.trigger("onLoadingGuiWake");
|
||||
}
|
||||
|
||||
function GameGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
Callback.trigger("onGameGuiWake");
|
||||
}
|
||||
|
||||
function ChatGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
Callback.trigger("onChatGuiWake");
|
||||
}
|
||||
|
||||
function DebriefGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
Callback.trigger("onDebriefGuiWake");
|
||||
}
|
||||
|
||||
function ScriptBrowserGui::onWake(%this) {
|
||||
|
||||
parent::onWake(%this);
|
||||
Callback.trigger("onScriptBrowserGuiWake");
|
||||
}
|
||||
|
||||
// FoV
|
||||
function setFOV(%fov) {
|
||||
|
||||
parent::setFOV(%fov);
|
||||
Callback.trigger("onSetFOV", %fov);
|
||||
}
|
||||
|
||||
function toggleZoom(%val) {
|
||||
|
||||
parent::toggleZoom(%val);
|
||||
Callback.trigger("onToggleZoom", %val);
|
||||
}
|
||||
|
||||
//PlayGui HUD updates
|
||||
function ammoHud::setVisible(%this, %val) {
|
||||
|
||||
parent::setVisible(%this, %val);
|
||||
Callback.trigger("onAmmoHudSetVisible", %val);
|
||||
}
|
||||
|
||||
function clientCmdDisplayHuds() {
|
||||
|
||||
parent::clientCmdDisplayHuds();
|
||||
Callback.trigger("onCmdDisplayHuds");
|
||||
}
|
||||
|
||||
function clientCmdTogglePlayHuds(%val) {
|
||||
|
||||
parent::clientCmdDisplayHuds();
|
||||
Callback.trigger("onCmdToggleHuds", %val);
|
||||
}
|
||||
|
||||
function clientCmdSetWeaponsHudBitmap(%slot, %name, %bitmap) {
|
||||
|
||||
parent::clientCmdSetWeaponsHudBitmap(%slot, %name, %bitmap);
|
||||
Callback.trigger("onCmdWeaponsHudBitmap", %slot, %name, %bitmap);
|
||||
}
|
||||
|
||||
function clientCmdSetWeaponsHudActive(%slot, %ret, %vis) {
|
||||
|
||||
parent::clientCmdSetWeaponsHudActive(%slot, %ret, %vis);
|
||||
Callback.trigger("onCmdSetWeaponsHudActive", %slot, %ret, %vis);
|
||||
}
|
||||
|
||||
function clientCmdSetInventoryHudItem(%slot, %amount, %addItem) {
|
||||
|
||||
parent::clientCmdSetInventoryHudItem(%slot, %amount, %addItem);
|
||||
Callback.trigger("onCmdSetInventoryHud", %slot, %amount, %addItem);
|
||||
}
|
||||
|
||||
//Simple vehicle mount
|
||||
function clientCmdVehicleMount() {
|
||||
|
||||
parent::clientCmdVehicleMount();
|
||||
Callback.trigger("onCmdVehicleMount");
|
||||
}
|
||||
|
||||
//Maintenance events
|
||||
function loadDemoSettings() {
|
||||
|
||||
Callback.trigger("preLoadDemoSettings");
|
||||
parent::loadDemoSettings();
|
||||
Callback.trigger("postLoadDemoSettings");
|
||||
}
|
||||
|
||||
function quit() {
|
||||
|
||||
Callback.trigger("onQuit");
|
||||
|
||||
if(!Callback.returned("onQuit", mute)) {
|
||||
parent::quit();
|
||||
}
|
||||
}
|
||||
|
||||
function connect(%address, %password, %playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch) {
|
||||
|
||||
Callback.trigger("onPreConnect");
|
||||
parent::connect(%address, %password, %playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch);
|
||||
}
|
||||
|
||||
function localConnect(%playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch) {
|
||||
|
||||
Callback.trigger("onPreLocalConnect");
|
||||
parent::localConnect(%playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch);
|
||||
}
|
||||
|
||||
function DisconnectedCleanup() {
|
||||
|
||||
parent::DisconnectedCleanup();
|
||||
Callback.trigger("onDisconnectedCleanup");
|
||||
}
|
||||
|
||||
// Actions
|
||||
function use(%item) {
|
||||
|
||||
Callback.trigger("onUse", %item);
|
||||
|
||||
if(!Callback.returned("onUse", mute)) {
|
||||
parent::use(%item);
|
||||
}
|
||||
}
|
||||
|
||||
function throw(%item) {
|
||||
|
||||
Callback.trigger("onThrow", %item);
|
||||
|
||||
if(!Callback.returned("onThrow", mute)) {
|
||||
parent::throw(%item);
|
||||
}
|
||||
}
|
||||
|
||||
function useRepairKit(%val) {
|
||||
|
||||
Callback.trigger("onUseKit");
|
||||
|
||||
if(!Callback.returned("onUseKit", mute)) {
|
||||
parent::useRepairKit(%val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
activatePackage(EventsPkg);
|
||||
520
docs/base/@vl2/z_scripts/support.vl2/support/file_tools.cs
Normal file
520
docs/base/@vl2/z_scripts/support.vl2/support/file_tools.cs
Normal file
|
|
@ -0,0 +1,520 @@
|
|||
// #name = File Tools
|
||||
// #version = 1.2.0
|
||||
// #date = May 19, 2001
|
||||
// #category = Support
|
||||
// #author = Lorne Laliberte
|
||||
// #warrior = Writer
|
||||
// #email = t2beta@cdnwriter.com
|
||||
// #web = http://www.t2scripts.com
|
||||
// #web = http://www.cdnwriter.com
|
||||
// #description = Adds new member functions to the FileObject class
|
||||
// #credit = Kaiten Commander for CopyTextFile() (Added by UberGuy 01/26/03)
|
||||
// #status = release
|
||||
// #include = support/string_tools.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// need to add some usage docs here :)
|
||||
|
||||
// get length of filename in bytes
|
||||
function FileObject::getLen(%this, %filename)
|
||||
{
|
||||
if(!%this.openForRead(%filename))
|
||||
return 0;
|
||||
|
||||
%length = 0;
|
||||
while(true)
|
||||
{
|
||||
if( $platform $= "linux" ) // thanks to ratorasniki for this test :)
|
||||
{
|
||||
%length += strlen( %line = %this.readline() );
|
||||
}
|
||||
else
|
||||
{
|
||||
%length += strlen( %line = %this.readline() ) + 2; // allow for CRLF on Windows
|
||||
}
|
||||
|
||||
if(%this.isEOF())
|
||||
break;
|
||||
}
|
||||
|
||||
return %length;
|
||||
}
|
||||
|
||||
// append a line (%text) to the end of %filename
|
||||
function FileObject::appendLine(%this, %filename, %text)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return false;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
%temp[%i] = %this.readLine();
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return false;
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
// append the line
|
||||
%this.writeLine(%text);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// insert line (%text) into %filename at %line_number
|
||||
function FileObject::insertLine(%this, %filename, %text, %line_number)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return false;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
%temp[%i] = %this.readLine();
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return false;
|
||||
|
||||
%lines = %i;
|
||||
|
||||
if(!%line_number)
|
||||
%line_number = 1;
|
||||
|
||||
// write the lines back into the file, up to %line_number
|
||||
for(%i = 1; %i < %line_number; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
// insert the text
|
||||
%this.writeLine(%text);
|
||||
|
||||
// leave %i the same so %text is inserted before %line_number
|
||||
for(%i = %i; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// insert line with %text in %filename at %line_number
|
||||
function FileObject::replaceLine(%this, %filename, %text, %line_number)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return false;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
%temp[%i] = %this.readLine();
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return false;
|
||||
|
||||
%lines = %i;
|
||||
|
||||
if(!%line_number)
|
||||
%line_number = 1;
|
||||
|
||||
// write the lines back into the file, up to %line_number
|
||||
for(%i = 1; %i < %line_number; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
// insert the text
|
||||
%this.writeLine(%text);
|
||||
|
||||
// increment %i so %text replaces %line_number
|
||||
for(%i++; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return line number of first occurence of %text in %filename,
|
||||
// optionally starting from %start_at and ending at %end_at
|
||||
function FileObject::findInFile(%this, %filename, %text, %start_at, %end_at)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return 0;
|
||||
|
||||
if(%end_at && (%end_at < %start_at))
|
||||
%end_at = %start_at;
|
||||
|
||||
// look for %text in %filename
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
{
|
||||
if(%start_at && (%i < %start_at))
|
||||
continue;
|
||||
|
||||
if( (strstr(%this.readLine(), %text) != -1) || (%end_at && (%i == %end_at)) )
|
||||
return %i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// replace every occurence of %search_text in %filename with %replace_text
|
||||
// optionally starting from %start_at and ending at %end_at
|
||||
// returns number of replacements made, or -1 on error
|
||||
function FileObject::replaceInFile(%this, %filename, %search_text, %replace_text, %start_at, %end_at)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return -1;
|
||||
|
||||
%replace_count = 0;
|
||||
|
||||
%len = strlen(%search_text);
|
||||
|
||||
if(%end_at && (%end_at < %start_at))
|
||||
%end_at = %start_at;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
{
|
||||
%temp[%i] = %this.readLine();
|
||||
|
||||
// starting from %start_at...and ending at %end_at...
|
||||
if((%i >= %start_at) && (%i <= %end_at))
|
||||
{
|
||||
// replace %search_text with %replace_text, if found
|
||||
if((%pos = strstr(%temp[%i], %search_text)) != -1)
|
||||
{
|
||||
%newstr = getSubStr(%temp[%i], 0, %pos) @ %replace_text @ getSubStr(%temp[%i], %pos + %len, 10000);
|
||||
%temp[%i] = %newstr;
|
||||
%replace_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return -1;
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the (modified) lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
return %replace_count;
|
||||
}
|
||||
|
||||
|
||||
// replace every line in %filename that has %search_text in it with %replace_text,
|
||||
// optionally starting from %start_at and ending at %end_at
|
||||
// returns number of replacements made, or -1 on error
|
||||
function FileObject::replaceLinesInFile(%this, %filename, %search_text, %replace_text, %start_at, %end_at)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return -1;
|
||||
|
||||
%replace_count = 0;
|
||||
|
||||
%len = strlen(%search_text);
|
||||
|
||||
if(%start_at $= "")
|
||||
%start_at = 1;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
{
|
||||
%temp[%i] = %this.readLine();
|
||||
|
||||
// starting from %start_at...and ending at %end_at...
|
||||
if((%i >= %start_at) && ((%end_at $= "") || (%i <= %end_at)))
|
||||
{
|
||||
// replace %search_text with %replace_text, if found
|
||||
if( (strstr(%temp[%i], %search_text) ) != -1)
|
||||
{
|
||||
%temp[%i] = %replace_text;
|
||||
%replace_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return -1;
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the (modified) lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
return %replace_count;
|
||||
}
|
||||
|
||||
// remove every line in %filename that has %search_text in it,
|
||||
// optionally starting from %start_at and ending at %end_at
|
||||
// returns number of replacements made, or -1 on error
|
||||
function FileObject::removeLinesFromFile(%this, %filename, %search_text, %start_at, %end_at)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return -1;
|
||||
|
||||
%remove_count = 0;
|
||||
|
||||
%len = strlen(%search_text);
|
||||
|
||||
if(%start_at $= "")
|
||||
%start_at = 1;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
{
|
||||
%temp[%i] = %this.readLine();
|
||||
}
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return -1;
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
{
|
||||
// starting from %start_at...and ending at %end_at...
|
||||
if((%i >= %start_at) && ((%end_at $= "") || (%i <= %end_at)))
|
||||
{
|
||||
// replace %search_text with %replace_text, if found
|
||||
if( ( strstr(%temp[%i], %search_text) ) != -1)
|
||||
{
|
||||
// remove the line
|
||||
%remove_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// write the line
|
||||
%this.writeLine(%temp[%i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return %remove_count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// get contents of %filename as a string,
|
||||
// optionally starting from %start_at and ending at %end_at
|
||||
function FileObject::getContents(%this, %filename, %start_at, %end_at)
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return "";
|
||||
|
||||
if(%start_at $= "")
|
||||
%start_at = 1;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
{
|
||||
|
||||
// starting from %start_at...
|
||||
if(%i >= %start_at)
|
||||
%string = %string @ %this.readLine() @ "\n";
|
||||
else
|
||||
%this.readline();
|
||||
|
||||
// ...and ending at %end_at
|
||||
if(%end_at && (%i >= %end_at))
|
||||
return %string;
|
||||
}
|
||||
|
||||
return %string;
|
||||
}
|
||||
|
||||
// append the contents of %text to %filename
|
||||
// returns true on success, false on failure
|
||||
function FileObject::append(%this, %filename, %text)
|
||||
{
|
||||
%i = 1; // init here in case file doesn't exist
|
||||
if(isFile(%filename))
|
||||
{
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%this.openForRead(%filename))
|
||||
return false;
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%this.isEOF(); %i++)
|
||||
%temp[%i] = %this.readLine();
|
||||
}
|
||||
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return false;
|
||||
|
||||
%str = %text;
|
||||
|
||||
// add the new content
|
||||
while( (%endline_pos = strstr(%str, "\n")) != -1 )
|
||||
{
|
||||
%temp[%i] = getSubStr(%str, 0, %endline_pos);
|
||||
%str = getSubStr(%str, %endline_pos + 1, 1000000);
|
||||
%i++;
|
||||
}
|
||||
|
||||
// add the last line
|
||||
if(%str !$= "")
|
||||
{
|
||||
%temp[%i] = %str;
|
||||
%i++;
|
||||
}
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// write the contents of %text to %filename
|
||||
// returns true on success, false on failure
|
||||
function FileObject::write(%this, %filename, %text)
|
||||
{
|
||||
// make sure we can write to the file
|
||||
if(!%this.openForWrite(%filename))
|
||||
return false;
|
||||
|
||||
%str = %text;
|
||||
|
||||
// set up the new content
|
||||
%i = 1;
|
||||
while( (%endline_pos = strstr(%str, "\n")) != -1 )
|
||||
{
|
||||
%temp[%i] = getSubStr(%str, 0, %endline_pos);
|
||||
%str = getSubStr(%str, %endline_pos + 1, 1000000);
|
||||
%i++;
|
||||
}
|
||||
|
||||
// add the last line
|
||||
if(%str !$= "")
|
||||
{
|
||||
%temp[%i] = %str;
|
||||
%i++;
|
||||
}
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
%this.writeLine(%temp[%i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// #name = CopyTextFile
|
||||
// #version = 1.0
|
||||
// #date = 21 January 2003
|
||||
// #status = Working
|
||||
// #author = @-Kaiten Commander
|
||||
// #warrior = Kaiten Commander
|
||||
// #email = kaiten@cb-tribes.co.uk
|
||||
// #web = http://www.kaiten.barrysworld.net
|
||||
|
||||
// Used ingame to copy files. I don't know why people would want to copy files..
|
||||
// Maybe can be used to backup prefs, cs files etc.
|
||||
// This is resticted to plain text files (cs, txt, etc).
|
||||
// This cannot be used to copy recordings, Screenshots,vl2 or dso files.
|
||||
//
|
||||
// Usage: CopyTextFile("PathTo/SourceFile", "PathTo/DestinationFile");
|
||||
// "PathTo" is relative to Base or mod directory.
|
||||
// Example: CopyTextFile("scripts/autoexec/copy.cs", "scripts/autoexec/copy.txt"); <--- Copies file if not existing
|
||||
// Example: CopyTextFile("scripts/autoexec/copy.cs", "scripts/autoexec/copy.txt", 1); <--- Overwrites file if existing
|
||||
//
|
||||
// Errors:
|
||||
// "Error: Filenames may not contain any of the following characters: \\ ? * < > \' |" <-- Illegal Chars.
|
||||
// "Error: Source & Destination cannot be the same!" <---- Duh.
|
||||
// "Error: You cannot use blank filenames!" <---- Duh.
|
||||
// "Error: There is no file scripts/autoexec/copy.cs". <---- Source file doesn't exist.
|
||||
// "Error: scripts/autoexec/copy.txt allready exists. Please use a different filename." <---- File allready exists.
|
||||
|
||||
function CopyTextFile(%sourceFile, %destFile, %overwrite)
|
||||
{
|
||||
if ( strcspn( %destFile, "\\?*\'<>|" ) < strlen( %destFile ) )
|
||||
{
|
||||
error("Error: Filenames may not contain any of the following characters: \\ ? * < > \' |");
|
||||
return;
|
||||
}
|
||||
|
||||
if(%sourceFile $= %destFile)
|
||||
{
|
||||
error("Error: Source & Destination cannot be the same!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(%sourceFile $= "" || %destFile $= "")
|
||||
{
|
||||
error("Error: You cannot use blank filenames!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isFile(%sourceFile))
|
||||
{
|
||||
error("Error: There is no file "@%sourceFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if(isFile(%destFile))
|
||||
{
|
||||
if(!%overwrite)
|
||||
{
|
||||
error("Error: "@%destFile@" allready exists. Please use a different filename.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteFile(%destFile);
|
||||
warn(%destFile@" Deleted.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%sObject = new FileObject();
|
||||
%dObject = new FileObject();
|
||||
|
||||
%sObject.openForRead(%sourceFile);
|
||||
// open/re-open the file to move to the start of it
|
||||
if(!%sObject.openForRead(%sourceFile))
|
||||
{
|
||||
error("Error: Unable to open: "@%sourceFile);
|
||||
return;
|
||||
}
|
||||
|
||||
// read file into temporary storage
|
||||
for(%i = 1; !%sObject.isEOF(); %i++)
|
||||
%temp[%i] = %sObject.readLine();
|
||||
|
||||
%dObject.openForWrite(%destFile);
|
||||
// make sure we can write to the file
|
||||
if(!%dObject.openForWrite(%destFile))
|
||||
{
|
||||
error("Error: Unable to write: "@%destFile);
|
||||
return;
|
||||
}
|
||||
|
||||
%lines = %i;
|
||||
|
||||
// write the lines back into the file
|
||||
for(%i = 1; %i < %lines; %i++)
|
||||
%dObject.writeLine(%temp[%i]);
|
||||
|
||||
%sObject.close();
|
||||
%dObject.close();
|
||||
warn("Copied file: "@%sourceFile@" to: "@%destFile);
|
||||
}
|
||||
298
docs/base/@vl2/z_scripts/support.vl2/support/flag_tracker.cs
Normal file
298
docs/base/@vl2/z_scripts/support.vl2/support/flag_tracker.cs
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
// #name = Flag Tracking Support
|
||||
// #version = 0.0.3
|
||||
// #date = January 30, 2003
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Provides information about flag status, events and carrier kills.
|
||||
// #status = Beta
|
||||
// #include = support/team_tracker.cs 0.0.4
|
||||
// #include = support/events 1.0.3
|
||||
// #include = support/kill_callbacks.cs
|
||||
|
||||
// Currently only supports CTF
|
||||
// Defines the following flag event callbacks:
|
||||
// onCTFGrab - Flag was taken from stand
|
||||
// onCTFCap - Flag was captured
|
||||
// onCTFDrop - Flag was dropped by carrier
|
||||
// onCTFPicked - Flag was taken from field
|
||||
// onCTFReturn - Flag was returned
|
||||
|
||||
// All of these callbacks pass a single parameter, %flagRef.
|
||||
// A flagRef is the stateful object for each flag.
|
||||
|
||||
// A flagRef has the following data fields:
|
||||
// stateCurrent - Current state of this flag, see below for state definitions
|
||||
// statePrevious - Previous state of this flag (the one before the current one)
|
||||
// actorCurrent - PlayerRep of player who caused the change to the current state
|
||||
// For example, if the state is "Taken" this field will be the capper.
|
||||
// actorPrevious - PlayerRep of player who caused the change to the previous state
|
||||
// teamID - TeamID of team to whom this flag belongs (1 or 2)
|
||||
|
||||
// Valid states are all currently defined as strings. They are self explanitory:
|
||||
// "At Home"
|
||||
// "In Field"
|
||||
// "Taken"
|
||||
|
||||
// Also defines one additional callback 'CarrierKillCTF'
|
||||
// This has all the parameters of a standard KillCallback (see kill_callbacks.cs)
|
||||
|
||||
// For CTF there is one other object, FlagTracker. This is a container object for the
|
||||
// flagRef objects for each team.
|
||||
// FlagTracker.team[1] is team 1's flag
|
||||
// FlagTracker.team[2] is team 2's flag
|
||||
|
||||
$FT_gameTypeMap["CTFPlusGame"] = "CTFgame";
|
||||
$FT_gameTypeMap["PracticeCTFGame"] = "CTFgame";
|
||||
|
||||
//=============================================================================
|
||||
// Flag state base class code
|
||||
//=============================================================================
|
||||
|
||||
// Change to a new state based on current state and an event. Record the playerRep
|
||||
// associated with the change.
|
||||
function FlagState::updateState(%this, %event, %actorRef) {
|
||||
|
||||
%this.statePrevious = %this.stateCurrent;
|
||||
%this.stateCurrent = %this.data.stateChange[%this.stateCurrent,%event];
|
||||
|
||||
%this.actorPrevious = %this.actorCurrent;
|
||||
%this.actorCurrent = %actorRef;
|
||||
|
||||
// Trigger any callback associated with a state change
|
||||
%callback = %this.data.callback[%this.statePrevious,%this.stateCurrent];
|
||||
if (%callback !$= "") {
|
||||
Callback.trigger(%callback,%this);
|
||||
}
|
||||
|
||||
return %this.stateCurrent;
|
||||
}
|
||||
|
||||
// Assign initial state based on an input string
|
||||
// Used in CTF to assign state from the CTF objective HUD
|
||||
function FlagState::initStatus(%this, %status) {
|
||||
|
||||
%this.stateCurrent = %this.data.initialState[%status];
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Gametype agnostic code
|
||||
//=============================================================================
|
||||
|
||||
function FT_activatePackage(%gameType) {
|
||||
|
||||
error("==========="@$FT_gameType@"===========");
|
||||
|
||||
if ($FT_gameTypeMap[%gameType] !$= "") %gameType = $FT_gameTypeMap[%gameType];
|
||||
|
||||
%pkg = "FlagTrack" @ %gameType;
|
||||
|
||||
if (%pkg !$= $FlagTrack::currentPkg) {
|
||||
|
||||
if (isActivePackage($FlagTrack::currentPkg)) {
|
||||
warn("Deactivating" SPC $FlagTrack::currentPkg);
|
||||
deactivatePackage($FlagTrack::currentPkg);
|
||||
}
|
||||
|
||||
if (isPackage(%pkg) && !isActivePackage(%pkg)) {
|
||||
warn("Activating" SPC %pkg);
|
||||
activatePackage(%pkg);
|
||||
$FlagTrack::currentPkg = %pkg;
|
||||
}
|
||||
else $FlagTrack::currentPkg = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Activate handler package based on current gametype
|
||||
function FT_onGameType(%msgType, %msgString, %gameType) {
|
||||
|
||||
%gameType = detag(%gameType);
|
||||
$FT_gameType = %gameType;
|
||||
|
||||
FT_activatePackage(%gameType);
|
||||
call(FT_onMissionBegin);
|
||||
}
|
||||
addMessageCallback('MsgClientReady', FT_onGameType);
|
||||
|
||||
function FT_onLoadDemoSettings() {
|
||||
|
||||
%pkg = "FlagTrack" @ objectiveHud.gameType;
|
||||
|
||||
$FT_gameType = objectiveHud.gameType;
|
||||
FT_activatePackage(objectiveHud.gameType);
|
||||
call(FT_onDemoPlayBack);
|
||||
call(FT_onMissionBegin);
|
||||
}
|
||||
Callback.add(postLoadDemoSettings,"FT_onLoadDemoSettings");
|
||||
|
||||
// By default do nothing here. Registered gametypes will override this.
|
||||
function FT_onMissionBegin() {
|
||||
|
||||
echo("NO Flag Tracker");
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// CTF code
|
||||
//=============================================================================
|
||||
|
||||
// Constants for CTF Flag states
|
||||
new ScriptObject(FlagStatesCTF) {
|
||||
|
||||
state["In Field"] = 0;
|
||||
state["At Home"] = 1;
|
||||
state["Taken"] = 2;
|
||||
|
||||
stateChange["At Home", "MsgCTFFlagTaken"] = "Taken";
|
||||
stateChange["Taken", "MsgCTFFlagCapped"] = "At Home";
|
||||
stateChange["Taken", "MsgCTFFlagDropped"] = "In Field";
|
||||
stateChange["In Field", "MsgCTFFlagTaken"] = "Taken";
|
||||
stateChange["In Field", "MsgCTFFlagReturned"] = "At Home";
|
||||
|
||||
initialState["<At Base>"] = "At Home";
|
||||
initialState["<In the Field>"] = "In Field";
|
||||
//anything else = "Taken";
|
||||
|
||||
callback["At Home","Taken"] = "onCTFGrab";
|
||||
callback["Taken","At Home"] = "onCTFCap";
|
||||
callback["Taken","In Field"] = "onCTFDrop";
|
||||
callback["In Field","Taken"] = "onCTFPicked";
|
||||
callback["In Field","At Home"] = "onCTFReturn";
|
||||
};
|
||||
|
||||
function FlagStateCTF::initStatus(%this, %status) {
|
||||
|
||||
parent::initStatus(%this, %status);
|
||||
|
||||
if (%this.stateCurrent $= "") {
|
||||
|
||||
// The state passed was a player name (with no tags) - they have the flag
|
||||
%this.stateCurrent = "Taken";
|
||||
%name = stripMLControlChars(%status);
|
||||
// Go find which player this is by looking in the PlayerListGroup
|
||||
%sz = PlayerListGroup.getCount();
|
||||
for (%i=0; %i < %sz; %i++) {
|
||||
%player = PlayerListGroup.getObject(%i);
|
||||
if (%name $= baseName(%player)) {
|
||||
%this.actorCurrent = %player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a flag tracking object for each team.
|
||||
// FlagTracker object created in CTF package version of FT_onMissionBegin()
|
||||
function FT_ProcessCTFInit(%msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6) {
|
||||
|
||||
%teamNum = detag(%a1);
|
||||
%flagStatus = detag(%a3);
|
||||
|
||||
warn("Initializing flag state object for team" SPC %teamNum SPC "with state" SPC %flagStatus);
|
||||
|
||||
FlagTracker.team[%teamNum] = new ScriptObject() {
|
||||
|
||||
class = FlagStateCTF;
|
||||
superClass = FlagState;
|
||||
|
||||
data = FlagStatesCTF;
|
||||
|
||||
stateCurrent = "";
|
||||
statePrevious = "";
|
||||
|
||||
teamID = %teamNum;
|
||||
|
||||
actorCurrent = "";
|
||||
actorPrevious = "";
|
||||
};
|
||||
|
||||
FlagTracker.team[%teamNum].initStatus(%flagStatus);
|
||||
FlagTracker.teamCount++;
|
||||
}
|
||||
|
||||
// This is the main CTF event engine. All CTF callbacks are routed here and used to drive
|
||||
// the state machine.
|
||||
function FT_ProcessCTFMsg(%msgType, %msgString, %playerName, %flagTeam, %flagTeamID) {
|
||||
|
||||
%playerName = detag(%playerName);
|
||||
|
||||
// Base CTF callbacks are very inconsistent in their paramater values.
|
||||
// The same callback will pass different values depending on the context of the call
|
||||
// For example, the player name is sent as "0" if the message is sent to the player
|
||||
// in question.
|
||||
// To avoid string parsing, I reviewed the callbacks and assign meningful values
|
||||
// when I receive a "0" instead of a player name.
|
||||
// None of this matters in Classic, where Yogi enforced sending all the values.
|
||||
|
||||
if (%playerName $= "0") {
|
||||
// If I got a "0" on flag return the flag returned due to timer.
|
||||
if (detag(%msgType) $= "MsgCTFFlagReturned") %playerRef = "";
|
||||
// Otherwise I got a "0" because it was *me* that acted on the flag
|
||||
else %playerRef = $PlayerList[TeamTracker.myID];
|
||||
}
|
||||
else %playerRef = $PlayerList[TeamTracker.idsByName[%playerName]];
|
||||
|
||||
// In all cases where the flagTeamID is zero it pertains to the enemy flag.
|
||||
if (%flagTeamID == 0) %flagTeamID = TeamTracker.enemyTeamID;
|
||||
|
||||
%flagRef = FlagTracker.team[%flagTeamID];
|
||||
%flagRef.updateState(detag(%msgType),%playerRef);
|
||||
}
|
||||
|
||||
// Mutate kill callbacks to see if they are kills on a carrier and retrigger them as a new callback.
|
||||
// The kill message is sent by CTF game code before the flag dropped message, so it's valid to
|
||||
// check the current state of the flag
|
||||
function FT_testCTFCarrierKill(%type, %killerRef, %victimRef, %weapon, %i_die, %i_win, %suicide, %tk) {
|
||||
|
||||
// Assume only two teams here
|
||||
%flagRef = FlagTracker.team[(%victimRef.teamID == 1) ? 2 : 1];
|
||||
|
||||
if ((%flagRef.stateCurrent $= "Taken") && (%victimRef == %flagRef.actorCurrent)) {
|
||||
Callback.trigger("CarrierKillCTF", %type, %killerRef, %victimRef, %weapon, %i_die, %i_win, %suicide, %tk);
|
||||
}
|
||||
}
|
||||
|
||||
Callback.add(KillCallback,FT_testCTFCarrierKill);
|
||||
|
||||
package FlagTrackCTFGame {
|
||||
|
||||
// CTF-specific startup code. Create a holder object for one flag state machine per team
|
||||
// Will be populated in FT_ProcessCTFInit()
|
||||
function FT_onMissionBegin() {
|
||||
|
||||
echo("CTF Flag Tracker");
|
||||
|
||||
if (isObject(FlagTracker)) {
|
||||
for (%i=1; %i <= FlagTracker.teamCount; %i++) {
|
||||
FlagTracker.team[%i].delete();
|
||||
}
|
||||
FlagTracker.delete();
|
||||
}
|
||||
|
||||
new ScriptObject(FlagTracker) {
|
||||
|
||||
class = FlagTracker;
|
||||
};
|
||||
}
|
||||
|
||||
function FT_onDemoPlayBack() {
|
||||
|
||||
%str = objectiveHud.getObject(6).getValue();
|
||||
if (%str $= "") FT_ProcessCTFInit("","",1,"","<At Base>");
|
||||
else FT_ProcessCTFInit("","",1,"",%str);
|
||||
|
||||
%str = objectiveHud.getObject(7).getValue();
|
||||
if (%str $= "") FT_ProcessCTFInit("","",2,"","<At Base>");
|
||||
else FT_ProcessCTFInit("","",2,"",%str);
|
||||
|
||||
FT_onMissionBegin();
|
||||
}
|
||||
};
|
||||
|
||||
addMessageCallback('MsgCTFFlagReturned', FT_ProcessCTFMsg);
|
||||
addMessageCallback('MsgCTFFlagDropped', FT_ProcessCTFMsg);
|
||||
addMessageCallback('MsgCTFFlagTaken', FT_ProcessCTFMsg);
|
||||
addMessageCallback('MsgCTFFlagCapped', FT_ProcessCTFMsg);
|
||||
addMessageCallback('MsgCTFAddTeam', FT_ProcessCTFInit);
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// #name = Flood Protect
|
||||
// #version = 1.0
|
||||
// #date = March 31, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Utility to help scripters prevent spam and other over-repetive events in their scripts.
|
||||
// #status = Release
|
||||
|
||||
|
||||
// Synopsis: floodProtect(%name, %duration)
|
||||
//
|
||||
// The single function in this script works quite simply:
|
||||
//
|
||||
// floodProtect("foo",1000);
|
||||
//
|
||||
// will return false unless the same call was made less than one second ago.
|
||||
// Basically, the 1st time you call it with any string in the %name argument,
|
||||
// the function starts a timer linked to that string. Until the timer expires
|
||||
// (set in milliseconds with the %duration argument), the function will return
|
||||
// true. If the timer has expired, it will return false and restart the timer.
|
||||
//
|
||||
// You can use this to prevent things from occuring except at intervals you desire.
|
||||
// A common use would be to prevent a script from saying things in chat more than
|
||||
// every so-many seconds.
|
||||
//
|
||||
// Example:
|
||||
// if (!floodProtect("youShotMeMessage",5000))
|
||||
// commandToServer('TeamMessageSent',"Watch where you're shooting!");
|
||||
|
||||
function floodProtect(%name, %duration) {
|
||||
|
||||
if(%name $= "") return false;
|
||||
if(!%duration) return false;
|
||||
|
||||
%obj = "_FP_" @ %name;
|
||||
|
||||
if(isObject(%obj)) return true;
|
||||
else {
|
||||
new ScriptObject(%obj) {
|
||||
class = floodProtect;
|
||||
};
|
||||
}
|
||||
|
||||
%obj.duration = %duration;
|
||||
%obj.schedID = %obj.schedule(%duration, delete);
|
||||
return false;
|
||||
}
|
||||
854
docs/base/@vl2/z_scripts/support.vl2/support/key_callbacks.cs
Normal file
854
docs/base/@vl2/z_scripts/support.vl2/support/key_callbacks.cs
Normal file
|
|
@ -0,0 +1,854 @@
|
|||
// #name = Key Support
|
||||
// #version = 0.0.2
|
||||
// #date = April 11, 2001
|
||||
// #category = Support
|
||||
// #author = Daniel Neilsen (aka Wizard_TPG)
|
||||
// #email = wizardsworld@bigpond.com
|
||||
// #web = http://www.tribalwar.com/wizard/
|
||||
// #description = Allows multiple uses of one button and button "muting"
|
||||
// #status = beta
|
||||
// #include = support/callback.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Usage Notes and Examples:
|
||||
//
|
||||
// When a button is pressed it calls a particular function. eg. MouseFire();
|
||||
// What this support script does is creates a callback of the same name that passes
|
||||
// the %val value as the first variable.
|
||||
//
|
||||
// eg. To attack to the mousefire command.
|
||||
//
|
||||
// function MyHandleForMouseFire (%val)
|
||||
// {
|
||||
// if(%val)
|
||||
// {
|
||||
// //button was pressed
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //button was released
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// callback.add(MouseFirePressed, MyHandleForMouseFire); - note %val will be 1
|
||||
// callback.add(MouseFireReleased, MyHandleForMouseFire); - note %val will be 0
|
||||
//
|
||||
//
|
||||
// The other useful function this support script performs is key "muting". Lets
|
||||
// just assume that you wanna use the mousefire(); command but wish to disable its normal
|
||||
// properties for pressing the fire button. You could do this.
|
||||
//
|
||||
// function MyHandleForMouseFire (%val)
|
||||
// {
|
||||
// if(%val)
|
||||
// {
|
||||
// //button was pressed
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //button was released
|
||||
// }
|
||||
// return mute;
|
||||
// }
|
||||
//
|
||||
// callback.add(MouseFirePressed, MyHandleForMouseFire);
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================================
|
||||
|
||||
package keycallbacks
|
||||
{
|
||||
function moveleft(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(moveleft, %val))
|
||||
parent::moveleft(%val);
|
||||
}
|
||||
|
||||
function moveright(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(moveright, %val))
|
||||
parent::moveright(%val);
|
||||
}
|
||||
|
||||
function moveforward(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(moveforward, %val))
|
||||
parent::moveforward(%val);
|
||||
}
|
||||
|
||||
function movebackward(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(movebackward, %val))
|
||||
parent::movebackward(%val);
|
||||
}
|
||||
|
||||
function moveup(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(moveup, %val))
|
||||
parent::moveup(%val);
|
||||
}
|
||||
|
||||
function movedown(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(movedown, %val))
|
||||
parent::movedown(%val);
|
||||
}
|
||||
|
||||
function turnLeft( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(turnLeft, %val))
|
||||
parent::turnLeft(%val);
|
||||
}
|
||||
|
||||
function turnRight( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(turnRight, %val))
|
||||
parent::turnRight(%val);
|
||||
}
|
||||
|
||||
function panUp( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(panUp, %val))
|
||||
parent::panUp(%val);
|
||||
}
|
||||
|
||||
function panDown( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(panDown, %val))
|
||||
parent::panDown(%val);
|
||||
}
|
||||
|
||||
function yaw(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(yaw, %val))
|
||||
parent::yaw(%val);
|
||||
}
|
||||
|
||||
function pitch(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(pitch, %val))
|
||||
parent::pitch(%val);
|
||||
}
|
||||
|
||||
function toggleDepth(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleDepth, %val))
|
||||
parent::toggleDepth(%val);
|
||||
}
|
||||
|
||||
function snLine(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(snLine, %val))
|
||||
parent::snLine(%val);
|
||||
}
|
||||
|
||||
function snToggle(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(snToggle, %val))
|
||||
parent::snToggle(%val);
|
||||
}
|
||||
|
||||
function pageMessageHudUp( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(pageMessageHudUp, %val))
|
||||
parent::pageMessageHudUp(%val);
|
||||
}
|
||||
|
||||
function pageMessageHudDown( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(pageMessageHudDown, %val))
|
||||
parent::pageMessageHudDown(%val);
|
||||
}
|
||||
|
||||
function voiceCapture( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(voiceCapture, %val))
|
||||
parent::voiceCapture(%val);
|
||||
}
|
||||
|
||||
function prevWeapon( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(prevWeapon, %val))
|
||||
parent::prevWeapon(%val);
|
||||
}
|
||||
|
||||
function nextWeapon( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(nextWeapon, %val))
|
||||
parent::nextWeapon(%val);
|
||||
}
|
||||
|
||||
function cycleWeaponAxis( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(cycleWeaponAxis, %val))
|
||||
parent::cycleWeaponAxis(%val);
|
||||
}
|
||||
|
||||
function cycleNextWeaponOnly( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(cycleNextWeaponOnly, %val))
|
||||
parent::cycleNextWeaponOnly(%val);
|
||||
}
|
||||
|
||||
function toggleFreeLook( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleFreeLook, %val))
|
||||
parent::toggleFreeLook(%val);
|
||||
}
|
||||
|
||||
function useRepairKit( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useRepairKit, %val))
|
||||
parent::useRepairKit(%val);
|
||||
}
|
||||
|
||||
function useBackPack( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useBackPack, %val))
|
||||
parent::useBackPack(%val);
|
||||
}
|
||||
|
||||
function useFirstWeaponSlot( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useFirstWeaponSlot, %val))
|
||||
parent::useFirstWeaponSlot(%val);
|
||||
}
|
||||
|
||||
function useSecondWeaponSlot( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useSecondWeaponSlot, %val))
|
||||
parent::useSecondWeaponSlot(%val);
|
||||
}
|
||||
|
||||
function useThirdWeaponSlot( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useThirdWeaponSlot, %val))
|
||||
parent::useThirdWeaponSlot(%val);
|
||||
}
|
||||
|
||||
function useFourthWeaponSlot( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useFourthWeaponSlot, %val))
|
||||
parent::useFourthWeaponSlot(%val);
|
||||
}
|
||||
|
||||
function useFifthWeaponSlot( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useFifthWeaponSlot, %val))
|
||||
parent::useFifthWeaponSlot(%val);
|
||||
}
|
||||
|
||||
function useSixthWeaponSlot( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useSixthWeaponSlot, %val))
|
||||
parent::useSixthWeaponSlot(%val);
|
||||
}
|
||||
|
||||
function useBlaster( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useBlaster, %val))
|
||||
parent::useBlaster(%val);
|
||||
}
|
||||
|
||||
function usePlasma( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(usePlasma, %val))
|
||||
parent::usePlasma(%val);
|
||||
}
|
||||
|
||||
function useChaingun( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useChaingun, %val))
|
||||
parent::useChaingun(%val);
|
||||
}
|
||||
|
||||
function useDisc( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useDisc, %val))
|
||||
parent::useDisc(%val);
|
||||
}
|
||||
|
||||
function useGrenadeLauncher( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useGrenadeLauncher, %val))
|
||||
parent::useGrenadeLauncher(%val);
|
||||
}
|
||||
|
||||
function useSniperRifle( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useSniperRifle, %val))
|
||||
parent::useSniperRifle(%val);
|
||||
}
|
||||
|
||||
function useELFGun( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useELFGun, %val))
|
||||
parent::useELFGun(%val);
|
||||
}
|
||||
|
||||
function useMortar( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useMortar, %val))
|
||||
parent::useMortar(%val);
|
||||
}
|
||||
|
||||
function useMissileLauncher( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useMissileLauncher, %val))
|
||||
parent::useMissileLauncher(%val);
|
||||
}
|
||||
|
||||
function useTargetingLaser( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useTargetingLaser, %val))
|
||||
parent::useTargetingLaser(%val);
|
||||
}
|
||||
|
||||
function useShockLance( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useShockLance, %val))
|
||||
parent::useShockLance(%val);
|
||||
}
|
||||
|
||||
function throwGrenade( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(throwGrenade, %val))
|
||||
parent::throwGrenade(%val);
|
||||
}
|
||||
|
||||
function placeMine( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(placeMine, %val))
|
||||
parent::placeMine(%val);
|
||||
}
|
||||
|
||||
function placeBeacon( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(placeBeacon, %val))
|
||||
parent::placeBeacon(%val);
|
||||
}
|
||||
|
||||
function throwWeapon( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(throwWeapon, %val))
|
||||
parent::throwWeapon(%val);
|
||||
}
|
||||
|
||||
function throwPack( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(throwPack, %val))
|
||||
parent::throwPack(%val);
|
||||
}
|
||||
|
||||
function throwFlag( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(throwFlag, %val))
|
||||
parent::throwFlag(%val);
|
||||
}
|
||||
|
||||
function resizeChatHud( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(resizeChatHud, %val))
|
||||
parent::resizeChatHud(%val);
|
||||
}
|
||||
|
||||
function setZoomFOV(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(setZoomFOV, %val))
|
||||
parent::setZoomFOV(%val);
|
||||
}
|
||||
|
||||
function toggleZoom( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleZoom, %val))
|
||||
parent::toggleZoom(%val);
|
||||
}
|
||||
|
||||
function toggleInventoryHud( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleInventoryHud, %val))
|
||||
parent::toggleInventoryHud(%val);
|
||||
}
|
||||
|
||||
function selectFavorite1( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite1, %val))
|
||||
parent::selectFavorite1(%val);
|
||||
}
|
||||
|
||||
function selectFavorite2( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite2, %val))
|
||||
parent::selectFavorite2(%val);
|
||||
}
|
||||
|
||||
function selectFavorite3( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite3, %val))
|
||||
parent::selectFavorite3(%val);
|
||||
}
|
||||
|
||||
function selectFavorite4( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite4, %val))
|
||||
parent::selectFavorite4(%val);
|
||||
}
|
||||
|
||||
function selectFavorite5( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite5, %val))
|
||||
parent::selectFavorite5(%val);
|
||||
}
|
||||
|
||||
function selectFavorite6( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite6, %val))
|
||||
parent::selectFavorite6(%val);
|
||||
}
|
||||
|
||||
function selectFavorite7( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite7, %val))
|
||||
parent::selectFavorite7(%val);
|
||||
}
|
||||
|
||||
function selectFavorite8( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite8, %val))
|
||||
parent::selectFavorite8(%val);
|
||||
}
|
||||
|
||||
function selectFavorite9( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite9, %val))
|
||||
parent::selectFavorite9(%val);
|
||||
}
|
||||
|
||||
function selectFavorite10( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite10, %val))
|
||||
parent::selectFavorite10(%val);
|
||||
}
|
||||
|
||||
function selectFavorite11( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite11, %val))
|
||||
parent::selectFavorite11(%val);
|
||||
}
|
||||
|
||||
function selectFavorite12( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite12, %val))
|
||||
parent::selectFavorite12(%val);
|
||||
}
|
||||
|
||||
function selectFavorite13( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite13, %val))
|
||||
parent::selectFavorite13(%val);
|
||||
}
|
||||
|
||||
function selectFavorite14( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite14, %val))
|
||||
parent::selectFavorite14(%val);
|
||||
}
|
||||
|
||||
function selectFavorite15( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite15, %val))
|
||||
parent::selectFavorite15(%val);
|
||||
}
|
||||
|
||||
function selectFavorite16( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite16, %val))
|
||||
parent::selectFavorite16(%val);
|
||||
}
|
||||
|
||||
function selectFavorite17( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite17, %val))
|
||||
parent::selectFavorite17(%val);
|
||||
}
|
||||
|
||||
function selectFavorite18( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite18, %val))
|
||||
parent::selectFavorite18(%val);
|
||||
}
|
||||
|
||||
function selectFavorite19( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite19, %val))
|
||||
parent::selectFavorite19(%val);
|
||||
}
|
||||
|
||||
function selectFavorite20( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(selectFavorite20, %val))
|
||||
parent::selectFavorite20(%val);
|
||||
}
|
||||
|
||||
function quickPackRepairPack(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackRepairPack, %val))
|
||||
parent::quickPackRepairPack(%val);
|
||||
}
|
||||
|
||||
function quickPackEnergyPack(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackEnergyPack, %val))
|
||||
parent::quickPackEnergyPack(%val);
|
||||
}
|
||||
|
||||
function quickPackShieldPack(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackShieldPack, %val))
|
||||
parent::quickPackShieldPack(%val);
|
||||
}
|
||||
|
||||
function quickPackCloakPack(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackCloakPack, %val))
|
||||
parent::quickPackCloakPack(%val);
|
||||
}
|
||||
|
||||
function quickPackJammerPack(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackJammerPack, %val))
|
||||
parent::quickPackJammerPack(%val);
|
||||
}
|
||||
|
||||
function quickPackAmmoPack(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackAmmoPack, %val))
|
||||
parent::quickPackAmmoPack(%val);
|
||||
}
|
||||
|
||||
function quickPackSatchelCharge(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackSatchelCharge, %val))
|
||||
parent::quickPackSatchelCharge(%val);
|
||||
}
|
||||
|
||||
function quickPackDeployableStation(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackDeployableStation, %val))
|
||||
parent::quickPackDeployableStation(%val);
|
||||
}
|
||||
|
||||
function quickPackIndoorTurret(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackIndoorTurret, %val))
|
||||
parent::quickPackIndoorTurret(%val);
|
||||
}
|
||||
|
||||
function quickPackOutdoorTurret(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackOutdoorTurret, %val))
|
||||
parent::quickPackOutdoorTurret(%val);
|
||||
}
|
||||
|
||||
function quickPackMotionSensor(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackMotionSensor, %val))
|
||||
parent::quickPackMotionSensor(%val);
|
||||
}
|
||||
|
||||
function quickPackPulse(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackPulse, %val))
|
||||
parent::quickPackPulse(%val);
|
||||
}
|
||||
|
||||
function quickPackMortarBarrel(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackMortarBarrel, %val))
|
||||
parent::quickPackMortarBarrel(%val);
|
||||
}
|
||||
|
||||
function quickPackElfBarrel(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackElfBarrel, %val))
|
||||
parent::quickPackElfBarrel(%val);
|
||||
}
|
||||
|
||||
function quickPackAABarrel(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackAABarrel, %val))
|
||||
parent::quickPackAABarrel(%val);
|
||||
}
|
||||
|
||||
function quickPackPlasmaBarrel(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackPlasmaBarrel, %val))
|
||||
parent::quickPackPlasmaBarrel(%val);
|
||||
}
|
||||
|
||||
function quickPackMissileBarrel(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackMissileBarrel, %val))
|
||||
parent::quickPackMissileBarrel(%val);
|
||||
}
|
||||
|
||||
function quickPackFlashGrenade(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackFlashGrenade, %val))
|
||||
parent::quickPackFlashGrenade(%val);
|
||||
}
|
||||
|
||||
function quickPackConcussionGrenade(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackConcussionGrenade, %val))
|
||||
parent::quickPackConcussionGrenade(%val);
|
||||
}
|
||||
|
||||
function quickPackGrenade(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackGrenade, %val))
|
||||
parent::quickPackGrenade(%val);
|
||||
}
|
||||
|
||||
function quickPackFlareGrenade(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackFlareGrenade, %val))
|
||||
parent::quickPackFlareGrenade(%val);
|
||||
}
|
||||
|
||||
function quickPackCameraGrenade(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(quickPackCameraGrenade, %val))
|
||||
parent::quickPackCameraGrenade(%val);
|
||||
}
|
||||
|
||||
function toggleCommanderMap( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleCommanderMap, %val))
|
||||
parent::toggleCommanderMap(%val);
|
||||
}
|
||||
|
||||
function report(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(report, %val))
|
||||
parent::report(%val);
|
||||
}
|
||||
|
||||
function suicide(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(suicide, %val))
|
||||
parent::suicide(%val);
|
||||
}
|
||||
|
||||
function toggleFirstPerson(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleFirstPerson, %val))
|
||||
parent::toggleFirstPerson(%val);
|
||||
}
|
||||
|
||||
function toggleCamera(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggltoggleCameraeCommanderMap, %val))
|
||||
parent::toggleCamera(%val);
|
||||
}
|
||||
|
||||
function dropPlayerAtCamera(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(dropPlayerAtCamera, %val))
|
||||
parent::dropPlayerAtCamera(%val);
|
||||
}
|
||||
|
||||
function dropCameraAtPlayer(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(dropCameraAtPlayer, %val))
|
||||
parent::dropCameraAtPlayer(%val);
|
||||
}
|
||||
|
||||
function dropPlayerAtCamera(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(dropPlayerAtCamera, %val))
|
||||
parent::dropPlayerAtCamera(%val);
|
||||
}
|
||||
|
||||
function togglePlayerRace(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(togglePlayerRace, %val))
|
||||
parent::togglePlayerRace(%val);
|
||||
}
|
||||
|
||||
function togglePlayerGender(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(togglePlayerGender, %val))
|
||||
parent::togglePlayerGender(%val);
|
||||
}
|
||||
|
||||
function togglePlayerArmor(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(togglePlayerArmor, %val))
|
||||
parent::togglePlayerArmor(%val);
|
||||
}
|
||||
|
||||
function jump(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(jump, %val))
|
||||
parent::jump(%val);
|
||||
}
|
||||
|
||||
function mouseFire(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(mouseFire, %val))
|
||||
parent::mouseFire(%val);
|
||||
}
|
||||
|
||||
function mouseJet(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(mouseJet, %val))
|
||||
parent::mouseJet(%val);
|
||||
}
|
||||
|
||||
function altTrigger(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(altTrigger, %val))
|
||||
parent::altTrigger(%val);
|
||||
}
|
||||
|
||||
function toggleHelpGui( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleHelpGui, %val))
|
||||
parent::toggleHelpGui(%val);
|
||||
}
|
||||
|
||||
function toggleScoreScreen( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleScoreScreen, %val))
|
||||
parent::toggleScoreScreen(%val);
|
||||
}
|
||||
|
||||
function toggleHudWaypoints(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleHudWaypoints, %val))
|
||||
parent::toggleHudWaypoints(%val);
|
||||
}
|
||||
|
||||
function toggleHudMarkers(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleHudMarkers, %val))
|
||||
parent::toggleHudMarkers(%val);
|
||||
}
|
||||
|
||||
function toggleHudTargets(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleHudTargets, %val))
|
||||
parent::toggleHudTargets(%val);
|
||||
}
|
||||
|
||||
function toggleHudCommands(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(toggleHudCommands, %val))
|
||||
parent::toggleHudCommands(%val);
|
||||
}
|
||||
|
||||
|
||||
function fnAcceptTask( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(fnAcceptTask, %val))
|
||||
parent::fnAcceptTask(%val);
|
||||
}
|
||||
|
||||
function fnDeclineTask( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(fnDeclineTask, %val))
|
||||
parent::fnDeclineTask(%val);
|
||||
}
|
||||
|
||||
function fnTaskCompleted( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(fnTaskCompleted, %val))
|
||||
parent::fnTaskCompleted(%val);
|
||||
}
|
||||
|
||||
function fnResetTaskList( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(fnResetTaskList, %val))
|
||||
parent::fnResetTaskList(%val);
|
||||
}
|
||||
|
||||
function voteYes( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(voteYes, %val))
|
||||
parent::voteYes(%val);
|
||||
}
|
||||
|
||||
function voteNo( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(voteNo, %val))
|
||||
parent::voteNo(%val);
|
||||
}
|
||||
|
||||
function useWeaponOne(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useWeaponOne, %val))
|
||||
parent::useWeaponOne(%val);
|
||||
}
|
||||
|
||||
function useWeaponTwo(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useWeaponTwo, %val))
|
||||
parent::useWeaponTwo(%val);
|
||||
}
|
||||
|
||||
function useWeaponThree(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(useWeaponThree, %val))
|
||||
parent::useWeaponThree(%val);
|
||||
}
|
||||
|
||||
function nextVehicleWeapon(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(nextVehicleWeapon, %val))
|
||||
parent::nextVehicleWeapon(%val);
|
||||
}
|
||||
|
||||
function prevVehicleWeapon(%val)
|
||||
{
|
||||
if(keycallbacks.ButtonPress(prevVehicleWeapon, %val))
|
||||
parent::prevVehicleWeapon(%val);
|
||||
}
|
||||
|
||||
function cycleVehicleWeapon( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(cycleVehicleWeapon, %val))
|
||||
parent::cycleVehicleWeapon(%val);
|
||||
}
|
||||
|
||||
function cycleNextVehicleWeaponOnly( %val )
|
||||
{
|
||||
if(keycallbacks.ButtonPress(cycleNextVehicleWeaponOnly, %val))
|
||||
parent::cycleNextVehicleWeaponOnly(%val);
|
||||
}
|
||||
};
|
||||
|
||||
activatepackage(keycallbacks);
|
||||
//======================================================================
|
||||
|
||||
if(!isObject(keycallbacks))
|
||||
{
|
||||
new ScriptObject(keycallbacks)
|
||||
{
|
||||
class = keycallbacks;
|
||||
};
|
||||
}
|
||||
|
||||
function keycallbacks::ButtonPress(%this, %name, %val)
|
||||
{
|
||||
if(%val)
|
||||
%callbackdata = %name @ "Pressed";
|
||||
else
|
||||
%callbackdata = %name @ "Released";
|
||||
callback.trigger(%callbackdata, %val);
|
||||
if( !callback.returned(%callbackdata, mute) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
131
docs/base/@vl2/z_scripts/support.vl2/support/kill_callbacks.cs
Normal file
131
docs/base/@vl2/z_scripts/support.vl2/support/kill_callbacks.cs
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
// #name = Kill Callbacks
|
||||
// #version = 1.0.1
|
||||
// #date = September 9, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Simplified kill tracking Callback.
|
||||
// #status = Release
|
||||
// #include = support/map.cs
|
||||
// #include = support/callback.cs
|
||||
// #include = support/mute_tools.cs
|
||||
// #include = support/team_tracker.cs
|
||||
|
||||
// This creates a single callback for all kill types, "KillCallback", with the following
|
||||
// passed arguments:
|
||||
//
|
||||
// %type : the MessageCallback type, such as "MsgLegitKill"
|
||||
// %killer : the playerRef of the player who performed the kill.
|
||||
// %victim : the playerRef of the player who was killed.
|
||||
// %weapon : the name of the implement that did the killing (e.g. "disc", "impact", "suicide").
|
||||
// %i_die : boolean flag - if true the player was killed in the exchange. Avoids name comparisons.
|
||||
// %i_win : boolean flag - if true the player was who performed this kill. Avoids name comparisons.
|
||||
// %suicide : boolean flag - if true the player just killed himself, either by CTRL-K or with a weapon.
|
||||
// %tk : boolean flag - if true this kill was a teamkill.
|
||||
|
||||
// It is posible to register other messages as kills and suicides (potentially useful for mods).
|
||||
//
|
||||
// killTypes.addKillType(%message); : adds a new kill message
|
||||
// killTypes.addSuicideType(%message); : adds a new suicide message
|
||||
|
||||
if (!isObject(killTypes)) {
|
||||
|
||||
new ScriptObject(killTypes) {
|
||||
|
||||
class = "killTypes";
|
||||
typeMap = Container::newVectorMap();
|
||||
suicideMap = Container::newVectorMap();
|
||||
};
|
||||
}
|
||||
|
||||
function killTypes::addKillType(%this, %typeName) {
|
||||
|
||||
%this.typeMap.add(%typeName, true);
|
||||
}
|
||||
|
||||
function killTypes::addSuicideType(%this, %typeName) {
|
||||
|
||||
%this.suicideMap.add(%typeName, true);
|
||||
}
|
||||
|
||||
function killTypes::isKillType(%this, %typeName) {
|
||||
|
||||
if (%this.typeMap.value(%typeName)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function killTypes::isSuicideType(%this, %typeName) {
|
||||
|
||||
if (%this.suicideMap.value(%typeName)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
package killCallbacks {
|
||||
|
||||
function defaultMessageCallback(%msgType, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10) {
|
||||
|
||||
%type = detag(%msgType);
|
||||
|
||||
// Ignore damage type value of zero
|
||||
if (killTypes.isKillType(%type) && detag(%a8)) {
|
||||
|
||||
%weapon = detag(%a9);
|
||||
|
||||
%victimName = detag(%a2);
|
||||
%victim = $PlayerList[TeamTracker.idsByName[%victimName]];
|
||||
%suicide = killTypes.isSuicideType(%type);
|
||||
|
||||
%killerName = detag(%a5);
|
||||
if (%killerName !$= "") {
|
||||
|
||||
%killer = $PlayerList[TeamTracker.idsByName[%killerName]];
|
||||
|
||||
//%tk = ((%killer.teamID == %victim.teamID) || (%type $= "msgTeamKill"));
|
||||
%tk = %type $= "msgTeamKill";
|
||||
%i_win = (teamTracker.myID == %killer.clientID);
|
||||
}
|
||||
else {
|
||||
%tk = %i_win = false;
|
||||
}
|
||||
|
||||
%i_die = (teamTracker.myID == %victim.clientID);
|
||||
|
||||
Callback.trigger("KillCallback", %type, %killer, %victim, %weapon, %i_die, %i_win, %suicide, %tk);
|
||||
|
||||
if(!Callback.returned("KillCallback", mute)) {
|
||||
parent::defaultMessageCallback(%msgType, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
}
|
||||
}
|
||||
else parent::defaultMessageCallback(%msgType, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
}
|
||||
};
|
||||
|
||||
// mute_tools.cs can end up blocking calls to defaultMessageCallback. To avoid this I make sure
|
||||
// it's loaded first (in the #include list) to force its package to be invoked after this one.
|
||||
|
||||
activatepackage(killCallbacks);
|
||||
|
||||
killTypes.addKillType("MsgHeadshotKill");
|
||||
killTypes.addKillType("MsgLegitKill");
|
||||
killTypes.addKillType("MsgRogueMineKill");
|
||||
killTypes.addKillType("MsgRearshotKill");
|
||||
killTypes.addKillType("msgCTurretKill");
|
||||
killTypes.addKillType("msgCampKill");
|
||||
killTypes.addKillType("msgExplosionKill");
|
||||
killTypes.addKillType("msgLavaKill");
|
||||
killTypes.addKillType("msgLightningKill");
|
||||
killTypes.addKillType("msgOOBKill");
|
||||
killTypes.addKillType("msgSelfKill");
|
||||
killTypes.addKillType("msgSuicide");
|
||||
killTypes.addKillType("msgTeamKill");
|
||||
killTypes.addKillType("msgTurretKill");
|
||||
killTypes.addKillType("msgTurretSelfKill");
|
||||
killTypes.addKillType("msgVehicleKill");
|
||||
killTypes.addKillType("msgVehicleSpawnKill");
|
||||
|
||||
killTypes.addSuicideType("msgSuicide");
|
||||
killTypes.addSuicideType("msgSelfKill");
|
||||
killTypes.addSuicideType("msgTurretSelfKill");
|
||||
401
docs/base/@vl2/z_scripts/support.vl2/support/launch_menu.cs
Normal file
401
docs/base/@vl2/z_scripts/support.vl2/support/launch_menu.cs
Normal file
|
|
@ -0,0 +1,401 @@
|
|||
// #name = Launch Menu API
|
||||
// #version = 1.0.0
|
||||
// #date = April 10, 2001
|
||||
// #category = Support
|
||||
// #author = Lorne Laliberte
|
||||
// #warrior = Writer
|
||||
// #email = t2beta@cdnwriter.com
|
||||
// #web = http://www.t2scripts.com
|
||||
// #web = http://www.cdnwriter.com
|
||||
// #description = Adds new commands to the LaunchToolbarMenu class so scripters can customize the launch menu
|
||||
// #status = release
|
||||
// #include = support/callback.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Usage notes and examples:
|
||||
//
|
||||
// Note: the "id" referred to here is a value that gets passed to the onSelect()
|
||||
// function when a Launch Menu item is selected.
|
||||
//
|
||||
// Be careful to use a unique id when adding an item to the launch menu!
|
||||
//
|
||||
// Don't use id 72 for anything, that one's mine. :)
|
||||
//
|
||||
// LaunchToolbarMenu.getItemID(1);
|
||||
//
|
||||
// -> returns the ID of the 2nd Launch Menu item (i.e. at position 1)
|
||||
//
|
||||
// LaunchToolbarMenu.getItemText(0);
|
||||
//
|
||||
// -> returns the ID of the 1st Launch Menu item (i.e. at position 0)
|
||||
//
|
||||
// LaunchToolbarMenu.findItem(%id, %target_text, %occurence);
|
||||
//
|
||||
// -> find an item by its id, by its text, or by both
|
||||
//
|
||||
// LaunchToolbarMenu.findItem(2, "GAME");
|
||||
//
|
||||
// -> returns the current index of the item with ID = 2 and text = "GAME"
|
||||
//
|
||||
// LaunchToolbarMenu.findItem("", "--", 2);
|
||||
//
|
||||
// -> returns the current index of the 2nd separator
|
||||
//
|
||||
// LaunchToolbarMenu.insertItemAt(0, 69, "GetItOn");
|
||||
//
|
||||
// -> inserts an item at the start of the list (position 0) with the id 69
|
||||
// and the text "GetItOn"
|
||||
//
|
||||
// LaunchToolbarMenu.insertItemAt(0, 69, "GetItOn", "LaunchGetItOn();");
|
||||
//
|
||||
// -> inserts an item at the start of the list (position 0) with the id 69
|
||||
// and the text "GetItOn" and attached "LaunchGetItOn();" to the callback
|
||||
// that will be triggered whenever the GetItOn item is selected
|
||||
//
|
||||
// LaunchToolbarMenu.insertItemAt(4, "", "--");
|
||||
//
|
||||
// -> inserts a separator at position 4 in the launch menu
|
||||
//
|
||||
// LaunchToolbarMenu.insertItemAt(LaunchToolbarMenu.findItem(7, "SETTINGS"), 72, "SCRIPTS", "LaunchScriptBrowser();");
|
||||
//
|
||||
// -> inserts my "SCRIPTS" item before the "SETTINGS" item in the launch menu,
|
||||
// assigns "72" as the ID for my "SCRIPTS" item, and sets "LaunchScriptBrowser();" as the function
|
||||
// that gets called whenever the "SCRIPTS" item is selected
|
||||
//
|
||||
// LaunchToolbarMenu.insertSeparatorAt(4);
|
||||
//
|
||||
// -> inserts a separator at position 4 in the launch menu
|
||||
//
|
||||
// LaunchToolbarMenu.removeItemAt(7);
|
||||
//
|
||||
// -> removes the item at position 7 in the menu
|
||||
//
|
||||
// NOTE: you can't remove "root" or "original" items
|
||||
//
|
||||
// Original items include Dynamix's stuff like "GAME" and "QUIT,"
|
||||
// as well as any items added without using this API
|
||||
//
|
||||
// LaunchToolbarMenu.removeSeparatorAt(3);
|
||||
//
|
||||
// -> only removes the item at position 3 in the menu if it's a separator
|
||||
//
|
||||
//
|
||||
// You should use the "LaunchMenuReady" callback to set up your launch items.
|
||||
// Here's the code I use in autoload.cs to add the SCRIPTS item as soon as the
|
||||
// Launch Menu is ready:
|
||||
//
|
||||
// function SB_AddLaunchItem()
|
||||
// {
|
||||
// LaunchToolbarMenu.insertItemAt(LaunchToolbarMenu.findItem(7, "SETTINGS"), 72, "SCRIPTS", "LaunchScriptBrowser();");
|
||||
// }
|
||||
// callback.add(LaunchMenuReady, "SB_AddLaunchItem();");
|
||||
|
||||
|
||||
|
||||
function LaunchToolbarMenu::getItemID(%this, %index)
|
||||
{
|
||||
return %this.api_public_item_id[%index];
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::getItemText(%this, %index)
|
||||
{
|
||||
return %this.api_public_item_text[%index];
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::findItem(%this, %target_id, %target_text, %occurence)
|
||||
{
|
||||
if(%occurence $= "")
|
||||
%occurence = 1;
|
||||
|
||||
if( (%target_id !$= "") && (%target_text !$= "") )
|
||||
{
|
||||
// search for match on id and text
|
||||
|
||||
for( %i = 0; %i < %this.api_public_item_count; %i++)
|
||||
{
|
||||
if( !stricmp(%this.api_public_item_text[%i], %target_text) &&
|
||||
!stricmp(%this.api_public_item_id[%i], %target_id) )
|
||||
{
|
||||
// item found with matching id and text
|
||||
%occurence--;
|
||||
|
||||
if(!%occurence)
|
||||
return %i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( %target_text !$= "" )
|
||||
{
|
||||
// search for match on text only
|
||||
|
||||
for( %i = 0; %i < %this.api_public_item_count; %i++)
|
||||
{
|
||||
if( !stricmp(%this.api_public_item_text[%i], %target_text) )
|
||||
{
|
||||
// item found with matching text
|
||||
%occurence--;
|
||||
|
||||
if(!%occurence)
|
||||
return %i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( %target_id !$= "" )
|
||||
{
|
||||
// search for match on id only
|
||||
|
||||
for( %i = 0; %i < %this.api_public_item_count; %i++)
|
||||
{
|
||||
if( !stricmp(%this.api_public_item_id[%i], %target_id) )
|
||||
{
|
||||
// item found with matching id
|
||||
%occurence--;
|
||||
|
||||
if(!%occurence)
|
||||
return %i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::insertItemAt(%this, %index, %id, %text, %func)
|
||||
{
|
||||
// get the main (root) item for this index
|
||||
%main_index = %this.api_public_item_root[%index];
|
||||
|
||||
%main_text = %this.api_main_item_text[%main_index];
|
||||
%main_repeat = %this.api_main_item_repeat[%main_index];
|
||||
|
||||
%branch_count = %this.api_main_item_branch_count[%main_text, %main_repeat];
|
||||
|
||||
if(%branch_count)
|
||||
{
|
||||
// get the branch index that corresponds to our target public index
|
||||
%branch_index = %this.api_branch_index[%index];
|
||||
|
||||
// make room for another branch item
|
||||
for(%i = %this.api_main_item_branch_count[%main_text, %main_repeat]; %i > %branch_index; %i--)
|
||||
{
|
||||
%this.api_branch_item_id[%main_text, %main_repeat, %i] = %this.api_branch_item_id[%main_text, %main_repeat, %i - 1];
|
||||
%this.api_branch_item_text[%main_text, %main_repeat, %i] = %this.api_branch_item_text[%main_text, %main_repeat, %i - 1];
|
||||
}
|
||||
|
||||
// insert the branch item
|
||||
%this.api_branch_item_id[%main_text, %main_repeat, %branch_index] = %id;
|
||||
%this.api_branch_item_text[%main_text, %main_repeat, %branch_index] = %text;
|
||||
|
||||
// increment the branch count
|
||||
%this.api_main_item_branch_count[%main_text, %main_repeat]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no existing items, so add our item here
|
||||
%this.api_branch_item_id[%main_text, %main_repeat, 0] = %id;
|
||||
%this.api_branch_item_text[%main_text, %main_repeat, 0] = %text;
|
||||
|
||||
// increment the branch count
|
||||
%this.api_main_item_branch_count[%main_text, %main_repeat]++;
|
||||
}
|
||||
|
||||
if( (%func !$= "") && (%text !$= "--") )
|
||||
{
|
||||
callback.add("LaunchMenuID_" @ %id @ "_Selected", %func);
|
||||
}
|
||||
|
||||
// refresh the launch menu (and the public item indices)
|
||||
LaunchToolbarDlg.onWake();
|
||||
}
|
||||
|
||||
|
||||
function LaunchToolbarMenu::insertSeparatorAt(%this, %index)
|
||||
{
|
||||
%this.insertItemAt(%index, "", "--");
|
||||
}
|
||||
|
||||
|
||||
function LaunchToolbarMenu::removeItemAt(%this, %index)
|
||||
{
|
||||
// get the main (root) item for this index
|
||||
%main_index = %this.api_public_item_root[%index];
|
||||
|
||||
if(%this.api_main_item_face[%main_index] == %index)
|
||||
{
|
||||
echo("Sorry, you can't remove any of the root Launch Menu items.");
|
||||
return;
|
||||
}
|
||||
|
||||
%main_text = %this.api_main_item_text[%main_index];
|
||||
%main_repeat = %this.api_main_item_repeat[%main_index];
|
||||
|
||||
%branch_count = %this.api_main_item_branch_count[%main_text, %main_repeat];
|
||||
|
||||
// get the branch index that corresponds to our target public index
|
||||
%branch_index = %this.api_branch_index[%index];
|
||||
|
||||
// remove this item
|
||||
for(%i = %branch_index; %i < %this.api_main_item_branch_count[%main_text, %main_repeat]; %i++)
|
||||
{
|
||||
%this.api_branch_item_id[%main_text, %main_repeat, %i] = %this.api_branch_item_id[%main_text, %main_repeat, %i + 1];
|
||||
%this.api_branch_item_text[%main_text, %main_repeat, %i] = %this.api_branch_item_text[%main_text, %main_repeat, %i + 1];
|
||||
}
|
||||
|
||||
// remove the previous last branch item (just a bit of cleanup)
|
||||
%this.api_branch_item_id[%main_text, %main_repeat, %i] = "";
|
||||
%this.api_branch_item_text[%main_text, %main_repeat, %i] = "";
|
||||
|
||||
// decrement the branch count
|
||||
%this.api_main_item_branch_count[%main_text, %main_repeat]--;
|
||||
|
||||
// shouldn't be necessary, but just in case:
|
||||
if(%this.api_main_item_branch_count[%main_text, %main_repeat] < 0)
|
||||
%this.api_main_item_branch_count[%main_text, %main_repeat] = 0;
|
||||
|
||||
// refresh the launch menu (and the public item indices)
|
||||
LaunchToolbarDlg.onWake();
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::removeSeparatorAt(%this, %index)
|
||||
{
|
||||
if(%this.api_public_item_text[%index] !$= "--")
|
||||
{
|
||||
echo("Target item isn't a separator. Nothing was removed.");
|
||||
return;
|
||||
}
|
||||
|
||||
%this.removeItemAt(%index);
|
||||
}
|
||||
|
||||
|
||||
package LaunchMenuOverrides
|
||||
{
|
||||
|
||||
function LaunchToolbarDlg::onWake(%this)
|
||||
{
|
||||
parent::onWake(%this);
|
||||
|
||||
if(!%this.api_awake)
|
||||
{
|
||||
%this.api_awake = true;
|
||||
callback.trigger(LaunchMenuReady);
|
||||
}
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::clear(%this)
|
||||
{
|
||||
for(%i = 0; %i < %this.api_main_item_count; %i++)
|
||||
{
|
||||
%text = %this.api_main_item_text[%i];
|
||||
%this.api_main_item_repeat_count[%text] = 0;
|
||||
}
|
||||
|
||||
%this.api_main_item_count = 0;
|
||||
%this.api_public_item_count = 0;
|
||||
|
||||
parent::clear(%this);
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::add(%this, %id, %text)
|
||||
{
|
||||
%main_index = %this.api_main_item_count + 0; // init to zero on first occurence
|
||||
|
||||
%repeat_counter = %this.api_main_item_repeat_count[%text] + 0;
|
||||
|
||||
%this.api_main_item_id[%main_index] = %id;
|
||||
%this.api_main_item_text[%main_index] = %text;
|
||||
%this.api_main_item_repeat[%main_index] = %repeat_counter;
|
||||
|
||||
%public_index = %this.api_public_item_count + 0;
|
||||
|
||||
// insert any branch items attached to this main item
|
||||
for(%i = 0; %i < %this.api_main_item_branch_count[%text, %repeat_counter]; %i++)
|
||||
{
|
||||
%branch_id = %this.api_branch_item_id[%text, %repeat_counter, %i];
|
||||
%branch_text = %this.api_branch_item_text[%text, %repeat_counter, %i];
|
||||
|
||||
// make this branch index accessible by the corresponding public index
|
||||
%this.api_branch_index[%public_index] = %i;
|
||||
|
||||
%this.api_public_item_id[%public_index] = %branch_id;
|
||||
%this.api_public_item_text[%public_index] = %branch_text;
|
||||
%this.api_public_item_root[%public_index] = %main_index;
|
||||
%public_index++;
|
||||
|
||||
if(%branch_text $= "--")
|
||||
parent::addSeparator(%this);
|
||||
else
|
||||
parent::add(%this, %branch_id, %branch_text);
|
||||
}
|
||||
|
||||
%this.api_public_item_id[%public_index] = %id;
|
||||
%this.api_public_item_text[%public_index] = %text;
|
||||
%this.api_public_item_root[%public_index] = %main_index;
|
||||
%this.api_main_item_face[%main_index] = %public_index;
|
||||
%public_index++;
|
||||
|
||||
parent::add(%this, %id, %text);
|
||||
|
||||
%this.api_main_item_count++;
|
||||
%this.api_public_item_count = %public_index;
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::addSeparator(%this)
|
||||
{
|
||||
%id = "";
|
||||
%text = "--";
|
||||
|
||||
%main_index = %this.api_main_item_count + 0; // init to zero on first occurence
|
||||
|
||||
%repeat_counter = %this.api_main_item_repeat_count[%text] + 0;
|
||||
|
||||
%this.api_main_item_id[%main_index] = %id;
|
||||
%this.api_main_item_text[%main_index] = %text;
|
||||
%this.api_main_item_repeat[%main_index] = %repeat_counter;
|
||||
|
||||
%public_index = %this.api_public_item_count + 0;
|
||||
|
||||
// insert any branch items attached to this main item
|
||||
for(%i = 0; %i < %this.api_main_item_branch_count[%text, %repeat_counter]; %i++)
|
||||
{
|
||||
%branch_id = %this.api_branch_item_id[%text, %repeat_counter, %i];
|
||||
%branch_text = %this.api_branch_item_text[%text, %repeat_counter, %i];
|
||||
|
||||
// make this branch index accessible by the corresponding public index
|
||||
%this.api_branch_index[%public_index] = %i;
|
||||
|
||||
%this.api_public_item_id[%public_index] = %branch_id;
|
||||
%this.api_public_item_text[%public_index] = %branch_text;
|
||||
%this.api_public_item_root[%public_index] = %main_index;
|
||||
%public_index++;
|
||||
|
||||
if(%branch_text $= "--")
|
||||
parent::addSeparator(%this);
|
||||
else
|
||||
parent::add(%this, %branch_id, %branch_text);
|
||||
}
|
||||
|
||||
%this.api_public_item_id[%public_index] = %id;
|
||||
%this.api_public_item_text[%public_index] = %text;
|
||||
%this.api_public_item_root[%public_index] = %main_index;
|
||||
%this.api_main_item_face[%main_index] = %public_index;
|
||||
%public_index++;
|
||||
|
||||
parent::addSeparator(%this);
|
||||
|
||||
%this.api_main_item_count++;
|
||||
%this.api_public_item_count = %public_index;
|
||||
}
|
||||
|
||||
function LaunchToolbarMenu::onSelect(%this, %id, %text)
|
||||
{
|
||||
parent::onSelect(%this, %id, %text);
|
||||
|
||||
callback.trigger(LaunchMenuItemSelected, %id, %text);
|
||||
callback.trigger("LaunchMenuID_" @ %id @ "_Selected", %text);
|
||||
}
|
||||
|
||||
};
|
||||
activatePackage(LaunchMenuOverrides);
|
||||
|
||||
//if(isObject(LaunchToolbarDlg))
|
||||
// LaunchToolbarDlg.onWake();
|
||||
249
docs/base/@vl2/z_scripts/support.vl2/support/list.cs
Normal file
249
docs/base/@vl2/z_scripts/support.vl2/support/list.cs
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
// #name = Data Struct - Linked List
|
||||
// #version = 1.0.1
|
||||
// #date = July 15, 2001
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Structure for fast adds and removes.
|
||||
// #status = Release
|
||||
|
||||
// It breaks ::delete() to have the class have a constructor function
|
||||
// in it's own namespace. So I put it in another one...
|
||||
|
||||
function Container::newList() {
|
||||
|
||||
%x = new ScriptObject() {
|
||||
class = List;
|
||||
head = "";
|
||||
tail = "";
|
||||
length = 0;
|
||||
};
|
||||
return %x;
|
||||
}
|
||||
|
||||
function List::newNode(%this) {
|
||||
|
||||
%x = new ScriptObject() {
|
||||
class = ListNode;
|
||||
next = "";
|
||||
prev = "";
|
||||
value = "";
|
||||
};
|
||||
return %x;
|
||||
}
|
||||
|
||||
//function ListNode::delete(%this, %flag) {
|
||||
//
|
||||
// if (!%flag) {
|
||||
// if (isObject(%this.value)) {
|
||||
// %this.value.delete();
|
||||
// }
|
||||
// %this.schedule(10,delete,1);
|
||||
// }
|
||||
// else parent::delete(%this);
|
||||
//}
|
||||
|
||||
|
||||
function List::removeAt(%this, %node) {
|
||||
|
||||
if (%node.class !$= ListNode) return;
|
||||
|
||||
if (%node.prev !$= "")
|
||||
%node.prev.next = %node.next;
|
||||
|
||||
if (%node.next !$="")
|
||||
%node.next.prev = %node.prev;
|
||||
|
||||
if (%node == %this.head) %this.head = %node.next;
|
||||
if (%node == %this.tail) %this.tail = %node.prev;
|
||||
|
||||
%node.delete();
|
||||
|
||||
%this.length--;
|
||||
}
|
||||
|
||||
function List::clear(%this) {
|
||||
|
||||
%node=%this.head;
|
||||
while (%node !$= "") {
|
||||
%tmp = %node;
|
||||
%node = %node.next;
|
||||
%tmp.delete();
|
||||
}
|
||||
}
|
||||
|
||||
function List::delete(%this,%flag) {
|
||||
|
||||
// The format here is VERY STRANGE.
|
||||
// the scheduled callback is needed to keep this from crashing T2.
|
||||
// Apparently it is bad for ::delete() to do work AND call its parent.
|
||||
// So I do the work, leave, then come back to call the parent, and that works.
|
||||
// Very, very ugly, and possibly a bug in T2.
|
||||
|
||||
if (!%flag) {
|
||||
%this.clear();
|
||||
%this.schedule(1,delete,1);
|
||||
}
|
||||
else parent::delete(%this);
|
||||
}
|
||||
|
||||
function List::nodeAt(%this, %index) {
|
||||
|
||||
if (%index < 0 || %index >= %this.length) return "";
|
||||
if (%index <= %this.length /2) {
|
||||
for(%node=%this.head; %node !$= ""; %node=%node.next) {
|
||||
if (%index == 0) return %node;
|
||||
%index--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
%idx = %this.length - %index - 1;
|
||||
for(%node=%this.tail; %node !$= ""; %node=%node.prev) {
|
||||
if (%idx == 0) return %node;
|
||||
%idx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function List::valueAt(%this, %index) {
|
||||
|
||||
return %this.nodeAt(%index).value;
|
||||
}
|
||||
|
||||
function List::insertAfter(%this, %node, %value) {
|
||||
|
||||
if (%node.class !$= "ListNode") return;
|
||||
|
||||
%newNode = %this.newNode();
|
||||
%newNode.value = %value;
|
||||
|
||||
if (%node.next !$= "") {
|
||||
%node.next.prev = %newNode;
|
||||
}
|
||||
%newNode.next = %node.next;
|
||||
|
||||
%node.next = %newNode;
|
||||
%newNode.prev = %node;
|
||||
|
||||
if (%node == %this.tail) %this.tail = %newNode;
|
||||
|
||||
%this.length++;
|
||||
return %newNode;
|
||||
}
|
||||
|
||||
function List::insertBefore(%this, %node, %value) {
|
||||
|
||||
if (%node.class !$= "ListNode") return;
|
||||
|
||||
%newNode = %this.newNode();
|
||||
%newNode.value = %value;
|
||||
|
||||
if (%node.prev !$= "") {
|
||||
%node.prev.next = %newNode;
|
||||
}
|
||||
%newNode.prev = %node.prev;
|
||||
|
||||
%node.prev = %newNode;
|
||||
%newNode.next = %node;
|
||||
|
||||
if (%node == %this.head) %this.head = %newNode;
|
||||
|
||||
%this.length++;
|
||||
return %newNode;
|
||||
}
|
||||
|
||||
function List::pushBack(%this,%value) {
|
||||
|
||||
%node = %this.newNode();
|
||||
%node.value = %value;
|
||||
|
||||
if (%this.length == 0) {
|
||||
%this.head = %this.tail = %node;
|
||||
}
|
||||
else {
|
||||
%node.prev = %this.tail;
|
||||
%this.tail.next = %node;
|
||||
%this.tail = %node;
|
||||
}
|
||||
|
||||
%this.length++;
|
||||
return %this.tail;
|
||||
}
|
||||
|
||||
function List::pushFront(%this,%value) {
|
||||
|
||||
%node = %this.newNode();
|
||||
%node.value = %value;
|
||||
|
||||
if (%this.length == 0) {
|
||||
%this.head = %this.tail = %node;
|
||||
}
|
||||
else {
|
||||
%node.next = %this.head;
|
||||
%this.head.prev = %node;
|
||||
%this.head = %node;
|
||||
}
|
||||
|
||||
%this.length++;
|
||||
return %this.head;
|
||||
}
|
||||
|
||||
function List::popBack(%this) {
|
||||
|
||||
if (%this.length == 0) return;
|
||||
|
||||
%tmp = %this.tail.prev;
|
||||
if (%tmp !$= "") {
|
||||
%tmp.next = "";
|
||||
}
|
||||
%val = %this.tail.value;
|
||||
%this.tail.delete();
|
||||
%this.tail = %tmp;
|
||||
%this.length--;
|
||||
|
||||
if (%this.length == 0) %this.head = "";
|
||||
return %val;
|
||||
}
|
||||
|
||||
function List::popFront(%this) {
|
||||
|
||||
if (%this.length == 0) return;
|
||||
|
||||
%tmp = %this.head.next;
|
||||
if (%tmp !$= "") {
|
||||
%tmp.prev = "";
|
||||
}
|
||||
%val = %this.head.value;
|
||||
%this.head.delete();
|
||||
%this.head = %tmp;
|
||||
%this.length--;
|
||||
|
||||
if (%this.length == 0) %this.tail = "";
|
||||
return %head;
|
||||
}
|
||||
|
||||
function List::size(%this) {
|
||||
|
||||
return %this.length;
|
||||
}
|
||||
|
||||
function List::findFirstIndex(%this, %value, %offset) {
|
||||
|
||||
if (%offset $= "") %offset = 0;
|
||||
return %this.findFirstNode(%value, %this.nodeAt(%offset));
|
||||
}
|
||||
|
||||
function List::findFirstNode(%this, %value, %node) {
|
||||
|
||||
if (%node $= "") %node = %this.head;
|
||||
else
|
||||
if (!isObject(%node) || (%node.class !$= "ListNode")) return -1;
|
||||
|
||||
for(%node=%node; %node !$= ""; %node=%node.next) {
|
||||
if (%node.value $= %value) return %node;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
559
docs/base/@vl2/z_scripts/support.vl2/support/loadout.cs
Normal file
559
docs/base/@vl2/z_scripts/support.vl2/support/loadout.cs
Normal file
|
|
@ -0,0 +1,559 @@
|
|||
// #name = loadout Support
|
||||
// #version = 0.1.1
|
||||
// #date = August 8, 2001
|
||||
// #author = Daniel Neilsen (aka Wizard_TPG)
|
||||
// #email = wizardsworld@bigpond.com
|
||||
// #web = http://www.tribalwar.com/wizard/
|
||||
// #description = Determines players current loadout status from HUD information
|
||||
// #category = Support
|
||||
// #status = release
|
||||
// #credit = Grenade tracking code by Ego, credited to Fragbait (integrated by UberGuy)
|
||||
// #credit = WeaponReceived callback idea by MadMonk
|
||||
// #include = support/callback.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Usage Notes and Examples:
|
||||
//
|
||||
// Callbacks included in this support script:
|
||||
// PlayerSpawn - called when player spawns.
|
||||
// WeaponChange - When player changes weapon. Returns new weapon as 1st variable.
|
||||
// PlayerUseInv - Player used the inventory station
|
||||
// PlayerDeath - Player died somehow. Could have changed teams or gone to obs.
|
||||
// MineUsed - A mine was removed from the players inventory either by use or otherwise
|
||||
// MineReceived - A mine was added to the players inventory
|
||||
// RepairKitUsed - A Repairkit was removed from the players inventory.
|
||||
// RepairKitReceived - A Repairkit was added to the players inventory.
|
||||
// BeaconUsed - A Beacon was removed from the players inventory.
|
||||
// BeaconReceived - A Beacon was added to the players inventory.
|
||||
// GrenadeUsed - A Grenade was removed from the players inventory.
|
||||
// GrenadeReceived - A Grenade was added to the players inventory.
|
||||
// BackpackReceived - The player received a backpack
|
||||
// BackpackDropped - The player's backpack was taken away
|
||||
// ModTypeChange - When you enter a server this callback returns mod name
|
||||
// WeaponReceived - A weapon has been added to your inventory. Returns weapon name and slot
|
||||
//
|
||||
//
|
||||
// Useful Functions in this support script:
|
||||
// loadout.isloadoutWeapon(%name); - Will return true or false if weapon is in players inv
|
||||
// loadout.getCurrentWeapon(); - Returns the name of the current weapon in players hand. "" for none.
|
||||
// loadout.getPreviousWeapon(); - Returns the name of the previously used weapon. "" for none
|
||||
// loadout.getWeaponAmmo(%name); - Returns the ammo amount for that weapon in players inv. -1 for infinite.
|
||||
// loadout.getPack(); - Returns name of current pack. "" for none.
|
||||
// loadout.getMineAmmo(); - Returns number of mines in players inv.
|
||||
// loadout.getRepairKit(); - Returns number of repairkits in players inv. (ie. 1 or 0)
|
||||
// loadout.getBeaconAmmo(); - Returns number of beacons in players inv.
|
||||
// loadout.getGrenadeAmmo(); - Returns number of grenades in players inv.
|
||||
// loadout.UseWeapon(%weapon); - Input the weapon name to load the correct weapon function
|
||||
// loadout.getGrenadeType(); - Returns the type of grenade in players inv.
|
||||
// loadout.getArmorType(); - Returns current type of armor (if mod with support).
|
||||
// loadout.getModType(); - Returns current server mod type.
|
||||
//
|
||||
//
|
||||
// Possible WeaponTypes Are:
|
||||
// Blaster
|
||||
// Plasma
|
||||
// Chaingun
|
||||
// Disc
|
||||
// GrenadeLauncher
|
||||
// SniperRifle
|
||||
// ELFGun
|
||||
// Mortar
|
||||
// MissileLauncher
|
||||
// ShockLance
|
||||
// TargetingLaser
|
||||
// RepairGun
|
||||
// ParticleGun - Shifter
|
||||
// HeaterGun - Shifter
|
||||
// RailGun - Shifter
|
||||
// Flamer - Shifter
|
||||
// EngineerRepairGun - Shifter
|
||||
// GravitronGun - Shifter
|
||||
// VoltProjector - Shifter
|
||||
// BoomStick - Shifter
|
||||
//
|
||||
// Note: All weapons from any mod should be fine
|
||||
//
|
||||
//
|
||||
//
|
||||
// Possible Grenade Types Are:
|
||||
// "Grenade"
|
||||
// "Whiteout Grenade"
|
||||
// "Concussion Grenade"
|
||||
// "Flare Grenade"
|
||||
// "Camera Grenade"
|
||||
//
|
||||
//
|
||||
// Possible Mine Types Are:
|
||||
// Mine
|
||||
//
|
||||
//
|
||||
// Possible Pack Types Are:
|
||||
// AmmoPack
|
||||
// CloakingPack`
|
||||
// EnergyPack
|
||||
// RepairPack
|
||||
// SatchelCharge
|
||||
// ShieldPack
|
||||
// InventoryDeployable
|
||||
// MotionSensorDeployable
|
||||
// PulseSensorDeployable
|
||||
// TurretOutdoorDeployable
|
||||
// TurretIndoorDeployable
|
||||
// SensorJammerPack
|
||||
// AABarrelPack
|
||||
// FusionBarrelPack
|
||||
// MissileBarrelPack
|
||||
// PlasmaBarrelPack
|
||||
// ELFBarrelPack
|
||||
// MortarBarrelPack
|
||||
// ThrusterPack - TAC2
|
||||
// MorphPack - Shifter
|
||||
// TelePack - Shifter
|
||||
// DetPack - Shifter
|
||||
// DeployableThumperPack - Shifter
|
||||
// heavydevistatorcannon - Shifter
|
||||
// heavyplasmacannon - Shifter
|
||||
// FFBeacon - Shifter
|
||||
// DeployableTurretPack - Shifter
|
||||
// DeployableLaserBarrelPack - Shifter
|
||||
// DeployableShockerBarrelPack - Shifter
|
||||
// CycloneLauncherPack - Shifter
|
||||
// ShieldBeacon - Shifter
|
||||
// FFCube - Shifter
|
||||
// JammerBeacon - Shifter
|
||||
// ForceFieldDeployable - Shifter
|
||||
// RepairBeaconDeployable - Shifter
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// Note: This script SHOULD work for mods as well.
|
||||
// I have only added mod weapon/pack names in here for TAC2 and Shifter although
|
||||
// other mods should also be fine.
|
||||
//
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
// UberGuy edit 01/25/03 - Ego's grenade support
|
||||
|
||||
loadout.grenadepickupText["some grenades"] = "Grenade";
|
||||
loadout.grenadepickupText["some flash grenades"] = "Whiteout Grenade";
|
||||
loadout.grenadepickupText["some concussion grenades"] = "Concussion Grenade";
|
||||
loadout.grenadepickupText["some flare grenades"] = "Flare Grenade";
|
||||
loadout.grenadepickupText["a deployable camera"] = "Deployable Camera";
|
||||
|
||||
loadout.command["Blaster"] = "useBlaster";
|
||||
loadout.command["Plasma"] = "usePlasma";
|
||||
loadout.command["Chaingun"] = "useChaingun";
|
||||
loadout.command["Disc"] = "useDisc";
|
||||
loadout.command["useGrenadeLauncher"] = "useGrenadeLauncher";
|
||||
loadout.command["SniperRifle"] = "useSniperRifle";
|
||||
loadout.command["ELFGun"] = "useELFGun";
|
||||
loadout.command["Mortar"] = "useMortar";
|
||||
loadout.command["MissileLauncher"] = "useMissileLauncher";
|
||||
loadout.command["TargetingLaser"] = "useTargetingLaser";
|
||||
loadout.command["ShockLance"] = "useShockLance";
|
||||
|
||||
package Inventory_Support
|
||||
{
|
||||
function clientCmdSetWeaponsHudItem(%slot, %ammoAmount, %addItem)
|
||||
{
|
||||
Parent::clientCmdSetWeaponsHudItem(%slot, %ammoAmount, %addItem);
|
||||
if(%addItem)
|
||||
loadout::addweapon(%this, %slot);
|
||||
else
|
||||
loadout::removeweapon(%this, %slot);
|
||||
}
|
||||
|
||||
|
||||
function clientCmdSetWeaponsHudAmmo(%slot, %ammoAmount)
|
||||
{
|
||||
Parent::clientCmdSetWeaponsHudAmmo(%slot, %ammoAmount);
|
||||
loadout.setWeaponAmmo(%slot, %ammoAmount);
|
||||
}
|
||||
|
||||
// Modified to work with v25026.015 (UberGuy)
|
||||
function clientCmdSetWeaponsHudActive(%slot, %ret, %vis)
|
||||
{
|
||||
Parent::clientCmdSetWeaponsHudActive(%slot, %ret, %vis);
|
||||
loadout.setCurrentWeapon(%slot);
|
||||
}
|
||||
|
||||
function clientCmdSetRepairReticle()
|
||||
{
|
||||
Parent::clientCmdSetRepairReticle();
|
||||
loadout.setCurrentWeapon(0, "RepairGun");
|
||||
}
|
||||
|
||||
function clientCmdSetWeaponsHudClearAll()
|
||||
{
|
||||
loadout.clearall();
|
||||
Parent::clientCmdSetWeaponsHudClearAll();
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
|
||||
function clientCmdSetBackpackHudItem(%num, %addItem)
|
||||
{
|
||||
if(%addItem) {
|
||||
loadout.addpack(%num);
|
||||
callback.trigger(BackpackReceived,loadout.pack); // UberGuy 01/27/03
|
||||
loadout.playerAtInvo = false;
|
||||
}
|
||||
else {
|
||||
if (!(loadout.playerAtInvo || loadout.playerDead || (loadout.pack !$= ""))) callback.trigger(BackPackDropped);
|
||||
loadout.clearpack();
|
||||
}
|
||||
Parent::clientCmdSetBackpackHudItem(%num, %addItem);
|
||||
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
|
||||
function clientCmdSetInventoryHudItem(%slot, %amount, %addItem)
|
||||
{
|
||||
// <grenType>
|
||||
loadout.grenType = "Grenade"; //Respawn grenade type - may be wrong in mods.
|
||||
loadout.grenRefreshSelected();
|
||||
// </grenType>
|
||||
callback.trigger(PlayerSpawn);
|
||||
Parent::clientCmdSetInventoryHudItem(%slot, %amount, %addItem);
|
||||
}
|
||||
|
||||
function clientCmdSetInventoryHudAmount(%slot, %amount)
|
||||
{
|
||||
loadout.setInvData(%slot, %amount);
|
||||
Parent::clientCmdSetInventoryHudAmount(%slot, %amount);
|
||||
}
|
||||
|
||||
function clientCmdSetInventoryHudClearAll()
|
||||
{
|
||||
loadout.PlayerDeath();
|
||||
Parent::clientCmdSetInventoryHudClearAll();
|
||||
}
|
||||
|
||||
function clientCmdSetArmorType(%type)
|
||||
{
|
||||
loadout.SetArmorType(%type);
|
||||
Parent::clientCmdSetArmorType(%type);
|
||||
}
|
||||
|
||||
// <grenType>
|
||||
function loadFavorite(%index, %echo)
|
||||
{
|
||||
parent::loadFavorite(%index, %echo);
|
||||
loadout.grenFavChange(%index);
|
||||
}
|
||||
|
||||
function addQuickPackFavorite(%pack, %item)
|
||||
{
|
||||
parent::addQuickPackFavorite(%pack, %item);
|
||||
if (stricmp(%item,"grenade") == 0) loadout.selectedGrenType = %pack;
|
||||
}
|
||||
|
||||
function addQuickChangeFavorite(%pack, %item){
|
||||
parent::addQuickChangeFavorite(%pack, %item);
|
||||
if (stricmp(%item,"grenade") == 0) loadout.selectedGrenType = %pack;
|
||||
}
|
||||
|
||||
function toggleCursorHuds(%val)
|
||||
{
|
||||
parent::toggleCursorHuds(%val);
|
||||
|
||||
if(%val $= 'inventoryScreen') loadout.grenRefreshSelected();
|
||||
}
|
||||
// </grenType>
|
||||
};
|
||||
|
||||
activatepackage(Inventory_Support);
|
||||
|
||||
if(!isObject(loadout))
|
||||
{
|
||||
new ScriptObject(loadout)
|
||||
{
|
||||
class = loadout;
|
||||
};
|
||||
}
|
||||
|
||||
function handleloadoutHUDMissionInfo(%msgType, %msgString, %missionname, %missiontype, %servername)
|
||||
{
|
||||
loadout.currentServerMod = getRecord( $ServerInfo, 2 );
|
||||
callback.trigger(ModTypeChange, loadout.currentServerMod);
|
||||
}
|
||||
addMessageCallback( 'MsgMissionDropInfo', handleloadoutHUDMissionInfo );
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
function loadout::addweapon(%this, %slot)
|
||||
{
|
||||
%this.playerdead = false;
|
||||
%name = $WeaponNames[%slot];
|
||||
$loadout::weapon[%name] = true;
|
||||
callback.trigger(WeaponReceived, %name, %slot);
|
||||
}
|
||||
|
||||
function loadout::removeweapon(%this, %slot)
|
||||
{
|
||||
%name = $WeaponNames[%slot];
|
||||
$loadout::weapon[%name] = false;
|
||||
}
|
||||
|
||||
function loadout::clearweapon(%this)
|
||||
{
|
||||
for(%slot=0; %slot<11; %slot++)
|
||||
{
|
||||
%name = $WeaponNames[%slot];
|
||||
$loadout::weapon[%name] = false;
|
||||
}
|
||||
}
|
||||
|
||||
function loadout::setCurrentWeapon(%this, %slot, %other)
|
||||
{
|
||||
%this.playerdead = false;
|
||||
if(%this.currentWeapon !$= "")
|
||||
%this.previousWeapon = %this.currentWeapon;
|
||||
if(%slot == -1)
|
||||
%this.currentWeapon = "";
|
||||
else if(%other $= "")
|
||||
%this.currentWeapon = $WeaponNames[%slot];
|
||||
else
|
||||
%this.currentWeapon = %other;
|
||||
callback.trigger(WeaponChange, %this.currentWeapon);
|
||||
}
|
||||
|
||||
function loadout::setWeaponAmmo(%this, %slot, %ammo)
|
||||
{
|
||||
%name = $WeaponNames[%slot];
|
||||
%this.weaponAmmo[%name] = %ammo;
|
||||
}
|
||||
|
||||
function loadout::isloadoutWeapon(%this, %name)
|
||||
{
|
||||
if(%name $= "")
|
||||
return false;
|
||||
|
||||
for(%slot=0; %slot<100; %slot++)
|
||||
{
|
||||
%namedata = $WeaponNames[%slot];
|
||||
if(%namedata $= "")
|
||||
return false;
|
||||
if(%name $= %namedata)
|
||||
{
|
||||
%val = $loadout::weapon[%namedata] == 1 ? 1 : 0;
|
||||
return %val;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadout::getCurrentWeapon(%this)
|
||||
{
|
||||
return %this.currentWeapon;
|
||||
}
|
||||
|
||||
function loadout::getPreviousWeapon(%this)
|
||||
{
|
||||
return %this.previousWeapon;
|
||||
}
|
||||
|
||||
function loadout::getWeaponAmmo(%this, %name)
|
||||
{
|
||||
%val = %this.weaponAmmo[%name] $= "" ? -1 : %this.weaponAmmo[%name];
|
||||
return %val;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================
|
||||
|
||||
function loadout::addpack(%this, %slot)
|
||||
{
|
||||
%this.pack = $BackpackHudData[%slot, itemDataName];
|
||||
}
|
||||
|
||||
function loadout::clearpack(%this)
|
||||
{
|
||||
%this.pack = "";
|
||||
}
|
||||
|
||||
function loadout::getPack(%this)
|
||||
{
|
||||
return %this.pack;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
function loadout::setInvData(%this, %slot, %ammo)
|
||||
{
|
||||
%this.playerdead = false;
|
||||
if(%slot $= "")
|
||||
return;
|
||||
|
||||
for(%num = 0; %num < $InventoryHudCount; %num++)
|
||||
{
|
||||
if($InventoryHudData[%num, slot] == %slot)
|
||||
{
|
||||
%numdata = %num;
|
||||
%num = $InventoryHudCount;
|
||||
}
|
||||
}
|
||||
%datatype = $InventoryHudData[%numdata, itemDataName];
|
||||
if(%datatype $= Mine)
|
||||
{
|
||||
%tmp = %this.mineAmmo;
|
||||
%this.mineAmmo = %ammo;
|
||||
if(%tmp > %ammo)
|
||||
callback.trigger(MineUsed);
|
||||
else if(%tmp < %ammo)
|
||||
callback.trigger(MineReceived);
|
||||
}
|
||||
else if(%datatype $= RepairKit)
|
||||
{
|
||||
%tmp = %this.repairKit;
|
||||
%this.repairKit = %ammo;
|
||||
if(%tmp > %ammo)
|
||||
callback.trigger(RepairKitUsed);
|
||||
else if(%tmp < %ammo)
|
||||
callback.trigger(RepairKitReceived);
|
||||
}
|
||||
else if(%datatype $= Beacon)
|
||||
{
|
||||
%tmp = %this.beaconAmmo;
|
||||
%this.beaconAmmo = %ammo;
|
||||
if(%tmp > %ammo)
|
||||
callback.trigger(BeaconUsed);
|
||||
else if(%tmp < %ammo)
|
||||
callback.trigger(BeaconReceived);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%ammo >= 0)
|
||||
{
|
||||
%tmp = %this.grenAmmo;
|
||||
%this.grenAmmo = %ammo;
|
||||
if(%tmp > %ammo)
|
||||
callback.trigger(GrenadeUsed);
|
||||
else if(%tmp < %ammo)
|
||||
callback.trigger(GrenadeReceived);
|
||||
//%this.grenType = %datatype; //
|
||||
}
|
||||
else if(%datatype $= %this.grenType)
|
||||
{
|
||||
%tmp = %this.grenAmmo;
|
||||
%this.grenAmmo = %ammo;
|
||||
if(%tmp > %ammo)
|
||||
callback.trigger(GrenadeUsed);
|
||||
else if(%tmp < %ammo)
|
||||
callback.trigger(GrenadeReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadout::clearInvData(%this)
|
||||
{
|
||||
%this.mineAmmo = 0;
|
||||
%this.repairKit = 0;
|
||||
%this.beaconAmmo = 0;
|
||||
%this.grenType = "";
|
||||
%this.grenAmmo = 0;
|
||||
}
|
||||
|
||||
function loadout::getMineAmmo(%this)
|
||||
{
|
||||
return %this.mineAmmo;
|
||||
}
|
||||
|
||||
function loadout::getRepairKit(%this)
|
||||
{
|
||||
return %this.repairKit;
|
||||
}
|
||||
|
||||
function loadout::getBeaconAmmo(%this)
|
||||
{
|
||||
return %this.beaconAmmo;
|
||||
}
|
||||
|
||||
function loadout::getGrenadeType(%this)
|
||||
{
|
||||
return %this.grenType;
|
||||
}
|
||||
|
||||
function loadout::getGrenadeAmmo(%this)
|
||||
{
|
||||
return %this.grenAmmo;
|
||||
}
|
||||
|
||||
function loadout::getSelectedGrenadeType(%this)
|
||||
{
|
||||
return %this.selectedGrenType;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================
|
||||
|
||||
function loadout::clearall(%this)
|
||||
{
|
||||
%this.clearweapon();
|
||||
//%this.clearpack();
|
||||
%this.clearInvData();
|
||||
if(!%this.playerdead)
|
||||
%this.playerAtInvo = true;
|
||||
// <grenType>
|
||||
%this.grenType = %this.selectedGrenType;
|
||||
// </grenType>
|
||||
callback.trigger(PlayerUseInv);
|
||||
}
|
||||
|
||||
function loadout::PlayerDeath(%this)
|
||||
{
|
||||
%this.playerdead = true;
|
||||
%this.clearall();
|
||||
callback.trigger(PlayerDeath);
|
||||
}
|
||||
|
||||
function loadout::UseWeapon(%this, %weapon)
|
||||
{
|
||||
%cmd = loadout.command[%weapon];
|
||||
if ($cmd $= "") use(%weapon);
|
||||
else call(%cmd,true);
|
||||
}
|
||||
|
||||
// <grenType>
|
||||
function loadout::grenRefreshSelected(%this)
|
||||
{
|
||||
for (%i = 1; %i < $Hud['inventoryScreen'].count; %i++)
|
||||
{
|
||||
%type = $Hud['inventoryScreen'].data[%i, 1].type;
|
||||
%equipment = $Hud['inventoryScreen'].data[%i, 1].getValue();
|
||||
if(%type $= "Grenade") %this.selectedGrenType = %equipment;
|
||||
}
|
||||
}
|
||||
|
||||
function loadout::grenFavChange(%this)
|
||||
{
|
||||
%this.grenSelectedFav = $pref::Favorite[$pref::FavCurrentSelect];
|
||||
|
||||
for (%i = 0; %i < getFieldCount(%this.grenSelectedFav); %i++)
|
||||
{
|
||||
%type = getField(%this.grenSelectedFav, %i);
|
||||
%equipment = getField(%this.grenSelectedFav, %i++);
|
||||
if(%type $= "Grenade") %this.selectedGrenType = %equipment;
|
||||
}
|
||||
}
|
||||
|
||||
function handlePickedUpMessage(%msgType, %msgText, %itemText)
|
||||
{
|
||||
if (loadout.grenadepickupText[%itemtext] !$= "")
|
||||
loadout.grenType = loadout.grenadepickupText[%itemtext];
|
||||
}
|
||||
|
||||
addMessageCallback('MsgItemPickup', handlePickedUpMessage);
|
||||
// </grenType>
|
||||
|
||||
//==========================================
|
||||
// Mod Functions
|
||||
|
||||
function loadout::getModType(%this)
|
||||
{
|
||||
return %this.currentServerMod;
|
||||
}
|
||||
148
docs/base/@vl2/z_scripts/support.vl2/support/map.cs
Normal file
148
docs/base/@vl2/z_scripts/support.vl2/support/map.cs
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
// #name = Data Struct - Map
|
||||
// #version = 1.0.9
|
||||
// #date = July 15, 2001
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Structure for fast lookup by key.
|
||||
// #status = Release
|
||||
// #include = support/list.cs
|
||||
// #include = support/vector.cs
|
||||
|
||||
function Container::newListMap() {
|
||||
|
||||
%x = new ScriptObject() {
|
||||
class = ListMap;
|
||||
superClass = Map;
|
||||
keys = Container::newList();
|
||||
};
|
||||
return %x;
|
||||
}
|
||||
|
||||
function Container::newVectorMap() {
|
||||
|
||||
%x = new ScriptObject() {
|
||||
class = VectorMap;
|
||||
superClass = Map;
|
||||
keys = Container::newVector();
|
||||
};
|
||||
return %x;
|
||||
}
|
||||
|
||||
function ListMap::hasKey(%this, %key) {
|
||||
|
||||
//return (%this.keys.findFirstIndex(%key) != -1);
|
||||
return (%this.keyLst[%key] !$= "");
|
||||
}
|
||||
|
||||
function VectorMap::hasKey(%this, %key) {
|
||||
|
||||
return (%this.keyMap[%key] !$= "");
|
||||
}
|
||||
|
||||
// Expensive function.
|
||||
// I could really use a for_each here, but I don't know if it's worth the overhead.
|
||||
function ListMap::hasValue(%this, %value) {
|
||||
|
||||
for(%node=%keys.head; %node !$= ""; %node=%node.next) {
|
||||
if (%this.keyLst[%node.value] $= %value) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function VectorMap::hasValue(%this, %value) {
|
||||
|
||||
%s = %keys.size();
|
||||
for(%i = 0; %i < %s; %i++) {
|
||||
if (%this.keyLst[%keys.valueAt(%i)] $= %value) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function ListMap::add(%this, %key, %value) {
|
||||
|
||||
%retVal = 0;
|
||||
if (%this.keyLst[%key] $= "") {
|
||||
%this.keyLst[%key] = %this.keys.pushBack(%key);
|
||||
%retVal = 1;
|
||||
}
|
||||
%this.keyMap[%key] = %value;
|
||||
return %retVal;
|
||||
}
|
||||
|
||||
function VectorMap::add(%this, %key, %value) {
|
||||
|
||||
%retVal = 0;
|
||||
if (%this.keyMap[%key] $= "") {
|
||||
%this.keys.pushBack(%key);
|
||||
%retVal = 1;
|
||||
}
|
||||
%this.keyMap[%key] = %value;
|
||||
return %retVal;
|
||||
}
|
||||
|
||||
function ListMap::remove(%this, %key) {
|
||||
|
||||
if (%this.keyLst[%key] !$= "") {
|
||||
%this.keys.removeAt(%this.keyLst[%key]);
|
||||
%this.keyList[%key] = "";
|
||||
%this.keyMap[%key] = "";
|
||||
}
|
||||
}
|
||||
|
||||
function VectorMap::remove(%this, %key) {
|
||||
|
||||
if (%this.hasKey(%key)) {
|
||||
%idx = %this.keys.findFirstIndex(%key);
|
||||
%this.keys.removeAt(%idx);
|
||||
%this.keyMap[%key] = "";
|
||||
}
|
||||
}
|
||||
|
||||
function Map::clear(%this) {
|
||||
|
||||
while (%this.keys.size()) {
|
||||
%this.remove(%this.keys.valueAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
function Map::delete(%this, %flag) {
|
||||
|
||||
if (!%flag) {
|
||||
%this.keys.delete();
|
||||
%this.schedule(1,delete,1);
|
||||
}
|
||||
else parent::delete(%this);
|
||||
}
|
||||
|
||||
function Map::value(%this,%key) {
|
||||
|
||||
return %this.keyMap[%key];
|
||||
}
|
||||
|
||||
function Map::incrementValue(%this,%key) {
|
||||
|
||||
return %this.keyMap[%key]++;
|
||||
}
|
||||
|
||||
function Map::decrementValue(%this,%key) {
|
||||
|
||||
return %this.keyMap[%key]--;
|
||||
}
|
||||
|
||||
function Map::valueAt(%this,%index) {
|
||||
|
||||
return %this.keyMap[%this.keys.valueAt(%index)];
|
||||
}
|
||||
|
||||
function Map::size(%this) {
|
||||
|
||||
return %this.keys.size();
|
||||
}
|
||||
|
||||
function Map::keys(%this) {
|
||||
|
||||
return %this.keys;
|
||||
}
|
||||
127
docs/base/@vl2/z_scripts/support.vl2/support/menu_system.cs
Normal file
127
docs/base/@vl2/z_scripts/support.vl2/support/menu_system.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
// #name = Menu System
|
||||
// #version = 1.02
|
||||
// #date = 1/5/2002 4:50PM
|
||||
// #status = release
|
||||
// #author = |Rx|Diogenes
|
||||
// #warrior = Diogenes
|
||||
// #email = diogenes@tribalpharmacy.com
|
||||
// #web = http://dioscripts.tribes-universe.com
|
||||
// #description = CenterPrint Menus just like T1 Stripped. This script is a T2 port of MrPoop's original MenuSystem.cs
|
||||
// #category = Support
|
||||
// #credit = MrPoop
|
||||
|
||||
//Menu System
|
||||
//Using and abusing the remmoteCP function to bend it to my will - AND - to create my own menu system
|
||||
|
||||
//
|
||||
// So here's the quick and dirty for using this support script:
|
||||
//
|
||||
// A menu starts off by using the MS::NewMenu(%menuName) function, that same function can also
|
||||
// be used to reset a menu. From there you will add options to it using the
|
||||
// MS::AddChoice(%menuName, %key, %title, %function) function, declaring the menu you're adding
|
||||
// your choice to, the key that option will be assigned to, the displayed text for that option,
|
||||
// and finally the function it will execute of the user chooses it.
|
||||
//
|
||||
// To call a menu you've created, simply use the MS::Display(%menuName,%lines) function with
|
||||
// your menuname. The %lines input is an optional override if you want to adjust the size of the menu,
|
||||
// instead of it being calculated automatically.
|
||||
//
|
||||
|
||||
|
||||
//For some strange reason T2 only defaults for centerprinting of up to 3 lines. By adding the following, we're able to expand on that (I used 30 as my number)
|
||||
for(%i = 4; %i <= 31; %i++) {
|
||||
$CenterPrintSizes[%i] = $CenterPrintSizes[%i-1] +16;
|
||||
}
|
||||
|
||||
|
||||
//Create a new menu
|
||||
function MS::NewMenu(%menuName) {
|
||||
//Create the new menu and be sure to overwrite any menu info that may be there.
|
||||
//This will allow you to rewrite menus on the fly if you wish to do so.
|
||||
%menuName = strreplace(%menuName, " ", "_");
|
||||
DeleteVariables("$MenSys"@%menuName@"*");
|
||||
$MenSys[%menuName] = %menuName;
|
||||
}
|
||||
|
||||
//Add a choice to a menu
|
||||
function MS::AddChoice(%menuName, %key, %title, %function) {
|
||||
%menuName = strreplace(%menuName, " ", "_");
|
||||
//If the actionMap doesnt exist, make it
|
||||
if(!isObject($MenSys[%menuname])) {
|
||||
new actionMap(%MenuName);
|
||||
%MenuName.bindCmd(keyboard0, "escape", "MS::Do();", "");
|
||||
}
|
||||
//Edit the actionMap for the menu
|
||||
%tmp = $MenSys[%menuName, Item]++;
|
||||
$MenSysFunctionNum++;
|
||||
$MenSys[%menuName, %tmp] = "<COLOR:00FF2A>"@%key@". <COLOR:FFFFFF>"@%title;
|
||||
$MenSysFunction[$MenSysFunctionNum] = %function;
|
||||
%MenuName.bindCmd(keyboard0, %key, "MS::Do("@$MenSysFunctionNum@");", "MS::Break();");
|
||||
}
|
||||
|
||||
//Dummny break function. This keeps from mixing up the keymaps.
|
||||
function MS::Break() { }
|
||||
|
||||
function MS::AddMenu(%parentMenu, %key, %menuName) {
|
||||
//If the actionMap doesnt exist, make it
|
||||
%menuName = strreplace(%menuName, " ", "_");
|
||||
%parentMenu = strreplace(%parentMenu, " ", "_");
|
||||
if(!$MenSys[%parentMenu, actionMap]) {
|
||||
new actionMap(%MenuName);
|
||||
$MenSys[%parentMenu, actionMap] = "TRUE";
|
||||
%MenuName.bindCmd(keyboard0, "escape", "MS::Do();", "");
|
||||
}
|
||||
//Edit the actionMap for the menu
|
||||
%tmp = $MenSys[%parentMenu, Item]++;
|
||||
$MenSys[%parentMenu, %tmp] = "<COLOR:00FF2A>"@%key@". <COLOR:FFFFFF>"@%menuName;
|
||||
%MenuName.bindCmd(keyboard0, %key, "MS::Display("@%menuName@");", "MS::Break();");
|
||||
}
|
||||
|
||||
function MS::Display(%menuName,%lines) {
|
||||
%menuName = strreplace(%menuName, " ", "_");
|
||||
if($MenSys[%menuName] !$= "") {
|
||||
// && %menuName !$= $MenSysCurrentMenu
|
||||
%text = "\t<JUST:LEFT><COLOR:FFFFFF><font:arial Bold:18>"@ %menuName @"\n<JUST:CENTER><font:arial:15>";
|
||||
for(%i = 1; %i <= $MenSys[%menuName, Item]; %i++) {
|
||||
%text = %text@"\t\t"@$MenSys[%menuName, %i]@"\n";
|
||||
}
|
||||
//Dio: T2 CenterPrinting doesn't really center itself on the screen. I added the following to do so.
|
||||
%x = firstWord(CenterPrintDlg.position);
|
||||
%y = (getWord(getresolution(), 1) / 2) - ($CenterPrintSizes[%i]/2) ;
|
||||
CenterPrintDlg.setposition(%x,%y);
|
||||
if(%lines){
|
||||
%i = %lines;
|
||||
}
|
||||
clientCmdCenterPrint(%text,0,%i);
|
||||
//If a current menu map is up, we need to remove it
|
||||
if($MenSysCurrentMenu !$= "" && $MenSysCurrentMenu !$= %menuName) {$MenSysCurrentMenu.pop(); }
|
||||
%MenuName.push();
|
||||
$MenSysCurrentMenu = %menuName;
|
||||
}
|
||||
else {
|
||||
echo("Invalid menu call." @ $MenSys[%menuName] @" Menu does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
function MS::Do(%functionNum) {
|
||||
clientCmdClearCenterPrint();
|
||||
if($MenSysCurrentMenu !$= ""){
|
||||
$MenSysCurrentMenu.pop();
|
||||
}
|
||||
$MenSysCurrentMenu = "";
|
||||
if($MenSysFunction[%functionNum] !$= ""){
|
||||
eval($MenSysFunction[%functionNum]);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to add something to catch respawns, since they screw up our action maps.
|
||||
package MenuSystem {
|
||||
|
||||
function clientCmdSetInventoryHudClearAll(%val){
|
||||
parent::clientCmdSetInventoryHudClearAll(%val);
|
||||
MS::Do();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
activatepackage(MenuSystem);
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
// #name = Mission Callbacks
|
||||
// #version = 1.0.1
|
||||
// #date = September 6, 2001
|
||||
// #author = Daniel Neilsen
|
||||
// #warrior = Wizard_TPG
|
||||
// #email = wizardsworld@bigpond.com
|
||||
// #web = http://mods.tribalwar.com/wizard/
|
||||
// #description = Adds some basic mission callbacks
|
||||
// #status = release
|
||||
// #include = support/callback.cs
|
||||
// #include = support/player_support.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Usage Notes and Examples:
|
||||
//
|
||||
// Callbacks included in this support script:
|
||||
//
|
||||
// onMatchStart - Match Start
|
||||
// onMissionEnd - Mission End
|
||||
// onClearDebrief - Debrief screen is cleared
|
||||
// onGameOver - Map ended for any reason (vote, etc.) //UberGuy
|
||||
// onMissionDropInfo - Mission Data is recieved
|
||||
// onSupportTimerUpdate - This occurs every 20 seconds when the timer is updated
|
||||
// onClientDrop - Client dropped. Includes variables %clientname & %clientid
|
||||
// onUserClientDrop - The user client dropped. Includes variables %clientname & %clientid
|
||||
// onClientJoin - Client joined. Includes variables %clientname & %clientid
|
||||
// onUserClientJoin - The users client has joined a game. Includes variables %clientname & %clientid
|
||||
//
|
||||
//
|
||||
//
|
||||
// Useful Functions in this support script:
|
||||
//
|
||||
// MissionCallback.getMissionName(); - Returns mission name
|
||||
// MissionCallback.getMissionType(); - Returns mission type (ie. CTF, etc)
|
||||
// MissionCallback.getServerName(); - Returns server name
|
||||
// MissionCallback.getServerAddress(); - Returns server address
|
||||
// MissionCallback.getServerMod(); - Returns server mod
|
||||
// MissionCallback.getServerMod(); - Returns server mod name (ie, base, bwadmin, tac)
|
||||
// MissionCallback.getServerType(); - Returns server type (ie. linux, etc)
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
if(!isObject(MissionCallback))
|
||||
{
|
||||
new ScriptObject(MissionCallback)
|
||||
{
|
||||
class = MissionCallback;
|
||||
};
|
||||
}
|
||||
|
||||
function handleMissionCallbackMissionStart (%msgType, %msgString)
|
||||
{
|
||||
if(strstr(%msgString, "Match started!") == -1)
|
||||
return;
|
||||
callback.trigger(onMatchStart);
|
||||
}
|
||||
addMessageCallback( 'MsgMissionStart', handleMissionCallbackMissionStart );
|
||||
|
||||
function handleMissionCallbackMissionEnd (%msgType, %msgString, %seconds)
|
||||
{
|
||||
if(%seconds)
|
||||
return;
|
||||
callback.trigger(onMissionEnd);
|
||||
}
|
||||
addMessageCallback( 'MsgMissionEnd', handleMissionCallbackMissionEnd );
|
||||
|
||||
// UberGuy 10/03/2002
|
||||
function handleMissionCallbackGameOver (%msgType, %msgString, %seconds)
|
||||
{
|
||||
callback.trigger(onGameOver);
|
||||
}
|
||||
addMessageCallback( 'MsgGameOver', handleMissionCallbackGameOver );
|
||||
|
||||
function handleMissionCallbackClearDebrief(%msgType, %msgString)
|
||||
{
|
||||
callback.trigger(onClearDebrief);
|
||||
}
|
||||
addMessageCallback( 'MsgClearDebrief',handleMissionCallbackClearDebrief );
|
||||
|
||||
function handleMissionCallbackMissionInfo(%msgType, %msgString, %missionname, %missiontype, %servername)
|
||||
{
|
||||
MissionCallback.MissionName = %missionname;
|
||||
MissionCallback.MissionType = %missiontype;
|
||||
MissionCallback.ServerName = %servername;
|
||||
MissionCallback.ServerAddress = getRecord( $ServerInfo, 1 );
|
||||
MissionCallback.ServerMod = getRecord( $ServerInfo, 2 );
|
||||
MissionCallback.ServerType = getRecord( $ServerInfo, 3 );
|
||||
callback.trigger(onMissionDropInfo);
|
||||
}
|
||||
addMessageCallback( 'MsgMissionDropInfo', handleMissionCallbackMissionInfo );
|
||||
|
||||
function handleMissionCallbackTimer(%msgType, %msgString, %timelimit, %curTimeLeftMS)
|
||||
{
|
||||
callback.trigger(onSupportTimerUpdate);
|
||||
}
|
||||
addMessageCallback( 'MsgSystemClock', handleMissionCallbackTimer );
|
||||
|
||||
function handleMissionCallbackClientDrop (%msgType, %msgString, %clientname, %clientid)
|
||||
{
|
||||
callback.trigger(onClientDrop, %clientname, %clientid);
|
||||
}
|
||||
addMessageCallback( 'MsgClientDrop', handleMissionCallbackClientDrop );
|
||||
|
||||
function handleMissionCallbackClientJoined (%msgType, %msgString, %clientName, %clientid)
|
||||
{
|
||||
if (strstr(%msgString, "Welcome to Tribes2") == -1)
|
||||
callback.trigger(onClientjoin, %clientname, %clientid);
|
||||
else
|
||||
callback.trigger(onUserClientJoin, %clientname, %clientid);
|
||||
}
|
||||
addMessageCallback( 'MsgClientJoin', handleMissionCallbackClientJoined );
|
||||
|
||||
|
||||
package mission_callbacks
|
||||
{
|
||||
function DisconnectedCleanup()
|
||||
{
|
||||
%name = PlayerList.getMyName();
|
||||
%id = PlayerList.getMyID();
|
||||
callback.trigger(onUserClientDrop, %name, %id);
|
||||
parent::DisconnectedCleanup();
|
||||
}
|
||||
};
|
||||
activatepackage(mission_callbacks);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Server Data
|
||||
|
||||
function MissionCallback::getMissionName(%this)
|
||||
{
|
||||
return %this.MissionName;
|
||||
}
|
||||
|
||||
function MissionCallback::getMissionType(%this)
|
||||
{
|
||||
return %this.MissionType;
|
||||
}
|
||||
|
||||
function MissionCallback::getServerName(%this)
|
||||
{
|
||||
return %this.ServerName;
|
||||
}
|
||||
|
||||
function MissionCallback::getServerAddress(%this)
|
||||
{
|
||||
return %this.ServerAddress;
|
||||
}
|
||||
|
||||
function MissionCallback::getServerMod(%this)
|
||||
{
|
||||
return %this.ServerMod;
|
||||
}
|
||||
|
||||
function MissionCallback::getServerType(%this)
|
||||
{
|
||||
return %this.ServerType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
37
docs/base/@vl2/z_scripts/support.vl2/support/mute_tools.cs
Normal file
37
docs/base/@vl2/z_scripts/support.vl2/support/mute_tools.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// #name = Muting Tools
|
||||
// #version = 0.4.1
|
||||
// #date = April 24, 2001
|
||||
// #category = Support
|
||||
// #credit = Robert blanchet (aka xgalaxy)
|
||||
// #author = Jason "VeKToR" Gill
|
||||
// #email = xgalaxy@home.com
|
||||
// #email = vektor@linux.ca
|
||||
// #warrior = VeKToR++
|
||||
// #description = Adds functions to help mute messages
|
||||
// #status = release
|
||||
// #include = support/callback.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
package mutetools
|
||||
{
|
||||
function defaultMessageCallback(%msgType, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
%callbackname = "Callback" @ detag(%msgType);
|
||||
callback.trigger(%callbackname, %msgtype, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
|
||||
if(!callback.returned(%callbackname, mute))
|
||||
parent::defaultMessageCallback(%msgType, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
|
||||
}
|
||||
|
||||
function addMessageHudLine(%text)
|
||||
{
|
||||
callback.trigger(msgText, %text);
|
||||
|
||||
if(!callback.returned(msgText, mute))
|
||||
parent::addMessageHudLine(%text);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
activatepackage(mutetools);
|
||||
55
docs/base/@vl2/z_scripts/support.vl2/support/object_tools.cs
Normal file
55
docs/base/@vl2/z_scripts/support.vl2/support/object_tools.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// #name = Object Tools
|
||||
// #version = 0.0.1
|
||||
// #date = November 25, 2000
|
||||
// #category = Support
|
||||
// #author = Lorne Laliberte
|
||||
// #warrior = Writer
|
||||
// #email = t2beta@cdnwriter.com
|
||||
// #web = http://www.t2scripts.com
|
||||
// #web = http://www.cdnwriter.com
|
||||
// #description = Adds new functions to work with objects
|
||||
// #status = beta
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
// find the first object in a group whose property (%property) matches %value,
|
||||
// optionally using %operator to test %value against the value of the %property property
|
||||
// returns the object ID (pointer) of the object if found, otherwise ""
|
||||
//
|
||||
// syntax: <groupobject>.findObjectByProperty(<property to test>, <value to search for> [, <operator to test with>])
|
||||
//
|
||||
function SimObject::findObjectByProperty(%this, %property, %value, %operator)
|
||||
{
|
||||
// always buckle up...
|
||||
if(%property $= "")
|
||||
return "";
|
||||
|
||||
// set default operator if none given
|
||||
if(%operator $= "")
|
||||
%operator = "$=";
|
||||
|
||||
// is this the object we're looking for?
|
||||
eval("%test = (" @ %this @ "." @ %property @ " " @ %operator @ " \"" @ %value @ "\");");
|
||||
|
||||
if(%test)
|
||||
return %this; // desired object found -- note this only finds the "first match"
|
||||
|
||||
// this object doesn't meet the criteria, so check to see if it contains any other
|
||||
// objects, and test all the objects it contains
|
||||
%i = 0;
|
||||
while(%i < %this.getcount())
|
||||
{
|
||||
%r = %this.getObject(%i).findObjectByProperty(%property, %value, %operator);
|
||||
|
||||
// desired object found -- note this is only finds the "first match"
|
||||
if(%r)
|
||||
return %r;
|
||||
|
||||
%i++;
|
||||
}
|
||||
|
||||
// no objects met the criteria
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
611
docs/base/@vl2/z_scripts/support.vl2/support/player_support.cs
Normal file
611
docs/base/@vl2/z_scripts/support.vl2/support/player_support.cs
Normal file
|
|
@ -0,0 +1,611 @@
|
|||
// #name = Player support
|
||||
// #version = 0.0.7
|
||||
// #date = June 8, 2001
|
||||
// #author = Jason "VeKToR" Gill
|
||||
// #warrior = VeKToR++
|
||||
// #email = vektor@linux.ca
|
||||
// #web = http://scripts.tribalwar.com/vektor
|
||||
// #description = Provides a convenient api for getting info about players.
|
||||
// #status = release
|
||||
|
||||
// ----------------------------------------
|
||||
// Documentation
|
||||
// ----------------------------------------
|
||||
// This script provides a convenient interface for T2 scripters to look up
|
||||
// information about players. You could do most of the stuff in this script
|
||||
// without it, but it's a lot more convenient this way :)
|
||||
// This script is little more than a nice looking interface to data the
|
||||
// client already stores.
|
||||
//
|
||||
// First up are the MOST convenient functions. These allow you to get info
|
||||
// about a player, given you know at least one other piece of info about
|
||||
// them, such as their Name, ClientID, TargetID, GUID, Index number.
|
||||
//
|
||||
// The functions are relatively self-explainatory.
|
||||
// They're all named in a consistent fashion, like:
|
||||
// PlayerList.get___By___
|
||||
// The blanks are filled in with the name of the information you want, and
|
||||
// the piece of information you want to use to look it up, respectively.
|
||||
// For example, PlayerList.GetNameByID would look up a player's name based on
|
||||
// his/her clientID. All these functions are named in this format.
|
||||
// Note - a return value of $PLAYER_ERROR indicates an error of some kind
|
||||
// occured. You should probably test for this value unless you're certain your
|
||||
// function call will result in valid information ;)
|
||||
// Additionally, a couple of these functions have special return values.
|
||||
//
|
||||
// First off, the getNetInfoBy* functions will return Ping AND Packet loss
|
||||
// seperated by a space in the same function call. I did this to prevent
|
||||
// additional unnecessary functions (heck, there's probably too many as it
|
||||
// stands). An example of a return value from a NetInfo function is:
|
||||
// "237 1", where 237 is the player's ping, and 1 is his packet loss.
|
||||
// These can be seperated using the getword function.
|
||||
//
|
||||
// Second, the getFlagsBy* functions will return a BITFIELD representing the
|
||||
// 4 player flags (smurf, admin, superadmin, ai).
|
||||
// An easy way to extract info from these flags is accomplished using several
|
||||
// global "flags" this script defines:
|
||||
// $PLAYER_SMURF - is the player using an alias?
|
||||
// $PLAYER_ADMIN - is the player an admin?
|
||||
// $PLAYER_SUPERADMIN - is the player a superadmin?
|
||||
// $PLAYER_AI - is the player a bot?
|
||||
//
|
||||
// To check any of these flags, merely AND it with the return value - if the
|
||||
// result is nonzero, the flag is set, otherwise, it's not. Here's an example:
|
||||
//
|
||||
// %flags = PlayerList.getFlagsByID(4100);
|
||||
// if (%flags & $PLAYER_SMURF)
|
||||
// echo("This player is a smurf!");
|
||||
//
|
||||
// NEW:
|
||||
// In order for player scores/pings/packetloss, etc. to be updated, you must
|
||||
// first request this information from the server - otherwise, you'll just get
|
||||
// the same info as the last time it was updated.
|
||||
// Be careful about how fast you refresh it, doing it too often can smack down
|
||||
// anyone on a modem running your script. Anyway, the command to update the
|
||||
// player info is:
|
||||
// commandToServer('getScores');
|
||||
//
|
||||
// Without further ado, here's the list of convenience functions:
|
||||
//
|
||||
// These functions get player info, if you know his/her detagged name.
|
||||
// PlayerList.getIDByName(%value);
|
||||
// PlayerList.getTargetIDByName(%value);
|
||||
// PlayerList.getGUIDByName(%value);
|
||||
// PlayerList.getTeamByName(%value);
|
||||
// PlayerList.getScoreByName(%value);
|
||||
// PlayerList.getNetInfoByName(%value);
|
||||
// PlayerList.getFlagsByName(%value);
|
||||
//
|
||||
// These functions get player info, if you know his/her ClientID
|
||||
// PlayerList.getNameByID(%value);
|
||||
// PlayerList.getTargetIDByID(%value);
|
||||
// PlayerList.getGUIDByID(%value);
|
||||
// PlayerList.getTeamByID(%value);
|
||||
// PlayerList.getScoreByID(%value);
|
||||
// PlayerList.getNetInfoByID(%value);
|
||||
// PlayerList.getFlagsByID(%value);
|
||||
//
|
||||
// These functions get player info, if you know his/her TargetD
|
||||
// PlayerList.getNameByTargetID(%value);
|
||||
// PlayerList.getIDByTargetID(%value);
|
||||
// PlayerList.getGUIDByTargetID(%value);
|
||||
// PlayerList.getTeamByTargetID(%value);
|
||||
// PlayerList.getScoreByTargetID(%value);
|
||||
// PlayerList.getNetInfoByTargetID(%value);
|
||||
// PlayerList.getFlagsByTargetID(%value);
|
||||
//
|
||||
// These functions get player info, if you know his/her Global User ID (GUID)
|
||||
// PlayerList.getNameByGUID(%value);
|
||||
// PlayerList.getTargetIDByGUID(%value);
|
||||
// PlayerList.getIDByGUID(%value);
|
||||
// PlayerList.getTeamByGUID(%value);
|
||||
// PlayerList.getScoreByGUID(%value);
|
||||
// PlayerList.getNetInfoByGUID(%value);
|
||||
// PlayerList.getFlagsByGUID(%value);
|
||||
//
|
||||
// These functions get player info, if you know his/her player Index
|
||||
// (Index is an arbitrary number from 0 to (MAX_PLAYERS - 1).
|
||||
// Note, index is NOT a reliable method if looking up players, as it can
|
||||
// change as players are added and removed. It's primary use is when you
|
||||
// want to cycle through all players in the game sequentially.
|
||||
// PlayerList.getNameByIndex(%value);
|
||||
// PlayerList.getIDByIndex(%value);
|
||||
// PlayerList.getGUIDByIndex(%value);
|
||||
// PlayerList.getTeamByIndex(%value);
|
||||
// PlayerList.getScoreByIndex(%value);
|
||||
// PlayerList.getNetInfoByIndex(%value);
|
||||
// PlayerList.getFlagsByIndex(%value);
|
||||
//
|
||||
// Now, this script also provides an easy way to get information about the
|
||||
// client actually using the machine right now (ie. the person running your
|
||||
// script - similar to getManagerID in Tribes1).
|
||||
// I made 2 quick information lookups about the local player. If you need
|
||||
// more, well - that's why you have all those fancy functions up there ;)
|
||||
//
|
||||
// PlayerList.getMyID(); - returns the ClientID of the local player
|
||||
// PlayerList.getMyName(); - returns the detagged name of the local player.
|
||||
//
|
||||
// Finally, these are ever so slightly more advanced - it's not quite as
|
||||
// braindead-straightforward as the above ;)
|
||||
// These return the object numbers of "PlayerRep" objects, which the game
|
||||
// default scripts use to track player information. You can use and store
|
||||
// these to directly access player information later, if you want (do NOT
|
||||
// use the index number to store player info long-term, as it can change
|
||||
// as people join and drop.)
|
||||
//
|
||||
// Anyway. here's the overall definition of the PlayerRep object, as taken
|
||||
// from messages.cs
|
||||
// new ScriptObject()
|
||||
// {
|
||||
// className = "PlayerRep";
|
||||
// name = detag(%clientName);
|
||||
// guid = %guid;
|
||||
// clientId = %clientId;
|
||||
// targetId = %targetId;
|
||||
// teamId = 0;
|
||||
// score = 0;
|
||||
// ping = 0;
|
||||
// packetLoss = 0;
|
||||
// chatMuted = false;
|
||||
// canListen = false;
|
||||
// voiceEnabled = false;
|
||||
// isListening = false;
|
||||
// isBot = %isAI;
|
||||
// isAdmin = %isAdmin;
|
||||
// isSuperAdmin = %isSuperAdmin;
|
||||
// isSmurf = %isSmurf;
|
||||
// };
|
||||
//
|
||||
// So now that you know what members each PlayerRep object contains, let's look
|
||||
// at how we can get them.
|
||||
// Like the PlayerList.getBy functions, you need at least one piece of info
|
||||
// about the player to retrieve a PlayerRep object.
|
||||
// Each of these functions returns a playerRep object that can be used as you
|
||||
// see fit. Doing it like this is more efficient if you want to look up multiple
|
||||
// pieces of into about a single player - this way, you only actually SEARCH for
|
||||
// the player once, then get multiple pieces of info, instead of searching for the
|
||||
// player once for each piece of info.
|
||||
// Anyway, here's the functions:
|
||||
//
|
||||
// PlayerList.findByName(%value);
|
||||
// PlayerList.findByID(%value);
|
||||
// PlayerList.findByTargetID(%value);
|
||||
// PlayerList.findByIndex(%value);
|
||||
// PlayerList.findByGUID(%value);
|
||||
//
|
||||
// So you could do something like this:
|
||||
// %p = PlayerList.findByIndex(3);
|
||||
// echo("Name: ", %p.name, " ID: ", %p.clientID, " Team: ", %p.teamID);
|
||||
//
|
||||
// Also, there's one more function you need to know about.
|
||||
// PlayerList.findByTeam(%value);
|
||||
// This will search the entire player list for players on a given team
|
||||
// number (the one you specify), and return a space-delimited list of
|
||||
// playerRef objects.
|
||||
// For example, PlayerList.findByTeam(1); might return:
|
||||
// "8576 8581 8593 8602 8611"
|
||||
// you can then use getword to seperate them and retrieve info, as follows:
|
||||
//
|
||||
// %list = PlayerList.findByTeam(1);
|
||||
// %p = getword(%list, 2);
|
||||
// echo("Name: ", %p.name, " ID: ", %p.clientID, " Team: ", %p.teamID);
|
||||
//
|
||||
// That is all ;)
|
||||
|
||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
// SCRIPT BEGINS HERE
|
||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
// ----------------------------------------
|
||||
// Information retrieval.
|
||||
// The lazy man's functions ;)
|
||||
// These functions take a certain input
|
||||
// like name, GUID, clientID, targetID, etc
|
||||
// and return a specific piece of information
|
||||
// about the requested player
|
||||
// The following pieces of data can be used
|
||||
// to look up info:
|
||||
// Name, ID, TargetID, Index, GUID
|
||||
// You can return the following info:
|
||||
// Name, ID, TargetID, GUID, Team, Score
|
||||
// Netinfo (ping,pl), flags (ai,smurf,admin,sad)
|
||||
// ----------------------------------------
|
||||
|
||||
// ----------------------------------------
|
||||
// Local Player
|
||||
// ----------------------------------------
|
||||
function PlayerList::getMyID(%this) {
|
||||
return %this.myID;
|
||||
}
|
||||
|
||||
function PlayerList::getMyName(%this) {
|
||||
return %this.myName;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Get by name
|
||||
// ----------------------------------------
|
||||
function PlayerList::getScoreByName(%this, %value) {
|
||||
return %this.getInfo(%value, "Score", "Name");
|
||||
}
|
||||
|
||||
function PlayerList::getIDByName(%this, %value) {
|
||||
return %this.getInfo(%value, "ClientID", "Name");
|
||||
}
|
||||
|
||||
function PlayerList::getTargetIDByName(%this, %value) {
|
||||
return %this.getInfo(%value, "TargetID", "Name");
|
||||
}
|
||||
|
||||
function PlayerList::getGUIDByName(%this, %value) {
|
||||
return %this.getInfo(%value, "guid", "Name");
|
||||
}
|
||||
|
||||
function PlayerList::getTeamByName(%this, %value) {
|
||||
return %this.getInfo(%value, "teamID", "Name");
|
||||
}
|
||||
|
||||
function PlayerList::getNetInfoByName(%this, %value) {
|
||||
return %this.getNetInfo(%value, "Name");
|
||||
}
|
||||
|
||||
function PlayerList::getFlagsByName(%this, %value) {
|
||||
return %this.getFlags(%value, "Name");
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Get by ID
|
||||
// ----------------------------------------
|
||||
function PlayerList::getScoreByID(%this, %value) {
|
||||
return %this.getInfo(%value, "Score", "ID");
|
||||
}
|
||||
|
||||
function PlayerList::getNameByID(%this, %value) {
|
||||
return %this.getInfo(%value, "Name", "ID");
|
||||
}
|
||||
|
||||
function PlayerList::getTargetIDByID(%this, %value) {
|
||||
return %this.getInfo(%value, "TargetID", "ID");
|
||||
}
|
||||
|
||||
function PlayerList::getGUIDByID(%this, %value) {
|
||||
return %this.getInfo(%value, "guid", "ID");
|
||||
}
|
||||
|
||||
function PlayerList::getTeamByID(%this, %value) {
|
||||
return %this.getInfo(%value, "teamID", "ID");
|
||||
}
|
||||
|
||||
function PlayerList::getNetInfoByID(%this, %value) {
|
||||
return %this.getNetInfo(%value, "ID");
|
||||
}
|
||||
|
||||
function PlayerList::getFlagsByID(%this, %value) {
|
||||
return %this.getFlags(%value, "ID");
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Get by TargetID
|
||||
// ----------------------------------------
|
||||
function PlayerList::getScoreByTargetID(%this, %value) {
|
||||
return %this.getInfo(%value, "Score", "TargetID");
|
||||
}
|
||||
|
||||
function PlayerList::getIDByTargetID(%this, %value) {
|
||||
return %this.getInfo(%value, "ClientID", "TargetID");
|
||||
}
|
||||
|
||||
function PlayerList::getNameByTargetID(%this, %value) {
|
||||
return %this.getInfo(%value, "Name", "TargetID");
|
||||
}
|
||||
|
||||
function PlayerList::getGUIDByTargetID(%this, %value) {
|
||||
return %this.getInfo(%value, "guid", "TargetID");
|
||||
}
|
||||
|
||||
function PlayerList::getTeamByTargetID(%this, %value) {
|
||||
return %this.getInfo(%value, "teamID", "TargetID");
|
||||
}
|
||||
|
||||
function PlayerList::getNetInfoByTargetID(%this, %value) {
|
||||
return %this.getNetInfo(%value, "TargetID");
|
||||
}
|
||||
|
||||
function PlayerList::getFlagsByTargetID(%this, %value) {
|
||||
return %this.getFlags(%value, "TargetID");
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Get by Index.
|
||||
// ----------------------------------------
|
||||
function PlayerList::getTargetIDByIndex(%this, %value) {
|
||||
return %this.getInfo(%value, "TargetID", "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getScoreByIndex(%this, %value) {
|
||||
return %this.getInfo(%value, "Score", "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getIDByIndex(%this, %value) {
|
||||
return %this.getInfo(%value, "ClientID", "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getNameByIndex(%this, %value) {
|
||||
return %this.getInfo(%value, "Name", "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getGUIDByIndex(%this, %value) {
|
||||
return %this.getInfo(%value, "guid", "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getTeamByIndex(%this, %value) {
|
||||
return %this.getInfo(%value, "teamID", "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getNetInfoByIndex(%this, %value) {
|
||||
return %this.getNetInfo(%value, "Index");
|
||||
}
|
||||
|
||||
function PlayerList::getFlagsByIndex(%this, %value) {
|
||||
return %this.getFlags(%value, "Index");
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Get by GUID
|
||||
// ----------------------------------------
|
||||
function PlayerList::getScoreByGUID(%this, %value) {
|
||||
return %this.getInfo(%value, "Score", "GUID");
|
||||
}
|
||||
|
||||
function PlayerList::getIDByGUID(%this, %value) {
|
||||
return %this.getInfo(%value, "ClientID", "GUID");
|
||||
}
|
||||
|
||||
function PlayerList::getNameByGUID(%this, %value) {
|
||||
return %this.getInfo(%value, "Name", "GUID");
|
||||
}
|
||||
|
||||
function PlayerList::getTargetIDByGUID(%this, %value) {
|
||||
return %this.getInfo(%value, "TargetID", "GUID");
|
||||
}
|
||||
|
||||
function PlayerList::getTeamByGUID(%this, %value) {
|
||||
return %this.getInfo(%value, "teamID", "GUID");
|
||||
}
|
||||
|
||||
function PlayerList::getNetInfoByGUID(%this, %value) {
|
||||
return %this.getNetInfo(%value, "GUID");
|
||||
}
|
||||
|
||||
function PlayerList::getFlagsByGUID(%this, %value) {
|
||||
return %this.getFlags(%value, "GUID");
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// The fancy functions that drive all the
|
||||
// above. Woohoo!
|
||||
// These three functions reduce the amount
|
||||
// of repeated code by a _LOT_
|
||||
// I am win ;)
|
||||
// ----------------------------------------
|
||||
function PlayerList::getInfo(%this, %value, %returntype, %searchtype) {
|
||||
%object = eval("PlayerList.findBy" @ %searchtype @ "(%value);");
|
||||
if (%object == 0)
|
||||
return $PLAYER_ERROR;
|
||||
else {
|
||||
eval("%retr = " @ %object @ "." @ %returntype @ ";");
|
||||
return %retr;
|
||||
}
|
||||
}
|
||||
|
||||
function PlayerList::getNetInfo(%this, %value, %searchtype) {
|
||||
%object = eval("PlayerList.findBy" @ %searchtype @ "(%value);");
|
||||
if (%object == 0)
|
||||
return $PLAYER_ERROR;
|
||||
else
|
||||
return %object.ping @ " " @ %object.packetloss;
|
||||
}
|
||||
|
||||
function PlayerList::getFlags(%this, %value, %searchtype) {
|
||||
%object = eval("PlayerList.findBy" @ %searchtype @ "(%value);");
|
||||
if (%object == 0)
|
||||
return $PLAYER_ERROR;
|
||||
else
|
||||
return %this.createFlags(%object.isSmurf, %object.isAdmin, %object.isSuperAdmin, %object.isBot);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Search functions. These functions look
|
||||
// through stored player data, and locate
|
||||
// a PlayerRep object by a certain criteria
|
||||
// such as GUID (Global User ID), name,
|
||||
// client ID, and target ID.
|
||||
// These are some of the most useful
|
||||
// functions in this file, because you can
|
||||
// find a PlayerRep object, then request
|
||||
// whatever information you want from it
|
||||
// by using the member selection operator
|
||||
// (ie. the period ;)
|
||||
// %object.name
|
||||
// %object.ping
|
||||
// etc.
|
||||
// Note - some of these (such as findByTeam)
|
||||
// can return multiple object numbers. These
|
||||
// will be returned in a space-delimited
|
||||
// string,
|
||||
// ----------------------------------------
|
||||
|
||||
// Find a playerRep object by GUID
|
||||
function PlayerList::findByGUID(%this, %guid) {
|
||||
if (!isObject(PlayerListGroup))
|
||||
return $PLAYER_ERROR;
|
||||
|
||||
%clients = PlayerListGroup.getCount();
|
||||
for (%i = 0; %i < %clients; %i++) {
|
||||
%objnum = PlayerListGroup.getObject(%i);
|
||||
if (%objnum.guid == %guid)
|
||||
return %objnum;
|
||||
}
|
||||
return $PLAYER_ERROR;
|
||||
}
|
||||
|
||||
// Find a playerRep object by TargetID
|
||||
function PlayerList::findByTargetID(%this, %targ) {
|
||||
if (!isObject(PlayerListGroup))
|
||||
return $PLAYER_ERROR;
|
||||
|
||||
%clients = PlayerListGroup.getCount();
|
||||
for (%i = 0; %i < %clients; %i++) {
|
||||
%objnum = PlayerListGroup.getObject(%i);
|
||||
if (%objnum.targetID == %targ)
|
||||
return %objnum;
|
||||
}
|
||||
return $PLAYER_ERROR;
|
||||
}
|
||||
|
||||
// Find a playerRep object by detagged playerName
|
||||
function PlayerList::findByName(%this, %name) {
|
||||
if (!isObject(PlayerListGroup))
|
||||
return $PLAYER_ERROR;
|
||||
|
||||
%clients = PlayerListGroup.getCount();
|
||||
for (%i = 0; %i < %clients; %i++) {
|
||||
%objnum = PlayerListGroup.getObject(%i);
|
||||
if (%objnum.name $= %name)
|
||||
return %objnum;
|
||||
}
|
||||
return $PLAYER_ERROR;
|
||||
}
|
||||
|
||||
// Find a playerRep object by clientID
|
||||
function PlayerList::findByID(%this, %id) {
|
||||
if (isObject($PlayerList[%id]))
|
||||
return $PlayerList[%id];
|
||||
else
|
||||
return $PLAYER_ERROR;
|
||||
}
|
||||
|
||||
// Find by 'index'. IE, %index of 0 will get the first player in the list
|
||||
// index of 1 gets the second, etc.
|
||||
function PlayerList::findByIndex(%this, %index) {
|
||||
if (!isObject(PlayerListGroup))
|
||||
return $PLAYER_ERROR;
|
||||
|
||||
if ((%index < PlayerListGroup.getCount()) && (%index >= 0))
|
||||
return PlayerListGroup.getObject(%index);
|
||||
else
|
||||
return $PLAYER_ERROR;
|
||||
}
|
||||
|
||||
// Find by team# - almost guaranteed to return more than one client
|
||||
function PlayerList::findByTeam(%this, %team) {
|
||||
if (!isObject(PlayerListGroup))
|
||||
return $PLAYER_ERROR;
|
||||
|
||||
%clients = PlayerListGroup.getCount();
|
||||
for (%i = 0; %i < %clients; %i++) {
|
||||
%objnum = PlayerListGroup.getObject(%i);
|
||||
if (%objnum.teamID == %team) %teamstring = %teamstring @ %objnum @ " ";
|
||||
}
|
||||
if (%teamstring $= "")
|
||||
return $PLAYER_ERROR;
|
||||
else
|
||||
return %teamstring;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Internal script nonsense ;)
|
||||
// ----------------------------------------
|
||||
|
||||
if(!isObject(PlayerList))
|
||||
{
|
||||
new ScriptObject(PlayerList)
|
||||
{
|
||||
class = PlayerList;
|
||||
activated = false;
|
||||
initialized = false;
|
||||
};
|
||||
}
|
||||
|
||||
function PlayerList::init(%this) {
|
||||
if (!%this.initialized) {
|
||||
// ----------------------------------------
|
||||
// GENERAL INITIALIZATION
|
||||
// ----------------------------------------
|
||||
%this.initialized = true;
|
||||
addMessageCallback('MsgClientJoin', PlayerList_HandleJoin);
|
||||
|
||||
activatePackage(Player_Support);
|
||||
|
||||
// Flags! Woohoo!
|
||||
$PLAYER_SMURF = 1;
|
||||
$PLAYER_ADMIN = 2;
|
||||
$PLAYER_SUPERADMIN = 4;
|
||||
$PLAYER_AI = 8;
|
||||
|
||||
// Error return value. Almost guaranteed never to match a legit return value.
|
||||
$PLAYER_ERROR = "\x10error\x10";
|
||||
|
||||
// ----------------------------------------
|
||||
// GUI OBJECTS
|
||||
// ----------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
// These are just part of my standard script format.
|
||||
// Since there's really no active parts to this script
|
||||
// (ie. all the functions just return values), they don't
|
||||
// do much right now, but they're here in case I ever decide
|
||||
// to implement them ;)
|
||||
function PlayerList::activate(%this) {
|
||||
if (!%this.activated) {
|
||||
%this.activated = true;
|
||||
}
|
||||
}
|
||||
|
||||
function PlayerList::deactivate(%this) {
|
||||
if (%this.activated) {
|
||||
%this.activated = false;
|
||||
}
|
||||
}
|
||||
|
||||
// debug functions! w00t w00t!
|
||||
//function listAllPlayers() {
|
||||
// %i = 0;
|
||||
// %p = PlayerList.findByIndex(%i);
|
||||
// while (%p !$= $PLAYER_ERROR) {
|
||||
// echo( "Name: ", %p.name, "(", %p.clientID, ") Team: ", %p.teamID, " Targ: ", %p.targetID,
|
||||
// " Net: ", %p.ping, "|", %p.packetloss, " Flags: ", PlayerList.createFlags(%p.isSmurf, %p.isAdmin, %p.isSuperAdmin, %p.isBot),
|
||||
// " Score: ", %p.score, " GUID: ", %p.guid);
|
||||
|
||||
// %i++;
|
||||
// %p = PlayerList.findByIndex(%i);
|
||||
// }
|
||||
//}
|
||||
|
||||
// This lil' doohicky combines a couple vars to make player flags
|
||||
function PlayerList::createFlags(%this, %smurf, %admin, %SAD, %smurf) {
|
||||
return ((%smurf?($PLAYER_SMURF):0) | (%AI?($PLAYER_AI):0) | (%Admin?($PLAYER_ADMIN):0) | (%SAD?($PLAYER_SUPERADMIN):0));
|
||||
}
|
||||
|
||||
function PlayerList_HandleJoin(%msgtype, %message, %name, %id) {
|
||||
// set the values of a few "special" variables if this is the player's client.
|
||||
// Got the idea for this one from Wizard's ObserverHUD.
|
||||
if (strstr(%message, "Welcome to Tribes2") != -1)
|
||||
{
|
||||
PlayerList.myID = %id;
|
||||
PlayerList.myName = detag(%name);
|
||||
}
|
||||
}
|
||||
|
||||
package Player_Support {
|
||||
function DisconnectedCleanup() {
|
||||
PlayerList.myID = "";
|
||||
PlayerList.myName = "";
|
||||
|
||||
parent::DisconnectedCleanup();
|
||||
}
|
||||
};
|
||||
|
||||
PlayerList.init();
|
||||
PlayerList.activate();
|
||||
844
docs/base/@vl2/z_scripts/support.vl2/support/stat_support.cs
Normal file
844
docs/base/@vl2/z_scripts/support.vl2/support/stat_support.cs
Normal file
|
|
@ -0,0 +1,844 @@
|
|||
// #name = Stat Support
|
||||
// #version = 0.0.8
|
||||
// #date = September 17, 2001
|
||||
// #author = Daniel Neilsen
|
||||
// #warrior = Wizard_TPG
|
||||
// #email = wizardsworld@bigpond.com
|
||||
// #web = http://mods.tribalwar.com/wizard/
|
||||
// #description = Adds player and team stat logging support
|
||||
// #status = release
|
||||
// #include = support/callback.cs
|
||||
// #include = support/player_support.cs
|
||||
// #include = support/mission_callbacks.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Usage Notes and Examples:
|
||||
//
|
||||
// Callbacks included in this support script:
|
||||
//
|
||||
// onStatsDelete - Stats have just been deleted
|
||||
// onSupportClearDebrief - Previous mission stats are wiped directly after this
|
||||
// onSupportUserClientDrop - The user client dropped (this is just before stats are deleted)
|
||||
// onPlayerDeathUpdate - A player was killed. includes variables %victimId, %killerid, %vTeam and %kTeam
|
||||
// onTeamScoreUpdate - Team Score Altered.
|
||||
// onFlagGrab - When a flag is taken. Includes variables for %clientid and %flagteam
|
||||
// onFlagDrop - When a flag is dropped. Includes variables for %clientid and %flagteam
|
||||
// onFlagCap - When a flag is capped. Includes variables for %clientid and %flagteam
|
||||
// onFlagReturn - When a flag is returned. Includes variables for %clientid and %flagteam
|
||||
// onFFGrab - When a FlipFlop is Grabbed. Includes variables for %clientid
|
||||
// onHuntFlagChange - When number of hunters flag carried changes. Includes variables for %clientid and %flags carried
|
||||
// onTACVehicleKill - When a TAC2 Vehicle is destroyed. Includes variables for killer %clientid
|
||||
//
|
||||
//
|
||||
// Useful Functions in this support script:
|
||||
//
|
||||
// StatSupport.getClientName(%client); - Returns client name, even if they have dropped
|
||||
// StatSupport.getClientScore(%client); - Returns client name, even post mission end
|
||||
// StatSupport.getClientDeaths(%client); - Returns client death count
|
||||
// StatSupport.getClientKills(%client); - Returns client kill count
|
||||
// StatSupport.getClientTeamKills(%client); - Returns client TK count
|
||||
// StatSupport.getClientHeadShot(%client); - Returns client headshot count
|
||||
// StatSupport.getClientDeathByType(%client, %type); - Returns client death count for damagetype
|
||||
// StatSupport.getClientKillByType(%client, %type); - Returns client kill count for damagetype
|
||||
// StatSupport.getClientDeathByClient(%client, %kclient); - Returns client death count from enemy client
|
||||
// StatSupport.getClientKillByClient(%client, %vclient); - Returns client kill count on enemy client
|
||||
// StatSupport.getClientGrabs(%client); - Returns client flag grabs
|
||||
// StatSupport.getClientDrops(%client); - Returns client flag drops
|
||||
// StatSupport.getClientCaps(%client); - Returns client flag caps
|
||||
// StatSupport.getClientReturns(%client); - Returns client flag returns
|
||||
// StatSupport.getClientFFGrabs(%client); - Returns client flag FF Grabs
|
||||
// StatSupport.getClientFlagsCarried(%client); - Returns client hunters flags carried
|
||||
// StatSupport.getClientTACFriendlyVehiclesKilled(%client) - Returns client TAC2 Friendly vehicle kills
|
||||
// StatSupport.getClientTACEnemyVehiclesKilled(%client) - Returns client TAC2 Enemy vehicle kills
|
||||
// StatSupport.getTeamScore(%team); - Returns team score
|
||||
// StatSupport.getTeamDeaths(%team); - Returns team death count
|
||||
// StatSupport.getTeamKills(%team); - Returns team kill count
|
||||
// StatSupport.getTeamTeamKills(%team); - Returns team TK count
|
||||
// StatSupport.getTeamDeathByType(%team, %type); - Returns team death count for damagetype
|
||||
// StatSupport.getTeamKillByType(%team, %type); - Returns team kill count for damagetype
|
||||
// StatSupport.getTeamGrabs(%team); - Returns team flag grabs
|
||||
// StatSupport.getTeamDrops(%team); - Returns team flag drops
|
||||
// StatSupport.getTeamCaps(%team); - Returns team flag caps
|
||||
// StatSupport.getTeamReturns(%team); - Returns team flag returns
|
||||
// StatSupport.getTeamFFGrabs(%team); - Returns team flag FF Grabs
|
||||
// StatSupport.getTeamTACFriendlyVehiclesKilled(%team) - Returns team TAC2 Friendly vehicle kills
|
||||
// StatSupport.getTeamTACEnemyVehiclesKilled(%team) - Returns team TAC2 Enemy vehicle kills
|
||||
//
|
||||
//
|
||||
// NOTE: This script will work fine for all mods but the damagetypes will be as per
|
||||
// the damagetypes for that particular mod.
|
||||
//
|
||||
//
|
||||
//
|
||||
// OTHER INFORMATION:
|
||||
//
|
||||
// This script will remember a players statistics even if they drop from a
|
||||
// server and reconnect. This means that should a player play for 10 minutes
|
||||
// and have 8 kills, then reconnect (in the same mission) and get another
|
||||
// 1 kill, his kills displayed will be 9 kills.
|
||||
//
|
||||
// Should the player drop from the mission, his statistics are still available
|
||||
// until the end of that mission, whether he is actualyl on the server or not.
|
||||
//
|
||||
// Another important thing to note is that the players names, scores, etc will
|
||||
// not be wiped at the mission end but will remain and be wiped with all the
|
||||
// other statistics allowing your script to output this data.
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// MAIN SYSTEM CODE
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Create Stat Support Container Object
|
||||
|
||||
if(!isObject(StatSupport))
|
||||
{
|
||||
new ScriptObject(StatSupport)
|
||||
{
|
||||
class = StatSupport;
|
||||
|
||||
new ScriptObject(StatServerData)
|
||||
{
|
||||
class = StatServerData;
|
||||
};
|
||||
new ScriptObject(StatMissionData)
|
||||
{
|
||||
class = StatMissionData;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//Start and End mission triggers
|
||||
|
||||
function handleStatSupportClearDebrief(%msgType, %msgString)
|
||||
{
|
||||
callback.trigger(onSupportClearDebrief);
|
||||
|
||||
//Clear All Stats
|
||||
StatMissionData.delete();
|
||||
if(!isObject(StatMissionData))
|
||||
{
|
||||
StatSupport.StatMissionData = new ScriptObject(StatMissionData)
|
||||
{
|
||||
class = StatMissionData;
|
||||
};
|
||||
}
|
||||
|
||||
callback.trigger(onStatsDelete);
|
||||
exec("support/stat_support.cs");
|
||||
}
|
||||
addMessageCallback( 'MsgClearDebrief',handleStatSupportClearDebrief );
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//Client Drop/Join Code
|
||||
|
||||
function handleStatSupportClientDrop (%clientname, %clientid)
|
||||
{
|
||||
//clean up stats on user drop
|
||||
callback.trigger(onSupportUserClientDrop);
|
||||
|
||||
StatMissionData.delete();
|
||||
StatServerData.delete();
|
||||
StatSupport.StatMissionData = new ScriptObject(StatMissionData)
|
||||
{
|
||||
class = StatMissionData;
|
||||
};
|
||||
StatSupport.StatServerData = new ScriptObject(StatServerData)
|
||||
{
|
||||
class = StatServerData;
|
||||
};
|
||||
exec("support/stat_support.cs");
|
||||
}
|
||||
callback.add(onUserClientDrop, handleStatSupportClientDrop);
|
||||
|
||||
|
||||
function handleStatSupportClientJoined (%clientName, %clientid)
|
||||
{
|
||||
//backup existing dropped client data
|
||||
if(StatSupport.ClientName[%clientid])
|
||||
{
|
||||
StatSupport.CurrentTempID++;
|
||||
%tempid = StatSupport.CurrentTempID;
|
||||
StatMissionData.CopyClientStats(%clientid, %tempid);
|
||||
}
|
||||
|
||||
//Add back in past data
|
||||
%cName = detag(%clientName);
|
||||
for(%oldid = 0; %oldid < 8000; %oldid++)
|
||||
{
|
||||
if(StatMissionData.ClientName[%oldid] $= %cName)
|
||||
{
|
||||
%foundid = %oldid;
|
||||
%oldid = 10000;
|
||||
}
|
||||
}
|
||||
if(%foundid)
|
||||
{
|
||||
StatMissionData.CopyClientStats(%foundid, %clientid);
|
||||
StatMissionData.ClearClientStats(%foundid);
|
||||
}
|
||||
}
|
||||
callback.add(onClientJoin, handleStatSupportClientJoined);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Player Stats Alteration Functions
|
||||
|
||||
function StatMissionData::ClearClientStats(%this, %client)
|
||||
{
|
||||
%this.ClientScore[%client] = "";
|
||||
%this.ClientName[%client] = "";
|
||||
%this.ClientDeath[%client] = "";
|
||||
%this.ClientKill[%client] = "";
|
||||
%this.ClientTeamKill[%client] = "";
|
||||
%this.ClientHeadShot[%client] = "";
|
||||
%this.ClientFlagGrab[%client] = "";
|
||||
%this.ClientFlagDrop[%client] = "";
|
||||
%this.ClientFlagCap[%client] = "";
|
||||
%this.ClientFlagReturn[%client] = "";
|
||||
%this.ClientFFGrab[%client] = "";
|
||||
%this.ClientHuntFlags[%client] = "";
|
||||
%this.ClientTACFriendVehicleKill[%client] = "";
|
||||
%this.ClientTACEnemyVehicleKill[%client] = "";
|
||||
for(%damageType = 0; %damageType<100; %damageType++)
|
||||
{
|
||||
%this.ClientDeathBy[%client, %damageType] = "";
|
||||
%this.ClientKillBy[%client, %damageType] = "";
|
||||
}
|
||||
for(%otherid = 0; %otherid < 8000; %otherid++)
|
||||
{
|
||||
if(%this.ClientName[%otherid] !$= "")
|
||||
{
|
||||
%this.ClientDeathByKiller[%client, %otherid] = "";
|
||||
%this.ClientKillByVictim[%client, %otherid] = "";
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function StatMissionData::CopyClientStats(%this, %foundid, %clientid)
|
||||
{
|
||||
//function swaps stats from foundid to clientid
|
||||
StatMissionData.ClientName[%clientid] = StatMissionData.ClientName[%foundid];
|
||||
StatMissionData.ClientDeath[%clientid] = StatMissionData.ClientDeath[%foundid];
|
||||
StatMissionData.ClientKill[%clientid] = StatMissionData.ClientKill[%foundid];
|
||||
StatMissionData.ClientTeamKill[%clientid] = StatMissionData.ClientTeamKill[%foundid];
|
||||
StatMissionData.ClientHeadShot[%clientid] = StatMissionData.ClientHeadShot[%foundid];
|
||||
StatMissionData.ClientFlagGrab[%clientid] = StatMissionData.ClientFlagGrab[%foundid];
|
||||
StatMissionData.ClientFlagDrop[%clientid] = StatMissionData.ClientFlagDrop[%foundid];
|
||||
StatMissionData.ClientFlagCap[%clientid] = StatMissionData.ClientFlagCap[%foundid];
|
||||
StatMissionData.ClientFlagReturn[%clientid] = StatMissionData.ClientFlagReturn[%foundid];
|
||||
StatMissionData.ClientFFGrab[%clientid] = StatMissionData.ClientFFGrab[%foundid];
|
||||
StatMissionData.ClientHuntFlags[%clientid] = StatMissionData.ClientHuntFlags[%foundid];
|
||||
%this.ClientTACFriendVehicleKill[%client] = %this.ClientTACFriendVehicleKill[%foundid];
|
||||
%this.ClientTACEnemyVehicleKill[%client] = %this.ClientTACEnemyVehicleKill[%foundid];
|
||||
|
||||
for(%damageType = 0; %damageType<100; %damageType++)
|
||||
{
|
||||
StatMissionData.ClientDeathBy[%clientid, %damageType] = StatMissionData.ClientDeathBy[%foundid, %damageType];
|
||||
StatMissionData.ClientKillBy[%clientid, %damageType] = StatMissionData.ClientKillBy[%foundid, %damageType];
|
||||
}
|
||||
for(%otherid = 0; %otherid < 8000; %otherid++)
|
||||
{
|
||||
if(StatMissionData.ClientName[%otherid] !$= "")
|
||||
{
|
||||
StatMissionData.ClientDeathByKiller[%clientid, %otherid] = StatMissionData.ClientDeathByKiller[%foundid, %kId];
|
||||
StatMissionData.ClientKillByVictim[%clientid, %otherid] = StatMissionData.ClientKillByVictim[%foundid, %otherid];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// SCORE AND KILLS CODE
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//Get client kills/deaths
|
||||
|
||||
function StatMissionData::KillInfo (%this, %victimname, %killername, %damageType)
|
||||
{
|
||||
if(%victimname $= "")
|
||||
return;
|
||||
%vName = detag(%victimname);
|
||||
%vId = PlayerList.getIDByName(%vName);
|
||||
%vTeam = PlayerList.getTeamByName(%vName);
|
||||
|
||||
if(%killername !$= "")
|
||||
{
|
||||
%kName = detag(%killername);
|
||||
%kId = PlayerList.getIDByName(%kName);
|
||||
%kTeam = PlayerList.getTeamByName(%kName);
|
||||
}
|
||||
else
|
||||
{
|
||||
%kId = 0;
|
||||
%kTeam = 0;
|
||||
}
|
||||
|
||||
//calc specific player death stats.
|
||||
%this.ClientDeath[%vID]++;
|
||||
%this.ClientDeathBy[%vID, %damageType]++;
|
||||
%this.ClientDeathByKiller[%vID, %kId]++;
|
||||
%this.ClientLastDeathBy[%vID] = %damageType;
|
||||
%this.ClientLastKiller[%vID] = %kId;
|
||||
|
||||
//calc team death stats
|
||||
%this.TeamDeath[%vTeam]++;
|
||||
%this.TeamDeathBy[%vTeam, %damageType]++;
|
||||
|
||||
//calc team kill stats
|
||||
%this.TeamKill[%kTeam]++;
|
||||
%this.TeamKillBy[%kTeam, %damageType]++;
|
||||
|
||||
if(%kID != 0)
|
||||
{
|
||||
//calc specific player kill stats
|
||||
%this.ClientKill[%kID]++;
|
||||
%this.ClientKillBy[%kID, %damageType]++;
|
||||
%this.ClientKillByVictim[%kID, %vId]++;
|
||||
%this.ClientLastKillBy[%kID] = %damageType;
|
||||
%this.ClientLastVictim[%kID] = %vId;
|
||||
}
|
||||
|
||||
// Check for Team Kill
|
||||
if(%vTeam == %kTeam)
|
||||
{
|
||||
%this.ClientTeamKill[%kID]++;
|
||||
%this.TeamTeamKill[%kTeam]++;
|
||||
}
|
||||
callback.trigger(onPlayerDeathUpdate, %vID, %kId, vTeam, %kTeam);
|
||||
}
|
||||
|
||||
function handleStatMissionDataExplosionKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataSuicideKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataVehicleSpawnKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataVehicleKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataTurretSelfKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataCTurretKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataTurretKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataSelfKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataOOBKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataCampKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataTeamKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataLavaKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataLightningKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataHeadshotKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
%kName = detag(%killername);
|
||||
%kId = PlayerList.getIDByName(%kName);
|
||||
%kTeam = PlayerList.getTeamByName(%kName);
|
||||
StatMissionData.ClientHeadShot[%kId]++;
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
function handleStatMissionDataLegitKillInfo (%msgType, %msgString, %victimname, %victimGender, %victimPoss, %killerName, %killerGender, %killerPoss, %damageType)
|
||||
{
|
||||
StatMissionData.KillInfo(%victimname, %killerName, %damageType);
|
||||
}
|
||||
|
||||
addMessageCallback( 'msgExplosionKill', handleStatMissionDataExplosionKillInfo );
|
||||
addMessageCallback( 'msgSuicide', handleStatMissionDataSuicideKillInfo );
|
||||
addMessageCallback( 'msgVehicleSpawnKill', handleStatMissionDataVehicleSpawnKillInfo );
|
||||
addMessageCallback( 'msgVehicleKill', handleStatMissionDataVehicleKillInfo );
|
||||
addMessageCallback( 'msgTurretSelfKill', handleStatMissionDataTurretSelfKillInfo );
|
||||
addMessageCallback( 'msgCTurretKill', handleStatMissionDataCTurretKillInfo );
|
||||
addMessageCallback( 'msgTurretKill', handleStatMissionDataTurretKillInfo );
|
||||
addMessageCallback( 'msgSelfKill', handleStatMissionDataSelfKillInfo );
|
||||
addMessageCallback( 'msgOOBKill', handleStatMissionDataOOBKillInfo );
|
||||
addMessageCallback( 'msgCampKill', handleStatMissionDataCampKillInfo );
|
||||
addMessageCallback( 'msgTeamKill', handleStatMissionDataTeamKillInfo );
|
||||
addMessageCallback( 'msgLavaKill', handleStatMissionDataLavaKillInfo );
|
||||
addMessageCallback( 'msgLightningKill', handleStatMissionDataLightningKillInfo );
|
||||
addMessageCallback( 'MsgHeadshotKill', handleStatMissionDataHeadshotKillInfo );
|
||||
addMessageCallback( 'MsgLegitKill', handleStatMissionDataLegitKillInfo );
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//Get client score data
|
||||
|
||||
function StatMissionData::PlayerScoreUpdate(%this)
|
||||
{
|
||||
%i = 0;
|
||||
%p = PlayerList.findByIndex(%i);
|
||||
while (%p !$= $PLAYER_ERROR)
|
||||
{
|
||||
if(%p.score != 0 || %this.ClientScore[%p.clientID] $= "")
|
||||
{
|
||||
%this.ClientScore[%p.clientID] = %p.score;
|
||||
}
|
||||
%i++;
|
||||
%p = PlayerList.findByIndex(%i);
|
||||
}
|
||||
}
|
||||
callback.add(onPlayerDeathUpdate, "StatMissionData.PlayerScoreUpdate();");
|
||||
callback.add(onSupportTimerUpdate, "StatMissionData.PlayerScoreUpdate();");
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//Get team score data
|
||||
|
||||
function handleStatSupportTeamScore (%msgType, %msgString, %teamid, %teamscore)
|
||||
{
|
||||
StatMissionData.TeamScore[%teamid] = %teamscore;
|
||||
callback.trigger(onTeamScoreUpdate);
|
||||
}
|
||||
addMessageCallback( 'MsgTeamScoreIs', handleStatSupportTeamScore );
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// CTF Specific Game Code
|
||||
|
||||
function handleStatSupportCTFTeamInfo (%msgType, %msgString, %teamid, %teamname, %flagstatus, %teamscore)
|
||||
{
|
||||
StatMissionData.TeamScore[%teamid] = %teamscore;
|
||||
callback.trigger(onTeamScoreUpdate);
|
||||
}
|
||||
addMessageCallback( 'MsgCTFAddTeam', handleStatSupportCTFTeamInfo );
|
||||
|
||||
function handleStatSupportCTFFlagTaken (%msgType, %msgString, %clientname, %flagteamname, %flagteamid, %namebase)
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientFlagGrab[%clientid]++;
|
||||
%capperteam = PlayerList.getTeamByID(%clientid);
|
||||
%flagteam = %capperteam == 1 ? 2 : 1;
|
||||
StatMissionData.TeamFlagGrab[%capperteam]++;
|
||||
callback.trigger(onFlagGrab, %clientid, %flagteam);
|
||||
}
|
||||
addMessageCallback( 'MsgCTFFlagTaken', handleStatSupportCTFFlagTaken );
|
||||
|
||||
function handleStatSupportCTFFlagDropped (%msgType, %msgString, %clientname, %flagteamname, %flagteamid)
|
||||
{
|
||||
if(%clientname $= "0")
|
||||
{
|
||||
%name = playerList.getMyName();
|
||||
}
|
||||
else
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
}
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientFlagDrop[%clientid]++;
|
||||
%capperteam = PlayerList.getTeamByID(%clientid);
|
||||
StatMissionData.TeamFlagDrop[%capperteam]++;
|
||||
%flagteam = %capperteam == 1 ? 2 : 1;
|
||||
callback.trigger(onFlagDrop, %clientid, %flagteam);
|
||||
}
|
||||
addMessageCallback( 'MsgCTFFlagDropped', handleStatSupportCTFFlagDropped );
|
||||
|
||||
function handleStatSupportCTFFlagCapped (%msgType, %msgString, %clientname, %flagteamname, %flagteamid, %clientteamid)
|
||||
{
|
||||
if(%clientname $= "0")
|
||||
{
|
||||
%name = playerList.getMyName();
|
||||
}
|
||||
else
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
}
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientFlagCap[%clientid]++;
|
||||
StatMissionData.TeamFlagCap[%clientteamid]++;
|
||||
%flagteam = %clientteamid == 1 ? 2 : 1;
|
||||
callback.trigger(onFlagCap, %clientid, %flagteam);
|
||||
}
|
||||
addMessageCallback( 'MsgCTFFlagCapped', handleStatSupportCTFFlagCapped );
|
||||
|
||||
function handleStatSupportCTFFlagReturn (%msgType, %msgString, %clientname, %flagteamname, %flagteamid)
|
||||
{
|
||||
if(%clientname $= "0")
|
||||
{
|
||||
%name = playerList.getMyName();
|
||||
}
|
||||
else
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
}
|
||||
|
||||
StatMissionData.TeamFlagReturn[%flagteamid]++;
|
||||
if(%name !$= $PLAYER_ERROR)
|
||||
{
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientFlagReturn[%clientid]++;
|
||||
}
|
||||
callback.trigger(onFlagReturn, %clientid, %flagteamid);
|
||||
}
|
||||
addMessageCallback( 'MsgCTFFlagReturned', handleStatSupportCTFFlagReturn );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// CnH Specific Stuff
|
||||
|
||||
function handleStatSupportCNHTeamInfo (%msgType, %msgString, %teamid, %teamname, %teamscore, %scorelimit, %teamHeld)
|
||||
{
|
||||
StatMissionData.TeamScore[%teamid] = %teamscore;
|
||||
StatMissionData.ScoreLimit = %scorelimit;
|
||||
callback.trigger(onTeamScoreUpdate);
|
||||
}
|
||||
addMessageCallback( 'MsgCnHAddTeam', handleStatSupportCNHTeamInfo );
|
||||
|
||||
function handleStatSupportCNHTeamClaim (%msgType, %msgString, %clientname, %ffname, %taggedteamname)
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientFFGrab[%clientid]++;
|
||||
%teamid = PlayerList.getTeamByID(%clientid);
|
||||
StatMissionData.TeamFFGrab[%teamid]++;
|
||||
callback.trigger(onFFGrab, %clientid);
|
||||
}
|
||||
addMessageCallback( 'MsgClaimFlipFlop', handleStatSupportCNHTeamClaim );
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Hunters Stuff
|
||||
|
||||
function handleStatSupportHuntPlayerScored (%msgType, %msgString, %clientname)
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientHuntFlags[%clientid] = 0;
|
||||
callback.trigger(onHuntFlagChange, %clientid, 0);
|
||||
}
|
||||
addMessageCallback( 'MsgHuntPlayerScored', handleStatSupportHuntPlayerScored );
|
||||
|
||||
function handleStatSupportHuntYouScored (%msgType, %msgString)
|
||||
{
|
||||
%clientid = PlayerList.getMyID();
|
||||
StatMissionData.ClientHuntFlags[%clientid] = 0;
|
||||
callback.trigger(onHuntFlagChange, %clientid, 0);
|
||||
}
|
||||
addMessageCallback( 'MsgHuntYouScored', handleStatSupportHuntYouScored );
|
||||
|
||||
function handleStatSupportHuntPlayerFlags (%msgType, %msgString, %clientname, %flagcount)
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientHuntFlags[%clientid] = %flagcount;
|
||||
callback.trigger(onHuntFlagChange, %clientid, %flagcount);
|
||||
}
|
||||
addMessageCallback( 'MsgHuntPlayerHasFlags', handleStatSupportHuntPlayerFlags );
|
||||
|
||||
function handleStatSupportHuntYouFlags (%msgType, %msgString, %flagcount)
|
||||
{
|
||||
%clientid = PlayerList.getMyID();
|
||||
StatMissionData.ClientHuntFlags[%clientid] = %flagcount;
|
||||
callback.trigger(onHuntFlagChange, %clientid, %flagcount);
|
||||
}
|
||||
addMessageCallback( 'MsgHuntYouHaveFlags', handleStatSupportHuntYouFlags );
|
||||
|
||||
function handleStatSupportHuntPlayerDrop (%msgType, %msgString, %clientname, %flagcount)
|
||||
{
|
||||
%name = detag(%clientname);
|
||||
%clientid = PlayerList.getIDByName(%name);
|
||||
StatMissionData.ClientHuntFlags[%clientid] = 0;
|
||||
callback.trigger(onHuntFlagChange, %clientid, 0);
|
||||
}
|
||||
addMessageCallback( 'MsgHuntPlayerDroppedFlags', handleStatSupportHuntPlayerDrop );
|
||||
|
||||
function handleStatSupportHuntYouDrop (%msgType, %msgString, %flagcount)
|
||||
{
|
||||
%clientid = PlayerList.getMyID();
|
||||
StatMissionData.ClientHuntFlags[%clientid] = 0;
|
||||
callback.trigger(onHuntFlagChange, %clientid, 0);
|
||||
}
|
||||
addMessageCallback( 'MsgHuntYouDroppedFlags', handleStatSupportHuntYouDrop );
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// TAC2 Specific Stuff
|
||||
|
||||
function handleStatSupportTACFriend (%msgType, %msgString, %clientid, %points)
|
||||
{
|
||||
if(%clientid $= 0 || %clientid $= "")
|
||||
return;
|
||||
StatMissionData.ClientTACFriendVehicleKill[%clientid]++;
|
||||
%myid = PlayerList.getMyID();
|
||||
%team = PlayerList.getTeamByID(%myid);
|
||||
StatMissionData.TeamTACFriendVehicleKill[%team]++;
|
||||
callback.trigger(onTACVehicleKill, %clientid);
|
||||
}
|
||||
addMessageCallback( 'MsgTACFriendVehicleKill', handleStatSupportTACFriend );
|
||||
|
||||
function handleStatSupportTACEnemy (%msgType, %msgString, %clientid, %points)
|
||||
{
|
||||
if(%clientid $= 0 || %clientid $= "")
|
||||
return;
|
||||
StatMissionData.ClientTACEnemyVehicleKill[%clientid]++;
|
||||
%myid = PlayerList.getMyID();
|
||||
%team = PlayerList.getTeamByID(%myid);
|
||||
StatMissionData.TeamTACEnemyVehicleKill[%team]++;
|
||||
callback.trigger(onTACVehicleKill, %clientid);
|
||||
}
|
||||
addMessageCallback( 'MsgTACEnemyVehicleKill', handleStatSupportTACEnemy );
|
||||
|
||||
//===========================================================================
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// DATA RETURN FUNCTIONS
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Client Data
|
||||
|
||||
// This function will return the clients name, even if they have dropped
|
||||
function StatSupport::getClientName(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientName[%client] = StatMissionData.ClientName[%client] $= "" ? "Unknown" : StatMissionData.ClientName[%client];
|
||||
return StatMissionData.ClientName[%client];
|
||||
}
|
||||
|
||||
function StatSupport::getClientScore(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientScore[%client] = StatMissionData.ClientScore[%client] $= "" ? 0 : StatMissionData.ClientScore[%client];
|
||||
return StatMissionData.ClientScore[%client];
|
||||
}
|
||||
|
||||
function StatSupport::getClientDeaths(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientDeath[%client] = StatMissionData.ClientDeath[%client] $= "" ? 0 : StatMissionData.ClientDeath[%client];
|
||||
return StatMissionData.ClientDeath[%client];
|
||||
}
|
||||
|
||||
function StatSupport::getClientKills(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientKill[%client] = StatMissionData.ClientKill[%client] $= "" ? 0 : StatMissionData.ClientKill[%client];
|
||||
return StatMissionData.ClientKill[%client];
|
||||
}
|
||||
|
||||
function StatSupport::getClientTeamKills(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientTeamKill[%client] = StatMissionData.ClientTeamKill[%client] $= "" ? 0 : StatMissionData.ClientTeamKill[%client];
|
||||
return StatMissionData.ClientTeamKill[%client];
|
||||
}
|
||||
|
||||
function StatSupport::getClientHeadShot(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientHeadShot[%client] = StatMissionData.ClientHeadShot[%client] $= "" ? 0 : StatMissionData.ClientHeadShot[%client];
|
||||
return StatMissionData.ClientHeadShot[%client];
|
||||
}
|
||||
|
||||
function StatSupport::getClientDeathByType(%this, %client, %damageType)
|
||||
{
|
||||
StatMissionData.ClientDeathBy[%client, %damageType] = StatMissionData.ClientDeathBy[%client, %damageType] $= "" ? 0 : StatMissionData.ClientDeathBy[%client, %damageType];
|
||||
return StatMissionData.ClientDeathBy[%client, %damageType];
|
||||
}
|
||||
|
||||
function StatSupport::getClientKillByType(%this, %client, %damageType)
|
||||
{
|
||||
StatMissionData.ClientKillBy[%client, %damageType] = StatMissionData.ClientKillBy[%client, %damageType] $= "" ? 0 : StatMissionData.ClientKillBy[%client, %damageType];
|
||||
return StatMissionData.ClientKillBy[%client, %damageType];
|
||||
}
|
||||
|
||||
function StatSupport::getClientDeathByClient(%this, %client, %kclient)
|
||||
{
|
||||
StatMissionData.ClientDeathByKiller[%client, %kclient] = StatMissionData.ClientDeathByKiller[%client, %kclient] $= "" ? 0 : StatMissionData.ClientDeathByKiller[%client, %kclient];
|
||||
return StatMissionData.ClientDeathByKiller[%client, %kclient];
|
||||
}
|
||||
|
||||
function StatSupport::getClientKillByClient(%this, %client, %vclient)
|
||||
{
|
||||
StatMissionData.ClientKillByVictim[%client, %vclient] = StatMissionData.ClientKillByVictim[%client, %vclient] $= "" ? 0 : StatMissionData.ClientKillByVictim[%client, %vclient];
|
||||
return StatMissionData.ClientKillByVictim[%client, %vclient];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Game Stat Data
|
||||
|
||||
function StatSupport::getClientGrabs(%this, %clientid)
|
||||
{
|
||||
StatMissionData.ClientFlagGrab[%clientid] = StatMissionData.ClientFlagGrab[%clientid] $= "" ? 0 : StatMissionData.ClientFlagGrab[%clientid];
|
||||
return StatMissionData.ClientFlagGrab[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientDrops(%this, %clientid)
|
||||
{
|
||||
StatMissionData.ClientFlagDrop[%clientid] = StatMissionData.ClientFlagDrop[%clientid] $= "" ? 0 : StatMissionData.ClientFlagDrop[%clientid];
|
||||
return StatMissionData.ClientFlagDrop[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientCaps(%this, %clientid)
|
||||
{
|
||||
StatMissionData.ClientFlagCap[%clientid] = StatMissionData.ClientFlagCap[%clientid] $= "" ? 0 : StatMissionData.ClientFlagCap[%clientid];
|
||||
return StatMissionData.ClientFlagCap[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientReturns(%this, %clientid)
|
||||
{
|
||||
StatMissionData.ClientFlagReturn[%clientid] = StatMissionData.ClientFlagReturn[%clientid] $= "" ? 0 : StatMissionData.ClientFlagReturn[%clientid];
|
||||
return StatMissionData.ClientFlagReturn[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientFFGrabs(%this, %clientid)
|
||||
{
|
||||
StatMissionData.ClientFFGrab[%clientid] = StatMissionData.ClientFFGrab[%clientid] $= "" ? 0 : StatMissionData.ClientFFGrab[%clientid];
|
||||
return StatMissionData.ClientFFGrab[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientFlagsCarried(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientHuntFlags[%clientid] = StatMissionData.ClientHuntFlags[%clientid] $= "" ? 0 : StatMissionData.ClientHuntFlags[%clientid];
|
||||
return StatMissionData.ClientHuntFlags[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientTACFriendlyVehiclesKilled(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientTACFriendVehicleKill[%clientid] = StatMissionData.ClientTACFriendVehicleKill[%clientid] $= "" ? 0 : StatMissionData.ClientTACFriendVehicleKill[%clientid];
|
||||
return StatMissionData.ClientTACFriendVehicleKill[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getClientTACEnemyVehiclesKilled(%this, %client)
|
||||
{
|
||||
StatMissionData.ClientTACEnemyVehicleKill[%clientid] = StatMissionData.ClientTACEnemyVehicleKill[%clientid] $= "" ? 0 : StatMissionData.ClientTACEnemyVehicleKill[%clientid];
|
||||
return StatMissionData.ClientTACEnemyVehicleKill[%clientid];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Team Data
|
||||
|
||||
function StatSupport::getTeamScore(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamScore[%teamid] = StatMissionData.TeamScore[%teamid] $= "" ? 0 : StatMissionData.TeamScore[%teamid];
|
||||
return StatMissionData.TeamScore[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamDeaths(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamDeath[%teamid] = StatMissionData.TeamDeath[%teamid] $= "" ? 0 : StatMissionData.TeamDeath[%teamid];
|
||||
return StatMissionData.TeamDeath[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamKills(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamKill[%teamid] = StatMissionData.TeamKill[%teamid] $= "" ? 0 : StatMissionData.TeamKill[%teamid];
|
||||
return StatMissionData.TeamKill[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamTeamKills(%this, %client)
|
||||
{
|
||||
StatMissionData.TeamTeamKill[%teamid] = StatMissionData.TeamTeamKill[%teamid] $= "" ? 0 : StatMissionData.TeamTeamKill[%teamid];
|
||||
return StatMissionData.TeamTeamKill[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamDeathByType(%this, %teamid, %damageType)
|
||||
{
|
||||
StatMissionData.TeamDeathBy[%teamid, %damageType] = StatMissionData.TeamDeathBy[%teamid, %damageType] $= "" ? 0 : StatMissionData.TeamDeathBy[%teamid, %damageType];
|
||||
return StatMissionData.TeamDeathBy[%teamid, %damageType];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamKillByType(%this, %teamid, %damageType)
|
||||
{
|
||||
StatMissionData.TeamKillBy[%teamid, %damageType] = StatMissionData.TeamKillBy[%teamid, %damageType] $= "" ? 0 : StatMissionData.TeamKillBy[%teamid, %damageType];
|
||||
return StatMissionData.TeamKillBy[%teamid, %damageType];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamGrabs(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamFlagGrab[%teamid] = StatMissionData.TeamFlagGrab[%teamid] $= "" ? 0 : StatMissionData.TeamFlagGrab[%teamid];
|
||||
return StatMissionData.TeamFlagGrab[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamDrops(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamFlagDrop[%teamid] = StatMissionData.TeamFlagDrop[%teamid] $= "" ? 0 : StatMissionData.TeamFlagDrop[%teamid];
|
||||
return StatMissionData.TeamFlagDrop[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamCaps(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamFlagCap[%teamid] = StatMissionData.TeamFlagCap[%teamid] $= "" ? 0 : StatMissionData.TeamFlagCap[%teamid];
|
||||
return StatMissionData.TeamFlagCap[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamReturns(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamFlagReturn[%teamid] = StatMissionData.TeamFlagReturn[%teamid] $= "" ? 0 : StatMissionData.TeamFlagReturn[%teamid];
|
||||
return StatMissionData.TeamFlagReturn[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamFFGrabs(%this, %teamid)
|
||||
{
|
||||
StatMissionData.TeamFFGrab[%teamid] = StatMissionData.TeamFFGrab[%teamid] $= "" ? 0 : StatMissionData.TeamFFGrab[%teamid];
|
||||
return StatMissionData.TeamFFGrab[%teamid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamTACFriendlyVehiclesKilled(%this, %client)
|
||||
{
|
||||
StatMissionData.TeamTACFriendVehicleKill[%clientid] = StatMissionData.TeamTACFriendVehicleKill[%clientid] $= "" ? 0 : StatMissionData.TeamTACFriendVehicleKill[%clientid];
|
||||
return StatMissionData.TeamTACFriendVehicleKill[%clientid];
|
||||
}
|
||||
|
||||
function StatSupport::getTeamTACEnemyVehiclesKilled(%this, %client)
|
||||
{
|
||||
StatMissionData.TeamTACEnemyVehicleKill[%clientid] = StatMissionData.TeamTACEnemyVehicleKill[%clientid] $= "" ? 0 : StatMissionData.TeamTACEnemyVehicleKill[%clientid];
|
||||
return StatMissionData.TeamTACEnemyVehicleKill[%clientid];
|
||||
}
|
||||
|
||||
409
docs/base/@vl2/z_scripts/support.vl2/support/string_tools.cs
Normal file
409
docs/base/@vl2/z_scripts/support.vl2/support/string_tools.cs
Normal file
|
|
@ -0,0 +1,409 @@
|
|||
// #name = String Tools
|
||||
// #version = 1.5.1
|
||||
// #date = March 18, 2001
|
||||
// #category = Support
|
||||
// #author = Lorne Laliberte
|
||||
// #warrior = Writer
|
||||
// #email = t2beta@cdnwriter.com
|
||||
// #web = http://www.t2scripts.com
|
||||
// #web = http://www.cdnwriter.com
|
||||
// #description = Adds functions to manipulate and work with strings
|
||||
// #status = release
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Test for multiple periods in isNumeric() fixed 03/20/02 by UberGuy (FT)
|
||||
|
||||
// weirdly enough, the printf() function will only work if I uncomment the next 9 lines!
|
||||
//%p1 =
|
||||
//%p2 =
|
||||
//%p3 =
|
||||
//%p4 =
|
||||
//%p5 =
|
||||
//%p6 =
|
||||
//%p7 =
|
||||
//%p8 =
|
||||
//%p9;
|
||||
|
||||
function printf(%s, %p1, %p2, %p3, %p4, %p5, %p6, %p7, %p8, %p9)
|
||||
{
|
||||
for(%i = 1; (strstr(%s, "%" @ %i) != -1) && (%i < 10); %i++)
|
||||
%s = strreplace(%s, "%" @ %i, %p[%i]);
|
||||
|
||||
return %s;
|
||||
}
|
||||
|
||||
|
||||
// get a filename (with path) from %text, assuming the filename starts at
|
||||
// the beginning of %text
|
||||
//
|
||||
// set %numeric to true to allow filenames with all-numeric extensions
|
||||
// like .001 etc.
|
||||
//
|
||||
// set %isfile to true to only return the filename if the file is visible to
|
||||
// Tribes 2 (i.e. not .ds0 files, etc)
|
||||
//
|
||||
// returns "" if no filename found
|
||||
function getFilename(%text, %numeric, %isfile)
|
||||
{
|
||||
%ext = firstWord(fileExt(%text));
|
||||
|
||||
if(!%numeric)
|
||||
{
|
||||
while( (%ext !$= "") && isNumeric(%ext) )
|
||||
{
|
||||
%text = getSubStr(%text, 0, strstr(%text, %ext));
|
||||
%ext = firstWord(fileExt(%text));
|
||||
}
|
||||
}
|
||||
|
||||
if(%ext !$= "")
|
||||
{
|
||||
%end_pos = strstr(%text, %ext) + strlen(%ext);
|
||||
|
||||
if( %isfile && !isFile(getSubStr(%text, 0, %end_pos)) )
|
||||
return "";
|
||||
|
||||
return getSubStr(%text, 0, %end_pos);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// returns true if %text consists of nothing but digits and/or decimals
|
||||
// note: rejects strings with more than one decimal, or with a + or - as anything but the first character
|
||||
// (+ or - are only allowed as the first character in the string)
|
||||
function isNumeric(%text)
|
||||
{
|
||||
for(%i = 0; (%char = getSubStr(%text, %i, 1)) !$= ""; %i++)
|
||||
{
|
||||
switch$(%char)
|
||||
{
|
||||
case "0":
|
||||
continue;
|
||||
case "1":
|
||||
continue;
|
||||
case "2":
|
||||
continue;
|
||||
case "3":
|
||||
continue;
|
||||
case "4":
|
||||
continue;
|
||||
case "5":
|
||||
continue;
|
||||
case "6":
|
||||
continue;
|
||||
case "7":
|
||||
continue;
|
||||
case "8":
|
||||
continue;
|
||||
case "9":
|
||||
continue;
|
||||
case ".":
|
||||
if(%dot_count >= 1)
|
||||
return false;
|
||||
|
||||
%dot_count++;
|
||||
continue;
|
||||
case "-":
|
||||
if(%i) // only valid as first character
|
||||
return false;
|
||||
|
||||
continue;
|
||||
case "+":
|
||||
if(%i) // only valid as first character
|
||||
return false;
|
||||
|
||||
continue;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// %text passed the test
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return line number %line (0 based) in %text
|
||||
// set %delimiter to a string to break each line at (defaults to "\n")
|
||||
function getLine(%text, %line, %delimiter)
|
||||
{
|
||||
%line += 0; // set %line to 0 by default
|
||||
|
||||
if(%delimiter $= "")
|
||||
{
|
||||
%delimiter = "\n";
|
||||
%delimiter_len = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
%delimiter_len = strlen(%delimiter);
|
||||
}
|
||||
|
||||
%i = 0;
|
||||
while( (%endline_pos = strstr(%text, %delimiter)) != -1 )
|
||||
{
|
||||
if(%i == %line)
|
||||
return getSubStr(%text, 0, %endline_pos);
|
||||
|
||||
%text = getSubStr(%text, %endline_pos + %delimiter_len, 1000000);
|
||||
%i++;
|
||||
}
|
||||
|
||||
// check the last line
|
||||
if( (%text !$= "") && ( %i == %line) )
|
||||
return %text;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// return number of lines in %text
|
||||
// set %skip_whitespace to true to not count lines containing only whitespace
|
||||
// set %delimiter to a string to break each line at (defaults to "\n")
|
||||
function getLineCount(%text, %skip_whitespace, %delimiter)
|
||||
{
|
||||
if(%delimiter $= "")
|
||||
{
|
||||
%delimiter = "\n";
|
||||
%delimiter_len = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
%delimiter_len = strlen(%delimiter);
|
||||
}
|
||||
|
||||
%lines = 0;
|
||||
while( (%endline_pos = strstr(%text, %delimiter)) != -1 )
|
||||
{
|
||||
if( %skip_whitespace && (trim(getSubStr(%text, 0, %endline_pos)) $= "") )
|
||||
continue;
|
||||
|
||||
%text = getSubStr(%text, %endline_pos + %delimiter_len, 1000000);
|
||||
%lines++;
|
||||
}
|
||||
|
||||
if(%skip_whitespace)
|
||||
%text = trim(%text);
|
||||
|
||||
// count last line if it exists
|
||||
if(%text !$= "")
|
||||
%lines++;
|
||||
|
||||
return %lines;
|
||||
}
|
||||
|
||||
|
||||
// shortcut for calling getLineCount with %skip_whitespace set
|
||||
function getTextLineCount(%text, %delimiter)
|
||||
{
|
||||
return getLineCount(%text, true, %delimiter);
|
||||
}
|
||||
|
||||
|
||||
// replaces the built-in firstWord() and getWord() functions
|
||||
package getWordOverrides {
|
||||
|
||||
// temporary replacement for firstWord()
|
||||
function firstWord(%text)
|
||||
{
|
||||
return parent::firstWord(trim(%text));
|
||||
}
|
||||
|
||||
}; // -- end of package: getWordOverrides
|
||||
|
||||
activatePackage(getWordOverrides);
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Date functions
|
||||
//
|
||||
// The following date functions are designed to operate on strings where:
|
||||
//
|
||||
// - the day is expressed as an integer of 1 or 2 digits
|
||||
// - the year is expressed as a 4-digit integer
|
||||
// - the month is expressed as either a three-letter word (Nov)
|
||||
// or with the full month name (November)
|
||||
//
|
||||
// Currently no ##/##/## formats are supported to avoid internationalization
|
||||
// issues.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
// get the month from %text as an int from 1 to 12
|
||||
// returns "" if month not found
|
||||
function getMonthFromString(%text)
|
||||
{
|
||||
%text = trim(%text);
|
||||
|
||||
for(%i = 0; (%word = getword(%text, %i)) !$= ""; %i++)
|
||||
{
|
||||
//...use first 3 letters to help minimize errors from spelling mistakes
|
||||
%month = getSubStr(%word, 0, 3);
|
||||
switch$(%month)
|
||||
{
|
||||
case "jan":
|
||||
return 1;
|
||||
case "feb":
|
||||
return 2;
|
||||
case "mar":
|
||||
return 3;
|
||||
case "apr":
|
||||
return 4;
|
||||
case "may":
|
||||
return 5;
|
||||
case "jun":
|
||||
return 6;
|
||||
case "jul":
|
||||
return 7;
|
||||
case "aug":
|
||||
return 8;
|
||||
case "sep":
|
||||
return 9;
|
||||
case "oct":
|
||||
return 10;
|
||||
case "nov":
|
||||
return 11;
|
||||
case "dec":
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
return ""; // month not found
|
||||
}
|
||||
|
||||
|
||||
// get the year from %text as a 4-digit integer
|
||||
// returns "" if year not found
|
||||
function getYearFromString(%text)
|
||||
{
|
||||
%text = trim(%text);
|
||||
|
||||
for(%i = 0; (%word = getword(%text, %i)) !$= ""; %i++)
|
||||
{
|
||||
if( isNumeric(%word) && (strlen(%word) == 4) )
|
||||
return %word;
|
||||
}
|
||||
return ""; // year not found
|
||||
}
|
||||
|
||||
|
||||
// get the day from %text as an integer
|
||||
// returns "" if year not found
|
||||
function getDayFromString(%text)
|
||||
{
|
||||
%text = trim(%text);
|
||||
|
||||
for(%i = 0; (%word = getword(%text, %i)) !$= ""; %i++)
|
||||
{
|
||||
// remove any trailing commas
|
||||
%comma_pos = strstr(%word, ",");
|
||||
if(%comma_pos != -1)
|
||||
%word = getSubStr(%word, 0, %comma_pos);
|
||||
|
||||
if( isNumeric(%word) && (strlen(%word) <= 2) )
|
||||
return %word;
|
||||
}
|
||||
return ""; // day not found
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Version functions
|
||||
//
|
||||
// The following version functions are designed to operate on strings using
|
||||
// the standard version.revision.subrevision numbering system.
|
||||
//
|
||||
// In this system, 1.2.3 has a version of 1, a revision of 2 and a subrevision
|
||||
// of 3.
|
||||
//
|
||||
// 1.10 has a version of 1 and a revision of 10, and is NEWER than 1.2, which
|
||||
// has a version of 1 and a revision of 2.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// get the version number from %text
|
||||
// returns "" if version not found
|
||||
function getVersion(%text, %sublevel)
|
||||
{
|
||||
%text = trim(%text);
|
||||
|
||||
if(%text $= "")
|
||||
return "";
|
||||
|
||||
%decimal_pos = strstr(%text, ".");
|
||||
|
||||
while(%sublevel)
|
||||
{
|
||||
if(%decimal_pos == -1) // we aren't at the desired sublevel and there are no more levels to check
|
||||
return "";
|
||||
|
||||
// skip to next sublevel
|
||||
%text = getSubStr(%text, %decimal_pos + 1, 1000);
|
||||
%decimal_pos = strstr(%text, ".");
|
||||
|
||||
%sublevel--;
|
||||
}
|
||||
|
||||
if(%decimal_pos == -1)
|
||||
return %text;
|
||||
else
|
||||
return getSubStr(%text, 0, %decimal_pos);
|
||||
}
|
||||
|
||||
|
||||
// get the revision number from %text
|
||||
// returns "" if version not found
|
||||
function getRevision(%text)
|
||||
{
|
||||
return getVersion(%text, 1);
|
||||
}
|
||||
|
||||
|
||||
// get the subrevision number from %text
|
||||
// returns "" if version not found
|
||||
function getSubrevision(%text)
|
||||
{
|
||||
return getVersion(%text, 2);
|
||||
}
|
||||
|
||||
|
||||
// compare two version strings
|
||||
//
|
||||
// returns 1 if %two is newer than %one
|
||||
// returns -1 if %two is older than %one
|
||||
// returns 0 if %two and %one are the same
|
||||
function versionCompare(%one, %two)
|
||||
{
|
||||
if(%two $= "")
|
||||
return 0; // no version isn't newer than anything :)
|
||||
|
||||
if(%one $= "")
|
||||
return 1; // any version is newer than no version :)
|
||||
|
||||
%one_version = getVersion(%one);
|
||||
%one_revision = getRevision(%one);
|
||||
%one_subrevision = getSubrevision(%one);
|
||||
|
||||
%two_version = getVersion(%two);
|
||||
%two_revision = getRevision(%two);
|
||||
%two_subrevision = getSubrevision(%two);
|
||||
|
||||
if(%two_version > %one_version)
|
||||
return 1;
|
||||
else if(%two_version < %one_version)
|
||||
return -1;
|
||||
else // %two_version == %one_version
|
||||
{
|
||||
if(%two_revision > %one_revision)
|
||||
return 1;
|
||||
else if(%two_revision < %one_revision)
|
||||
return -1;
|
||||
else // %two_revision == %one_revision
|
||||
{
|
||||
if(%two_subrevision > %one_subrevision)
|
||||
return 1;
|
||||
else if(%two_subrevision < %one_subrevision)
|
||||
return -1;
|
||||
else // %two_subrevision == %one_subrevision
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
docs/base/@vl2/z_scripts/support.vl2/support/tap.cs
Normal file
72
docs/base/@vl2/z_scripts/support.vl2/support/tap.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
// #name = Tap Handler
|
||||
// #version = 1.0.0
|
||||
// #date = February 24, 2001
|
||||
// #category = Support
|
||||
// #author = Lorne Laliberte
|
||||
// #warrior = Writer
|
||||
// #email = t2beta@cdnwriter.com
|
||||
// #web = http://www.t2scripts.com
|
||||
// #web = http://www.cdnwriter.com
|
||||
// #description = Adds functions that scripts can use to check for tapped keys or buttons
|
||||
// #status = release
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function tap(%name, %taptime)
|
||||
{
|
||||
if(%name $= "")
|
||||
return;
|
||||
|
||||
if(!%taptime)
|
||||
%taptime = 0.01;
|
||||
|
||||
%obj = "tap_" @ %name;
|
||||
|
||||
if( isObject(%obj) )
|
||||
{
|
||||
%obj.tapped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
new ScriptObject(%obj)
|
||||
{
|
||||
class = tap;
|
||||
tapped = true;
|
||||
};
|
||||
}
|
||||
|
||||
%obj.id = %obj.schedule(%taptime, clear);
|
||||
}
|
||||
|
||||
function wasTapped(%name)
|
||||
{
|
||||
if(%name $= "")
|
||||
return false;
|
||||
|
||||
return ("tap_" @ %name).tapped;
|
||||
}
|
||||
|
||||
function deleteTap(%name)
|
||||
{
|
||||
if(%name $= "")
|
||||
return;
|
||||
|
||||
("tap_" @ %name).delete();
|
||||
}
|
||||
|
||||
function rescueTap(%name)
|
||||
{
|
||||
if(%name $= "")
|
||||
return;
|
||||
|
||||
cancel( ("tap_" @ %name).id );
|
||||
}
|
||||
|
||||
function tap::clear(%this)
|
||||
{
|
||||
%this.tapped = false;
|
||||
}
|
||||
|
||||
function tap::rescue(%this)
|
||||
{
|
||||
cancel(%this.id);
|
||||
}
|
||||
432
docs/base/@vl2/z_scripts/support.vl2/support/team_tracker.cs
Normal file
432
docs/base/@vl2/z_scripts/support.vl2/support/team_tracker.cs
Normal file
|
|
@ -0,0 +1,432 @@
|
|||
// #name = Team Tracking Support
|
||||
// #version = 0.0.6
|
||||
// #date = July 15, 2001
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Provides information about teams and the players on them.
|
||||
// #status = Release
|
||||
// #include = support/callback.cs
|
||||
// #include = support/PJEnhancedRecording.cs
|
||||
|
||||
// This class defines the following:
|
||||
// Fields:
|
||||
// myID : the player's clientID
|
||||
// myTag : the player's tribal tag. "" if none.
|
||||
// myName : the player's own name
|
||||
// enemyTeamID : the # of the enemy team. In gametypes with more or less
|
||||
// than 2 teams, this is -1
|
||||
// friendlyTeamID : the # of the player's own team
|
||||
// numTeams : the number of teams, not including observers as a team
|
||||
// idsByName[] : an array of player ID's indexed by name. So idsByName["Bob"]
|
||||
// would return Bob's clientID.
|
||||
// teamName[] : an array of team names. teamName[0] is always "Observer".
|
||||
// teamGroup[] : an array of SimGroups containing references to the Player
|
||||
// class instances. So to iterate over all of the observers:
|
||||
// for(%i=0; %i < teamTracker.teamGroup[0].getCount(); %i++) {
|
||||
// ...
|
||||
// }
|
||||
// Methods: - these are modeled directly after PJ's functions.
|
||||
// Props to him for the originals. Like his, mine accept a %detag argument
|
||||
// that will strip tag codes from passed arguments if it is sent as 1 or true.
|
||||
//
|
||||
// isManagerName(%name,%detag) : true if %name is the player's name
|
||||
// getManagerId() : the player's clientID. Same as teamTracker.myID
|
||||
// getManagerName() : the player's name. Same as teamTracker.myName
|
||||
// getManagerTags() : the player's tribal tags. Same as teamTracker.myTag
|
||||
// getEnemyTeamName() : the name of the enemy team. "" if <> 2 teams
|
||||
// getFriendlyTeamName() : the name of the player's team
|
||||
// getClientName(%ID,%detag) : the name of the player with clientID %ID
|
||||
// getClientID(%name,%detag) : the clientID of the player with name %name
|
||||
// getClientTeamID(%ID,%detag) : the teamID of the player with clientID %ID
|
||||
// getPlayerTeamId(%name,%detag): the teamID of the player with name %name
|
||||
// getClientTeamName(%ID,%detag): the name of the team of the player with clientID %ID
|
||||
// getTeamSize(%teamID,%detag) : the number of players on a given team
|
||||
// getClientRef(%ID) : a reference to the playerRef object for clientID %ID
|
||||
// getPlayerRef(%name) : a reference to the playerRef object for player %name
|
||||
// getSelfRef() : a reference to the client's own playerRef object
|
||||
//
|
||||
// Callback:
|
||||
// TeamUpdated : passes - the team ID that changed. Called when the size of a
|
||||
// team changes.
|
||||
// PlayerLeavingGame : passes - the client ID of the dropping player
|
||||
// MyTeamChanged : passes - the player's new teamID
|
||||
// PlayerJoinedTeam : passes - teamID of the affected team & the player's clientID
|
||||
|
||||
// Miscellaneous:
|
||||
|
||||
// strippedName(%playerRep) : Returns the full name of the player with all special
|
||||
// characters removed
|
||||
// baseName() : Returns the player's name without team tags
|
||||
// baseTags() : Returns the player's tribal tags, or "" if none.
|
||||
|
||||
// ============================================================================
|
||||
|
||||
function makeTracker() {
|
||||
|
||||
if(!isObject(teamTracker)) {
|
||||
|
||||
new ScriptObject(teamTracker)
|
||||
{
|
||||
class = teamTracker;
|
||||
myID = 0;
|
||||
myTag = "";
|
||||
myName = "";
|
||||
enemyTeamID = 0;
|
||||
friendlyTeamID = 0;
|
||||
numTeams = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function resetTeamTracker() {
|
||||
|
||||
for (%i = 0; %i<= teamTracker.numTeams; %i++) {
|
||||
if (isObject(teamTracker.teamGroup[%i])) {
|
||||
teamTracker.teamGroup[%i].delete();
|
||||
}
|
||||
}
|
||||
teamTracker.delete();
|
||||
makeTracker();
|
||||
}
|
||||
|
||||
function teamTracker::isManagerName(%this, %clientname, %detag) {
|
||||
|
||||
if (%detag) %clientname = detag(%clientname);
|
||||
return (%this.name $= %clientname);
|
||||
}
|
||||
|
||||
function teamTracker::getManagerId(%this) {
|
||||
|
||||
return %this.myID;
|
||||
}
|
||||
|
||||
function teamTracker::getManagerName(%this) {
|
||||
|
||||
return %this.myName;
|
||||
}
|
||||
|
||||
function teamTracker::getManagerTags(%this) {
|
||||
|
||||
return %this.myTag;
|
||||
}
|
||||
|
||||
function teamTracker::getEnemyTeamName(%this) {
|
||||
|
||||
return %this.teamName[%this.enemyTeamID];
|
||||
}
|
||||
|
||||
function teamTracker::getFriendlyTeamName(%this) {
|
||||
|
||||
return %this.teamName[%this.friendlyTeamID];
|
||||
}
|
||||
|
||||
function teamTracker::getEnemyTeam(%this) {
|
||||
|
||||
return %this.enemyTeamID;
|
||||
}
|
||||
|
||||
function teamTracker::getClientName(%this, %clientId, %detag) {
|
||||
|
||||
if (%detag) %clientId = detag(%clientId);
|
||||
|
||||
if (isObject($PlayerList[%clientId])) {
|
||||
return $PlayerList[%clientId].name;
|
||||
}
|
||||
else return "";
|
||||
}
|
||||
|
||||
function teamTracker::getClientId(%this, %name, %detag) {
|
||||
|
||||
if (%detag) %name = detag(%name);
|
||||
|
||||
return %this.idsByName[%name];
|
||||
}
|
||||
|
||||
function teamTracker::getClientTeamId(%this, %clientId, %detag) {
|
||||
|
||||
if (%detag) %clientId = detag(%clientId);
|
||||
|
||||
%player = $PlayerList[%clientId];
|
||||
if (isObject(%player)) return %player.teamId;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
function teamTracker::getClientRef(%this, %clientId, %detag) {
|
||||
|
||||
if (%detag) %clientId = detag(%clientId);
|
||||
|
||||
%ref = $PlayerList[%clientId];
|
||||
if (isObject(%ref)) return %ref;
|
||||
else return "";
|
||||
}
|
||||
|
||||
function teamTracker::getPlayerRef(%this, %name, %detag) {
|
||||
|
||||
if (%detag) %name = detag(%name);
|
||||
|
||||
%ref = $PlayerList[%this.idsByName[%playerName]];
|
||||
if (isObject(%ref)) return %ref;
|
||||
else return "";
|
||||
}
|
||||
|
||||
function teamTracker::getSelfRef(%this) {
|
||||
|
||||
return $PlayerList[%this.myID];
|
||||
}
|
||||
|
||||
function teamTracker::getPlayerTeamId(%this, %playerName, %detag) {
|
||||
|
||||
if (%detag) %playerName = detag(%playerName);
|
||||
|
||||
%player = $PlayerList[%this.idsByName[%playerName]];
|
||||
if (isObject(%player)) return %player.teamId;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
function teamTracker::getClientTeamName(%this, %clientId, %detag) {
|
||||
|
||||
if(%detag) %clientId = detag(%clientId);
|
||||
|
||||
if (isObject($PlayerList[%clientId])) {
|
||||
return %this.teamName[$PlayerList[%clientId].teamId];
|
||||
}
|
||||
else return "";
|
||||
}
|
||||
|
||||
function teamTracker::getTeamSize(%this, %teamID, %detag) {
|
||||
|
||||
if(%detag) %teamID = detag(%teamID);
|
||||
|
||||
if ((%teamID < 0) || (%teamID > %this.numTeams)) return -1;
|
||||
else return %this.teamGroup[%teamID].getCount();
|
||||
}
|
||||
|
||||
//=== PlayerRef utilites ======================================================
|
||||
|
||||
function strippedName(%playerRep) {
|
||||
|
||||
if (!isObject(%playerRep)) return "";
|
||||
|
||||
// Lazy evaluation, cached value
|
||||
if (%playerRep.strippedName $= "") {
|
||||
%playerRep.strippedName = stripMLControlChars(%playerRep.name);
|
||||
}
|
||||
return %playerRep.strippedName;
|
||||
}
|
||||
|
||||
function baseName(%playerRep) {
|
||||
|
||||
if (!isObject(%playerRep)) return "";
|
||||
|
||||
if (%playerRep.baseName $= "") {
|
||||
%p1 = strstr(%playerRep.name,"\c6");
|
||||
%p2 = strstr(%playerRep.name,"\c7");
|
||||
%p3 = strstr(%playerRep.name,"\x11");
|
||||
if(%p1 < %p2) %baseName = getSubStr(%playerRep.name,%p1+1,strstr(%playerRep.name,"\c7")-1);
|
||||
if(%p1 > %p2) %baseName = getSubStr(%playerRep.name,%p1+1,strstr(%playerRep.name,"\x11"));
|
||||
if(%baseName $= "") %baseName = %playerRep.name;
|
||||
%playerRep.baseName = stripChars(%baseName,"\cp\co\c6\c7\c8\c9");
|
||||
}
|
||||
return %playerRep.baseName;
|
||||
}
|
||||
|
||||
function baseTags(%playerRep) {
|
||||
|
||||
if (!isObject(%playerRep)) return "";
|
||||
|
||||
if (%playerRep.baseTags $= "") {
|
||||
%p1 = strstr(%playerRep.name,"\c6");
|
||||
%p2 = strstr(%playerRep.name,"\c7");
|
||||
%p3 = strstr(%playerRep.name,"\x11");
|
||||
if(%p1 > %p2) %baseTag = getSubStr(%playerRep.name,%p2+1,strstr(%playerRep.name,"\c6")-1);
|
||||
if(%p1 < %p2) %baseTag = getSubStr(%playerRep.name,%p2+1,strstr(%playerRep.name,"\x11"));
|
||||
if(%p2 == %p3) %baseTag = "";
|
||||
%playerRep.baseTags = stripChars(%baseTag,"\cp\co\c6\c7\c8\c9");
|
||||
}
|
||||
return %playerRep.baseTags;
|
||||
}
|
||||
|
||||
//=== Package Wrappers ========================================================
|
||||
|
||||
package teamTrackerPkg {
|
||||
|
||||
function handleClientJoin(%msgType, %msgString, %clientName, %clientId, %targetId,
|
||||
%isAI, %isAdmin, %isSuperAdmin, %isSmurf, %guid) {
|
||||
|
||||
parent::handleClientJoin(%msgType, %msgString, %clientName, %clientId, %targetId,
|
||||
%isAI, %isAdmin, %isSuperAdmin, %isSmurf, %guid);
|
||||
|
||||
%clName = detag(%clientName);
|
||||
|
||||
if(StrStr(%msgString, "Welcome to Tribes") != -1) {
|
||||
teamTracker.myID = %clientId;
|
||||
teamTracker.myName = %clName;
|
||||
|
||||
if(%isSmurf) teamTracker.myTag = "";
|
||||
}
|
||||
|
||||
teamTracker.idsByName[%clName] = %clientId;
|
||||
|
||||
// Put player in observer group until I hear otherwise
|
||||
if (!isObject(teamTracker.teamGroup[0]))
|
||||
teamTracker.teamGroup[0] = new SimSet("TrackerTeam_0");
|
||||
|
||||
// $PlayerList[%clientID] is guaranteed to be a valid object here
|
||||
teamTracker.teamGroup[0].add($PlayerList[%clientID]);
|
||||
Callback.Trigger(TeamUpdated,0);
|
||||
}
|
||||
|
||||
function handleClientDrop(%msgType, %msgString, %clientName, %clientId) {
|
||||
|
||||
//if (%clientId != teamTracker.myID) {}
|
||||
|
||||
%clName = detag(%clientName);
|
||||
teamTracker.idsByName[%clName] = "";
|
||||
|
||||
%player = $PlayerList[%clientID];
|
||||
if (%player) {
|
||||
teamTracker.teamGroup[%player.teamID].remove(%player);
|
||||
|
||||
Callback.Trigger(TeamUpdated,%player.teamID);
|
||||
}
|
||||
Callback.Trigger(PlayerLeavingGame,%clientID);
|
||||
|
||||
parent::handleClientDrop(%msgType, %msgString, %clientName, %clientId);
|
||||
}
|
||||
|
||||
function handleClientJoinTeam(%msgType, %msgString, %clientName, %teamName,
|
||||
%clientId, %teamId) {
|
||||
|
||||
if(%clientId == teamTracker.myID) {
|
||||
if(%teamId == 0) {
|
||||
teamTracker.friendlyTeamID = teamTracker.enemyTeamID = -1;
|
||||
}
|
||||
else {
|
||||
teamTracker.friendlyTeamID = %teamID;
|
||||
// Assign a valid enemy team only if there are 2 teams.
|
||||
teamTracker.enemyTeamID =
|
||||
(teamTracker.numTeams == 2) ? ((%teamID == 1) ? 2 : 1) : -1;
|
||||
}
|
||||
// event here for my team change
|
||||
Callback.Trigger(MyTeamChanged,%teamID);
|
||||
}
|
||||
|
||||
%player = $PlayerList[%clientID];
|
||||
// Looks like players who start the map teamed are on team -1...
|
||||
if (isObject(%player)) {
|
||||
|
||||
%oldteam = %player.teamId;
|
||||
if (%oldTeam < 0) %oldTeam = 0;
|
||||
if (%oldteam != %teamID) {
|
||||
// Move out of old team
|
||||
%teamGrp = teamTracker.teamGroup[%oldTeam];
|
||||
if (isObject(%teamGrp)) {
|
||||
if (%teamGrp.isMember(%player)) {
|
||||
%teamGrp.remove(%player);
|
||||
}
|
||||
}
|
||||
|
||||
// Add to new
|
||||
%teamGrp = teamTracker.teamGroup[%teamID];
|
||||
if (!isObject(%teamGrp)) {
|
||||
%teamGrp = teamTracker.teamGroup[%teamID] =
|
||||
new SimSet("TrackerTeam_" @ %teamID);
|
||||
}
|
||||
%teamGrp.add(%player);
|
||||
|
||||
// Event here indicating team size update
|
||||
Callback.Trigger(TeamUpdated,%teamID);
|
||||
Callback.Trigger(PlayerJoinedTeam,%teamID,%clientID);
|
||||
}
|
||||
}
|
||||
parent::handleClientJoinTeam(%msgType, %msgString, %clientName, %teamName,
|
||||
%clientId, %teamId);
|
||||
}
|
||||
|
||||
function handleTeamListMessage(%msgType, %msgString, %teamCount, %teamList) {
|
||||
|
||||
teamTracker.numTeams = %teamCount;
|
||||
for ( %i = 0; %i < %teamCount; %i++ ) {
|
||||
%j = %i+1;
|
||||
teamTracker.teamName[%j] = detag(getRecord(%teamList, %i));
|
||||
if (!isObject(teamTracker.teamGroup[%j]))
|
||||
teamTracker.teamGroup[%j] = new SimSet("TrackerTeam_" @ %j);
|
||||
}
|
||||
teamTracker.teamName[0] = "Observer";
|
||||
if (!isObject(teamTracker.teamGroup[0]))
|
||||
teamTracker.teamGroup[0] = new SimSet("TrackerTeam_0");
|
||||
|
||||
parent::handleTeamListMessage(%msgType, %msgString, %teamCount, %teamList);
|
||||
}
|
||||
|
||||
function connect(%address, %password, %playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch) {
|
||||
|
||||
resetTeamTracker();
|
||||
parent::connect(%address, %password, %playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch);
|
||||
}
|
||||
|
||||
function localConnect(%playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch) {
|
||||
|
||||
resetTeamTracker();
|
||||
parent::localConnect(%playerName, %playerRaceGender, %playerSkin, %playerVoice, %playerVoicePitch);
|
||||
}
|
||||
|
||||
// Demo support
|
||||
function loadDemoSettings() {
|
||||
|
||||
resetTeamTracker();
|
||||
NewRecordingData.clientid = ""; // Need to clear this between recordings
|
||||
|
||||
parent::loadDemoSettings();
|
||||
|
||||
teamTracker.teamName[0] = "Observer";
|
||||
if (!isObject(teamTracker.teamGroup[0]))
|
||||
teamTracker.teamGroup[0] = new SimSet("TrackerTeam_0");
|
||||
|
||||
%sz = PlayerListGroup.getCount();
|
||||
for (%i=0; %i < %sz; %i++) {
|
||||
%player = PlayerListGroup.getObject(%i);
|
||||
|
||||
if (!isObject(teamTracker.teamGroup[%player.teamId])) {
|
||||
teamTracker.teamGroup[%player.teamId] = new SimSet("TrackerTeam_" @ %player.teamId);
|
||||
teamTracker.numTeams++;
|
||||
}
|
||||
|
||||
teamTracker.idsByName[%player.name] = %player.clientId;
|
||||
echo(%player.name SPC teamTracker.idsByName[%player.name]);
|
||||
teamTracker.teamGroup[%player.teamId].add(%player);
|
||||
Callback.Trigger(TeamUpdated,%player.teamId);
|
||||
Callback.Trigger(PlayerJoinedTeam,%player.teamId,%player.clientId);
|
||||
}
|
||||
|
||||
// If this demo was recorded with PJs Enhanced info, we can determine team info
|
||||
if (NewRecordingData.clientid !$= "") {
|
||||
|
||||
teamTracker.extendedDemo = true;
|
||||
teamTracker.myID = NewRecordingData.clientid;
|
||||
%player = $PlayerList[teamTracker.myID];
|
||||
teamTracker.myName = %player.name;
|
||||
teamTracker.friendlyTeamID = %player.teamId;
|
||||
teamTracker.enemyTeamID =
|
||||
(teamTracker.numTeams == 2) ? ((%teamID == 1) ? 2 : 1) : -1;
|
||||
Callback.Trigger(MyTeamChanged,%player.teamId);
|
||||
|
||||
if(%player.isSmurf) teamTracker.myTag = "";
|
||||
else teamTracker.myTag = baseTags(%player);
|
||||
}
|
||||
else teamTracker.extendedDemo = false;
|
||||
}
|
||||
|
||||
function LoadingGui::onWake(%this) {
|
||||
|
||||
teamTracker.myTag = getField(wonGetAuthInfo(), 1);
|
||||
parent::onWake(%this);
|
||||
}
|
||||
};
|
||||
|
||||
activatePackage(teamTrackerPkg);
|
||||
makeTracker();
|
||||
313
docs/base/@vl2/z_scripts/support.vl2/support/template_tools.cs
Normal file
313
docs/base/@vl2/z_scripts/support.vl2/support/template_tools.cs
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
// #name = Template Tools
|
||||
// #version = 0.0.1
|
||||
// #date = May 16, 2001
|
||||
// #status = beta
|
||||
// #description = Provides tools for script Authors to define and use code templates
|
||||
// #category = Support
|
||||
// #author = Jon Naiman
|
||||
// #warrior = Ratorasniki
|
||||
// #email = ratorasniki@tribalwar.com
|
||||
// #web = http://www.tribalwar.com
|
||||
//************************************************************************************
|
||||
$TemplateLoadBasic = 1; // Do not load file contents into object
|
||||
// only set to 0 when debugging templates
|
||||
// otherwise it just wastes memory
|
||||
$TemplateClearFile = 1;
|
||||
//************************************************************************************
|
||||
// Template addition & class stuff (ie. 'the guts')
|
||||
function useTemplate(%name, %replacement, %tmp)
|
||||
{
|
||||
if($tempflock == 0) //keep the temp file from being used twice
|
||||
{
|
||||
if(%tmp != 1)
|
||||
%tmp = 0;
|
||||
$tempflock = 1;
|
||||
%TemplateToUse = -1;
|
||||
%TemplateLines = 0;
|
||||
for( %i = 0; %i < Templates.getCount(); %i++ )
|
||||
{
|
||||
if(Templates.getObject(%i).name $= %name)
|
||||
{
|
||||
%TemplateToUse = Templates.getObject(%i);
|
||||
}
|
||||
}
|
||||
if(%TemplateToUse != -1)
|
||||
{
|
||||
if($TemplateLoadBasic == 1)
|
||||
{
|
||||
%TemplateFilename = %TemplateToUse.filename; // get the filename
|
||||
%TemplateToUse.delete(); // delete the old object
|
||||
%TemplateToUse = addTemplate(%TemplateFilename); // recreate w/ contents
|
||||
}
|
||||
%TemplateLines = %TemplateToUse.linenum;
|
||||
%TemplateContents = "";
|
||||
%Filehandle = new FileObject();
|
||||
if(%tmp == 0)
|
||||
{
|
||||
%Filehandle.openForWrite( "support/templates/temp.cs" );
|
||||
} else {
|
||||
%Filehandle.openForAppend( "support/templates/temp.cs" );
|
||||
%Filehandle.writeLine( "" );
|
||||
%Filehandle.writeLine( "//-----Starting Template " @ %TemplateToUse.name @ " using " @ %replacement @ "-----" );
|
||||
%Filehandle.writeLine( "" );
|
||||
}
|
||||
for(%i = 1; %i < %TemplateLines; %i++)
|
||||
{
|
||||
%oldstr = %TemplateToUse.line[%i];
|
||||
%newstr = ReplaceTextInString(%oldstr, "< " @ %TemplateToUse.name @ " >", %replacement);
|
||||
while ( %oldstr !$= %newstr )
|
||||
{
|
||||
%oldstr = %newstr;
|
||||
%newstr = ReplaceTextInString(%oldstr, "< " @ %TemplateToUse.name @ " >", %replacement);
|
||||
}
|
||||
%Filehandle.writeLine( %newstr );
|
||||
}
|
||||
%Filehandle.close();
|
||||
%Filehandle.delete();
|
||||
// load the new stuff into t2
|
||||
if(%tmp != 1)
|
||||
{
|
||||
compile("support/templates/temp.cs"); // force recompile it
|
||||
exec("support/templates/temp.cs");
|
||||
}
|
||||
// clear the file
|
||||
if($TemplateClearFile == 1 && %tmp != 1)
|
||||
{
|
||||
%Filehandle2 = new FileObject();
|
||||
%Filehandle2.openForWrite( "support/templates/temp.cs" );
|
||||
%Filehandle2.close();
|
||||
%Filehandle2.delete();
|
||||
}
|
||||
if($TemplateLoadBasic == 1)
|
||||
{
|
||||
%TemplateFilename = %TemplateToUse.filename; // get the filename
|
||||
%TemplateToUse.delete(); // delete the new object
|
||||
%TemplateToUse = addTemplateBasic(%TemplateFilename); // recreate w/o contents
|
||||
}
|
||||
}
|
||||
$tempflock = 0;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function ReplaceTextInString(%string, %search_text, %replacement)
|
||||
{
|
||||
if((%pos = strstr(%string, %search_text)) != -1)
|
||||
{
|
||||
%len = strlen(%search_text);
|
||||
%newstr = getSubStr(%string, 0, %pos) @ %replacement @ getSubStr(%string, %pos + %len, 10000);
|
||||
return %newstr;
|
||||
} else {
|
||||
return %string;
|
||||
}
|
||||
}
|
||||
|
||||
function addTemplate(%filename, %isfile)
|
||||
{
|
||||
if( !( fileExt(%filename) $= ".tmp" ) )
|
||||
{
|
||||
echo("addTemplate(" @ %filename @ ") failed -- " @ %filename @ " does not have a .tmp extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(%isfile && !isfile(%filename))
|
||||
{
|
||||
echo("addTemplate(" @ %filename @ ") failed -- " @ %filename @ " does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
%Filehandle = new FileObject();
|
||||
%Filehandle.openForRead( %filename );
|
||||
%linenum = 0;
|
||||
while ( !%Filehandle.isEOF() )
|
||||
{
|
||||
%line = %Filehandle.readLine();
|
||||
if ( %linenum > 0 )
|
||||
{
|
||||
//file contents
|
||||
%TemplateLine[%linenum] = %line;
|
||||
%linenum++;
|
||||
} else {
|
||||
//file header
|
||||
%TemplateName = %line;
|
||||
%linenum++;
|
||||
}
|
||||
}
|
||||
%Filehandle.close();
|
||||
%Filehandle.delete();
|
||||
|
||||
%TemplateName = getSubStr(%TemplateName, strlen("// template< "), strlen(%TemplateName) - strlen("// template< ") - 2);
|
||||
|
||||
$template[%TemplateName] = new ScriptObject()
|
||||
{
|
||||
name = %TemplateName;
|
||||
class = template;
|
||||
filename = %filename;
|
||||
};
|
||||
Templates.add($template[%TemplateName]);
|
||||
for(%i = 1; %i < %linenum; %i++) //start at first line after header
|
||||
$template[%TemplateName].line[%i] = %TemplateLine[%i];
|
||||
$template[%TemplateName].linenum = %linenum;
|
||||
return $template[%TemplateName];
|
||||
}
|
||||
|
||||
function addTemplateBasic(%filename, %isfile)
|
||||
{
|
||||
if( !( fileExt(%filename) $= ".tmp" ) )
|
||||
{
|
||||
echo("addTemplate(" @ %filename @ ") failed -- " @ %filename @ " does not have a .tmp extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(%isfile && !isfile(%filename))
|
||||
{
|
||||
echo("addTemplate(" @ %filename @ ") failed -- " @ %filename @ " does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
%Filehandle = new FileObject();
|
||||
%Filehandle.openForRead( %filename );
|
||||
%linenum = 0;
|
||||
while ( !%Filehandle.isEOF() )
|
||||
{
|
||||
%line = %Filehandle.readLine();
|
||||
if ( %linenum > 0 )
|
||||
{
|
||||
//file contents
|
||||
%linenum++;
|
||||
} else {
|
||||
//file header
|
||||
%TemplateName = %line;
|
||||
%linenum++;
|
||||
}
|
||||
}
|
||||
%Filehandle.close();
|
||||
%Filehandle.delete();
|
||||
|
||||
%TemplateName = getSubStr(%TemplateName, strlen("// template< "), strlen(%TemplateName) - strlen("// template< ") - 2);
|
||||
|
||||
$template[%TemplateName] = new ScriptObject()
|
||||
{
|
||||
name = %TemplateName;
|
||||
class = template;
|
||||
filename = %filename;
|
||||
};
|
||||
Templates.add($template[%TemplateName]);
|
||||
$template[%TemplateName].linenum = %linenum;
|
||||
return $template[%TemplateName];
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
// this ones special, usage:
|
||||
// $ExampleReplacement = "Testing"; $ExampleValue = 1;
|
||||
// addDynamicString("$Var::< Example > = " @ $ExampleValue, "Example", $ExampleReplacement);
|
||||
// creates:
|
||||
// $Var::Testing = 1;
|
||||
function addDynamicString(%string, %var, %replacement)
|
||||
{
|
||||
%oldstr = %string;
|
||||
%newstr = ReplaceTextInString(%oldstr, "< " @ %var @ " >", %replacement);
|
||||
while ( %oldstr !$= %newstr )
|
||||
{
|
||||
%oldstr = %newstr;
|
||||
%newstr = ReplaceTextInString(%oldstr, "< " @ %var @ " >", %replacement);
|
||||
}
|
||||
// echo(%newstr);
|
||||
return %newstr;
|
||||
}
|
||||
|
||||
function template::main(%this)
|
||||
{
|
||||
if(!isObject(%this.loadedGroup))
|
||||
%this.loadedGroup = new SimGroup(Templates);
|
||||
echo(" - - - - - - Searching for templates to load...");
|
||||
|
||||
for(%filename = findFirstFile("*.tmp"); %filename !$= ""; %filename = findNextFile("*.tmp"))
|
||||
{
|
||||
if(!isObject($template[%filename]))
|
||||
{
|
||||
echo(" + '" @ %filename @ "' found");
|
||||
%this.processFile(%filename);
|
||||
}
|
||||
}
|
||||
echo(" - - - - - - template load done!");
|
||||
%this.numinit = 0;
|
||||
$TemplateLoader = schedule(3000, 0, "GenTemplates");
|
||||
}
|
||||
|
||||
function template::processFile(%this, %filename)
|
||||
{
|
||||
if(isObject($template[%filename]))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if($TemplateLoadBasic == 1)
|
||||
{
|
||||
if(!addTemplateBasic(%filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if(!addTemplate(%filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function template::Use(%this, %name, %var)
|
||||
{
|
||||
cancel($TemplateLoader);
|
||||
%this.initName[%this.numinit] = %name;
|
||||
%this.initVar[%this.numinit] = %var;
|
||||
%this.numinit = %this.numinit + 1;
|
||||
$TemplateLoader = schedule(3000, 0, "GenTemplates");
|
||||
return %this.numinit;
|
||||
}
|
||||
|
||||
function GenTemplates()
|
||||
{
|
||||
%num = template.Generate();
|
||||
echo( %num @ " bits o code generated from templates" );
|
||||
}
|
||||
|
||||
function template::Generate(%this)
|
||||
{
|
||||
//do all the preloaded ones in one batch :D
|
||||
|
||||
%Filehandle = new FileObject();
|
||||
%Filehandle.openForWrite( "support/templates/temp.cs" );
|
||||
%Filehandle.close();
|
||||
%Filehandle.delete();
|
||||
|
||||
for( %i = 0; %i < %this.numinit; %i++ )
|
||||
{
|
||||
%load[%i] = useTemplate(%this.initName[%i], %this.initVar[%i], 1);
|
||||
while(%load[%i] != 1)
|
||||
{
|
||||
%load[%i] = useTemplate(%this.initName[%i], %this.initVar[%i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
compile("support/templates/temp.cs"); // force recompile it
|
||||
exec("support/templates/temp.cs");
|
||||
return %this.numinit;
|
||||
}
|
||||
|
||||
function TemplateStart()
|
||||
{
|
||||
if( !isObject(template) )
|
||||
{
|
||||
new ScriptObject(template)
|
||||
{
|
||||
class = template;
|
||||
};
|
||||
template.main();
|
||||
}
|
||||
}
|
||||
|
||||
TemplateStart();
|
||||
|
||||
38
docs/base/@vl2/z_scripts/support.vl2/support/tourney_mode.cs
Normal file
38
docs/base/@vl2/z_scripts/support.vl2/support/tourney_mode.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// #name = TournyMode Query Support
|
||||
// #version = 1.0.0
|
||||
// #date = July 1, 2002
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Callbacks and functions to test for touney mode.
|
||||
// #status = Release
|
||||
// #include = support/callback.cs
|
||||
|
||||
// This script sets a simple flag named $TourneyMode whenever you join a
|
||||
// server or change maps to allow you to determine if you are in tourney
|
||||
// mode or not. To use it, just test like so:
|
||||
|
||||
// if($TourneyMode) { ... }
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
addMessageCallback('MsgVoteItem', TM_onTourneyModeCallback);
|
||||
Callback.add(onUserClientJoin,"TourneyMode::checkJustJoined");
|
||||
Callback.add(onMissionDropInfo,"TourneyMode::checkJustJoined");
|
||||
|
||||
function TourneyMode::checkJustJoined() {
|
||||
|
||||
commandToServer('GetVoteMenu', "TourneyQuery");
|
||||
}
|
||||
|
||||
function TM_onTourneyModeCallback(%msgType, %msgString, %key, %voteName, %voteActionMsg, %voteText, %sort) {
|
||||
|
||||
if (%key !$= "TourneyQuery") return;
|
||||
%voteName = detag(%voteName);
|
||||
if (%voteName $= "VoteFFAMode") $TourneyMode = true;
|
||||
else if (%voteName $= "VoteTournamentMode") $TourneyMode = false;
|
||||
}
|
||||
113
docs/base/@vl2/z_scripts/support.vl2/support/vector.cs
Normal file
113
docs/base/@vl2/z_scripts/support.vl2/support/vector.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
// #name = Data Struct - Vector
|
||||
// #version = 1.0.3
|
||||
// #date = July 15, 2001
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = Structure for fast adds and indexed lookup.
|
||||
// #status = Release
|
||||
|
||||
function Container::newVector() {
|
||||
|
||||
%x = new ScriptObject() {
|
||||
class = Vector;
|
||||
lastIndex = -1;
|
||||
};
|
||||
return %x;
|
||||
}
|
||||
|
||||
function Vector::pushFront(%this, %value) {
|
||||
|
||||
%this.insertBefore(0,%value);
|
||||
}
|
||||
|
||||
function Vector::popFront(%this) {
|
||||
|
||||
%val = %this.array[0];
|
||||
%this.removeAt(0);
|
||||
return %val;
|
||||
}
|
||||
|
||||
function Vector::pushBack(%this, %value) {
|
||||
|
||||
%this.lastIndex++;
|
||||
%this.array[%this.lastIndex] = %value;
|
||||
return %this.lastIndex;
|
||||
}
|
||||
|
||||
function Vector::popBack(%this) {
|
||||
|
||||
%val = %this.array[%this.lastIndex];
|
||||
%this.array[%this.lastIndex] = "";
|
||||
%this.lastIndex--;
|
||||
return %val;
|
||||
}
|
||||
|
||||
function Vector::insertBefore(%this, %idx, %value) {
|
||||
|
||||
%this.lastIndex++;
|
||||
if (%idx < %this.lastIndex && %idx >= 0) {
|
||||
for(%i=%this.lastIndex;%i>%idx;%i--) {
|
||||
%this.array[%i] = %this.array[%i-1];
|
||||
}
|
||||
%this.array[%idx] = %value;
|
||||
return %idx;
|
||||
}
|
||||
else {
|
||||
%this.pushBack(%value);
|
||||
return %this.lastIndex;
|
||||
}
|
||||
}
|
||||
|
||||
function Vector::insertAfter(%this, %idx, %value) {
|
||||
|
||||
if (%idx < %this.lastIndex && %idx >= 0) {
|
||||
%this.insertBefore(%idx++);
|
||||
return %idx;
|
||||
}
|
||||
else {
|
||||
%this.pushBack(%value);
|
||||
return %this.lastIndex;
|
||||
}
|
||||
}
|
||||
|
||||
function Vector::removeAt(%this, %idx) {
|
||||
|
||||
if (%idx <= %this.lastIndex && %idx >= 0) {
|
||||
for (%i=%idx;%i<%this.lastIndex;%i++) {
|
||||
%this.array[%i] = %this.array[%i+1];
|
||||
}
|
||||
%this.array[%this.lastIndex] = "";
|
||||
}
|
||||
%this.lastIndex--;
|
||||
}
|
||||
|
||||
function Vector::valueAt(%this, %idx) {
|
||||
|
||||
return %this.array[%idx];
|
||||
}
|
||||
|
||||
function Vector::clear(%this) {
|
||||
|
||||
for(%i=0;%i<=%this.lastIndex;%i++) {
|
||||
%this.array[%i] = "";
|
||||
}
|
||||
%this.lastIndex = -1;
|
||||
}
|
||||
|
||||
function Vector::size(%this) {
|
||||
|
||||
return %this.lastIndex+1;
|
||||
}
|
||||
|
||||
function Vector::findFirstIndex(%this, %value, %offset) {
|
||||
|
||||
if (%offset $= "") %offset = 0;
|
||||
for(%i=%offset;%i<=%this.lastIndex;%i++) {
|
||||
if (%this.array[%i] $= %value) return %i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
// #name = Vehicle Callbacks
|
||||
// #version = 0.0.5
|
||||
// #date = June 19, 2001
|
||||
// #author = Daniel Neilsen (aka Wizard_TPG)
|
||||
// #credit = Jon 'Ratorasniki' Naiman
|
||||
// #email = wizardsworld@bigpond.com
|
||||
// #web = http://www.tribalwar.com/wizard/
|
||||
// #description = Callbacks for mounting and dismounting vehicles
|
||||
// #status = release
|
||||
// #include = support/callback.cs
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Callbacks included in this script:
|
||||
//
|
||||
// The following callbacks all have the vehicle type as the first variable and the node
|
||||
// as the second variable.
|
||||
// onShrikePilot
|
||||
// onBomberPilot
|
||||
// onBomberBomber
|
||||
// onBomberTailgunner
|
||||
// onHAPCPilot
|
||||
// onHAPCPassenger
|
||||
// onFLPCPilot
|
||||
// onFLPCPassenger
|
||||
// onTankGunner
|
||||
// onTankDriver
|
||||
// onHoverbikeDriver
|
||||
// onMPBDriver
|
||||
// onHawkeyePilot
|
||||
// onHawkeyeGunner
|
||||
// onAirVehicle
|
||||
// onLandVehicle
|
||||
// onPilotingAirVehicle
|
||||
// onDrivingLandVehicle
|
||||
// onGunningVehicle
|
||||
//
|
||||
// The following callbacks have no variables.
|
||||
// onVehicleMount
|
||||
// onVehicleDismount
|
||||
//
|
||||
//
|
||||
// The following functions are also available for scripters usage:
|
||||
// isPlayerMounted(); - Returns either true or false
|
||||
// getCurrentVehicle();- Returns "Shrike","Hawkeye","Bomber","HAPC","Tank","Bike",
|
||||
// "MPB", "FLPC" or ""
|
||||
// getCurrentPosition();- Returns "Pilot", "Gunner", "Passenger" or ""
|
||||
//
|
||||
//===================================================================
|
||||
|
||||
$VehicleCallback::CurrentMountState = false;
|
||||
$VehicleCallback::CurrentVehicle = "";
|
||||
$VehicleCallback::CurrentPosition = "";
|
||||
|
||||
package eventcallbacks
|
||||
{
|
||||
function clientCmdShowVehicleGauges(%vehType, %node)
|
||||
{
|
||||
switch$ (%vehType)
|
||||
{
|
||||
case "Shrike" :
|
||||
onShrikePilot(%vehType, %node);
|
||||
case "Hawkeye" :
|
||||
if(%node == 1)
|
||||
{
|
||||
onHawkeyeGunner(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onHawkeyePilot(%vehType, %node);
|
||||
}
|
||||
case "Bomber" :
|
||||
if(%node == 1)
|
||||
{
|
||||
onBomberBomber(%vehType, %node);
|
||||
}
|
||||
else if(%node == 0)
|
||||
{
|
||||
onBomberPilot(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onBomberTailgunner(%vehType, %node);
|
||||
}
|
||||
case "TACBomber" :
|
||||
if(%node == 1)
|
||||
{
|
||||
onBomberBomber(%vehType, %node);
|
||||
}
|
||||
else if(%node == 0)
|
||||
{
|
||||
onBomberPilot(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onBomberTailgunner(%vehType, %node);
|
||||
}
|
||||
case "HAPC" :
|
||||
if(%node == 0)
|
||||
{
|
||||
onHAPCPilot(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onHAPCPassenger(%vehType, %node);
|
||||
}
|
||||
case "FLPC" :
|
||||
if(%node == 0)
|
||||
{
|
||||
onFLPCPilot(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onFLPCPassenger(%vehType, %node);
|
||||
}
|
||||
case "Assault" :
|
||||
if(%node == 1)
|
||||
{
|
||||
onTankGunner(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onTankDriver(%vehType, %node);
|
||||
}
|
||||
case "TACAssault" :
|
||||
if(%node == 1)
|
||||
{
|
||||
onTankGunner(%vehType, %node);
|
||||
}
|
||||
else
|
||||
{
|
||||
onTankDriver(%vehType, %node);
|
||||
}
|
||||
case "Hoverbike" :
|
||||
onHoverbikeDriver(%vehType, %node);
|
||||
case "MPB" :
|
||||
onMPBDriver(%vehType, %node);
|
||||
}
|
||||
parent::clientCmdShowVehicleGauges(%vehType, %node);
|
||||
}
|
||||
|
||||
function clientCmdSetVWeaponsHudActive(%num, %vType)
|
||||
{
|
||||
parent::clientCmdSetVWeaponsHudActive(%num, %vType);
|
||||
onVehicleMount();
|
||||
}
|
||||
|
||||
function clientCmdSetVWeaponsHudClearAll()
|
||||
{
|
||||
parent::clientCmdSetVWeaponsHudClearAll();
|
||||
onVehicleDismount();
|
||||
}
|
||||
|
||||
function clientCmdToggleDashHud(%val)
|
||||
{
|
||||
if(%val)
|
||||
onVehicleMount();
|
||||
parent::clientCmdToggleDashHud(%val);
|
||||
}
|
||||
|
||||
function clientCmdVehicleDismount()
|
||||
{
|
||||
parent::clientCmdVehicleDismount();
|
||||
onVehicleDismount();
|
||||
}
|
||||
|
||||
function clientCmdVehicleMount()
|
||||
{
|
||||
parent::clientCmdVehicleMount();
|
||||
onVehicleMount();
|
||||
}
|
||||
|
||||
function clientCmdSetDefaultVehicleKeys(%inVehicle)
|
||||
{
|
||||
if(%inVehicle)
|
||||
onVehicleMount();
|
||||
else
|
||||
onVehicleDismount();
|
||||
parent::clientCmdSetDefaultVehicleKeys(%inVehicle);
|
||||
}
|
||||
};
|
||||
|
||||
activatePackage(eventcallbacks);
|
||||
|
||||
|
||||
function onShrikePilot(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onShrikePilot, %vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Shrike";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
onAirVehicle(%vehType, %node);
|
||||
onPilotingAirVehicle(%vehType, %node);
|
||||
}
|
||||
|
||||
function onHawkeyeGunner(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onHawkeyeGunner, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onGunningVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Hawkeye";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onHawkeyePilot(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onHawkeyePilot, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onPilotingAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Hawkeye";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onBomberPilot(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onBomberPilot, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onPilotingAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Bomber";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
|
||||
}
|
||||
|
||||
function onBomberBomber(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onBomberBomber, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onGunningVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Bomber";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onBomberTailgunner(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onBomberTailgunner, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentPosition = "Passenger";
|
||||
$VehicleCallback::CurrentVehicle = "Bomber";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onHAPCPilot(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onHAPCPilot, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onPilotingAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "HAPC";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onHAPCPassenger(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onHAPCPassenger, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentPosition = "Passenger";
|
||||
$VehicleCallback::CurrentVehicle = "HAPC";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onFLPCPilot(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onFLPCPilot, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onPilotingAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "FLPC";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onFLPCPassenger(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onFLPCPassenger, %vehType, %node);
|
||||
onAirVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentPosition = "Passenger";
|
||||
$VehicleCallback::CurrentVehicle = "FLPC";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onTankGunner(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onTankGunner, %vehType, %node);
|
||||
onLandVehicle(%vehType, %node);
|
||||
onGunningVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Tank";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onTankDriver(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onTankDriver, %vehType, %node);
|
||||
onLandVehicle(%vehType, %node);
|
||||
onDrivingLandVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Tank";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onHoverbikeDriver(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onHoverbikeDriver, %vehType, %node);
|
||||
onLandVehicle(%vehType, %node);
|
||||
onDrivingLandVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "Bike";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onMPBDriver(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onMPBDriver, %vehType, %node);
|
||||
onLandVehicle(%vehType, %node);
|
||||
onDrivingLandVehicle(%vehType, %node);
|
||||
onVehicleMount();
|
||||
$VehicleCallback::CurrentVehicle = "MPB";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onVehicleDismount()
|
||||
{
|
||||
if(!$VehicleCallback::CurrentMountState)
|
||||
return;
|
||||
callback.trigger(onVehicleDismount);
|
||||
$VehicleCallback::CurrentVehicle = "";
|
||||
$VehicleCallback::CurrentPosition = "";
|
||||
$VehicleCallback::CurrentMountState = false;
|
||||
}
|
||||
|
||||
function onVehicleMount()
|
||||
{
|
||||
if($VehicleCallback::CurrentMountState)
|
||||
return;
|
||||
callback.trigger(onVehicleMount);
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onAirVehicle(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onAirVehicle, %vehType, %node);
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onLandVehicle(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onLandVehicle, %vehType, %node);
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onPilotingAirVehicle(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onPilotingAirVehicle, %vehType, %node);
|
||||
$VehicleCallback::CurrentPosition = "Pilot";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onDrivingLandVehicle(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onDrivingLandVehicle, %vehType, %node);
|
||||
$VehicleCallback::CurrentPosition = "Pilot";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function onGunningVehicle(%vehType, %node)
|
||||
{
|
||||
callback.trigger(onGunningVehicle, %vehType, %node);
|
||||
$VehicleCallback::CurrentPosition = "Gunner";
|
||||
$VehicleCallback::CurrentMountState = true;
|
||||
}
|
||||
|
||||
function isPlayerMounted ()
|
||||
{
|
||||
return $VehicleCallback::CurrentMountState;
|
||||
}
|
||||
|
||||
function getCurrentVehicle()
|
||||
{
|
||||
return $VehicleCallback::CurrentVehicle;
|
||||
}
|
||||
|
||||
function getCurrentPosition()
|
||||
{
|
||||
return $VehicleCallback::CurrentPosition;
|
||||
}
|
||||
187
docs/base/@vl2/z_scripts/support.vl2/support/weapon_list.cs
Normal file
187
docs/base/@vl2/z_scripts/support.vl2/support/weapon_list.cs
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
// #name = Weapon List Handler
|
||||
// #version = 1.4.0
|
||||
// #date = Oct 10, 2001
|
||||
// #category = Support
|
||||
// #author = Paul Tousignant
|
||||
// #warrior = UberGuy (FT)
|
||||
// #email = uberguy@tribalwar.com
|
||||
// #web = http://scripts.tribalwar.com/uberguy
|
||||
// #web = http://scripts.tribes-universe.com/uberguy
|
||||
// #description = This class maintains a mapping of numbers ("slots") to weapon names.
|
||||
// #status = Release
|
||||
// #include = support/map.cs
|
||||
// #include = support/loadout.cs
|
||||
|
||||
// v1.4 Added support for weapon HUD info.
|
||||
|
||||
// This class defines 4 fields, 4 methods, and 4 Callbacks
|
||||
// Fields:
|
||||
// slotByName[%name] : evaluates to the slot for a given weapon name
|
||||
// numWeapons : evaluates to the number of slots defined. See note below
|
||||
// loadOutSize : evaluates to the current number of weapons in your loadout.
|
||||
// Methods:
|
||||
// getWeapon(%slot) : returns the weapon name corresponding to %slot
|
||||
// getSlot(%name) : returns the slot corresponding to weapon called %name
|
||||
// weaponHudItem(%i) : returns the name of the weapon in weapon HUD at position
|
||||
// %i. Position 0 is the first position at the top.
|
||||
// weaponHudIndex(%n) : returns to the 0-based position in the weapon HUD of the
|
||||
// weapon named %n.
|
||||
// Callback:
|
||||
// WeaponListUpdated : passes the arguments (%slot, %name).
|
||||
// This is called as each weapon is added.
|
||||
// WeaponListCleared : no arguments. Called when the list is about to be created
|
||||
// WeaponListUpdDone : passes number of weapons in the list. Called when list is
|
||||
// done being built.
|
||||
// WeaponHudUpdated : Called when the weapons in your loadout change as reflected
|
||||
// in the weapon HUD. Strange things happen at inventories and
|
||||
// my code for handling this event there may not port to MODs.
|
||||
|
||||
if (!isObject(weaponList)) {
|
||||
new ScriptObject(weaponList) {
|
||||
class = weaponList;
|
||||
numWeapons = 0;
|
||||
loadOutSize = 0;
|
||||
updating = false;
|
||||
atInvo = false;
|
||||
data = Container::newListMap();
|
||||
};
|
||||
}
|
||||
Callback.add(PlayerUseInv,"weaponList.atInvo = true;");
|
||||
|
||||
package weaponListPkg {
|
||||
|
||||
function weaponsHud::addWeapon(%this, %slot, %ammoAmount) {
|
||||
|
||||
parent::addWeapon(%this, %slot, %ammoAmount);
|
||||
|
||||
if (weaponList.weaponHudIndex[%slot] !$= "") return;
|
||||
weaponList.weaponHudItem[weaponList.loadOutSize] = %slot;
|
||||
weaponList.weaponHudIndex[%slot] = weaponList.loadOutSize;
|
||||
weaponList.loadOutSize++;
|
||||
// Not very mod friendly, but the TL is the last thing to be loaded into
|
||||
// the WeaponHud at an invo station in base code.
|
||||
if (weaponList.atInvo && ($WeaponNames[%slot] $= "TargetingLaser")) {
|
||||
Callback.trigger(WeaponHudUpdated,weaponList.loadOutSize);
|
||||
weaponList.atInvo = false;
|
||||
}
|
||||
}
|
||||
|
||||
function weaponsHud::removeWeapon(%this, %slot) {
|
||||
|
||||
parent::removeWeapon(%this, %slot);
|
||||
|
||||
//error("Removing " @ $weaponnames[%slot]);
|
||||
if (weaponList.loadOutSize == 0) return;
|
||||
if (weaponList.weaponHudIndex[%slot] $= "") return;
|
||||
|
||||
// Scoot all the entries down
|
||||
%i = weaponList.weaponHudIndex[%slot];
|
||||
weaponList.weaponHudIndex[%slot] = "";
|
||||
for(%i++; %i < weaponList.loadOutSize; %i++) {
|
||||
%nextSlot = weaponList.weaponHudItem[%i];
|
||||
weaponList.weaponHudIndex[%nextSlot] = %i-1;
|
||||
weaponList.weaponHudItem[%i-1] = %nextSlot;
|
||||
}
|
||||
weaponList.weaponHudItem[weaponList.loadOutSize--] = "";
|
||||
Callback.Trigger(WeaponHudUpdated,weaponList.loadOutSize);
|
||||
}
|
||||
|
||||
function clientCmdSetWeaponsHudClearAll() {
|
||||
|
||||
parent::clientCmdSetWeaponsHudClearAll();
|
||||
|
||||
//error("***Clearing WeaponHUD***");
|
||||
while (weaponList.loadOutSize) {
|
||||
%slot = weaponList.weaponHudItem[weaponList.loadOutSize--];
|
||||
weaponList.weaponHudItem[weaponList.loadOutSize] = "";
|
||||
weaponList.weaponHudIndex[%slot] = "";
|
||||
}
|
||||
}
|
||||
|
||||
function clientCmdSetWeaponsHudBitmap(%slot, %name, %bitmap) {
|
||||
|
||||
// Note:
|
||||
// This code assumes no one will ever make a non-contiguous list of weapons
|
||||
// like Disc (1), Chain (2), Mortar (4).
|
||||
// If they do, I'll have to make this a relational structure.
|
||||
|
||||
parent::clientCmdSetWeaponsHudBitmap(%slot, %name, %bitmap);
|
||||
|
||||
if (!weaponList.updating) weaponList.updating = true;
|
||||
|
||||
%N = %slot+1;
|
||||
if (weaponList.numWeapons < %N) weaponList.numWeapons = %N;
|
||||
weaponList.slotByName[$WeaponNames[%slot]] = %slot;
|
||||
Callback.trigger(WeaponListUpdated, %slot, $WeaponNames[%slot]);
|
||||
}
|
||||
|
||||
function clientCmdSetInventoryHudBitmap(%slot, %name, %bitmap) {
|
||||
// In the current game scripts this is called right after the
|
||||
// Weapon HUD is updated.
|
||||
|
||||
parent::clientCmdSetInventoryHudBitmap(%slot, %name, %bitmap);
|
||||
|
||||
if (weaponList.updating) {
|
||||
weaponList.updating = false;
|
||||
Callback.trigger(WeaponListUpdDone, weaponList.numWeapons);
|
||||
}
|
||||
}
|
||||
|
||||
function handleTeamListMessage( %msgType, %msgString, %teamCount, %teamList ) {
|
||||
// In the current game scripts this is called right before the
|
||||
// Weapon HUD is updated.
|
||||
|
||||
weaponList.clear();
|
||||
parent::handleTeamListMessage( %msgType, %msgString, %teamCount, %teamList );
|
||||
Callback.Trigger(WeaponListCleared);
|
||||
}
|
||||
|
||||
function throw(%item) {
|
||||
|
||||
parent::throw(%item);
|
||||
if ((%slot = weaponList.slotByName[%item]) !$= "") {
|
||||
//schedule(100,0,"clientCmdSetWeaponsHudItem",%slot,0,0);
|
||||
clientCmdSetWeaponsHudItem(%slot,0,0);
|
||||
}
|
||||
}
|
||||
};
|
||||
activatePackage(weaponListPkg);
|
||||
|
||||
|
||||
function weaponList::getWeapon(%this,%slot) {
|
||||
|
||||
return $WeaponNames[%slot];
|
||||
}
|
||||
|
||||
function weaponList::getSlot(%this,%weaponName) {
|
||||
|
||||
return %this.slotByName[%weaponName];
|
||||
}
|
||||
|
||||
function weaponList::weaponHudItem(%this, %i) {
|
||||
|
||||
return $WeaponNames[%this.weaponHudItem[%i]];
|
||||
}
|
||||
|
||||
function weaponList::weaponHudIndex(%this, %name) {
|
||||
|
||||
return %this.weaponHudIndex[%this.slotByName[%name]];
|
||||
}
|
||||
|
||||
function weaponList::clear(%this) {
|
||||
|
||||
// Again, I asssume contiguous numbers for the slots.
|
||||
while (%this.numWeapons) {
|
||||
%this.slotByName[$WeaponNames[%this.numWeapons--]] = "";
|
||||
}
|
||||
}
|
||||
|
||||
function weaponList::getWeaponByHudIndex(%this, %idx) {
|
||||
|
||||
return $WeaponNames[%this.weaponHudItem[%idx]];
|
||||
}
|
||||
|
||||
function weaponList::getWeaponHudSlot(%this, %weapon) {
|
||||
|
||||
return %this.weaponHudIndex[%this.slotByName[%weapon]];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue