mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
82 lines
2.0 KiB
Plaintext
82 lines
2.0 KiB
Plaintext
include library.utils;
|
|
|
|
trigger OnSpeaking(string text)
|
|
{
|
|
if ( (text.startsWith("grantXP")) || (text.startsWith("revokeXP")) )
|
|
{
|
|
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
|
|
if ( st.countTokens() != 3 )
|
|
{
|
|
debugSpeakMsg(self, "PARAM ERROR - syntax: <grantXP/revokeXP> <xpType> <amt>");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
string cmd = st.nextToken();
|
|
string xpType = st.nextToken();
|
|
int amt = utils.stringToInt(st.nextToken());
|
|
if ( amt == -1 )
|
|
{
|
|
debugSpeakMsg(self, "PARSE ERROR - syntax: <grantXP/revokeXP> <xpType> <amt>");
|
|
}
|
|
|
|
obj_id target = getLookAtTarget(self);
|
|
if ( (target == null) || (target == obj_id.NULL_ID) )
|
|
{
|
|
target = self;
|
|
}
|
|
|
|
if ( !isPlayer(target) )
|
|
{
|
|
debugSpeakMsg(self, "test_xp: invalid target for action!");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
if ( cmd == "grantXP" )
|
|
{
|
|
if ( grantExperiencePoints(target, xpType, amt) != XP_ERROR)
|
|
{
|
|
debugSpeakMsg(target, "test_xp(grantXP): " + xpType + " + " + amt + " = " + getExperiencePoints(target, xpType));
|
|
}
|
|
}
|
|
else if ( cmd == "revokeXP" )
|
|
{
|
|
if ( grantExperiencePoints(target, xpType, -amt) != XP_ERROR)
|
|
{
|
|
debugSpeakMsg(target, "test_xp(revokeXP): " + xpType + " - " + amt + " = " + getExperiencePoints(target, xpType));
|
|
}
|
|
|
|
}
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else if ( text.startsWith("getXP") )
|
|
{
|
|
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
|
|
if ( st.countTokens() != 2 )
|
|
{
|
|
debugSpeakMsg(self, "PARAM ERROR - syntax: getXP <xpType>");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
string cmd = st.nextToken();
|
|
string xpType = st.nextToken();
|
|
|
|
obj_id target = getLookAtTarget(self);
|
|
if ( (target == null) || (target == obj_id.NULL_ID) )
|
|
{
|
|
target = self;
|
|
}
|
|
|
|
if ( !isPlayer(target) )
|
|
{
|
|
debugSpeakMsg(self, "test_xp: invalid target for action!");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
int xp = getExperiencePoints(target, xpType);
|
|
debugSpeakMsg(target, "XP: " + xpType + " = " + xp);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|