Files
dsrc/sku.0/sys.server/compiled/game/script/cybernetic/cybernetic_player.script
T

604 lines
20 KiB
Plaintext

include library.cybernetic;
include library.utils;
include library.buff;
include library.sui;
include library.money;
include library.features;
include library.ai_lib;
inherits systems.combat.combat_base;
//We JUST want to ENSURE that IF something weird happens and a player
// SOMEHOW acquires skillmods from cybernetics that don't actually
// exist any more, they'll EVENTUALLY be "reset".
//...it would be better if we didn't persist them, but since we do,
// this is what I'm doing.
trigger OnInitialize()
{
cybernetic.validateSkillMods( self );
return SCRIPT_CONTINUE;
}
commandHandler cyborgLightning()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgLightning" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
if (!combatStandardAction("cyborgLightning", self, target, params, "", ""))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
executePowerSounds( self, "cyborgLightning" );
return SCRIPT_CONTINUE;
}
commandHandler cyborgStrengthBuff()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgStrengthBuff" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
buff.applyBuff(self, "cyborgStrengthBuff");
doAnimationAction( self, "pound_fist_palm" );
executePowerSounds( self, "cyborgStrengthBuff" );
playClientEffectObj(self, "appearance/pt_heal_resist_states.prt", self, "");
return SCRIPT_CONTINUE;
}
commandHandler cyborgBurstRun()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgBurstRun" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
//debugSpeakMsg( self, "cyborgBurstRun" );
buff.applyBuff(self, "cyborgBurstRun");
executePowerSounds( self, "cyborgBurstRun" );
return SCRIPT_CONTINUE;
}
commandHandler cyborgRevive()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgRevive" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
if (ai_lib.isInCombat(self))
{
handleFailureSound(self);
return SCRIPT_OVERRIDE;
}
if ( cybernetic.doCyborgRevive( self, target ) )
{
executePowerSounds( self, "cyborgRevive" );
return SCRIPT_CONTINUE;
}
else
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
}
commandHandler cyborgSureShot()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgSureShot" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
//debugSpeakMsg( self, "executing combat standard action: cyborgSureShot" );
if (!combatStandardAction("cyborgSureShot", self, target, params, "", ""))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
executePowerSounds( self, "cyborgSureShot" );
return SCRIPT_CONTINUE;
}
commandHandler cyborgCriticalSnipe()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgCriticalSnipe" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
//debugSpeakMsg( self, "executing combat standard action: cyborgCriticalSnipe" );
if (!combatStandardAction("cyborgCriticalSnipe", self, target, params, "", ""))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
executePowerSounds( self, "cyborgCriticalSnipe" );
return SCRIPT_CONTINUE;
}
commandHandler cyborgKickDown()
{
if (!cybernetic.hasUndamagedCybernetic( self, "cyborgKickDown" ))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
//debugSpeakMsg( self, "executing combat standard action: cyborgKickDown" );
if (!combatStandardAction("cyborgKickDown", self, target, params, "", ""))
{
handleFailureSound( self );
return SCRIPT_OVERRIDE;
}
executePowerSounds( self, "cyborgKickDown" );
return SCRIPT_CONTINUE;
}
void handleFailureSound( obj_id self )
{
playClientEffectObj(self, "clienteffect/cyborg_ui_cannot_use.cef", self, "");
}
void executePowerSounds( obj_id self, string commandName )
{
dictionary parms = new dictionary();
parms.put( "commandName", commandName );
messageTo( self, "handlePowerDownSound", parms, 2, false );
}
messageHandler handlePowerDownSound()
{
playClientEffectObj(self, "clienteffect/cyborg_itm_powerdown.cef", self, "");
string commandName = params.getString( "commandName" );
if ( commandName != null && commandName != "" )
{
float cooldownTime = dataTableGetFloat( "datatables/command/command_table.iff", commandName, "cooldownTime" );
if ( cooldownTime > 3.0f )
{
cooldownTime -= 3.0f;//yes, it plays 1 second early. I did that on purpose.
messageTo( self, "handlePowerUpSound", null, cooldownTime, false );
}
}
return SCRIPT_CONTINUE;
}
messageHandler handlePowerUpSound()
{
playClientEffectObj(self, "clienteffect/cyborg_itm_powerup.cef", self, "");
return SCRIPT_CONTINUE;
}
/** INSTALL PAYMENT CALLBACKS: **/
messageHandler handleInstallPaymentConfirmed()
{
LOG("sissynoid", "handleInstallPaymentConfirmed:::: ENTERED");
if((params == null) || (params.isEmpty()))
{
CustomerServiceLog("cyborg", "Cybernetics - Bad Params - please contact the Design Team if the issue persists");
return SCRIPT_CONTINUE;
}
obj_id player= sui.getPlayerId(params);
//retrieve cybernetic scriptVars off of the player
int amt = utils.getIntScriptVar(player, "cyborg.install.amount");
obj_id item = utils.getObjIdScriptVar(player, "cyborg.install.item");
//let's see if the player can have this item installed.
int playerInstalledCount = cybernetic.getPlayerInstalledCyberneticCount(player);
int playerCyberSkillMod = getEnhancedSkillStatisticModifierUncapped(player, "cybernetic_psychosis_resistance");
int cyberneticToInstall = cybernetic.getCyberneticPointValue(item);
if(playerInstalledCount < 0 || playerCyberSkillMod < 0 || cyberneticToInstall < 0)
{
CustomerServiceLog("cyborg", "Player("+ getPlayerFullName(player) +", "+ player +") can not install Cybernetic (" + item + ") - Code issues - please contact the Design Team.");
sendSystemMessage(self, new string_id("ep3/cybernetic", "cannot_install"));
return SCRIPT_CONTINUE;
}
LOG("sissynoid", "handleInstallPaymentConfirmed:::: playerInstalledCount: "+ playerInstalledCount +", playerCyberSkillMod: "+ playerCyberSkillMod +", cyberneticToInstall: " + cyberneticToInstall);
/*if((playerInstalledCount + cyberneticToInstall) > playerCyberSkillMod)
{
CustomerServiceLog("cyborg", "Player("+ getPlayerFullName(player) +", "+ player +") can not install Cybernetic (" + item + ") because it would surpass his/her allowed point value of ("+ playerCyberSkillMod +")");
sendSystemMessage(self, new string_id( "ep3/cybernetic", "not_enough_cybernetic_points"));
return SCRIPT_CONTINUE;
}*/
if(!isIdValid(player))
{
removeCyberneticInstallScriptVars(player);
return SCRIPT_CONTINUE;
}
int bp = sui.getIntButtonPressed(params);
if(bp == -1)
{
CustomerServiceLog("cyborg", "Player("+ getPlayerFullName(player) +", "+ player +") had a cybernetic UI error (btn = -1)");
removeCyberneticInstallScriptVars(player);
return SCRIPT_CONTINUE;
}
else if(bp != sui.BP_OK)
{
removeCyberneticInstallScriptVars(player);
return SCRIPT_CONTINUE;
}
if(!isIdValid(item))
{
CustomerServiceLog("cyborg", "Player("+ getPlayerFullName(player) +", "+ player +") had a cybernetic UI error Cybernetic Part("+ item +") was invalid");
removeCyberneticInstallScriptVars(player);
return SCRIPT_CONTINUE;
}
if (!money.pay(player, "cyborg", amt, "handleInstallPaid", params, false))
{
CustomerServiceLog("cyborg", "Player("+ getPlayerFullName(player) +", "+ player +") had a Failed Payment attempting to install Cybernetic Item("+ item +")");
removeCyberneticInstallScriptVars(player);
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
messageHandler handleInstallPaid()
{
if((params == null) || (params.isEmpty()))
{
CustomerServiceLog("cyborg", "Cybernetics - Bad Params - please contact the Design Team if the issue persists");
return SCRIPT_CONTINUE;
}
int amt = utils.getIntScriptVar(self, "cyborg.install.amount");
obj_id item = utils.getObjIdScriptVar(self, "cyborg.install.item");
if(params.getInt(money.DICT_CODE) == money.RET_FAIL)
{
removeCyberneticInstallScriptVars(self);
CustomerServiceLog("cyborg", "Player(" + self + ") did not have enough money to install this cybernetic("+ item +")");
sendSystemMessage(self, new string_id( "ep3/cybernetic", "no_money"));
return SCRIPT_CONTINUE;
}
string itemTemplate = getTemplateName(item);
//remove bio-link script from crafted items that is causing issues
if((itemTemplate.indexOf("crafted") > -1 ) && hasScript(item, "item.armor.biolink_item_non_faction"))
{
CustomerServiceLog("cyborg", "Crafted Cybernetic Fix -Player("+ self +") Cybernetic("+ item +") had the bio-link script removed because it is not needed.");
detachScript(item, "item.armor.biolink_item_non_faction");
}
//Anakin Forearm Fix - Removing Bio-Link remnants from the item that blew up.
if(itemTemplate.startsWith("object/tangible/wearables/cybernetic/cybernetic_anakin_forearm.iff"))
{
CustomerServiceLog("cyborg", "Anakin Reward Arm Fix: Anakin Forearm("+ item +") is having it's bio-link removed for player("+ self +").");
//clear the bio-link. everyone gets a free ride with this reward arm.
clearBioLink(item);
//remove the bio-link script from this item.
if(hasScript(item, "item.armor.biolink_item_non_faction"))
{
CustomerServiceLog("cyborg", "Anakin Reward Arm Fix: Anakin Forearm("+ item +") is having it's bio-link script for player("+ self +").");
detachScript(item, "item.armor.biolink_item_non_faction");
}
if(hasObjVar(item, "biolink.id"))
{
CustomerServiceLog("cyborg", "Anakin Reward Arm Fix: Anakin Forearm("+ item +") is having it's bio-link objvar for player("+ self +").");
removeObjVar(item, "biolink.id");
}
CustomerServiceLog("cyborg", "Anakin Reward Arm Fix: Anakin Forearm("+ item +") has had all bio-link remnants removed. Player("+ self +") was the owner at the time.");
}
removeCyberneticInstallScriptVars(self);
if(!isIdValid(item))
{
if(amt > 0)
{
CustomerServiceLog("cyborg", "Cybernetic Item("+ item +") was invalid - player("+ self +") had his/her credits("+ amt +") returned to him/her");
params.put("refundAmount", amt);
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
return SCRIPT_CONTINUE;
}
//A-Tab Install
if(utils.hasScriptVar(self, "cybernetic.appearance_install"))
{
if(hasObjVar(item, "biolink.id"))
{
obj_id biolinkId = getObjIdObjVar(item, "biolink.id");
if((biolinkId != self) && (biolinkId != utils.OBJ_ID_BIO_LINK_PENDING) && (biolinkId != null))
{
//Then it's biolinked to someone else
sendSystemMessage(self, new string_id("ep3/cybernetic", "bio_link_mismatch"));
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
return SCRIPT_CONTINUE;
}
}
//otherwise - there is no bio-link to check with A-Tab items.
obj_id a_tab_inv = getAppearanceInventory(self);
if(equip(item, a_tab_inv))
{
CustomerServiceLog("cyborg", "Cybernetic Item("+ item +") was successfully A-Tab installed on Player("+ self +")");
playClientEffectObj(self, "clienteffect/cyborg_itm_installed.cef", self, "");
}
else
{
sendSystemMessage(self, new string_id("ep3/cybernetic", "cannot_install"));
CustomerServiceLog("cyborg", "Cybernetic Item("+ item +") could not be installed - player("+ self +") had his/her credits("+ amt +") returned to him/her");
//refund the player for the installation:
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
}
else
{
if(hasObjVar(item, "biolink.id"))
{
obj_id biolinkId = getObjIdObjVar(item, "biolink.id");
if((biolinkId != self) && (biolinkId != utils.OBJ_ID_BIO_LINK_PENDING) && (biolinkId != null))
{
//Then it's biolinked to someone else
sendSystemMessage(self, new string_id("ep3/cybernetic", "bio_link_mismatch"));
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
return SCRIPT_CONTINUE;
}
}
//otherwise - there is no bio-link to check with A-Tab items.
if(equip(item, self))
{
playClientEffectObj(self, "clienteffect/cyborg_itm_installed.cef", self, "");
CustomerServiceLog("cyborg", "Cybernetic Item("+ item +") was successfully installed on Player("+ self +")");
//Cybernetic successfully equipped - bio-link it if it's a crafted item.
if(getTemplateName(item).indexOf("crafted") > -1 )
{
CustomerServiceLog("cyborg", "Cybernetic Item("+ item +") was installed on Player("+ self +") and Bio-Linked - as designed.");
setBioLink(item, self);
}
}
else
{
sendSystemMessage(self, new string_id("ep3/cybernetic", "cannot_install"));
CustomerServiceLog("cyborg", "Cybernetic Item("+ item +") could not be installed - player("+ self +") had his/her credits("+ amt +") returned to him/her");
//refund the player for the installation:
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
}
return SCRIPT_CONTINUE;
}
//removes scriptvars from the player that were used for the installation process
void removeCyberneticInstallScriptVars(obj_id player)
{
if(utils.hasScriptVar(player, "cyborg.install.amount") && utils.hasScriptVar(player, "cyborg.install.item"))
{
utils.removeScriptVar(player, "cyborg.install.amount");
utils.removeScriptVar(player, "cyborg.install.item");
}
}
/** Cybernetic payment refunds: if it fails, we owe this dude money! **/
messageHandler handleCyborgRefunded()
{
//debugSpeakMsg( self, "refunded!" );
return SCRIPT_CONTINUE;
}
messageHandler handleCyborgNotRefunded()
{
//debugSpeakMsg( self, "not refunded!" );
int amt = params.getInt( "refundAmount" );
CustomerServiceLog("cyborg", "Player %TU failed to be refunded " + amt + " credits for aborted cybernetic refund", self);
return SCRIPT_CONTINUE;
}
/** REMOVE PAYMENT CALLBACKS: **/
messageHandler handleUnInstallPaymentConfirmed()
{
//debugSpeakMsg( self, "option received" );
obj_id player= sui.getPlayerId(params);
if (!isIdValid(player))
return SCRIPT_CONTINUE;
int bp = sui.getIntButtonPressed(params);
if (bp == -1)
{
utils.removeScriptVar( player, "cyborg.remove.amount" );
utils.removeScriptVar( player, "cyborg.remove.item" );
return SCRIPT_CONTINUE;
}
else if ( bp != sui.BP_OK )
{
utils.removeScriptVar( player, "cyborg.remove.amount" );
utils.removeScriptVar( player, "cyborg.remove.item" );
return SCRIPT_CONTINUE;
}
int amt = utils.getIntScriptVar( player, "cyborg.remove.amount" );
obj_id item = utils.getObjIdScriptVar( player, "cyborg.remove.item" );
if ( !isIdValid(item) )
{
utils.removeScriptVar( player, "cyborg.remove.amount" );
utils.removeScriptVar( player, "cyborg.remove.item" );
return SCRIPT_CONTINUE;
}
if (!money.pay( player, "cyborg", amt, "handleUnInstallPaid", params, false))
{
//debugSpeakMsg( player, "Can't afford that" );
utils.removeScriptVar( player, "cyborg.remove.amount" );
utils.removeScriptVar( player, "cyborg.remove.item" );
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
messageHandler handleUnInstallPaid()
{
if ( params.getInt(money.DICT_CODE) == money.RET_FAIL )
{
utils.removeScriptVar( self, "cyborg.remove.amount" );
utils.removeScriptVar( self, "cyborg.remove.item" );
sendSystemMessage( self, new string_id( "ep3/cybernetic", "no_money" ));
return SCRIPT_CONTINUE;
}
int amt = utils.getIntScriptVar( self, "cyborg.remove.amount" );
obj_id item = utils.getObjIdScriptVar( self, "cyborg.remove.item" );
utils.removeScriptVar( self, "cyborg.remove.amount" );
utils.removeScriptVar( self, "cyborg.remove.item" );
if ( !isIdValid(item) )
{
if ( amt > 0 )
{
sendSystemMessage( self, new string_id( "ep3/cybernetic", "cannot_remove" ) );
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
return SCRIPT_CONTINUE;
}
obj_id inv = utils.getInventoryContainer(self);
/*
******We no longer destroy the s01 items since we no longer give Death Cybernetics******
**************and Cybernetics are now craftable (even the s01 cybernetics)**************
if ( getTemplateName( item ).indexOf("s01") != -1 )
{
//the s01 items are destroyed when un-installed:
if ( !destroyObject(item) )
{
sendSystemMessage( self, new string_id( "ep3/cybernetic", "cannot_remove" ) );
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
else
{
playClientEffectObj(self, "clienteffect/cyborg_itm_uninstalled.cef", self, "");
}
}*/
if ( isIdValid(inv) && putIn(item, inv) )
{
//other items are put in the player's inventory
playClientEffectObj(self, "clienteffect/cyborg_itm_uninstalled.cef", self, "");
}
else
{
//but if we can't, then refund the money
sendSystemMessage( self, new string_id( "ep3/cybernetic", "cannot_remove" ) );
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
return SCRIPT_CONTINUE;
}
/** REPAIR PAYMENT CALLBACKS: **/
messageHandler handleRepairPaymentConfirmed()
{
//debugSpeakMsg( self, "option received" );
obj_id player= sui.getPlayerId(params);
if (!isIdValid(player))
return SCRIPT_CONTINUE;
int bp = sui.getIntButtonPressed(params);
if (bp == -1)
{
utils.removeScriptVar( player, "cyborg.repair.amount" );
utils.removeScriptVar( player, "cyborg.repair.item" );
return SCRIPT_CONTINUE;
}
else if ( bp != sui.BP_OK )
{
utils.removeScriptVar( player, "cyborg.repair.amount" );
utils.removeScriptVar( player, "cyborg.repair.item" );
return SCRIPT_CONTINUE;
}
int amt = utils.getIntScriptVar( player, "cyborg.repair.amount" );
obj_id item = utils.getObjIdScriptVar( player, "cyborg.repair.item" );
if ( !isIdValid(item) )
{
utils.removeScriptVar( player, "cyborg.repair.amount" );
utils.removeScriptVar( player, "cyborg.repair.item" );
return SCRIPT_CONTINUE;
}
if (!money.pay( player, "cyborg", amt, "handleRepairPaid", params, false))
{
//debugSpeakMsg( player, "Can't afford that" );
utils.removeScriptVar( player, "cyborg.repair.amount" );
utils.removeScriptVar( player, "cyborg.repair.item" );
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
messageHandler handleRepairPaid()
{
if ( params.getInt(money.DICT_CODE) == money.RET_FAIL )
{
utils.removeScriptVar( self, "cyborg.repair.amount" );
utils.removeScriptVar( self, "cyborg.repair.item" );
sendSystemMessage( self, new string_id( "ep3/cybernetic", "no_money" ));
return SCRIPT_CONTINUE;
}
int amt = utils.getIntScriptVar( self, "cyborg.repair.amount" );
obj_id item = utils.getObjIdScriptVar( self, "cyborg.repair.item" );
utils.removeScriptVar( self, "cyborg.repair.amount" );
utils.removeScriptVar( self, "cyborg.repair.item" );
if ( !isIdValid(item) )
{
if ( amt > 0 )
{
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
}
return SCRIPT_CONTINUE;
}
int itemHps = getHitpoints( item );
int maxHps = getMaxHitpoints( item );
maxHps--;
if ( itemHps >= maxHps )
{
params.put( "refundAmount", amt );
transferBankCreditsFromNamedAccount("cyborg", self, amt, "handleCyborgRefunded", "handleCyborgNotRefunded", params);
return SCRIPT_CONTINUE;
}
setMaxHitpoints(item, maxHps );
setHitpoints(item, maxHps );
sendSystemMessage( self, new string_id( "ep3/cybernetic", "item_repaired" ) );
playClientEffectObj( self, "clienteffect/cyborg_itm_repaired.cef", self, "");
return SCRIPT_CONTINUE;
}