Server Help

Bot Questions - TWCore:Letter Coords :]

BDwinsAlt - Sat Nov 19, 2005 3:01 pm
Post subject: TWCore:Letter Coords :]
Well ya know how you have those silly little X/Y coords. Well umm now you can have letter coords. Here is the code:
Code: Show/Hide

String coords;

Player p = m_botAction.getPlayerName(event.getPlayerID());

coords=""+((char)(65+((p.getXLocation() * 5 ) >> 12)))+
(((p.getYLocation() * 5 ) >> 12) + 1);

m_botAction.sendPrivateMessage( p.getPlayerName() + " is at " + coords );


Something along the lines of that is how you get letter coords.

Output would be: BDwinsAlt is at K10.

If your using a bounty rabbit game do this.

Code: Show/Hide

private String wabbit;
   public void rabbit(String name, String message){
         Player p = m_botAction.getPlayer(name);
   if(oplist.isER(name)){
      if( message.equals("on") ){
         m_botAction.sendArenaMessage( p.getPlayerName() + " is the new rabbit! Get him/her to become the new rabbit." );
         wabbit = p.getPlayerName();
         m_botAction.sendUnfilteredPrivateMessage( wabbit, "*prize 5000" );
      } else if( message.equals("off") ){
      wabbit=off;
      }
      } if( message.equals("") ){
      m_botAction.sendPrivateMessage( name, "Wabbit: " + wabbit );
      }
   }

   public void handleEvent(PlayerDeath event){
      String killee = m_botAction.getPlayerName( event.getKilleeID() );
      String killer = m_botAction.getPlayerName( event.getKillerID() );
      String coords;
      Player p = m_botAction.getPlayer(event.getKillerID());
      coords=""+((char)(65+((p.getXLocation() * 5 ) >> 12)))+(((p.getYLocation() * 5 ) >> 12) + 1);
      if( killee.equals(wabbit) ){
          m_botAction.sendUnfilteredPrivateMessage( killer, "*points 100000" );
          m_botAction.sendUnfilteredPrivateMessage( killer, "*prize 5000" );
         m_botAction.sendArenaMessage( killer + " is the new rabbit! Kill the wabbit to get the reward! (" + coords + ")" );
         m_botAction.sendPrivateMessage( wabbit, "You are no longer the wabbit!" );
         m_botAction.sendPrivateMessage( killer, "You are the new wabbit! You have been given the reward: 100,000 points." );
         wabbit = killer;
}


Ta-Dah, now you can point and laugh at me and my code.

Credits: Thanks to wiredfreak (SSCU Redstar) for the coord coding.
Cyan~Fire - Sat Nov 19, 2005 5:26 pm
Post subject:
*points and laughs*
BDwinsAlt - Sat Nov 19, 2005 7:23 pm
Post subject:
lol it is, weird. Anyways it was in custom code. I posted it there because i didn't think my topic was a question.
Chambahs - Sat Nov 19, 2005 7:25 pm
Post subject:
thsis isnt custoim code. iths is bot questionas
D1st0rt - Sat Nov 19, 2005 8:36 pm
Post subject:
wouldn't something like this be a lot easier?

Note: didn't compile this so theres probably an error somewhere

Code: Show/Hide
public String getPlayerLocation(int xtiles, int ytiles)
{
   char x = ('A' + xtiles * 20 / 1024);
   short y = (ytiles * 20 / 1024) + 1;
   return (""+ x + y);
}

BDwinsAlt - Sat Nov 19, 2005 9:01 pm
Post subject:
Who knows d1s lol. Well i know my way works. sa_tongue.gif

Hmm i wonder if letter coords are included in TWCore 1.0

Im checking the site 58 times a day to see if its released.
Cerium - Sun Nov 20, 2005 12:29 am
Post subject:
Dont count on it. Something like that requires so little work it doesnt need to be built into the core, and by all means SHOULDNT be.
BDwinsAlt - Sun Nov 20, 2005 1:20 am
Post subject:
Its more convenient to have a p.getLetterCoords() rather than having to make the code sa_tongue.gif .
Mr Ekted - Sun Nov 20, 2005 2:41 am
Post subject:
*points and laughs*
Cerium - Sun Nov 20, 2005 7:23 pm
Post subject:
public class BloatedPlayer extends Player
{
public String getLetterCoords()
{
...
}
}
D1st0rt - Sun Nov 20, 2005 8:19 pm
Post subject:
It would actually make a lot more sense to make it static in a utility class such as Tools. Even having it in BotAction would make more sense than putting it in Player.
Cerium - Sun Nov 20, 2005 10:04 pm
Post subject:
I wouldnt bother. The number of bots which actually make use of it isnt nearly high enough to add a block of code that simple into the core.
Anonymous - Mon Nov 21, 2005 11:35 am
Post subject:
I must join in here, it's too small of a code block to be required in the core; however, if they were to do it, I'd suggest making it a static function like they do w/ the Java Math util functions (since it's not dependent on anything spectacular). I doubt the map size will change any time soon, etc. etc.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group