mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-03 03:15:55 -04:00
238 lines
7.1 KiB
Plaintext
238 lines
7.1 KiB
Plaintext
/***** INCLUDES ********************************************************/
|
|
|
|
include library.gcw;
|
|
include library.hq;
|
|
include library.utils;
|
|
include library.factions;
|
|
include library.player_structure;
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
|
|
trigger OnAttach()
|
|
{
|
|
if ( hasObjVar(self, factions.FACTION) )
|
|
factions.setFaction(self, factions.getFaction(self));
|
|
|
|
string myFac = factions.getFaction(self);
|
|
int intFac = myFac.equals("Rebel") ? gcw.FACTION_REBEL : gcw.FACTION_IMPERIAL;
|
|
int lvl = getHqLevel(self);
|
|
if ( lvl > 0 )
|
|
factions.changeFactionPoints(myFac, 10 * lvl);
|
|
|
|
gcw.incrementGCWScore (self);
|
|
gcw.modifyPlanetaryBaseCount(self, intFac, 1);
|
|
setObjVar(self, "lotsRefunded", 1);
|
|
setObjVar(self, "lotsRefunded2", 1);
|
|
setCWData(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
permissionsMakePublic(self);
|
|
setObjVar(self, "playersWithAlignedEnemyFlagsAllowed", 1);
|
|
//hq.refundFactionBaseLots(self); //check to see if we've converted this base to the new GCW system (refund faction points and lots for bases placed prior to the GCW revamp - 2/6/05).
|
|
messageTo(self, "handleDelayedRefundChecker", null, 10f, true);
|
|
hq.removeCovertDetector(self); //check to see if there are covert detectors assigned to this base. Any present are legacy and obsolete under the GCW revamp and should be removed. - 2/22/05
|
|
setCWData(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/*
|
|
trigger OnPreloadComplete()
|
|
{
|
|
//hq.refundFactionBaseLots(self); //check to see if we've converted this base to the new GCW system (refund faction points and lots for bases placed prior to the GCW revamp - 2/28/05).
|
|
//messageTo(self, "handleDelayedRefundChecker", null, 5f, null);
|
|
LOG("hq", "library.hq ////--\\\\ OnPreloadComplete");
|
|
LOG("hq", "library.hq ////--\\\\ OnPreloadComplete");
|
|
LOG("hq", "library.hq ////--\\\\ OnPreloadComplete");
|
|
LOG("hq", "library.hq ////--\\\\ OnPreloadComplete");
|
|
LOG("hq", "library.hq ////--\\\\ OnPreloadComplete");
|
|
LOG("hq", "library.hq ////--\\\\ OnPreloadComplete");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
trigger OnReceivedItem(obj_id srcContainer, obj_id transferer, obj_id item)
|
|
{
|
|
if(!isIdValid(srcContainer))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if(!isIdValid(item))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( utils.isNestedWithin(srcContainer, self) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( isPlayer(item) && factions.isDeclared(item) && factions.getFaction(item).equals(factions.getFaction(self)) )
|
|
utils.setScriptVar(item, "inAlignedStructure", self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAboutToReceiveItem(obj_id srcContainer, obj_id transferer, obj_id item)
|
|
{
|
|
if (utils.isNestedWithinAPlayer(item))
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnLostItem(obj_id destContainer, obj_id transferer, obj_id item)
|
|
{
|
|
if ( !isIdValid(destContainer) )
|
|
utils.removeScriptVar(item, "inAlignedStructure");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
/***** FUNCTIONS *******************************************************/
|
|
messageHandler handleDelayedRefundChecker()
|
|
{
|
|
hq.refundFactionBaseLots(self); //check to see if we've converted this base to the new GCW system (refund faction points and lots for bases placed prior to the GCW revamp - 2/28/05).
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
|
|
messageHandler handleHqDetonation()
|
|
{
|
|
obj_id player = obj_id.NULL_ID;
|
|
if (utils.hasScriptVar(self, "faction_hq.detonator"))
|
|
player = utils.getObjIdScriptVar(self, "faction_hq.detonator");
|
|
|
|
location[] tmplocs = params.getLocationArray("locs");
|
|
//LOG("LOG_CHANNEL", "handleHqDetonation -- " + tmplocs);
|
|
if ( tmplocs == null || tmplocs.length == 0 )
|
|
{
|
|
gcw.grantBaseDestructionPoints(self);
|
|
|
|
player_structure.destroyStructure(self, false, true);
|
|
string hqName = getName(self);
|
|
if (isIdValid(player))
|
|
CustomerServiceLog( "faction_hq", "Faction HQ (" + self + "), destroyed by normal terminal overload. Player initiating the destruction is %TU", player, null);
|
|
else
|
|
CustomerServiceLog( "faction_hq", "Faction HQ (" + self + "), destroyed by normal terminal overload.");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
resizeable location[] locs = new Vector(Arrays.asList(tmplocs));
|
|
if ( locs == null || locs.length == 0 )
|
|
{
|
|
string myFac = factions.getFaction(self);
|
|
int lvl = getHqLevel(self);
|
|
if ( lvl > 0 )
|
|
factions.changeFactionPoints(myFac, -10 * lvl);
|
|
gcw.grantBaseDestructionPoints(self);
|
|
|
|
player_structure.destroyStructure(self, false, true);
|
|
string hqName = getName(self);
|
|
if (isIdValid(player))
|
|
CustomerServiceLog( "faction_hq", "Faction HQ (" + self + "), destroyed by normal terminal overload. Player initiating the destruction is %TU", player, null);
|
|
else
|
|
CustomerServiceLog( "faction_hq", "Faction HQ (" + self + "), destroyed by normal terminal overload.");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
location there = locs[0];
|
|
locs.removeElementAt(0);
|
|
if ( locs == null || locs.length == 0 )
|
|
{
|
|
params.remove("locs");
|
|
}
|
|
else
|
|
{
|
|
params.put("locs", locs);
|
|
}
|
|
|
|
//play explosion there!
|
|
messageTo(self, "handleHqExplosions", params, rand(0.1f, 1.0f), false);
|
|
|
|
messageTo(self, "handleHqDetonation", params, rand(0.1f, 1f), true);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler handleHqExplosions()
|
|
{
|
|
location[] locs = params.getLocationArray("locs");
|
|
//LOG("LOG_CHANNEL", "handleHqExplosions -- " + self + " " + locs);
|
|
if (locs != null && locs.length > 0)
|
|
{
|
|
obj_id players[] = getPlayerCreaturesInRange(getLocation(self), 100.0f);
|
|
if (players != null && players.length > 0)
|
|
{
|
|
//LOG("LOG_CHANNEL", "player ->" + players[0]);
|
|
playClientEffectLoc(players[0], "clienteffect/combat_explosion_lair_large.cef", locs[0], 0.0f);
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
int getHqLevel(obj_id self)
|
|
{
|
|
string template = getTemplateName(self);
|
|
int idx = template.indexOf("_s0");
|
|
if ( idx > -1 )
|
|
{
|
|
string sLvl = template.substring(idx+3, idx+4);
|
|
int lvl = utils.stringToInt(sLvl);
|
|
return lvl;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
|
|
trigger OnDestroy()
|
|
{
|
|
hq.cleanUpHackAlarms(self);
|
|
string myFac = factions.getFaction(self);
|
|
int intFac = myFac.equals("Rebel") ? gcw.FACTION_REBEL : gcw.FACTION_IMPERIAL;
|
|
int lvl = getHqLevel(self);
|
|
gcw.modifyPlanetaryBaseCount(self, intFac, -1);
|
|
gcw.decrementGCWScore(self);
|
|
hq.refundBaseUnit(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void setCWData(obj_id self)
|
|
{
|
|
getClusterWideData("gcw_player_base", "base_cwdata_manager", true, self);
|
|
}
|
|
|
|
trigger OnClusterWideDataResponse(string manage_name, string dungeon_name, int request_id, string[] element_name_list, dictionary[] dungeon_data, int lock_key)
|
|
{
|
|
|
|
|
|
string name = "base_cwdata_manager"+"-"+self;
|
|
string scene = getCurrentSceneName();
|
|
location loc = getLocation(self);
|
|
string myFac = factions.getFaction(self);
|
|
int intFac = myFac.equals("Rebel") ? gcw.FACTION_REBEL : gcw.FACTION_IMPERIAL;
|
|
|
|
dictionary dungeon_info = new dictionary();
|
|
dungeon_info.put("dungeon_id", self);
|
|
dungeon_info.put("faction", intFac);
|
|
dungeon_info.put("ownerId", getOwner(self));
|
|
dungeon_info.put("scene", scene);
|
|
dungeon_info.put("position_x", loc.x);
|
|
dungeon_info.put("position_y", loc.y);
|
|
dungeon_info.put("position_z", loc.z);
|
|
|
|
replaceClusterWideData(manage_name, name, dungeon_info, true, lock_key);
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
|