Server Help

Bot Questions - Updated TWCore

D1st0rt - Sat Feb 21, 2004 5:25 pm
Post subject: Updated TWCore
Let me know (email or otherwise) if you would like the updates I have made to the TWCore that now handle the TurretEvents, they were previously unimplemented. I had to modify the SubspaceBot, EventRequester, and GamePacketInterpreter classes to incorporate the TurretEvent class that was already there. The one problem comes with detaching, because it will throw a NullPointerException if you try to get information from the attachee.

here's the code I use to get around it:
Code: Show/Hide
import java.util.*;

public class TurretBot extends SubspaceBot
{
      private HashSet attached;
      public TurretBot(BotAction botAction)
      {
            attached = new HashSet();
      }

      public void handleEvent(TurretEvent event)
      {
            int turret = event.getAttacherID();
            String name = m_botAction.getPlayerName(turret);
            if(attached.add(name))
            {
                  int capship = event.getAttacheeID();
                  //Stuff goes here
            }
            else
                  attached.remove(name);
            }
      }
}

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group