SHOW:
|
|
- or go back to the newest paste.
| 1 | package twcore.bots.battlebot.PublicOps; | |
| 2 | - | private long TS_FlagTimer = System.currentTimeMillis(); |
| 2 | + | |
| 3 | - | private int Delay_FlagTimer = 90;//seconds |
| 3 | + | import java.util.Iterator; |
| 4 | - | private boolean[] m_FlagTimerNotificationsChecks = new boolean[]{ false, false, false, false, false, false };
|
| 4 | + | |
| 5 | - | private int[] m_FlagTimerNotificationsTimes = new int[]{ 30, 5, 4, 3, 2, 1 };
|
| 5 | + | import twcore.bots.battlebot.ChatBuffer; |
| 6 | - | private String[] m_FlagTimerNotifications = new String[]{"30 Seconds!"," - 5 - "," - 4 - "," - 3 - "," - 2 - "," - 1 - "};
|
| 6 | + | import twcore.bots.battlebot.DoorMan; |
| 7 | - | private int[] m_FlagTimerSoundCodes = new int[]{ 0, 26, 26, 26, 26, 26};
|
| 7 | + | import twcore.core.BotAction; |
| 8 | import twcore.core.events.Message; | |
| 9 | - | private String m_InitialAnnounce = "T20 BaseAttack starting in 1m 30s ! Hop in to join the fun."; |
| 9 | + | import twcore.core.events.PlayerPosition; |
| 10 | - | private int m_InitialAnnounceSoundCode = 4; |
| 10 | + | import twcore.core.game.Player; |
| 11 | - | private String m_TimerEndAnnounce = "GO GO GO - Defend T20!."; |
| 11 | + | |
| 12 | - | private int m_TimerEndSoundCode = 104; |
| 12 | + | /*----------------------------------------------------------------------------------\ |
| 13 | * BZ Public Flag Ops Class: | |
| 14 | * This will keep track of any flag event for public. | |
| 15 | * For now there will be 2 types of flag games | |
| 16 | * | |
| 17 | * STQ Flag game: | |
| 18 | * One flag will be available to carry. We will give a player a multiplier(or increase) for points | |
| 19 | * if flag is carried. This will make the flag an item that is sought after. | |
| 20 | * | |
| 21 | * BaseFlag: | |
| 22 | * I will have one flag base on the lower map. The entire game will be bot controlled. | |
| 23 | * Flag is a monitored hotspot for the bot and will use 2 lvz: de/activated | |
| 24 | *----------------------------------------------------------------------------------*/ | |
| 25 | public class PublicFlagOps {
| |
| 26 | BotAction b; | |
| 27 | ChatBuffer bzChat; | |
| 28 | DoorMan bob; | |
| 29 | public PublicFlagOps(BotAction b, ChatBuffer c, DoorMan d) | |
| 30 | {
| |
| 31 | this.b = b; | |
| 32 | this.bzChat = c; | |
| 33 | this.bob = d; | |
| 34 | } | |
| 35 | ||
| 36 | /*-------------------------------------------------------------------------------\ | |
| 37 | * SHARED METHODS | |
| 38 | *-------------------------------------------------------------------------------*/ | |
| 39 | // ----------------------------------- Chat commands | |
| 40 | public void chatCommands( Message m) | |
| 41 | - | m_BGameOn = true; |
| 41 | + | |
| 42 | // Toggle single flag mode | |
| 43 | - | } |
| 43 | + | if (m.getMessage().startsWith("!flag_stq"))
|
| 44 | {
| |
| 45 | toggleSTQ(); | |
| 46 | return; | |
| 47 | } | |
| 48 | // Toggle base flag mode | |
| 49 | if (m.getMessage().startsWith("!flag_base"))
| |
| 50 | {
| |
| 51 | toggleBase(); | |
| 52 | return; | |
| 53 | } | |
| 54 | } | |
| 55 | // Simple collision check - seeing if player is in a given region | |
| 56 | private boolean InRegion( PlayerPosition p, short[] Region) | |
| 57 | {
| |
| 58 | return (p.getXLocation() > Region[0] && | |
| 59 | p.getXLocation() < Region[2] && | |
| 60 | p.getYLocation() > Region[1] && | |
| 61 | p.getYLocation() < Region[3]) ? true:false; | |
| 62 | } | |
| 63 | public void flagTimer() | |
| 64 | {
| |
| 65 | baseGameFlagTimer(); | |
| 66 | updateBaseGame(); | |
| 67 | } | |
| 68 | /*-------------------------------------------------------------------------------\ | |
| 69 | * STQ | |
| 70 | *-------------------------------------------------------------------------------*/ | |
| 71 | // if game is on | |
| 72 | private boolean m_STQ_On = false; | |
| 73 | // Current Flag Owner | |
| 74 | private String m_FlagOwner = ""; | |
| 75 | ||
| 76 | public boolean STQ_On() { return m_STQ_On; }
| |
| 77 | ||
| 78 | // Toggles single flag mode on and off | |
| 79 | // Configures arena for 1 or 0 flags, then resets | |
| 80 | private void toggleSTQ() | |
| 81 | {
| |
| 82 | m_STQ_On = !m_STQ_On; | |
| 83 | bzChat.sendChatMsg(1, "Single Flag Mode is now set to : [ " + m_STQ_On + " ]"); | |
| 84 | ||
| 85 | int setting = m_STQ_On ? 1:0; | |
| 86 | ||
| 87 | bzChat.sendChatMsg(0, "?set Flag:MaxFlags=" + setting); | |
| 88 | bzChat.sendChatMsg(0, "*flagreset"); | |
| 89 | } | |
| 90 | ||
| 91 | /*-------------------------------------------------------------------------------\ | |
| 92 | * BASE | |
| 93 | *-------------------------------------------------------------------------------*/ | |
| 94 | // if game is on | |
| 95 | private boolean m_Base_On = false; | |
| 96 | public boolean Base_On() { return m_Base_On; }
| |
| 97 | // Freq that owns Base | |
| 98 | private int m_Base_Freq = 8025; | |
| 99 | ||
| 100 | // Lvz for flag on/off | |
| 101 | private int m_Base_LVZ_Off = 1427; | |
| 102 | private int m_Base_LVZ_On = 1428; | |
| 103 | ||
| 104 | // Door used to close off flag room | |
| 105 | private byte m_baseDoor = 5; | |
| 106 | ||
| 107 | // Base Game Settings | |
| 108 | private boolean m_BGameOn = false; | |
| 109 | private long Delay_BGameOn = 180; //seconds | |
| 110 | ||
| 111 | public void updateBaseGame() | |
| 112 | {
| |
| 113 | if (!m_BGameOn) return; | |
| 114 | } | |
| 115 | ||
| 116 | ||
| 117 | private boolean m_FlagTimerON = false; | |
| 118 | private long TS_FlagTimer; | |
| 119 | private int Delay_FlagTimer;//seconds | |
| 120 | private boolean[] m_FlagTimerNotificationsChecks; | |
| 121 | private int[] m_FlagTimerNotificationsTimes; | |
| 122 | private String[] m_FlagTimerNotifications; | |
| 123 | private int[] m_FlagTimerSoundCodes; | |
| 124 | private boolean m_InitialAnnounceSent = false; | |
| 125 | private String m_InitialAnnounce; | |
| 126 | private int m_InitialAnnounceSoundCode; | |
| 127 | private String m_TimerEndAnnounce; | |
| 128 | private int m_TimerEndSoundCode; | |
| 129 | private int m_TimerTask; | |
| 130 | private void baseGameFlagTimer() | |
| 131 | {
| |
| 132 | if (!m_FlagTimerON) return; | |
| 133 | if (!m_InitialAnnounceSent) | |
| 134 | {
| |
| 135 | m_InitialAnnounceSent = true; | |
| 136 | b.sendArenaMessage(m_InitialAnnounce,m_InitialAnnounceSoundCode); | |
| 137 | return; | |
| 138 | } | |
| 139 | ||
| 140 | long elapsed = System.currentTimeMillis() - TS_FlagTimer; | |
| 141 | ||
| 142 | for (int i = 0; i < m_FlagTimerNotificationsChecks.length; i+=1) | |
| 143 | {
| |
| 144 | if (!m_FlagTimerNotificationsChecks[i] && (Delay_FlagTimer * 1000) - elapsed <= (m_FlagTimerNotificationsTimes[i]*1000)) | |
| 145 | {
| |
| 146 | int secs = m_FlagTimerNotificationsTimes[i]; | |
| 147 | m_FlagTimerNotificationsChecks[i] = true; | |
| 148 | b.sendArenaMessage(m_FlagTimerNotifications[i],m_FlagTimerSoundCodes[i]); | |
| 149 | } | |
| 150 | } | |
| 151 | ||
| 152 | if (elapsed > (Delay_FlagTimer *1000)) | |
| 153 | {
| |
| 154 | m_FlagTimerON = false; | |
| 155 | TS_FlagTimer = System.currentTimeMillis(); | |
| 156 | m_InitialAnnounceSent = false; | |
| 157 | b.sendArenaMessage(m_TimerEndAnnounce,m_TimerEndSoundCode); | |
| 158 | ||
| 159 | switch(m_TimerTask) | |
| 160 | {
| |
| 161 | case 0: | |
| 162 | m_BGameOn = true; | |
| 163 | BaseGameTimer(); | |
| 164 | break; | |
| 165 | } | |
| 166 | ||
| 167 | } | |
| 168 | } | |
| 169 | ||
| 170 | public void BaseStartTimer() | |
| 171 | {
| |
| 172 | TS_FlagTimer = System.currentTimeMillis(); | |
| 173 | Delay_FlagTimer = 35;//seconds | |
| 174 | m_FlagTimerNotificationsChecks = new boolean[]{ false, false, false, false, false, false };
| |
| 175 | m_FlagTimerNotificationsTimes = new int[]{ 30, 5, 4, 3, 2, 1 };
| |
| 176 | m_FlagTimerNotifications = new String[]{"30 Seconds for T20 Base Attack, head over to p17 now!!"," - 5 - "," - 4 - "," - 3 - "," - 2 - "," - 1 - "};
| |
| 177 | m_FlagTimerSoundCodes = new int[]{ 0, 26, 26, 26, 26, 26};
| |
| 178 | m_InitialAnnounce = "T20 BaseAttack starting in 0m 35s ! Hop in to join the fun."; | |
| 179 | m_InitialAnnounceSoundCode = 4; | |
| 180 | m_TimerEndAnnounce = "GO GO GO - Defend T20!."; | |
| 181 | m_TimerEndSoundCode = 104; | |
| 182 | m_TimerTask = 0; | |
| 183 | m_FlagTimerON = true; | |
| 184 | } | |
| 185 | ||
| 186 | public void BaseGameTimer() | |
| 187 | {
| |
| 188 | TS_FlagTimer = System.currentTimeMillis(); | |
| 189 | Delay_FlagTimer = 60;//seconds | |
| 190 | m_FlagTimerNotificationsChecks = new boolean[]{ false, false, false, false, false, false };
| |
| 191 | m_FlagTimerNotificationsTimes = new int[]{ 30, 5, 4, 3, 2, 1 };
| |
| 192 | m_FlagTimerNotifications = new String[]{"30 Seconds left hurraaa!"," - 5 - "," - 4 - "," - 3 - "," - 2 - "," - 1 - "};
| |
| 193 | m_FlagTimerSoundCodes = new int[]{ 0, 26, 26, 26, 26, 26};
| |
| 194 | m_InitialAnnounce = "[1 minute Game] T20 BaseAttack - capture the p17 flag and defend all your base.."; | |
| 195 | m_InitialAnnounceSoundCode = 0; | |
| 196 | m_TimerEndAnnounce = " ----- Score Printout here -----."; | |
| 197 | m_TimerEndSoundCode = 104; | |
| 198 | m_TimerTask = 1; | |
| 199 | m_FlagTimerON = true; | |
| 200 | } | |
| 201 | ||
| 202 | public void playerPositionHandled(PlayerPosition p) | |
| 203 | {
| |
| 204 | // No need to track players unless game has started | |
| 205 | if (!m_BGameOn) return; | |
| 206 | ||
| 207 | // Flag Room Coords | |
| 208 | if (!InRegion(p,new short[]{ 225 * 16, 778 * 16, 784 * 16, 845 * 16})) return;
| |
| 209 | ||
| 210 | if (InRegion(p, new short[] { 12336, 13328, 12496, 13488 }))
| |
| 211 | {
| |
| 212 | short freq = b.getPlayer(p.getPlayerID()).getFrequency(); | |
| 213 | ||
| 214 | if (freq != m_Base_Freq) | |
| 215 | {
| |
| 216 | m_Base_Freq = freq; | |
| 217 | bzChat.debugMessage("Freq [ "+freq+" ] Has just taken the flag.");
| |
| 218 | flagTakenToggle(freq); | |
| 219 | return; | |
| 220 | } | |
| 221 | } | |
| 222 | } | |
| 223 | ||
| 224 | private void flagTakenToggle(short Freq) | |
| 225 | {
| |
| 226 | // Toggle lvz off for all players | |
| 227 | b.sendUnfilteredPublicMessage("*objset -" + m_Base_LVZ_On + ", +" + m_Base_LVZ_Off + ",");
| |
| 228 | Iterator<Player> i = b.getPlayingPlayerIterator(); | |
| 229 | while( i.hasNext() ){
| |
| 230 | Player p = i.next(); | |
| 231 | if( p.getFrequency() == Freq){
| |
| 232 | // Toggle lvz on for freq | |
| 233 | b.sendUnfilteredPrivateMessage( p.getPlayerID(), "*objset +" + m_Base_LVZ_On + ", -" + m_Base_LVZ_Off + ","); | |
| 234 | } | |
| 235 | } | |
| 236 | } | |
| 237 | private void toggleBase() | |
| 238 | {
| |
| 239 | m_Base_On = !m_Base_On; | |
| 240 | m_Base_Freq = 8025; | |
| 241 | bzChat.sendChatMsg(1, "Base Flag Mode is now set to : [ " + m_Base_On + " ]"); | |
| 242 | bob.ChangeDoorStatus(m_baseDoor, !m_Base_On); | |
| 243 | String i = m_Base_On ? "+":"-"; | |
| 244 | b.sendUnfilteredPublicMessage("*objset "+i+"1427,-1428,");
| |
| 245 | if (m_Base_On) | |
| 246 | {
| |
| 247 | //m_FlagTimerON = true; | |
| 248 | BaseStartTimer(); | |
| 249 | } | |
| 250 | } | |
| 251 | } |