package script.terminal; import script.*; import script.base_class.*; import script.combat_engine.*; import java.util.Arrays; import java.util.Hashtable; import java.util.Vector; import script.base_script; import script.library.city; import script.library.prose; import script.library.sui; import script.library.utils; import script.library.money; import script.library.player_structure; import java.util.Vector; public class terminal_city extends script.base_script { public terminal_city() { } public static final String STF = "city/city"; public static final string_id SID_CITY_HACKS = new string_id(STF, "city_hacks"); public static final string_id SID_CITY_FORCE_UPDATE = new string_id(STF, "force_update"); public static final string_id SID_CITY_RANK_UP = new string_id(STF, "rank_up"); public static final string_id SID_CITY_RANK_DOWN = new string_id(STF, "rank_down"); public static final string_id SID_CITY_FIX_MAYOR = new string_id(STF, "fix_mayor"); public static final string_id SID_CITY_MAKE_MAYOR = new string_id(STF, "make_mayor"); public static final string_id SID_CITY_REVOKE_CITIZENSHIP = new string_id(STF, "revoke_citizenship"); public static final string_id SID_CITY_REMOVE_OLD_TRAINERS = new string_id(STF, "remove_trainers"); public static final string_id SID_CLONE_DATA_WIPED = new string_id(STF, "clone_data_wiped"); public static final string_id SID_SHUTTLE_DATA_WIPED = new string_id(STF, "clone_data_wiped"); public static final string_id SID_CITY_RESET_CLONE_DATA = new string_id(STF, "reset_clone_data"); public static final string_id SID_CITY_RESET_SHUTTLE_DATA = new string_id(STF, "reset_shuttle_data"); public static final string_id SID_CITY_MODIFY_STRUCTURE_LIST = new string_id(STF, "modify_structure_list"); public static final string_id SID_CITY_INFO = new string_id(STF, "city_info"); public static final string_id SID_CITY_STATUS = new string_id(STF, "city_status"); public static final string_id SID_CITY_CITIZENS = new string_id(STF, "city_citizens"); public static final string_id SID_CITY_STRUCTURES = new string_id(STF, "city_structures"); public static final string_id SID_CITY_RANK = new string_id(STF, "city_rank"); public static final string_id SID_CITY_MAINT_REPORT = new string_id(STF, "city_maint"); public static final string_id SID_CITY_MANAGEMENT = new string_id(STF, "city_management"); public static final string_id SID_CITY_NAME = new string_id(STF, "city_name"); public static final string_id SID_CITY_MILITIA = new string_id(STF, "city_militia"); public static final string_id SID_CITY_REGISTER = new string_id(STF, "city_register"); public static final string_id SID_CITY_UNREGISTER = new string_id(STF, "city_unregister"); public static final string_id SID_CITY_SPECIALIZATIONS = new string_id(STF, "city_specializations"); public static final string_id SID_TREASURY_MANAGEMENT = new string_id(STF, "treasury_management"); public static final string_id SID_TREASURY_STATUS = new string_id(STF, "treasury_status"); public static final string_id SID_TREASURY_DEPOSIT = new string_id(STF, "treasury_deposit"); public static final string_id SID_TREASURY_WITHDRAW = new string_id(STF, "treasury_withdraw"); public static final string_id SID_TREASURY_TAXES = new string_id(STF, "treasury_taxes"); public static final string_id SID_NAME_CHANGED = new string_id(STF, "name_changed"); public static final string_id SID_OBSCENE = new string_id("player_structure", "obscene"); public static final string_id SID_NOT_UNIQUE = new string_id("player_structure", "cityname_not_unique"); public static final string_id SID_CANT_FIND_PLAYER = new string_id(STF, "cant_find_player"); public static final string_id SID_NOT_CITIZEN = new string_id(STF, "not_citizen"); public static final string_id SID_ADDED_MILITIA = new string_id(STF, "added_militia"); public static final string_id SID_REMOVED_MILITIA = new string_id(STF, "removed_militia"); public static final string_id SID_ADDED_MILITIA_TARGET = new string_id(STF, "added_militia_target"); public static final string_id SID_REMOVED_MILITIA_TARGET = new string_id(STF, "removed_militia_target"); public static final string_id SID_NO_MONEY = new string_id(STF, "no_money"); public static final string_id SID_TAX_OUT_OF_RANGE = new string_id(STF, "tax_out_of_range"); public static final string_id SID_INCOME_TAX = new string_id(STF, "set_income_tax"); public static final string_id SID_PROPERTY_TAX = new string_id(STF, "set_property_tax"); public static final string_id SID_SALES_TAX = new string_id(STF, "set_sales_tax"); public static final string_id SID_TRAVEL_FEE = new string_id(STF, "set_travel_fee"); public static final string_id SID_GARAGE_TAX = new string_id(STF, "set_garage_tax"); public static final string_id SID_CANT_TAX = new string_id(STF, "cant_tax"); public static final string_id SID_CANT_REGISTER = new string_id(STF, "cant_register"); public static final string_id SID_CANT_REGISTER_RANK = new string_id(STF, "cant_register_rank"); public static final string_id SID_REGISTERED = new string_id(STF, "registered"); public static final string_id SID_UNREGISTERED = new string_id(STF, "unregistered"); public static final string_id SID_CANT_MILITIA = new string_id(STF, "cant_militia"); public static final string_id SID_NO_RANK_TAXES = new string_id(STF, "no_rank_taxes"); public static final string_id SID_NO_RANK_SPEC = new string_id(STF, "no_rank_spec"); public static final string_id SID_NO_SPECS = new string_id(STF, "no_specs"); public static final string_id SID_SPEC_SET = new string_id(STF, "spec_set"); public static final string_id SID_SPEC_TIME = new string_id(STF, "spec_time"); public static final string_id SID_WITHDRAW_LIMITS = new string_id(STF, "withdraw_limits"); public static final string_id SID_WITHDRAW_DAILY = new string_id(STF, "withdraw_daily"); public static final string_id SID_NO_SHUTTLEPORT = new string_id(STF, "no_shuttleport"); public static final string_id PUBLIC_ELECTION_SUBJECT = new string_id( STF, "public_election_subject"); public static final string_id PUBLIC_ELECTION_BODY = new string_id( STF, "public_election_body"); public static final String CITY_SPECS = "datatables/city/specializations.iff"; public static final String[] TAX_STRING = { "income", "property", "sales", "travel", "garage" }; public static final int[] TAX_MIN = { 0, 0, 0, 1, 0 }; public static final int[] TAX_MAX = { 2000, 50, 20, 500, 30 }; public static final string_id SID_CITY_ZONE = new string_id(STF, "zone"); public static final string_id SID_CITY_UNZONE = new string_id(STF, "unzone"); public static final string_id SID_ZONING_ENABLED = new string_id(STF, "zoning_enabled"); public static final string_id SID_ZONING_DISABLED = new string_id(STF, "zoning_disabled"); public static final string_id SID_ZONING_SKILL = new string_id(STF, "zoning_skill"); public static final string_id TREASURY_WITHDRAW_SUBJECT = new string_id( STF, "treasury_withdraw_subject"); public static final string_id TREASURY_WITHDRAW_BODY = new string_id( STF, "treasury_withdraw_body"); public static final string_id TAX_INCOME_SUBJECT = new string_id( STF, "tax_income_subject"); public static final string_id TAX_INCOME_BODY = new string_id( STF, "tax_income_body"); public static final string_id TAX_PROPERTY_SUBJECT = new string_id( STF, "tax_property_subject"); public static final string_id TAX_PROPERTY_BODY = new string_id( STF, "tax_property_body"); public static final string_id TAX_SALES_SUBJECT = new string_id( STF, "tax_sales_subject"); public static final string_id TAX_SALES_BODY = new string_id( STF, "tax_sales_body"); public static final string_id TAX_TRAVEL_SUBJECT = new string_id( STF, "tax_travel_subject"); public static final string_id TAX_TRAVEL_BODY = new string_id( STF, "tax_travel_body"); public static final string_id GARAGE_FEE_SUBJECT = new string_id( STF, "garage_fee_subject"); public static final string_id GARAGE_FEE_BODY = new string_id( STF, "garage_fee_body"); public static final string_id SID_YOU_WITHDRAW_FROM_TREASURY = new string_id( STF, "you_withdraw_from_treasury"); public static final string_id SID_SUI_CONFIRM_REMOVE_TITLE = new string_id( STF, "sui_confirm_remove_title"); public static final string_id SID_REVOKE_CITIZEN_WARNING = new string_id(STF, "revoke_citizenship_warning"); public static final String PROFESSION_TRAINER_SCRIPT = "npc.skillteacher.trainer_spawner"; public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException { obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); if (!cityExists( city_id )) { return SCRIPT_CONTINUE; } obj_id mayor = cityGetLeader( city_id ); if (!city.isCitizenOfCity(player, city_id) && (player != mayor) && !isGod(player)) { return SCRIPT_CONTINUE; } int menu = mi.addRootMenu(menu_info_types.ITEM_USE, SID_CITY_INFO); mi.addSubMenu( menu, menu_info_types.CITY_STATUS, SID_CITY_STATUS ); mi.addSubMenu( menu, menu_info_types.CITY_CITIZENS, SID_CITY_CITIZENS ); mi.addSubMenu( menu, menu_info_types.CITY_STRUCTURES, SID_CITY_STRUCTURES ); mi.addSubMenu( menu, menu_info_types.CITY_RANK, SID_CITY_RANK ); mi.addSubMenu( menu, menu_info_types.SERVER_MENU3, SID_CITY_MAINT_REPORT ); mi.addSubMenu( menu, menu_info_types.CITY_TREASURY, SID_TREASURY_STATUS ); mi.addSubMenu( menu, menu_info_types.CITY_TREASURY_DEPOSIT, SID_TREASURY_DEPOSIT ); if (city.isCitizenOfCity(player, city_id) && (player != mayor)) { mi.addSubMenu( menu, menu_info_types.SERVER_MENU5, SID_CITY_REVOKE_CITIZENSHIP ); } if (player == mayor) { menu = mi.addRootMenu( menu_info_types.CITY_MANAGEMENT, SID_CITY_MANAGEMENT ); mi.addSubMenu( menu, menu_info_types.CITY_NAME, SID_CITY_NAME ); if (!city.isCityRegistered( city_id )) { mi.addSubMenu( menu, menu_info_types.CITY_REGISTER, SID_CITY_REGISTER ); } else { mi.addSubMenu( menu, menu_info_types.CITY_REGISTER, SID_CITY_UNREGISTER ); } if (city.isCityZoned( city_id )) { mi.addSubMenu( menu, menu_info_types.SERVER_MENU2, SID_CITY_UNZONE ); } else { mi.addSubMenu( menu, menu_info_types.SERVER_MENU2, SID_CITY_ZONE ); } mi.addSubMenu( menu, menu_info_types.CITY_MILITIA, SID_CITY_MILITIA ); mi.addSubMenu( menu, menu_info_types.CITY_TAXES, SID_TREASURY_TAXES ); mi.addSubMenu( menu, menu_info_types.CITY_TREASURY_WITHDRAW, SID_TREASURY_WITHDRAW ); mi.addSubMenu( menu, menu_info_types.SERVER_MENU1, SID_CITY_SPECIALIZATIONS ); if (!city.isCitizenOfCity( player, city_id )) { mi.addSubMenu( menu, menu_info_types.SERVER_MENU8, SID_CITY_FIX_MAYOR ); } if (citySkillTrainersExist(city_id)) { mi.addRootMenu( menu_info_types.SERVER_MENU10, SID_CITY_REMOVE_OLD_TRAINERS ); } } if (isGod( player )) { int godMenu = mi.addRootMenu( menu_info_types.ITEM_USE_SELF, SID_CITY_HACKS ); mi.addSubMenu( godMenu, menu_info_types.SERVER_MENU4, SID_CITY_FORCE_UPDATE ); mi.addSubMenu( godMenu, menu_info_types.SERVER_MENU6, SID_CITY_RANK_UP ); mi.addSubMenu( godMenu, menu_info_types.SERVER_MENU7, SID_CITY_RANK_DOWN ); mi.addSubMenu( godMenu, menu_info_types.CITY_NAME, SID_CITY_NAME ); mi.addSubMenu( godMenu, menu_info_types.SERVER_MENU9, SID_CITY_MAKE_MAYOR ); mi.addSubMenu( godMenu, menu_info_types.CITY_ADMIN_1, SID_CITY_RESET_CLONE_DATA ); mi.addSubMenu( godMenu, menu_info_types.CITY_ADMIN_2, SID_CITY_RESET_SHUTTLE_DATA ); mi.addSubMenu( godMenu, menu_info_types.CITY_ADMIN_3, SID_CITY_MODIFY_STRUCTURE_LIST ); } return SCRIPT_CONTINUE; } public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException { obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); if (!cityExists( city_id )) { return SCRIPT_CONTINUE; } obj_id mayor = cityGetLeader( city_id ); if (item == menu_info_types.CITY_STATUS) { showCityInfo( player, self, city_id ); } else if (item == menu_info_types.CITY_CITIZENS) { showCitizensList( player, self, city_id ); } else if (item == menu_info_types.CITY_STRUCTURES) { showStructuresList( player, self, city_id ); } else if (item == menu_info_types.CITY_TREASURY) { showTreasuryInfo( player, self, city_id ); } else if (item == menu_info_types.CITY_RANK) { showAdvancementInfo( player, self, city_id ); } else if (item == menu_info_types.SERVER_MENU3) { showMaintInfo( player, self, city_id ); } if (item == menu_info_types.CITY_TREASURY_DEPOSIT) { makeTreasuryDeposit( player, self, city_id ); } if (player == mayor) { if (item == menu_info_types.CITY_NAME) { changeCityName( player, self, city_id ); } else if (item == menu_info_types.CITY_TAXES) { adjustTaxes( player, self, city_id ); } else if (item == menu_info_types.CITY_MILITIA) { modifyMilitia( player, self, city_id ); } else if (item == menu_info_types.CITY_TREASURY_WITHDRAW) { makeTreasuryWithdraw( player, self, city_id ); } else if (item == menu_info_types.CITY_REGISTER) { if (!city.isCityRegistered( city_id )) { sui.msgbox( self, player, "@city/city:register_d", sui.YES_NO, "@city/city:register_t", sui.MSG_QUESTION, "handleRegisterCity"); } else { sui.msgbox( self, player, "@city/city:unregister_d", sui.YES_NO, "@city/city:unregister_t", sui.MSG_QUESTION, "handleUnregisterCity"); } } else if (item == menu_info_types.SERVER_MENU1) { changeSpecialization( player, self, city_id ); } else if (item == menu_info_types.SERVER_MENU2) { changeZoning( player, self, city_id ); } else if (item == menu_info_types.SERVER_MENU8) { if (!city.isCitizenOfCity( mayor, city_id )) { citySetCitizenInfo( city_id, mayor, getName(mayor), mayor, city.CP_CITIZEN ); sendSystemMessage(self, new string_id(STF, "mayor_citizen_restored")); } } else if (item == menu_info_types.SERVER_MENU10) { boolean trainersDestroyed = destroyCitySkillTrainers(mayor, city_id); if (trainersDestroyed) { sendSystemMessage(mayor, new string_id(STF, "old_trainers_removed")); } } } else { if (item == menu_info_types.SERVER_MENU5) { if (city.isCitizenOfCity( player, city_id )) { sui.msgbox( self, player, "@city/city:revoke_cit_d", sui.YES_NO, "@city/city:revoke_cit_t", sui.MSG_QUESTION, "handleRevokeCitizenship"); } } } if (isGod( player )) { if (item == menu_info_types.SERVER_MENU4) { forceUpdate( player, self, city_id ); } else if (item == menu_info_types.SERVER_MENU6) { forceRank( player, self, city_id, 1 ); } else if (item == menu_info_types.SERVER_MENU7) { forceRank( player, self, city_id, -1 ); } else if (item == menu_info_types.SERVER_MENU9) { makeMayor( player, self, city_id ); } else if (item == menu_info_types.CITY_ADMIN_1) { resetCloneData( player, self, city_id ); } else if (item == menu_info_types.CITY_ADMIN_2) { resetShuttleData( player, self, city_id ); } else if (item == menu_info_types.CITY_ADMIN_3) { modifyStructureList( player, self, city_id ); } } return SCRIPT_CONTINUE; } public void forceUpdate(obj_id player, obj_id self, int city_id) throws InterruptedException { sui.msgbox( self, player, "@city/city:force_election_only", sui.YES_NO, "@city/city:force_city_update_t", sui.MSG_QUESTION, "handleForceUpdateElection"); } public int handleForceUpdateElection(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId( params ); obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); int btn = sui.getIntButtonPressed( params ); if (btn == sui.BP_CANCEL) { sui.msgbox( self, player, "@city/city:confirm_city_update", sui.YES_NO, "@city/city:force_city_update_t", sui.MSG_QUESTION, "handleForceUpdateConfirmed"); } else { CustomerServiceLog( "player_city", "!!!!! A CITY ELECTION WAS FORCED !!!!! Player: "+ player + " City: "+ city_id ); sendSystemMessageProse(self, prose.getPackage(new string_id (STF, "force_city_election"), city_id)); obj_id cityMaster = getMasterCityObject(); dictionary outparams = new dictionary(); outparams.put( "city_id", city_id ); messageTo( cityMaster, "forceElection", outparams, 0.f, false ); } return SCRIPT_CONTINUE; } public int handleForceUpdateConfirmed(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId( params ); int btn = sui.getIntButtonPressed( params ); if (btn == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } sui.msgbox( self, player, "@city/city:confirm_disable_cleanup", sui.YES_NO, "@city/city:disable_cleanup_t", sui.MSG_QUESTION, "handleForceUpdateNow"); return SCRIPT_CONTINUE; } public int handleForceUpdateNow(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId( params ); obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); dictionary outparams = new dictionary(); outparams.put( "city_id", city_id ); int btn = sui.getIntButtonPressed( params ); if (btn != sui.BP_CANCEL) { outparams.put( "no_citizen_cleanup", 1 ); } CustomerServiceLog( "player_city", "!!!!! A CITY UPDATE WAS FORCED !!!!! Player: "+ player + " City: "+ city_id ); sendSystemMessageProse(self, prose.getPackage(new string_id (STF, "force_city_update"), city_id)); obj_id cityMaster = getMasterCityObject(); messageTo( cityMaster, "forceUpdate", outparams, 0.f, false ); return SCRIPT_CONTINUE; } public void forceRank(obj_id player, obj_id self, int city_id, int rank) throws InterruptedException { utils.setScriptVar( self, "rank_change", rank ); sui.msgbox( self, player, "@city/city:force_city_rank_d", sui.YES_NO, "@city/city:force_city_rank_t", sui.MSG_QUESTION, "handleForceRankConfirmed"); } public int handleForceRankConfirmed(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId( params ); int btn = sui.getIntButtonPressed( params ); if (btn == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); CustomerServiceLog( "player_city", "!!!!! A CITY RANK CHANGE WAS FORCED !!!!! Player: "+ player + " City: "+ city_id ); sendSystemMessageProse(self, prose.getPackage(new string_id (STF, "force_city_rank"), city_id)); obj_id cityMaster = getMasterCityObject(); dictionary outparams = new dictionary(); outparams.put( "city_id", city_id ); outparams.put( "rank_change", utils.getIntScriptVar( self, "rank_change") ); messageTo( cityMaster, "forceRank", outparams, 0.f, false ); return SCRIPT_CONTINUE; } public void makeMayor(obj_id player, obj_id self, int city_id) throws InterruptedException { sui.inputbox( self, player, "@city/city:make_mayor_d", sui.OK_CANCEL, "@city/city:make_mayor_t", sui.INPUT_NORMAL, null, "handleMakeMayor", null ); } public int handleMakeMayor(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId(params); String input_name = sui.getInputBoxText( params ); obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); obj_id[] citizens = cityGetCitizenIds( city_id ); for (int i=0; i= 1) { string_id sm_garden = new string_id(STF, "small_garden"); rankInfo = utils.addElement( rankInfo, getString(sm_garden)); } if (city_rank >= 2) { string_id bank = new string_id(STF, "bank"); rankInfo = utils.addElement( rankInfo, getString(bank)); string_id cantina = new string_id(STF, "cantina"); rankInfo = utils.addElement( rankInfo, getString(cantina)); string_id med_garden = new string_id(STF, "medium_garden"); rankInfo = utils.addElement( rankInfo, getString(med_garden)); string_id garage = new string_id(STF, "garage"); rankInfo = utils.addElement( rankInfo, getString(garage)); } if (city_rank >= 3) { string_id cloning = new string_id(STF, "cloning_facility"); rankInfo = utils.addElement( rankInfo, getString(cloning)); string_id hospital = new string_id(STF, "hospital"); rankInfo = utils.addElement( rankInfo, getString(hospital)); string_id lg_garden = new string_id(STF, "large_garden"); rankInfo = utils.addElement( rankInfo, getString(lg_garden)); } if (city_rank >= 4) { string_id theater = new string_id(STF, "theater"); rankInfo = utils.addElement( rankInfo, getString(theater)); string_id shuttleport = new string_id(STF, "shuttleport"); rankInfo = utils.addElement( rankInfo, getString(shuttleport)); } sui.listbox( self, player, "@city/city:rank_info_d", sui.OK_CANCEL, "@city/city:rank_info_t", rankInfo, "handleRankInfo", true ); obj_id city_master = getMasterCityObject(); dictionary outparams = new dictionary(); outparams.put( "player", player ); outparams.put( "city_id", city_id ); messageTo( city_master, "reportUpdateEstimate", outparams, 0.f, false ); } public void showMaintInfo(obj_id player, obj_id self, int city_id) throws InterruptedException { obj_id city_hall = getTopMostContainer( self ); int city_hall_cost = city.getStructureCost( city_id, city_hall ); int spec_cost = city.cityGetSpecCost( city_id ); int over_cap = 0; int total_cost = 0; String[] maintInfo; int civic_count = city.getCivicCount( city_id ); int max_civic = city.getMaxCivicCount( city_id ); if (civic_count > max_civic) { over_cap = civic_count - max_civic; total_cost += 75000 * over_cap; maintInfo = new String[9]; } else { maintInfo = new String[7]; } int structures_cost = 0; int deco_cost = 0; int other_cost = 0; obj_id[] structures = cityGetStructureIds( city_id ); for (int i=0; i max_civic) { string_id civ_struc_pen = new string_id(STF, "civic_structure_panalty"); maintInfo[i++] = "\\#FF0000" + getString(civ_struc_pen) + "\\ " + (75000*over_cap); string_id you_have = new string_id(STF, "you_have"); string_id more_than_cap = new string_id(STF, "more_than_cap"); maintInfo[i++] = " (" + getString(you_have) + over_cap + getString(more_than_cap) + max_civic + ".)"; } if (city.isCityRegistered( city_id )) { string_id map_reg_cost = new string_id(STF, "map_reg_cost"); maintInfo[i++] = getString(map_reg_cost); } else { string_id map_unreg = new string_id(STF, "map_unreg"); maintInfo[i++] = getString(map_unreg); } string_id spec_text = new string_id(STF, "specialization"); maintInfo[i++] = getString(spec_text) + spec_cost + getString(credits_suffix); string_id struc_text = new string_id(STF, "structures"); maintInfo[i++] = getString(struc_text) + structures_cost + getString(credits_suffix); string_id deco_text = new string_id(STF, "decorations"); maintInfo[i++] = getString(deco_text) + deco_cost + getString(credits_suffix); string_id tnt_text = new string_id(STF, "train_and_term"); maintInfo[i++] = getString(tnt_text) + other_cost + getString(credits_suffix); sui.listbox( self, player, "@city/city:maint_info_d", sui.OK_CANCEL, "@city/city:maint_info_t", maintInfo, "handleMaintInfo", true ); obj_id city_master = getMasterCityObject(); dictionary outparams = new dictionary(); outparams.put( "player", player ); outparams.put( "city_id", city_id ); messageTo( city_master, "reportUpdateEstimate", outparams, 0.f, false ); } public void changeCityName(obj_id player, obj_id self, int city_id) throws InterruptedException { sui.inputbox( self, player, "@city/city:city_name_new_d", sui.OK_CANCEL, "@city/city:city_name_new_t", sui.INPUT_NORMAL, null, "handleSetCityName", null ); } public int handleSetCityName(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId(params); String cityName = sui.getInputBoxText( params ); int btn = sui.getIntButtonPressed( params ); if (btn == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } if ((cityName.equals("")) || isNameReserved(cityName)) { sendSystemMessage( player, SID_OBSCENE ); sui.inputbox( self, player, "@city/city:city_name_new_d", sui.OK_CANCEL, "@city/city:city_name_new_t", sui.INPUT_NORMAL, null, "handleSetCityName", null ); return SCRIPT_CONTINUE; } if (cityName.length() > 24) { cityName = cityName.substring( 0, 23 ); } if (!city.isUniqueCityName( cityName )) { sendSystemMessage( player, SID_NOT_UNIQUE ); sui.inputbox( self, player, "@city/city:city_name_new_d", sui.OK_CANCEL, "@city/city:city_name_new_t", sui.INPUT_NORMAL, null, "handleSetCityName", null ); return SCRIPT_CONTINUE; } obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); if (!cityExists( city_id )) { return SCRIPT_CONTINUE; } city.setName( city_id, cityName ); obj_id mayor = cityGetLeader( city_id ); sendSystemMessage( mayor, SID_NAME_CHANGED ); return SCRIPT_CONTINUE; } public void modifyMilitia(obj_id player, obj_id self, int city_id) throws InterruptedException { if (!hasCommand( player, "manage_militia" )) { sendSystemMessage( player, SID_CANT_MILITIA ); return; } obj_id[] citizens = cityGetCitizenIds( city_id ); Vector militiaMembers = new Vector(); militiaMembers.setSize(0); militiaMembers = utils.addElement( militiaMembers, "Add Militia Member"); for (int i=0; i -1) { s1 = s1.substring( 0, indexOf ); } if (s1.compareTo( s2 ) == 0) { if (city.isCitizenOfCity( players[i], city_id )) { city.addMilitia( city_id, players[i] ); sendSystemMessage( player, SID_ADDED_MILITIA ); sendSystemMessage( players[i], SID_ADDED_MILITIA_TARGET ); } else { sendSystemMessage( player, SID_NOT_CITIZEN ); } return SCRIPT_CONTINUE; } } sendSystemMessage( player, SID_CANT_FIND_PLAYER ); return SCRIPT_CONTINUE; } public int handleRemoveMilitiaConfirmed(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId( params ); int btn = sui.getIntButtonPressed( params ); if (btn == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); if (!cityExists( city_id )) { return SCRIPT_CONTINUE; } obj_id removeTarget = utils.getObjIdScriptVar( self, "removal.temp"); if (city.isCitizenOfCity( removeTarget, city_id )) { city.removeMilitia( city_id, removeTarget ); sendSystemMessage( player, SID_REMOVED_MILITIA ); sendSystemMessage( removeTarget, SID_REMOVED_MILITIA_TARGET ); } else { sendSystemMessage( player, SID_NOT_CITIZEN ); } return SCRIPT_CONTINUE; } public void showTreasuryInfo(obj_id player, obj_id self, int city_id) throws InterruptedException { obj_id structure = getTopMostContainer( self ); String[] treasury_info = new String[6]; treasury_info[0] = "Balance: " + getBankBalance( structure ); obj_id city = cityGetCityHall(city_id); String city_name = cityGetName(city_id); String garage = city_name + ".garageFee"; if (!hasObjVar(city, garage)) { setObjVar(city, garage, 0); } int income_tax = cityGetIncomeTax( city_id ); int property_tax = cityGetPropertyTax( city_id ); int sales_tax = cityGetSalesTax( city_id ); int travel_fee = cityGetTravelCost( city_id ); int garage_fee = getIntObjVar(city, garage); treasury_info[1] = "@city/city:income_tax" + " -- " + income_tax + " cr"; treasury_info[2] = "@city/city:property_tax" + " -- " + property_tax + "%"; treasury_info[3] = "@city/city:sales_tax" + " -- " + sales_tax + "%"; treasury_info[4] = "@city/city:travel_tax" + " -- " + travel_fee + " cr"; treasury_info[5] = "@city/city:garage_tax" + " -- " + garage_fee + "%"; sui.listbox( self, player, "@city/city:treasury_balance_d", sui.OK_CANCEL, "@city/city:treasury_balance_t", treasury_info, "handleTreasuryInfoSelect", true ); } public void makeTreasuryDeposit(obj_id player, obj_id self, int city_id) throws InterruptedException { obj_id structure = getTopMostContainer( self ); int total = getTotalMoney( player ); if (total > 0) { int maint_pool = getBankBalance( structure ); int pid = sui.transfer( self, player, "@city/city:treasury_deposit_d", "@city/city:treasury_deposit", "@city/city:total_funds", total, "@city/city:treasury", 0, "depositTreasury"); } else { sendSystemMessage( player, SID_NO_MONEY ); } } public int depositTreasury(obj_id self, dictionary params) throws InterruptedException { obj_id structure = getTopMostContainer( self ); obj_id player = sui.getPlayerId( params ); int bp = sui.getIntButtonPressed( params ); if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } int total = getTotalMoney( player ); int end_bal = sui.getTransferInputFrom( params ); int amt = total - end_bal; if (amt < 0) { sendSystemMessage(player, new string_id(STF, "positive_deposit")); } else if (amt == 0) { return SCRIPT_CONTINUE; } else { sendSystemMessageProse(self, prose.getPackage(new string_id (STF, "deposit_treasury"), amt)); money.requestPayment( player, structure, amt, "handlePayment", null ); } return SCRIPT_CONTINUE; } public void makeTreasuryWithdraw(obj_id player, obj_id self, int city_id) throws InterruptedException { sui.inputbox( self, player, "@city/city:withdraw_reason_d", sui.OK_CANCEL, "@city/city:withdraw_reason_t", sui.INPUT_NORMAL, null, "handleWithdrawReason", null ); } public int handleWithdrawReason(obj_id self, dictionary params) throws InterruptedException { obj_id player = sui.getPlayerId(params); String withdraw_reason = sui.getInputBoxText( params ); int btn = sui.getIntButtonPressed( params ); if (btn == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } utils.setScriptVar( self, "withdrawReason", withdraw_reason ); obj_id structure = getTopMostContainer( self ); int total = getBankBalance( structure ); if (total > 0) { int player_cash = getCashBalance( player ); int pid = sui.transfer( self, player, "@city/city:treasury_withdraw_prompt", "@city/city:treasury_withdraw", "@city/city:treasury", total, "@city/city:funds", 0, "withdrawTreasury"); } else { sendSystemMessage( player, SID_NO_MONEY ); } return SCRIPT_CONTINUE; } public int withdrawTreasury(obj_id self, dictionary params) throws InterruptedException { obj_id structure = getTopMostContainer( self ); int city_id = findCityByCityHall( structure ); obj_id player = sui.getPlayerId( params ); int bp = sui.getIntButtonPressed( params ); if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } int total = getBankBalance( structure ); int end_bal = sui.getTransferInputFrom( params ); if (hasObjVar( self, "lastWithdrawTime" )) { int lastWithdrawTime = getIntObjVar( self, "lastWithdrawTime"); if (getGameTime() - lastWithdrawTime < 86400) { sendSystemMessage( player, SID_WITHDRAW_DAILY ); return SCRIPT_CONTINUE; } } int amt = total - end_bal; if (amt < 0) { sendSystemMessage(player, new string_id(STF, "withdraw_treasury")); } else if (amt == 0) { return SCRIPT_CONTINUE; } else { if ((amt < 5000) || (amt > 50000)) { sendSystemMessage( player, SID_WITHDRAW_LIMITS ); return SCRIPT_CONTINUE; } dictionary payparams = new dictionary(); payparams.put( "city_id", city_id ); payparams.put( "amt", amt ); payparams.put( "player", player ); transferBankCreditsTo( structure, player, amt, "handleWithdrawSuccess", "handleWithdrawFail", payparams ); } return SCRIPT_CONTINUE; } public int handleWithdrawSuccess(obj_id self, dictionary params) throws InterruptedException { int city_id = params.getInt( "city_id"); int amt = params.getInt( "amt"); obj_id player = params.getObjId( "player"); setObjVar( self, "lastWithdrawTime", getGameTime() ); prose_package ppWithdraw = prose.getPackage(SID_YOU_WITHDRAW_FROM_TREASURY); prose.setDI(ppWithdraw, amt); sendSystemMessageProse( player, ppWithdraw ); CustomerServiceLog( "player_city", "Mayor withdrew from treasury. City: "+ city_id + " Amt: "+ amt + " Player: "+ player ); obj_id mayor = cityGetLeader( city_id ); String mayor_name = cityGetCitizenName( city_id, mayor ); String citizen_name = ""; String withdraw_reason = utils.getStringScriptVar( self, "withdrawReason"); obj_id[] citizens = cityGetCitizenIds( city_id ); for (int i=0; i TAX_MAX[set_tax]) { sendSystemMessage( player, SID_TAX_OUT_OF_RANGE ); return SCRIPT_CONTINUE; } obj_id mayor = cityGetLeader( city_id ); String mayor_name = cityGetCitizenName( city_id, mayor ); String city_name = cityGetName( city_id ); obj_id[] citizens = cityGetCitizenIds( city_id ); prose_package pp = null; switch( set_tax ) { case 0: city.setIncomeTax( city_id, desired_tax ); pp = prose.getPackage( SID_INCOME_TAX, desired_tax ); for (int i=0; i