Tvt event aura

    
  1. Atsijungęs

    Jeppi

    Pranešimai: 0

    Sveiki. Vel bedos su serveriu :D Isidejau tvt eventa ir noriu padaryti kad rodytu team aura. NIekip nepavyksta su tais string man jos padaryt, uzdeda tik vienai komandai.

    Meginau toki isidet
    public void auraCheck()
           {
                   int i = 1;
                  
                   for (EventTeam et : _teams)
                   {
                                                
                           for (L2PcInstance p : et.getPlayers())
                           {
                            p.setTeam(i++);
                            p.broadcastCharInfo();
                           }
                   }
                          
                          
         }


    
    public class EventTeam
    {
           public  static List<L2PcInstance> _players;
           private static String _name;
           private int _points;
           private final int[] _respawnLoc;
          
           public EventTeam(List<L2PcInstance> players, String name, int points, int[] respawnLoc)
           {
                   _players = players;
                   _name = name;
                   _points = points;
                   _respawnLoc = respawnLoc;
                  
                   for (L2PcInstance p : _players)
                   {
                           p.setEventTeam(this);
                   }
           }
    
    
          
           public void teleportTeam(int x, int y, int z, boolean sendMessage)
           {
                   for (L2PcInstance p : _players)
                   {
                           p.teleToLocation(x, y, z, 1);
                           if (sendMessage)
                                   p.sendMessage("You have been teleported.");
                   }
           }
          
           public void paralize(boolean val)
           {
                   if (val)
                   {
                           for (L2PcInstance p : _players)
                           {
                                   p.startAbnormalEffect(AbnormalEffect.ROOT);
                                   p.setIsParalyzed(true);
                           }
                   }
                   else
                   {
                           for (L2PcInstance p : _players)
                           {
                                   p.stopAbnormalEffect(AbnormalEffect.ROOT);
                                   p.setIsParalyzed(false);
                           }
                   }
           }
          
           public void rewardTeam(int itemId, int count)
           {
                   for (L2PcInstance p : _players)
                   {
                           p.addItem("Event Reward", itemId, count, null, true);
                   }
           }
          
           public void addPoints(int val)
           {
                   _points += val;
           }
          
           public void removePoints(int val)
           {
                   _points -= val;
           }
          
           public int getPoints()
           {
                   return _points;
           }
          
           public int getRespawcenzura()
           {
                   return _respawnLoc[0];
           }
          
           public int getRespawnY()
           {
                   return _respawnLoc[1];
           }
          
           public int getRespawnZ()
           {
                   return _respawnLoc[2];
           }
          
           public String getName()
           {
                   return _name;
           }
          
           public List<L2PcInstance> getPlayers()
           {
                   return _players;
           }
          
           public boolean containsPlayer(L2PcInstance p)
           {
                   return _players.contains(p);
           }
    
    }
    


    Tvt.java
    Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "3 seconds left till registration close.");
                   
                   sleep(1);
                  
                   Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "2 seconds left till registration close.");
                   
                   sleep(1);
                   
                   Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "1 seconds left till registration close.");
                   
                   sleep(1);
                   
                   if (!check())
                   {
                           EventManager.getInstance().setCurrentEvent(null);
                           return;
                   }
                  
                   Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "Registrations for the TvT Event are closed. Teams will be teleported in 20 seconds.");
                   _state = EventState.RUNNING;
                   split();
                   auraCheck();
    
                   sleep(20);
    
    
                  
                   for (EventTeam et : _teams)
                   {
                           et.teleportTeam(Config.TVT_TEAMS_DATA.get(et.getName())[0], Config.TVT_TEAMS_DATA.get(et.getName())[1], Config.TVT_TEAMS_DATA.get(et.getName())[2], true);
                           et.paralize(true);
                   }
                   closeDoors();
                   Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "Teams have been teleported. Fight begins in 30 seconds.");
                  
                   sleep(30);
                  
                   for (EventTeam et : _teams)
                   {
                           et.paralize(false);
                   }
                   Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "The fight has started!");
                   Announcements.getInstance().gameAnnounceToAll("TvT" + " : " + "The event will last for 5 minute(s).");
                  
                   sleep(250); // tvt time in sec
                  
                   rewardAndClear();
                   openDoors();
                   _state = EventState.INACTIVE;
                  
                   EventManager.getInstance().setCurrentEvent(null);
           }
          
           public void auraCheck()
           {
                   int i = 1;
                  
                   for (EventTeam et : _teams)
                   {
                                                
                           for (L2PcInstance p : et.getPlayers())
                           {
                            p.setTeam(i++);
                            p.broadcastCharInfo();
                           }
                   }
                          
                          
         }
           private void openDoors()
           {
                   if (_doors.isEmpty())
                   {
                           for (int i : Config.TVT_DOORS)
                           {
                                   L2DoorInstance door = DoorTable.getInstance().getDoor(i);
                                   door.openMe();
                           }
                   }
                   else
                   {
                           for (L2DoorInstance door : _doors)
                           {
                                   door.deleteMe();
                           }
                  }
           }
           
           private static void closeDoors()
           {
                   for (int i : Config.TVT_DOORS)
                   {
                           L2DoorInstance door = DoorTable.getInstance().getDoor(i);
                           door.closeMe();
                   }
           }
          
           public void rewardAndClear()
           {
                   int i = 0;
                   EventTeam winner = null;
                  
                   for (EventTeam et : _teams)
                   {
                           et.teleportTeam(82698, 148638, -3473, true);
                          
                           for (L2PcInstance p : et.getPlayers())
                           {
                                   EventCommons.getInstance().removePlayer(p);
                           }
                          
                           if (et.getPoints() > i)
                           {
                                   i = et.getPoints();
                                  winner = et;
                          }
                   }
                  
                   if (winner != null)
                   {
                           for (int ii : Config.TVT_EVENT_REWARDS.keySet())
                           {
                                   winner.rewardTeam(ii, Config.TVT_EVENT_REWARDS.get(ii));
                           }
                  
                           Announcements.announceToAll(winner.getName() + " team has won the event.");
                   }
                   else
                           Announcements.announceToAll("TvT" + " : " + "Event ended with no winner.");
                   return;
           }
          
           public boolean check()
           {
                   if (EventCommons.getInstance().getRegisteredPlayersSize(TvTEvent.class) < Config.TVT_TEAMS_DATA.size() * 1)
                   {
                           Announcements.announceToAll("The event has been canceled due to lack of participants.");
                           EventCommons.getInstance().removeRegisteredPlayers(TvTEvent.class);
                           _state = EventState.INACTIVE;
                           return false;
                   }
                  
                   return true;
           }
          
           public void split()
           {
                   int i = Config.TVT_TEAMS_DATA.size() - 1;
                   LinkedList<LinkedList<L2PcInstance>> temp = new LinkedList<>();
                  
                   for (int ii = Config.TVT_TEAMS_DATA.size(); ii > 0; ii--)
                   {
                           LinkedList<L2PcInstance> t = new LinkedList<>();
                           temp.add(t);
                   }
                  
                   for (L2PcInstance p : EventCommons.getInstance().getRegisteredPlayers(TvTEvent.class))
                   {
                           temp.get(i).add(p);
                           i--;
                          
                           if (i == -1)
                           {
                                   i = Config.TVT_TEAMS_DATA.size();
                           }
                          
                           EventCommons.getInstance().addPlayer(p, this);
                   }
                  
                   for (String s : Config.TVT_TEAMS_DATA.keySet())
                   {
                           EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
                           {
                                   Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
                           });
                           temp.remove(temp.getLast());
                          
                           _teams.add(et);
                   }
           }
          
           private static void sleep(int seconds)
           {
                   try
                   {
                           Thread.sleep(seconds * 1000);
                   }
                   catch (InterruptedException e)
                   {
                           e.printStackTrace();
                  }
           }
          
           @Override
           public EventState getState()
           {
                   return _state;
           }
          
           @Override
           public String getTimes()
           {
                   return Config.TVT_EVENT_TIMES;
           }
          
           @Override
           public int getId()
           {
                   return 1;
           }
    }
    21 Spalio 2014 - 19:26 / #1
  2. 
  3. Atsijungęs

    povis111

    Pranešimai: 0

    Geriau pati void setTeam(int) numesk is pc instances, nes UserInfo ir CharInfo failuose derinas ta aura. Juose tikrina tikriausiai pagal int getTeam() ir ziuri skaičiu, surask viska kur PcInstancej panaudotas skaicius kuri keicia setTeam. Kitaip tariant tu prikuri kiekvienam zaidejui po komanda, bent is pirmo zvilgsnio toks vaizdas (i++).
    21 Spalio 2014 - 23:43 / #2
  4. 
  5. Atsijungęs

    Jeppi

    Pranešimai: 0

    Void radau, hmm bet kad skaiciu parinktu nerandu. Pvz ant duel sistemos playerA setteam(0) ir playerB setTeam(1)padaryta.
    public void setTeam(int team)
    	{
    		_team = team;
    	}
    	
    	public int getTeam()
    	{
    		return _team;
    	}
    22 Spalio 2014 - 14:44 / #3
  6. 
  7. Atsijungęs

    povis111

    Pranešimai: 0

    
    public EventTeam(List<L2PcInstance> players, String name, int points, int[] respawnLoc)
           {
                   _players = players;
                   _name = name;
                   _points = points;
                   _respawnLoc = respawnLoc;
                  
                   for (L2PcInstance p : _players)
                   {
                           p.setEventTeam(this);
                   }
           }
    
    Idomiai padarė, pcinstancej saugo EventTeam objekta...
    krc daryk taip :D
    
    public EventTeam(List<L2PcInstance> players, String name, int points, int[] respawnLoc, int team)
           {
                   _players = players;
                   _name = name;
                   _points = points;
                   _respawnLoc = respawnLoc;
                  
                   for (L2PcInstance p : _players)
                   {
                           p.setEventTeam(this);
                           p.setTeam(team);
                   }
           }
    

    ir tose vietose kur naudoja new EventTeam(List players, String name, int points, int[] respawnLoc, int team)
    ant vieno listo dek int team 0, o ant kito 1. turetu paeit :)
    22 Spalio 2014 - 16:51 / #4
  8. 
  9. Atsijungęs

    Jeppi

    Pranešimai: 0

    Blecha neina pridet dar vieno int, kad imtu is configo.

    public static HashMap<String, int[]> TVT_TEAMS_DATA = new HashMap<>();


    String tvt_teams_data = events.getProperty("TvtTeamsData", "Good_0,0,0;Evil_0,0,0");
    			String[] ttd_splitted = tvt_teams_data.split(";");
    			for (String s : ttd_splitted)
    			 {
    			 String[] ss = s.split("_");
    			String name = ss[0];
    			 String[] sss = ss[1].split(",");
    			int x = Integer.parseInt(sss[0]);
    			int y = Integer.parseInt(sss[1]);
    			int z = Integer.parseInt(sss[2]);
    
    			
    			TVT_TEAMS_DATA.put(name, new int[] { x, y, z });
    			}

    for (String s : Config.TVT_TEAMS_DATA.keySet())
                   {
    					EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
                           {
                                   Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
                           }, i);
                           temp.remove(temp.getLast());
                          
                           _teams.add(et);
                   }


    Jei i Hasmap pridedu dar viena int[] , meta erorr
    Paskutinį kartą redagavo: Jeppi 22 Spalio 2014 - 18:22
    22 Spalio 2014 - 18:19 / #5
  10. 
  11. Atsijungęs

    povis111

    Pranešimai: 0

    matyt nesupratai manęs... is kur tas "i" atsiranda new EventTeam() gale? :D
    daryk taip
    
    int t = 0;
    for (String s : Config.TVT_TEAMS_DATA.keySet())
                   {
    			EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]{ Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2] }, t++);
                           temp.remove(temp.getLast());
                          
                           _teams.add(et);
                   }
    

    Dar galetum parodyt kas per objektas "temp", nes panasu, kad skirtas komandu masyvams.
    Paskutinį kartą redagavo: povis111 22 Spalio 2014 - 20:57
    22 Spalio 2014 - 20:56 / #6
  12. 
  13. Atsijungęs

    Jeppi

    Pranešimai: 0

    Tuoj bandau :D

    Va tas temp
     public void split()
           {
                   int i = Config.TVT_TEAMS_DATA.size() - 1;
                   LinkedList<LinkedList<L2PcInstance>> temp = new LinkedList<>();
                  
                   for (int ii = Config.TVT_TEAMS_DATA.size(); ii > 0; ii--)
                   {
                           LinkedList<L2PcInstance> t = new LinkedList<>();
                           temp.add(t);
                   }
                  
                   for (L2PcInstance p : EventCommons.getInstance().getRegisteredPlayers(TvTEvent.class))
                   {
                           temp.get(i).add(p);
                           i--;
                          
                           if (i == -1)
                           {
                                   i = Config.TVT_TEAMS_DATA.size();
                           }
                          
                           EventCommons.getInstance().addPlayer(p, this);
                   }
                   int t = 0;
                   for (String s : Config.TVT_TEAMS_DATA.keySet())
                	   {
                           EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
                           {
                                   Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
                           }, t++);
                          temp.remove(temp.getLast());
                          
                          _teams.add(et);
                   }
           }
          
    Paskutinį kartą redagavo: Jeppi 22 Spalio 2014 - 21:40
    22 Spalio 2014 - 21:39 / #7
  14. 
  15. Atsijungęs

    povis111

    Pranešimai: 0

    manyciau tures veikt jau :D
    22 Spalio 2014 - 21:47 / #8
  16. 
  17. Atsijungęs

    Jeppi

    Pranešimai: 0

    Eina sau neveikai kaip turi dar :D Ant vienos komandos uzmeta aura ir nuteleportuoja, o kita lieka stovet ir auros nemeta. Na susibugina :)

    int t = 0;
                   for (String s : Config.TVT_TEAMS_DATA.keySet())
                	   {
                           EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
                           {
                                   Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
                           }, t++);



     public EventTeam(List<L2PcInstance> players, String name, int points, int[] respawnLoc, int t)
           {
                   _players = players;
                   _name = name;
                   _points = points;
                   _respawnLoc = respawnLoc;
                  
                   for (L2PcInstance p : _players)
                   {
                           p.setEventTeam(this);
                           p.setTeam(t);
                   }
           }

    Kaip ir gerai viska idejau.
    Paskutinį kartą redagavo: Jeppi 22 Spalio 2014 - 21:50
    22 Spalio 2014 - 21:49 / #9
  18. 
  19. Atsijungęs

    povis111

    Pranešimai: 0

    kaip ir turetu veikt sakyciau. pabandykim padebugint.
    
    for (String s : Config.TVT_TEAMS_DATA.keySet())
                	   {
                           System.out.println("Masyvo zaidejai dedami tarp komandos " + s + " su komand. sk. " + t + " ir dydziu " + temp.getLast().size());
                           EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
                           {
                                   Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
                           }, t++);
    


    
    public EventTeam(List<L2PcInstance> players, String name, int points, int[] respawnLoc, int t)
           {
                   _players = players;
                   _name = name;
                   _points = points;
                   _respawnLoc = respawnLoc;
                  
                   for (L2PcInstance p : _players)
                   {
                           System.out.println("zaidejas " + p.getName() + " i komanda " + name + " su nr " + t);
                           p.setEventTeam(this);
                           p.setTeam(t);
                   }
           }
    
    22 Spalio 2014 - 22:22 / #10