Prohibit parameter assignments.

This commit is contained in:
MobiusDevelopment
2020-05-10 03:29:34 +00:00
parent 2d73110d15
commit 33bbf97afb
1756 changed files with 12542 additions and 10025 deletions

View File

@@ -897,7 +897,7 @@ public class Valakas extends Quest
}
}
public void callSkillAI(NpcInstance npc, Creature c2, Skill skill)
public void callSkillAI(NpcInstance npc, Creature creature, Skill skill)
{
final QuestTimer timer = getQuestTimer("launch_random_skill", npc, null);
if (npc == null)
@@ -914,16 +914,18 @@ public class Valakas extends Quest
return;
}
if ((c2 == null) || c2.isDead() || (timer == null))
Creature currentTarget = creature;
if ((currentTarget == null) || currentTarget.isDead() || (timer == null))
{
c2 = getRandomTarget(npc); // just in case if hate AI fail
currentTarget = getRandomTarget(npc); // just in case if hate AI fail
if (timer == null)
{
startQuestTimer("launch_random_skill", 500, npc, null, true);
return;
}
}
final Creature target = c2;
final Creature target = currentTarget;
if ((target == null) || target.isDead())
{
return;

View File

@@ -179,7 +179,7 @@ public class NewbieHelper extends Quest
}
String htmltext = event;
player = qs1.getPlayer();
// player = qs1.getPlayer();
final int ex = qs2.getInt("Ex");
final int classId = qs1.getPlayer().getClassId().getId();
@@ -241,6 +241,7 @@ public class NewbieHelper extends Quest
}
}
}
return htmltext;
}

View File

@@ -36,7 +36,7 @@ import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
public class SummonMinions extends Quest
{
private static int HasSpawned;
private static int hasSpawned;
private static Set<Integer> myTrackingSet = new CopyOnWriteArraySet<>(); // Used to track instances of npcs
private final Map<Integer, List<PlayerInstance>> _attackersList = new ConcurrentHashMap<>();
private static final Map<Integer, Integer[]> MINIONS = new HashMap<>();
@@ -148,20 +148,22 @@ public class SummonMinions extends Quest
{
final int npcId = npc.getNpcId();
final int npcObjId = npc.getObjectId();
if (MINIONS.containsKey(npcId))
{
if (!myTrackingSet.contains(npcObjId)) // this allows to handle multiple instances of npc
{
myTrackingSet.add(npcObjId);
HasSpawned = npcObjId;
hasSpawned = npcObjId;
}
if (HasSpawned == npcObjId)
if (hasSpawned == npcObjId)
{
if ((npcId == 22030) || (npcId == 22032) || (npcId == 22038)) // mobs that summon minions only on certain hp
{
if (npc.getStatus().getCurrentHp() < (npc.getMaxHp() / 2))
{
HasSpawned = 0;
hasSpawned = 0;
if (Rnd.get(100) < 33) // mobs that summon minions only on certain chance
{
final Integer[] minions = MINIONS.get(npcId);
@@ -177,13 +179,15 @@ public class SummonMinions extends Quest
}
else if ((npcId == 22257) || (npcId == 22258) || (npcId == 22259) || (npcId == 22260) || (npcId == 22261) || (npcId == 22262) || (npcId == 22263) || (npcId == 22264) || (npcId == 22265) || (npcId == 22266))
{
PlayerInstance currentAttacker = attacker;
if (isPet)
{
attacker = attacker.getPet().getOwner();
currentAttacker = attacker.getPet().getOwner();
}
if (attacker.getParty() != null)
if (currentAttacker.getParty() != null)
{
for (PlayerInstance member : attacker.getParty().getPartyMembers())
for (PlayerInstance member : currentAttacker.getParty().getPartyMembers())
{
if (_attackersList.get(npcObjId) == null)
{
@@ -200,30 +204,30 @@ public class SummonMinions extends Quest
else if (_attackersList.get(npcObjId) == null)
{
final List<PlayerInstance> player = new ArrayList<>();
player.add(attacker);
player.add(currentAttacker);
_attackersList.put(npcObjId, player);
}
else if (!_attackersList.get(npcObjId).contains(attacker))
else if (!_attackersList.get(npcObjId).contains(currentAttacker))
{
_attackersList.get(npcObjId).add(attacker);
_attackersList.get(npcObjId).add(currentAttacker);
}
if (((attacker.getParty() != null) && (attacker.getParty().getMemberCount() > 2)) || (_attackersList.get(npcObjId).size() > 2)) // Just to make sure..
if (((currentAttacker.getParty() != null) && (currentAttacker.getParty().getMemberCount() > 2)) || (_attackersList.get(npcObjId).size() > 2)) // Just to make sure..
{
HasSpawned = 0;
hasSpawned = 0;
final Integer[] minions = MINIONS.get(npcId);
for (Integer minion : minions)
{
final Attackable newNpc = (Attackable) addSpawn(minion, npc.getX() + Rnd.get(-150, 150), npc.getY() + Rnd.get(-150, 150), npc.getZ(), 0, false, 0);
newNpc.setRunning();
newNpc.addDamageHate(attacker, 0, 999);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
newNpc.addDamageHate(currentAttacker, 0, 999);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, currentAttacker);
}
}
}
else
// mobs without special conditions
else // mobs without special conditions
{
HasSpawned = 0;
hasSpawned = 0;
final Integer[] minions = MINIONS.get(npcId);
if (npcId != 20767)
{
@@ -249,10 +253,12 @@ public class SummonMinions extends Quest
}
}
}
if (_attackersList.get(npcObjId) != null)
{
_attackersList.get(npcObjId).clear();
}
return super.onAttack(npc, attacker, damage, isPet);
}
@@ -261,10 +267,12 @@ public class SummonMinions extends Quest
{
final int npcId = npc.getNpcId();
final int npcObjId = npc.getObjectId();
if (MINIONS.containsKey(npcId))
{
myTrackingSet.remove(npcObjId);
}
return super.onKill(npc, killer, isPet);
}

View File

@@ -164,8 +164,8 @@ public class Q242_PossessorOfAPreciousSoul extends Quest
// Spawn Fallen Unicorn
else if (event.equals("sfu"))
{
npc = addSpawn(FALLEN_UNICORN, 85884, -76588, -3470, 0, false, 0);
npc.getSpawn().startRespawn();
final NpcInstance unicorn = addSpawn(FALLEN_UNICORN, 85884, -76588, -3470, 0, false, 0);
unicorn.getSpawn().startRespawn();
return null;
}

View File

@@ -408,119 +408,144 @@ public class Q335_TheSongOfTheHunter extends Quest
return event;
}
String htmltext = event;
final int state = st.getState();
if ("30744_03.htm".equalsIgnoreCase(event) && (state == 1))
if ("30744_03.htm".equals(htmltext))
{
if (st.getQuestItemsCount(TEST_INSTRUCTIONS1) == 0)
if (state == 1)
{
st.giveItems(TEST_INSTRUCTIONS1, 1);
if (st.getQuestItemsCount(TEST_INSTRUCTIONS1) == 0)
{
st.giveItems(TEST_INSTRUCTIONS1, 1);
}
st.setState(State.STARTED);
st.set("cond", "1");
st.playSound("ItemSound.quest_accept");
}
st.setState(State.STARTED);
st.set("cond", "1");
st.playSound("ItemSound.quest_accept");
}
else if ("30744_09.htm".equalsIgnoreCase(event) && (state == 2))
else if ("30744_09.htm".equals(htmltext))
{
if (GetCurrentRequest(st, REQUESTS1) != null)
if (state == 2)
{
return "30744_09a.htm";
if (GetCurrentRequest(st, REQUESTS1) != null)
{
return "30744_09a.htm";
}
if (st.getQuestItemsCount(TEST_INSTRUCTIONS2) == 0)
{
st.playSound("ItemSound.quest_middle");
st.giveItems(TEST_INSTRUCTIONS2, 1);
}
}
if (st.getQuestItemsCount(TEST_INSTRUCTIONS2) == 0)
}
else if ("30744_16.htm".equals(htmltext))
{
if (state == 2)
{
if (st.getQuestItemsCount(LAUREL_LEAF_PIN) >= 20)
{
st.giveItems(57, 20000);
htmltext = "30744_17.htm";
}
st.playSound("ItemSound.quest_finish");
st.exitQuest(true);
}
}
else if ("30746_03.htm".equals(htmltext))
{
if (state == 2)
{
if ((st.getQuestItemsCount(CIRCLE_HUNTER_LICENSE1) == 0) && (st.getQuestItemsCount(CIRCLE_HUNTER_LICENSE2) == 0))
{
return null;
}
if (st.getQuestItemsCount(CYBELLINS_DAGGER) == 0)
{
st.giveItems(CYBELLINS_DAGGER, 1);
}
if (st.getQuestItemsCount(CYBELLINS_REQUEST) == 0)
{
st.giveItems(CYBELLINS_REQUEST, 1);
}
for (int i : Q_BLOOD_CRYSTAL)
{
st.takeItems(i, -1);
}
st.playSound("ItemSound.quest_middle");
st.giveItems(TEST_INSTRUCTIONS2, 1);
st.giveItems(Q_BLOOD_CRYSTAL[1], 1);
}
}
else if ("30744_16.htm".equalsIgnoreCase(event) && (state == 2))
else if ("30746_06.htm".equals(htmltext))
{
if (st.getQuestItemsCount(LAUREL_LEAF_PIN) >= 20)
if (state == 2)
{
st.giveItems(57, 20000);
event = "30744_17.htm";
}
st.playSound("ItemSound.quest_finish");
st.exitQuest(true);
}
else if ("30746_03.htm".equalsIgnoreCase(event) && (state == 2))
{
if ((st.getQuestItemsCount(CIRCLE_HUNTER_LICENSE1) == 0) && (st.getQuestItemsCount(CIRCLE_HUNTER_LICENSE2) == 0))
{
return null;
}
if (st.getQuestItemsCount(CYBELLINS_DAGGER) == 0)
{
st.giveItems(CYBELLINS_DAGGER, 1);
}
if (st.getQuestItemsCount(CYBELLINS_REQUEST) == 0)
{
st.giveItems(CYBELLINS_REQUEST, 1);
}
for (int i : Q_BLOOD_CRYSTAL)
{
st.takeItems(i, -1);
}
st.playSound("ItemSound.quest_middle");
st.giveItems(Q_BLOOD_CRYSTAL[1], 1);
}
else if ("30746_06.htm".equalsIgnoreCase(event) && (state == 2))
{
if (!Blood_Crystal2Adena(st, Get_Blood_Crystal_Level(st)))
{
return null;
if (!Blood_Crystal2Adena(st, Get_Blood_Crystal_Level(st)))
{
return null;
}
}
}
else if ("30746_10.htm".equalsIgnoreCase(event) && (state == 2))
else if ("30746_10.htm".equals(htmltext))
{
st.takeItems(CYBELLINS_DAGGER, -1);
st.takeItems(CYBELLINS_REQUEST, -1);
for (int i : Q_BLOOD_CRYSTAL)
if (state == 2)
{
st.takeItems(i, -1);
st.takeItems(CYBELLINS_DAGGER, -1);
st.takeItems(CYBELLINS_REQUEST, -1);
for (int i : Q_BLOOD_CRYSTAL)
{
st.takeItems(i, -1);
}
}
}
else if ("30745_02.htm".equalsIgnoreCase(event) && (state == 2))
else if ("30745_02.htm".equals(htmltext))
{
if (st.getQuestItemsCount(TEST_INSTRUCTIONS2) > 0)
if (state == 2)
{
return "30745_03.htm";
if (st.getQuestItemsCount(TEST_INSTRUCTIONS2) > 0)
{
return "30745_03.htm";
}
}
}
else if ("30745_05b.htm".equalsIgnoreCase(event) && (state == 2))
else if ("30745_05b.htm".equals(htmltext))
{
if (st.getQuestItemsCount(LAUREL_LEAF_PIN) > 0)
if (state == 2)
{
st.takeItems(LAUREL_LEAF_PIN, 1);
}
for (Request r : REQUESTS1)
{
st.takeItems(r.request_id, -1);
st.takeItems(r.request_item, -1);
}
for (Request r : REQUESTS2)
{
st.takeItems(r.request_id, -1);
st.takeItems(r.request_item, -1);
if (st.getQuestItemsCount(LAUREL_LEAF_PIN) > 0)
{
st.takeItems(LAUREL_LEAF_PIN, 1);
}
for (Request r : REQUESTS1)
{
st.takeItems(r.request_id, -1);
st.takeItems(r.request_item, -1);
}
for (Request r : REQUESTS2)
{
st.takeItems(r.request_id, -1);
st.takeItems(r.request_item, -1);
}
}
}
else
else if (state == 2)
{
if ("30745-list1".equalsIgnoreCase(event) && (state == 2))
if ("30745-list1".equals(htmltext))
{
GenList(st);
return FormatList(st, REQUESTS1);
}
if ("30745-list2".equalsIgnoreCase(event) && (state == 2))
if ("30745-list2".equals(htmltext))
{
GenList(st);
return FormatList(st, REQUESTS2);
}
if (event.startsWith("30745-request-") && (state == 2))
if (htmltext.startsWith("30745-request-"))
{
event = event.replaceFirst("30745-request-", "");
htmltext = htmltext.replaceFirst("30745-request-", "");
int requestId;
try
{
requestId = Integer.parseInt(event);
requestId = Integer.parseInt(htmltext);
}
catch (Exception e)
{
@@ -534,7 +559,8 @@ public class Q335_TheSongOfTheHunter extends Quest
return "30745-" + requestId + ".htm";
}
}
return event;
return htmltext;
}
@Override
@@ -975,11 +1001,12 @@ public class Q335_TheSongOfTheHunter extends Quest
return result;
}
private static int[] unpackInt(int a, int bits)
private static int[] unpackInt(int value, int bits)
{
final int m = 32 / bits;
final int mval = (int) Math.pow(2.0, bits);
final int[] result = new int[m];
int a = value;
for (int i = m; i > 0; --i)
{
final int next = a;

View File

@@ -437,10 +437,11 @@ public class Q384_WarehouseKeepersPastime extends Quest
{
final String[] playerArray = st.getString("playerArray").split("");
final String[] board = st.getString("board").split("");
String result = htmltext;
for (int i = 1; i < 10; i++)
{
htmltext = htmltext.replace("<?Cell" + i + "?>", (Util.contains(playerArray, board[i])) ? board[i] : "?");
result = result.replace("<?Cell" + i + "?>", (Util.contains(playerArray, board[i])) ? board[i] : "?");
}
return htmltext;
return result;
}
}