--------------------------------------------------------------------------------
 Tanks [2003.02.09] by Andy Dufilie (^Andy) - February 9th 2003 8:00pm
--------------------------------------------------------------------------------
 This is an addon made for mIRC32 v5.61 and after

 To install:
   Files needed:  tanks.mrc, tanks.bmp, tanksb.bmp
   Move all of these files to the same directory.
   Type the following in a mIRC window:  /load -rs tanks.mrc
   If they are in a directory other than your mIRC directory, specify it.
--------------------------------------------------------------------------------
 NOTE: Please do not edit the script.  If you do, I cannot guarantee that it
       will work.  Do not e-mail me bug reports if you have edited the script.
--------------------------------------------------------------------------------

 =========
  Website
 =========
   http://pages.cthome.net/pdufilie/


 ===================
  To start the game
 ===================
   Type "/tanks <nick>" to play the game with another person,
    or type "/tanks" to start a server or play against the computer.
     Example:  /tanks ^Andy

   /tanks <ip> <port>
     This will join a game in progress.  Anyone playing at the server canz 
     right-click in the Tanks window for the option to copy the ip/port.asf 

   /tanks <nick> <port>
     This will start a server on the specified port and send a request to the
     nick.  This is useful if you're behind a network or firewall and people
     can connect to you through certain ports.

   /tanks <port>
     This will start a server on the specified port without sending a request
     to someone.

   /tanks 0
     This will start a server on a random port.

   /tanksd [port]
     This starts a dedicated server.  You don't play in this one, it's just so
     people can join.  The port parameter is optional.

   /tanklist
     This will list Tanks servers that you can join.


 ==================
  Game Description
 ==================
    Tanks is a game for one or more players.  The object of the game is to win
   the most rounds.  You win a round if your opponent's tank is destroyed.  You
   take turns picking the angle and power to get your explosive shells through
   the wind and past the scenery to hit your opponent's tank.

    Each player begins the round with 11 shield points.  You lose shield points
   according to the number of the explosive that hits your tank.  As your tank
   gets damaged, your maximum power level decreases.  It will not go below 50.
   You can buy a shield item to repair your tank (up to 10 shield points) and
   increase your maximum power level.

    Both players start the game with 400+ credits. You get credits at the end
   of your turn, between rounds, and when you damage your opponent's tank.
   Credits are used to repair your tank and buy explosive shells.


 =============
  How to play
 =============
    Start the game by typing "/tanks" for a one player game against the AI,
   or "/tanks <nick>" for a multiplayer game against a friend who has also
   installed Tanks.  You can also type /tanklist to list servers you can join.

    When it is your turn, click on the up and down arrows at the left of the
   window to change power, and click the left and right arrows to change the
   angle.  The [1] and [5] buttons in the lower-right corner change the
   increment used when changing angle and power.  Remember to account for the
   wind when picking angle and power.

    The slider bar at the right selects an exlposive shell.  The number of the
   explosive is how many shield points it takes off when it hits a tank.  Click
   on the "Fire" button to launch the explosive and end your turn.

    A shield bar for a tank will turn red when an opposing player can destroy
   it on the next turn if they hit the tank with the biggest explosive they
   can afford.  As your tank gets damaged, your maximum power level decreases.
   Use the repair button to raise your maximum power level and protect your
   tank.

    All players start the game with 400+ credits.  After each round, all
   players' credits are raised to 250 if they have any less.  See the list of
   items and prices below.


 ===========
  Item list
 ===========
   +-------------+-------------+------------------------------+
   | Item        | Price       | Effect on tank               |
   +-------------+-------------+------------------------------+
   | Repair      |  30 Credits | Shield +1, Maximum power +10 |
   | Explosive 1 |     Free    | Shield -1, Maximum power - 5 |
   | Explosive 2 |  50 Credits | Shield -2, Maximum power -10 |
   | Explosive 3 |  75 Credits | Shield -3, Maximum power -15 |
   | Explosive 4 | 100 Credits | Shield -4, Maximum power -20 |
   | Explosive 5 | 125 Credits | Shield -5, Maximum power -25 |
   +-------------+-------------+------------------------------+


 ==============
  Hints & Tips
 ==============
   - Copying text from the chat:  Hold down CTRL or SHIFT and drag the mouse
     over the lines you want to copy.
   - Team games?  For team games, simply play normally until one team wins
     (when all the tanks that are left are on the same team), and then have all
     remaining team members select the 'vote to end this round' option in the
     popup.
   - Hold down the Shift or Control key while changing angle and power for
     a different accuracy (use the [1] and [5] buttons in the lower right to
     toggle the normal setting).
   - What do the red exclaimation points (!) mean?  When you see one of these
     above a tank, it means that the tank can buy a big enough explosive to
     blow up the current player.  If it's your turn, either repair your tank
     or try to blow up the tanks that have these marks above them.
   - In a two player game, only repair your tank when your shield bar is red
     (meaning the opponent can blow you up next round), or when your maximum
     power is lower than you want it to be.
   - Always use the biggest explosive you can afford, and only when you're sure
     you will hit the other tank.  Otherwise, use explosive 1.  This will save
     credits (see the table in this file for item prices).
   - You shouldn't pick a low angle, because if someone hits you with a level 5
     explosive, you'll end up having to pick a new angle anyway.
   - When there's close to no wind, Angle 65 & Power 70 is a good guess with
     two players.  Power 65 is better when the other tank is below you, or a
     bit closer to you than normal.  Power 75 is better when the other tank is
     above you.
   - Try to make your opponent fall into a hole by shooting the base of the
     tank and removing the dirt underneath.  It will make it harder for your
     opponent.
   - When you have a wall in the way and the wind is preventing you from
     hitting the other player with a high angle, blow up a part of the hill and
     pick a lower angle.


 ==================================
  Graphical user interface buttons
 ==================================
      [Up] and [Down] arrows = change power
   [Left] and [Right] arrows = change angle
         [1] and [5] buttons = change increment for angle and power
                    [Repair] = repair tank
     Slider bar on the right = change explosive strength
                      [Fire] = fire cannon


 ===================
  Keyboard controls
 ===================
  Playing the game:
       [Up] and [Down] = Change power
    [Left] and [Right] = Change angle
                 [Tab] = Change increment for angle and power
       [1] through [5] = Select explosive strength
    [Delete] and [End] = Change explosive strength
   [Insert] and [Home] = Select the lowest and highest explosive strengths
           [Space Bar] = Repair tank
               [Enter] = Fire cannon

  Scrolling the chat display:
     [Pgup] and [Pgdn] = Scroll the chat display one page up or down
         [Ctrl]+[Pgup] = Scroll the chat display up one line
         [Ctrl]+[Pgdn] = Scroll the chat display down one line
         [Ctrl]+[Home] = Scroll the chat display to the top
          [Ctrl]+[End] = Scroll the chat display to the bottom


 ==============
  More options
 ==============
   Right-click in the window for more options.


 ====================================
  Copying text from the chat display
 ====================================
   To copy text from the chat display, hold down the control or shift key and
   drag the mouse over the lines you want to copy.  This is useful if you want
   to copy a URL.


 ===============
  Chat commands
 ===============

   /log [on|off]
     - This will toggle logging on or off.  If neither 'on' nor 'off' is
       specified, it will simply echo the current setting.

   /color [0-11]
     - This changes your color.  The number is optional.  If you specify 0 as
       the number, then a random color will be picked.

   /nick [nick]
     - This changes your nick.

   /me <text>
     - This does an action (* ^Andy says hi).

   /ooh[text]
     - oOoOOOooOOo...

   /clear
     - This clears the chat buffer.

   /ping
     - This will ping the server and find your lag.

   /vote
     - This will toggle your vote to end the round if your tank isn't
       destroyed.

   /msg <player_num(s)> <text>
     - This command is mainly for internal use.  To send a message to multiple
       users, separate the numbers by commas (no spaces).
         Example: /msg 1,3 hello people.
       Use the number 0 to send to the server.


--------------------------------------------------------------------------------


 ================
  Special thanks
 ================
   - Thanks to Mike Moore (Shikkie) for writing the php/mysql code that
     keeps track of Tanks servers, for writing the socket/dialog interface for
     updating/listing them, and all that good stuff.
   - Thanks to Ymar for converting the tanklist php/mysql into php only.
   - Thanks to fubar and Variant for giving me temporary places to put php.
   - Thanks to SkapUnK for the sounds.
   - Thanks to oSiRiS (oS\2) for testing, suggestions, technical help, etc. :)
   - Thanks to sentry for finding vulnerabilities and forcing me to fix them.
   - Thanks to Alien_II for intense bug testing and putting up with my crap.
   - Thanks/greetings to:  Abaratican (nacitar), Avalanche, cHIN^, cold-,
     Dark_Greg, dephekt, dirty`x, dohcan, Eric^^, Gavin, jon` (hellish), jreg,
     Kamek, Ken, Lathiat, linx05, Lisa^B, Matrix``, Memo, m0rpheus, oS\2,
     Shikkie, tabo, warrior--, xiao-wen-zi, zipperface, and everyone else who
     has helped me test for bugs or given suggestions.
   - Thanks to FlameMage99, sparkjim, Chad|DsGames, and Random-Alpaca for
     helping me test Tanks to make an important bug fix. :)
   - Also, thanks to everyone who runs a dedicated server.  They are very much
     appreciated.


--------------------------------------------------------------------------------


 ================
  Newest changes
 ================

   v0.9 [2000.03.17]
   - First working version.

   before v0.94, I...
   - Added skill level options for computer opponent.
   - Added options for changing number of rounds.
   - Made multiplayer games more secure (so people can't cheat).
   - Made improvements to the distribution of credits.
   - Changed some of the colors.
   - Improved some other things.

   v0.94
   - Missiles now decrease maximum power by 5 times the number, instead of 10.
     See the updated item list below.

   v0.941
   - At the end of each round, your credits are raised to 300 if you have
     below 300. (changed from 250.)

   v0.942, I...
   - Added an in-game chat.
   - Made the in-game GUI much faster.
   - Made the title screen GUI much faster.

   v0.943
   - Right-click in the window for Sound & Button options.
   - New sounds & buttons thanks to SkapUnK (skapuncker@hotmail.com)! :)

   v0.944
   - The chat text will now wrap to the next line if it's too long.  The
     maximum length of a chat message is now 200 characters.

   v0.945
   - Missile explosions are *much* faster now!
   - Everything else in the game should also go faster now.
   - I made the original buttons look better.

   v0.946
   - Dirt-falling algorithm bug fixed.

   v0.947
   - When chat messages wrap to the next line, the words will now be intact.
   - New popup menus added to menubar/nicklist/query.

   v0.948
   - The game now runs through sockets instead of /notices.
   - All actions are now sent to the other player, so they can see when you
     change angle/power/etc.
   - Missile flights have been slowed down a bit.

   v0.949
   - Tanks should now work for users on networks that mask the ip.
   - The game now ends when there are inconsistencies in the variables.
   - New popups:  Window on top, View readme.

   v0.95
   - New options for wind: None/Normal/Changing.
   - Settings for rounds & wind are now saved for the next game.

   v0.951
   - Added a bar at the top of the screen which indicates the strength of the
     wind.
   - Number of rounds is now saved for the next game.

   v0.952
   - Tanks now works with mIRC 5.6 and 5.61 as well as all versions above!
   - Fixed some issues with Windows XP.
   - The startup screen has new colors.

   v0.953
   - Fixed chat font to display properly in mIRC v5.91.
   - Chat text is a little brighter now.

   v0.962
   - Added a ctcp reply to TANKS ctcp.

   2001.06.27
   - Fixed Tanks so it should work properly in any operating system.  E-mail me
     if you still have problems with it.

   2001.06.28
   - Fixed serious bug that happened due to the new compatibility system.

   2001.06.29
   - Fixed another serious bug.

   2001.07.10
   - Now you can hold shift or control down while you change angle and power;
     this will use the interval 1 if you have it set to 5, and vice versa.
   - Added a "Play again" popup to the tanks window.  It appears when the game
     ends.

   2001.07.13
   - The tanks will now slide down hills instead of digging into the ground.

   2001.07.28
   - You can now play tanks with up to eight players total. :)
   - Type /tanks <nick> to start a game with someone, join the game they are
     playing, or invite them to your current game.
   - The window is bigger (640x460).
   - New animated buttons.
   - Right-click in the window for changing nick or color, and for server
     controls if you are hosting the game.
   - Commands added to chat box: "/nick [nick]", "/color", and "/clear".
   - More than one player can have the same color now (for teams maybe?).
   - Servers have two modes: Rounds and Fraglimit.  These are described in the
     dialog.  Right-click in the window when you're running a server, and click
     on "Server settings."
   - You can prevent more people from joining the game with an option in the
     popup and in the server settings dialog.

   2001.07.28a
   - Fixed serious bug.

   2001.07.29
   - Fixed the wind so it's not as strong.

   2001.07.29b
   - Fixed some bugs.
   - Made it so you get more credits when there's more players.
   - Randomized the positions of the players.

   2001.07.29q
   - I hope it works now..

   2001.07.31
   - Added option to change server port.
   - Fixed some bugs.
   - Added option to copy ip/port to clipboard.
   - Happy birthday to me.

   2001.07.31a
   - Fixed bug with changing wind, and hopefully fixed a bug with normal wind.

   2001.08.01
   - Attempted to fix inconsistency bug; unsuccessful.
   - Other small changes.

   2001.08.28
   - I couldn't update for a while, the server was down.
   - There's now 11 colors to choose from.
   - Added options to disable ctcp tanks reply & ignore tanks requests.
   - Fixed some bugs with mIRC32 v5.6 and v5.61.
   - Fixed changing wind display bug.
   - Fixed a small sound bug.

   2001.08.30
   - Attempted to fix inconsistency bug again (unsuccessful).
   - Added server option to restart current round.
   - Added option to log the chat text to tanks.log.

   2001.08.31
   - Changed restart round option to 'End this round.'

   2001.09.04
   - Fixed small bug with 'End this round' option.

   2001.09.09a
   - This should fix it.  Really.

   2001.09.10
   - Important bug fix.

   2001.09.11
   - This will definately fix some stuff.

   2001.09.13
   - Fixed bug in single player.

   2001.09.13c
   - Fixed a sound bug.
   - Now the increment will only reset to 5 at the beginning of the game, not
     each round.

   2001.10.04
   - Added an option to remember your angle/power increment setting or not.
   - Changed "Missile X" display to a slider.  The Tanks don't actually shoot
     missiles; they shoot 'mortar cannon shells.'  I named them missiles before
     because I based the game on Scorched Earth.  In Scorched Earth, the bombs
     are called missiles, nukes, etc..  Now I'll just call them explosive
     shells. :)
   - Added buttons 1-5 for selecting the corresponding explosive.
   - Dialog interface added for listing & joining servers that are currently
     running.  Type /tanklist to open the dialog.
   - There's an option in the popup for listing your server in the /tanklist or
     not.
   - Big thanks to Shikkie for writing the php/mysql/socket interface for the
     Tanks server list!
   - More big thanks to fubar at mircscripts.org for hosting the php/mysql!
     I had a hard time finding a place that it would work on.

   2001.10.04b
   - Fixed bug that wasn't removing your server from /tanklist when you closed
     the window.
   - New command "/tanks <port>" to start a server without sending a request to
     someone.  Use "/tanks 0" to start a server on a random port.

   2001.10.05b
   - I added a popup for a 'vote to end this round' option.  This is used when
     all the players whose tanks are still intact want to end the round.  If
     you want to play a team game, then use this option when your team wins
     (when all the tanks of your opponents have been destroyed).
   - Added /em command to the chat box for people like me who typo on "/me" :)

   2001.10.06
   - Fixed a bug in the voting option.  Now you can take back your vote.
   - Added a 'Tank info' popup window for when you click near a tank.
   - Added an 'End current game' option for servers.
   - The server lister now displays the number of total players in the list.

   2001.10.08
   - Fixed bugs having to do with players quitting.
   - Fixed some bugs with mIRC v5.6.

   2001.10.09a
   - Fixed a bug where it wasn't displaying when people left.
   - Added private messaging; press 'M' during the game.

   2001.10.09b
   - Important bug fix to pmsg.
   - Fixed a bug with mIRC 5.6 and 5.61.

   2001.10.10
   - Fixed a bug in pmsg that wouldn't let you send a message to more than one
     person at a time.
   - Private messages are now blue.
   - Fixed a bug which still displayed a server on /tanklist when it was set to
     closed.
   - Added messages for when tanks get blown up.

   2001.10.14
   - Fixed bug with tank damage area (it was off by a bit).
   - Added "Shots fired" to tanks scores window.
   - Added a dedicated server option.  Type /tanksd to start a dedicated
     server.
   - Added an auto-fire after 1 minute of idle time for a player during their
     turn.

   2001.10.14c
   - Fixed bugs with people leaving.
   - Fixed bug where it would leave only 1 person playing.

   2001.10.14d
   - Fixed really stupid bug where I typed an %n instead of a %c.

   2001.10.14e
   - Fixed stupid display bug. Sorry.

   2001.10.19
   - Changed the 1-minute timeout to a 40-second timeout.
   - Added an auto-kick for people who idle 3 times in a row.
   - Fixed bug in /tanklist when a nickname had # in it.
   - You can now send pmsgs to the server (dedicated).
   - Fixed a few miscellaneous bugs.
   - Finally fixed scores window so it sorts properly now.

   2001.10.19b
   - Fixed bug with scores window displaying wrong number of frags.
   - Made it so the server name can be longer than 15 characters.

   2001.10.21a
   - The turret is now drawn for each angle instead of loading from a bitmap.
   - Fixed an inconsistency bug.
   - Fixed bugs with tank damage & collision detection.
   - Added a parameter to the chat command /color.  Type /color [1-11].

   2001.10.28
   - Added server ping.
   - Added /vote command for chat box (same as the popup).
   - Added debug logging so I can figure out where the bugs are coming from.
     When an error occurs, it will ask you if you want to submit the debug log.
     Please answer "yes" when this happens; it will help me a lot. :)

   2001.10.28b
   - Added option for servers to ping clients.
   - Fixed one type of inconsistency bug.
   - Added flood protection.

   2001.10.30
   - Fixed bug where Tanks could collide.
   - Fixed sound bug.
   - Fixed auto-fire bug.
   - Fixed another type of inconsistency bug.

   2001.10.31
   - Bad bug fixed.

   2001.10.31a
   - Fixed bug where it displayed tanks that weren't there.

   2001.10.31d
   - Fixed more bugs.
   - I had to change the version check/download site.  I don't know when
     I will get /tanklist back up.

   2001.10.31e
   - VEWWY IMPORTANT FIXORZ. Fixed several bugs when people join a game in
     progress.  Thanks Memo :)

   2001.11.01
   - /tanklist is working again.

   2001.11.03a
   - /tanklist moved to a different location.
   - Fixed a freezing bug.
   - Improved damage detection.

   2001.11.04
   - Fixed scores bug.
   - Fixed bug with auto-fire.
   - Fixed /tanklist display bug.

   2001.11.14
   - Fixed client-side crashing bug when someone left the game while a new
     round was starting.
   - Added "Un-minimize on your turn" option.
   - /tanklist now sorts servers again.
   - Server is now displayed in the titlebar.
   - Made it easy to copy scores to clipboard.
   - Added accuracy to the scores window.
   - Fixed some other small bugs.

   2001.11.14b
   - Fixed bug with scores.
   - Made accuracy display in the titlebar.

   2001.11.20
   - Accuracy will not count in scores window for a player who hasn't played at
     least 5 turns.
   - Added Home and End keys for selecting the lowest and highest explosive
     strengths, respectively.
   - Added a "Fast mode" option, where instead of showing the projectile flying
     through the air, the path of the projectile is drawn instantly, and it
     stays on the screen for a little while.
   - Added an accuracy display on the tank info popup window.
   - The current player's accuracy is now displayed below when it isn't your
     turn.

   2001.11.20a
   - Fixed a display bug for the tank info popup.

   2001.11.29
   - Added a ban list.
   - Fixed some small bugs.

   2001.11.29a
   - Previous version didn't work. Fixed.

   2001.12.04
   - Fixed one type of inconsistency bug.
   - Fixed it so no duplicate connections can be made.
   - Fixed a bug with the ban list.

   2001.12.04a
   - Fixed serious bugs.

   2001.12.16
   - Fixed voting bug.
   - Fixed a few types of inconsistency bugs.
   - Fixed bugs concerning "already connected" and "reconnecting too fast."

   2001.12.17b
   - Fixed bug where 'kick user' wouldn't work.
   - Now when you move your mouse over a name in the list, it will display the
     name above the proper tank.

   2002.01.10a
   - Fixed some more inconsistency bugs.
   - Fixed display bug when drawing new land.
   - Added "/log [on|off]" chat command.
   - Added "/color 0" chat command to pick a random color.
   - Now you can click on the nicklist to see the info for that player.

   2002.01.10b
   - Fixed silly inconsistency bug that was created by mistake in last version.

   2002.01.18
   - New colors.
   - Bug fixes.
   - Timestamp in logs.

   2002.01.22a
   - Fixed a few display bugs.
   - Actions (/me) are now displayed in purple.
   - Players now begin rounds with 11 shield instead of 10.  Once a player has
     been damaged, their tank can still only be repaired up to 10 shield.
   - Tank starting positions are more random now.

   2002.01.25
   - Fixed a few more display bugs.
   - Fixed removing-extra-dirt-at-bottom bug.
   - Fixed another type of inconsistency bug.
   - Changed public action color slightly.
   - Modified tank colors.
   - Improved logging.

   2002.01.27
   - Important bug fix (I forgot to remove debugging code that made the game
     exit when the mouse was held down during an explosion).
   - Added an option to enable/disable prevention of duplicate connections
     (more than one connection from the same IP).

   2002.02.03
   - For people who want to make popups, you can use "tanks.chat <text>"
     instead of "say <text>."  You can also use $tanks.player($?="huh?") to
     enter a player number and return the nick of that player.
   - Added "/msg <player_num> <text>" chat command.  This is mainly for
     internal use, and you can use it for popups (explained above).  To send a
     message to multiple users, separate the numbers by commas (no spaces).
     Example: /msg 1,3 hello people.
   - Fixed display bugs in mIRC 5.6 (finally).
   - Fixed display problems with the new mIRC 6.0 released today.
   - Changed keyboard controls for selecting explosive strengths.
     [Delete] and [End] will now change explosive by 1
     [Insert] and [Home] will now select the smallest and largest explosives.
   - Fixed bug where some players could get a lot more credits than others when
     skipping a round.
   - Spiffy new look for /tanklist dialog.

   2002.03.05
   - Fixed tank collision bug.

   2002.03.06
   - Fixed fire bug.

   2002.03.31a - I thought I was done..
   - Fixed some bugs having to do with players quitting.
   - I think I'm done with this script.  There won't be any more major updates.
     If I occasionally see the need to make an update, I will.  There's a few
     small bugs that I'm aware of, but they don't affect the game.  Have fun.

   2002.06.14 - mIRC v6.02
   - Fixed bugs in mIRC v6.02 (This is what motivated me to update).
   - In mIRC v6.02, I had to disable the little name display over the tank when
     you move the mouse on the player names.  A bug in /window -o prevented it
     from working properly.  All other versions of mIRC are unaffected.
   - Fixed some gui bugs.
   - As promised, this version has a scrollbar in the chat display.
   - You can now copy text from the chat display by holding down the shift or
     control keys while dragging the mouse over the lines you want to copy.

   2003.02.09 - Bug fixes
   - Tanks no longer works with mIRC v5.6 (it hasn't for some time).
   - Chat scrolling no longer disables after the server closes the connection.
   - Improved chat text copying.
   - Fixed a problem with /tanklist sockets not closing.
   - Fixed a wrapping bug on server name echo.
   - Fixed a voting bug.
   - Fixed an "idle three times" bug.
   - Added an option to hide the window when running a dedicated server.
   - Fixed the server settings dialog (text was being cut off).


--------------------------------------------------------------------------------
