Changeset 1781
- Timestamp:
- 08/20/07 13:28:48 (3 years ago)
- Location:
- trunk/twcore/src/twcore/core
- Files:
-
- 4 modified
-
BotAction.java (modified) (4 diffs)
-
events/PlayerDeath.java (modified) (1 diff)
-
game/Arena.java (modified) (4 diffs)
-
game/Player.java (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/twcore/src/twcore/core/BotAction.java
r1740 r1781 91 91 m_positionTask = null; 92 92 DefaultSpectateTime = getCoreData().getGeneralSettings().getInt( "DefaultSpectateTime" ); 93 setPlayerPositionUpdating(DefaultSpectateTime); 93 94 } 94 95 … … 2259 2260 /** 2260 2261 * Turns automatic player position updating on and off. By default it is ON, 2261 * and set to change between the players it spectates for packets every 5000ms. 2262 * The lower the number, the more reliable any position information stored in 2262 * and set to change between the players it spectates for packets at the rate 2263 * specified in setup.cfg under the DefaultSpectateTime field (in ms). Clearly 2264 * the lower the number, the more reliable any position information stored in 2263 2265 * Player will be, and the more frequently and reliably will the bot receive 2264 * PlayerPosition events. It is strongly advised that if you do not use 2265 * position packets that you set the time to 0 (completely off). 2266 * PlayerPosition events. The network load is almost inconsequential, 2267 * particularly with DefaultSpectateTime at values >1000 -- it requires only 3 2268 * bytes sent each specified tick -- but it is recommended to turn this feature 2269 * off by using a 0 value if you will not need reliable information in Player 2270 * classes. (Name, playerID, ship type, wins and losses do not rely on this.) 2266 2271 * <p>Note that because TWCore is a client emulator (does not operate on the 2267 2272 * server side but logs in as a bot) it only receives position packets from 2268 2273 * the server about players within radar range. This is why it must switch 2269 * who is being spectated in order to get as many packets as possible. This2270 * process may be CPU-intensive when done rapidly.2274 * who is being spectated in order to get as many packets as possible. Fortunately 2275 * this process requires only minimal load. 2271 2276 * <p>If the arena the bot operates in is small, you may want to manually 2272 * adjust its position using the move() methods for efficiency.2277 * adjust its position using the move() methods to most effectively receive packets. 2273 2278 * @param milliseconds - specified time to update player positions at 2274 2279 * 0 : turns tracking off and has the bot spectate its current area (change with move()) … … 2302 2307 2303 2308 /** 2304 * Starts the automatic player position updating system with the most reliable 2305 * positioning TWCore offers (switching between players every 200ms). This 2306 * will cause the bot to switch which players it is spectating once every 5 2307 * seconds. On slower systems and older network connections this may be 2308 * quite taxing. 2309 * <p>If you wish to switch faster than every 200ms, you must manually edit 2310 * Arena.java and hardcore a new value. 2309 * Starts the automatic player position updating system at the default 2310 * rate in setup.cfg. The load on the network is a fairly trivial 3 bytes sent 2311 * at each change of player that the bot is spectating. 2312 * <p>Note that 200ms is the default floor value. If you wish to switch faster 2313 * than every 200ms, you must edit the setPlayerPositionUpdating method manually. 2311 2314 */ 2312 2315 public void startReliablePositionUpdating() { … … 2318 2321 * stop spectating the player it is currently spectating on, and cease 2319 2322 * switching between players to update position packets. Use this if your 2320 * bot will not be receiving position packets.2323 * bot will not be receiving any position packets. 2321 2324 */ 2322 2325 public void stopReliablePositionUpdating() { -
trunk/twcore/src/twcore/core/events/PlayerDeath.java
r1535 r1781 73 73 74 74 /** 75 * Gets the score resulting from the kill. NOTE: this currently76 * just returns the bounty and not the entire score.77 * @return the points gotten from the kill75 * Gets the bounty of the player who was killed. This is not the amount of bounty 76 * added to the player who made the kill, or the amount of points to add. 77 * @return Bounty of the player who was killed. 78 78 */ 79 public short get Score(){79 public short getKilledPlayerBounty(){ 80 80 return m_score; 81 81 } -
trunk/twcore/src/twcore/core/game/Arena.java
r1679 r1781 36 36 * "Player ID" refers to the internal packet ID used by the SS protocol rather than 37 37 * the player's UserID found in ?userid. IDs are assigned sequentially arena-wide 38 * rather than zone-wide. In almost all cases, an ID is sent as 2 bytes; however, 39 * short position packets, used to update frequent info on a player, send ID as 1 byte. 40 * This doesn't become a problem until we have >255 people in an arena, after which a 41 * client with a movement prediction algorithm has no real trouble distinguishing between 42 * two players with the same 1-byte ID, but a bot core does. Fair warning! -qan 38 * rather than zone-wide. Large position packets send 2 bytes for ID, and small 39 * position packets send only 1; on the offchance that more than 256 players are in 40 * the arena at the same time, the server will begin sending only large position 41 * packets to alleviate potential problems with the same lower byte in two IDs.<br> 42 * However, if a player leaves the arena, their ID is freed up to be used by another 43 * player. This can cause confusion in bots attempting to remember players primarily 44 * by their ID -- and for the reason that only 19 of a possible 23 characters of a 45 * player's name is accessible (aside from using *info) name is also not reliable. 46 * A combination of the two may be used, or just fairly meticulous planning.<br> 47 * A last word: using Arena's getPlayer(ID) method is more reliable than getPlayer(name), 48 * for the reasons described above. If you need to get a Player object, try to do 49 * so by player ID rather than name. For utmost security also compare the name in 50 * the Player object with the expected one. 43 51 */ 44 52 public class Arena { … … 353 361 return list.size(); 354 362 } 363 364 // *** EVENT PROCESSING *** 355 365 356 366 /** … … 678 688 } 679 689 690 // *** PLAYER OBJECT UPDATING *** 691 680 692 /** 681 693 * Adds a playing player into the tracker queue to be spectated by the bot … … 735 747 } 736 748 749 /** 750 * Turns on or off the system of changing the bot's spectating target. Each time a 751 * change is made in who is being spectated, 3 bytes are sent -- plan accordingly. 752 * @param enable 753 */ 737 754 public void setEnableSpectating(boolean enable) { 738 755 synchronized(m_tracker) { -
trunk/twcore/src/twcore/core/game/Player.java
r1630 r1781 18 18 * relevant or useful being stored here. 19 19 * <p> 20 * A VERY IMPORTANT consideration is that a player's X & Y location, X & Y velocities & rotation 21 * amount may not be accurate / updated. Use BotAction's setPlayerPositionUpdating() to make 22 * this information more reliable. 20 * A <b>VERY IMPORTANT<b> consideration is that a player's X & Y location, X & Y velocities, rotation 21 * amount, weapons and accessories data (XRadar, shields, etc) may not be accurate / updated. 22 * Use BotAction's setPlayerPositionUpdating() to make this information more reliable. 23 * <p> 24 * Also note that <b>using the player's name is not a reliable method of identification</b>. 25 * Only 19 of a possible 23 characters are stored; two players whose first 19 characters 26 * of the name are identical can not be separated by the bot except by their player ID. 27 * This brings the <i>additional<i> problem of player ID being represented in a single byte, 28 * or 256 possible values, with ID re-use being possible -- this means that ID is also not 29 * a reliable method of identification; it is useless if the player is not in the arena, and 30 * it is not static in any sense. 23 31 */ 24 32 public class Player { … … 52 60 private LinkedList<Integer> m_turrets; // List of player IDs (Integer) that are attached 53 61 62 63 // The following data is generally considered so unreliably tracked as to be almost meaningless -- 64 // even moreso than standard position data found in a short position packet. It is supplied for the 65 // sake of completeness only, and it's not recommended anyone attempt to use it. Coder beware. 66 54 67 private boolean m_stealthOn; // Status of Stealth 55 68 private boolean m_cloakOn; // Status of Cloaking … … 204 217 if( message.getKillerID() == m_playerID ){ 205 218 m_wins++; 206 m_score += message.getScore(); 219 // This particular operation (adding bounty of the killed to score) is questionable; 220 // we should be using settings to properly adjust the score. We should also update 221 // bounty as appropriate. 222 // TODO: When arena settings storage class is implemented, use to properly update score & bounty. 223 m_score += message.getKilledPlayerBounty(); 207 224 } else if( message.getKilleeID() == m_playerID ){ 208 225 m_losses++; 226 m_bounty = 0; // As a precaution; we will retrieve bounty at next position packet 209 227 } 210 228 } … … 260 278 261 279 m_frequency = message.getFrequency(); 280 m_bounty = 0; // As a precaution; we will retrieve bounty at next position packet 262 281 } 263 282 … … 270 289 m_frequency = message.getFrequency(); 271 290 m_shipType = message.getShipType(); 291 m_bounty = 0; // As a precaution; we will retrieve bounty at next position packet 272 292 } 273 293 … … 402 422 403 423 /** 404 * @return Name of the player 424 * Gets a String of the first 19 out of a possible 23 characters of this player's name. 425 * Note that <b>using the player's name is not a reliable method of identification</b>. 426 * Only 19 of a possible 23 characters are stored; two players whose first 19 characters 427 * of the name are identical can not be separated by the bot except by their player ID. 428 * @return First 19 out of 23 possible characters of the name of the player 405 429 */ 406 430 public String getPlayerName(){ … … 574 598 575 599 /** 576 * @return Player's last recorded amount of energy left 600 * @return Player's last recorded amount of energy left. Not reliable 577 601 */ 578 602 public short getEnergy(){ … … 645 669 646 670 /** 671 * Returns the score as tracked by TWCore. TWCore does <b>NOT</b> currently track 672 * score properly -- this is provided as a working approximation only. 647 673 * @return Overall point score of the player 648 674 */ … … 653 679 654 680 /** 655 * @return True if player has shields 681 * @return True if player has shields (UNRELIABLE; DO NOT USE) 656 682 */ 657 683 public boolean hasShields(){ … … 660 686 661 687 /** 662 * @return True if player has super 688 * @return True if player has super (UNRELIABLE; DO NOT USE) 663 689 */ 664 690 public boolean hasSuper(){ … … 667 693 668 694 /** 669 * @return Total number of bursts player currently possesses 695 * @return Total number of bursts player currently possesses (UNRELIABLE; DO NOT USE) 670 696 */ 671 697 public int getBurstCount(){ … … 674 700 675 701 /** 676 * @return Total number of bursts player currently possesses 702 * @return Total number of bursts player currently possesses (UNRELIABLE; DO NOT USE) 677 703 */ 678 704 public int getRepelCount(){ … … 681 707 682 708 /** 683 * @return Total number of bursts player currently possesses 709 * @return Total number of bursts player currently possesses (UNRELIABLE; DO NOT USE) 684 710 */ 685 711 public int getThorCount(){ … … 688 714 689 715 /** 690 * @return Total number of bricks player currently possesses 716 * @return Total number of bricks player currently possesses (UNRELIABLE; DO NOT USE) 691 717 * @deprecated "Walls" is not a clear term. Made this a wrapper for getBrickCount 692 718 */ … … 697 723 698 724 /** 699 * @return Total number of bricks player currently posesses 725 * @return Total number of bricks player currently posesses (UNRELIABLE; DO NOT USE) 700 726 */ 701 727 public int getBrickCount(){ … … 704 730 705 731 /** 706 * @return Total number of decoys player currently possesses 732 * @return Total number of decoys player currently possesses (UNRELIABLE; DO NOT USE) 707 733 */ 708 734 public int getDecoyCount(){ … … 711 737 712 738 /** 713 * @return Total number of rockets player currently possesses 739 * @return Total number of rockets player currently possesses (UNRELIABLE; DO NOT USE) 714 740 */ 715 741 public int getRocketCount(){ … … 718 744 719 745 /** 720 * @return Total number of portals player currently possesses 746 * @return Total number of portals player currently possesses (UNRELIABLE; DO NOT USE) 721 747 */ 722 748 public int getPortalCount(){ … … 725 751 726 752 /** 727 * @return True if ship has Stealth on 753 * @return True if ship has Stealth on (UNRELIABLE; DO NOT USE) 728 754 */ 729 755 public boolean isStealthed(){ … … 732 758 733 759 /** 734 * @return True if ship has Cloaking on 760 * @return True if ship has Cloaking on (UNRELIABLE; DO NOT USE) 735 761 */ 736 762 public boolean isCloaked(){ … … 739 765 740 766 /** 741 * @return True if ship has X-Radar on 767 * @return True if ship has X-Radar on (UNRELIABLE; DO NOT USE) 742 768 */ 743 769 public boolean hasXRadarOn(){ … … 746 772 747 773 /** 748 * @return True if ship has Antiwarp on 774 * @return True if ship has Antiwarp on (UNRELIABLE; DO NOT USE) 749 775 */ 750 776 public boolean hasAntiwarpOn(){ … … 753 779 754 780 /** 755 * @return True if ship is warping in/cloaking/uncloaking (display flash on client) 781 * @return True if ship is warping in/cloaking/uncloaking (display flash on client) (UNRELIABLE; DO NOT USE) 756 782 */ 757 783 public boolean isWarpingIn(){ … … 760 786 761 787 /** 762 * @return True if ship is currently in safe 788 * @return True if ship is currently in safe (UNRELIABLE; DO NOT USE) 763 789 */ 764 790 public boolean isInSafe(){ … … 767 793 768 794 /** 769 * @return True if ship has UFO on 795 * @return True if ship has UFO on (UNRELIABLE; DO NOT USE) 770 796 */ 771 797 public boolean isUFO(){ … … 788 814 789 815 /** 790 * Gets a String representation (name) of this player 816 * Gets a String of the first 19 out of a possible 23 characters of this player's name. 817 * Note that <b>using the player's name is not a reliable method of identification</b>. 818 * Only 19 of a possible 23 characters are stored; two players whose first 19 characters 819 * of the name are identical can not be separated by the bot except by their player ID. 791 820 * @return the player's name 792 821 */
