Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package twcore.bots.battlebot.PublicOps.Flags;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import twcore.bots.battlebot.BZTimer;
- import twcore.bots.battlebot.ChatBuffer;
- import twcore.bots.battlebot.DoorMan;
- import twcore.core.BotAction;
- import twcore.core.events.PlayerDeath;
- import twcore.core.events.PlayerPosition;
- import twcore.core.events.WatchDamage;
- import twcore.core.game.Player;
- public class BaseFlagging {
- BotAction b;
- ChatBuffer bzChat;
- DoorMan bob;
- public BaseFlagging(BotAction b, ChatBuffer c, DoorMan bob)
- {
- this.b = b;
- this.bzChat = c;
- this.bob = bob;
- }
- /*-------------------------------------------------------------------------------\
- *
- * NEEDED VARS
- *
- *-------------------------------------------------------------------------------*/
- private boolean m_StartingGame = false;
- private boolean m_GameOn = false;
- public boolean GameOn(){ return this.m_GameOn; }
- private long m_GameStartTimeStamp;
- // Flag lvz
- private int m_LvzOn = 1428;
- private int m_LvzOff = 1427;
- // Door to toggle on and off
- private byte m_DoorNumber = 5;
- // Map room coords
- private short[] m_MapRoom1 = new short[]{ 225 * 16, 778 * 16, 499 * 16, 846 * 16};
- private short[] m_MapRoom2 = new short[]{ 499 * 16, 792 * 16, 785 * 16, 846 * 16};
- private short[] m_FlagHotSpot = new short[]{ 12336, 13328, 12496, 13488 };
- // Settings for timer
- private BZTimer m_StartGameSet;
- // settings for game timer
- private BZTimer m_GameTimerSet;
- // If base has initially been raided
- private boolean m_BeenRaided = false;
- private String m_WhoRaided = "~nobody~";
- private short m_FreqRaided = 8025;
- private long m_RaidTime = 0;
- // Freq that owns the flag
- private short m_BaseOwner = 8025;
- private long m_BaseTimestamp;
- /*-------------------------------------------------------------------------------\
- *
- * SUBSPACE EVENTS
- *
- *-------------------------------------------------------------------------------*/
- public void PlayerPositionEvent(PlayerPosition p)
- {
- // If there is no game check for stragglers in the area
- if (!m_GameOn)
- {
- // Flag room
- if (InRegion(p,m_MapRoom1)||InRegion(p,m_MapRoom2))
- {
- // Warp them back
- b.sendPrivateMessage(p.getPlayerID(), "There are no matches at this time and you are not authorized to be in this area.");
- b.warpTo(p.getPlayerID(), 512,512);
- }
- // No need to track flag hot spot unless game has started
- return;
- }
- // Flag HOTSPOT - If a new freq has taken possession
- if (InRegion(p, m_FlagHotSpot) && b.getPlayer(p.getPlayerID()).getFrequency() != m_BaseOwner)
- baseRaided(p);
- }
- public void PlayerDeathEvent(PlayerDeath pd)
- {
- // Don't continue if game isn't running
- if (!m_GameOn) return;
- if (InMapRoom(pd.getKillerID()) || InMapRoom(pd.getKilleeID()))
- {
- // Get basing freqs
- BaseFreq killerF = getBaseFreq(b.getPlayer(pd.getKillerID()).getFrequency(),b.getPlayerName(pd.getKillerID()));
- BaseFreq killedF = getBaseFreq(b.getPlayer(pd.getKilleeID()).getFrequency(),b.getPlayerName(pd.getKilleeID()));
- // Get players
- BasePlayer killer = killerF.getPlayer(b.getPlayerName(pd.getKillerID()));
- BasePlayer killed = killedF.getPlayer(b.getPlayerName(pd.getKilleeID()));
- killer.KilledPlayer();
- killed.Died();
- if (killerF.getFreq() == killedF.getFreq())
- killer.killedTeamMate();
- else if (killer.getMultis() > 1)
- updateMultiKillPlayer(killer);
- }
- }
- public void damageEvent(WatchDamage w)
- {
- if (!m_GameOn) return;
- if (InMapRoom(w.getAttacker()) || InMapRoom(w.getVictim()))
- {
- // Get basing freqs
- BaseFreq attackerF = getBaseFreq(b.getPlayer(w.getAttacker()).getFrequency(),b.getPlayerName(w.getAttacker()));
- BaseFreq victimF = getBaseFreq(b.getPlayer(w.getVictim()).getFrequency(),b.getPlayerName(w.getVictim()));
- BasePlayer a = attackerF.getPlayer(b.getPlayerName(w.getAttacker()));
- BasePlayer v = victimF.getPlayer(b.getPlayerName(w.getVictim()));
- if(a.equals(v))
- a.damagedSelf(w.getEnergyLost());
- else
- {
- a.dealtDamage(w.getEnergyLost());
- v.tookDamage(w.getEnergyLost());
- }
- }
- }
- /*-------------------------------------------------------------------------------\
- *
- * MultiKills
- *
- *-------------------------------------------------------------------------------*/
- // Time setting for multikills
- int m_MultiKillTimeLimit = 3000;//3 seconds
- // Holds all the multi kill messages
- private List<MultiMessageEvent> m_MultiKillMessages = new ArrayList<MultiMessageEvent>();
- // SoundCodes to messages sent
- private int[] m_MultiAnnouncementsSoundCodes = new int[]{ 2, 2, 2, 21 };
- // Messages to send according to kill amount
- private String[] m_MultiAnnouncements = new String[]
- {
- "[MULTIKILL] - @name@ got a DOUBLE kill.",//2 kills
- "[MULTIKILL] - @name@ with the TRIPLE KILL.",//3 kills
- "[MULTIKILL] - Quadruple ownage by @name@!",// 4 kills
- "[MULTIKILL] - Stop the madness! @name@ got @kills@ kills!"//5+ kills
- };
- // Configures the message and sends it out
- private void announceMultiKillMessage(String PlayerName, int Kills)
- {
- int index = (Kills - 2) > (m_MultiAnnouncements.length - 1) ? m_MultiAnnouncements.length - 1: Kills - 2;
- b.sendArenaMessage(
- m_MultiAnnouncements[index].replace("@name@", PlayerName).replace("@kills@", Integer.toString(Kills))
- , m_MultiAnnouncementsSoundCodes[index]);
- }
- // This goes in timer - checks for new messages and sends them
- private void updateMultiKillList()
- {
- // Ignore method if list is empty
- if (m_MultiKillMessages.isEmpty()) return;
- // Check next message
- if (m_MultiKillMessages.get(0).timeToSend())
- {
- // Send out message and delete
- announceMultiKillMessage(m_MultiKillMessages.get(0).getPlayerName(),m_MultiKillMessages.get(0).getNumberOfKills());
- m_MultiKillMessages.remove(0);
- }
- }
- // Creates/Updates multikill messages
- private void updateMultiKillPlayer(BasePlayer BPlayer)
- {
- // If player is already on list - update it
- for (MultiMessageEvent m: m_MultiKillMessages)
- {
- if (m.getPlayerName() == BPlayer.getPlayerName())
- {
- m.updateMultiPlayer(BPlayer.getMultis());
- return;
- }
- }
- // If he isn't on list create and store it in list
- m_MultiKillMessages.add( new MultiMessageEvent(BPlayer.getPlayerName(),BPlayer.getMultis()));
- }
- // Object to hold multi kill message info
- private class MultiMessageEvent
- {
- public MultiMessageEvent(String PlayerName, int Kills)
- {
- this.m_PlayerName = PlayerName;
- this.m_Kills = Kills;
- }
- private String m_PlayerName;
- public String getPlayerName(){ return m_PlayerName; }
- private long m_Timestamp = System.currentTimeMillis();
- public void updateMultiPlayer(int Kills)
- {
- this.m_Kills = Kills;
- this.m_Timestamp = System.currentTimeMillis();
- }
- private int m_Kills;
- public int getNumberOfKills() { return m_Kills;};
- // Expiration time for new update - send out message
- public boolean timeToSend(){ return (System.currentTimeMillis() - m_Timestamp > m_MultiKillTimeLimit + 1000) ? true: false; }
- }
- /*-------------------------------------------------------------------------------\
- *
- * BASE FLAG TIMER
- *
- *-------------------------------------------------------------------------------*/
- // main timer for game
- public void BaseTimer()
- {
- updateMultiKillList();
- updateTimerTasks();
- }
- // List of timed events
- private List<BZTimer> Timers = new ArrayList<BZTimer>();
- // Updates timers
- public void updateTimerTasks()
- {
- // sort through timers and update
- for (int i=Timers.size()-1; i> -1; i--)
- {
- if (!Timers.get(i).TimerExpired() )
- Timers.get(i).UpdateTimer(b, bzChat);
- else
- {
- doTimerTask(Timers.get(i).getTimerTask());
- Timers.remove(i);
- }
- }
- }
- // Timer tasks
- private void doTimerTask(int Task)
- {
- switch(Task)
- {
- case 1: doGameTimer(); break;
- case 2: doGameOver(); break;
- }
- }
- /*-------------------------------------------------------------------------------\
- *
- * MAIN FUNCTIONS
- *
- *-------------------------------------------------------------------------------*/
- public void m_StartGame()
- {
- if (m_GameOn || m_StartingGame)
- {
- bzChat.debugMessage("BaseFlagging has already been activated.");
- return;
- }
- // starting game duh
- m_StartingGame = true;
- b.sendUnfilteredPublicMessage("*objset -" + m_LvzOn + ", +" + m_LvzOff + ",");
- // ## Debug ##
- bzChat.debugMessage(" - [T20 Attack] Starting timer for Game start.");
- // Record the start to timer
- m_StartGameSet.StartTimer();
- // add to our timer list
- Timers.add(m_StartGameSet);
- }
- private void doGameTimer()
- {
- // ## Debug ##
- bzChat.debugMessage(" - [T20 Attack] GameStarted");
- // turn game on
- m_GameOn = true;
- // Open the map room doors
- bob.ChangeDoorStatus(m_DoorNumber, !m_GameOn);
- // Start Game timer
- m_GameTimerSet.StartTimer();
- m_GameStartTimeStamp = System.currentTimeMillis();
- // add to our timer list
- Timers.add(m_GameTimerSet);
- }
- private void doGameOver()
- {
- // ## Debug ##
- bzChat.debugMessage(" - [T20 Attack] GameEnded");
- // Close the map room doors
- bob.ChangeDoorStatus(m_DoorNumber, !m_GameOn);
- // Record the last time held
- BaseFreq raided = getBaseFreq(m_BaseOwner,"");
- raided.addHoldTime(System.currentTimeMillis() - m_BaseTimestamp);
- int winFreqIndex = 999;
- long wintime = 0;
- for(BaseFreq bf: FreqList)
- {
- if(bf.getTotalHoldTime() > wintime)
- {
- winFreqIndex = FreqList.indexOf(bf);
- wintime = bf.getTotalHoldTime();
- }
- }
- FreqList.get(winFreqIndex).doEndGameLoad();
- for (String s:FreqList.get(winFreqIndex).getGamePrintOut())
- b.sendArenaMessage(s);
- for(BaseFreq bf: FreqList)
- {
- //if (FreqList.indexOf(bf) != winFreqIndex)
- //{
- // bf.doEndGameLoad();
- //
- // for (String s:bf.getGamePrintOut())
- // b.sendArenaMessage(s);
- //}
- /* b.sendArenaMessage("+-----------------------------------------------------------------------------");
- b.sendArenaMessage("| Freq[ "+padL(Integer.toString(bf.getFreq()),4," ")+" : "+bf.getFreqName()+" ] Total Time[ "+getTimeMs(bf.getTotalHoldTime())+" ] ");
- b.sendArenaMessage("+-----------------------------------------------------------------------------");
- for(BasePlayer bp:bf.FreqPlayers())
- {
- b.sendPrivateMessage(bp.getPlayerName(),"Player: " + bp.getPlayerName());
- b.sendPrivateMessage(bp.getPlayerName(),"-------------+ Captured Flags : " + bp.getCapturedFlags());
- b.sendPrivateMessage(bp.getPlayerName(),"| | Kills : " + (bp.getKills() - bp.getTKs()));
- b.sendPrivateMessage(bp.getPlayerName(),"| | Deaths : " + bp.getDeaths());
- b.sendPrivateMessage(bp.getPlayerName(),"| | Damage Dealt : " + bp.getDamageDealt());
- b.sendPrivateMessage(bp.getPlayerName(),"| | Damage Received: " + bp.getDamageTaken());
- b.sendPrivateMessage(bp.getPlayerName(),"| | Self Damage wtf: " + bp.getDamageSelf());
- b.sendPrivateMessage(bp.getPlayerName(),"+------------+----------------------------------------------------------------");
- }*/
- }
- // Reset vars
- m_GameOn = false;
- m_StartingGame = false;
- m_BeenRaided = false;
- m_WhoRaided = "~nobody~";
- m_FreqRaided = 8025;
- m_RaidTime = 0;
- m_BaseOwner = 8025;
- FreqList = new ArrayList<BaseFreq>();
- // load timers
- loadTimers();
- // Toggle flag off
- b.sendUnfilteredPublicMessage("*objset -" + m_LvzOn + ", +" + m_LvzOff + ",");
- }
- // Base has been raided
- private void baseRaided(PlayerPosition p)
- {
- // Grab freq info
- BaseFreq raiders = getBaseFreq(b.getPlayer(p.getPlayerID()).getFrequency(),b.getPlayerName(p.getPlayerID()));
- BasePlayer raider = raiders.getPlayer(b.getPlayerName(p.getPlayerID()));
- raider.capturedAFlag();
- // Has base been initialy raided?
- if (!m_BeenRaided)
- {
- // Record initial raiders - getTimeMs
- m_BeenRaided = true;
- m_WhoRaided = b.getPlayerName(p.getPlayerID());
- m_FreqRaided = raiders.getFreq();
- m_RaidTime = System.currentTimeMillis() - m_GameStartTimeStamp;
- // ## DEBUG ##
- bzChat.debugMessage("Initial Base Raid: Player[ "+m_WhoRaided+" ] Freq[ "+m_FreqRaided+" ] Time[ "+getTimeMs(m_RaidTime)+" ]");
- }
- else
- {
- // Grab losers info
- BaseFreq raided = getBaseFreq(m_BaseOwner,raider.getPlayerName());
- raided.addHoldTime(System.currentTimeMillis() - m_BaseTimestamp);
- b.sendOpposingTeamMessageByFrequency(m_BaseOwner, "Flag lost. Time held [ "+getTimeMs(System.currentTimeMillis() - m_BaseTimestamp)+" ] TotalHoldTime[ "+getTimeMs(raided.getTotalHoldTime())+" ]");
- }
- // make them owners
- m_BaseOwner = raiders.getFreq();
- m_BaseTimestamp = System.currentTimeMillis();
- // Toggle gfx
- FlagToggle(raiders.getFreq());
- }
- // Toggle flag lvz for raid
- private void FlagToggle(short Freq)
- {
- // Get all Players
- Iterator<Player> i = b.getPlayingPlayerIterator();
- // Toggle lvz off for all players
- b.sendUnfilteredPublicMessage("*objset -" + m_LvzOn + ", +" + m_LvzOff + ",");
- // Get all players on same freq and toggle lvz.
- while( i.hasNext() ){
- Player p = i.next();
- if( p.getFrequency() == Freq){
- //Toggle lvz on for freq
- b.sendUnfilteredPrivateMessage( p.getPlayerID(), "*objset +" + m_LvzOn + ", -" + m_LvzOff + ",");
- }
- }
- }
- /*-------------------------------------------------------------------------------\
- *
- * Player Object Methods
- *
- *-------------------------------------------------------------------------------*/
- private class BasePlayer
- {
- public BasePlayer(String PlayerName)
- {
- this.m_PlayerName = PlayerName;
- }
- private String m_PlayerName;
- public String getPlayerName(){ return m_PlayerName; }
- private int m_CapturedFlags = 0;
- public int getCapturedFlags(){ return this.m_CapturedFlags;}
- public void capturedAFlag(){ m_CapturedFlags +=1; }
- private int m_TKs = 0;
- public int getTKs(){ return this.m_TKs;}
- public void killedTeamMate(){ this.m_TKs += 1;}
- private int m_Multi = 0;
- public int getMultis(){ return this.m_Multi;}
- private int m_BestMulti = 1;
- public int getBestMulti(){ return this.m_BestMulti;}
- private long m_KillTimestamp = System.currentTimeMillis();
- private int m_Kills = 0;
- public int getKills(){ return this.m_Kills;}
- public void KilledPlayer()
- {
- // add player kills
- this.m_Kills += 1;
- // check for multikill
- if (System.currentTimeMillis() - m_KillTimestamp < m_MultiKillTimeLimit)
- {
- m_Multi+=1;
- if (m_Multi > m_BestMulti) m_BestMulti = m_Multi;
- }
- else m_Multi = 1;
- // update kill timestamp
- m_KillTimestamp = System.currentTimeMillis();
- }
- private int m_Deaths = 0;
- public int getDeaths(){ return this.m_Deaths;}
- public void Died(){ this.m_Deaths += 1;}
- private int m_DamageSelf = 0;
- public int getDamageSelf() { return this.m_DamageSelf; }
- public void damagedSelf(int Damage) { this.m_DamageSelf += Damage;}
- private int m_DamageDealt = 0;
- public int getDamageDealt() { return this.m_DamageDealt; }
- public void dealtDamage(int Damage) { this.m_DamageDealt += Damage;}
- private int m_DamageTaken = 0;
- public int getDamageTaken() { return this.m_DamageTaken; }
- public void tookDamage(int Damage) { this.m_DamageTaken += Damage;}
- }
- /*-------------------------------------------------------------------------------\
- *
- * Freq Object Methods
- *
- *-------------------------------------------------------------------------------*/
- // Master list of active freqs
- private List<BaseFreq> FreqList = new ArrayList<BaseFreq>();
- // Get freq object by freq number
- private BaseFreq getBaseFreq(short freq, String PlayerName)
- {
- for(BaseFreq b:FreqList)
- if (b.getFreq() == freq) return b;
- BaseFreq newBF = new BaseFreq(freq,b.getPlayer(PlayerName).getSquadName());
- FreqList.add(newBF);
- return FreqList.get((FreqList.indexOf(newBF)));
- }
- // Object to store freq info
- private class BaseFreq
- {
- public BaseFreq(short freq, String FreqName)
- {
- this.b_Freq = freq;
- this.b_FreqName = FreqName;
- }
- private String b_FreqName;
- public String getFreqName() { return b_FreqName; }
- private short b_Freq;
- public short getFreq(){ return this.b_Freq;}
- private List<BasePlayer> b_FreqPlayers = new ArrayList<BasePlayer>();
- public List<BasePlayer> FreqPlayers()
- { return b_FreqPlayers; }
- /*----------------------------------------------\
- * STAT VARIABLES
- *---------------------------------------------*/
- // ----------------------------------- FREQ Stats
- private long b_LongestHoldTime = 0;
- public long getLongestHoldTime()
- { return b_LongestHoldTime; }
- private long b_TotalHoldTime = 0;
- public long getTotalHoldTime()
- { return b_TotalHoldTime; }
- private int b_TotalKills = 0;
- private int b_TotalDeaths = 0;
- private int b_TotalTKs = 0;
- private int b_TotalDamage = 0;
- private int b_TotalDamageTaken = 0;
- private int b_TotalSelfDamage = 0;
- private int b_TotalRaids = 0;
- // ----------------------------- PLAYER STATS
- private String b_BestKiller = "~none~";
- private int b_BestKillerCount = 0;
- private String b_Suicider = "~none~";
- private int b_SuiciderCount = 0;
- private String b_Cannibal = "~none~";
- private int b_CannibalCount = 0;
- private String b_BestPainDealer = "~none~";
- private int b_BestPainDealerDamage = 0;
- private String b_PunchingBag = "~none~";
- private int b_PunchingBagDamage = 0;
- private String b_Masochist = "~none~";
- private int b_MasochistDamage = 0;
- private String b_BestRaider = "~none~";
- private int b_BestRaidCount = 0;
- private String b_AtomicKiller = "~none~";// best mob destroyer
- private int b_AtomicKillerCount = 0;
- // most toys used???
- // biggest lagger
- // most weapon fire
- // least weapons used
- //
- /*----------------------------------------------\
- * TASKS
- *---------------------------------------------*/
- // Load the stats to vars and load printout
- public void doEndGameLoad()
- {
- for (BasePlayer b: b_FreqPlayers)
- {
- // Load raid stats
- this.b_TotalRaids += b.getCapturedFlags();
- if (b.getCapturedFlags() > b_BestRaidCount)
- {
- this.b_BestRaider = b.getPlayerName();
- this.b_BestRaidCount = b.getCapturedFlags();
- }
- // Best multi killer
- if (b.getBestMulti() > b_AtomicKillerCount)
- {
- this.b_AtomicKillerCount = b.getBestMulti();
- this.b_AtomicKiller = b.getPlayerName();
- }
- // Load kill stats
- this.b_TotalKills += b.getKills();
- if (b.getKills() > b_BestKillerCount)
- {
- this.b_BestKillerCount = b.getKills();
- this.b_BestKiller = b.getPlayerName();
- }
- this.b_TotalDeaths += b.getDeaths();
- if (b.getDeaths() > b_SuiciderCount)
- {
- this.b_SuiciderCount = b.getDeaths();
- this.b_Suicider = b.getPlayerName();
- }
- this.b_TotalTKs += b.getTKs();
- if (b.getTKs() > b_CannibalCount)
- {
- this.b_CannibalCount = b.getTKs();
- this.b_Cannibal = b.getPlayerName();
- }
- // Load most damage
- this.b_TotalDamage += b.getDamageDealt();
- if (b.getDamageDealt() > b_BestPainDealerDamage)
- {
- this.b_BestPainDealerDamage = b.getDamageDealt();
- this.b_BestPainDealer = b.getPlayerName();
- }
- this.b_TotalDamageTaken += b.getDamageTaken();
- if (b.getDamageTaken() > b_PunchingBagDamage)
- {
- this.b_PunchingBagDamage = b.getDamageTaken();
- this.b_PunchingBag = b.getPlayerName();
- }
- this.b_TotalSelfDamage += b.getDamageSelf();
- if (b.getDamageSelf() > b_MasochistDamage)
- {
- this.b_MasochistDamage = b.getDamageSelf();
- this.b_Masochist = b.getPlayerName();
- }
- loadGamePrintOut();
- }
- }
- private String[] m_GamePrintOut = new String[7];
- public String[] getGamePrintOut() {return m_GamePrintOut;}
- private void loadGamePrintOut()
- {
- m_GamePrintOut[0] = "+-----------------------------------------------------------------------------";
- m_GamePrintOut[1] = "| Freq[ "+padL(Integer.toString(this.b_Freq),4,"0")+" :"+padR(this.b_FreqName,10," ")+" ] Total Time[ "+getTimeMs(b_TotalHoldTime)+" ] ";
- m_GamePrintOut[2] = "+---------------+--------------+------------+---------------------------------";
- m_GamePrintOut[3] = "| Name | Category | Amount | Award ";
- m_GamePrintOut[4] = "+---------------+--------------+------------+---------------------------------";
- m_GamePrintOut[5] = "| " +padR(b_BestKiller,14," ")+ "| Most Kills | " + padR(Integer.toString(b_BestKillerCount),11," ") + "| Freq AssASSin ";
- m_GamePrintOut[6] = "+---------------+--------------+------------+---------------------------------";
- }
- // Grab player for freq list
- // If not on list add player
- public BasePlayer getPlayer(String PlayerName)
- {
- // Find player on list
- for (BasePlayer b: b_FreqPlayers)
- if (b.getPlayerName() == PlayerName) return b;
- // Make new player if not found
- BasePlayer b = new BasePlayer(PlayerName);
- b_FreqPlayers.add(b);
- return b_FreqPlayers.get(b_FreqPlayers.indexOf(b));
- }
- // Increment hold time and check to see if its longest
- public void addHoldTime(long time)
- {
- b_TotalHoldTime+= time;
- if (time > b_LongestHoldTime ) b_LongestHoldTime = time;
- }
- }
- /*-------------------------------------------------------------------------------\
- *
- * MISC FUNCTIONS
- *
- *-------------------------------------------------------------------------------*/
- public void InitializeBaseFlagging()
- {
- // Hide flag on start of module
- b.sendUnfilteredPublicMessage("*objset -1427,-1428,");
- loadTimers();
- }
- public void loadTimers()
- {
- // Store all settings for Timer to start game
- m_StartGameSet = new BZTimer(1,35);
- m_StartGameSet.setInitialMessage("T20 BaseAttack starting in @time@ ! Hop in to join the fun.", 4);
- m_StartGameSet.setEndMessage("GO GO GO - Defend T20!", 104);
- m_StartGameSet.setNotification(60, "[@time@] until T20 Base Attack starts! Head over to O17 now!!", 0);
- m_StartGameSet.setNotification(30, "[@time@] until T20 Base Attack starts! Head over to O17 now!!", 0);
- m_StartGameSet.setNotification(5, "- 5 -", 26);
- m_StartGameSet.setNotification(4, "- 4 -", 26);
- m_StartGameSet.setNotification(3, "- 3 -", 26);
- m_StartGameSet.setNotification(2, "- 2 -", 26);
- m_StartGameSet.setNotification(1, "- 1 -", 26);
- // Settings for Game Timer
- m_GameTimerSet = new BZTimer(2,360);
- m_GameTimerSet.setInitialMessage("T20 BaseAttack - All your flag are belong to us... Defend the O-17 Flag! [Game Time = @time@] ", 0);
- m_GameTimerSet.setNoEndMessage();
- //m_GameTimerSet.setEndMessage(" ----- Score Printout here -----.", 104);
- m_GameTimerSet.setNotification(180, "T20 Attack - @time@ remaining!", 0);
- m_GameTimerSet.setNotification(60, "T20 Attack - @time@ remaining!", 0);
- m_GameTimerSet.setNotification(30, "T20 Attack - @time@ remaining!", 0);
- m_GameTimerSet.setNotification(5, "- 5 -", 26);
- m_GameTimerSet.setNotification(4, "- 4 -", 26);
- m_GameTimerSet.setNotification(3, "- 3 -", 26);
- m_GameTimerSet.setNotification(2, "- 2 -", 26);
- m_GameTimerSet.setNotification(1, "- 1 -", 26);
- }
- // Simple collision check - seeing if player is in a given region
- private boolean InRegion( PlayerPosition p, short[] Region)
- { return InRegion(p.getXLocation(),p.getYLocation(),Region); }
- private boolean InMapRoom(int PlayerID)
- {
- return InRegion(b.getPlayer(PlayerID).getXLocation(),b.getPlayer(PlayerID).getYLocation(),m_MapRoom1)
- || InRegion(b.getPlayer(PlayerID).getXLocation(),b.getPlayer(PlayerID).getYLocation(),m_MapRoom2);
- }
- // Simple collision check - seeing if player is in a given region
- private boolean InRegion( short x, short y, short[] Region)
- {
- return (x > Region[0] && x < Region[2] &&
- y > Region[1] && y < Region[3]) ? true:false;
- }
- private String padR(String Str, int Amount, String Char)
- {
- if (Str.length() < Amount)
- {
- String NewStr = Str;
- int maxIndex = Amount - Str.length();
- for (int i = 0; i < maxIndex;i++)
- {
- NewStr += Char;
- }
- return NewStr;
- }
- return Str;
- }
- private String padL(String Str, int Amount, String Char)
- {
- if (Str.length() < Amount)
- {
- String NewStr = Str;
- int maxIndex = Amount - Str.length();
- for (int i = 0; i < maxIndex;i++)
- {
- NewStr = Char + NewStr;
- }
- return NewStr;
- }
- return Str;
- }
- // Format time to print
- public String getTimeMs(long elapsedTime) {
- String format = String.format("%%0%dd", 2);
- elapsedTime = elapsedTime / 1000;
- String seconds = String.format(format, elapsedTime % 60);
- String minutes = String.format(format, (elapsedTime % 3600) / 60);
- String hours = String.format(format, elapsedTime / 3600);
- long milli = elapsedTime - ((elapsedTime % 60) + ((elapsedTime % 3600) / 60) + (elapsedTime / 3600));
- String time = hours + "h:" + minutes + "m:" + seconds +"s:" + milli + "ms";
- return time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement