mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
392 lines
13 KiB
Plaintext
392 lines
13 KiB
Plaintext
/**********************************************************************
|
|
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
|
|
* All Rights Reserved
|
|
*
|
|
* Title: enclave_controller
|
|
* Description: This script attaches to the jedi council enclaves
|
|
* @author $Author:$
|
|
* @version $Revision:$
|
|
**********************************************************************/
|
|
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
include library.force_rank;
|
|
include library.utils;
|
|
include library.pvp;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
trigger OnInitialize()
|
|
{
|
|
string frsConfig = getConfigSetting("GameServer", "enableFRS");
|
|
if(frsConfig == null || frsConfig.length() < 1)
|
|
{
|
|
removeObjVar(self, "force_rank.roster");
|
|
removeObjVar(self, "force_rank.data");
|
|
removeObjVar(self, "force_rank.voting");
|
|
force_rank.resetEnclaveData(self);
|
|
force_rank.resetClusterData(self);
|
|
force_rank.createEnclaveTerminals(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
LOG("force_rank", "enclave_controller.OnInitialize -- " + self);
|
|
|
|
int council = force_rank.getCouncilAffiliation(self);
|
|
if (council == -1)
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnInitialize -- " + self + " does not have a valid council value.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Check for enclave data.
|
|
if (!hasObjVar(self, "force_rank.roster"))
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnInitialize -- can't find enclave data on " + self + ". Setting it up...");
|
|
CustomerServiceLog("force_rank", "Initializing data for enclave " + self);
|
|
|
|
force_rank.resetEnclaveData(self);
|
|
}
|
|
|
|
// Get the latest clusterwide data or write up the latest data if none exists.
|
|
int request_id = getClusterWideData(force_rank.CLUSTER_DATA_NAME, force_rank.STRING_CLUSTER_ENCLAVE_NAME + council, false, self);
|
|
utils.setScriptVar(self, force_rank.SCRIPT_VAR_DATA_REQUEST + request_id, 0);
|
|
|
|
force_rank.logEnclaveData(self);
|
|
|
|
/*
|
|
if (hasObjVar(self, force_rank.VAR_BACKUP_TIME))
|
|
{
|
|
int time_stamp = getIntObjVar(self, force_rank.VAR_BACKUP_TIME);
|
|
if (getGameTime() - time_stamp > force_rank.BACK_UP_INTERVAL)
|
|
{
|
|
// Time for a backup
|
|
force_rank.backupEnclaveData(self);
|
|
}
|
|
}
|
|
else
|
|
force_rank.backupEnclaveData(self);
|
|
*/
|
|
|
|
force_rank.makeAllCellsPublic(self);
|
|
force_rank.setCellScripts(self);
|
|
|
|
//force_rank.deleteExpiredPvPActions(self); // this doesn't take care of sudden death actions, as the voting system has to clear these out
|
|
|
|
// Start the maintenance pulse
|
|
messageTo(self, "msgEnclavePulse", null, force_rank.MAINTENANCE_PULSE, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//trigger OnAttach()
|
|
//{
|
|
// force_rank.refreshAllRoomPermissions(self);
|
|
// return SCRIPT_CONTINUE;
|
|
//}
|
|
|
|
trigger OnClusterWideDataResponse(string manage_name, string enclave_name, int request_id, string[] element_name_list, dictionary[] enclave_data, int lock_key)
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- " + self);
|
|
|
|
if (!manage_name.equals(force_rank.CLUSTER_DATA_NAME))
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- " + self + " Ignoring cluster manager name " + manage_name);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (utils.hasScriptVar(self, force_rank.SCRIPT_VAR_DATA_REQUEST + request_id))
|
|
{
|
|
int data_mode = utils.getIntScriptVar(self, force_rank.SCRIPT_VAR_DATA_REQUEST + request_id);
|
|
if (data_mode != 0)
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- ignoring request_id " + request_id + " on " + self + " since its data_mode is " + data_mode);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
utils.removeScriptVar(self, force_rank.SCRIPT_VAR_DATA_REQUEST + request_id);
|
|
}
|
|
else
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- cannot find a data_mode for request_id " + request_id + " on " + self);
|
|
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
int council = force_rank.getCouncilAffiliation(self);
|
|
if (council == -1)
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- " + self + " does not have a valid council value.");
|
|
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
//LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- " + element_name_list);
|
|
if (element_name_list == null || element_name_list.length < 1)
|
|
{
|
|
// There is no data returned. Therefore, we need to load up the cluster-wide data.
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- replace cluster data");
|
|
force_rank.replaceEnclaveClusterData(self, lock_key);
|
|
}
|
|
else
|
|
{
|
|
if (enclave_data == null || enclave_data.length < 1)
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- " + self + " enclave data is null or empty.");
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
if (enclave_data.length > 1)
|
|
{
|
|
LOG("force_rank", "enclave_controller.OnClusterWideDataResponse -- " + self + " There is more than one element in the returned data. This shouldn't happen.");
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
// There is existing data. Update the enclave's objvars with this data.
|
|
force_rank.updateEnclaveClusterData(self, enclave_data[0]);
|
|
}
|
|
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
|
|
// comes from systems.gcw.player_pvp::OnInit
|
|
messageHandler PEFSynchRequest()
|
|
{
|
|
if(!params.containsKey("sender"))
|
|
{
|
|
LOG("force_rank", "enclave_controller::requestPEFSynch: -> missing @sender parm... not responding to PEF sync.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// PEFSynchResponse
|
|
obj_id sender = params.getObjId("sender");
|
|
|
|
dictionary parms = new dictionary();
|
|
parms.put("sender", self);
|
|
parms.put("enemies", force_rank.getCurrentDarkJediEnemies(sender, self));
|
|
|
|
messageTo(sender, "PEFSynchResponse", parms, 0, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// comes from library.pvp when a Jedi has died and there were other dark jedi involved in his death whil the
|
|
// victim was a target of a Dark Jedi PvP action
|
|
messageHandler msgVictimizedJediDeath()
|
|
{
|
|
if(params != null)
|
|
{
|
|
force_rank.handleCondemnedPlayerDeath(self, params);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//
|
|
// message arrived from pvp.library called from systems.gcw.player_pvp when a dark jedi kills another dark jedi
|
|
// the enclave must validate that these two players can actually kill each other for XP.
|
|
// here we need to check if they are involved in a Vendetta, Banishment, etc
|
|
messageHandler XPDeathValidateRequest()
|
|
{
|
|
java.util.Enumeration pKeysd = params.keys();
|
|
while(pKeysd.hasMoreElements())
|
|
{
|
|
LOG("force_rank", "XPDeathValidateRequest params keys: " + pKeysd.nextElement());
|
|
}
|
|
|
|
if((!params.containsKey("victim")) || (!params.containsKey("totalDamageToVictim")))
|
|
{
|
|
LOG("pvp_rating", "enclabe_controller::XPDeathValidateRequest: -> Missing vital params 'victim' and 'totalDamageToVictim'. Not validating Dark Jedi XP death.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id victim = params.getObjId("victim");
|
|
params.remove("victim");
|
|
|
|
int totalDamageTally = params.getInt("totalDamageToVictim");
|
|
params.remove("totalDamageToVictim");
|
|
|
|
java.util.Enumeration pKeys = params.keys();
|
|
obj_id[] winners = new obj_id[params.size()];
|
|
float[] contributions = new float[winners.length];
|
|
int i = 0;
|
|
|
|
while(pKeys.hasMoreElements())
|
|
{
|
|
obj_id key = (obj_id)pKeys.nextElement();
|
|
winners[i] = key;
|
|
contributions[i] = params.getFloat(key);
|
|
i++;
|
|
}
|
|
|
|
dictionary suddenDeathData = force_rank.getAndValidatePvPActionData(force_rank.ACTION_CANDIDATE_SUDDEN_DEATH, self);
|
|
dictionary vendettaData = force_rank.getAndValidatePvPActionData(force_rank.ACTION_VENDETTA, self);
|
|
dictionary banishmentData = force_rank.getAndValidatePvPActionData(force_rank.ACTION_BANISHMENT, self);
|
|
dictionary purgeData = force_rank.getAndValidatePvPActionData(force_rank.ACTION_PURGE_COUNCIL, self);
|
|
|
|
dictionary validatedXPDeltas = new dictionary(); // this will get sent back to victim to indicate all of the XP deltas that are allowed
|
|
int victimXPDelta = 0;
|
|
for(i = 0; i < winners.length; i++)
|
|
{
|
|
// loop through the winners to see if they are allowed to kill the victim for XP
|
|
// since the victim and the winners in this handler should all be dark jedi, they can only kill each other if...
|
|
|
|
if((vendettaData != null && force_rank.isPartOfSameVendetta(winners[i], victim, vendettaData)) ||
|
|
(banishmentData != null && force_rank.isPvPActionVictim(victim, banishmentData)) ||
|
|
(purgeData != null && force_rank.isPvPActionVictim(victim, purgeData)) ||
|
|
(suddenDeathData != null && force_rank.bothArePartOfSameSuddenDeathRank(winners[i], victim, self, suddenDeathData))
|
|
)
|
|
{
|
|
validatedXPDeltas.put(winners[i], pvp.getAdjustedForceRankXPDelta(victim, winners[i], contributions[i], false));
|
|
victimXPDelta += pvp.getAdjustedForceRankXPDelta(victim, winners[i], contributions[i], true);
|
|
}
|
|
}
|
|
|
|
if(victimXPDelta > 0)
|
|
{
|
|
validatedXPDeltas.put(victim, victimXPDelta);
|
|
}
|
|
|
|
if(validatedXPDeltas.size() > 0)
|
|
{
|
|
messageTo(victim, "XPDeathValidateResponse", validatedXPDeltas, 0, false);
|
|
}
|
|
else
|
|
{
|
|
LOG("force_rank", "enclave_controller::XPDeathValidateRequest: -> None of the dark Jedi who participated in the death are eligible to receive XP.");
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgRequestExperienceDebt()
|
|
{
|
|
obj_id player = params.getObjId("player");
|
|
string player_name = params.getString("player_name");
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgRequestExperienceDebt -- player is invalid.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (player_name == null)
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgRequestExperienceDebt -- player_name is null.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int xp_debt = force_rank.getExperienceDebt(self, player_name);
|
|
if (xp_debt > 0)
|
|
{
|
|
if (force_rank.getForceRank(self, player_name) > 0)
|
|
{
|
|
dictionary d = new dictionary();
|
|
d.put("xp_debt", xp_debt);
|
|
messageTo(player, "msgApplyExperienceDebt", d, 3.0f, false);
|
|
}
|
|
|
|
// Clear the xp_debt
|
|
string obj_var_name = force_rank.VAR_MEMBER_DATA + player_name + ".xp_debt";
|
|
removeObjVar(self, obj_var_name);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgForceEnclaveUpdate()
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgForceEnclaveUpdate -- " + self);
|
|
|
|
int council = force_rank.getCouncilAffiliation(self);
|
|
if (council == -1)
|
|
{
|
|
LOG("force_rank", "enclave_controller.forceEnclaveUpdate -- " + self + " does not have a valid council value.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int request_id = getClusterWideData(force_rank.CLUSTER_DATA_NAME, force_rank.STRING_CLUSTER_ENCLAVE_NAME + council, false, self);
|
|
utils.setScriptVar(self, force_rank.SCRIPT_VAR_DATA_REQUEST + request_id, 0);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgEnclavePulse()
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgEnclavePulse -- " + self + " " + getGameTime());
|
|
|
|
messageTo(self, "msgEnclavePulse", null, force_rank.MAINTENANCE_PULSE, false);
|
|
force_rank.performEnclaveMaintenance(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgValidateFRSPlayerData()
|
|
{
|
|
if (params == null)
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgValidateFRSPlayerData(enclave) -- params is null");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
string player_name = params.getString("player_name");
|
|
int player_rank = params.getInt("player_rank");
|
|
obj_id player = params.getObjId("player");
|
|
|
|
if (player_name == null)
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgValidateFRSPlayerData(enclave) -- player_name is null");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (player_rank < 0 || player_rank > 11)
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgValidateFRSPlayerData(enclave) -- player_rank is not a legal value: " + player_rank);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgValidateFRSPlayerData(enclave) -- player is invalid");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int enclave_rank = force_rank.getForceRank(self, player_name);
|
|
// If we can't find the player in the force rankings, we assume he's at rank 0.
|
|
if (enclave_rank == -1)
|
|
enclave_rank = 0;
|
|
|
|
if (player_rank != enclave_rank)
|
|
{
|
|
// If the player's rank doesn't match the enclave's data, change it to the enclave's data.
|
|
params.put("player_rank", enclave_rank);
|
|
}
|
|
|
|
messageTo(player, "msgValidateFRSPlayerData", params, 0.0f, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgFRSUpdateClusterData()
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgFRSUpdateClusterData");
|
|
int council = force_rank.getCouncilAffiliation(self);
|
|
if (council == -1)
|
|
{
|
|
LOG("force_rank", "enclave_controller.msgFRSUpdateClusterData -- " + self + " does not have a valid council value.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int request_id = getClusterWideData(force_rank.CLUSTER_DATA_NAME, force_rank.STRING_CLUSTER_ENCLAVE_NAME + council, true, self);
|
|
utils.setScriptVar(self, force_rank.SCRIPT_VAR_DATA_REQUEST + request_id, 0);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** COMMANDHANDLERS *************************************************/
|
|
|
|
|
|
/***** FUNCTIONS *******************************************************/
|