Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ###################################################################
- ###### Battle Mania ######
- ###################################################################
- ###### Script by: LOVER$BOY ######
- ###### Description: Please leave this header. Thanks! ######
- ###### Contact: zodiacsohma1@gmail.com ######
- ###################################################################
- //!< Reads the STDIN (input) from feed provided by the stream
- function ReadStdin()
- {
- // Normally use rtrim but trim is better for this.
- // Extended read line length from 1024 to 2048 for long lines.
- Base::$base->line = trim(fgets(STDIN, 2048));
- }
- //!< Put the pieces together
- function BridgePieces($start, $break = " ", $finish = -1)
- {
- $str = "";
- if ($finish == -1)
- $finish = count(Base::$base->pieces);
- for($i = $start; $i < $finish; $i++)
- {
- if (($i + 1) == count(Base::$base->pieces))
- $str .= Base::$base->pieces[$i];
- else
- $str .= Base::$base->pieces[$i].$break;
- }
- return $str;
- }
- //!< MAIN ENGINE >!\\
- function main()
- {
- // parse lines read
- if (Filter(Base::$base->line) !== "")
- {
- // split and store strings by the break character (" ")
- Base::$base->pieces = explode(" ", Base::$base->line);
- try
- {
- //<! When a player has entered the server; grid/spectator
- if (startswith(Base::$base->line, "PLAYER_ENTERED"))
- {
- PlayerEntered();
- }
- //!< When a AI has entered the server
- elseif (startswith(Base::$base->line, "PLAYER_AI_ENTERED"))
- {
- PlayerAIEntered();
- }
- //!< When a player has been renamed
- elseif (startswith(Base::$base->line, "PLAYER_RENAMED"))
- {
- PlayerRenamed();
- }
- //!< Setting the colored display name of the player
- elseif (startswith(Base::$base->line, "PLAYER_COLORED_NAME"))
- {
- PlayerColoredName();
- }
- //!< Online players stats
- elseif (startswith(Base::$base->line, "ONLINE_PLAYERS"))
- {
- OnlineSyncDetails();
- }
- //!< The data of the online player
- elseif (startswith(Base::$base->line, "ONLINE_PLAYER"))
- {
- OnlinePlayer();
- }
- //!< When a AI or player leave the server
- elseif ((startswith(Base::$base->line, "PLAYER_LEFT")) || (startswith(Base::$base->line, "PLAYER_AI_LEFT")))
- {
- PlayerLeft();
- }
- //!< When a team is created
- elseif (startswith(Base::$base->line, "TEAM_CREATED"))
- {
- TeamCreated();
- }
- //!< When a team is renamed
- elseif (startswith(Base::$base->line, "TEAM_RENAMED"))
- {
- TeamRenamed();
- }
- //!< When players leave the team and it gets destroyed
- elseif (startswith(Base::$base->line, "TEAM_DESTROYED"))
- {
- TeamDestroyed();
- }
- //!< When a player is added to a certain team
- elseif (startswith(Base::$base->line, "TEAM_PLAYER_ADDED"))
- {
- TeamAddedPlayer();
- }
- //!< The currntly played map and the size factor for it
- elseif (startswith(Base::$base->line, "CURRENT_MAP"))
- {
- CurrentMap();
- }
- //!< When player (s) have died
- elseif (startswith(Base::$base->line, "DEATH_"))
- {
- deaths();
- }
- //!< When a cycle is created on the grid
- elseif (startswith(Base::$base->line, "CYCLE_CREATED"))
- {
- CycleCreated();
- }
- //!< When a cycle is destroyed on the grid
- elseif (startswith(Base::$base->line, "CYCLE_DESTROYED"))
- {
- CycleDestroyed();
- }
- //!< The gridpos of the player and their cycle
- elseif (startswith(Base::$base->line, "PLAYER_GRIDPOS"))
- {
- // No need to process the positions of players during zombie challenge.
- // This will save time and process energy for the spawned zombie zones.
- if (Base::$base->game_mode == 1) return;
- $player = getPlayerByLog(Base::$base->pieces[1]);
- if (isset($player) && !is_null($player) && $player instanceof Player)
- {
- $cycle = $player->cycle;
- if (isset($cycle) && !is_null($cycle) && $cycle instanceof Cycle)
- {
- $pos = new Coord(Base::$base->pieces[2] / Base::$base->ARENA->sizeMultiplier, Base::$base->pieces[3] / Base::$base->ARENA->sizeMultiplier);
- $dir = new Coord(Base::$base->pieces[4], Base::$base->pieces[5]);
- player_gridpos($cycle, $pos, $dir, Base::$base->pieces[6], Base::$base->pieces[7], Base::$base->pieces[8]);
- }
- }
- }
- //!< When the round has just started
- elseif (startswith(Base::$base->line, "ROUND_STARTED"))
- {
- onRoundStart();
- }
- //!< When the round has just finished (declaring winner or no one alive)
- elseif (startswith(Base::$base->line, "ROUND_FINISHED"))
- {
- onRoundFinish();
- }
- //!< When a new round is about to commence
- elseif (startswith(Base::$base->line, "ROUND_COMMENCING"))
- {
- onRoundCommencing();
- }
- //!< When the round has just ended (clearing out all grid and data of cycles)
- elseif (startswith(Base::$base->line, "ROUND_ENDED"))
- {
- onRoundEnd();
- }
- //!< When an unknown chat command is called
- elseif (startswith(Base::$base->line, "INVALID_COMMAND"))
- {
- parseNormalChat();
- }
- //!< When an custom unknown chat command is called
- elseif (startswith(Base::$base->line, "CUSTOM_INVALID_COMMAND"))
- {
- parseUnknownChat();
- }
- //!< When the deathzone is activated
- elseif (startswith(Base::$base->line, "DEATHZONE_ACTIVATED"))
- {
- // turn off respawning since it's time to close the round
- Base::$base->respawn = false;
- con("0xffaaffDeathzone Activated, respawn is now switched off!");
- }
- //!< When a zone is spawned or created
- elseif (startswith(Base::$base->line, "ZONE_CREATED") || startswith(Base::$base->line, "ZONE_SPAWNED"))
- {
- ZoneCreated();
- }
- //!< When an objectzone is created
- elseif (startswith(Base::$base->line, "OBJECTZONE_SPAWNED"))
- {
- ObjectZoneCreated();
- }
- //!< When a player entered an object zone
- elseif (startswith(Base::$base->line, "OBJECTZONE_PLAYER_ENTER"))
- {
- ObjectZonePlayerEntered();
- }
- //!< When a zone entered an object zone
- elseif (startswith(Base::$base->line, "OBJECTZONE_ZONE_ENTERED"))
- {
- ObjectZoneZoneEntered();
- }
- //!< When a zone has collapsed/destroyed
- elseif (startswith(Base::$base->line, "ZONE_COLLAPSED"))
- {
- ZoneCollapsed();
- }
- //!< When a round winner (team) is declared
- elseif (startswith(Base::$base->line, "ROUND_WINNER"))
- {
- onRoundWinnerDeclared();
- }
- //!< When all players leave the server
- elseif (startswith(Base::$base->line, "GAME_END"))
- {
- on_game_end();
- }
- //!< When the server has been shutdown, do the shutdown of the script
- elseif (startswith(Base::$base->line, "SHUTDOWN"))
- {
- on_server_exist();
- }
- }
- catch (ErrorException $ex)
- {
- errorExecute($ex);
- errorLog($ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement