Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#871 closed enhancement (fixed)

FreezeJavs and Freezetag Lagout Enhancement

Reported by: Left_Eye Owned by:
Priority: normal Milestone: milestone:
Component: Bots - Multibot Version: Latest version from repository
Severity: minor Keywords:
Cc:

Description

I would like to have a !lagout or !return command that normal players can do to enter the game when a freezejavs or freezetag module is running.

A lot of times, when the host does it by hand, the bot won't recognize when a game has ended, so the host has to stop the module which is kind of embarrassing. If there is a way to have this tested out to where when a player does !return or !lagout, the bot recognizes how many on each team there is from the original (or if people have specced) to keep teams as even as possible, that would be fantastic. A thing to remember is that teams won't always look even because when someone is frozen, they are moved to the opposing team's frequency.

Thanks!

Lefty

Change History (3)

comment:1 Changed 5 years ago by SpookedOne

Can't commit or attach file so here is another source change for you, as follows:

add to imports

import twcore.core.events.*;

remove the other imports from same level

import twcore.core.events.FrequencyShipChange;
import twcore.core.events.Message;
import twcore.core.events.PlayerDeath;
import twcore.core.events.PlayerLeft;

add class member

private boolean teamToggle; //toggles team which to add new player to

adjust init method to include new class member

    /**
     * Initialize the module.
     */

    public void init() {
        teamToggle = false;
        freq0WarbirdSet  = new HashSet<String>();
        freq0LevSet      = new HashSet<String>();
        freq1JavSet      = new HashSet<String>();
        freq1SpidSet     = new HashSet<String>();
        timeLimit        = 0; //default if game is not timed
        isRunning        = false;
    }

add new request for player entering in the requestor

    /**
     * This method requests the events used by this module.
     */
    public void requestEvents(ModuleEventRequester eventRequester)
    {
      eventRequester.request(this, EventRequester.FREQUENCY_SHIP_CHANGE);
      eventRequester.request(this, EventRequester.PLAYER_DEATH);
      eventRequester.request(this, EventRequester.PLAYER_LEFT);
      eventRequester.request(this, EventRequester.PLAYER_ENTERED);
    }

add to handle player handle command the !enter command

     public void handlePlayerCommand( String name, String message ) {
        if( message.toLowerCase().equals( "!leave" ) ) {
            doLeave( name );
        } else if (message.equalsIgnoreCase("!enter")) {
            doEnter(name);
        }
     }

add method for handling the player entered events

     /**
      * This method handles players entering the arena late. Will notify them 
      * once to pm !enter to bot to join.
      * 
      * @param event the player entering event
      */
    @Override
    public void handleEvent(PlayerEntered event) {
        if (isRunning) {
            m_botAction.sendSmartPrivateMessage(event.getPlayerName(), "Type "
                    + "!enter to me to join");
        }
    }

and finally add a new method to actually handle the player command !enter

/**
     * This method allows late comers to enter arena without host interaction.
     * 
     * @param name name of player to join arena
     */
    public void doEnter(String name) {
        if (teamToggle) {
            m_botAction.setShip(name, WARBIRD);
            m_botAction.setFreq(name, TEAM1_FREQ);
            teamToggle = false;
        } else {
            m_botAction.setShip(name, JAVELIN);
            m_botAction.setFreq(name, TEAM2_FREQ);
            teamToggle = true;
        }
    }

comment:2 Changed 5 years ago by qan

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.