mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-03 03:15:55 -04:00
Fixes for Elusive Fish and Fishing Controller
This commit is contained in:
@@ -13,41 +13,92 @@ public class master_object extends script.base_script {
|
||||
public static final String OBJVAR_LEADERBOARD_UPDATE_TIME = "leaderboards_last_updated";
|
||||
public static final String OBJVAR_CONTROLLER_SETUP_TIME = "master_fishing_object_created";
|
||||
|
||||
public int OnInitialize(obj_id self) throws InterruptedException {
|
||||
if(!hasObjVar(self, OBJVAR_CONTROLLER_SETUP_TIME)) {
|
||||
messageTo(self, "handleSetupMasterFishingObject", null, 3, true);
|
||||
}
|
||||
setName(self, "Master Fishing Object [do not move]");
|
||||
public int OnAttach(obj_id self) throws InterruptedException {
|
||||
messageTo(self, "handleControllerInitialization", null, 120f, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
public int OnInitialize(obj_id self) throws InterruptedException {
|
||||
messageTo(self, "handleControllerInitialization", null, 120f, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// Make sure CSRs can't take the master object on a stroll down Amidala's Beach when they should be home doing their homework
|
||||
public int OnAboutToBeTransferred(obj_id self, obj_id destContainer, obj_id transferer) throws InterruptedException {
|
||||
sendSystemMessageTestingOnly(transferer, "You cannot move this item!");
|
||||
return SCRIPT_OVERRIDE;
|
||||
}
|
||||
|
||||
/**
|
||||
* handleControllerInitialization
|
||||
* Handles the setup of the controller and triggers updates to critical functions
|
||||
*/
|
||||
public int handleControllerInitialization(obj_id self, dictionary params) throws InterruptedException {
|
||||
|
||||
setName(self, "Master Fishing Object");
|
||||
if(!hasObjVar(self, OBJVAR_CONTROLLER_SETUP_TIME)) {
|
||||
messageTo(self, "handleSetupMasterFishingObject", null, 20f, true);
|
||||
}
|
||||
// Update the leader board weekly, and force update if 7-days have passed since last update (in case of offline fails to trigger update)
|
||||
createWeeklyAlarmClock(self, "handleUpdateLeaderboards", null, DAY_OF_WEEK_THU, 19, 0,0);
|
||||
if (!hasObjVar(self, OBJVAR_LEADERBOARD_UPDATE_TIME)) {
|
||||
messageTo(self, "handleUpdateLeaderboards", null, 120, false);
|
||||
messageTo(self, "handleWeeklyUpdateLeaderboards", null, 20f, true);
|
||||
}
|
||||
if(getCalendarTime() > getIntObjVar(self, OBJVAR_LEADERBOARD_UPDATE_TIME) + 604800) {
|
||||
messageTo(self, "handleUpdateLeaderboards", null, 120, false);
|
||||
messageTo(self, "handleWeeklyUpdateLeaderboards", null, 20f, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* handleSetupMasterFishingObject
|
||||
* Handles all required setup for the Fishing Object, intended to only be called on a fresh server once
|
||||
*/
|
||||
public int handleSetupMasterFishingObject(obj_id self, dictionary params) throws InterruptedException {
|
||||
if(!hasObjVar(self, OBJVAR_CONTROLLER_SETUP_TIME)) {
|
||||
if (isIdValid(self)) {
|
||||
setObjVar(getPlanetByName("tatooine"), "master_fishing_object", self);
|
||||
setObjVar(self, OBJVAR_CONTROLLER_SETUP_TIME, getCalendarTime());
|
||||
fishing.handleConstructElusiveFishTable(self);
|
||||
LOG("fishing", "Created Master Fishing Object ("+ self +") and attached to Tatooine Planet Object.");
|
||||
} else {
|
||||
LOG("fishing", "[ERROR FEATURE-FATAL]: Attempted to create Master Fishing Object but it failed.");
|
||||
}
|
||||
setObjVar(getPlanetByName("tatooine"), fishing.OBJVAR_PLANET_OBJECT_REFERENCE, self);
|
||||
setObjVar(self, OBJVAR_CONTROLLER_SETUP_TIME, getCalendarTime());
|
||||
String[] elusiveFishTable = dataTableGetStringColumn(fishing.ELUSIVE_FISH_TABLE, "fish");
|
||||
for (String fish : elusiveFishTable) {
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TABLE_TREE+fish, 0);
|
||||
}
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TOTAL, 0);
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TABLE_MADE, 1);
|
||||
LOG("fishing", "Created Master Fishing Object ("+ self +") and completed setupMasterFishingObject.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* handleUpdateElusiveFishLeaderboard
|
||||
* Adds an array of information to the elusive fish leaderboard as passed in fishing.giveElusiveFishRewards
|
||||
*/
|
||||
public int handleUpdateElusiveFishLeaderboard(obj_id self, dictionary params) throws InterruptedException {
|
||||
String[] fishInfo = params.getStringArray("elusiveFishLeaderboardItems");
|
||||
String fishType = params.getString("fishType");
|
||||
// update total elusive fish caught count
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TOTAL, getIntObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TOTAL)+1);
|
||||
// update specific elusive fish caught count
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TABLE_TREE+fishType, getIntObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_COUNT_TABLE_TREE+fishType)+1);
|
||||
// add leaderboard entry
|
||||
if(!hasObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_LEADERBOARD_COUNT_TOTAL)) {
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_LEADERBOARD_COUNT_TOTAL, 1);
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_LEADERBOARD_TREE+"0", fishInfo);
|
||||
} else {
|
||||
int leaderboardEntries = getIntObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_LEADERBOARD_COUNT_TOTAL);
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_LEADERBOARD_TREE+leaderboardEntries, fishInfo);
|
||||
setObjVar(self, fishing.OBJVAR_ELUSIVE_FISH_LEADERBOARD_COUNT_TOTAL, ++leaderboardEntries);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
public int handleUpdateLeaderboards(obj_id self, dictionary params) throws InterruptedException {
|
||||
/**
|
||||
* handleWeeklyUpdateLeaderboards
|
||||
* Called when it is time to update all of the fishing leaderboards (does not include elusive fish as that is lifetime per galaxy)
|
||||
*/
|
||||
public int handleWeeklyUpdateLeaderboards(obj_id self, dictionary params) throws InterruptedException {
|
||||
// placeholder for weekly updated leaderboards
|
||||
setObjVar(self, OBJVAR_LEADERBOARD_UPDATE_TIME, getCalendarTime());
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user