Sync with L2jServer HighFive Apr 21st 2015.

This commit is contained in:
MobiusDev 2015-04-22 09:59:28 +00:00
parent c896c6cd51
commit 1a6970e30d
37 changed files with 1518 additions and 1298 deletions

View File

@ -1,27 +0,0 @@
/*
* Javolution - Java(tm) Solution for Real-Time and Embedded Systems
* Copyright (c) 2005-2009, Javolution (http://javolution.org/)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

View File

@ -1,173 +0,0 @@
README
======
JavaMail(TM) API 1.5.0 release
------------------------------
Welcome to the JavaMail API 1.5.0 release! This release includes
versions of the JavaMail API implementation, IMAP, SMTP, and POP3
service providers, some examples, and documentation for the JavaMail
API.
Please see the FAQ at http://www.oracle.com/technetwork/java/javamail/faq/
JDK Version notes
-----------------
The JavaMail API supports JDK 1.5 or higher. Note that we have
currently tested this implementation with JDK 1.5, 1.6, and 1.7.
While JavaMail will work with JAF 1.0.2, we recommend the use of JAF 1.1
or newer. JAF 1.1.1 is currently the newest version. Note that JAF 1.1
is included in JDK 1.6 and JAF 1.1.1 is included in JDK 1.6.0_10 and
later.
Protocols supported
-------------------
This release supports the following Internet standard mail protocols:
IMAP - a message Store protocol, for reading messages from a server
POP3 - a message Store protocol, for reading messages from a server
SMTP - a message Transport protocol, for sending messages to a server
The following table lists the names of the supported protocols (as used
in the JavaMail API) and their capabilities:
Protocol Store or Uses Supports
Name Transport? SSL? STARTTLS?
-------------------------------------------------
imap Store No Yes
imaps Store Yes N/A
gimap Store Yes N/A
pop3 Store No Yes
pop3s Store Yes N/A
smtp Transport No Yes
smtps Transport Yes N/A
See our web page at http://www.oracle.com/technetwork/java/javamail/
for the latest information on third party protocol providers.
Download
--------
See the JavaMail project page to download this release.
http://javamail.java.net
Requirements
------------
Note that the JavaMail API requires the JavaBeans(TM) Activation
Framework package to be installed as well if you're using JDK 1.5.
Download the latest version of the JavaBeans Activation Framework from
http://www.oracle.com/technetwork/java/javase/index-jsp-136939.html
and install it in a suitable location.
Installation
------------
UNIX/Linux
----------
1. Download the javax.mail.jar file from the JavaMail project website.
http://java.net/projects/javamail/downloads/download/javax.mail.jar
2. Set your CLASSPATH to include the "javax.mail.jar" file obtained from
the download, as well as the current directory.
Assuming you have downloaded javax.mail.jar to the /u/me/download/
directory, the following would work:
export CLASSPATH=$CLASSPATH:/u/me/download/javax.mail.jar:.
(Don't forget the trailing "." for the current directory.)
Also, if you're using JDK 1.5, include the "activation.jar" file that you
obtained from downloading the JavaBeans Activation Framework. For example:
export CLASSPATH=$CLASSPATH:/u/me/download/activation/activation.jar
3. Download the javamail-samples.zip file from the project website.
http://java.net/projects/javamail/downloads/download/javamail-samples.zip
4. Compile any sample program using your Java compiler. For example:
javac msgshow.java
5. Run the sample program. The '-' option lists the required and optional
command-line options to successfully run any sample. For example:
java msgshow -
lists the available options. And
java msgshow -T imap -H <mailserver> -U <username> -P <passwd> -f INBOX 5
uses the IMAP protocol to display message number 5 from your INBOX.
(Additional instructions on how to run the simple mail reader sample
and servlet sample are provided in client/README.txt and servlet/README.txt,
respectively.)
Windows
-------
1. Download the javax.mail.jar file from the JavaMail project website.
http://java.net/projects/javamail/downloads/download/javax.mail.jar
2. Set your CLASSPATH to include the "javax.mail.jar" file obtained from
the download, as well as the current directory.
Assuming you have downloaded javax.mail.jar to the /u/me/download/
directory, the following would work:
set CLASSPATH=%CLASSPATH%;c:\download\javax.mail.jar;.
(Don't forget the trailing "." for the current directory.)
Also, if you're using JDK 1.5, include the "activation.jar" file that you
obtained from downloading the JavaBeans Activation Framework. For example:
set CLASSPATH=%CLASSPATH%;c:\download\activation\activation.jar
3. Download the javamail-samples.zip file from the project website.
http://java.net/projects/javamail/downloads/download/javamail-samples.zip
4. Compile any sample program using your Java compiler. For example:
javac msgshow.java
5. Run the sample program. The '-' option lists the required and optional
command-line options to successfully run any sample. For example:
java msgshow -
lists the available options. And
java msgshow -T imap -H <mailserver> -U <username> -P <passwd> -f INBOX 5
uses the IMAP protocol to display message number 5 from your INBOX.
(Additional instructions on how to run the simple mail reader sample
and servlet sample are provided in client/README.txt and servlet/README.txt,
respectively.)
Problems?
---------
The JavaMail FAQ at http://www.oracle.com/technetwork/java/javamail/faq/
includes information on protocols supported, installation problems,
debugging tips, etc.
See the NOTES.txt file for information on how to report bugs.
Enjoy!
The JavaMail API Team

View File

@ -1,502 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -496,13 +496,6 @@ DualboxCheckWhitelist = 127.0.0.1,0
# Default: False
AllowChangePassword = False
# Enables L2J old drop behavior
# The old L2J system used to add amount of items drop per 100% range of chance.
# For example, if chance is 230% when rate are applied, it will do :
# amount dropped = (2 * getRandomAmount(min,max)) + 30% chance to get ad additional getRandomAmount(min,max)
# Default : False
OldDropBehavior = False
# ---------------------------------------------------------------------------
# Allowed Player Races
@ -689,7 +682,7 @@ BalancePlayerExceedLimit = 20
# Enable premium system.
# Default: False
EnablePremiumSystem = False
EnablePremiumSystem = True
# Xp rate for premium players.
PremiumRateXp = 2

View File

@ -335,7 +335,8 @@ ClearDroppedItemTable = False
# Default: False
AutoDeleteInvalidQuestData = False
# Setting False can improve server performance on high rate/population servers.
# If True, allows a special handling for drops when chance raises over 100% (eg. when applying chance rates).
# True value causes better drop handling at higher rates.
# Default: True
PreciseDropCalculation = True

View File

@ -182,6 +182,14 @@ MinionChaosTime = 10
# Drops
# ---------------------------------------------------------------------------
# If True, activates bellow level gap rules for standard mobs:
# Default: True
UseDeepBlueDropRules = True
# If True, activates bellow level gap rules for raid bosses:
# Default: True
UseDeepBlueDropRulesRaid = True
# The min and max level difference used for level gap calculation
# this is only for how many levels higher the player is than the monster
# Default: 8

View File

@ -9,8 +9,7 @@
# ---------------------------------------------------------------------------
# Item Rates
# ---------------------------------------------------------------------------
# Warning: to achieve old l2j behavior before drops rework you need to enable OldDropBehavior in Custom.properties
# and increase only chance multipliers! Remember if you increase both chance and amount you will have higher rates than expected
# Warning: Remember if you increase both chance and amount you will have higher rates than expected
# Example: if amount multiplier is 5 and chance multiplier is 5 you will end up with 5*5 = 25 drop rates so be careful!
# Multiplies the amount of items dropped from monster on ground when it dies.
@ -19,6 +18,7 @@ DeathDropAmountMultiplier = 1
CorpseDropAmountMultiplier = 1
# Multiplies the amount of items dropped from monster on ground when it dies.
HerbDropAmountMultiplier = 1
RaidDropAmountMultiplier = 1
# Multiplies the chance of items that can be dropped from monster on ground when it dies.
DeathDropChanceMultiplier = 1
@ -26,6 +26,7 @@ DeathDropChanceMultiplier = 1
CorpseDropChanceMultiplier = 1
# Multiplies the chance of items that can be dropped from monster on ground when it dies.
HerbDropChanceMultiplier = 1
RaidDropChanceMultiplier = 1
# List of items affected by custom drop rate by id, used now for Adena rate too.
# Usage: itemId1,multiplier1;itemId2,multiplier2;...

View File

@ -85,7 +85,7 @@ public class L2NpcActionShift implements IActionShiftHandler
html.replace("%accu%", String.valueOf(((L2Character) target).getAccuracy()));
html.replace("%evas%", String.valueOf(((L2Character) target).getEvasionRate(null)));
html.replace("%crit%", String.valueOf(((L2Character) target).getCriticalHit(null, null)));
html.replace("%rspd%", String.valueOf(((L2Character) target).getRunSpeed()));
html.replace("%rspd%", String.valueOf((int) ((L2Character) target).getRunSpeed()));
html.replace("%aspd%", String.valueOf(((L2Character) target).getPAtkSpd()));
html.replace("%cspd%", String.valueOf(((L2Character) target).getMAtkSpd()));
html.replace("%atkType%", String.valueOf(((L2Character) target).getTemplate().getBaseAttackType()));

View File

@ -1005,7 +1005,7 @@ public class AdminEditChar implements IAdminCommandHandler
adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy()));
adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null)));
adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null)));
adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed()));
adminReply.replace("%runspeed%", String.valueOf((int) player.getRunSpeed()));
adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd()));
adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd()));
adminReply.replace("%access%", player.getAccessLevel().getLevel() + " (" + player.getAccessLevel().getName() + ")");

View File

@ -290,34 +290,7 @@ public class NpcViewMod implements IBypassHandler
final IDropItem dropItem = dropList.get(i);
if (dropItem instanceof GeneralDropItem)
{
final GeneralDropItem generalDropItem = (GeneralDropItem) dropItem;
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
addGeneralDropItem(activeChar, npc, amountFormat, chanceFormat, sb, (GeneralDropItem) dropItem);
}
else if (dropItem instanceof GroupedGeneralDropItem)
{
@ -325,46 +298,21 @@ public class NpcViewMod implements IBypassHandler
if (generalGroupedDropItem.getItems().size() == 1)
{
final GeneralDropItem generalDropItem = generalGroupedDropItem.getItems().get(0);
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalGroupedDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
addGeneralDropItem(activeChar, npc, amountFormat, chanceFormat, sb, new GeneralDropItem(generalDropItem.getItemId(), generalDropItem.getMin(), generalDropItem.getMax(), (generalDropItem.getChance() * generalGroupedDropItem.getChance()) / 100, generalDropItem.getAmountStrategy(), generalDropItem.getChanceStrategy(), generalGroupedDropItem.getPreciseStrategy(), generalGroupedDropItem.getKillerChanceModifierStrategy(), generalDropItem.getDropCalculationStrategy()));
}
else
{
GroupedGeneralDropItem normalized = generalGroupedDropItem.normalizeMe(npc, activeChar);
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top><img src=\"L2UI_CT1.ICON_DF_premiumItem\" width=32 height=32></td>");
sb.append("<td fixwidth=300 align=center><font name=\"ScreenMessageSmall\" color=\"CD9000\">One from group</font>");
sb.append("</td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0><tr>");
sb.append("<td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalGroupedDropItem.getChance(npc, activeChar), 100)));
sb.append(chanceFormat.format(Math.min(normalized.getChance(), 100)));
sb.append("%</td></tr></table><br>");
for (GeneralDropItem generalDropItem : generalGroupedDropItem.getItems())
for (GeneralDropItem generalDropItem : normalized.getItems())
{
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=291 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
@ -374,9 +322,9 @@ public class NpcViewMod implements IBypassHandler
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=259><table width=253 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td><td width=205 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
MinMax minMax = getPreciseMinMax(normalized.getChance(), generalDropItem.getMin(npc, activeChar), generalDropItem.getMax(npc, activeChar), generalDropItem.isPreciseCalculated());
final long min = minMax.min;
final long max = minMax.max;
if (min == max)
{
sb.append(amountFormat.format(min));
@ -433,4 +381,68 @@ public class NpcViewMod implements IBypassHandler
html = html.replaceAll("%items%", bodySb.toString());
Util.sendCBHtml(activeChar, html);
}
/**
* @param activeChar
* @param npc
* @param amountFormat
* @param chanceFormat
* @param sb
* @param dropItem
*/
private static void addGeneralDropItem(L2PcInstance activeChar, L2Npc npc, final DecimalFormat amountFormat, final DecimalFormat chanceFormat, final StringBuilder sb, final GeneralDropItem dropItem)
{
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
MinMax minMax = getPreciseMinMax(dropItem.getChance(npc, activeChar), dropItem.getMin(npc, activeChar), dropItem.getMax(npc, activeChar), dropItem.isPreciseCalculated());
final long min = minMax.min;
final long max = minMax.max;
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(dropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
private static class MinMax
{
public final long min, max;
public MinMax(long min, long max)
{
this.min = min;
this.max = max;
}
}
private static MinMax getPreciseMinMax(double chance, long min, long max, boolean isPrecise)
{
if (!isPrecise || (chance <= 100))
{
return new MinMax(min, max);
}
int mult = (int) (chance) / 100;
return new MinMax(mult * min, (chance % 100) > 0 ? (mult + 1) * max : mult * max);
}
}

View File

@ -429,7 +429,7 @@
<node X="188132" Y="119249" />
<node X="173386" Y="119391" />
</zone>
<zone name="no_bookmark_baium_no_restart" type="ConditionZone" shape="NPoly" minZ="10061" maxZ="1061">
<zone name="no_bookmark_baium_no_restart" type="ConditionZone" shape="NPoly" minZ="10061" maxZ="11061">
<stat name="NoBookmark" val="true" />
<node X="111074" Y="16177" />
<node X="114562" Y="12623" />

View File

@ -75,7 +75,6 @@ import com.l2jserver.util.data.xml.IXmlReader;
/**
* This class loads all the game server related configurations from files.<br>
* The files are usually located in config folder in server root folder.<br>
* Each configuration has a default value (that should reflect retail behavior).
*/
public final class Config
{
@ -799,7 +798,6 @@ public final class Config
public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
public static Map<Integer, Integer> L2JMOD_DUALBOX_CHECK_WHITELIST;
public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
public static boolean L2JMOD_OLD_DROP_BEHAVIOR;
public static boolean ALLOW_HUMAN;
public static boolean ALLOW_ELF;
public static boolean ALLOW_DARKELF;
@ -886,6 +884,8 @@ public final class Config
public static boolean ALT_ATTACKABLE_NPCS;
public static boolean ALT_GAME_VIEWNPC;
public static int MAX_DRIFT_RANGE;
public static boolean DEEPBLUE_DROP_RULES;
public static boolean DEEPBLUE_DROP_RULES_RAID;
public static boolean SHOW_NPC_LVL;
public static boolean SHOW_CREST_WITHOUT_QUEST;
public static boolean ENABLE_RANDOM_ENCHANT_EFFECT;
@ -959,9 +959,11 @@ public final class Config
public static float RATE_DEATH_DROP_AMOUNT_MULTIPLIER;
public static float RATE_CORPSE_DROP_AMOUNT_MULTIPLIER;
public static float RATE_HERB_DROP_AMOUNT_MULTIPLIER;
public static float RATE_RAID_DROP_AMOUNT_MULTIPLIER;
public static float RATE_DEATH_DROP_CHANCE_MULTIPLIER;
public static float RATE_CORPSE_DROP_CHANCE_MULTIPLIER;
public static float RATE_HERB_DROP_CHANCE_MULTIPLIER;
public static float RATE_RAID_DROP_CHANCE_MULTIPLIER;
public static Map<Integer, Float> RATE_DROP_AMOUNT_MULTIPLIER;
public static Map<Integer, Float> RATE_DROP_CHANCE_MULTIPLIER;
public static float RATE_KARMA_LOST;
@ -1872,6 +1874,7 @@ public final class Config
SAVE_DROPPED_ITEM_INTERVAL = General.getInt("SaveDroppedItemInterval", 60) * 60000;
CLEAR_DROPPED_ITEM_TABLE = General.getBoolean("ClearDroppedItemTable", false);
AUTODELETE_INVALID_QUEST_DATA = General.getBoolean("AutoDeleteInvalidQuestData", false);
PRECISE_DROP_CALCULATION = General.getBoolean("PreciseDropCalculation", true);
MULTIPLE_ITEM_DROP = General.getBoolean("MultipleItemDrop", true);
FORCE_INVENTORY_UPDATE = General.getBoolean("ForceInventoryUpdate", false);
LAZY_CACHE = General.getBoolean("LazyCache", true);
@ -2046,6 +2049,8 @@ public final class Config
ALT_ATTACKABLE_NPCS = NPC.getBoolean("AltAttackableNpcs", true);
ALT_GAME_VIEWNPC = NPC.getBoolean("AltGameViewNpc", false);
MAX_DRIFT_RANGE = NPC.getInt("MaxDriftRange", 300);
DEEPBLUE_DROP_RULES = NPC.getBoolean("UseDeepBlueDropRules", true);
DEEPBLUE_DROP_RULES_RAID = NPC.getBoolean("UseDeepBlueDropRulesRaid", true);
SHOW_NPC_LVL = NPC.getBoolean("ShowNpcLevel", false);
SHOW_CREST_WITHOUT_QUEST = NPC.getBoolean("ShowCrestWithoutQuest", false);
ENABLE_RANDOM_ENCHANT_EFFECT = NPC.getBoolean("EnableRandomEnchantEffect", false);
@ -2162,9 +2167,11 @@ public final class Config
RATE_DEATH_DROP_AMOUNT_MULTIPLIER = RatesSettings.getFloat("DeathDropAmountMultiplier", 1);
RATE_CORPSE_DROP_AMOUNT_MULTIPLIER = RatesSettings.getFloat("CorpseDropAmountMultiplier", 1);
RATE_HERB_DROP_AMOUNT_MULTIPLIER = RatesSettings.getFloat("HerbDropAmountMultiplier", 1);
RATE_RAID_DROP_AMOUNT_MULTIPLIER = RatesSettings.getFloat("RaidDropAmountMultiplier", 1);
RATE_DEATH_DROP_CHANCE_MULTIPLIER = RatesSettings.getFloat("DeathDropChanceMultiplier", 1);
RATE_CORPSE_DROP_CHANCE_MULTIPLIER = RatesSettings.getFloat("CorpseDropChanceMultiplier", 1);
RATE_HERB_DROP_CHANCE_MULTIPLIER = RatesSettings.getFloat("HerbDropChanceMultiplier", 1);
RATE_RAID_DROP_CHANCE_MULTIPLIER = RatesSettings.getFloat("RaidDropChanceMultiplier", 1);
String[] dropAmountMultiplier = RatesSettings.getString("DropAmountMultiplierByItemId", "").split(";");
RATE_DROP_AMOUNT_MULTIPLIER = new HashMap<>(dropAmountMultiplier.length);
if (!dropAmountMultiplier[0].isEmpty())
@ -2264,8 +2271,6 @@ public final class Config
L2JMOD_ENABLE_WAREHOUSESORTING_CLAN = CustomSettings.getBoolean("EnableWarehouseSortingClan", false);
L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = CustomSettings.getBoolean("EnableWarehouseSortingPrivate", false);
L2JMOD_OLD_DROP_BEHAVIOR = CustomSettings.getBoolean("OldDropBehavior", false);
if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
{
TVT_EVENT_ENABLED = false;
@ -2635,10 +2640,10 @@ public final class Config
PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("EnablePremiumSystem", false);
PREMIUM_RATE_XP = CustomSettings.getFloat("PremiumRateXp", 2);
PREMIUM_RATE_SP = CustomSettings.getFloat("PremiumRateSp", 2);
PREMIUM_RATE_DROP_CHANCE = CustomSettings.getFloat("PremiumRateDropChance", 2);
PREMIUM_RATE_DROP_AMOUNT = CustomSettings.getFloat("PremiumRateDropAmount", 1);
PREMIUM_RATE_SPOIL_CHANCE = CustomSettings.getFloat("PremiumRateSpoilChance", 2);
PREMIUM_RATE_SPOIL_AMOUNT = CustomSettings.getFloat("PremiumRateSpoilAmount", 1);
PREMIUM_RATE_DROP_CHANCE = CustomSettings.getFloat("PremiumRateDropChance", 1);
PREMIUM_RATE_DROP_AMOUNT = CustomSettings.getFloat("PremiumRateDropAmount", 2);
PREMIUM_RATE_SPOIL_CHANCE = CustomSettings.getFloat("PremiumRateSpoilChance", 1);
PREMIUM_RATE_SPOIL_AMOUNT = CustomSettings.getFloat("PremiumRateSpoilAmount", 2);
String[] premiumDropChanceMultiplier = CustomSettings.getString("PremiumRateDropChanceByItemId", "").split(";");
PREMIUM_RATE_DROP_CHANCE_BY_ID = new HashMap<>(premiumDropChanceMultiplier.length);
if (!premiumDropChanceMultiplier[0].isEmpty())
@ -3207,6 +3212,9 @@ public final class Config
case "cleardroppeditemtable":
CLEAR_DROPPED_ITEM_TABLE = Boolean.parseBoolean(pValue);
break;
case "precisedropcalculation":
PRECISE_DROP_CALCULATION = Boolean.parseBoolean(pValue);
break;
case "multipleitemdrop":
MULTIPLE_ITEM_DROP = Boolean.parseBoolean(pValue);
break;
@ -3347,6 +3355,12 @@ public final class Config
case "maxdriftrange":
MAX_DRIFT_RANGE = Integer.parseInt(pValue);
break;
case "usedeepbluedroprules":
DEEPBLUE_DROP_RULES = Boolean.parseBoolean(pValue);
break;
case "usedeepbluedroprulesraid":
DEEPBLUE_DROP_RULES_RAID = Boolean.parseBoolean(pValue);
break;
case "guardattackaggromob":
GUARD_ATTACK_AGGRO_MOB = Boolean.parseBoolean(pValue);
break;

View File

@ -30,7 +30,7 @@ import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Mobius, RobíkBobík
* @author Mobius
*/
public class PremiumManager
{

View File

@ -139,6 +139,7 @@ import com.l2jserver.gameserver.network.serverpackets.ChangeWaitType;
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
import com.l2jserver.gameserver.network.serverpackets.ExRotation;
import com.l2jserver.gameserver.network.serverpackets.ExTeleportToLocationActivate;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillCanceld;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillLaunched;
@ -2062,7 +2063,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public boolean checkDoCastConditions(Skill skill)
{
if ((skill == null) || isSkillDisabled(skill) || (((skill.getFlyRadius() > 0) || (skill.getFlyType() != null)) && isMovementDisabled()))
if ((skill == null) || isSkillDisabled(skill) || ((skill.getFlyType() == FlyType.CHARGE) && isMovementDisabled()))
{
// Send a Server->Client packet ActionFailed to the L2PcInstance
sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -9083,29 +9083,6 @@ public final class L2PcInstance extends L2Playable
}
}
if (skill.hasEffectType(L2EffectType.TELEPORT_TO_TARGET))
{
// You cannot jump while rooted right ;)
if (isMovementDisabled())
{
// Sends message that skill cannot be used...
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
sm.addSkillName(skill.getId());
sendPacket(sm);
// Send a Server->Client packet ActionFailed to the L2PcInstance
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
// And this skill cannot be used in peace zone, not even on NPCs!
if (isInsideZone(ZoneId.PEACE))
{
// Sends a sys msg to client
sendPacket(SystemMessageId.YOU_MAY_NOT_ATTACK_THIS_TARGET_IN_A_PEACEFUL_ZONE);
// Send a Server->Client packet ActionFailed to the L2PcInstance
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
}
// Check if the skill is a good magic, target is a monster and if force attack is set, if not then we don't want to cast.
if ((skill.getEffectPoint() > 0) && target.isMonster() && !forceUse)
{

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops;
import com.l2jserver.Config;
/**
* @author NosBit
*/
public class CorpseDropItem extends GeneralDropItem
{
/**
* @param itemId the item id
* @param min the min count
* @param max the max count
* @param chance the chance of this drop item
*/
public CorpseDropItem(int itemId, long min, long max, double chance)
{
super(itemId, min, max, chance);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier()
*/
@Override
protected double getGlobalAmountMultiplier(boolean isPremium)
{
return isPremium ? Config.PREMIUM_RATE_SPOIL_AMOUNT * Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER : Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalChanceMultiplier()
*/
@Override
protected double getGlobalChanceMultiplier(boolean isPremium)
{
return isPremium ? Config.PREMIUM_RATE_SPOIL_CHANCE * Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER : Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER;
}
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops;
import com.l2jserver.Config;
/**
* @author NosBit
*/
public class DeathDropItem extends GeneralDropItem
{
/**
* @param itemId the item id
* @param min the min count
* @param max the max count
* @param chance the chance of this drop item
*/
public DeathDropItem(int itemId, long min, long max, double chance)
{
super(itemId, min, max, chance);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier()
*/
@Override
protected double getGlobalAmountMultiplier(boolean isPremium)
{
return isPremium ? Config.PREMIUM_RATE_DROP_AMOUNT * Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER : Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER;
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalChanceMultiplier()
*/
@Override
protected double getGlobalChanceMultiplier(boolean isPremium)
{
return isPremium ? Config.PREMIUM_RATE_DROP_CHANCE * Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER : Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER;
}
}

View File

@ -18,75 +18,46 @@
*/
package com.l2jserver.gameserver.model.drops;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.drops.strategy.IAmountMultiplierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IChanceMultiplierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IGroupedItemDropCalculationStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IKillerChanceModifierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IPreciseDeterminationStrategy;
/**
* @author NosBit
*/
public enum DropListScope
public enum DropListScope implements IDropItemFactory, IGroupedDropItemFactory
{
DEATH(DeathDropItem.class, GroupedDeathDropItem.class),
CORPSE(CorpseDropItem.class, GroupedCorpseDropItem.class);
DEATH((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.DROP, IChanceMultiplierStrategy.DROP), chance -> new GroupedGeneralDropItem(chance)),
CORPSE((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.SPOIL, IChanceMultiplierStrategy.SPOIL), DEATH),
private static final Logger _log = Logger.getLogger(DropListScope.class.getName());
/**
* This droplist scope isn't affected by ANY rates, nor Champion, etc...
*/
STATIC(
(itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.STATIC, IChanceMultiplierStrategy.STATIC, IPreciseDeterminationStrategy.ALWAYS, IKillerChanceModifierStrategy.NO_RULES),
chance -> new GroupedGeneralDropItem(chance, IGroupedItemDropCalculationStrategy.DEFAULT_STRATEGY, IKillerChanceModifierStrategy.NO_RULES, IPreciseDeterminationStrategy.ALWAYS)),
QUEST((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.STATIC, IChanceMultiplierStrategy.QUEST, IPreciseDeterminationStrategy.ALWAYS, IKillerChanceModifierStrategy.NO_RULES), STATIC);
private final Class<? extends GeneralDropItem> _dropItemClass;
private final Class<? extends GroupedGeneralDropItem> _groupedDropItemClass;
private final IDropItemFactory _factory;
private final IGroupedDropItemFactory _groupFactory;
private DropListScope(Class<? extends GeneralDropItem> dropItemClass, Class<? extends GroupedGeneralDropItem> groupedDropItemClass)
private DropListScope(IDropItemFactory factory, IGroupedDropItemFactory groupFactory)
{
_dropItemClass = dropItemClass;
_groupedDropItemClass = groupedDropItemClass;
_factory = factory;
_groupFactory = groupFactory;
}
@Override
public IDropItem newDropItem(int itemId, long min, long max, double chance)
{
final Constructor<? extends GeneralDropItem> constructor;
try
{
constructor = _dropItemClass.getConstructor(int.class, long.class, long.class, double.class);
}
catch (NoSuchMethodException | SecurityException e)
{
_log.log(Level.SEVERE, "Constructor(int, long, long, double) not found for " + _dropItemClass.getSimpleName(), e);
return null;
}
try
{
return constructor.newInstance(itemId, min, max, chance);
}
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
_log.log(Level.SEVERE, "", e);
return null;
}
return _factory.newDropItem(itemId, min, max, chance);
}
@Override
public GroupedGeneralDropItem newGroupedDropItem(double chance)
{
final Constructor<? extends GroupedGeneralDropItem> constructor;
try
{
constructor = _groupedDropItemClass.getConstructor(double.class);
}
catch (NoSuchMethodException | SecurityException e)
{
_log.log(Level.SEVERE, "Constructor(double) not found for " + _groupedDropItemClass.getSimpleName(), e);
return null;
}
try
{
return constructor.newInstance(chance);
}
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
_log.log(Level.SEVERE, "", e);
return null;
}
return _groupFactory.newGroupedDropItem(chance);
}
}

View File

@ -18,28 +18,33 @@
*/
package com.l2jserver.gameserver.model.drops;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.strategy.IAmountMultiplierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IChanceMultiplierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IDropCalculationStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IKillerChanceModifierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.INonGroupedKillerChanceModifierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IPreciseDeterminationStrategy;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.items.L2Item;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Rnd;
/**
* @author NosBit
*/
public class GeneralDropItem implements IDropItem
public final class GeneralDropItem implements IDropItem
{
private final int _itemId;
private final long _min;
private final long _max;
private final double _chance;
protected final IAmountMultiplierStrategy _amountStrategy;
protected final IChanceMultiplierStrategy _chanceStrategy;
protected final IPreciseDeterminationStrategy _preciseStrategy;
protected final INonGroupedKillerChanceModifierStrategy _killerStrategy;
protected final IDropCalculationStrategy _dropCalculationStrategy;
/**
* @param itemId the item id
* @param min the min count
@ -47,233 +52,193 @@ public class GeneralDropItem implements IDropItem
* @param chance the chance of this drop item
*/
public GeneralDropItem(int itemId, long min, long max, double chance)
{
this(itemId, min, max, chance, 1, 1);
}
public GeneralDropItem(int itemId, long min, long max, double chance, double defaultAmountMultiplier, double defaultChanceMultiplier)
{
this(itemId, min, max, defaultChanceMultiplier, IAmountMultiplierStrategy.DEFAULT_STRATEGY(defaultAmountMultiplier), IChanceMultiplierStrategy.DEFAULT_STRATEGY(defaultChanceMultiplier));
}
public GeneralDropItem(int itemId, long min, long max, double chance, IAmountMultiplierStrategy amountMultiplierStrategy, IChanceMultiplierStrategy chanceMultiplierStrategy)
{
this(itemId, min, max, chance, amountMultiplierStrategy, chanceMultiplierStrategy, IPreciseDeterminationStrategy.DEFAULT, IKillerChanceModifierStrategy.DEFAULT_NONGROUP_STRATEGY);
}
public GeneralDropItem(int itemId, long min, long max, double chance, IAmountMultiplierStrategy amountMultiplierStrategy, IChanceMultiplierStrategy chanceMultiplierStrategy, IPreciseDeterminationStrategy preciseStrategy, INonGroupedKillerChanceModifierStrategy killerStrategy)
{
this(itemId, min, max, chance, amountMultiplierStrategy, chanceMultiplierStrategy, preciseStrategy, killerStrategy, IDropCalculationStrategy.DEFAULT_STRATEGY);
}
public GeneralDropItem(int itemId, long min, long max, double chance, IAmountMultiplierStrategy amountMultiplierStrategy, IChanceMultiplierStrategy chanceMultiplierStrategy, IPreciseDeterminationStrategy preciseStrategy, INonGroupedKillerChanceModifierStrategy killerStrategy, IDropCalculationStrategy dropCalculationStrategy)
{
_itemId = itemId;
_min = min;
_max = max;
_chance = chance;
_amountStrategy = amountMultiplierStrategy;
_chanceStrategy = chanceMultiplierStrategy;
_preciseStrategy = preciseStrategy;
_killerStrategy = killerStrategy;
_dropCalculationStrategy = dropCalculationStrategy;
}
protected double getGlobalChanceMultiplier(boolean isPremium)
/**
* @return the _amountStrategy
*/
public final IAmountMultiplierStrategy getAmountStrategy()
{
return 1.;
return _amountStrategy;
}
protected double getGlobalAmountMultiplier(boolean isPremium)
/**
* @return the _chanceStrategy
*/
public final IChanceMultiplierStrategy getChanceStrategy()
{
return 1.;
return _chanceStrategy;
}
private final long getMinMax(L2Character victim, L2Character killer, long val)
/**
* @return the _preciseStrategy
*/
public final IPreciseDeterminationStrategy getPreciseStrategy()
{
double multiplier = 1;
// individual drop amount
Float individualDropAmountMultiplier = null;
if (killer.getActingPlayer().hasPremiumStatus())
{
final Float normalMultiplier = Config.RATE_DROP_AMOUNT_MULTIPLIER.get(getItemId());
final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.get(getItemId());
if ((normalMultiplier != null) && (premiumMultiplier != null))
{
individualDropAmountMultiplier = normalMultiplier * premiumMultiplier;
}
else if (normalMultiplier != null)
{
individualDropAmountMultiplier = normalMultiplier;
}
else if (premiumMultiplier != null)
{
individualDropAmountMultiplier = premiumMultiplier;
}
}
else
{
individualDropAmountMultiplier = Config.RATE_DROP_AMOUNT_MULTIPLIER.get(getItemId());
return _preciseStrategy;
}
if (individualDropAmountMultiplier != null)
/**
* @return the _killerStrategy
*/
public final INonGroupedKillerChanceModifierStrategy getKillerChanceModifierStrategy()
{
// individual amount list multiplier
multiplier *= individualDropAmountMultiplier;
}
else
{
final L2Item item = ItemTable.getInstance().getTemplate(getItemId());
// global amount multiplier
if ((item != null) && item.hasExImmediateEffect())
{
// global herb amount multiplier
multiplier *= Config.RATE_HERB_DROP_AMOUNT_MULTIPLIER;
}
else
{
// drop type specific amount multiplier
multiplier *= getGlobalAmountMultiplier(killer.getActingPlayer().hasPremiumStatus());
}
return _killerStrategy;
}
// global champions amount multiplier
if (victim.isChampion())
/**
* @return the _dropCalculationStrategy
*/
public final IDropCalculationStrategy getDropCalculationStrategy()
{
multiplier *= getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS : Config.L2JMOD_CHAMPION_ADENAS_REWARDS;
}
return (long) (val * multiplier);
return _dropCalculationStrategy;
}
/**
* Gets the item id
* @return the item id
*/
public int getItemId()
public final int getItemId()
{
return _itemId;
}
/**
* Gets the min drop count
* Gets the base min drop count
* @return the min
*/
public long getMin()
public final long getMin()
{
return _min;
}
/**
* Gets the min drop count
* @param victim the victim
* @param killer the killer
* Gets the min drop count modified by server rates
* @param victim the victim who drops the item
* @param killer
* @return the min modified by any rates.
*/
public long getMin(L2Character victim, L2Character killer)
public final long getMin(L2Character victim, L2Character killer)
{
return getMinMax(victim, killer, getMin());
return (long) (getMin() * getAmountMultiplier(victim, killer));
}
/**
* Gets the max drop count
* Gets the base max drop count
* @return the max
*/
public long getMax()
public final long getMax()
{
return _max;
}
/**
* Gets the max drop count
* @param victim the victim
* @param killer the killer
* Gets the max drop count modified by server rates
* @param victim the victim who drops the item
* @param killer
* @return the max modified by any rates.
*/
public long getMax(L2Character victim, L2Character killer)
public final long getMax(L2Character victim, L2Character killer)
{
return getMinMax(victim, killer, getMax());
return (long) (getMax() * getAmountMultiplier(victim, killer));
}
/**
* Gets the chance of this drop item.
* @return the chance
*/
public double getChance()
public final double getChance()
{
return _chance;
}
/**
* Gets the chance of this drop item.
* @param victim the victim
* @param killer the killer
* @return the chance modified by any rates.
* Gets the chance of dropping this item for current killer and victim (modified by server rates and another rules based on killer) <br>
* This shall be used to calculate chance outside of drop groups.
* @param victim the victim who drops the item
* @param killer who kills the victim
* @return a chance to drop modified by deep blue drop rules
*/
public double getChance(L2Character victim, L2Character killer)
public final double getChance(L2Character victim, L2Character killer)
{
double multiplier = 1;
// individual drop chance
Float individualDropChanceMultiplier = null;
if (killer.getActingPlayer().hasPremiumStatus())
{
final Float normalMultiplier = Config.RATE_DROP_CHANCE_MULTIPLIER.get(getItemId());
final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(getItemId());
if ((normalMultiplier != null) && (premiumMultiplier != null))
{
individualDropChanceMultiplier = normalMultiplier * premiumMultiplier;
}
else if (normalMultiplier != null)
{
individualDropChanceMultiplier = normalMultiplier;
}
else if (premiumMultiplier != null)
{
individualDropChanceMultiplier = premiumMultiplier;
}
}
else
{
individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_MULTIPLIER.get(getItemId());
return (getKillerChanceModifier(victim, killer) * getChance());
}
if (individualDropChanceMultiplier != null)
{
multiplier *= individualDropChanceMultiplier;
}
else
{
final L2Item item = ItemTable.getInstance().getTemplate(getItemId());
if ((item != null) && item.hasExImmediateEffect())
{
multiplier *= Config.RATE_HERB_DROP_CHANCE_MULTIPLIER;
}
else
{
multiplier *= getGlobalChanceMultiplier(killer.getActingPlayer().hasPremiumStatus());
}
}
if (victim.isChampion())
{
multiplier *= Config.L2JMOD_CHAMPION_REWARDS;
}
return (getChance() * multiplier);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
public final List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
{
final int levelDifference = victim.getLevel() - killer.getLevel();
final double levelGapChanceToDrop;
if (getItemId() == Inventory.ADENA_ID)
{
levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100.0);
}
else
{
levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0);
return _dropCalculationStrategy.calculateDrops(this, victim, killer);
}
// There is a chance of level gap that it wont drop this item
if (levelGapChanceToDrop < (Rnd.nextDouble() * 100))
/**
* @return <code>true</code> if chance over 100% should be handled
*/
public final boolean isPreciseCalculated()
{
return null;
return _preciseStrategy.isPreciseCalculated(this);
}
final double chance = getChance(victim, killer);
final boolean successes = chance > (Rnd.nextDouble() * 100);
if (successes)
/**
* This handles by default deep blue drop rules. It may also be used to handle another drop chance rules based on killer
* @param victim the victim who drops the item
* @param killer who kills the victim
* @return a number between 0 and 1 (usually)
*/
protected final double getKillerChanceModifier(L2Character victim, L2Character killer)
{
final Collection<ItemHolder> items = new ArrayList<>(1);
final long baseDropCount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + (chance > 100 ? (chance % 100) > (Rnd.nextDouble() * 100) ? baseDropCount : 0 : 0) : baseDropCount);
items.add(new ItemHolder(getItemId(), finaldropCount));
return items;
return _killerStrategy.getKillerChanceModifier(this, victim, killer);
}
return null;
/**
* This gets standard server rates for this item
* @param victim who drops the item
* @param killer
* @return
*/
protected final double getAmountMultiplier(L2Character victim, L2Character killer)
{
return _amountStrategy.getAmountMultiplier(this, victim, killer);
}
/**
* This gets standard server rates for this item
* @param victim who drops the item
* @param killer
* @return
*/
protected final double getChanceMultiplier(L2Character victim, L2Character killer)
{
return _chanceStrategy.getChanceMultiplier(this, victim, killer);
}
}

View File

@ -19,134 +19,234 @@
package com.l2jserver.gameserver.model.drops;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2RaidBossInstance;
import com.l2jserver.gameserver.model.drops.strategy.IAmountMultiplierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IChanceMultiplierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IGroupedItemDropCalculationStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IKillerChanceModifierStrategy;
import com.l2jserver.gameserver.model.drops.strategy.IPreciseDeterminationStrategy;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.gameserver.model.items.L2Item;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Rnd;
/**
* @author NosBit
*/
public class GroupedGeneralDropItem implements IDropItem
public final class GroupedGeneralDropItem implements IDropItem
{
private final double _chance;
private List<GeneralDropItem> _items;
protected final IGroupedItemDropCalculationStrategy _dropCalculationStrategy;
protected final IKillerChanceModifierStrategy _killerChanceModifierStrategy;
protected final IPreciseDeterminationStrategy _preciseStrategy;
/**
* @param chance the chance of this drop item.
*/
public GroupedGeneralDropItem(double chance)
{
_chance = chance;
this(chance, IGroupedItemDropCalculationStrategy.DEFAULT_STRATEGY, IKillerChanceModifierStrategy.DEFAULT_STRATEGY, IPreciseDeterminationStrategy.DEFAULT);
}
protected double getGlobalChanceMultiplier()
/**
* @param chance the chance of this drop item.
* @param dropStrategy to calculate drops.
* @param killerStrategy
* @param preciseStrategy
*/
public GroupedGeneralDropItem(double chance, IGroupedItemDropCalculationStrategy dropStrategy, IKillerChanceModifierStrategy killerStrategy, IPreciseDeterminationStrategy preciseStrategy)
{
return 1.;
_chance = chance;
_dropCalculationStrategy = dropStrategy;
_killerChanceModifierStrategy = killerStrategy;
_preciseStrategy = preciseStrategy;
}
/**
* Gets the chance of this drop item.
* @return the chance
*/
public double getChance()
public final double getChance()
{
return _chance;
}
/**
* Gets the chance of this drop item.
* @param victim the victim
* @param killer the killer
* @return the chance modified by any rates.
*/
public double getChance(L2Character victim, L2Character killer)
{
for (final GeneralDropItem gdi : getItems())
{
final L2Item item = ItemTable.getInstance().getTemplate(gdi.getItemId());
if ((item == null) || !item.hasExImmediateEffect())
{
return getChance() * getGlobalChanceMultiplier();
}
}
return getChance() * Config.RATE_HERB_DROP_CHANCE_MULTIPLIER;
}
/**
* Gets the items.
* @return the items
*/
public List<GeneralDropItem> getItems()
public final List<GeneralDropItem> getItems()
{
return _items;
}
/**
* @return the strategy
*/
public final IGroupedItemDropCalculationStrategy getDropCalculationStrategy()
{
return _dropCalculationStrategy;
}
/**
* @return the _killerChanceModifierStrategy
*/
public IKillerChanceModifierStrategy getKillerChanceModifierStrategy()
{
return _killerChanceModifierStrategy;
}
/**
* @return the _preciseStrategy
*/
public final IPreciseDeterminationStrategy getPreciseStrategy()
{
return _preciseStrategy;
}
/**
* Sets an item list to this drop item.
* @param items the item list
*/
public void setItems(List<GeneralDropItem> items)
public final void setItems(List<GeneralDropItem> items)
{
_items = Collections.unmodifiableList(items);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
/**
* Returns a list of items in the group with chance multiplied by chance of the group
* @return the list of items with modified chances
*/
@Override
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
public final List<GeneralDropItem> extractMe()
{
final int levelDifference = victim.getLevel() - killer.getLevel();
double chanceModifier;
if (victim instanceof L2RaidBossInstance)
List<GeneralDropItem> items = new ArrayList<>();
for (final GeneralDropItem item : getItems())
{
chanceModifier = Math.max(0, Math.min(1, (levelDifference * 0.15) + 1));
// precise and killer strategies of the group
items.add(new GeneralDropItem(item.getItemId(), item.getMin(), item.getMax(), (item.getChance() * getChance()) / 100, item.getAmountStrategy(), item.getChanceStrategy(), getPreciseStrategy(), getKillerChanceModifierStrategy(), item.getDropCalculationStrategy()));
}
else
{
chanceModifier = 1;
double levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0);
// There is a chance of level gap that it wont drop this item
if (levelGapChanceToDrop < (Rnd.nextDouble() * 100))
{
return null;
}
}
final double chance = getChance(victim, killer) * chanceModifier;
final boolean successes = chance > (Rnd.nextDouble() * 100);
if (successes)
{
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)
{
final Collection<ItemHolder> items = new ArrayList<>(1);
final long baseDropCount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + (chance > 100 ? (chance % 100) > (Rnd.nextDouble() * 100) ? baseDropCount : 0 : 0) : baseDropCount);
items.add(new ItemHolder(item.getItemId(), finaldropCount));
return items;
}
/**
* statically normalizes a group, useful when need to convert legacy SQL data
* @return a new group with items, which have a sum of getChance() of 100%
*/
public final GroupedGeneralDropItem normalizeMe()
{
double sumchance = 0;
for (GeneralDropItem item : getItems())
{
sumchance += (item.getChance() * getChance()) / 100;
}
final double sumchance1 = sumchance;
GroupedGeneralDropItem group = new GroupedGeneralDropItem(sumchance1, getDropCalculationStrategy(), IKillerChanceModifierStrategy.NO_RULES, getPreciseStrategy());
List<GeneralDropItem> items = new ArrayList<>();
for (final GeneralDropItem item : getItems())
{
// modify only the chance, leave all other rules intact
items.add(new GeneralDropItem(item.getItemId(), item.getMin(), item.getMax(), (item.getChance() * getChance()) / sumchance1, item.getAmountStrategy(), item.getChanceStrategy(), item.getPreciseStrategy(), item.getKillerChanceModifierStrategy(), item.getDropCalculationStrategy()));
}
group.setItems(items);
return group;
}
return null;
/**
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
* @param victim
* @param killer
* @return a new normalized group with all drop modifiers applied
*/
public final GroupedGeneralDropItem normalizeMe(L2Character victim, L2Character killer)
{
return normalizeMe(victim, killer, true, 1);
}
/**
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
* @param victim
* @param killer
* @param chanceModifier an additional chance modifier
* @return a new normalized group with all drop modifiers applied
*/
public final GroupedGeneralDropItem normalizeMe(L2Character victim, L2Character killer, double chanceModifier)
{
return normalizeMe(victim, killer, true, chanceModifier);
}
/**
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
* @param victim
* @return a new normalized group with all victim modifiers applied
*/
public final GroupedGeneralDropItem normalizeMe(L2Character victim)
{
return normalizeMe(victim, null, false, 1);
}
/**
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
* @param victim
* @param chanceModifier an additional chance modifier
* @return a new normalized group with all victim modifiers applied
*/
public final GroupedGeneralDropItem normalizeMe(L2Character victim, double chanceModifier)
{
return normalizeMe(victim, null, false, chanceModifier);
}
/**
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
* @param victim
* @param killer
* @param applyKillerModifier if to modify chance by {@link GroupedGeneralDropItem#getKillerChanceModifier(L2Character, L2Character)}
* @param chanceModifier an additional chance modifier
* @return a new normalized group with all drop modifiers applied
*/
private final GroupedGeneralDropItem normalizeMe(L2Character victim, L2Character killer, boolean applyKillerModifier, double chanceModifier)
{
if (applyKillerModifier)
{
chanceModifier *= (getKillerChanceModifier(victim, killer));
}
double sumchance = 0;
for (GeneralDropItem item : getItems())
{
sumchance += (item.getChance(victim, killer) * getChance() * chanceModifier) / 100;
}
GroupedGeneralDropItem group = new GroupedGeneralDropItem(sumchance, getDropCalculationStrategy(), IKillerChanceModifierStrategy.NO_RULES, getPreciseStrategy()); // to discard further deep blue calculations
List<GeneralDropItem> items = new ArrayList<>();
for (GeneralDropItem item : getItems())
{
// the item is made almost "static"
items.add(new GeneralDropItem(item.getItemId(), item.getMin(victim, killer), item.getMax(victim, killer), (item.getChance(victim, killer) * getChance() * chanceModifier) / sumchance, IAmountMultiplierStrategy.STATIC, IChanceMultiplierStrategy.STATIC, getPreciseStrategy(), IKillerChanceModifierStrategy.NO_RULES, item.getDropCalculationStrategy()));
}
group.setItems(items);
return group;
}
@Override
public final List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
{
return _dropCalculationStrategy.calculateDrops(this, victim, killer);
}
/**
* This handles by default deep blue drop rules. It may also be used to handle another drop chance rules based on killer
* @param victim the victim who drops the item
* @param killer who kills the victim
* @return a number between 0 and 1 (usually)
*/
public final double getKillerChanceModifier(L2Character victim, L2Character killer)
{
return _killerChanceModifierStrategy.getKillerChanceModifier(this, victim, killer);
}
public boolean isPreciseCalculated()
{
return _preciseStrategy.isPreciseCalculated(this);
}
}

View File

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

View File

@ -18,28 +18,17 @@
*/
package com.l2jserver.gameserver.model.drops;
import com.l2jserver.Config;
/**
* @author NosBit
* @author Battlecruiser
*/
public class GroupedDeathDropItem extends GroupedGeneralDropItem
public interface IDropItemFactory
{
/**
* @param chance the chance of this drop item.
* @param itemId the item id
* @param min the min count
* @param max the max count
* @param chance the chance of this drop item
* @return the drop item created by this factory
*/
public GroupedDeathDropItem(double chance)
{
super(chance);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drops.GroupedGeneralDropItem#getGlobalChanceMultiplier()
*/
@Override
protected double getGlobalChanceMultiplier()
{
return Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER;
}
public IDropItem newDropItem(int itemId, long min, long max, double chance);
}

View File

@ -18,28 +18,10 @@
*/
package com.l2jserver.gameserver.model.drops;
import com.l2jserver.Config;
/**
* @author NosBit
* @author Battlecruiser
*/
public class GroupedCorpseDropItem extends GroupedGeneralDropItem
public interface IGroupedDropItemFactory
{
/**
* @param chance the chance of this drop item.
*/
public GroupedCorpseDropItem(double chance)
{
super(chance);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.drops.GroupedGeneralDropItem#getGlobalChanceMultiplier()
*/
@Override
protected double getGlobalChanceMultiplier()
{
return Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER;
}
public GroupedGeneralDropItem newGroupedDropItem(double chance);
}

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
/**
* @author Battlecruiser
*/
public interface IAmountMultiplierStrategy
{
public static final IAmountMultiplierStrategy DROP = DEFAULT_STRATEGY(Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER);
public static final IAmountMultiplierStrategy SPOIL = DEFAULT_STRATEGY(Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER);
public static final IAmountMultiplierStrategy STATIC = (item, victim, killer) -> 1;
public static IAmountMultiplierStrategy DEFAULT_STRATEGY(final double defaultMultiplier)
{
return (item, victim, killer) ->
{
double multiplier = 1;
final Float dropChanceMultiplier = Config.RATE_DROP_AMOUNT_MULTIPLIER.get(item.getItemId());
final Float premiumAmountMultiplier = Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.get(item.getItemId());
if (Config.PREMIUM_SYSTEM_ENABLED && (premiumAmountMultiplier != null) && (killer != null) && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
{
multiplier *= premiumAmountMultiplier;
}
else if (dropChanceMultiplier != null)
{
multiplier *= dropChanceMultiplier;
}
else if (ItemTable.getInstance().getTemplate(item.getItemId()).hasExImmediateEffect())
{
multiplier *= Config.RATE_HERB_DROP_AMOUNT_MULTIPLIER;
}
else if (victim.isRaid())
{
multiplier *= Config.RATE_RAID_DROP_AMOUNT_MULTIPLIER;
}
else if (Config.PREMIUM_SYSTEM_ENABLED && (killer != null) && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
{
if ((defaultMultiplier == Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER) && (defaultMultiplier != Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER))
{
multiplier *= Config.PREMIUM_RATE_DROP_AMOUNT;
}
else
{
multiplier *= Config.PREMIUM_RATE_SPOIL_AMOUNT;
}
}
else
{
multiplier *= defaultMultiplier;
}
return multiplier;
};
}
public double getAmountMultiplier(GeneralDropItem item, L2Character victim, L2Character killer);
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
/**
* @author Battlecruiser
*/
public interface IChanceMultiplierStrategy
{
public static final IChanceMultiplierStrategy DROP = DEFAULT_STRATEGY(Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER);
public static final IChanceMultiplierStrategy SPOIL = DEFAULT_STRATEGY(Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER);
public static final IChanceMultiplierStrategy STATIC = (item, victim, killer) -> 1;
public static final IChanceMultiplierStrategy QUEST = (item, victim, killer) ->
{
double championmult;
if ((item.getItemId() == Inventory.ADENA_ID) || (item.getItemId() == Inventory.ANCIENT_ADENA_ID))
{
championmult = Config.L2JMOD_CHAMPION_ADENAS_REWARDS;
}
else
{
championmult = Config.L2JMOD_CHAMPION_REWARDS;
}
return (Config.L2JMOD_CHAMPION_ENABLE && (victim != null) && victim.isChampion()) ? (Config.RATE_QUEST_DROP * championmult) : Config.RATE_QUEST_DROP;
};
public static IChanceMultiplierStrategy DEFAULT_STRATEGY(final double defaultMultiplier)
{
return (item, victim, killer) ->
{
float multiplier = 1;
if (victim.isChampion())
{
multiplier *= item.getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS : Config.L2JMOD_CHAMPION_ADENAS_REWARDS;
}
final Float dropChanceMultiplier = Config.RATE_DROP_CHANCE_MULTIPLIER.get(item.getItemId());
final Float premiumChanceMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(item.getItemId());
if (Config.PREMIUM_SYSTEM_ENABLED && (premiumChanceMultiplier != null) && (killer != null) && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
{
multiplier *= premiumChanceMultiplier;
}
else if (dropChanceMultiplier != null)
{
multiplier *= dropChanceMultiplier;
}
else if (ItemTable.getInstance().getTemplate(item.getItemId()).hasExImmediateEffect())
{
multiplier *= Config.RATE_HERB_DROP_CHANCE_MULTIPLIER;
}
else if (victim.isRaid())
{
multiplier *= Config.RATE_RAID_DROP_CHANCE_MULTIPLIER;
}
else if (Config.PREMIUM_SYSTEM_ENABLED && (killer != null) && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
{
if ((defaultMultiplier == Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER) && (defaultMultiplier != Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER))
{
multiplier *= Config.PREMIUM_RATE_DROP_CHANCE;
}
else
{
multiplier *= Config.PREMIUM_RATE_SPOIL_CHANCE;
}
}
else
{
multiplier *= defaultMultiplier;
}
return multiplier;
};
}
public double getChanceMultiplier(GeneralDropItem item, L2Character victim, L2Character killer);
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import java.util.Collections;
import java.util.List;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.util.Rnd;
/**
* @author Battlecruiser
*/
public interface IDropCalculationStrategy
{
public static final IDropCalculationStrategy DEFAULT_STRATEGY = (item, victim, killer) ->
{
double chance = item.getChance(victim, killer);
if (chance > (Rnd.nextDouble() * 100))
{
int amountMultiply = 1;
if (item.isPreciseCalculated() && (chance > 100))
{
amountMultiply = (int) chance / 100;
if ((chance % 100) > (Rnd.nextDouble() * 100))
{
amountMultiply++;
}
}
return Collections.singletonList(new ItemHolder(item.getItemId(), Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer)) * amountMultiply));
}
return null;
};
public List<ItemHolder> calculateDrops(GeneralDropItem item, L2Character victim, L2Character killer);
}

View File

@ -0,0 +1,132 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.drops.GroupedGeneralDropItem;
import com.l2jserver.gameserver.model.drops.IDropItem;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.util.Rnd;
/**
* @author Battlecruiser
*/
public interface IGroupedItemDropCalculationStrategy
{
/**
* The default strategy used in L2J to calculate drops. When the group's chance raises over 100% and group has precise calculation, the dropped item's amount increases.
*/
public static final IGroupedItemDropCalculationStrategy DEFAULT_STRATEGY = new IGroupedItemDropCalculationStrategy()
{
private final Map<GroupedGeneralDropItem, GeneralDropItem> singleItemCache = new ConcurrentHashMap<>();
private GeneralDropItem getSingleItem(GroupedGeneralDropItem dropItem)
{
final GeneralDropItem item1 = dropItem.getItems().iterator().next();
singleItemCache.putIfAbsent(dropItem, new GeneralDropItem(item1.getItemId(), item1.getMin(), item1.getMax(), (item1.getChance() * dropItem.getChance()) / 100, item1.getAmountStrategy(), item1.getChanceStrategy(), dropItem.getPreciseStrategy(), dropItem.getKillerChanceModifierStrategy(), item1.getDropCalculationStrategy()));
return singleItemCache.get(dropItem);
}
@Override
public List<ItemHolder> calculateDrops(GroupedGeneralDropItem dropItem, L2Character victim, L2Character killer)
{
if (dropItem.getItems().size() == 1)
{
return getSingleItem(dropItem).calculateDrops(victim, killer);
}
GroupedGeneralDropItem normalized = dropItem.normalizeMe(victim, killer);
if (normalized.getChance() > (Rnd.nextDouble() * 100))
{
final double random = (Rnd.nextDouble() * 100);
double totalChance = 0;
for (GeneralDropItem item2 : normalized.getItems())
{
// Grouped item chance rates should not be modified (the whole magic was already done by normalizing thus the items' chance sum is always 100%).
totalChance += item2.getChance();
if (totalChance > random)
{
int amountMultiply = 1;
if (dropItem.isPreciseCalculated() && (normalized.getChance() >= 100))
{
amountMultiply = (int) (normalized.getChance()) / 100;
if ((normalized.getChance() % 100) > (Rnd.nextDouble() * 100))
{
amountMultiply++;
}
}
return Collections.singletonList(new ItemHolder(item2.getItemId(), Rnd.get(item2.getMin(victim, killer), item2.getMax(victim, killer)) * amountMultiply));
}
}
}
return null;
}
};
/**
* This strategy calculates a group's drop by calculating drops of its individual items and merging its results.
*/
public static final IGroupedItemDropCalculationStrategy DISBAND_GROUP = (item, victim, killer) ->
{
List<ItemHolder> dropped = new ArrayList<>();
for (IDropItem dropItem : item.extractMe())
{
dropped.addAll(dropItem.calculateDrops(victim, killer));
}
return dropped.isEmpty() ? null : dropped;
};
/**
* This strategy when group has precise calculation rolls multiple times over group to determine drops when group's chance raises over 100% instead of just multiplying the dropped item's amount. Thus it can produce different items from group at once.
*/
public static final IGroupedItemDropCalculationStrategy PRECISE_MULTIPLE_GROUP_ROLLS = (item, victim, killer) ->
{
if (!item.isPreciseCalculated())
{
// if item hasn't precise calculation there's no change from DEFAULT_STRATEGY
return DEFAULT_STRATEGY.calculateDrops(item, victim, victim);
}
GroupedGeneralDropItem newItem = new GroupedGeneralDropItem(item.getChance(), DEFAULT_STRATEGY, item.getKillerChanceModifierStrategy(), IPreciseDeterminationStrategy.NEVER);
newItem.setItems(item.getItems());
GroupedGeneralDropItem normalized = newItem.normalizeMe(victim, killer);
// Let's determine the number of rolls.
int rolls = (int) (normalized.getChance() / 100);
if ((Rnd.nextDouble() * 100) < (normalized.getChance() % 100))
{
rolls++;
}
List<ItemHolder> dropped = new ArrayList<>(rolls);
for (int i = 0; i < rolls; i++)
{
// As further normalizing on already normalized drop group does nothing, we can just pass the calculation to DEFAULT_STRATEGY with precise calculation disabled as we handle it.
dropped.addAll(normalized.calculateDrops(victim, killer));
}
return dropped.isEmpty() ? null : dropped;
};
public List<ItemHolder> calculateDrops(GroupedGeneralDropItem item, L2Character victim, L2Character killer);
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.drops.IDropItem;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.util.Util;
/**
* @author Battlecruiser
*/
public interface IKillerChanceModifierStrategy extends INonGroupedKillerChanceModifierStrategy
{
public static final IKillerChanceModifierStrategy DEFAULT_STRATEGY = (item, victim, killer) ->
{
int levelDifference = victim.getLevel() - killer.getLevel();
if ((victim.isRaid()) && Config.DEEPBLUE_DROP_RULES_RAID)
{
// FIXME: Config?
return Math.max(0, Math.min(1, (levelDifference * 0.15) + 1));
}
else if (Config.DEEPBLUE_DROP_RULES)
{
return Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
}
return 1;
};
public static final INonGroupedKillerChanceModifierStrategy DEFAULT_NONGROUP_STRATEGY = (item, victim, killer) ->
{
if (((!(victim.isRaid())) && Config.DEEPBLUE_DROP_RULES) || ((victim.isRaid()) && Config.DEEPBLUE_DROP_RULES_RAID))
{
int levelDifference = victim.getLevel() - killer.getLevel();
if (item.getItemId() == Inventory.ADENA_ID)
{
return Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
}
return Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
}
return 1;
};
IKillerChanceModifierStrategy NO_RULES = (item, victim, killer) -> 1;
public double getKillerChanceModifier(IDropItem item, L2Character victim, L2Character killer);
@Override
public default double getKillerChanceModifier(GeneralDropItem item, L2Character victim, L2Character killer)
{
return getKillerChanceModifier((IDropItem) item, victim, killer);
}
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
/**
* @author Battlecruiser
*/
public interface INonGroupedKillerChanceModifierStrategy
{
public double getKillerChanceModifier(GeneralDropItem item, L2Character victim, L2Character killer);
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.drops.IDropItem;
/**
* @author Battlecruiser
*/
public interface IPreciseDeterminationStrategy
{
public static final IPreciseDeterminationStrategy ALWAYS = dropItem -> true;
public static final IPreciseDeterminationStrategy DEFAULT = dropItem -> Config.PRECISE_DROP_CALCULATION;
public static final IPreciseDeterminationStrategy NEVER = dropItem -> false;
/**
* @param dropItem
* @return <code>true</code> if drop calculation strategy should use precise rules
*/
public boolean isPreciseCalculated(IDropItem dropItem);
}

View File

@ -39,6 +39,7 @@ import com.l2jserver.gameserver.datatables.EventDroplist;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.announce.EventAnnouncement;
import com.l2jserver.gameserver.model.drops.DropListScope;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.script.DateRange;
@ -188,7 +189,7 @@ public class LongTimeEvent extends Quest
continue;
}
_dropList.add(new GeneralDropItem(itemId, minCount, maxCount, finalChance));
_dropList.add((GeneralDropItem) DropListScope.STATIC.newDropItem(itemId, minCount, maxCount, finalChance));
}
catch (NumberFormatException nfe)
{

View File

@ -25,8 +25,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
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.CopyOnWriteArrayList;
@ -59,6 +63,9 @@ import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2TrapInstance;
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.drops.GroupedGeneralDropItem;
import com.l2jserver.gameserver.model.drops.IDropItem;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.model.entity.Instance;
@ -137,6 +144,7 @@ import com.l2jserver.gameserver.scripting.L2ScriptEngineManager;
import com.l2jserver.gameserver.scripting.ScriptManager;
import com.l2jserver.gameserver.util.MinionList;
import com.l2jserver.util.Rnd;
import com.l2jserver.util.Util;
/**
* Abstract script.
@ -348,7 +356,7 @@ public abstract class AbstractScript implements INamable
// ---------------------------------------------------------------------------------------------------------------------------
/**
* Provides callback operation when L2Attackable dies from a player.
* Provides delayed (Depending on {@link com.l2jserver.gameserver.model.actor.L2Attackable#getOnKillDelay()}) callback operation when L2Attackable dies from a player.
* @param callback
* @param npcIds
* @return
@ -359,7 +367,7 @@ public abstract class AbstractScript implements INamable
}
/**
* Provides callback operation when L2Attackable dies from a player.
* Provides delayed (Depending on {@link com.l2jserver.gameserver.model.actor.L2Attackable#getOnKillDelay()}) callback operation when L2Attackable dies from a player.
* @param callback
* @param npcIds
* @return
@ -2330,6 +2338,501 @@ public abstract class AbstractScript implements INamable
return false;
}
/**
* Gives an item to the player
* @param player
* @param item
* @param victim the character that "dropped" the item
* @return <code>true</code> if at least one item was given, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim)
{
List<ItemHolder> items = item.calculateDrops(victim, player);
if ((items == null) || items.isEmpty())
{
return false;
}
giveItems(player, items);
return true;
}
/**
* Gives an item to the player
* @param player
* @param items
*/
protected static void giveItems(L2PcInstance player, List<ItemHolder> items)
{
for (ItemHolder item : items)
{
giveItems(player, item);
}
}
/**
* Gives an item to the player
* @param player
* @param item
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached.
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, ItemHolder item, long limit)
{
long maxToGive = limit - player.getInventory().getInventoryItemCount(item.getId(), -1);
if (maxToGive <= 0)
{
return false;
}
giveItems(player, item.getId(), Math.min(maxToGive, item.getCount()));
return true;
}
protected static boolean giveItems(L2PcInstance player, ItemHolder item, long limit, boolean playSound)
{
boolean drop = giveItems(player, item, limit);
if (drop && playSound)
{
playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
}
return drop;
}
/**
* @param player
* @param items
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached.
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, List<ItemHolder> items, long limit)
{
boolean b = false;
for (ItemHolder item : items)
{
b |= giveItems(player, item, limit);
}
return b;
}
protected static boolean giveItems(L2PcInstance player, List<ItemHolder> items, long limit, boolean playSound)
{
boolean drop = giveItems(player, items, limit);
if (drop && playSound)
{
playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
}
return drop;
}
/**
* @param player
* @param items
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached. If a no limit for an itemId is specified, item will always be given
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, List<ItemHolder> items, Map<Integer, Long> limit)
{
return giveItems(player, items, Util.mapToFunction(limit));
}
/**
* @param player
* @param items
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached. If a no limit for an itemId is specified, item will always be given
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, List<ItemHolder> items, Function<Integer, Long> limit)
{
boolean b = false;
for (ItemHolder item : items)
{
if (limit != null)
{
Long longLimit = limit.apply(item.getId());
// null -> no limit specified for that item id. This trick is to avoid limit.apply() be called twice (once for the null check)
if (longLimit != null)
{
b |= giveItems(player, item, longLimit);
continue; // the item is given, continue with next
}
}
// da BIG else
// no limit specified here (either limit or limit.apply(item.getId()) is null)
b = true;
giveItems(player, item);
}
return b;
}
protected static boolean giveItems(L2PcInstance player, List<ItemHolder> items, Function<Integer, Long> limit, boolean playSound)
{
boolean drop = giveItems(player, items, limit);
if (drop && playSound)
{
playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
}
return drop;
}
protected static boolean giveItems(L2PcInstance player, List<ItemHolder> items, Map<Integer, Long> limit, boolean playSound)
{
return giveItems(player, items, Util.mapToFunction(limit), playSound);
}
/**
* @param player
* @param item
* @param victim the character that "dropped" the item
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached.
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim, int limit)
{
return giveItems(player, item.calculateDrops(victim, player), limit);
}
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim, int limit, boolean playSound)
{
boolean drop = giveItems(player, item, victim, limit);
if (drop && playSound)
{
playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
}
return drop;
}
/**
* @param player
* @param item
* @param victim the character that "dropped" the item
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached. If a no limit for an itemId is specified, item will always be given
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim, Map<Integer, Long> limit)
{
return giveItems(player, item.calculateDrops(victim, player), limit);
}
/**
* @param player
* @param item
* @param victim the character that "dropped" the item
* @param limit the maximum amount of items the player can have. Won't give more if this limit is reached. If a no limit for an itemId is specified, item will always be given
* @return <code>true</code> if at least one item was given to the player, <code>false</code> otherwise
*/
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim, Function<Integer, Long> limit)
{
return giveItems(player, item.calculateDrops(victim, player), limit);
}
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim, Map<Integer, Long> limit, boolean playSound)
{
return giveItems(player, item, victim, Util.mapToFunction(limit), playSound);
}
protected static boolean giveItems(L2PcInstance player, IDropItem item, L2Character victim, Function<Integer, Long> limit, boolean playSound)
{
boolean drop = giveItems(player, item, victim, limit);
if (drop && playSound)
{
playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
}
return drop;
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, Collection<ItemHolder> items, Function<Integer, Long> limit, boolean playSound)
{
Map<L2PcInstance, Map<Integer, Long>> rewardedCounts = calculateDistribution(players, items, limit);
// now give the calculated items to the players
giveItems(rewardedCounts, playSound);
return rewardedCounts;
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, Collection<ItemHolder> items, Map<Integer, Long> limit, boolean playSound)
{
return distributeItems(players, items, Util.mapToFunction(limit), playSound);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, Collection<ItemHolder> items, long limit, boolean playSound)
{
return distributeItems(players, items, t -> limit, playSound);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param item the items to distribute
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Long> distributeItems(Collection<L2PcInstance> players, ItemHolder item, long limit, boolean playSound)
{
Map<L2PcInstance, Map<Integer, Long>> distribution = distributeItems(players, Collections.singletonList(item), limit, playSound);
Map<L2PcInstance, Long> returnMap = new HashMap<>();
for (Entry<L2PcInstance, Map<Integer, Long>> entry : distribution.entrySet())
{
for (Entry<Integer, Long> entry2 : entry.getValue().entrySet())
{
returnMap.put(entry.getKey(), entry2.getValue());
}
}
return returnMap;
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param killer the one who "kills" the victim
* @param victim the character that "dropped" the item
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, IDropItem items, L2Character killer, L2Character victim, Function<Integer, Long> limit, boolean playSound)
{
return distributeItems(players, items.calculateDrops(victim, killer), limit, playSound);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param killer the one who "kills" the victim
* @param victim the character that "dropped" the item
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, IDropItem items, L2Character killer, L2Character victim, Map<Integer, Long> limit, boolean playSound)
{
return distributeItems(players, items.calculateDrops(victim, killer), limit, playSound);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param killer the one who "kills" the victim
* @param victim the character that "dropped" the item
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, IDropItem items, L2Character killer, L2Character victim, long limit, boolean playSound)
{
return distributeItems(players, items.calculateDrops(victim, killer), limit, playSound);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param killer the one who "kills" the victim
* @param victim the character that "dropped" the item
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @param smartDrop true if to not calculate a drop, which can't be given to any player 'cause of limits
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, final GroupedGeneralDropItem items, L2Character killer, L2Character victim, Function<Integer, Long> limit, boolean playSound, boolean smartDrop)
{
GroupedGeneralDropItem toDrop;
if (smartDrop)
{
toDrop = new GroupedGeneralDropItem(items.getChance(), items.getDropCalculationStrategy(), items.getKillerChanceModifierStrategy(), items.getPreciseStrategy());
List<GeneralDropItem> dropItems = new LinkedList<>(items.getItems());
ITEM_LOOP: for (Iterator<GeneralDropItem> it = dropItems.iterator(); it.hasNext();)
{
GeneralDropItem item = it.next();
for (L2PcInstance player : players)
{
int itemId = item.getItemId();
if (player.getInventory().getInventoryItemCount(itemId, -1, true) < avoidNull(limit, itemId))
{
// we can give this item to this player
continue ITEM_LOOP;
}
}
// there's nobody to give this item to
it.remove();
}
toDrop.setItems(dropItems);
toDrop = toDrop.normalizeMe(victim, killer);
}
else
{
toDrop = items;
}
return distributeItems(players, toDrop, killer, victim, limit, playSound);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param killer the one who "kills" the victim
* @param victim the character that "dropped" the item
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @param smartDrop true if to not calculate a drop, which can't be given to any player
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, final GroupedGeneralDropItem items, L2Character killer, L2Character victim, Map<Integer, Long> limit, boolean playSound, boolean smartDrop)
{
return distributeItems(players, items, killer, victim, Util.mapToFunction(limit), playSound, smartDrop);
}
/**
* Distributes items to players equally
* @param players the players to whom the items will be distributed
* @param items the items to distribute
* @param killer the one who "kills" the victim
* @param victim the character that "dropped" the item
* @param limit the limit what single player can have of each item
* @param playSound if to play sound if a player gets at least one item
* @param smartDrop true if to not calculate a drop, which can't be given to any player
* @return the counts of each items given to each player
*/
protected static Map<L2PcInstance, Map<Integer, Long>> distributeItems(Collection<L2PcInstance> players, final GroupedGeneralDropItem items, L2Character killer, L2Character victim, long limit, boolean playSound, boolean smartDrop)
{
return distributeItems(players, items, killer, victim, t -> limit, playSound, smartDrop);
}
/**
* @param players
* @param items
* @param limit
* @return
*/
private static Map<L2PcInstance, Map<Integer, Long>> calculateDistribution(Collection<L2PcInstance> players, Collection<ItemHolder> items, Function<Integer, Long> limit)
{
Map<L2PcInstance, Map<Integer, Long>> rewardedCounts = new HashMap<>();
for (L2PcInstance player : players)
{
rewardedCounts.put(player, new HashMap<Integer, Long>());
}
NEXT_ITEM: for (ItemHolder item : items)
{
long equaldist = item.getCount() / players.size();
long randomdist = item.getCount() % players.size();
List<L2PcInstance> toDist = new ArrayList<>(players);
do // this must happen at least once in order to get away already full players (and then equaldist can become nonzero)
{
for (Iterator<L2PcInstance> it = toDist.iterator(); it.hasNext();)
{
L2PcInstance player = it.next();
if (!rewardedCounts.get(player).containsKey(item.getId()))
{
rewardedCounts.get(player).put(item.getId(), 0L);
}
long maxGive = avoidNull(limit, item.getId()) - player.getInventory().getInventoryItemCount(item.getId(), -1, true) - rewardedCounts.get(player).get(item.getId());
long toGive = equaldist;
if (equaldist >= maxGive)
{
toGive = maxGive;
randomdist += (equaldist - maxGive); // overflown items are available to next players
it.remove(); // this player is already full
}
rewardedCounts.get(player).put(item.getId(), rewardedCounts.get(player).get(item.getId()) + toGive);
}
if (toDist.isEmpty())
{
// there's no one to give items anymore, all players will be full when we give the items
continue NEXT_ITEM;
}
equaldist = randomdist / toDist.size(); // the rest of items may be allowed to be equally distributed between remaining players
randomdist %= toDist.size();
}
while (equaldist > 0);
while (randomdist > 0)
{
if (toDist.isEmpty())
{
// we don't have any player left
continue NEXT_ITEM;
}
L2PcInstance player = toDist.get(getRandom(toDist.size()));
// avoid null return
long maxGive = avoidNull(limit, item.getId()) - limit.apply(item.getId()) - player.getInventory().getInventoryItemCount(item.getId(), -1, true) - rewardedCounts.get(player).get(item.getId());
if (maxGive > 0)
{
// we can add an item to player
// so we add one item to player
rewardedCounts.get(player).put(item.getId(), rewardedCounts.get(player).get(item.getId()) + 1);
randomdist--;
}
toDist.remove(player); // Either way this player isn't allowable for next random award
}
}
return rewardedCounts;
}
/**
* This function is for avoidance null returns in function limits
* @param <T> the type of function arg
* @param function the function
* @param arg the argument
* @return {@link Long#MAX_VALUE} if function.apply(arg) is null, function.apply(arg) otherwise
*/
private static <T> long avoidNull(Function<T, Long> function, T arg)
{
Long longLimit = function.apply(arg);
return longLimit == null ? Long.MAX_VALUE : longLimit;
}
/**
* Distributes items to players
* @param rewardedCounts A scheme of distribution items (the structure is: Map<player Map<itemId, count>>)
* @param playSound if to play sound if a player gets at least one item
*/
private static void giveItems(Map<L2PcInstance, Map<Integer, Long>> rewardedCounts, boolean playSound)
{
for (Entry<L2PcInstance, Map<Integer, Long>> entry : rewardedCounts.entrySet())
{
L2PcInstance player = entry.getKey();
boolean playPlayerSound = false;
for (Entry<Integer, Long> item : entry.getValue().entrySet())
{
if (item.getValue() >= 0)
{
playPlayerSound = true;
giveItems(player, item.getKey(), item.getValue());
}
}
if (playSound && playPlayerSound)
{
playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
}
}
}
/**
* Take an amount of a specified item from player's inventory.
* @param player the player whose item to take

View File

@ -239,10 +239,6 @@ public abstract class ItemContainer
// Updates database
float adenaRate = Config.RATE_DROP_AMOUNT_MULTIPLIER.getOrDefault(Inventory.ADENA_ID, 1f);
if (actor.hasPremiumStatus() && Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.containsKey(Inventory.ADENA_ID))
{
adenaRate *= Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.get(Inventory.ADENA_ID);
}
if ((item.getId() == Inventory.ADENA_ID) && (count < (10000 * adenaRate)))
{
// Small adena changes won't be saved to database all the time
@ -295,10 +291,6 @@ public abstract class ItemContainer
// Updates database
// If Adena drop rate is not present it will be x1.
float adenaRate = Config.RATE_DROP_AMOUNT_MULTIPLIER.getOrDefault(Inventory.ADENA_ID, 1f);
if (actor.hasPremiumStatus() && Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.containsKey(Inventory.ADENA_ID))
{
adenaRate *= Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.get(Inventory.ADENA_ID);
}
if ((itemId == Inventory.ADENA_ID) && (count < (10000 * adenaRate)))
{
// Small adena changes won't be saved to database all the time

View File

@ -25,6 +25,7 @@ import java.util.logging.Level;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.enums.ItemLocation;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@ -108,19 +109,10 @@ public class Mail extends ItemContainer
item.setItemLocation(getBaseLocation(), _messageId);
}
/*
* Allow saving of the items without owner
*/
@Override
public void updateDatabase()
{
for (L2ItemInstance item : _items)
{
if (item != null)
{
item.updateDatabase(true);
}
}
_items.forEach(i -> i.updateDatabase(true));
}
@Override
@ -168,4 +160,17 @@ public class Mail extends ItemContainer
{
return _ownerId;
}
@Override
public void deleteMe()
{
_items.forEach(i ->
{
i.updateDatabase(true);
i.deleteMe();
L2World.getInstance().removeObject(i);
IdFactory.getInstance().releaseId(i.getObjectId());
});
_items.clear();
}
}

View File

@ -1462,7 +1462,7 @@ public final class L2ItemInstance extends L2Object
/**
* Updates the database.<BR>
* @param force if the update should necessarilly be done.
* @param force if the update should necessarily be done.
*/
public void updateDatabase(boolean force)
{

View File

@ -199,13 +199,14 @@ public class CellPathFinding extends PathFinding
int currentY = y;
int currentZ = z;
for (int i = 0; i < path.size() - 1; i++)
int midPoint = 0;
while (endPoint.hasNext())
{
AbstractNodeLoc locMiddle = path.get(i);
AbstractNodeLoc locMiddle = path.get(midPoint);
AbstractNodeLoc locEnd = endPoint.next();
if (GeoData.getInstance().canMove(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
{
path.remove(i);
path.remove(midPoint);
remove = true;
if (debug)
{
@ -217,6 +218,7 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX();
currentY = locMiddle.getY();
currentZ = locMiddle.getZ();
midPoint++;
}
}
}

View File

@ -31,6 +31,8 @@ import java.time.temporal.TemporalAdjusters;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.logging.Logger;
/**
@ -223,4 +225,16 @@ public final class Util
.orElse(dateNowWithDifferentTime.with(TemporalAdjusters.next(daysOfWeek.get(0))));
// @formatter:on
}
/**
* This method translates map to function
* @param <K> key type of the map and argument of the function
* @param <V> value type of the map and return type of the function
* @param map the input map
* @return a function which returns map.get(arg)
*/
public static <K, V> Function<K, V> mapToFunction(Map<K, V> map)
{
return key -> map.get(key);
}
}