Custom Provisional Clan Hall implementation.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<html><body>Greetings, my lord.<br1>
|
||||
I am at your service.<br>
|
||||
<center>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest ClanHallManager expel">Expel an outsider</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest ClanHallManager useFunctions">Clan Hall function</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest ClanHallManager warehouse">Clan Warehouse</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest ClanHallManager manageFunctions">Manage Clan Hall</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest ProvisionalHalls leave">See you later</Button>
|
||||
</center>
|
||||
</body></html>
|
@@ -0,0 +1,9 @@
|
||||
<html><body><br>
|
||||
<font color="LEVEL">[Manage Clan Hall]</font><br>
|
||||
<center>
|
||||
<br><button action="bypass -h Quest ClanHallManager manageFunctions recovery" value="Recovery" width=80 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
<br><button action="bypass -h Quest ClanHallManager manageFunctions other" value="Other" width=80 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
<br>
|
||||
<br><button action="bypass -h Quest ClanHallManager index" value="Main Screen" width=80 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
</center>
|
||||
</body></html>
|
@@ -62,6 +62,7 @@ public class ClanHallManager extends AbstractNpcAI
|
||||
36721, 36723, 36725, 36727, // Gludio Outskirts
|
||||
36729, 36731, 36733, 36735, // Dion Outskirts
|
||||
36737, 36739, // Floran Village
|
||||
33360, // Talking Island
|
||||
};
|
||||
// @formatter:on
|
||||
// Misc
|
||||
@@ -118,7 +119,21 @@ public class ClanHallManager extends AbstractNpcAI
|
||||
{
|
||||
case "index":
|
||||
{
|
||||
htmltext = isOwningClan(player, npc) ? "ClanHallManager-01.html" : "ClanHallManager-03.html";
|
||||
if (isOwningClan(player, npc))
|
||||
{
|
||||
if (npc.getId() == 33360) // Provisional Hall Manager
|
||||
{
|
||||
htmltext = "ClanHallManager-01b.html";
|
||||
}
|
||||
else if (clanHall.getCostFailDay() == 0)
|
||||
{
|
||||
htmltext = "ClanHallManager-01.html";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "ClanHallManager-03.html";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "manageDoors":
|
||||
@@ -257,7 +272,14 @@ public class ClanHallManager extends AbstractNpcAI
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
((MerchantInstance) npc).showBuyWindow(player, Integer.parseInt(npc.getId() + "0" + (itemLevel - 1)));
|
||||
if (npc.getId() == 33360) // Provisional Hall Manager
|
||||
{
|
||||
((MerchantInstance) npc).showBuyWindow(player, Integer.parseInt(clanHall.getResidenceId() + "0" + (itemLevel - 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
((MerchantInstance) npc).showBuyWindow(player, Integer.parseInt(npc.getId() + "0" + (itemLevel - 1)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -289,7 +311,14 @@ public class ClanHallManager extends AbstractNpcAI
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
htmltext = "ClanHallManager-11.html";
|
||||
if (npc.getId() == 33360) // Provisional Hall Manager
|
||||
{
|
||||
htmltext = "ClanHallManager-11b.html";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "ClanHallManager-11.html";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -435,7 +464,11 @@ public class ClanHallManager extends AbstractNpcAI
|
||||
final ClanHall clanHall = npc.getClanHall();
|
||||
if (isOwningClan(player, npc))
|
||||
{
|
||||
if (clanHall.getCostFailDay() == 0)
|
||||
if (npc.getId() == 33360) // Provisional Hall Manager
|
||||
{
|
||||
htmltext = "ClanHallManager-01b.html";
|
||||
}
|
||||
else if (clanHall.getCostFailDay() == 0)
|
||||
{
|
||||
htmltext = "ClanHallManager-01.html";
|
||||
}
|
||||
|
13
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/33359-01.html
vendored
Normal file
13
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/33359-01.html
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<html><body><br><br><br>
|
||||
Ah, hello!<br><br>
|
||||
I am the Clan Hall Gatekeeper, Kerry. It's an honor to serve you.<br>
|
||||
Do you need help with the <font color="FFFB99">Provisional Clan Hall</font>?<br>
|
||||
<br><br>
|
||||
<center>
|
||||
<button action="bypass -h Quest ProvisionalHalls enter" value="Enter the Clan Hall" width=180 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
<br>
|
||||
<button action="bypass -h Quest ProvisionalHalls 33359-03.html" value="Buy a Clan Hall" width=180 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
<br>
|
||||
<button action="bypass -h Quest ProvisionalHalls 33359-02.html" value="Learn more" width=180 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
<br>
|
||||
</body></html>
|
12
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/33359-02.html
vendored
Normal file
12
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/33359-02.html
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<html><body>
|
||||
<br><br>
|
||||
<center>
|
||||
Participant,<br>
|
||||
<center>
|
||||
Aw, sorry, but you didn't win a <font color="FFFB99">Provisional Clan Hall</font>.<br><br>
|
||||
The auction takes place every 2 weeks,<br>
|
||||
between 00:01 Saturday and 23:59 Sunday.<br>
|
||||
<br>
|
||||
<center>
|
||||
Better luck at the next auction!<br>
|
||||
</body></html>
|
6
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/33359-03.html
vendored
Normal file
6
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/33359-03.html
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<html><body><br><br><br>
|
||||
The <font color="FFFB99">Provisional Clan Hall</font> will cost you 50.000.000 adena, are you sure?<br>
|
||||
<br><br>
|
||||
<center>
|
||||
<button action="bypass -h Quest ProvisionalHalls buy" value="Buy the Clan Hall" width=180 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
|
||||
</body></html>
|
199
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/ProvisionalHalls.java
vendored
Normal file
199
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/ProvisionalHalls/ProvisionalHalls.java
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.ProvisionalHalls;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Custom implementation for Provisional Clan Halls.
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ProvisionalHalls extends AbstractNpcAI
|
||||
{
|
||||
// NPCs
|
||||
private static final int KERRY = 33359;
|
||||
private static final int MAID = 33360;
|
||||
// Misc
|
||||
private static final int HALL_PRICE = 50000000;
|
||||
private static final long TWO_WEEKS = 1209600000;
|
||||
private static final Map<Integer, Location> CLAN_HALLS = new LinkedHashMap<>();
|
||||
static
|
||||
{
|
||||
CLAN_HALLS.put(187, new Location(-122200, -116552, -5798, 1779));
|
||||
CLAN_HALLS.put(186, new Location(-122264, -122392, -5870, 15229));
|
||||
CLAN_HALLS.put(188, new Location(-121864, -111240, -6014, 30268));
|
||||
CLAN_HALLS.put(190, new Location(-117080, -116551, -5771, 1779));
|
||||
CLAN_HALLS.put(189, new Location(-117000, -122052, -5845, 15229));
|
||||
CLAN_HALLS.put(191, new Location(-117074, -111237, -5989, 30268));
|
||||
CLAN_HALLS.put(193, new Location(-111717, -116550, -5773, 1779));
|
||||
CLAN_HALLS.put(192, new Location(-111726, -122378, -5845, 15229));
|
||||
CLAN_HALLS.put(194, new Location(-111158, -111230, -5989, 30268));
|
||||
}
|
||||
private static final String HALL_OWNER_VAR = "PCH_OWNER_";
|
||||
private static final String HALL_TIME_VAR = "PCH_TIME_";
|
||||
private static final String HALL_RESET_VAR = "PCH_RESET_";
|
||||
private static final String HALL_RETURN_VAR = "PCH_RETURN";
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private ProvisionalHalls()
|
||||
{
|
||||
addStartNpc(KERRY);
|
||||
addFirstTalkId(KERRY);
|
||||
addTalkId(KERRY);
|
||||
|
||||
for (int id : CLAN_HALLS.keySet())
|
||||
{
|
||||
final long resetTime = GlobalVariablesManager.getInstance().getLong(HALL_TIME_VAR + id, 0);
|
||||
if (resetTime > 0)
|
||||
{
|
||||
cancelQuestTimers(HALL_RESET_VAR + id);
|
||||
startQuestTimer(HALL_RESET_VAR + id, Math.max(1000, (TWO_WEEKS - (System.currentTimeMillis() - resetTime) - 30000)), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
|
||||
{
|
||||
if ((npc.getId() != KERRY) && (npc.getId() != MAID))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String htmltext = null;
|
||||
if (event.equals("33359-01.html") || event.equals("33359-02.html") || event.equals("33359-03.html"))
|
||||
{
|
||||
htmltext = event;
|
||||
}
|
||||
else if (event.equals("buy"))
|
||||
{
|
||||
synchronized (LOCK)
|
||||
{
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
if ((player.getClan() == null) || (player.getClan().getLeaderId() != player.getObjectId()))
|
||||
{
|
||||
player.sendMessage("You need to be a clan leader in order to proceed.");
|
||||
}
|
||||
else if ((player.getClan().getHideoutId() > 0))
|
||||
{
|
||||
player.sendMessage("You already own a hideout.");
|
||||
}
|
||||
else if ((dayOfWeek != Calendar.SATURDAY) && (dayOfWeek != Calendar.SUNDAY))
|
||||
{
|
||||
htmltext = "33359-02.html";
|
||||
}
|
||||
else if (player.getAdena() < HALL_PRICE)
|
||||
{
|
||||
player.sendMessage("You need " + HALL_PRICE + " adena in order to proceed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dayOfWeek != Calendar.SATURDAY)
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_WEEK, -1);
|
||||
}
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 1);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
for (int id : CLAN_HALLS.keySet())
|
||||
{
|
||||
if ((GlobalVariablesManager.getInstance().getInt(HALL_OWNER_VAR + id, 0) == 0) && ((GlobalVariablesManager.getInstance().getLong(HALL_TIME_VAR + id, 0) + TWO_WEEKS) < System.currentTimeMillis()))
|
||||
{
|
||||
player.reduceAdena("ProvisionalHall", HALL_PRICE, player, true);
|
||||
GlobalVariablesManager.getInstance().set(HALL_OWNER_VAR + id, player.getClanId());
|
||||
GlobalVariablesManager.getInstance().set(HALL_TIME_VAR + id, calendar.getTimeInMillis());
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallById(id);
|
||||
if (clanHall != null)
|
||||
{
|
||||
clanHall.setOwner(player.getClan());
|
||||
}
|
||||
player.sendMessage("Congratulations! You now own a provisional clan hall!");
|
||||
startQuestTimer("RESET_ORCHID_HALL", TWO_WEEKS - (System.currentTimeMillis() - calendar.getTimeInMillis()), null, null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
player.sendMessage("I am sorry, all halls have been taken.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.equals("enter"))
|
||||
{
|
||||
final int playerClanId = player.getClanId();
|
||||
for (Entry<Integer, Location> hall : CLAN_HALLS.entrySet())
|
||||
{
|
||||
if (playerClanId == GlobalVariablesManager.getInstance().getInt(HALL_OWNER_VAR + hall.getKey(), -1))
|
||||
{
|
||||
player.getVariables().set(HALL_RETURN_VAR, player.getX() + "," + player.getY() + "," + player.getZ() + "," + player.getHeading());
|
||||
player.teleToLocation(hall.getValue());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
htmltext = "33359-02.html";
|
||||
}
|
||||
else if (event.equals("leave"))
|
||||
{
|
||||
final String[] location = player.getVariables().getString(HALL_RETURN_VAR, "-112574,256057,-1449,-1").split(",");
|
||||
player.teleToLocation(Integer.parseInt(location[0]), Integer.parseInt(location[1]), Integer.parseInt(location[2]), Integer.parseInt(location[3]));
|
||||
}
|
||||
else if (event.startsWith(HALL_RESET_VAR))
|
||||
{
|
||||
final String id = event.replace(HALL_RESET_VAR, "");
|
||||
if (((GlobalVariablesManager.getInstance().getLong(HALL_TIME_VAR + id, 0) + TWO_WEEKS) - 60000) <= System.currentTimeMillis())
|
||||
{
|
||||
final int clanId = GlobalVariablesManager.getInstance().getInt(HALL_OWNER_VAR + id, 0);
|
||||
if (clanId > 0)
|
||||
{
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallById(Integer.parseInt(id));
|
||||
if (clanHall != null)
|
||||
{
|
||||
clanHall.setOwner(null);
|
||||
}
|
||||
}
|
||||
GlobalVariablesManager.getInstance().remove(HALL_TIME_VAR + id);
|
||||
GlobalVariablesManager.getInstance().remove(HALL_OWNER_VAR + id);
|
||||
}
|
||||
}
|
||||
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(Npc npc, PlayerInstance player)
|
||||
{
|
||||
return npc.getId() + "-01.html";
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new ProvisionalHalls();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user