FFs Posted June 15, 2011 Posted June 15, 2011 Core Part: Index: java/com/l2jserver/Config.java =================================================================== --- java/com/l2jserver/Config.java (revision 4011) +++ java/com/l2jserver/Config.java (working copy) @@ -625,6 +630,9 @@ public static TIntIntHashMap TVT_EVENT_FIGHTER_BUFFS; public static TIntIntHashMap TVT_EVENT_MAGE_BUFFS; public static boolean TVT_ALLOW_VOICED_COMMAND; + public static boolean TVT_ALLOW_REGISTER_VOICED_COMMAND; + public static boolean TVT_RESTORE_PLAYER_POS; @@ -2009,6 +2017,16 @@ TVT_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(L2JModSettings.getProperty("TvTEventStartLeaveTeleportDelay", "20")); TVT_EVENT_EFFECTS_REMOVAL = Integer.parseInt(L2JModSettings.getProperty("TvTEventEffectsRemoval", "0")); TVT_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowVoicedInfoCommand", "false")); + TVT_ALLOW_REGISTER_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowRegisterVoicedCommand", "false")); + TVT_DISALLOW_DUALBOX = Boolean.parseBoolean(L2JModSettings.getProperty("TvTEnableDualBoxProtection", "false")); + TVT_RESTORE_PLAYER_POS = Boolean.parseBoolean(L2JModSettings.getProperty("TvTRestorePlayerOldPosition", "false")); Index: java/com/l2jserver/gameserver/model/entity/TvTEvent.java =================================================================== --- java/com/l2jserver/gameserver/model/entity/TvTEvent.java (revision 4011) +++ java/com/l2jserver/gameserver/model/entity/TvTEvent.java (working copy) @@ -28,6 +29,7 @@ import com.l2jserver.gameserver.instancemanager.InstanceManager; import com.l2jserver.gameserver.model.L2Skill; import com.l2jserver.gameserver.model.L2Spawn; +import com.l2jserver.gameserver.model.L2World; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.L2Summon; @@ -91,8 +94,22 @@ */ public static void init() { + + if(Config.TVT_RESTORE_PLAYER_POS) + TvTEventTeleporter.initializeRestoreMap(); + } @@ -459,6 +464,12 @@ } } + if(Config.TVT_RESTORE_PLAYER_POS) + TvTEventTeleporter.clearRestoreMap(); + @@ -1136,7 +1291,7 @@ */ public static int[] getParticipantTeamCoordinates(int playerObjectId) { - return _teams[0].containsPlayer(playerObjectId) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerObjectId) ? _teams[1].getCoordinates() : null); + return getParticipantTeam(playerObjectId).getCoordinates(); } /** @@ -1152,7 +1307,7 @@ return false; } - return _teams[0].containsPlayer(playerObjectId) || _teams[1].containsPlayer(playerObjectId); + return getParticipantTeam(playerObjectId) != null; Index: java/com/l2jserver/gameserver/model/entity/TvTEventTeleporter.java =================================================================== --- java/com/l2jserver/gameserver/model/entity/TvTEventTeleporter.java (revision 4011) +++ java/com/l2jserver/gameserver/model/entity/TvTEventTeleporter.java (working copy) @@ -14,6 +14,8 @@ */ package com.l2jserver.gameserver.model.entity; +import javolution.util.FastMap; + import com.l2jserver.Config; import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.model.actor.L2Summon; @@ -28,6 +30,22 @@ private int[] _coordinates = new int[3]; /** Admin removed this player from event */ private boolean _adminRemove = false; + /** Old Player Coordinates */ + private static FastMap<Integer, Integer[]> _oldPlayerPos; + /** Color name identifier per Team */ + private static final int[] _colorNames = + { + // White + 16777215, + // Blue + 26367, + // Red + 16711680, + // Green + 3407718, + // Yellow + 16776960 + }; /** * Initialize the teleporter and start the delayed task<br><br> @@ -94,13 +112,55 @@ _playerInstance.doRevive(); - _playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false ); + int objId = _playerInstance.getObjectId(); + if(Config.TVT_RESTORE_PLAYER_POS && TvTEvent.isStarted() && !_adminRemove) + { + final Integer[] oldCoords = + { + _playerInstance.getX(), + _playerInstance.getY(), + _playerInstance.getZ() + }; + + _oldPlayerPos.put(objId, oldCoords); + } + + if(Config.TVT_RESTORE_PLAYER_POS && !TvTEvent.isStarted()) + { + Integer[] coor = _oldPlayerPos.get(objId); + + if(coor != null) + { + _playerInstance.teleToLocation(coor[0], coor[1], coor[2], false); + } + else + { + _playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false ); + } + } + else + _playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false ); if (TvTEvent.isStarted() && !_adminRemove) - _playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1); + { + int team = TvTEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1; + + if(Config.TVT_TEAMS_COUNT == 2) + _playerInstance.setTeam(team); + else + _playerInstance.getAppearance().setNameColor(_colorNames[team]); + } else - _playerInstance.setTeam(0); + { + if(Config.TVT_TEAMS_COUNT == 2) + _playerInstance.setTeam(0); + else + _playerInstance.getAppearance().setNameColor(_colorNames[0]); + } + if(_oldPlayerPos.containsKey(objId)) + _oldPlayerPos.remove(objId); + _playerInstance.setCurrentCp(_playerInstance.getMaxCp()); _playerInstance.setCurrentHp(_playerInstance.getMaxHp()); _playerInstance.setCurrentMp(_playerInstance.getMaxMp()); @@ -108,4 +168,22 @@ _playerInstance.broadcastStatusUpdate(); _playerInstance.broadcastUserInfo(); } + + /** + * Initializes the map where the player position + * will be stored + */ + public static void initializeRestoreMap() + { + if(_oldPlayerPos == null) + _oldPlayerPos = new FastMap<Integer, Integer[]>(); + } + + /** + * Clear all containing data for a new event + */ + public static void clearRestoreMap() + { + _oldPlayerPos.clear(); + } } Index: java/config/l2jmods.properties =================================================================== --- java/config/l2jmods.properties (revision 4011) +++ java/config/l2jmods.properties (working copy) @@ -172,6 +175,15 @@ TvTEventTeam2Name = Team2 TvTEventTeam2Coordinates = 149999,46728,-3414 +#Restore previous char position when TvT ends +TvTRestorePlayerOldPosition = False DP Part: Index: data/scripts/handlers/MasterHandler.java =================================================================== --- data/scripts/handlers/MasterHandler.java (revision 7189) +++ data/scripts/handlers/MasterHandler.java (working copy) @@ -265,8 +265,8 @@ VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Wedding()); if (Config.BANKING_SYSTEM_ENABLED) VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking()); - if (Config.TVT_ALLOW_VOICED_COMMAND) - VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new TvTVoicedInfo()); + if (Config.TVT_ALLOW_VOICED_COMMAND || Config.TVT_ALLOW_REGISTER_VOICED_COMMAND) + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new TvTVoiced()); Index: data/scripts/handlers/voicedcommandhandlers/TvTVoiced.java =================================================================== --- data/scripts/handlers/voicedcommandhandlers/TvTVoiced.java (revision 7189) +++ data/scripts/handlers/voicedcommandhandlers/TvTVoiced.java (working copy) @@ -27,40 +27,72 @@ * * @author denser */ -public class TvTVoicedInfo implements IVoicedCommandHandler +public class TvTVoiced implements IVoicedCommandHandler { - private static final String[] _voicedCommands = { "tvt" }; + private static final String[] _voicedCommands = + { + "tvt", + "tvtjoin", + "tvtleave" + }; @@ -74,6 +106,20 @@ activeChar.sendPacket(ActionFailed.STATIC_PACKET); } } + else if(command.equalsIgnoreCase("tvtjoin")) + { + if(Config.TVT_ALLOW_REGISTER_VOICED_COMMAND) + TvTEvent.onBypass("tvt_event_participation", activeChar); + else + activeChar.sendMessage("Command disabled"); + } + else if(command.equalsIgnoreCase("tvtleave")) + { + if(Config.TVT_ALLOW_REGISTER_VOICED_COMMAND) + TvTEvent.onBypass("tvt_event_remove_participation", activeChar); + else + activeChar.sendMessage("Command disabled"); + } That's my code and i need help to finish it. Its my first code so... i dont know if it is good coded, so i need some1 who tell me if it is good or will not work, and why, what else need the code. Well, thats all. Thanx Quote
0 FighterBoss Posted June 16, 2011 Posted June 16, 2011 UP! No1 can help me? You can bump your topic every 24 hours. Quote
0 Tryskell Posted June 16, 2011 Posted June 16, 2011 Try to compile, see errors -> if there isn't, try ingame -> if there aren't errors, GG -> if there are, post here. It's part of developper to test himself its creations, so until you didn't show any error, I don't get the point of the topic. Quote
0 FFs Posted June 16, 2011 Author Posted June 16, 2011 Try to compile, see errors -> if there isn't, try ingame -> if there aren't errors, GG -> if there are, post here. It's part of developper to test himself its creations, so until you didn't show any error, I don't get the point of the topic. You have right, thanx a lot. And FighterBoss, thanx for the information. Quote
Question
FFs
Core Part:
DP Part:
That's my code and i need help to finish it.
Its my first code so... i dont know if it is good coded, so i need some1 who tell me if it is good or will not work, and why, what else need the code.
Well, thats all. Thanx
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.