Sync with L2JServer Jan 26th 2015.

This commit is contained in:
mobius
2015-01-27 01:59:37 +00:00
parent 5d7ab65416
commit bfe682bbe3
63 changed files with 1049 additions and 1306 deletions

View File

@@ -19,10 +19,13 @@
package com.l2jserver.gameserver.model.actor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import com.l2jserver.Config;
@@ -88,10 +91,10 @@ public class L2Attackable extends L2Npc
private boolean _seeded = false;
private L2Seed _seed = null;
private int _seederObjId = 0;
private ItemHolder _harvestItem;
private final AtomicReference<ItemHolder> _harvestItem = new AtomicReference<>();
// Spoil
private int _spoilerObjectId;
private ItemHolder[] _sweepItems;
private final AtomicReference<Collection<ItemHolder>> _sweepItems = new AtomicReference<>();
// Over-hit
private boolean _overhit;
private double _overhitDamage;
@@ -1001,14 +1004,10 @@ public class L2Attackable extends L2Npc
if (isSpoiled())
{
List<ItemHolder> sweepItems = npcTemplate.calculateDrops(DropListScope.CORPSE, this, player);
if ((sweepItems != null) && !sweepItems.isEmpty())
{
_sweepItems = sweepItems.toArray(new ItemHolder[sweepItems.size()]);
}
_sweepItems.set(npcTemplate.calculateDrops(DropListScope.CORPSE, this, player));
}
List<ItemHolder> deathItems = npcTemplate.calculateDrops(DropListScope.DEATH, this, player);
Collection<ItemHolder> deathItems = npcTemplate.calculateDrops(DropListScope.DEATH, this, player);
if (deathItems != null)
{
for (ItemHolder drop : deathItems)
@@ -1156,7 +1155,7 @@ public class L2Attackable extends L2Npc
@Override
public boolean isSweepActive()
{
return _sweepItems != null;
return _sweepItems.get() != null;
}
/**
@@ -1164,10 +1163,11 @@ public class L2Attackable extends L2Npc
*/
public List<L2Item> getSpoilLootItems()
{
final List<L2Item> lootItems = new ArrayList<>();
if (isSweepActive())
final Collection<ItemHolder> sweepItems = _sweepItems.get();
final List<L2Item> lootItems = new LinkedList<>();
if (sweepItems != null)
{
for (ItemHolder item : _sweepItems)
for (ItemHolder item : sweepItems)
{
lootItems.add(ItemTable.getInstance().getTemplate(item.getId()));
}
@@ -1178,21 +1178,17 @@ public class L2Attackable extends L2Npc
/**
* @return table containing all L2ItemInstance that can be spoiled.
*/
public synchronized ItemHolder[] takeSweep()
public Collection<ItemHolder> takeSweep()
{
ItemHolder[] sweep = _sweepItems;
_sweepItems = null;
return sweep;
return _sweepItems.getAndSet(null);
}
/**
* @return table containing all L2ItemInstance that can be harvested.
*/
public synchronized ItemHolder takeHarvest()
public ItemHolder takeHarvest()
{
ItemHolder harvest = _harvestItem;
_harvestItem = null;
return harvest;
return _harvestItem.getAndSet(null);
}
/**
@@ -1436,7 +1432,7 @@ public class L2Attackable extends L2Npc
// Clear all aggro char from list
clearAggroList();
// Clear Harvester reward
_harvestItem = null;
_harvestItem.set(null);
// Clear mod Seeded stat
_seeded = false;
_seed = null;
@@ -1444,7 +1440,7 @@ public class L2Attackable extends L2Npc
// Clear overhit value
overhitEnabled(false);
_sweepItems = null;
_sweepItems.set(null);
resetAbsorbList();
setWalking();
@@ -1534,7 +1530,7 @@ public class L2Attackable extends L2Npc
{
count += diff;
}
_harvestItem = new ItemHolder(_seed.getCropId(), count * Config.RATE_DROP_MANOR);
_harvestItem.set(new ItemHolder(_seed.getCropId(), count * Config.RATE_DROP_MANOR));
}
}

View File

@@ -14455,6 +14455,10 @@ public final class L2PcInstance extends L2Playable
public boolean hasPremiumStatus()
{
if (!Config.PREMIUM_SYSTEM_ENABLED)
{
return false;
}
return _premiumStatus;
}

View File

@@ -19,7 +19,9 @@
package com.l2jserver.gameserver.model.actor.templates;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -552,7 +554,7 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
return dropLists != null ? dropLists.get(dropListScope) : null;
}
public List<ItemHolder> calculateDrops(DropListScope dropListScope, L2Character victim, L2Character killer)
public Collection<ItemHolder> calculateDrops(DropListScope dropListScope, L2Character victim, L2Character killer)
{
List<IDropItem> dropList = getDropList(dropListScope);
if (dropList == null)
@@ -560,10 +562,10 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
return null;
}
List<ItemHolder> calculatedDrops = null;
Collection<ItemHolder> calculatedDrops = null;
for (IDropItem dropItem : dropList)
{
List<ItemHolder> drops = dropItem.calculateDrops(victim, killer);
final Collection<ItemHolder> drops = dropItem.calculateDrops(victim, killer);
if ((drops == null) || drops.isEmpty())
{
continue;
@@ -571,7 +573,7 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
if (calculatedDrops == null)
{
calculatedDrops = new ArrayList<>(drops.size());
calculatedDrops = new LinkedList<>();
}
calculatedDrops.addAll(drops);

View File

@@ -19,7 +19,7 @@
package com.l2jserver.gameserver.model.drops;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
@@ -231,13 +231,10 @@ public class GeneralDropItem implements IDropItem
}
}
// global champions chance multiplier, there is no such option yet
// @formatter:off
/*if (victim.isChampion())
if (victim.isChampion())
{
multiplier *= getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS_CHANCE : Config.L2JMOD_CHAMPION_ADENAS_REWARDS_CHANCE;
}*/
// @formatter:on
multiplier *= Config.L2JMOD_CHAMPION_REWARDS;
}
return (getChance() * multiplier);
}
@@ -247,7 +244,7 @@ public class GeneralDropItem implements IDropItem
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
{
final int levelDifference = victim.getLevel() - killer.getLevel();
final double levelGapChanceToDrop;
@@ -266,48 +263,25 @@ public class GeneralDropItem implements IDropItem
return null;
}
final List<ItemHolder> items = new ArrayList<>(1);
if (Config.L2JMOD_OLD_DROP_BEHAVIOR)
final double chance = getChance(victim, killer);
int successes;
if (!Config.L2JMOD_OLD_DROP_BEHAVIOR)
{
double chance = getChance(victim, killer);
if (Config.L2JMOD_CHAMPION_ENABLE && victim.isChampion() && (getItemId() != Inventory.ADENA_ID))
{
chance *= Config.L2JMOD_CHAMPION_REWARDS;
}
long amount = 0;
if (chance > 100)
{
int chanceOveflow = (int) (chance / 100);
chance = chance % 100;
while (chanceOveflow > 0)
{
amount += Rnd.get(getMin(victim, killer), getMax(victim, killer));
chanceOveflow--;
}
}
if (chance > (Rnd.nextDouble() * 100))
{
amount += Rnd.get(getMin(victim, killer), getMax(victim, killer));
}
if (amount > 0)
{
items.add(new ItemHolder(getItemId(), amount));
}
successes = chance > (Rnd.nextDouble() * 100) ? 1 : 0;
}
else
{
if (getChance(victim, killer) > (Rnd.nextDouble() * 100))
{
final long amount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
items.add(new ItemHolder(getItemId(), amount));
}
successes = (int) (chance / 100);
successes += (chance % 100) > (Rnd.nextDouble() * 100) ? 1 : 0;
}
return items;
if (successes > 0)
{
final Collection<ItemHolder> items = new ArrayList<>(1);
items.add(new ItemHolder(getItemId(), Rnd.get(getMin(victim, killer), getMax(victim, killer)) * successes));
return items;
}
return null;
}
}

View File

@@ -19,6 +19,7 @@
package com.l2jserver.gameserver.model.drops;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -104,9 +105,9 @@ public class GroupedGeneralDropItem implements IDropItem
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
{
int levelDifference = victim.getLevel() - killer.getLevel();
final int levelDifference = victim.getLevel() - killer.getLevel();
double chanceModifier;
if (victim instanceof L2RaidBossInstance)
{
@@ -124,61 +125,29 @@ public class GroupedGeneralDropItem implements IDropItem
}
}
if ((getChance(victim, killer) * chanceModifier) > (Rnd.nextDouble() * 100))
final double chance = getChance(victim, killer) * chanceModifier;
int successes;
if (!Config.L2JMOD_OLD_DROP_BEHAVIOR)
{
final List<ItemHolder> items = new ArrayList<>(1);
long amount = 0;
double totalChance = 0;
double random = (Rnd.nextDouble() * 100);
double chance = 0;
if (Config.L2JMOD_OLD_DROP_BEHAVIOR)
successes = chance > (Rnd.nextDouble() * 100) ? 1 : 0;
}
else
{
successes = (int) (chance / 100);
successes += (chance % 100) > (Rnd.nextDouble() * 100) ? 1 : 0;
}
double totalChance = 0;
final double random = (Rnd.nextDouble() * 100);
for (GeneralDropItem item : getItems())
{
// Grouped item chance rates should not be modified.
totalChance += item.getChance();
if (totalChance > random)
{
for (GeneralDropItem item : getItems())
{
// Grouped item chance rates should not be modified.
totalChance += item.getChance();
if (totalChance > 100)
{
int chanceOverflow = (int) (totalChance / 100);
chance = totalChance % 100;
while (chanceOverflow > 0)
{
amount += Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
chanceOverflow--;
}
}
else
{
chance = totalChance;
}
if (chance > random)
{
amount += Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
}
if (amount > 0)
{
items.add(new ItemHolder(item.getItemId(), amount));
return items;
}
}
}
else
{
for (GeneralDropItem item : getItems())
{
// Grouped item chance rates should not be modified.
totalChance += item.getChance();
if (totalChance > random)
{
amount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
items.add(new ItemHolder(item.getItemId(), amount));
return items;
}
}
final Collection<ItemHolder> items = new ArrayList<>(1);
items.add(new ItemHolder(item.getItemId(), Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer)) * successes));
return items;
}
}

View File

@@ -18,7 +18,7 @@
*/
package com.l2jserver.gameserver.model.drops;
import java.util.List;
import java.util.Collection;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.holders.ItemHolder;
@@ -32,7 +32,7 @@ public interface IDropItem
* Calculates drops of this drop item.
* @param victim the victim
* @param killer the killer
* @return {@code null} or empty list if there are no drops, a list containing all items to drop otherwise
* @return {@code null} or empty collection if there are no drops, a collection containing all items to drop otherwise
*/
public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer);
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer);
}

View File

@@ -2773,4 +2773,34 @@ public abstract class AbstractScript extends ManagedScript
{
player.sendPacket(new SpecialCamera(creature, force, angle1, angle2, time, range, duration, relYaw, relPitch, isWide, relAngle, unk));
}
/**
* @param player
* @param x
* @param y
* @param z
*/
public static void addRadar(L2PcInstance player, int x, int y, int z)
{
player.getRadar().addMarker(x, y, z);
}
/**
* @param player
* @param x
* @param y
* @param z
*/
public void removeRadar(L2PcInstance player, int x, int y, int z)
{
player.getRadar().removeMarker(x, y, z);
}
/**
* @param player
*/
public void clearRadar(L2PcInstance player)
{
player.getRadar().removeAllMarkers();
}
}

View File

@@ -27,6 +27,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
@@ -34,6 +35,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
@@ -608,8 +610,17 @@ public class Quest extends AbstractScript implements IIdentifiable
String res = null;
try
{
//@formatter:off
final Set<Quest> startingQuests = npc.getListeners(EventType.ON_NPC_QUEST_START).stream()
.map(AbstractEventListener::getOwner)
.filter(Quest.class::isInstance)
.map(Quest.class::cast)
.distinct()
.collect(Collectors.toSet());
//@formatter:on
final String startConditionHtml = getStartConditionHtml(player);
if (!player.hasQuestState(_name) && (startConditionHtml != null))
if (startingQuests.contains(this) && (startConditionHtml != null))
{
res = startConditionHtml;
}

View File

@@ -1608,13 +1608,34 @@ public final class Formulas
return false;
}
double val = actor.getStat().calcStat(Stats.SKILL_MASTERY, 1, null, null);
if (actor.isPlayer())
final int val = (int) actor.getStat().calcStat(Stats.SKILL_CRITICAL, 0, null, null);
if (val == 0)
{
val *= (actor.getActingPlayer().isMageClass() ? BaseStats.INT : BaseStats.STR).calcBonus(actor);
return false;
}
return Rnd.get(100) < val;
if (actor.isPlayer())
{
double initVal = 0;
switch (val)
{
case 1:
{
initVal = (BaseStats.STR).calcBonus(actor);
break;
}
case 4:
{
initVal = (BaseStats.INT).calcBonus(actor);
break;
}
}
initVal *= actor.getStat().calcStat(Stats.SKILL_CRITICAL_PROBABILITY, 1, null, null);
return (Rnd.get(100) < initVal);
}
return false;
}
/**

View File

@@ -178,7 +178,8 @@ public enum Stats
SHIELD_DEFENCE_ANGLE("shieldDefAngle"),
// Skill mastery
SKILL_MASTERY("skillMastery"),
SKILL_CRITICAL("skillCritical"),
SKILL_CRITICAL_PROBABILITY("skillCriticalProbability"),
// Vitality
VITALITY_CONSUME_RATE("vitalityConsumeRate"),

View File

@@ -322,7 +322,9 @@ public final class UseItem extends L2GameClientPacket
{
if (!item.isEquipped() && (activeChar.getInventory().getBroochJewelSlots() == 0))
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_EQUIP_S1_WITHOUT_EQUIPPING_A_BROOCH);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_EQUIP_S1_WITHOUT_EQUIPPING_A_BROOCH);
sm.addItemName(item);
activeChar.sendPacket(sm);
return;
}
break;

View File

@@ -85,7 +85,7 @@ public class ConfirmMenteeAdd extends L2GameClientPacket
MentorManager.getInstance().addMentor(mentor.getObjectId(), mentee.getObjectId());
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerMenteeAdd(mentor, mentee), mentee);
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerMenteeAdd(mentor, mentee), mentor);
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FROM_NOW_ON_S1_WILL_BE_YOUR_MENTEE).addCharName(mentee));
mentor.sendPacket(new ExMentorList(mentor));

View File

@@ -21,13 +21,15 @@ package com.l2jserver.gameserver.network.serverpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.network.NpcStringId;
/**
* @author UnAfraid
*/
public class ExQuestNpcLogList extends L2GameServerPacket
{
private final int _questId;
private final List<NpcHolder> _npcs = new ArrayList<>();
private final List<Holder> _npcLogList = new ArrayList<>();
public ExQuestNpcLogList(int questId)
{
@@ -36,12 +38,12 @@ public class ExQuestNpcLogList extends L2GameServerPacket
public void addNpc(int npcId, int count)
{
_npcs.add(new NpcHolder(npcId, 0, count));
_npcLogList.add(new Holder(npcId, false, count));
}
public void addNpc(int npcId, int unknown, int count)
public void addNpcString(NpcStringId npcStringId, int count)
{
_npcs.add(new NpcHolder(npcId, unknown, count));
_npcLogList.add(new Holder(npcStringId.getId(), true, count));
}
@Override
@@ -50,36 +52,36 @@ public class ExQuestNpcLogList extends L2GameServerPacket
writeC(0xFE);
writeH(0xC6);
writeD(_questId);
writeC(_npcs.size());
for (NpcHolder holder : _npcs)
writeC(_npcLogList.size());
for (Holder holder : _npcLogList)
{
writeD((holder.getNpcId() + 1000000));
writeC(holder.getUnknown());
writeD((holder.getId()));
writeC(holder.isNpcString() ? 0x01 : 0x00);
writeD(holder.getCount());
}
}
private class NpcHolder
private class Holder
{
private final int _npcId;
private final int _unknown;
private final int _id;
private final boolean _isNpcString;
private final int _count;
public NpcHolder(int npcId, int unknown, int count)
public Holder(int id, boolean isNpcString, int count)
{
_npcId = npcId;
_unknown = unknown;
_id = id;
_isNpcString = isNpcString;
_count = count;
}
public int getNpcId()
public int getId()
{
return _npcId;
return _id;
}
public int getUnknown()
public boolean isNpcString()
{
return _unknown;
return _isNpcString;
}
public int getCount()

View File

@@ -80,7 +80,7 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
_title = cha.getTitle();
if (cha.isGM() && cha.isInvisible())
{
_title += "[Invisible]";
_title = "[Invisible]";
}
if (addAll)