Files
dsrc/sku.0/sys.server/compiled/game/script/library/debug.scriptlib
T

296 lines
5.6 KiB
Plaintext

/**
* Copyright (c) ©2000,2001 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: debug.scriptlib
* Description: A library of routines to facilitate script debugging.
* @author $Author: asommers $
* @version $Revision: #1 $
*/
/***** INCLUDES ********************************************************/
include library.healing;
include library.pclib;
/***** INHERITS ********************************************************/
/***** CONSTANTS *******************************************************/
const string VERSION = "v0.01.00";
const string VAR_DEBUG_BASE = "debug";
const string VAR_DICTIONARY_IN = "debug.dict.in";
const string VAR_DICTIONARY_OUT = "debug.dict.out";
/***** FUNCTIONS *******************************************************/
/**
* @brief allows a debug message to be printed to both the scripters log.txt file and
* to their servers console
*
* @param string channel_name
* @param obj_id self
* @param string message
*
*/
void debugAllMsg(string channelName, obj_id self, string message)
{
// prints debug message to the scripters server console
debugServerConsoleMsg(self, message);
// prints debug message to the scripters log file located at swg/current/exe/linux
LOG(channelName, message);
}//debugAllMsg
/**
* This will cause the object returned form getSelf() to speak the
* specified message
*
* @param string msg
*
*/
void print( string msg )
{
if ( msg == null || msg.equals("") )
msg = "ERROR: invalid (null or empty) parameter specified in debug.print";
debugServerConsoleMsg( getSelf(), msg );
}
/**
* This will cause the object specified in the self parameter to
* speak a list of contents
*
* @param obj_id self
* @param obj_id[] contents
*
*/
void barkContents(obj_id self, obj_id[] contents)
{
// build a contents message string
string contentsMsg = "Contents: ";
// iterate over each contents element (a list of object IDs)
// adding each to the contents message string so that it
// appears as:
// "Contents: [201] [1320]"
for(int i = 0; i < contents.length; ++i)
{
if ( contents[i] != null )
{
contentsMsg += " [";
contentsMsg += contents[i].toString();
contentsMsg += "]";
}
}
// finally, speak the contents message text
debugServerConsoleMsg(self, contentsMsg);
} // barkContents
/**
* This will cause the object to speak a message identifying
* some error described in msgText
*
* @param unknown script (the caller must pass 'this')
* @param obj_id self
* @param string msgText
*
*/
void barkBug(unknown script, obj_id self, string msgText)
{
// start sith a message string, prepending
// the message
string msg = "in file: ";
// grab the current script name
msg += script.getClass().getName();
msg += " - ";
// append the user supplied descriptive text
msg += msgText;
// speak it before returning
debugServerConsoleMsg(self, msg);
} // barkBug
string getDebugName( obj_id id )
{
if ( id == null )
return (string)("[debug.getDebugName] ERROR: id == null");
string name = base_class.getName(id);
if(name == null)
return (string)("invalid object id");
return (string)(base_class.getName(id)+ " [" + id + "] ");
}
boolean fullHeal(obj_id target)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
boolean litmus = true;
int shock = getShockWound(target);
litmus &= healShockWound(target, shock);
for ( int i = 0; i < 3; i++ )
{
int attrib = i * 3;
litmus &= healing.healDamage(target, attrib, 2 * getMaxAttrib(target, attrib));
}
return litmus;
}
boolean damageMob(obj_id target, int attrib, int amt)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
return healing.healDamage(target, attrib, -amt);
}
boolean heal(obj_id target, int attrib, int amt)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
return healing.healDamage(target, attrib, amt);
}
boolean woundMob(obj_id target, int attrib, int amt)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
return true;
}
boolean healWounds(obj_id target)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
return true;
}
boolean getShock(obj_id target)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
int shock = getShockWound(target);
debugSpeakMsg(target, "(" + getGameTime() + ") my shock wound value = " + shock);
return true;
}
boolean addShock(obj_id target, int amt)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
if ( addShockWound(target, amt) )
{
return getShock(target);
}
return false;
}
boolean healShock(obj_id target, int amt)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
if ( healShockWound(target, amt) )
{
return getShock(target);
}
return false;
}
boolean zeroShock(obj_id target)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
if ( setShockWound(target, 0) )
{
return getShock(target);
}
return false;
}
boolean incapacitateMob(obj_id target)
{
if ( (target == null) || (!isMob(target)) )
{
return false;
}
boolean litmus = true;
int dam = 0;
for ( int i = 0; i < 3; i++ )
{
dam += getAttrib(target, i * 3);
}
damage(target, 0, 0, dam * 10);
return litmus;
}
boolean killCreature(obj_id target)
{
if ( (target == null) || (!isMob(target)) || (isPlayer(target)) )
{
return false;
}
if ( incapacitateMob(target) )
{
return kill(target);
}
return false;
}
void forceSuicide(obj_id target)
{
if ( (target == null) || (target == obj_id.NULL_ID) )
{
return;
}
suicide(target);
}
void suicide(obj_id self)
{
pclib.killPlayer(self, self);
}