Jump to content
  • 0

Random Finght To Frozen


Question

Posted

Hi everyone i take Random Fight event from frozen and sometimes not teleport in, ppl just walking whit that aura, please help if you can.

 

/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/
package com.l2jfrozen.gameserver.model.entity.event;

import java.util.concurrent.CopyOnWriteArrayList;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.entity.Announcements;
import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.random.Rnd;

/**
* @author RnP PC
*
*/
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/


/**
* @author lioy
*
*/
public class RandomFight
{
public static enum State{INACTIVE,REGISTER,LOADING,FIGHT}
public static State state = State.INACTIVE;

public static CopyOnWriteArrayList players = new CopyOnWriteArrayList<>();

protected void openRegistrations()
{
state = State.REGISTER;
Announcements.getInstance().announceToAll("Winner reward: " + ItemTable.getInstance().getTemplate(Config.RANDOM_FIGHT_REWARD_ID).getName() + "!");
Announcements.getInstance().announceToAll("Random Fight Event will start in 10 minute.");
Announcements.getInstance().announceToAll("To register write ?register");
Announcements.getInstance().announceToAll("If you wanna unregister write ?unregister");
ThreadPoolManager.getInstance().scheduleGeneral(new checkRegist(), 60000 );
}

protected void checkRegistrations()
{
state=State.LOADING;

if(players.size() < 2)
{
// Announcements.getInstance().announceToAll("Random Fight Event will not start cause of no many partitipations, we are sorry.");
// clean();
// return;
for(L2PcInstance player : L2World.getInstance().getAllPlayers())
{
if(!players.contains(player) && !player.isInOlympiadMode() && !Olympiad.getInstance().isRegistered(player) && !player.isDead()
&& player.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_NONE && !player.isProcessingTransaction() && !player.inObserverMode())
players.add(player);
}
if(players.size() < 2)
{
Announcements.getInstance().announceToAll("Random Fight Event will not start cause of no many partitipations, we are sorry.");
clean();
return;
}
}
Announcements.getInstance().announceToAll("Amount of players Registed: "+players.size());
Announcements.getInstance().announceToAll("2 Random players will be choosen in 30 seconds!");
Announcements.getInstance().announceToAll("If you wanna unregister write ?unregister");
ThreadPoolManager.getInstance().scheduleGeneral(new pickPlayers(), 30000 );
}


protected void pickPlayers()
{
if(players.size() < 2)
{
Announcements.getInstance().announceToAll("Random Fight Event aborted because no many partitipations, we are sorry.");
clean();
return;
}

for(L2PcInstance p : players)
if(p.isInOlympiadMode() || Olympiad.getInstance().isRegistered(p))
{
players.remove(p);
p.sendMessage("You automatically left from event because of your olympiad obligations.");
}


L2PcInstance p1 = players.get(Rnd.get(players.size()));
L2PcInstance p2 = players.get(Rnd.get(players.size()));

while(p1==p2)
p2=players.get(Rnd.get(players.size()));

players.clear();
players.add(p1);
players.add(p2);

Announcements.getInstance().announceToAll("Players selected: "+players.get(0).getName()+" || "+players.get(1).getName());
Announcements.getInstance().announceToAll("Players will be teleported in 15 seconds");
ThreadPoolManager.getInstance().scheduleGeneral(new teleportPlayers(), 15000);
}


protected void teleport()
{
if(players.size() < 2)
{
Announcements.getInstance().announceToAll("Random Fight Event aborted because no many partitipations, we are sorry.");
clean();
return;
}
Announcements.getInstance().announceToAll("Players teleported!");

players.get(0).teleToLocation(113474,15552,3968);
players.get(1).teleToLocation(112990,15489,3968);
players.get(0).setTeam(1);
players.get(1).setTeam(2);

//para,etc

players.get(0).sendMessage("Fight will begin in 15 seconds!");
players.get(1).sendMessage("Fight will begin in 15 seconds!");

ThreadPoolManager.getInstance().scheduleGeneral(new fight(), 15000);
}

protected void startFight()
{

if(players.isEmpty() || players.size() < 2)
{
Announcements.getInstance().announceToAll("One of the players isn't online, event aborted we are sorry!");
clean();
return;
}

state = State.FIGHT;

Announcements.getInstance().announceToAll("FIGHT STARTED!");
try{
for(L2PcInstance p : players){
p.updatePvPFlag(1);
p.sendPacket(new ExShowScreenMessage("Start Fight!",750));
Thread.sleep(750);
p.sendPacket(new ExShowScreenMessage("Kill your enemy!",750));
Thread.sleep(750);
p.sendPacket(new ExShowScreenMessage("Reveiwe reward Top-Grade Life Stone: level 76 ",750));
}
}catch(Exception e){}
ThreadPoolManager.getInstance().scheduleGeneral(new checkLast(), 120000 );
}

protected void lastCheck()
{
if(state == State.FIGHT)
{
if(players.size() 0)
p.setKarma(0);
p.updatePvPFlag(0);
p.broadcastUserInfo();
p.teleToLocation(82698,148638,-3473);

}
}

public static void clean()
{

if(state == State.FIGHT)
for(L2PcInstance p : players)
p.setTeam(0);


players.clear();
state = State.INACTIVE;

}

protected RandomFight()
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Event(), 60000 * Config.EVERY_MINUTES , 60000 * Config.EVERY_MINUTES);
}

public static RandomFight getInstance()
{
return SingletonHolder._instance;
}

private static class SingletonHolder
{
protected static final RandomFight _instance = new RandomFight();
}

protected class Event implements Runnable
{
@Override
public void run()
{
if(state == State.INACTIVE)
openRegistrations();
}

}

protected class checkRegist implements Runnable
{

@Override
public void run()
{
checkRegistrations();
}

}

protected class pickPlayers implements Runnable
{
@Override
public void run()
{
pickPlayers();
}

}

protected class teleportPlayers implements Runnable
{
@Override
public void run()
{
teleport();
}

}

protected class fight implements Runnable
{

@Override
public void run()
{
startFight();
}

}

protected class checkLast implements Runnable
{
@Override
public void run()
{
lastCheck();
}

}
}

That event

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...