mirror of
https://github.com/moparisthebest/osiris
synced 2024-12-21 23:08:55 -05:00
Initial commit.
This commit is contained in:
commit
6e7c73f074
40
README.txt
Normal file
40
README.txt
Normal file
@ -0,0 +1,40 @@
|
||||
,-----. ,--. ,--.
|
||||
' .-. ' ,---. `--',--.--.`--' ,---.
|
||||
| | | |( .-' ,--.| .--',--.( .-'
|
||||
' '-' '.-' `)| || | | |.-' `)
|
||||
`-----' `----' `--'`--' `--'`----'
|
||||
|
||||
http://enkrona.net
|
||||
--------------------------------------------------------------
|
||||
Copyright
|
||||
--------------------------------------------------------------
|
||||
The Osiris emulator is copyright (C) 2010-2011 Blake Beaupain,
|
||||
Garrett Woodard, and Travis Burtrum.
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
About Osiris
|
||||
--------------------------------------------------------------
|
||||
Orisis is a lightweight and high performance server base made
|
||||
exclusively for the Enkrona v4 (http://enkrona.net) project.
|
||||
It is designed to emulate the RuneScape #508 server.
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
Developers
|
||||
--------------------------------------------------------------
|
||||
The Osiris emulator developers are:
|
||||
|
||||
* blakeman8192 <blakeman8192@hotmail.com>
|
||||
* boomer <boomer216@hotmail.com>
|
||||
* samuraiblood2 <someguy2191@hotmail.com>
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
Thanks
|
||||
--------------------------------------------------------------
|
||||
The Osiris developers give thanks to:
|
||||
|
||||
* Graham
|
||||
* Taharok
|
||||
* Kramer
|
661
agpl-3.0.txt
Normal file
661
agpl-3.0.txt
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state 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 program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
69
data/config/dialogues.xml
Normal file
69
data/config/dialogues.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<!-- Handles the cosmetic side of dialogues. -->
|
||||
<dialogues>
|
||||
|
||||
<!-- The below three handle the "Man" Npc. -->
|
||||
<dialogue type="npc" id="1">
|
||||
<npc>12</npc>
|
||||
<lines title="Barbarian">
|
||||
<line>Hello NAME, what brings you here?</line>
|
||||
</lines>
|
||||
<next>2</next>
|
||||
</dialogue>
|
||||
|
||||
<!-- Display some options for the user to choose -->
|
||||
<dialogue type="option" id="2">
|
||||
<npc>12</npc>
|
||||
<lines>
|
||||
<line>Nothing much really. Just exploring crap, killing monsters.</line>
|
||||
</lines>
|
||||
<next>3</next>
|
||||
</dialogue>
|
||||
|
||||
<!-- Show the Npc's last dialogue. -->
|
||||
<dialogue type="npc" id="3">
|
||||
<npc>12</npc>
|
||||
<lines title="Barbarian">
|
||||
<line>Glad to see a bright young adventurer like yourself NAME.</line>
|
||||
<line>Come by for a chat anytime you want!</line>
|
||||
</lines>
|
||||
<next>-1</next>
|
||||
</dialogue>
|
||||
|
||||
<!-- Bankers -->
|
||||
<dialogue type="npc" id="1">
|
||||
<npc>494,44,45</npc>
|
||||
<lines title="Banker">
|
||||
<line>What can I do for you today, NAME?</line>
|
||||
</lines>
|
||||
<next>2</next>
|
||||
</dialogue>
|
||||
|
||||
<dialogue type="option" id="2">
|
||||
<npc>494,44,45</npc>
|
||||
<lines>
|
||||
<line>I would like to open up my bank please.</line>
|
||||
<line>Nothing today, thank you.</line>
|
||||
</lines>
|
||||
<next>-1</next>
|
||||
</dialogue>
|
||||
<!-- End of bankers -->
|
||||
|
||||
</dialogues>
|
46
data/config/ground-items.xml
Normal file
46
data/config/ground-items.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<groundItems>
|
||||
|
||||
<ground id="1351" respawn="true">
|
||||
<X>3076</X>
|
||||
<Y>3430</Y>
|
||||
</ground>
|
||||
|
||||
<ground id="590" respawn="true">
|
||||
<X>3077</X>
|
||||
<Y>3430</Y>
|
||||
</ground>
|
||||
|
||||
<ground id="1265" respawn="true">
|
||||
<X>3073</X>
|
||||
<Y>3429</Y>
|
||||
</ground>
|
||||
|
||||
<ground id="303" respawn="true">
|
||||
<X>3103</X>
|
||||
<Y>3435</Y>
|
||||
</ground>
|
||||
|
||||
<ground id="307" respawn="true">
|
||||
<X>3103</X>
|
||||
<Y>3436</Y>
|
||||
</ground>
|
||||
|
||||
</groundItems>
|
36
data/config/npc-combat.xml
Normal file
36
data/config/npc-combat.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<!--
|
||||
health, block animation, death animation
|
||||
accuracy (only need to put the types the npc uses)
|
||||
defence (melee, ranged, magic)
|
||||
attack (type = HitType) (animation are all animations for that attack) (hit = maxDamage,delay) (projectile=id or id,speed,height) (attackgfx/hitgfx= gfx,height)
|
||||
-->
|
||||
<npcCombat>
|
||||
|
||||
<!--Men/Women-->
|
||||
<definition>
|
||||
<ids>12</ids>
|
||||
<info health="15" block="424" death="7197"/>
|
||||
<attacks>
|
||||
<attack type="melee" animation="395,401" hit="1,0"/>
|
||||
</attacks>
|
||||
</definition>
|
||||
|
||||
</npcCombat>
|
47
data/config/npc-drops.xml
Normal file
47
data/config/npc-drops.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<npcDrops>
|
||||
|
||||
<npcDrop>
|
||||
<npcIds>12</npcIds>
|
||||
<item id="313" amount="5-15" chance="90%"/>
|
||||
<item id="995" amount="15-40" chance="80%" />
|
||||
</npcDrop>
|
||||
|
||||
<npcDrop>
|
||||
<npcIds>12</npcIds>
|
||||
<item id="526" amount="1" chance="100%" />
|
||||
</npcDrop>
|
||||
|
||||
<npcDrop>
|
||||
<npcIds>12</npcIds>
|
||||
<item id="1075" amount="1" chance="50%"/>
|
||||
<item id="1087" amount="1" chance="50%"/>
|
||||
<item id="1103" amount="1" chance="50%"/>
|
||||
<item id="1117" amount="1" chance="50%"/>
|
||||
<item id="1139" amount="1" chance="50%"/>
|
||||
<item id="1155" amount="1" chance="50%"/>
|
||||
<item id="1073" amount="1" chance="50%"/>
|
||||
<item id="1089" amount="1" chance="50%"/>
|
||||
<item id="1291" amount="1" chance="50%"/>
|
||||
<item id="1307" amount="1" chance="50%"/>
|
||||
<item id="1321" amount="1" chance="50%"/>
|
||||
</npcDrop>
|
||||
|
||||
</npcDrops>
|
62
data/config/npc-spawns.xml
Normal file
62
data/config/npc-spawns.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Default NPC spawns for the Osiris framework.
|
||||
Please edit this file with a text editor (i.e. notepad).
|
||||
|
||||
A few notes:
|
||||
Case IS important (i.e. movementRange vs movementrange). It is recommended
|
||||
that you use XML comments to explain each spawn is so others can
|
||||
understand what's going on. The values of each field should be self
|
||||
explanatory. Have fun!
|
||||
-->
|
||||
<npcSpawns>
|
||||
|
||||
<npc id="316">
|
||||
<position x="3110" y="3433" z="0"/>
|
||||
<face>south</face>
|
||||
</npc>
|
||||
|
||||
<npc id="316">
|
||||
<position x="3110" y="3434" z="0"/>
|
||||
<face>south</face>
|
||||
</npc>
|
||||
|
||||
<npc id="12">
|
||||
<position x="3083" y="3423" z="0"/>
|
||||
<movementRange minX="3083" minY="3423" maxX="3085" maxY="3425"/>
|
||||
</npc>
|
||||
|
||||
<npc id="12">
|
||||
<position x="3082" y="3416" z="0"/>
|
||||
<movementRange minX="3082" minY="3416" maxX="3084" maxY="3418"/>
|
||||
</npc>
|
||||
|
||||
<npc id="12">
|
||||
<position x="3076" y="3418" z="0"/>
|
||||
<movementRange minX="3076" minY="3418" maxX="3078" maxY="3420"/>
|
||||
</npc>
|
||||
|
||||
<npc id="494">
|
||||
<position x="3086" y="3414" z="0"/>
|
||||
</npc>
|
||||
|
||||
|
||||
|
||||
</npcSpawns>
|
48
data/config/position-change.xml
Normal file
48
data/config/position-change.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<positions>
|
||||
<pos id="21514" x="2331" y="3802" >
|
||||
<up x="2329" y="3802" z="1" />
|
||||
<down x="2329" y="3802" z="-1" />
|
||||
</pos>
|
||||
|
||||
<pos id="21515" x="2330" y="3802" z="1" >
|
||||
<down x="2331" y="3802" />
|
||||
</pos>
|
||||
|
||||
<pos id="11617" x="3076" y="3427" >
|
||||
<swing current="north" to="east" />
|
||||
</pos>
|
||||
|
||||
<pos id="11616" x="3082" y="3426" >
|
||||
<swing current="west" to="north" />
|
||||
</pos>
|
||||
|
||||
<pos id="11620" x="3079" y="3435" >
|
||||
<swing current="west" to="north" />
|
||||
</pos>
|
||||
|
||||
<pos id="11621" x="3078" y="3435" >
|
||||
<swing current="west" to="south" />
|
||||
</pos>
|
||||
|
||||
<pos id="11616" x="3098" y="3426" >
|
||||
<swing current="west" to="south" />
|
||||
</pos>
|
||||
</positions>
|
20
data/config/world-objects.xml
Normal file
20
data/config/world-objects.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<!--
|
||||
Copyright (C) 2010 ENKRONA.NET
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
-->
|
||||
|
||||
<worldObjects>
|
||||
</worldObjects>
|
202
data/database/osiris_sql_structure.sql
Normal file
202
data/database/osiris_sql_structure.sql
Normal file
@ -0,0 +1,202 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 3.1.3.2
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Jan 22, 2011 at 01:41 PM
|
||||
-- Server version: 5.1.50
|
||||
-- PHP Version: 5.3.5
|
||||
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||
|
||||
--
|
||||
-- Database: `osiris`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `contacts`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `contacts` (
|
||||
`player_id` int(11) NOT NULL,
|
||||
`friends` longtext NOT NULL,
|
||||
`ignores` longtext NOT NULL,
|
||||
PRIMARY KEY (`player_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `contacts`
|
||||
--
|
||||
|
||||
INSERT INTO `contacts` (`player_id`, `friends`, `ignores`) VALUES
|
||||
(1, '[]', '[]');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `items`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `items` (
|
||||
`player_id` int(11) NOT NULL,
|
||||
`inventory_item_ids` longtext NOT NULL,
|
||||
`inventory_item_amounts` longtext NOT NULL,
|
||||
`bank_item_ids` longtext NOT NULL,
|
||||
`bank_item_amounts` longtext NOT NULL,
|
||||
`equipment_item_ids` longtext NOT NULL,
|
||||
`equipment_item_amounts` longtext NOT NULL,
|
||||
PRIMARY KEY (`player_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `items`
|
||||
--
|
||||
|
||||
INSERT INTO `items` (`player_id`, `inventory_item_ids`, `inventory_item_amounts`, `bank_item_ids`, `bank_item_amounts`, `equipment_item_ids`, `equipment_item_amounts`) VALUES
|
||||
(1, '[995, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042]', '[2147000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]', '[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]', '[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]', '[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]', '[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `players`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `players` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(12) NOT NULL,
|
||||
`password` varchar(40) NOT NULL,
|
||||
`ip` varchar(15) NOT NULL,
|
||||
`status` tinyint(4) NOT NULL DEFAULT '0',
|
||||
`salt` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
|
||||
|
||||
--
|
||||
-- Dumping data for table `players`
|
||||
--
|
||||
|
||||
INSERT INTO `players` (`id`, `name`, `password`, `ip`, `status`, `salt`) VALUES
|
||||
(1, 'boomer', '6ff132356667a5c33784466834891e3a3e76075a', '127.0.0.1', 2, -932341131);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `settings`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `settings` (
|
||||
`player_id` int(11) NOT NULL,
|
||||
`position_x` int(11) NOT NULL,
|
||||
`position_y` int(11) NOT NULL,
|
||||
`position_z` int(11) NOT NULL,
|
||||
`run_energy` int(11) NOT NULL,
|
||||
`special_energy` int(11) NOT NULL,
|
||||
`attack_style` int(11) NOT NULL,
|
||||
`spell_book` varchar(10) NOT NULL,
|
||||
`gender` tinyint(4) NOT NULL,
|
||||
`auto_retaliate` tinyint(4) NOT NULL,
|
||||
`emote_status` longtext NOT NULL,
|
||||
PRIMARY KEY (`player_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `settings`
|
||||
--
|
||||
|
||||
INSERT INTO `settings` (`player_id`, `position_x`, `position_y`, `position_z`, `run_energy`, `special_energy`, `attack_style`, `spell_book`, `gender`, `auto_retaliate`, `emote_status`) VALUES
|
||||
(1, 3081, 3416, 0, 100, 1000, 0, 'NORMAL', 0, 0, '[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `skills`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `skills` (
|
||||
`player_id` int(11) NOT NULL DEFAULT '0',
|
||||
`attack_curlevel` int(11) NOT NULL,
|
||||
`attack_maxlevel` int(11) NOT NULL,
|
||||
`attack_xp` double(255,30) NOT NULL,
|
||||
`defence_curlevel` int(11) NOT NULL,
|
||||
`defence_maxlevel` int(11) NOT NULL,
|
||||
`defence_xp` double(255,30) NOT NULL,
|
||||
`strength_curlevel` int(11) NOT NULL,
|
||||
`strength_maxlevel` int(11) NOT NULL,
|
||||
`strength_xp` double(255,30) NOT NULL,
|
||||
`hitpoints_curlevel` int(11) NOT NULL,
|
||||
`hitpoints_maxlevel` int(11) NOT NULL,
|
||||
`hitpoints_xp` double(255,30) NOT NULL,
|
||||
`range_curlevel` int(11) NOT NULL,
|
||||
`range_maxlevel` int(11) NOT NULL,
|
||||
`range_xp` double(255,30) NOT NULL,
|
||||
`prayer_curlevel` int(11) NOT NULL,
|
||||
`prayer_maxlevel` int(11) NOT NULL,
|
||||
`prayer_xp` double(255,30) NOT NULL,
|
||||
`magic_curlevel` int(11) NOT NULL,
|
||||
`magic_maxlevel` int(11) NOT NULL,
|
||||
`magic_xp` double(255,30) NOT NULL,
|
||||
`cooking_curlevel` int(11) NOT NULL,
|
||||
`cooking_maxlevel` int(11) NOT NULL,
|
||||
`cooking_xp` double(255,30) NOT NULL,
|
||||
`woodcutting_curlevel` int(11) NOT NULL,
|
||||
`woodcutting_maxlevel` int(11) NOT NULL,
|
||||
`woodcutting_xp` double(255,30) NOT NULL,
|
||||
`fletching_curlevel` int(11) NOT NULL,
|
||||
`fletching_maxlevel` int(11) NOT NULL,
|
||||
`fletching_xp` double(255,30) NOT NULL,
|
||||
`fishing_curlevel` int(11) NOT NULL,
|
||||
`fishing_maxlevel` int(11) NOT NULL,
|
||||
`fishing_xp` double(255,30) NOT NULL,
|
||||
`firemaking_curlevel` int(11) NOT NULL,
|
||||
`firemaking_maxlevel` int(11) NOT NULL,
|
||||
`firemaking_xp` double(255,30) NOT NULL,
|
||||
`crafting_curlevel` int(11) NOT NULL,
|
||||
`crafting_maxlevel` int(11) NOT NULL,
|
||||
`crafting_xp` double(255,30) NOT NULL,
|
||||
`smithing_curlevel` int(11) NOT NULL,
|
||||
`smithing_maxlevel` int(11) NOT NULL,
|
||||
`smithing_xp` double(255,30) NOT NULL,
|
||||
`mining_curlevel` int(11) NOT NULL,
|
||||
`mining_maxlevel` int(11) NOT NULL,
|
||||
`mining_xp` double(255,30) NOT NULL,
|
||||
`herblore_curlevel` int(11) NOT NULL,
|
||||
`herblore_maxlevel` int(11) NOT NULL,
|
||||
`herblore_xp` double(255,30) NOT NULL,
|
||||
`agility_curlevel` int(11) NOT NULL,
|
||||
`agility_maxlevel` int(11) NOT NULL,
|
||||
`agility_xp` double(255,30) NOT NULL,
|
||||
`thieving_curlevel` int(11) NOT NULL,
|
||||
`thieving_maxlevel` int(11) NOT NULL,
|
||||
`thieving_xp` double(255,30) NOT NULL,
|
||||
`slayer_curlevel` int(11) NOT NULL,
|
||||
`slayer_maxlevel` int(11) NOT NULL,
|
||||
`slayer_xp` double(255,30) NOT NULL,
|
||||
`farming_curlevel` int(11) NOT NULL,
|
||||
`farming_maxlevel` int(11) NOT NULL,
|
||||
`farming_xp` double(255,30) NOT NULL,
|
||||
`runecrafting_curlevel` int(11) NOT NULL,
|
||||
`runecrafting_maxlevel` int(11) NOT NULL,
|
||||
`runecrafting_xp` double(255,30) NOT NULL,
|
||||
`construction_curlevel` int(11) NOT NULL,
|
||||
`construction_maxlevel` int(11) NOT NULL,
|
||||
`construction_xp` double(255,30) NOT NULL,
|
||||
`hunter_curlevel` int(11) NOT NULL,
|
||||
`hunter_maxlevel` int(11) NOT NULL,
|
||||
`hunter_xp` double(255,30) NOT NULL,
|
||||
`summoning_curlevel` int(11) NOT NULL,
|
||||
`summoning_maxlevel` int(11) NOT NULL,
|
||||
`summoning_xp` double(255,30) NOT NULL,
|
||||
`overall_curlevel` int(11) NOT NULL,
|
||||
`overall_maxlevel` int(11) NOT NULL,
|
||||
`overall_xp` double(255,30) NOT NULL,
|
||||
PRIMARY KEY (`player_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `skills`
|
||||
--
|
||||
|
||||
INSERT INTO `skills` (`player_id`, `attack_curlevel`, `attack_maxlevel`, `attack_xp`, `defence_curlevel`, `defence_maxlevel`, `defence_xp`, `strength_curlevel`, `strength_maxlevel`, `strength_xp`, `hitpoints_curlevel`, `hitpoints_maxlevel`, `hitpoints_xp`, `range_curlevel`, `range_maxlevel`, `range_xp`, `prayer_curlevel`, `prayer_maxlevel`, `prayer_xp`, `magic_curlevel`, `magic_maxlevel`, `magic_xp`, `cooking_curlevel`, `cooking_maxlevel`, `cooking_xp`, `woodcutting_curlevel`, `woodcutting_maxlevel`, `woodcutting_xp`, `fletching_curlevel`, `fletching_maxlevel`, `fletching_xp`, `fishing_curlevel`, `fishing_maxlevel`, `fishing_xp`, `firemaking_curlevel`, `firemaking_maxlevel`, `firemaking_xp`, `crafting_curlevel`, `crafting_maxlevel`, `crafting_xp`, `smithing_curlevel`, `smithing_maxlevel`, `smithing_xp`, `mining_curlevel`, `mining_maxlevel`, `mining_xp`, `herblore_curlevel`, `herblore_maxlevel`, `herblore_xp`, `agility_curlevel`, `agility_maxlevel`, `agility_xp`, `thieving_curlevel`, `thieving_maxlevel`, `thieving_xp`, `slayer_curlevel`, `slayer_maxlevel`, `slayer_xp`, `farming_curlevel`, `farming_maxlevel`, `farming_xp`, `runecrafting_curlevel`, `runecrafting_maxlevel`, `runecrafting_xp`, `construction_curlevel`, `construction_maxlevel`, `construction_xp`, `hunter_curlevel`, `hunter_maxlevel`, `hunter_xp`, `summoning_curlevel`, `summoning_maxlevel`, `summoning_xp`, `overall_curlevel`, `overall_maxlevel`, `overall_xp`) VALUES
|
||||
(1, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 10, 10, 1154.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 1, 1, 0.000000000000000000000000000000, 33, 33, 1154.000000000000000000000000000000);
|
BIN
data/database/osirisdb.sqlite
Normal file
BIN
data/database/osirisdb.sqlite
Normal file
Binary file not shown.
BIN
data/itemdefs/itemdefinitions.bin
Normal file
BIN
data/itemdefs/itemdefinitions.bin
Normal file
Binary file not shown.
1
data/itemdefs/untradeable.txt
Normal file
1
data/itemdefs/untradeable.txt
Normal file
@ -0,0 +1 @@
|
||||
//untradeable item ids in here, one per line
|
BIN
data/landscapekeys.bin
Normal file
BIN
data/landscapekeys.bin
Normal file
Binary file not shown.
28
settings.ini
Normal file
28
settings.ini
Normal file
@ -0,0 +1,28 @@
|
||||
# Debug/verbose/local mode.
|
||||
# Put to false for all debug and startup information.
|
||||
VERBOSE_MODE: false
|
||||
|
||||
# The servers running port.
|
||||
# Keep at 43594 for obvious reaasons.
|
||||
SERVER_PORT: 43594
|
||||
|
||||
# The servers name obviously.
|
||||
SERVER_NAME: Osiris
|
||||
|
||||
# The EXP rate.
|
||||
EXP_RATE: 50
|
||||
|
||||
# Use SQLite for saving/loading?
|
||||
SQLITE_SAVING: true
|
||||
|
||||
# The servers SQL information.
|
||||
# Only needed if SQLite is set to false.
|
||||
SERVER_HOST: localhost
|
||||
SERVER_DATABASE: database
|
||||
SERVER_USERNAME: root
|
||||
SERVER_PASSWORD: admin
|
||||
|
||||
# Starting position cordinates.
|
||||
START_X: 3082
|
||||
START_Y: 3419
|
||||
START_Z: 0
|
264
src/osiris/Main.java
Normal file
264
src/osiris/Main.java
Normal file
@ -0,0 +1,264 @@
|
||||
package osiris;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.util.Settings.LANDSCAPE_KEYS_FILE;
|
||||
import static osiris.util.Settings.MAX_NPCS;
|
||||
import static osiris.util.Settings.MAX_PLAYERS;
|
||||
import static osiris.util.Settings.PORT;
|
||||
import static osiris.util.Settings.SCRIPTS_DIRECTORY;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
|
||||
import osiris.data.SettingsLoader;
|
||||
import osiris.data.parser.ParserLookup;
|
||||
import osiris.data.parser.impl.PositionChangeParser.PositionChangeInfo;
|
||||
import osiris.data.sql.SqlManager;
|
||||
import osiris.game.model.CharacterGroup;
|
||||
import osiris.game.model.Npc;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.def.NpcCombatDef;
|
||||
import osiris.game.model.dialogues.Dialogue;
|
||||
import osiris.game.model.ground.GroundManager;
|
||||
import osiris.game.model.magic.MagicManager;
|
||||
import osiris.net.OsirisPipelineFactory;
|
||||
import osiris.util.ConsoleProxy;
|
||||
import osiris.util.LandscapeKeys;
|
||||
import osiris.util.RubyInterpreter;
|
||||
import osiris.util.Settings;
|
||||
|
||||
/**
|
||||
* The main class.
|
||||
*
|
||||
* @author Blake
|
||||
* @author samuraiblood2
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class Main {
|
||||
/**
|
||||
* The Constant players.
|
||||
*/
|
||||
private static final CharacterGroup<Player> players = new CharacterGroup<Player>(MAX_PLAYERS);
|
||||
|
||||
/**
|
||||
* The Constant npcs.
|
||||
*/
|
||||
private static final CharacterGroup<Npc> npcs = new CharacterGroup<Npc>(MAX_NPCS);
|
||||
|
||||
/** The Constant quickChatMessages. */
|
||||
private static final Hashtable<Integer, String> quickChatMessages = new Hashtable<Integer, String>();
|
||||
|
||||
/** The local. */
|
||||
private static boolean local;
|
||||
|
||||
/** The Constant dialogues. */
|
||||
private static final List<Dialogue> dialogues = new ArrayList<Dialogue>();
|
||||
|
||||
/** The Constant stairs. */
|
||||
private static final List<PositionChangeInfo> stairs = new ArrayList<PositionChangeInfo>();
|
||||
|
||||
/** The most players online. */
|
||||
private static int mostPlayersOnline = 0;
|
||||
|
||||
/** The start time. */
|
||||
public static long startTime;
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args
|
||||
* the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
printTag();
|
||||
|
||||
System.setOut(new ConsoleProxy(System.out));
|
||||
System.setErr(new ConsoleProxy(System.err));
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("-verbose") || args[0].equalsIgnoreCase("-v") || args[0].equalsIgnoreCase("-local") || args[0].equalsIgnoreCase("-l")) {
|
||||
local = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Load up any configuration.
|
||||
try {
|
||||
SettingsLoader.load();
|
||||
if (SettingsLoader.contains("verbose_mode")) {
|
||||
local = SettingsLoader.getValueAsBoolean("verbose_mode");
|
||||
}
|
||||
|
||||
System.out.println("Bootstrapping " + Settings.SERVER_NAME + " emulator...");
|
||||
|
||||
LandscapeKeys.loadKeys(LANDSCAPE_KEYS_FILE);
|
||||
GroundManager.create();
|
||||
ItemDef.load();
|
||||
SqlManager.load();
|
||||
MagicManager.load();
|
||||
NpcCombatDef.load();
|
||||
|
||||
// XXX: Run the various configuration parsers.
|
||||
ParserLookup.doRun();
|
||||
|
||||
RubyInterpreter.loadScripts(new File(SCRIPTS_DIRECTORY));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Start the server engine.
|
||||
ServerEngine.start();
|
||||
|
||||
// Start the networking system.
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
bootstrap.setPipelineFactory(new OsirisPipelineFactory());
|
||||
ExecutorService e = Executors.newCachedThreadPool();
|
||||
ChannelFactory factory = new NioServerSocketChannelFactory(e, e);
|
||||
bootstrap.setFactory(factory);
|
||||
bootstrap.bind(new InetSocketAddress(PORT));
|
||||
startTime = System.currentTimeMillis();
|
||||
System.out.println("Bootstrap complete!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the tag.
|
||||
*/
|
||||
private static void printTag() {
|
||||
System.out.println();
|
||||
System.out.println(" ,-----. ,--. ,--. ");
|
||||
System.out.println(" ' .-. ' ,---. `--',--.--.`--' ,---. ");
|
||||
System.out.println(" | | | |( .-' ,--.| .--',--.( .-' ");
|
||||
System.out.println(" ' '-' '.-' `)| || | | |.-' `)");
|
||||
System.out.println(" `-----' `----' `--'`--' `--'`----'");
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the players.
|
||||
*
|
||||
* @return the players
|
||||
*/
|
||||
public static CharacterGroup<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the npcs.
|
||||
*
|
||||
* @return the npcs
|
||||
*/
|
||||
public static CharacterGroup<Npc> getNpcs() {
|
||||
return npcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the quick chat messages.
|
||||
*
|
||||
* @return the quick chat messages
|
||||
*/
|
||||
public static Hashtable<Integer, String> getQuickChatMessages() {
|
||||
return quickChatMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find player.
|
||||
*
|
||||
* @param uid
|
||||
* the uid
|
||||
* @return the character
|
||||
*/
|
||||
public static Player findPlayer(int uid) {
|
||||
for (Player player : getPlayers())
|
||||
if (player.getUniqueId() == uid)
|
||||
return player;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find player.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @return the player
|
||||
*/
|
||||
public static Player findPlayer(String name) {
|
||||
for (Player player : getPlayers())
|
||||
if (player.getUsername().equalsIgnoreCase(name))
|
||||
return player;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the most players online.
|
||||
*
|
||||
* @param most
|
||||
* the new most players online
|
||||
*/
|
||||
public static void setMostPlayersOnline(int most) {
|
||||
mostPlayersOnline = most;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the most players online.
|
||||
*
|
||||
* @return the most players online
|
||||
*/
|
||||
public static int getMostPlayersOnline() {
|
||||
return mostPlayersOnline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is local.
|
||||
*
|
||||
* @return true, if is local
|
||||
*/
|
||||
public static boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dialogues.
|
||||
*
|
||||
* @return the dialogues
|
||||
*/
|
||||
public static List<Dialogue> getDialogues() {
|
||||
return dialogues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stairs.
|
||||
*
|
||||
* @return the stairs
|
||||
*/
|
||||
public static List<PositionChangeInfo> getStairs() {
|
||||
return stairs;
|
||||
}
|
||||
|
||||
}
|
332
src/osiris/ServerEngine.java
Normal file
332
src/osiris/ServerEngine.java
Normal file
@ -0,0 +1,332 @@
|
||||
package osiris;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.util.Settings.NPC_MOVEMENT_TIME;
|
||||
import static osiris.util.Settings.TICKRATE;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.event.impl.ServiceRequestEvent;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.DeathManager;
|
||||
import osiris.game.model.InfoUpdater;
|
||||
import osiris.game.model.Npc;
|
||||
import osiris.game.model.NpcMovement;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.combat.CombatManager;
|
||||
import osiris.game.model.combat.Hit;
|
||||
import osiris.game.model.ground.GroundManager;
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The main server engine.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class ServerEngine implements Runnable, ThreadFactory {
|
||||
|
||||
/**
|
||||
* The scheduler.
|
||||
*/
|
||||
private static ScheduledExecutorService scheduler;
|
||||
|
||||
/**
|
||||
* The Constant eventsToProcess.
|
||||
*/
|
||||
private static final Queue<GameEvent> eventsToProcess = new LinkedList<GameEvent>();
|
||||
|
||||
/** The hit queue. */
|
||||
private static PriorityQueue<Hit> hitQueue;
|
||||
|
||||
/** The death manager. */
|
||||
private static DeathManager deathManager;
|
||||
|
||||
/** The lockdown. */
|
||||
private static boolean lockdown = false;
|
||||
|
||||
/**
|
||||
* The ticks.
|
||||
*/
|
||||
private static int ticks = 0;
|
||||
|
||||
/**
|
||||
* Starts the server engine.
|
||||
*/
|
||||
public static void start() {
|
||||
// Create a new ServerEngine instance.
|
||||
ServerEngine instance = new ServerEngine();
|
||||
deathManager = new DeathManager();
|
||||
|
||||
// Initialize the scheduler and schedule the engine instance.
|
||||
scheduler = Executors.newSingleThreadScheduledExecutor(instance);
|
||||
scheduler.scheduleAtFixedRate(instance, 0, TICKRATE, TimeUnit.MILLISECONDS);
|
||||
|
||||
// Schedule any other utilities.
|
||||
scheduler.scheduleAtFixedRate(GroundManager.getManager(), 0, 3, TimeUnit.SECONDS);
|
||||
scheduler.scheduleAtFixedRate(new NpcMovement(), 0, NPC_MOVEMENT_TIME, TimeUnit.SECONDS);
|
||||
scheduler.scheduleAtFixedRate(new InfoUpdater(), 0, 600, TimeUnit.MILLISECONDS);
|
||||
scheduler.scheduleAtFixedRate(deathManager, 0, 600, TimeUnit.MILLISECONDS);
|
||||
|
||||
hitQueue = new PriorityQueue<Hit>(1, new Comparator<Hit>() {
|
||||
@Override
|
||||
public int compare(Hit a, Hit b) {
|
||||
return b.getTimer().getStart() - a.getTimer().getStart();
|
||||
}
|
||||
}) {
|
||||
private static final long serialVersionUID = 412420407031048943L;
|
||||
|
||||
@Override
|
||||
public boolean add(Hit hit) {
|
||||
return hit.getAttacker().isInSight(hit.getVictim()) && super.add(hit);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the server engine.
|
||||
*/
|
||||
public static void stop() {
|
||||
getScheduler().shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues a game event for processing.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
public static void queueGameEvent(GameEvent event) {
|
||||
synchronized (eventsToProcess) {
|
||||
eventsToProcess.add(event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Runnable#cycle()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// 1. Process all game events.
|
||||
synchronized (eventsToProcess) {
|
||||
while (!eventsToProcess.isEmpty()) {
|
||||
// Get the next event.
|
||||
GameEvent event = eventsToProcess.poll();
|
||||
try {
|
||||
// Attempt to process the event.
|
||||
event.process();
|
||||
event.getPlayer().getTimeoutTimer().reset();
|
||||
} catch (Exception ex) {
|
||||
// Whoops! Something went wrong. Clean up.
|
||||
if (event.getPlayer() != null) {
|
||||
ex.printStackTrace();
|
||||
// Log out the problematic player.
|
||||
event.getPlayer().logout();
|
||||
} else if (event.getClass() == ServiceRequestEvent.class || event.getClass().getSuperclass() == ServiceRequestEvent.class) {
|
||||
// Or close the problematic service requesting channel.
|
||||
ServiceRequestEvent e = (ServiceRequestEvent) event;
|
||||
e.getChannel().close();
|
||||
} else {
|
||||
// Or what the fuck happened?
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
event = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Update all players.
|
||||
try {
|
||||
synchronized (Main.getPlayers()) {
|
||||
CombatManager.updateHits();
|
||||
// Perform the pre-update procedures for players and NPCs.
|
||||
for (Player player : Main.getPlayers()) {
|
||||
if ((player.getInteractingCharacter() instanceof Player && !Main.getPlayers().contains((Player) player.getInteractingCharacter())) || player.getInteractingCharacter() instanceof Npc && !Main.getNpcs().contains((Npc) player.getInteractingCharacter()))
|
||||
player.setInteractingCharacter(null);
|
||||
|
||||
// Timeout checking.
|
||||
if (player.getTimeoutTimer().elapsed() > Settings.TIMEOUT_DELAY) {
|
||||
player.logout();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pre-updating.
|
||||
player.handleQueuedUpdateBlocks();
|
||||
player.getCombatManager().cycle();
|
||||
player.getMovementQueue().cycle();
|
||||
}
|
||||
for (Npc npc : Main.getNpcs()) {
|
||||
if ((npc.getInteractingCharacter() instanceof Player && !Main.getPlayers().contains((Player) npc.getInteractingCharacter())) || npc.getInteractingCharacter() instanceof Npc && !Main.getNpcs().contains((Npc) npc.getInteractingCharacter()))
|
||||
npc.setInteractingCharacter(null);
|
||||
npc.handleQueuedUpdateBlocks();
|
||||
npc.getCombatManager().cycle();
|
||||
npc.getMovementQueue().cycle();
|
||||
}
|
||||
|
||||
// Perform the actual update procedures.
|
||||
for (Player player : Main.getPlayers()) {
|
||||
player.getPlayerUpdater().run();
|
||||
player.getNpcUpdater().run();
|
||||
}
|
||||
|
||||
// Perform the post-update procedures for players and NPCs.
|
||||
for (Player player : Main.getPlayers()) {
|
||||
player.getUpdateFlags().reset();
|
||||
player.getUpdateBlocks().clear();
|
||||
player.adjustSpecialEnergy(player.specialRegainRate());
|
||||
}
|
||||
for (Npc npc : Main.getNpcs()) {
|
||||
npc.getUpdateFlags().reset();
|
||||
npc.getUpdateBlocks().clear();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Something bad happened while updating.
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// 3. Update any other server logic.
|
||||
try {
|
||||
|
||||
for (Player player : Main.getPlayers()) {
|
||||
if (ticks % 6 == 0) {
|
||||
if (!player.getMovementQueue().getRunningQueue() && player.getEnergy() < 100) {
|
||||
player.setEnergy(player.getEnergy() + 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Something bad happened while processing logic.
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
ticks++; // Record this tick.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ticks.
|
||||
*
|
||||
* @return the ticks
|
||||
*/
|
||||
public static int getTicks() {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable task) {
|
||||
// Make sure our thread gets the highest priority.
|
||||
Thread thread = new Thread(task);
|
||||
thread.setPriority(Thread.MAX_PRIORITY);
|
||||
thread.setName("ServerEngine");
|
||||
return thread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send global message.
|
||||
*
|
||||
* @param msg
|
||||
* the msg
|
||||
*/
|
||||
public static void sendGlobalMessage(String msg) {
|
||||
for (Player player : Main.getPlayers()) {
|
||||
player.getEventWriter().sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scheduler.
|
||||
*
|
||||
* @return the scheduler
|
||||
*/
|
||||
public static ScheduledExecutorService getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hit queue.
|
||||
*
|
||||
* @return the hit queue
|
||||
*/
|
||||
public static PriorityQueue<Hit> getHitQueue() {
|
||||
return hitQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the death manager.
|
||||
*
|
||||
* @return the death manager
|
||||
*/
|
||||
public static DeathManager getDeathManager() {
|
||||
return deathManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lockdown.
|
||||
*/
|
||||
public static void setLockdown() {
|
||||
lockdown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is under lockdown.
|
||||
*
|
||||
* @return true, if is under lockdown
|
||||
*/
|
||||
public static boolean isUnderLockdown() {
|
||||
return lockdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static graphic.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param id
|
||||
* the id
|
||||
* @param height
|
||||
* the height
|
||||
*/
|
||||
public static void staticGraphic(Character character, int id, int height) {
|
||||
for (Player player : Main.getPlayers())
|
||||
if (player.isInSight(character))
|
||||
player.getEventWriter().spawnGfx(id, height, character.getPosition());
|
||||
}
|
||||
|
||||
}
|
72
src/osiris/data/NpcDropLoader.java
Normal file
72
src/osiris/data/NpcDropLoader.java
Normal file
@ -0,0 +1,72 @@
|
||||
package osiris.data;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import osiris.game.model.NpcDropContainer;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class NpcDropLoader.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class NpcDropLoader {
|
||||
|
||||
/** The drop containers. */
|
||||
private static List<NpcDropContainer> dropContainers = new LinkedList<NpcDropContainer>();
|
||||
|
||||
/**
|
||||
* Adds the.
|
||||
*
|
||||
* @param container
|
||||
* the container
|
||||
*/
|
||||
public static void add(NpcDropContainer container) {
|
||||
dropContainers.add(container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the containers.
|
||||
*
|
||||
* @param npcId
|
||||
* the npc id
|
||||
* @return the containers
|
||||
*/
|
||||
public static ArrayList<NpcDropContainer> getContainers(int npcId) {
|
||||
ArrayList<NpcDropContainer> containers = new ArrayList<NpcDropContainer>();
|
||||
for (NpcDropContainer container : dropContainers)
|
||||
for (int i : container.getNpcs())
|
||||
if (i == npcId)
|
||||
containers.add(container);
|
||||
return containers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all containers.
|
||||
*
|
||||
* @return the all containers
|
||||
*/
|
||||
public static List<NpcDropContainer> getAllContainers() {
|
||||
return dropContainers;
|
||||
}
|
||||
}
|
411
src/osiris/data/PlayerData.java
Normal file
411
src/osiris/data/PlayerData.java
Normal file
@ -0,0 +1,411 @@
|
||||
package osiris.data;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.ServerEngine;
|
||||
import osiris.data.sql.SqlManager;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.model.Skills;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerData.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class PlayerData {
|
||||
|
||||
/**
|
||||
* Saves the player.
|
||||
*
|
||||
* @param player
|
||||
* The player's instance.
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
public static boolean save(Player player) {
|
||||
int uniqueId = player.getUniqueId();
|
||||
|
||||
// Skills
|
||||
try {
|
||||
saveSkills(SqlManager.manager.playerSkillsReplaceStatement, player, uniqueId);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Contacts
|
||||
try {
|
||||
saveContacts(SqlManager.manager.playerContactsReplaceStatement, player, uniqueId);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Items
|
||||
try {
|
||||
saveItems(SqlManager.manager.playerItemsReplaceStatement, player, uniqueId);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Settings
|
||||
try {
|
||||
saveSettings(SqlManager.manager.playerSettingsReplaceStatement, player, uniqueId);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return Codes: 1 = wait 2 seconds 2 = success 3 = wrong pass 4 = disabled
|
||||
* 5 = logged in already 6 = reload client 7 = full 8 = unable to connect 9
|
||||
* = too many connections from ip 10= bad session id 11 = please try again
|
||||
* 12 = members 13 = could not complete login 14 = server is being updated
|
||||
* 16 = login attemps exceeded 17 = standing in members area 20 = invalid
|
||||
* login request 21 = just left another world
|
||||
*/
|
||||
|
||||
/**
|
||||
* Loads the player.
|
||||
*
|
||||
* @param playerName
|
||||
* The player's name.
|
||||
* @param pass
|
||||
* The player's password.
|
||||
* @param player
|
||||
* The player's instance.
|
||||
* @return A return code to be sent to the client.
|
||||
*/
|
||||
public static int load(String playerName, String pass, Player player) {
|
||||
// Is the server down for an update?
|
||||
if (ServerEngine.isUnderLockdown()) {
|
||||
return 14;
|
||||
}
|
||||
|
||||
// Is the player already logged in?
|
||||
for (Player p : Main.getPlayers()) {
|
||||
if (p.getUsername().equalsIgnoreCase(playerName))
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (SqlManager.manager != null) {
|
||||
try {
|
||||
ResultSet playerResults = SqlManager.manager.getResults(SqlManager.manager.serverPlayerResultsStatement, playerName);
|
||||
|
||||
boolean foundUser = false;
|
||||
while (playerResults.next()) {
|
||||
player.setUniqueId(playerResults.getInt("id"));
|
||||
|
||||
if (player.getUniqueId() == -1)
|
||||
return 3;
|
||||
|
||||
int salt = playerResults.getInt("salt");
|
||||
// Is the player's password correct?
|
||||
if (!playerResults.getString("password").equals(Utilities.smfHash(pass, salt)))
|
||||
return 3;
|
||||
|
||||
// Retrieve the player's status.
|
||||
player.setPlayerStatus(playerResults.getInt("status"));
|
||||
foundUser = true;
|
||||
}
|
||||
|
||||
// Player doesn't exist.
|
||||
if (!foundUser || player.getUniqueId() == -1)
|
||||
return 3;
|
||||
|
||||
// Retrieve items for the player.
|
||||
ResultSet itemsResults = SqlManager.manager.getResults(SqlManager.manager.playerItemsResultsStatement, player.getUniqueId());
|
||||
if (itemsResults != null) {
|
||||
while (itemsResults.next()) {
|
||||
String inventoryIds = itemsResults.getString("inventory_item_ids").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
String inventoryAmounts = itemsResults.getString("inventory_item_amounts").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
|
||||
String[] ids = inventoryIds.split(", ");
|
||||
String[] amounts = inventoryAmounts.split(", ");
|
||||
Item[] items = new Item[ids.length];
|
||||
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
int id = Integer.parseInt(ids[i]);
|
||||
|
||||
if (id == -1) {
|
||||
items[i] = null;
|
||||
} else {
|
||||
items[i] = Item.create(id, Integer.parseInt(amounts[i]));
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().setItems(items);
|
||||
|
||||
String bankIds = itemsResults.getString("bank_item_ids").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
String bankAmounts = itemsResults.getString("bank_item_amounts").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
|
||||
ids = bankIds.split(", ");
|
||||
amounts = bankAmounts.split(", ");
|
||||
items = new Item[ids.length];
|
||||
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
int id = Integer.parseInt(ids[i]);
|
||||
|
||||
if (id == -1) {
|
||||
items[i] = null;
|
||||
} else {
|
||||
items[i] = Item.create(id, Integer.parseInt(amounts[i]));
|
||||
}
|
||||
}
|
||||
|
||||
player.getBank().getMain().setItems(items);
|
||||
|
||||
String equipmentIds = itemsResults.getString("equipment_item_ids").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
String equipmentAmounts = itemsResults.getString("equipment_item_amounts").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
|
||||
ids = equipmentIds.split(", ");
|
||||
amounts = equipmentAmounts.split(", ");
|
||||
items = new Item[ids.length];
|
||||
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
int id = Integer.parseInt(ids[i]);
|
||||
|
||||
if (id == -1) {
|
||||
items[i] = null;
|
||||
} else {
|
||||
items[i] = Item.create(id, Integer.parseInt(amounts[i]));
|
||||
}
|
||||
}
|
||||
|
||||
player.getEquipment().setItems(items);
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the contacts for the player.
|
||||
ResultSet contactsResults = SqlManager.manager.getResults(SqlManager.manager.playerContactsResultsStatement, player.getUniqueId());
|
||||
if (contactsResults != null) {
|
||||
while (contactsResults.next()) {
|
||||
String friendIds = contactsResults.getString("friends").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
String[] friends = friendIds.split(", ");
|
||||
|
||||
for (String friend : friends) {
|
||||
if (friend.length() != 0) {
|
||||
player.getContacts().getFriends().add(Long.parseLong(friend));
|
||||
}
|
||||
}
|
||||
|
||||
String ignoreIds = contactsResults.getString("ignores").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
String[] ignores = ignoreIds.split(", ");
|
||||
|
||||
for (String ignore : ignores) {
|
||||
if (ignore.length() != 0) {
|
||||
player.getContacts().getIgnores().add(Long.parseLong(ignore));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the settings for the player.
|
||||
ResultSet settingsResults = SqlManager.manager.getResults(SqlManager.manager.playerSettingsResultsStatement, player.getUniqueId());
|
||||
if (settingsResults != null) {
|
||||
while (settingsResults.next()) {
|
||||
player.setLoadedPosition(new Position(settingsResults.getInt("position_x"), settingsResults.getInt("position_y"), settingsResults.getInt("position_z")));
|
||||
player.setEnergy(settingsResults.getInt("run_energy"), false);
|
||||
player.setSpecialEnergy(settingsResults.getInt("special_energy"), false);
|
||||
player.setAttackStyle(settingsResults.getInt("attack_style"), false);
|
||||
String spellBook = settingsResults.getString("spell_book");
|
||||
player.setSpellBook(spellBook);
|
||||
player.getAppearance().setGender(settingsResults.getInt("gender"));
|
||||
player.getSettings().setAutoRetaliate(settingsResults.getInt("auto_retaliate") == 1);
|
||||
String[] emoteStatuses = settingsResults.getString("emote_status").replaceAll("\\[", "").replaceAll("\\]", "").split(", ");
|
||||
for (int i = 0; i < emoteStatuses.length; i++)
|
||||
player.getEmoteStatus()[i] = Integer.parseInt(emoteStatuses[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the skills for the player.
|
||||
ResultSet skillsResults = SqlManager.manager.getResults(SqlManager.manager.playerSkillsResultsStatement, player.getUniqueId());
|
||||
if (skillsResults != null) {
|
||||
while (skillsResults.next()) {
|
||||
int columnIndex = 2;
|
||||
|
||||
for (int i = 0; i < Skills.NUMBER_OF_SKILLS; i++) {
|
||||
int curLevel = skillsResults.getInt(columnIndex++);
|
||||
columnIndex++; // Omitting maxLevel
|
||||
double xp = skillsResults.getDouble(columnIndex++);
|
||||
|
||||
player.getSkills().setSkill(i, curLevel, xp, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
if (player.getUniqueId() == -1)
|
||||
return 3;
|
||||
|
||||
return 13;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the player's skills.
|
||||
*
|
||||
* @param statement
|
||||
* The prepared statement for saving.
|
||||
* @param player
|
||||
* The player's instance.
|
||||
* @param uniqueId
|
||||
* The player's ID.
|
||||
* @throws SQLException
|
||||
* On a MySQL failure.
|
||||
*/
|
||||
public static void saveSkills(PreparedStatement statement, Player player, int uniqueId) throws SQLException {
|
||||
int[] curLevels = player.getSkills().getCurLevels();
|
||||
int[] maxLevels = player.getSkills().getMaxLevels();
|
||||
double[] experience = player.getSkills().getExperience();
|
||||
|
||||
int totalCurLevels = 0;
|
||||
int totalMaxLevels = 0;
|
||||
double totalExp = 0.0;
|
||||
|
||||
int statementIndex = 0;
|
||||
|
||||
// Iterate through the skills.
|
||||
for (int i = 0; i < Skills.NUMBER_OF_SKILLS; i++) {
|
||||
statement.setInt(++statementIndex, curLevels[i]);
|
||||
statement.setInt(++statementIndex, maxLevels[i]);
|
||||
statement.setDouble(++statementIndex, experience[i]);
|
||||
|
||||
totalCurLevels += curLevels[i];
|
||||
totalMaxLevels += maxLevels[i];
|
||||
totalExp += experience[i];
|
||||
}
|
||||
|
||||
statement.setInt(++statementIndex, totalCurLevels);
|
||||
statement.setInt(++statementIndex, totalMaxLevels);
|
||||
statement.setDouble(++statementIndex, totalExp);
|
||||
|
||||
statement.setInt(++statementIndex, uniqueId);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the player's contacts.
|
||||
*
|
||||
* @param statement
|
||||
* The prepared statement for saving.
|
||||
* @param player
|
||||
* The player's instance.
|
||||
* @param uniqueId
|
||||
* The player's ID.
|
||||
* @throws SQLException
|
||||
* On a MySQL failure.
|
||||
*/
|
||||
public static void saveContacts(PreparedStatement statement, Player player, int uniqueId) throws SQLException {
|
||||
statement.setString(1, Arrays.toString(player.getContacts().getFriends().toArray(new Long[player.getContacts().getFriends().size()])));
|
||||
statement.setString(2, Arrays.toString(player.getContacts().getIgnores().toArray(new Long[player.getContacts().getIgnores().size()])));
|
||||
statement.setInt(3, uniqueId);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the player's items.
|
||||
*
|
||||
* @param statement
|
||||
* The prepared statement for saving.
|
||||
* @param player
|
||||
* The player's instance.
|
||||
* @param uniqueId
|
||||
* The player's ID.
|
||||
* @throws SQLException
|
||||
* On a MySQL failure.
|
||||
*/
|
||||
public static void saveItems(PreparedStatement statement, Player player, int uniqueId) throws SQLException {
|
||||
Item[][] containers = new Item[][] { player.getInventory().getItems(), player.getBank().getMain().getItems(), player.getEquipment().getItems() };
|
||||
int saveSlot = 1;
|
||||
|
||||
for (Item[] container : containers) {
|
||||
int[] itemIds = new int[container.length];
|
||||
int[] itemNs = new int[container.length];
|
||||
|
||||
for (int i = 0; i < container.length; i++) {
|
||||
Item item = container[i];
|
||||
|
||||
if (item == null) {
|
||||
itemIds[i] = -1;
|
||||
itemNs[i] = 0;
|
||||
} else {
|
||||
itemIds[i] = item.getId();
|
||||
itemNs[i] = item.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
statement.setString(saveSlot, Arrays.toString(itemIds));
|
||||
saveSlot++;
|
||||
|
||||
statement.setString(saveSlot, Arrays.toString(itemNs));
|
||||
saveSlot++;
|
||||
}
|
||||
|
||||
statement.setInt(saveSlot, uniqueId);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the player's settings.
|
||||
*
|
||||
* @param statement
|
||||
* The prepared statement for saving.
|
||||
* @param player
|
||||
* The player's instance.
|
||||
* @param uniqueId
|
||||
* The player's ID.
|
||||
* @throws SQLException
|
||||
* On a MySQL failure.
|
||||
*/
|
||||
public static void saveSettings(PreparedStatement statement, Player player, int uniqueId) throws SQLException {
|
||||
statement.setInt(1, player.getPosition().getX());
|
||||
statement.setInt(2, player.getPosition().getY());
|
||||
statement.setInt(3, player.getPosition().getZ());
|
||||
statement.setInt(4, player.getEnergy());
|
||||
statement.setInt(5, player.getSpecialEnergy());
|
||||
statement.setInt(6, player.getAttackStyle());
|
||||
statement.setString(7, player.getSpellBook().name());
|
||||
statement.setInt(8, player.getAppearance().getGender());
|
||||
statement.setInt(9, player.getSettings().isAutoRetaliate() ? 1 : 0);
|
||||
statement.setString(10, Arrays.toString(player.getEmoteStatus()));
|
||||
statement.setInt(11, uniqueId);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
}
|
186
src/osiris/data/SettingsLoader.java
Normal file
186
src/osiris/data/SettingsLoader.java
Normal file
@ -0,0 +1,186 @@
|
||||
package osiris.data;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SettingsLoader.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class SettingsLoader {
|
||||
|
||||
/** The Constant FILE_EXTENSION. */
|
||||
private static final String FILE_EXTENSION = ".ini";
|
||||
|
||||
/** The Constant SETTINGS_LOCATION. */
|
||||
private static final String SETTINGS_LOCATION = "./";
|
||||
|
||||
/** The settings. */
|
||||
private static Hashtable<String, String> settings = new Hashtable<String, String>();
|
||||
|
||||
/**
|
||||
* Searches for all files ending with FILE_EXTENSION and parses them
|
||||
* accordingly.
|
||||
*
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static void load() throws IOException {
|
||||
boolean found = false;
|
||||
File root = new File(SETTINGS_LOCATION);
|
||||
for (File child : root.listFiles()) {
|
||||
if (child == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!child.getName().endsWith(FILE_EXTENSION)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BufferedReader in = new BufferedReader(new FileReader(child));
|
||||
List<String> lines = new ArrayList<String>();
|
||||
while (true) {
|
||||
String line = in.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
lines.add(line);
|
||||
}
|
||||
doParsing(lines.toArray(new String[0]));
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
createDefault();
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default.
|
||||
*
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private static void createDefault() throws IOException {
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(new File(SETTINGS_LOCATION + "settings" + FILE_EXTENSION)));
|
||||
final String[] keys = { "server_port", "server_name", "exp_rate", "sqlite_saving", "server_host", "server_database", "server_username", "server_password", "start_x", "start_y", "start_z" };
|
||||
|
||||
final String[] values = { "43594", "Osiris", "10", "true", "localhost", "database", "root", "admin", "3082", "3419", "0" };
|
||||
|
||||
out.write("# Generated on " + new Date());
|
||||
out.newLine();
|
||||
out.newLine();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
out.write(keys[i].toUpperCase() + ": " + values[i]);
|
||||
out.newLine();
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the keys and values to a Hashtable for later use.
|
||||
*
|
||||
* @param lines
|
||||
* the lines
|
||||
*/
|
||||
private static void doParsing(String[] lines) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String line = lines[i];
|
||||
int number = (i + 1);
|
||||
|
||||
if (line == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.matches("\\s*") || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] args = line.split("\\s*(=|:)\\s*");
|
||||
if (args.length < 2) {
|
||||
System.out.println("Missing argument at line " + number);
|
||||
continue;
|
||||
}
|
||||
|
||||
String key = args[0];
|
||||
String value = args[1];
|
||||
settings.put(key.toLowerCase(), value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
*
|
||||
* @param key
|
||||
* the key
|
||||
* @return the value
|
||||
*/
|
||||
public static String getValue(String key) {
|
||||
return settings.get(key.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value as int.
|
||||
*
|
||||
* @param key
|
||||
* the key
|
||||
* @return the value as int
|
||||
*/
|
||||
public static int getValueAsInt(String key) {
|
||||
return Integer.parseInt(getValue(key).trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value as boolean.
|
||||
*
|
||||
* @param key
|
||||
* the key
|
||||
* @return the value as boolean
|
||||
*/
|
||||
public static boolean getValueAsBoolean(String key) {
|
||||
return Boolean.parseBoolean(settings.get(key.toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains.
|
||||
*
|
||||
* @param key
|
||||
* the key
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean contains(String key) {
|
||||
return settings.containsKey(key.toLowerCase());
|
||||
}
|
||||
}
|
154
src/osiris/data/parser/Parser.java
Normal file
154
src/osiris/data/parser/Parser.java
Normal file
@ -0,0 +1,154 @@
|
||||
package osiris.data.parser;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Parser.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public abstract class Parser implements Runnable {
|
||||
|
||||
/** The file. */
|
||||
private File file;
|
||||
|
||||
/**
|
||||
* Instantiates a new parser with a pre-given directory.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public Parser(String file) {
|
||||
this(new File("./data/config/" + file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public Parser(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(getFile());
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
// XXX: We can use this to parse other files with the same parser.
|
||||
doIncludeTag(doc);
|
||||
|
||||
onParse(doc);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Anything done on parse.
|
||||
*
|
||||
* @param doc
|
||||
* the doc
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public abstract void onParse(Document doc) throws Exception;
|
||||
|
||||
/**
|
||||
* If there is an include tag, we change the file name and run the thread.
|
||||
* This way we can have XML files calling other files with the same parser.
|
||||
*
|
||||
* @param doc
|
||||
* the doc
|
||||
*/
|
||||
private void doIncludeTag(Document doc) {
|
||||
Element includeElement = (Element) doc.getElementsByTagName("include").item(0);
|
||||
if (includeElement != null) {
|
||||
String dir = "./data/config/";
|
||||
if (includeElement.getAttribute("dir") != null) {
|
||||
dir = includeElement.getAttribute("dir");
|
||||
}
|
||||
setFile(new File(dir + includeElement.getAttribute("name")));
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value inside the specified tag as a String.
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @param tag
|
||||
* the tag
|
||||
* @return the text value
|
||||
*/
|
||||
public String getTextValue(Element element, String tag) {
|
||||
NodeList list = element.getElementsByTagName(tag);
|
||||
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (list.getLength() <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Element tmp = (Element) list.item(0);
|
||||
return tmp.getFirstChild().getNodeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
private void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file.
|
||||
*
|
||||
* @return the file
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
}
|
76
src/osiris/data/parser/ParserLookup.java
Normal file
76
src/osiris/data/parser/ParserLookup.java
Normal file
@ -0,0 +1,76 @@
|
||||
package osiris.data.parser;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.data.parser.impl.DialogueParser;
|
||||
import osiris.data.parser.impl.GroundItemParser;
|
||||
import osiris.data.parser.impl.NpcDropParser;
|
||||
import osiris.data.parser.impl.NpcSpawnParser;
|
||||
import osiris.data.parser.impl.PositionChangeParser;
|
||||
import osiris.data.parser.impl.WorldObjectParser;
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Runs all the various parsers at once. Basically for convenience only.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class ParserLookup {
|
||||
|
||||
/** The parsers. */
|
||||
private static List<Parser> parsers = new ArrayList<Parser>();
|
||||
|
||||
/**
|
||||
* Adds the parsers.
|
||||
*
|
||||
* TODO: Possibly make a parser for this as well.
|
||||
*
|
||||
*/
|
||||
private static void addParsers() {
|
||||
parsers.add(new DialogueParser(Settings.DIALOGUES));
|
||||
parsers.add(new PositionChangeParser(Settings.POSITION_CHANGE));
|
||||
parsers.add(new GroundItemParser(Settings.GROUND_ITEMS));
|
||||
parsers.add(new NpcDropParser(Settings.NPC_DROPS));
|
||||
parsers.add(new NpcSpawnParser(Settings.NPC_SPAWNS));
|
||||
parsers.add(new WorldObjectParser(Settings.WORLD_OBJECTS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Do run.
|
||||
*/
|
||||
public static void doRun() {
|
||||
addParsers();
|
||||
for (Parser parser : parsers) {
|
||||
if (parser == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Main.isLocal()) {
|
||||
System.out.println("[Parser]: Running '" + parser.getFile().getName() + "' parser...");
|
||||
}
|
||||
new Thread(parser).run();
|
||||
}
|
||||
}
|
||||
}
|
95
src/osiris/data/parser/impl/DialogueParser.java
Normal file
95
src/osiris/data/parser/impl/DialogueParser.java
Normal file
@ -0,0 +1,95 @@
|
||||
package osiris.data.parser.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.data.parser.Parser;
|
||||
import osiris.game.model.dialogues.Dialogue;
|
||||
import osiris.game.model.dialogues.Dialogue.Type;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class DialogueParser.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class DialogueParser extends Parser {
|
||||
|
||||
/**
|
||||
* Instantiates a new dialogue parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public DialogueParser(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.data.parser.Parser#onParse(org.w3c.dom.Document)
|
||||
*/
|
||||
@Override
|
||||
public void onParse(Document doc) throws Exception {
|
||||
NodeList dialogueList = (NodeList) doc.getElementsByTagName("dialogue");
|
||||
if (dialogueList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < dialogueList.getLength(); i++) {
|
||||
Element dialogueElement = (Element) dialogueList.item(i);
|
||||
|
||||
Type type = Type.valueOf(dialogueElement.getAttribute("type").toUpperCase());
|
||||
int id = Integer.parseInt(dialogueElement.getAttribute("id"));
|
||||
Dialogue dialogue = new Dialogue(type, id);
|
||||
|
||||
String[] params = getTextValue(dialogueElement, "npc").split(",");
|
||||
for (int l = 0; l < params.length; l++) {
|
||||
Dialogue clone = new Dialogue(dialogue);
|
||||
clone.setNpc(Integer.parseInt(params[l]));
|
||||
|
||||
Element linesElement = (Element) dialogueElement.getElementsByTagName("lines").item(0);
|
||||
clone.setTitle(linesElement.getAttribute("title"));
|
||||
|
||||
NodeList lineList = (NodeList) linesElement.getElementsByTagName("line");
|
||||
List<String> lines = new ArrayList<String>();
|
||||
for (int j = 0; j < lineList.getLength(); j++) {
|
||||
Element lineElement = (Element) lineList.item(j);
|
||||
lines.add(lineElement.getFirstChild().getNodeValue());
|
||||
}
|
||||
|
||||
if (clone.getType() == Type.OPTION && lines.size() < 2) {
|
||||
lines.add("");
|
||||
}
|
||||
clone.setLines(lines);
|
||||
clone.setNext(Integer.parseInt(getTextValue(dialogueElement, "next")));
|
||||
Main.getDialogues().add(clone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
92
src/osiris/data/parser/impl/GroundItemParser.java
Normal file
92
src/osiris/data/parser/impl/GroundItemParser.java
Normal file
@ -0,0 +1,92 @@
|
||||
package osiris.data.parser.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.util.Settings.DEFAULT_Z;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import osiris.data.parser.Parser;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.ground.GroundItem;
|
||||
import osiris.game.model.ground.GroundManager;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class GroundItemParser.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class GroundItemParser extends Parser {
|
||||
|
||||
/**
|
||||
* Instantiates a new ground item parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public GroundItemParser(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.data.parser.Parser#onParse(org.w3c.dom.Document)
|
||||
*/
|
||||
@Override
|
||||
public void onParse(Document doc) throws Exception {
|
||||
NodeList itemsList = (NodeList) doc.getElementsByTagName("ground");
|
||||
if (itemsList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemsList.getLength(); i++) {
|
||||
Element itemElement = (Element) itemsList.item(i);
|
||||
int id = Integer.parseInt(itemElement.getAttribute("id"));
|
||||
|
||||
int amount = 1;
|
||||
if (ItemDef.forId(id).isStackable()) {
|
||||
String amountAttribute = itemElement.getAttribute("amount").trim();
|
||||
if (amountAttribute != null) {
|
||||
amount = Integer.parseInt(amountAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
String respawnAttribute = itemElement.getAttribute("respawn");
|
||||
boolean respawn = respawnAttribute != null && Boolean.parseBoolean(respawnAttribute);
|
||||
|
||||
int x = Integer.parseInt(getTextValue(itemElement, "X").trim());
|
||||
int y = Integer.parseInt(getTextValue(itemElement, "Y").trim());
|
||||
|
||||
String zNode = getTextValue(itemElement, "Z");
|
||||
int z = DEFAULT_Z;
|
||||
if (zNode != null) {
|
||||
z = Integer.parseInt(zNode.trim());
|
||||
}
|
||||
GroundItem item = new GroundItem(Item.create(id, amount).setRespawns(respawn), new Position(x, y, z));
|
||||
GroundManager.getManager().dropItem(item);
|
||||
}
|
||||
}
|
||||
}
|
98
src/osiris/data/parser/impl/NpcDropParser.java
Normal file
98
src/osiris/data/parser/impl/NpcDropParser.java
Normal file
@ -0,0 +1,98 @@
|
||||
package osiris.data.parser.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import osiris.data.NpcDropLoader;
|
||||
import osiris.data.parser.Parser;
|
||||
import osiris.game.model.NpcDrop;
|
||||
import osiris.game.model.NpcDropContainer;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class NpcDropParser.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
* @author Boomer
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class NpcDropParser extends Parser {
|
||||
|
||||
/**
|
||||
* Instantiates a new npc drop parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public NpcDropParser(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.data.parser.Parser#onParse(org.w3c.dom.Document)
|
||||
*/
|
||||
@Override
|
||||
public void onParse(Document doc) throws Exception {
|
||||
NodeList dropList = doc.getElementsByTagName("npcDrop");
|
||||
for (int i = 0; i < dropList.getLength(); i++) {
|
||||
Element dropElement = (Element) dropList.item(i);
|
||||
NpcDropContainer container;
|
||||
List<Integer> npcIds = new ArrayList<Integer>();
|
||||
List<NpcDrop> npcDrops = new ArrayList<NpcDrop>();
|
||||
|
||||
// Get the NPC IDs.
|
||||
Element npcIdsElement = (Element) dropElement.getElementsByTagName("npcIds").item(0);
|
||||
if (npcIdsElement != null) {
|
||||
String value = npcIdsElement.getFirstChild().getNodeValue();
|
||||
StringTokenizer st = new StringTokenizer(value, ", ");
|
||||
while (st.hasMoreTokens()) {
|
||||
Integer id = Integer.parseInt(st.nextToken());
|
||||
npcIds.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the items.
|
||||
NodeList itemsList = (NodeList) dropElement.getElementsByTagName("item");
|
||||
for (int n = 0; n < itemsList.getLength(); n++) {
|
||||
Element itemElement = (Element) itemsList.item(n);
|
||||
int itemId = Integer.parseInt(itemElement.getAttribute("id"));
|
||||
String amount = itemElement.getAttribute("amount");
|
||||
double chance = Double.parseDouble(itemElement.getAttribute("chance").replaceAll("%", "")) / 100;
|
||||
StringTokenizer st = new StringTokenizer(amount, "-");
|
||||
if (st.countTokens() == 1)
|
||||
npcDrops.add(new NpcDrop(itemId, Integer.parseInt(st.nextToken()), chance));
|
||||
else
|
||||
npcDrops.add(new NpcDrop(itemId, Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()), chance));
|
||||
}
|
||||
|
||||
container = new NpcDropContainer(npcIds, npcDrops);
|
||||
NpcDropLoader.add(container);
|
||||
}
|
||||
}
|
||||
}
|
117
src/osiris/data/parser/impl/NpcSpawnParser.java
Normal file
117
src/osiris/data/parser/impl/NpcSpawnParser.java
Normal file
@ -0,0 +1,117 @@
|
||||
package osiris.data.parser.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.util.Settings.DEFAULT_X;
|
||||
import static osiris.util.Settings.DEFAULT_Y;
|
||||
import static osiris.util.Settings.DEFAULT_Z;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.data.parser.Parser;
|
||||
import osiris.game.model.Npc;
|
||||
import osiris.game.model.Position;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class NpcSpawnParser.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
* @author samuraiblood2
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class NpcSpawnParser extends Parser {
|
||||
|
||||
/**
|
||||
* Instantiates a new npc spawn parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public NpcSpawnParser(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.data.parser.Parser#onParse(org.w3c.dom.Document)
|
||||
*/
|
||||
@Override
|
||||
public void onParse(Document doc) throws Exception {
|
||||
NodeList npcList = (NodeList) doc.getElementsByTagName("npc");
|
||||
for (int i = 0; i < npcList.getLength(); i++) {
|
||||
int npcID = 1;
|
||||
int posX = DEFAULT_X, posY = DEFAULT_Y, posZ = DEFAULT_Z;
|
||||
int minX = DEFAULT_X, minY = DEFAULT_Y, maxX = DEFAULT_Z, maxY = DEFAULT_Y;
|
||||
Position defaultFacing = null;
|
||||
@SuppressWarnings("unused")
|
||||
int health = 0, maxHit = 1, accuracy = 0, defence = 0, attackSpeed = 3;
|
||||
// Load the NPC ID.
|
||||
Element npcElement = (Element) npcList.item(i);
|
||||
npcID = Integer.parseInt(npcElement.getAttribute("id"));
|
||||
|
||||
// Load the position.
|
||||
Element posElement = (Element) npcElement.getElementsByTagName("position").item(0);
|
||||
if (posElement != null) {
|
||||
posX = Integer.parseInt(posElement.getAttribute("x"));
|
||||
posY = Integer.parseInt(posElement.getAttribute("y"));
|
||||
posZ = Integer.parseInt(posElement.getAttribute("z"));
|
||||
}
|
||||
|
||||
// Load the movement missile.
|
||||
Element rangeElement = (Element) npcElement.getElementsByTagName("movementRange").item(0);
|
||||
if (rangeElement != null) {
|
||||
minX = Integer.parseInt(rangeElement.getAttribute("minX"));
|
||||
minY = Integer.parseInt(rangeElement.getAttribute("minY"));
|
||||
maxX = Integer.parseInt(rangeElement.getAttribute("maxX"));
|
||||
maxY = Integer.parseInt(rangeElement.getAttribute("maxY"));
|
||||
}
|
||||
|
||||
Element faceElement = (Element) npcElement.getElementsByTagName("face").item(0);
|
||||
if (faceElement != null) {
|
||||
int faceX = posX;
|
||||
int faceY = posY;
|
||||
String facing = faceElement.getTextContent().toLowerCase();
|
||||
if (facing.contains("north"))
|
||||
faceY += 1;
|
||||
else if (facing.contains("south"))
|
||||
faceY -= 1;
|
||||
if (facing.contains("west"))
|
||||
faceX -= 1;
|
||||
else if (facing.contains("east"))
|
||||
faceX += 1;
|
||||
defaultFacing = new Position(faceX, faceY, posZ);
|
||||
}
|
||||
|
||||
// Make the NPC object and register it with the world.
|
||||
Npc npc = new Npc(npcID);
|
||||
npc.getPosition().set(posX, posY, posZ);
|
||||
npc.setDefaultPosition(npc.getPosition());
|
||||
npc.setWalkingRange(minX, minY, maxX, maxY);
|
||||
npc.setDefaultFacing(defaultFacing);
|
||||
Main.getNpcs().add(npc);
|
||||
}
|
||||
}
|
||||
}
|
252
src/osiris/data/parser/impl/PositionChangeParser.java
Normal file
252
src/osiris/data/parser/impl/PositionChangeParser.java
Normal file
@ -0,0 +1,252 @@
|
||||
package osiris.data.parser.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.data.parser.Parser;
|
||||
import osiris.game.model.Position;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* I The Class PositionChangeParser.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class PositionChangeParser extends Parser {
|
||||
|
||||
/**
|
||||
* Instantiates a new position change parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public PositionChangeParser(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.data.parser.Parser#onParse(org.w3c.dom.Document)
|
||||
*/
|
||||
@Override
|
||||
public void onParse(Document doc) throws Exception {
|
||||
NodeList positionList = (NodeList) doc.getElementsByTagName("pos");
|
||||
if (positionList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < positionList.getLength(); i++) {
|
||||
Element positionElement = (Element) positionList.item(i);
|
||||
int id = Integer.parseInt(positionElement.getAttribute("id"));
|
||||
if (id < 0) {
|
||||
throw new Exception("Object ID must be higher than 0.");
|
||||
}
|
||||
|
||||
int x = Integer.parseInt(positionElement.getAttribute("x"));
|
||||
int y = Integer.parseInt(positionElement.getAttribute("y"));
|
||||
int z = 0;
|
||||
if (!positionElement.getAttribute("z").matches("\\s*")) {
|
||||
z = Integer.parseInt(positionElement.getAttribute("z"));
|
||||
}
|
||||
PositionChangeInfo positionInfo = new PositionChangeInfo(id, new Position(x, y, z));
|
||||
|
||||
Element door = (Element) positionElement.getElementsByTagName("swing").item(0);
|
||||
if (door != null) {
|
||||
String currentFace = door.getAttribute("current").toUpperCase();
|
||||
WorldObjectParser.Face current = WorldObjectParser.Face.valueOf(currentFace);
|
||||
if (current == null) {
|
||||
throw new Exception("Incorrect face value.");
|
||||
}
|
||||
positionInfo.setCurrent(current);
|
||||
positionInfo.setFrom(current);
|
||||
|
||||
String toFace = door.getAttribute("to").toUpperCase();
|
||||
WorldObjectParser.Face to = WorldObjectParser.Face.valueOf(toFace);
|
||||
if (to == null) {
|
||||
throw new Exception("Incorrect face value.");
|
||||
}
|
||||
positionInfo.setTo(to);
|
||||
positionInfo.setType(Type.DOOR);
|
||||
} else {
|
||||
for (int i2 = 0; i2 < 2; i2++) {
|
||||
Element direction = (Element) positionElement.getElementsByTagName(i2 == 0 ? "up" : "down").item(0);
|
||||
if (direction == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Position pos = createPositionFromElement(direction);
|
||||
if (i2 == 0) {
|
||||
positionInfo.setMove(0, pos);
|
||||
} else {
|
||||
positionInfo.setMove(1, pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (positionInfo.getMove(0) == null && positionInfo.getMove(1) == null) {
|
||||
throw new Exception("Must have the up or down tag present.");
|
||||
}
|
||||
positionInfo.setType(Type.STAIR);
|
||||
}
|
||||
|
||||
Main.getStairs().add(positionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the position from element.
|
||||
*
|
||||
* @param element
|
||||
* the element
|
||||
* @return the position
|
||||
*/
|
||||
private Position createPositionFromElement(Element element) {
|
||||
int moveX = Integer.parseInt(element.getAttribute("x"));
|
||||
int moveY = Integer.parseInt(element.getAttribute("y"));
|
||||
int moveZ = 0;
|
||||
if (!element.getAttribute("z").matches("\\s*")) {
|
||||
moveZ = Integer.parseInt(element.getAttribute("z"));
|
||||
}
|
||||
|
||||
return new Position(moveX, moveY, moveZ);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
DOOR, STAIR
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class PositionChangeInfo.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class PositionChangeInfo {
|
||||
|
||||
/** The id. */
|
||||
private int id;
|
||||
|
||||
/** The location. */
|
||||
private Position location;
|
||||
|
||||
/** The move. */
|
||||
private Position[] move;
|
||||
|
||||
/** The face. */
|
||||
private WorldObjectParser.Face current, from, to;
|
||||
|
||||
private Type type;
|
||||
|
||||
/**
|
||||
* Instantiates a new position change info.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param location
|
||||
* the location
|
||||
*/
|
||||
public PositionChangeInfo(int id, Position location) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
move = new Position[2];
|
||||
}
|
||||
|
||||
public PositionChangeInfo setType(Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lcation.
|
||||
*/
|
||||
public void setLocation(Position location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location.
|
||||
*
|
||||
* @return the location
|
||||
*/
|
||||
public Position getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setMove(int index, Position position) {
|
||||
move[index] = position;
|
||||
}
|
||||
|
||||
public Position getMove(int index) {
|
||||
return move[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the face.
|
||||
*
|
||||
* @param current
|
||||
* the new face
|
||||
*/
|
||||
public void setCurrent(WorldObjectParser.Face current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the face.
|
||||
*
|
||||
* @return the face
|
||||
*/
|
||||
public WorldObjectParser.Face getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setTo(WorldObjectParser.Face to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public WorldObjectParser.Face getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setFrom(WorldObjectParser.Face from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public WorldObjectParser.Face getFrom() {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
}
|
172
src/osiris/data/parser/impl/WorldObjectParser.java
Normal file
172
src/osiris/data/parser/impl/WorldObjectParser.java
Normal file
@ -0,0 +1,172 @@
|
||||
package osiris.data.parser.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import osiris.data.parser.Parser;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.model.WorldObject;
|
||||
import osiris.game.model.WorldObjects;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class WorldObjectParser.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class WorldObjectParser extends Parser {
|
||||
|
||||
/**
|
||||
* Instantiates a new world object parser.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public WorldObjectParser(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum Face.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public enum Face {
|
||||
|
||||
NORTH(2), SOUTH(0), EAST(3), WEST(1);
|
||||
|
||||
/** The id. */
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* Instantiates a new face.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
Face(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum Type.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/** The WALL. */
|
||||
WALL(0), /** The WAL l_ decor. */
|
||||
WALL_DECOR(4), /** The DIA g_ wall. */
|
||||
DIAG_WALL(9), /** The WORLD. */
|
||||
WORLD(10), /** The ROOF. */
|
||||
ROOF(12), /** The FLOOR. */
|
||||
FLOOR(22);
|
||||
|
||||
/** The id. */
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* Instantiates a new type.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
Type(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.data.parser.Parser#onParse(org.w3c.dom.Document)
|
||||
*/
|
||||
@Override
|
||||
public void onParse(Document doc) throws Exception {
|
||||
NodeList objectList = (NodeList) doc.getElementsByTagName("object");
|
||||
if (objectList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<WorldObject> list = new ArrayList<WorldObject>();
|
||||
for (int i = 0; i < objectList.getLength(); i++) {
|
||||
Element objectElement = (Element) objectList.item(i);
|
||||
String idAttribute = objectElement.getAttribute("id");
|
||||
int id = 0;
|
||||
if (idAttribute.equalsIgnoreCase("remove")) {
|
||||
id = 6951;
|
||||
} else {
|
||||
id = Integer.parseInt(idAttribute);
|
||||
}
|
||||
|
||||
int x = Integer.parseInt(objectElement.getAttribute("x"));
|
||||
int y = Integer.parseInt(objectElement.getAttribute("y"));
|
||||
int z = 0;
|
||||
if (!objectElement.getAttribute("z").contains("")) {
|
||||
z = Integer.parseInt(objectElement.getAttribute("z"));
|
||||
}
|
||||
Face face = Face.WEST;
|
||||
if (id != 6951) {
|
||||
face = Face.valueOf(getTextValue(objectElement, "face").toUpperCase().replaceAll(" ", "_").trim());
|
||||
}
|
||||
|
||||
String value = getTextValue(objectElement, "type");
|
||||
Type type = Type.WORLD;
|
||||
if (value.equalsIgnoreCase("all")) {
|
||||
for (int l = 0; l < 22; l++) {
|
||||
list.add(new WorldObject(id, face.getId(), l, new Position(x, y, z)));
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
type = Type.valueOf(value.toUpperCase().replaceAll(" ", "_").trim());
|
||||
}
|
||||
list.add(new WorldObject(id, face.getId(), type.getId(), new Position(x, y, z)));
|
||||
}
|
||||
WorldObjects.getObjects().addAll(list);
|
||||
}
|
||||
}
|
139
src/osiris/data/sql/SqlConnection.java
Normal file
139
src/osiris/data/sql/SqlConnection.java
Normal file
@ -0,0 +1,139 @@
|
||||
package osiris.data.sql;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SqlConnection.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class SqlConnection {
|
||||
|
||||
/** The password. */
|
||||
private final String host, database, username, password;
|
||||
|
||||
/** The connection. */
|
||||
private Connection connection;
|
||||
|
||||
/**
|
||||
* Instantiates a new sql connection.
|
||||
*
|
||||
* @param host
|
||||
* the host
|
||||
* @param database
|
||||
* the database
|
||||
* @param username
|
||||
* the username
|
||||
* @param password
|
||||
* the password
|
||||
*/
|
||||
public SqlConnection(final String host, final String database, final String username, final String password) {
|
||||
this.host = host;
|
||||
this.database = database;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the connection.
|
||||
*
|
||||
* @return the connection
|
||||
*/
|
||||
public Connection getConnection() {
|
||||
try {
|
||||
if (connection == null || connection.isClosed())
|
||||
connect();
|
||||
} catch (SQLException e) {
|
||||
connect();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect.
|
||||
*/
|
||||
public void connect() {
|
||||
String tag = "[SQL" + (Settings.SQLITE_SAVING ? "ite" : "") + "]";
|
||||
try {
|
||||
if (Main.isLocal()) {
|
||||
System.out.println(tag + " Connecting to Database (" + database + ")... ");
|
||||
}
|
||||
|
||||
if (!Settings.SQLITE_SAVING) {
|
||||
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
||||
String url = "jdbc:mysql://" + host + "/" + database;
|
||||
connection = DriverManager.getConnection(url, username, password);
|
||||
} else {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:./data/database/osirisdb.sqlite");
|
||||
|
||||
}
|
||||
|
||||
if (Main.isLocal()) {
|
||||
System.out.println(tag + " SUCCESS!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(tag + " FAILURE: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the host.
|
||||
*
|
||||
* @return the host
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database.
|
||||
*
|
||||
* @return the database
|
||||
*/
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the password.
|
||||
*
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
161
src/osiris/data/sql/SqlManager.java
Normal file
161
src/osiris/data/sql/SqlManager.java
Normal file
@ -0,0 +1,161 @@
|
||||
package osiris.data.sql;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SqlManager.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class SqlManager {
|
||||
|
||||
/** The server connection. */
|
||||
public SqlConnection serverConnection;
|
||||
|
||||
/** The player settings replace statement. */
|
||||
public PreparedStatement serverPlayerResultsStatement, serverPlayerReplaceStatement, playerSkillsResultsStatement, playerSkillsReplaceStatement, playerContactsResultsStatement, playerContactsReplaceStatement, playerItemsResultsStatement, playerItemsReplaceStatement, playerSettingsResultsStatement, playerSettingsReplaceStatement;
|
||||
|
||||
/**
|
||||
* Instantiates a new sql manager.
|
||||
*/
|
||||
public SqlManager() {
|
||||
serverConnection = new SqlConnection(Settings.SERVER_HOST, Settings.SERVER_DATABASE, Settings.SERVER_USERNAME, Settings.SERVER_PASSWORD);
|
||||
serverConnection.connect();
|
||||
|
||||
String serverPlayerResultsQuery = "SELECT * FROM players WHERE name = ?";
|
||||
String playerSkillsResultsQuery = "SELECT * FROM skills WHERE player_id = ?";
|
||||
String playerContactsResultsQuery = "SELECT * FROM contacts WHERE player_id = ?";
|
||||
String playerItemsResultsQuery = "SELECT * FROM items WHERE player_id = ?";
|
||||
String playerSettingsResultsQuery = "SELECT * FROM settings WHERE player_id = ?";
|
||||
|
||||
String serverPlayerReplaceQuery = "REPLACE INTO players (`name` ,`password`, `ip`, `status`, `salt`) VALUES (?, ?, ?, ?, ?);";
|
||||
String playerSkillsReplaceQuery = "REPLACE INTO skills (`attack_curlevel`, `attack_maxlevel`, `attack_xp`, `defence_curlevel`, `defence_maxlevel`, `defence_xp`, `strength_curlevel`, `strength_maxlevel`, `strength_xp`, `hitpoints_curlevel`, `hitpoints_maxlevel`, `hitpoints_xp`, `range_curlevel`, `range_maxlevel`, `range_xp`, `prayer_curlevel`, `prayer_maxlevel`, `prayer_xp`, `magic_curlevel`, `magic_maxlevel`, `magic_xp`, `cooking_curlevel`, `cooking_maxlevel`, `cooking_xp`, `woodcutting_curlevel`, `woodcutting_maxlevel`, `woodcutting_xp`, `fletching_curlevel`, `fletching_maxlevel`, `fletching_xp`, `fishing_curlevel`, `fishing_maxlevel`, `fishing_xp`, `firemaking_curlevel`, `firemaking_maxlevel`, `firemaking_xp`, `crafting_curlevel`, `crafting_maxlevel`, `crafting_xp`, `smithing_curlevel`, `smithing_maxlevel`, `smithing_xp`, `mining_curlevel`, `mining_maxlevel`, `mining_xp`, `herblore_curlevel`, `herblore_maxlevel`, `herblore_xp`, `agility_curlevel`, `agility_maxlevel`, `agility_xp`, `thieving_curlevel`, `thieving_maxlevel`, `thieving_xp`, `slayer_curlevel`, `slayer_maxlevel`, `slayer_xp`, `farming_curlevel`, `farming_maxlevel`, `farming_xp`, `runecrafting_curlevel`, `runecrafting_maxlevel`, `runecrafting_xp`, `construction_curlevel`, `construction_maxlevel`, `construction_xp`, `hunter_curlevel`, `hunter_maxlevel`, `hunter_xp`, `summoning_curlevel`, `summoning_maxlevel`, `summoning_xp`, `overall_curlevel`, `overall_maxlevel`, `overall_xp`, `player_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String playerContactsReplaceQuery = "REPLACE INTO contacts (`friends`, `ignores`, `player_id`) VALUES (?, ?, ?);";
|
||||
String playerItemsReplaceQuery = "REPLACE INTO items (`inventory_item_ids`, `inventory_item_amounts`, `bank_item_ids`, `bank_item_amounts`, `equipment_item_ids`, `equipment_item_amounts`, `player_id`) VALUES (?, ?, ?, ?, ?, ?, ?);";
|
||||
String playerSettingsReplaceQuery = "REPLACE INTO settings (`position_x`, `position_y`, `position_z`, `run_energy`, `special_energy`, `attack_style`, `spell_book`, `gender`, `auto_retaliate`, `emote_status`, `player_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
try {
|
||||
serverPlayerResultsStatement = serverConnection.getConnection().prepareStatement(serverPlayerResultsQuery);
|
||||
serverPlayerReplaceStatement = serverConnection.getConnection().prepareStatement(serverPlayerReplaceQuery);
|
||||
|
||||
playerSkillsReplaceStatement = serverConnection.getConnection().prepareStatement(playerSkillsReplaceQuery);
|
||||
playerSkillsResultsStatement = serverConnection.getConnection().prepareStatement(playerSkillsResultsQuery);
|
||||
|
||||
playerContactsReplaceStatement = serverConnection.getConnection().prepareStatement(playerContactsReplaceQuery);
|
||||
playerContactsResultsStatement = serverConnection.getConnection().prepareStatement(playerContactsResultsQuery);
|
||||
|
||||
playerItemsReplaceStatement = serverConnection.getConnection().prepareStatement(playerItemsReplaceQuery);
|
||||
playerItemsResultsStatement = serverConnection.getConnection().prepareStatement(playerItemsResultsQuery);
|
||||
|
||||
playerSettingsReplaceStatement = serverConnection.getConnection().prepareStatement(playerSettingsReplaceQuery);
|
||||
playerSettingsResultsStatement = serverConnection.getConnection().prepareStatement(playerSettingsResultsQuery);
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load.
|
||||
*/
|
||||
public static void load() {
|
||||
manager = new SqlManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the results.
|
||||
*
|
||||
* @param statement
|
||||
* the statement
|
||||
* @param value
|
||||
* the value
|
||||
* @return the results
|
||||
*/
|
||||
public ResultSet getResults(PreparedStatement statement, String value) {
|
||||
try {
|
||||
statement.setString(1, value);
|
||||
return statement.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all results.
|
||||
*
|
||||
* @param table
|
||||
* the table
|
||||
* @return the all results
|
||||
*/
|
||||
public ResultSet getAllResults(String table) {
|
||||
try {
|
||||
return serverConnection.getConnection().createStatement().executeQuery("SELECT * FROM " + table + "");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the results.
|
||||
*
|
||||
* @param query
|
||||
* the query
|
||||
* @return the results
|
||||
*/
|
||||
public ResultSet getResults(String query) {
|
||||
try {
|
||||
return serverConnection.getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the results.
|
||||
*
|
||||
* @param statement
|
||||
* the statement
|
||||
* @param value
|
||||
* the value
|
||||
* @return the results
|
||||
*/
|
||||
public ResultSet getResults(PreparedStatement statement, int value) {
|
||||
try {
|
||||
statement.setInt(1, value);
|
||||
return statement.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The manager. */
|
||||
public static SqlManager manager;
|
||||
}
|
123
src/osiris/game/action/Action.java
Normal file
123
src/osiris/game/action/Action.java
Normal file
@ -0,0 +1,123 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.impl.TeleportAction;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Death;
|
||||
import osiris.game.model.Player;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* A timed game action.
|
||||
*
|
||||
* @author Blake
|
||||
*/
|
||||
public abstract class Action implements Runnable {
|
||||
|
||||
/**
|
||||
* The player.
|
||||
*/
|
||||
private final Character character;
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
*/
|
||||
public Action(Character character) {
|
||||
this.character = character;
|
||||
if (!canRun())
|
||||
return;
|
||||
Action current = character.getCurrentAction();
|
||||
if (current != null) {
|
||||
current.cancel();
|
||||
}
|
||||
character.setCurrentAction(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel.
|
||||
*/
|
||||
public abstract void onCancel();
|
||||
|
||||
// public abstract boolean inProgress();
|
||||
|
||||
/**
|
||||
* Cancel.
|
||||
*/
|
||||
public void cancel() {
|
||||
onCancel();
|
||||
character.setCurrentAction(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Character getCharacter() {
|
||||
return character;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return (Player) character;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
if (!canRun())
|
||||
return;
|
||||
else
|
||||
onRun();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can run.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canRun() {
|
||||
if (character == null)
|
||||
return false;
|
||||
Action current = character.getCurrentAction();
|
||||
if (current != null) {
|
||||
if (current instanceof Death || current instanceof TeleportAction)
|
||||
if (!this.equals(current))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* On run.
|
||||
*/
|
||||
public abstract void onRun();
|
||||
}
|
78
src/osiris/game/action/DelayAction.java
Normal file
78
src/osiris/game/action/DelayAction.java
Normal file
@ -0,0 +1,78 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.model.Character;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class DelayAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class DelayAction extends Action {
|
||||
|
||||
/** The delay. */
|
||||
private long delay;
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param delay
|
||||
* the delay
|
||||
*/
|
||||
public DelayAction(Character character, long delay) {
|
||||
super(character);
|
||||
if (!character.getActionTimer().completed())
|
||||
cancel();
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
getCharacter().getActionTimer().setDelay(delay, null);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
}
|
||||
}
|
119
src/osiris/game/action/DistancedAction.java
Normal file
119
src/osiris/game/action/DistancedAction.java
Normal file
@ -0,0 +1,119 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.util.DistancedTask;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class DistancedAction.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public abstract class DistancedAction extends Action {
|
||||
|
||||
/** The task. */
|
||||
private DistancedTask task;
|
||||
|
||||
/**
|
||||
* Instantiates a new distanced action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param position
|
||||
* the position
|
||||
* @param distance
|
||||
* the distance
|
||||
*/
|
||||
public DistancedAction(Character character, Position position, int distance) {
|
||||
super(character);
|
||||
|
||||
// Initialize the task.
|
||||
task = new DistancedTask(getCharacter(), position, distance) {
|
||||
@Override
|
||||
public void execute() {
|
||||
DistancedAction.this.execute();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new distanced action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param other
|
||||
* the other
|
||||
* @param distance
|
||||
* the distance
|
||||
*/
|
||||
public DistancedAction(Character character, final Character other, final int distance) {
|
||||
super(character);
|
||||
|
||||
// Initialize the task.
|
||||
task = new DistancedTask(getCharacter(), other.getPosition(), distance) {
|
||||
@Override
|
||||
public void execute() {
|
||||
DistancedAction.this.execute();
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return other.getPosition();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute.
|
||||
*/
|
||||
public abstract void execute();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Runnable#cycle()
|
||||
*/
|
||||
@Override
|
||||
public final void onRun() {
|
||||
task.run();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#cancelAttack()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the task.
|
||||
*
|
||||
* @return the task
|
||||
*/
|
||||
public DistancedTask getTask() {
|
||||
return task;
|
||||
}
|
||||
}
|
44
src/osiris/game/action/ItemActionListener.java
Normal file
44
src/osiris/game/action/ItemActionListener.java
Normal file
@ -0,0 +1,44 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.item.ItemAction;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The listener interface for receiving itemAction events. The class that is
|
||||
* interested in processing a itemAction event implements this interface, and
|
||||
* the object created with that class is registered with a component using the
|
||||
* component's <code>addItemActionListener<code> method. When
|
||||
* the itemAction event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @author Blakeman8192
|
||||
*/
|
||||
public interface ItemActionListener {
|
||||
|
||||
/**
|
||||
* On item action.
|
||||
*
|
||||
* @param action
|
||||
* the action
|
||||
*/
|
||||
public void onItemAction(ItemAction action);
|
||||
|
||||
}
|
114
src/osiris/game/action/ItemActionListeners.java
Normal file
114
src/osiris/game/action/ItemActionListeners.java
Normal file
@ -0,0 +1,114 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import osiris.game.action.item.ItemAction;
|
||||
import osiris.game.action.item.ItemOnItemAction;
|
||||
import osiris.game.action.item.impl.BuryBonesListener;
|
||||
import osiris.game.action.item.impl.FiremakingListener;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemActionListeners.
|
||||
*/
|
||||
public class ItemActionListeners {
|
||||
|
||||
/** The listener map. */
|
||||
public static Map<Integer, List<ItemActionListener>> listenerMap;
|
||||
|
||||
static {
|
||||
listenerMap = new HashMap<Integer, List<ItemActionListener>>();
|
||||
// Register listeners here.
|
||||
addListener(new BuryBonesListener(), 526, 528, 530, 532, 534, 536);
|
||||
addListener(new FiremakingListener(), 590);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire item action.
|
||||
*
|
||||
* @param action
|
||||
* the action
|
||||
*/
|
||||
public static void fireItemAction(ItemAction action) {
|
||||
List<ItemActionListener> listeners = new LinkedList<ItemActionListener>();
|
||||
List<ItemActionListener> primary = listenerMap.get(action.getItem().getId());
|
||||
if (primary != null)
|
||||
listeners.addAll(primary);
|
||||
if (action instanceof ItemOnItemAction) {
|
||||
Item usedOn = ((ItemOnItemAction) action).getUsedOn();
|
||||
if (usedOn != null) {
|
||||
List<ItemActionListener> other = listenerMap.get(usedOn.getId());
|
||||
if (other != null)
|
||||
listeners.addAll(other);
|
||||
}
|
||||
}
|
||||
if (listeners.size() == 0) {
|
||||
System.out.println("Couldn't find listener for " + action.getItem().getId());
|
||||
return;
|
||||
}
|
||||
for (ItemActionListener listener : listeners) {
|
||||
listener.onItemAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener.
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
* @param itemIDs
|
||||
* the item i ds
|
||||
*/
|
||||
public static void addListener(ItemActionListener listener, int... itemIDs) {
|
||||
for (int itemID : itemIDs) {
|
||||
List<ItemActionListener> listeners = listenerMap.get(itemID);
|
||||
if (listeners == null) {
|
||||
listeners = new LinkedList<ItemActionListener>();
|
||||
listenerMap.put(itemID, listeners);
|
||||
}
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listeners.
|
||||
*
|
||||
* @param itemID
|
||||
* the item id
|
||||
* @param listeners
|
||||
* the listeners
|
||||
*/
|
||||
public static void addListeners(int itemID, ItemActionListener... listeners) {
|
||||
List<ItemActionListener> list = listenerMap.get(itemID);
|
||||
if (list == null) {
|
||||
list = new LinkedList<ItemActionListener>();
|
||||
listenerMap.put(itemID, list);
|
||||
}
|
||||
for (ItemActionListener listener : listeners) {
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
44
src/osiris/game/action/ObjectActionListener.java
Normal file
44
src/osiris/game/action/ObjectActionListener.java
Normal file
@ -0,0 +1,44 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The listener interface for receiving objectAction events. The class that is
|
||||
* interested in processing a objectAction event implements this interface, and
|
||||
* the object created with that class is registered with a component using the
|
||||
* component's <code>addObjectActionListener<code> method. When
|
||||
* the objectAction event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
*/
|
||||
public interface ObjectActionListener {
|
||||
|
||||
/**
|
||||
* On object action.
|
||||
*
|
||||
* @param objectAction
|
||||
* the object action
|
||||
*/
|
||||
public void onObjectAction(ObjectAction objectAction);
|
||||
|
||||
}
|
139
src/osiris/game/action/ObjectActionListeners.java
Normal file
139
src/osiris/game/action/ObjectActionListeners.java
Normal file
@ -0,0 +1,139 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.game.model.skills.Mining.ADAMANTITE;
|
||||
import static osiris.game.model.skills.Mining.CLAY;
|
||||
import static osiris.game.model.skills.Mining.COAL;
|
||||
import static osiris.game.model.skills.Mining.COPPER;
|
||||
import static osiris.game.model.skills.Mining.GOLD;
|
||||
import static osiris.game.model.skills.Mining.IRON;
|
||||
import static osiris.game.model.skills.Mining.MITHRIL;
|
||||
import static osiris.game.model.skills.Mining.RUNITE;
|
||||
import static osiris.game.model.skills.Mining.SILVER;
|
||||
import static osiris.game.model.skills.Mining.TIN;
|
||||
import static osiris.game.model.skills.Woodcutting.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.data.parser.impl.PositionChangeParser;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.action.object.impl.CookingListener;
|
||||
import osiris.game.action.object.impl.PositionChangeActionListener;
|
||||
import osiris.game.action.object.impl.RockActionListener;
|
||||
import osiris.game.action.object.impl.TreeActionListener;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ObjectActionListeners.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
*/
|
||||
public class ObjectActionListeners {
|
||||
|
||||
/** The listener map. */
|
||||
public static Map<Integer, List<ObjectActionListener>> listenerMap;
|
||||
|
||||
/**
|
||||
* Fire object action.
|
||||
*
|
||||
* @param action
|
||||
* the action
|
||||
*/
|
||||
public static void fireObjectAction(ObjectAction action) {
|
||||
List<ObjectActionListener> listeners = listenerMap.get(action.getObjectID());
|
||||
if (listeners == null) {
|
||||
System.out.println("Couldn't find listerer for " + action.getObjectID());
|
||||
return;
|
||||
}
|
||||
for (ObjectActionListener listener : listeners) {
|
||||
listener.onObjectAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener.
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
* @param objectIDs
|
||||
* the object i ds
|
||||
*/
|
||||
public static void addListener(ObjectActionListener listener, int... objectIDs) {
|
||||
for (int objectID : objectIDs) {
|
||||
List<ObjectActionListener> listeners = listenerMap.get(objectID);
|
||||
if (listeners == null) {
|
||||
listeners = new LinkedList<ObjectActionListener>();
|
||||
listenerMap.put(objectID, listeners);
|
||||
}
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listeners.
|
||||
*
|
||||
* @param objectID
|
||||
* the object id
|
||||
* @param listeners
|
||||
* the listeners
|
||||
*/
|
||||
public static void addListeners(int objectID, ObjectActionListener... listeners) {
|
||||
List<ObjectActionListener> list = listenerMap.get(objectID);
|
||||
if (list == null) {
|
||||
list = new LinkedList<ObjectActionListener>();
|
||||
listenerMap.put(objectID, list);
|
||||
}
|
||||
for (ObjectActionListener listener : listeners) {
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
listenerMap = new HashMap<Integer, List<ObjectActionListener>>();
|
||||
|
||||
// Woodcutting.
|
||||
TreeActionListener treeActionListener = new TreeActionListener();
|
||||
addListener(treeActionListener, TREE_1, TREE_2, TREE_3, TREE_4, TREE_OAK, TREE_WILLOW_1, TREE_WILLOW_2, TREE_WILLOW_3, TREE_WILLOW_4, TREE_MAPLE, TREE_YEW, TREE_MAGIC);
|
||||
|
||||
// Mining
|
||||
RockActionListener rockActionListener = new RockActionListener();
|
||||
addListener(rockActionListener, COPPER);
|
||||
addListener(rockActionListener, TIN);
|
||||
addListener(rockActionListener, CLAY);
|
||||
addListener(rockActionListener, IRON);
|
||||
addListener(rockActionListener, COAL);
|
||||
addListener(rockActionListener, SILVER);
|
||||
addListener(rockActionListener, GOLD);
|
||||
addListener(rockActionListener, MITHRIL);
|
||||
addListener(rockActionListener, ADAMANTITE);
|
||||
addListener(rockActionListener, RUNITE);
|
||||
|
||||
addListener(new CookingListener(true), 2732);
|
||||
for (PositionChangeParser.PositionChangeInfo info : Main.getStairs()) {
|
||||
ObjectActionListeners.addListener(new PositionChangeActionListener(info), info.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
183
src/osiris/game/action/TickedAction.java
Normal file
183
src/osiris/game/action/TickedAction.java
Normal file
@ -0,0 +1,183 @@
|
||||
package osiris.game.action;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.util.Settings.TICKRATE;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import osiris.ServerEngine;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.util.StopWatch;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* A ticked action.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public abstract class TickedAction extends Action {
|
||||
|
||||
/**
|
||||
* The ticks.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* The starting value for random tick values.
|
||||
*/
|
||||
private int inclusive;
|
||||
|
||||
/**
|
||||
* The ending value for random tick values.
|
||||
*/
|
||||
private int exclusive;
|
||||
|
||||
/**
|
||||
* The task.
|
||||
*/
|
||||
private ScheduledFuture<?> task;
|
||||
|
||||
/**
|
||||
* Generates a random tick based off of the inclusive and exclusive values.
|
||||
*
|
||||
* @param character
|
||||
* The character.
|
||||
* @param inclusive
|
||||
* The starting value.
|
||||
* @param exclusive
|
||||
* The ending value.
|
||||
*/
|
||||
public TickedAction(Character character, int inclusive, int exclusive) {
|
||||
super(character);
|
||||
this.inclusive = inclusive;
|
||||
this.exclusive = exclusive;
|
||||
|
||||
Random rand = new Random();
|
||||
this.ticks = (rand.nextInt(exclusive - inclusive) + inclusive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new ticked action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param ticks
|
||||
* the ticks
|
||||
*/
|
||||
public TickedAction(Character character, int ticks) {
|
||||
super(character);
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute.
|
||||
*/
|
||||
public abstract void execute();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public final void onRun() {
|
||||
final StopWatch timer = new StopWatch();
|
||||
task = ServerEngine.getScheduler().scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (timer.elapsed() >= ticks) {
|
||||
TickedAction.this.execute();
|
||||
timer.reset();
|
||||
}
|
||||
}
|
||||
}, 0, TICKRATE, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#cancelAttack()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
task.cancel(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current tick to the given value.
|
||||
*
|
||||
* @param ticks
|
||||
* The new tick value.
|
||||
*/
|
||||
public void setTicks(int ticks) {
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current tick value.
|
||||
*
|
||||
* @return The tick value.
|
||||
*/
|
||||
public int getTicks() {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the inclusive value for a random tick.
|
||||
*
|
||||
* @param inclusive
|
||||
* The starting value.
|
||||
*/
|
||||
public void setInclusive(int inclusive) {
|
||||
this.inclusive = inclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the inclusive value.
|
||||
*
|
||||
* @return The ending value.
|
||||
*/
|
||||
public int getInclusive() {
|
||||
return inclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exclusive value for a random tick.
|
||||
*
|
||||
* @param exclusive
|
||||
* The ending value.
|
||||
*/
|
||||
public void setExclusive(int exclusive) {
|
||||
this.exclusive = exclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exclusive value.
|
||||
*
|
||||
* @return The starting value.
|
||||
*/
|
||||
public int getExclusive() {
|
||||
return exclusive;
|
||||
}
|
||||
|
||||
}
|
102
src/osiris/game/action/impl/BankAction.java
Normal file
102
src/osiris/game/action/impl/BankAction.java
Normal file
@ -0,0 +1,102 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.item.Bank;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class BankAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class BankAction extends Action {
|
||||
|
||||
/** The bank. */
|
||||
private Bank bank;
|
||||
|
||||
/** The player. */
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Instantiates a new bank action.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public BankAction(Player player) {
|
||||
super(player);
|
||||
this.bank = player.getBank();
|
||||
this.player = player;
|
||||
run();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
closeBank();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
openBank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open bank.
|
||||
*/
|
||||
public void openBank() {
|
||||
player.getEventWriter().openSideLockingInterface(762, 763);
|
||||
player.getEventWriter().sendConfig2(563, 4194304);
|
||||
player.getEventWriter().sendConfig2(1248, -2013265920);
|
||||
player.getEventWriter().sendBankOptions();
|
||||
bank.setBankOpen(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close bank.
|
||||
*/
|
||||
public void closeBank() {
|
||||
player.getEventWriter().removeSideLockingInterface();
|
||||
bank.setBankOpen(false);
|
||||
if (player.getXValue() != null)
|
||||
player.getXValue().cancel(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bank.
|
||||
*
|
||||
* @return the bank
|
||||
*/
|
||||
public Bank getBank() {
|
||||
return bank;
|
||||
}
|
||||
|
||||
}
|
88
src/osiris/game/action/impl/CombatAction.java
Normal file
88
src/osiris/game/action/impl/CombatAction.java
Normal file
@ -0,0 +1,88 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CombatAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class CombatAction extends Action {
|
||||
|
||||
/** The victim. */
|
||||
private final Character victim;
|
||||
|
||||
/** The spell slot. */
|
||||
private int spellSlot;
|
||||
|
||||
/**
|
||||
* Instantiates a new distanced action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param victim
|
||||
* the victim
|
||||
*/
|
||||
public CombatAction(Character character, Character victim) {
|
||||
super(character);
|
||||
this.victim = victim;
|
||||
this.spellSlot = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new combat action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param victim
|
||||
* the victim
|
||||
* @param spellSlot
|
||||
* the spell slot
|
||||
*/
|
||||
public CombatAction(Character character, Character victim, int spellSlot) {
|
||||
super(character);
|
||||
this.victim = victim;
|
||||
this.spellSlot = spellSlot;
|
||||
character.getMovementQueue().reset();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getCharacter().getCombatManager().resetAttackVars();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
getCharacter().getCombatManager().attackCharacter(victim, spellSlot);
|
||||
}
|
||||
}
|
75
src/osiris/game/action/impl/DeathItemsScreenAction.java
Normal file
75
src/osiris/game/action/impl/DeathItemsScreenAction.java
Normal file
@ -0,0 +1,75 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class DeathItemsScreenAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class DeathItemsScreenAction extends Action {
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
*/
|
||||
public DeathItemsScreenAction(osiris.game.model.Character character) {
|
||||
super(character);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getPlayer().getEventWriter().removeSideLockingInterface();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
getPlayer().getEventWriter().openSideLockingInterface(102, 149);
|
||||
getPlayer().getEventWriter().setAccessMask(211, 0, 2, 6684690, 4);
|
||||
getPlayer().getEventWriter().setAccessMask(212, 0, 2, 6684693, 42);
|
||||
|
||||
ArrayList<Item> items = getPlayer().getItemsKeptOnDeath();
|
||||
int[] itemIds = new int[4];
|
||||
Arrays.fill(itemIds, -1);
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
itemIds[i] = items.get(i).getId();
|
||||
}
|
||||
Object[] params = { 11510, 12749, "", 0, itemIds[3], itemIds[2], itemIds[1], itemIds[0], items.size(), 0 };
|
||||
getPlayer().getEventWriter().runScript(118, params, "iioooiisii");
|
||||
}
|
||||
}
|
103
src/osiris/game/action/impl/DialogueAction.java
Normal file
103
src/osiris/game/action/impl/DialogueAction.java
Normal file
@ -0,0 +1,103 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.dialogues.Dialogue;
|
||||
import osiris.game.model.dialogues.Dialogue.Type;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class DialogueAction.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class DialogueAction extends Action {
|
||||
|
||||
/** The dialogue. */
|
||||
private Dialogue dialogue;
|
||||
|
||||
/**
|
||||
* Instantiates a new dialogue action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param dialogue
|
||||
* the dialogue
|
||||
*/
|
||||
public DialogueAction(Character character, Dialogue dialogue) {
|
||||
super(character);
|
||||
this.dialogue = dialogue;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getPlayer().getEventWriter().sendCloseChatboxInterface();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
int inter = 241;
|
||||
switch (dialogue.getType()) {
|
||||
case OPTION:
|
||||
int start = ((dialogue.getLines().length > 2) ? 228 : 227);
|
||||
inter = start + dialogue.getLines().length;
|
||||
getPlayer().getEventWriter().sendChatboxInterface(inter);
|
||||
break;
|
||||
|
||||
case NPC:
|
||||
inter = 240 + dialogue.getLines().length;
|
||||
getPlayer().getEventWriter().sendChatboxInterface(inter);
|
||||
getPlayer().getEventWriter().sendInterfaceAnimation(inter, 2, 9847);
|
||||
getPlayer().getEventWriter().sendInterfaceNpc(inter, 2, dialogue.getNpc());
|
||||
getPlayer().getEventWriter().sendString(dialogue.getTitle(), inter, 3);
|
||||
break;
|
||||
|
||||
case PLAYER:
|
||||
break;
|
||||
}
|
||||
|
||||
int child = dialogue.getType() == Type.OPTION ? 2 : 4;
|
||||
for (int i = 0; i < dialogue.getLines().length; i++) {
|
||||
String line = dialogue.getLines()[i];
|
||||
if (line == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.contains("NAME")) {
|
||||
line = line.replaceAll("NAME", Utilities.toProperCase(getPlayer().getUsername()));
|
||||
}
|
||||
getPlayer().getEventWriter().sendString(line, inter, child++);
|
||||
}
|
||||
getPlayer().setCurrentlyOpenDialogue(dialogue);
|
||||
}
|
||||
}
|
98
src/osiris/game/action/impl/DisplaySelectOptionAction.java
Normal file
98
src/osiris/game/action/impl/DisplaySelectOptionAction.java
Normal file
@ -0,0 +1,98 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Displays the "What would you like to build?" chat interface.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class DisplaySelectOptionAction extends Action {
|
||||
|
||||
/** The interface ID. */
|
||||
private int id;
|
||||
|
||||
/** The size of the model's being displayed. */
|
||||
private int size;
|
||||
|
||||
/** The various item ID's. */
|
||||
private int[] items;
|
||||
|
||||
/**
|
||||
* Instantiates a new display select option event.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param id
|
||||
* The interface ID.
|
||||
* @param size
|
||||
* The size of the model's being displayed.
|
||||
* @param items
|
||||
* The various item ID's.
|
||||
*/
|
||||
public DisplaySelectOptionAction(Character character, int id, int size, int[] items) {
|
||||
super(character);
|
||||
this.id = id;
|
||||
this.size = size;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getPlayer().getEventWriter().sendCloseChatboxInterface();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
|
||||
/**
|
||||
* The child interface. XXX: This should remain 2 until more then one
|
||||
* item is being displayed.
|
||||
*/
|
||||
int child = 2;
|
||||
|
||||
/**
|
||||
* Displays the interface.
|
||||
*/
|
||||
getPlayer().getEventWriter().sendChatboxInterface(id);
|
||||
|
||||
/**
|
||||
* Iterates through all the item ID's and displays the models on the
|
||||
* specified interface.
|
||||
*/
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
getPlayer().getEventWriter().sendInterfaceItem(id, child++, size, items[i]);
|
||||
}
|
||||
}
|
||||
}
|
81
src/osiris/game/action/impl/DropItemAction.java
Normal file
81
src/osiris/game/action/impl/DropItemAction.java
Normal file
@ -0,0 +1,81 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.ground.GroundItem;
|
||||
import osiris.game.model.ground.GroundManager;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class DropItemAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class DropItemAction extends Action {
|
||||
|
||||
/** The item id. */
|
||||
private int slot, itemId;
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param slot
|
||||
* the slot
|
||||
* @param itemId
|
||||
* the item id
|
||||
*/
|
||||
public DropItemAction(Character character, int slot, int itemId) {
|
||||
super(character);
|
||||
this.slot = slot;
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
if (getPlayer() == null || getPlayer().getInventory() == null || getPlayer().getInventory().getItem(slot) == null)
|
||||
return;
|
||||
Item item = getPlayer().getInventory().getItem(slot).clone();
|
||||
if (item == null || item.getId() != itemId)
|
||||
return;
|
||||
if (!getPlayer().getInventory().removeBySlot(slot, item.getAmount()))
|
||||
return;
|
||||
GroundItem ground = new GroundItem(item, getPlayer());
|
||||
GroundManager.getManager().dropItem(ground);
|
||||
|
||||
}
|
||||
}
|
95
src/osiris/game/action/impl/EmoteAction.java
Normal file
95
src/osiris/game/action/impl/EmoteAction.java
Normal file
@ -0,0 +1,95 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
import osiris.game.update.block.GraphicsBlock;
|
||||
import osiris.util.StopWatch;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class EmoteAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class EmoteAction extends Action {
|
||||
|
||||
/** The graphic id. */
|
||||
private int emoteId, graphicId = -1;
|
||||
|
||||
/** The emote duration. */
|
||||
private StopWatch emoteDuration;
|
||||
|
||||
/**
|
||||
* Instantiates a new ticked action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param emoteId
|
||||
* the emote id
|
||||
*/
|
||||
public EmoteAction(Character character, int emoteId) {
|
||||
super(character);
|
||||
this.emoteId = emoteId;
|
||||
emoteDuration = new StopWatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new emote action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param emoteId
|
||||
* the emote id
|
||||
* @param graphicId
|
||||
* the graphic id
|
||||
*/
|
||||
public EmoteAction(Character character, int emoteId, int graphicId) {
|
||||
this(character, emoteId);
|
||||
this.graphicId = graphicId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
getCharacter().addUpdateBlock(new AnimationBlock(getCharacter(), emoteId, 0));
|
||||
if (graphicId != -1)
|
||||
getCharacter().addUpdateBlock(new GraphicsBlock(getCharacter(), graphicId, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
if (emoteDuration.elapsed() < 3) {
|
||||
getCharacter().addUpdateBlock(new AnimationBlock(getCharacter(), -1, 0));
|
||||
getCharacter().addUpdateBlock(new GraphicsBlock(getCharacter(), -1, 0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
78
src/osiris/game/action/impl/EquipmentScreenAction.java
Normal file
78
src/osiris/game/action/impl/EquipmentScreenAction.java
Normal file
@ -0,0 +1,78 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class EquipmentScreenAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class EquipmentScreenAction extends Action {
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
*/
|
||||
public EquipmentScreenAction(Character character) {
|
||||
super(character);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
getPlayer().getEventWriter().removeSideLockingInterface();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
getPlayer().getMovementQueue().reset();
|
||||
getPlayer().getEventWriter().openSideLockingInterface(667, 149);
|
||||
int[] bonuses = new int[Settings.BONUSES.length];
|
||||
for (Item item : getPlayer().getEquipment().getItems()) {
|
||||
if (item != null) {
|
||||
ItemDef def = ItemDef.forId(item.getId());
|
||||
for (int i = 0; i < def.getBonuses().length; i++) {
|
||||
if (i == 12) {
|
||||
continue;
|
||||
}
|
||||
bonuses[i] += def.getBonus(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
getPlayer().getEventWriter().sendBonus(bonuses);
|
||||
}
|
||||
}
|
144
src/osiris/game/action/impl/FoodAction.java
Normal file
144
src/osiris/game/action/impl/FoodAction.java
Normal file
@ -0,0 +1,144 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.effect.Effect;
|
||||
import osiris.game.model.effect.ExpiringEffect;
|
||||
import osiris.game.model.effect.FoodEffect;
|
||||
|
||||
/**
|
||||
* The Class FoodAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class FoodAction extends Action {
|
||||
|
||||
/** The food. */
|
||||
private Food food;
|
||||
|
||||
/** The item id. */
|
||||
private int itemId, itemSlot;
|
||||
|
||||
/**
|
||||
* Instantiates a new food action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param food
|
||||
* the food
|
||||
* @param itemSlot
|
||||
* the item slot
|
||||
* @param itemId
|
||||
* the item id
|
||||
*/
|
||||
public FoodAction(Character character, Food food, int itemSlot, int itemId) {
|
||||
super(character);
|
||||
this.food = food;
|
||||
this.itemId = itemId;
|
||||
this.itemSlot = itemSlot;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
for (Effect effect : getCharacter().getEffects()) {
|
||||
if (effect instanceof FoodEffect) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (food == null)
|
||||
return;
|
||||
|
||||
ExpiringEffect effect = new FoodEffect(itemSlot, itemId, food.getHeal());
|
||||
getCharacter().addEffect(effect);
|
||||
effect.execute(getCharacter());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate food.
|
||||
*
|
||||
* @param itemId
|
||||
* the item id
|
||||
* @return the food
|
||||
*/
|
||||
public static Food calculateFood(int itemId) {
|
||||
String value = ItemDef.forId(itemId).getName().toUpperCase().replaceAll(" ", "_");
|
||||
Food food = null;
|
||||
try {
|
||||
food = Food.valueOf(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
return food;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum Food.
|
||||
*
|
||||
* TODO: Add the rest of the foods. TODO: Check if the current foods have
|
||||
* the correct heal amount.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*/
|
||||
public enum Food {
|
||||
|
||||
// XXX: Meat
|
||||
COOKED_CHIKEN(3), COOKED_MEAT(3), COOKED_KARAMBWAN(18),
|
||||
|
||||
// XXX: Fish
|
||||
ANCHOIVES(1), SHRIMPS(3), BREAD(5), HERRING(5), MACKEREL(6), TROUT(7), COD(7), PIKE(8), SALMON(9), TUNA(10), LOBSTER(12), BASS(13), SWORDFISH(14), MONKFISH(16), SHARK(20), TURTLE(21), MANTA_RAY(22);
|
||||
|
||||
/** The heal. */
|
||||
private int heal;
|
||||
|
||||
/**
|
||||
* Instantiates a new food.
|
||||
*
|
||||
* @param heal
|
||||
* the heal
|
||||
*/
|
||||
private Food(int heal) {
|
||||
this.heal = heal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the heal.
|
||||
*
|
||||
* @return the heal
|
||||
*/
|
||||
public int getHeal() {
|
||||
return heal;
|
||||
}
|
||||
}
|
||||
}
|
103
src/osiris/game/action/impl/HomeTeleportAction.java
Normal file
103
src/osiris/game/action/impl/HomeTeleportAction.java
Normal file
@ -0,0 +1,103 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.TickedAction;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
import osiris.game.update.block.GraphicsBlock;
|
||||
import osiris.util.StopWatch;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class HomeTeleportAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class HomeTeleportAction extends TickedAction {
|
||||
|
||||
/** The Constant DELAY. */
|
||||
public static final int DELAY = 1;
|
||||
|
||||
/** The Constant graphics. */
|
||||
public static final int[] animations = { 1723, 1724, 1725, 2798, 2799, 2800, 4847, 4848, 4849, 4850, 4851 }, graphics = { 800, 801, 802, 1703, 1704, 1705, 1706, 1707, 1708, 1711, 1712 };
|
||||
|
||||
/** The timer. */
|
||||
private StopWatch timer;
|
||||
|
||||
/** The increment. */
|
||||
private int increment;
|
||||
|
||||
/** The to. */
|
||||
private Position to;
|
||||
|
||||
/** The ignore home timer. */
|
||||
private boolean ignoreHomeTimer;
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param to
|
||||
* teleporting to
|
||||
*/
|
||||
public HomeTeleportAction(Character character, Position to) {
|
||||
super(character, 1);
|
||||
character.getMovementQueue().reset();
|
||||
character.addUpdateBlock(new AnimationBlock(character, 1722, 0));
|
||||
this.to = to;
|
||||
this.increment = 0;
|
||||
this.timer = new StopWatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore home timer.
|
||||
*
|
||||
* @return the home teleport action
|
||||
*/
|
||||
public HomeTeleportAction ignoreHomeTimer() {
|
||||
this.ignoreHomeTimer = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.TickedAction#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
if (timer.elapsed() >= DELAY) {
|
||||
if (increment == animations.length) {
|
||||
this.cancel();
|
||||
new TeleportAction(getCharacter(), to, TeleportAction.TeleportType.HOME).run();
|
||||
if (!ignoreHomeTimer)
|
||||
getCharacter().getHomeTeleTimer().reset();
|
||||
return;
|
||||
}
|
||||
timer.reset();
|
||||
getCharacter().addUpdateBlock(new AnimationBlock(getCharacter(), animations[increment], 0));
|
||||
getCharacter().addUpdateBlock(new GraphicsBlock(getCharacter(), graphics[increment], 0));
|
||||
increment++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
90
src/osiris/game/action/impl/PickupItemAction.java
Normal file
90
src/osiris/game/action/impl/PickupItemAction.java
Normal file
@ -0,0 +1,90 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.DistancedAction;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.ground.GroundItem;
|
||||
import osiris.game.model.ground.GroundManager;
|
||||
|
||||
/**
|
||||
* The Class GroundItemAction.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class PickupItemAction extends DistancedAction {
|
||||
|
||||
/** The id. */
|
||||
private int id;
|
||||
|
||||
/** The position. */
|
||||
private Position position;
|
||||
|
||||
/**
|
||||
* Instantiates a new ground item action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param position
|
||||
* the position
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
public PickupItemAction(Character character, Position position, int id) {
|
||||
super(character, position, 1);
|
||||
this.id = id;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.DistancedAction#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
if (getCharacter() instanceof Player) {
|
||||
Player player = (Player) getCharacter();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getInventory().isFull() && (!ItemDef.forId(id).isStackable() || (ItemDef.forId(id).isStackable() && player.getInventory().getItemById(id) == null))) {
|
||||
player.getEventWriter().sendMessage("You don't have enough room in your inventory!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (GroundItem item : player.getGroundItems()) {
|
||||
if (item.getPosition().equals(position) && item.getItem().getId() == id) {
|
||||
if (!getPlayer().getInventory().add(item.getItem()))
|
||||
getPlayer().getEventWriter().sendMessage("You have no room open in your inventory!");
|
||||
else {
|
||||
GroundManager.getManager().pickupItem(item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
242
src/osiris/game/action/impl/SkillAction.java
Normal file
242
src/osiris/game/action/impl/SkillAction.java
Normal file
@ -0,0 +1,242 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.TickedAction;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Skills;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.model.skills.Skill;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SkillAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class SkillAction extends TickedAction {
|
||||
|
||||
/** The max attempts. */
|
||||
private int skillId, levelRequired, iterationsQueued, iterationsCompleted, emote, attempts, maxAttempts;
|
||||
|
||||
/** The tools required. */
|
||||
private Item[] itemsRemoved, itemsGained, toolsRequired;
|
||||
|
||||
/** The experience gained. */
|
||||
private double experienceGained;
|
||||
|
||||
/** The success message. */
|
||||
private String successMessage;
|
||||
|
||||
/** The skill. */
|
||||
private Skill skill;
|
||||
|
||||
/**
|
||||
* Instantiates a new ticked action.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param skill
|
||||
* the skill
|
||||
* @param skillId
|
||||
* the skill id
|
||||
* @param levelRequired
|
||||
* the level required
|
||||
* @param expGained
|
||||
* the exp gained
|
||||
* @param emote
|
||||
* the emote
|
||||
* @param toolsRequired
|
||||
* the tools required
|
||||
* @param itemsRemoved
|
||||
* the items removed
|
||||
* @param itemsGained
|
||||
* the items gained
|
||||
* @param successMessage
|
||||
* the success message
|
||||
* @param iterationsQueued
|
||||
* the iterations queued
|
||||
*/
|
||||
public SkillAction(Player player, Skill skill, int skillId, int levelRequired, double expGained, int emote, Item[] toolsRequired, Item[] itemsRemoved, Item[] itemsGained, String successMessage, int iterationsQueued) {
|
||||
super(player, skill.calculateCooldown());
|
||||
this.skill = skill;
|
||||
this.skillId = skillId;
|
||||
this.levelRequired = levelRequired;
|
||||
this.iterationsCompleted = 0;
|
||||
this.itemsRemoved = itemsRemoved;
|
||||
this.itemsGained = itemsGained;
|
||||
this.toolsRequired = toolsRequired;
|
||||
this.experienceGained = expGained;
|
||||
this.emote = emote;
|
||||
this.successMessage = successMessage;
|
||||
this.iterationsQueued = iterationsQueued;
|
||||
this.attempts = 0;
|
||||
this.maxAttempts = -1;
|
||||
player.getMovementQueue().reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max attempts.
|
||||
*
|
||||
* @param attempts
|
||||
* the attempts
|
||||
* @return the skill action
|
||||
*/
|
||||
public SkillAction setMaxAttempts(int attempts) {
|
||||
this.maxAttempts = attempts;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the items gained.
|
||||
*
|
||||
* @param itemsGained
|
||||
* the new items gained
|
||||
*/
|
||||
public void setItemsGained(Item[] itemsGained) {
|
||||
this.itemsGained = itemsGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the success message.
|
||||
*
|
||||
* @param message
|
||||
* the new success message
|
||||
*/
|
||||
public void setSuccessMessage(String message) {
|
||||
this.successMessage = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the experience gained.
|
||||
*
|
||||
* @param exp
|
||||
* the new experience gained
|
||||
*/
|
||||
public void setExperienceGained(double exp) {
|
||||
this.experienceGained = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level required.
|
||||
*
|
||||
* @param level
|
||||
* the new level required
|
||||
*/
|
||||
public void setLevelRequired(int level) {
|
||||
this.levelRequired = level;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.TickedAction#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
if (getPlayer().getSkills().currentLevel(skillId) < levelRequired) {
|
||||
getPlayer().getEventWriter().sendMessage("You need a level of at least " + levelRequired + " " + Skills.SKILL_NAMES[skillId] + " to do that.");
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (toolsRequired.length > 0) {
|
||||
for (Item item : toolsRequired) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getPlayer().getInventory().amountOfItem(item.getId()) < item.getAmount()) {
|
||||
getPlayer().getEventWriter().sendMessage("You need a " + ItemDef.forId(item.getId()).getName() + " to do that.");
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (emote != -1)
|
||||
getPlayer().addUpdateBlock(new AnimationBlock(getPlayer(), emote, 0));
|
||||
|
||||
if (!skill.canIterate()) {
|
||||
attempts++;
|
||||
if (maxAttempts != -1 && attempts == maxAttempts)
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] invBefore = getPlayer().getInventory().getItems();
|
||||
if (itemsRemoved.length > 0) {
|
||||
for (Item item : itemsRemoved) {
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
if (!getPlayer().getInventory().removeById(item.getId(), item.getAmount(), false)) {
|
||||
getPlayer().getEventWriter().sendMessage("You do not have all the resources required!");
|
||||
cancel();
|
||||
getPlayer().getInventory().setItems(invBefore);
|
||||
getPlayer().getInventory().refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemsGained.length > 0) {
|
||||
if (!getPlayer().getInventory().canFitAll(itemsGained)) {
|
||||
getPlayer().getEventWriter().sendMessage("You do not have enough room for that!");
|
||||
cancel();
|
||||
getPlayer().getInventory().setItems(invBefore);
|
||||
getPlayer().getInventory().refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
getPlayer().addAllItems(itemsGained);
|
||||
} else
|
||||
getPlayer().getInventory().refresh();
|
||||
|
||||
if (successMessage != null) {
|
||||
getPlayer().getEventWriter().sendMessage(successMessage);
|
||||
}
|
||||
|
||||
iterationsCompleted++;
|
||||
getPlayer().getSkills().addExp(skillId, experienceGained);
|
||||
if (iterationsQueued != -1 && iterationsCompleted == iterationsQueued) {
|
||||
skill.onCompletion();
|
||||
cancel();
|
||||
return;
|
||||
} else {
|
||||
setTicks(skill.calculateCooldown());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#cancel()
|
||||
*/
|
||||
@Override
|
||||
public void cancel() {
|
||||
getPlayer().getEventWriter().sendCloseChatboxInterface();
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
getPlayer().getEventWriter().removeSideLockingInterface();
|
||||
super.cancel();
|
||||
}
|
||||
}
|
132
src/osiris/game/action/impl/SwitchAutoCastAction.java
Normal file
132
src/osiris/game/action/impl/SwitchAutoCastAction.java
Normal file
@ -0,0 +1,132 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.model.magic.MagicManager;
|
||||
import osiris.game.model.magic.SpellBook;
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SwitchAutoCastAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class SwitchAutoCastAction extends Action {
|
||||
|
||||
/** The spell id. */
|
||||
private int spellId;
|
||||
|
||||
/** The defence. */
|
||||
private boolean defence;
|
||||
|
||||
/** The completed. */
|
||||
private boolean completed = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new action.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param defence
|
||||
* the defence
|
||||
*/
|
||||
public SwitchAutoCastAction(Player player, boolean defence) {
|
||||
super(player);
|
||||
this.spellId = -1;
|
||||
this.defence = defence;
|
||||
SpellBook spellBook = player.getSpellBook();
|
||||
if (spellBook == SpellBook.LUNAR) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Item weapon = player.getEquipment().getItem(Settings.SLOT_WEAPON);
|
||||
if (weapon == null) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if ((spellBook == SpellBook.ANCIENT && weapon.getId() != 4675) || (spellBook == SpellBook.NORMAL && weapon.getId() == 4675)) {
|
||||
player.getEventWriter().sendMessage("You can only autocast ANCIENT spells with an ANCIENT staff!");
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
player.getEventWriter().sendTab(73, spellBook == SpellBook.ANCIENT ? 388 : 319);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the auto spell id.
|
||||
*
|
||||
* @param spellId
|
||||
* the spell id
|
||||
* @return the switch auto cast action
|
||||
*/
|
||||
public SwitchAutoCastAction setAutoSpellId(int spellId) {
|
||||
this.spellId = spellId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
if (!completed)
|
||||
getPlayer().getCombatManager().setAutoSpell(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
if (spellId != -1) {
|
||||
int[] spells = null;
|
||||
switch (getPlayer().getSpellBook()) {
|
||||
case NORMAL:
|
||||
spells = MagicManager.NORMAL_AUTOCAST_SPELLS;
|
||||
break;
|
||||
case ANCIENT:
|
||||
spells = MagicManager.ANCIENT_AUTOCAST_SPELLS;
|
||||
break;
|
||||
}
|
||||
if (spells == null) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
int spellSprite = 45;
|
||||
if (getPlayer().getSpellBook() == SpellBook.ANCIENT)
|
||||
spellSprite = 13;
|
||||
if (defence)
|
||||
spellSprite += 100;
|
||||
spellSprite += spellId * 2;
|
||||
getPlayer().getCombatManager().setAutoSpell(spells[spellId], getPlayer().getSpellBook(), defence, spellSprite);
|
||||
completed = true;
|
||||
}
|
||||
getPlayer().refreshWeaponTab();
|
||||
|
||||
}
|
||||
}
|
99
src/osiris/game/action/impl/TeleportAction.java
Normal file
99
src/osiris/game/action/impl/TeleportAction.java
Normal file
@ -0,0 +1,99 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.TickedAction;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
import osiris.game.update.block.GraphicsBlock;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TeleportAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class TeleportAction extends TickedAction {
|
||||
|
||||
/** The to. */
|
||||
private Position to;
|
||||
|
||||
/** The type. */
|
||||
private TeleportType type;
|
||||
|
||||
/** The stage. */
|
||||
private int stage;
|
||||
|
||||
/**
|
||||
* The Enum TeleportType.
|
||||
*/
|
||||
public enum TeleportType {
|
||||
HOME, NORMAL, ANCIENT
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new timed action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param to
|
||||
* the position
|
||||
* @param type
|
||||
* the type
|
||||
*/
|
||||
public TeleportAction(Character character, Position to, TeleportType type) {
|
||||
super(character, type == TeleportType.HOME ? 1 : 2);
|
||||
character.getMovementQueue().reset();
|
||||
this.to = to;
|
||||
this.type = type;
|
||||
this.stage = 0;
|
||||
boolean ancients = type == TeleportType.ANCIENT;
|
||||
boolean home = type == TeleportType.HOME;
|
||||
getCharacter().addUpdateBlock(new AnimationBlock(getCharacter(), (ancients ? 1979 : (home ? 4852 : 8939)), 0));
|
||||
getCharacter().addUpdateBlock(new GraphicsBlock(getCharacter(), (ancients ? 392 : (home ? 1713 : 1576)), 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.TickedAction#execute()
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!getCharacter().canTeleport()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (stage == 0) {
|
||||
getCharacter().teleport(to);
|
||||
boolean ancients = type == TeleportType.ANCIENT;
|
||||
boolean home = type == TeleportType.HOME;
|
||||
if (!home) {
|
||||
getCharacter().addUpdateBlock(new AnimationBlock(getCharacter(), (ancients ? -1 : 8941), 0));
|
||||
getCharacter().addUpdateBlock(new GraphicsBlock(getCharacter(), (ancients ? 455 : 1577), 0));
|
||||
}
|
||||
}
|
||||
if (stage == 2) {
|
||||
this.cancel();
|
||||
}
|
||||
stage++;
|
||||
}
|
||||
|
||||
}
|
83
src/osiris/game/action/impl/TradeAction.java
Normal file
83
src/osiris/game/action/impl/TradeAction.java
Normal file
@ -0,0 +1,83 @@
|
||||
package osiris.game.action.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.item.Trade;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TradeAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class TradeAction extends Action {
|
||||
|
||||
/** The trade. */
|
||||
private Trade trade;
|
||||
|
||||
/** The player. */
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Instantiates a new trade action.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param trade
|
||||
* the trade
|
||||
*/
|
||||
public TradeAction(Player player, Trade trade) {
|
||||
super(player);
|
||||
this.trade = trade;
|
||||
this.player = player;
|
||||
player.setTradeRequest(null);
|
||||
run();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
trade.cancel(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
trade.openTrade(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the trade.
|
||||
*
|
||||
* @return the trade
|
||||
*/
|
||||
public Trade getTrade() {
|
||||
return trade;
|
||||
}
|
||||
}
|
81
src/osiris/game/action/item/ItemAction.java
Normal file
81
src/osiris/game/action/item/ItemAction.java
Normal file
@ -0,0 +1,81 @@
|
||||
package osiris.game.action.item;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemAction.
|
||||
*
|
||||
* @author Blakeman8192
|
||||
*/
|
||||
public abstract class ItemAction extends Action {
|
||||
|
||||
/** The item. */
|
||||
private final Item item;
|
||||
|
||||
/** The slot. */
|
||||
private final int slot;
|
||||
|
||||
/**
|
||||
* Instantiates a new item action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param item
|
||||
* the item
|
||||
* @param slot
|
||||
* the slot
|
||||
*/
|
||||
public ItemAction(Character character, Item item, int slot) {
|
||||
super(character);
|
||||
this.item = item;
|
||||
this.slot = slot;
|
||||
if (character instanceof Player) {
|
||||
Item inv = ((Player) character).getInventory().getItem(slot);
|
||||
if (inv == null || !inv.equals(item)) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
*
|
||||
* @return the item
|
||||
*/
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slot.
|
||||
*
|
||||
* @return the slot
|
||||
*/
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
}
|
67
src/osiris/game/action/item/ItemClickAction.java
Normal file
67
src/osiris/game/action/item/ItemClickAction.java
Normal file
@ -0,0 +1,67 @@
|
||||
package osiris.game.action.item;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemClickAction.
|
||||
*
|
||||
* @author Blakeman8192
|
||||
*/
|
||||
public class ItemClickAction extends ItemAction {
|
||||
|
||||
/**
|
||||
* Instantiates a new item click action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param item
|
||||
* the item
|
||||
* @param slot
|
||||
* the slot
|
||||
*/
|
||||
public ItemClickAction(Character character, Item item, int slot) {
|
||||
super(character, item, slot);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
|
||||
}
|
||||
|
||||
}
|
81
src/osiris/game/action/item/ItemOnCharacterAction.java
Normal file
81
src/osiris/game/action/item/ItemOnCharacterAction.java
Normal file
@ -0,0 +1,81 @@
|
||||
package osiris.game.action.item;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemOnCharacterAction.
|
||||
*/
|
||||
public class ItemOnCharacterAction extends ItemAction {
|
||||
|
||||
/** The used on. */
|
||||
private final Character usedOn;
|
||||
|
||||
/**
|
||||
* Instantiates a new item on character action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param item
|
||||
* the item
|
||||
* @param slot
|
||||
* the slot
|
||||
* @param usedOn
|
||||
* the used on
|
||||
*/
|
||||
public ItemOnCharacterAction(Character character, Item item, int slot, Character usedOn) {
|
||||
super(character, item, slot);
|
||||
this.usedOn = usedOn;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the used on.
|
||||
*
|
||||
* @return the used on
|
||||
*/
|
||||
public Character getUsedOn() {
|
||||
return usedOn;
|
||||
}
|
||||
|
||||
}
|
98
src/osiris/game/action/item/ItemOnItemAction.java
Normal file
98
src/osiris/game/action/item/ItemOnItemAction.java
Normal file
@ -0,0 +1,98 @@
|
||||
package osiris.game.action.item;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemOnItemAction.
|
||||
*
|
||||
* @author Blakeman8192
|
||||
*/
|
||||
public class ItemOnItemAction extends ItemAction {
|
||||
|
||||
/** The used on. */
|
||||
private final Item usedOn;
|
||||
|
||||
/** The used on slot. */
|
||||
private final int usedOnSlot;
|
||||
|
||||
/**
|
||||
* Instantiates a new item on item action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param first
|
||||
* the first
|
||||
* @param slot
|
||||
* the slot
|
||||
* @param usedOn
|
||||
* the used on
|
||||
* @param usedOnSlot
|
||||
* the used on slot
|
||||
*/
|
||||
public ItemOnItemAction(Character character, Item first, int slot, Item usedOn, int usedOnSlot) {
|
||||
super(character, first, slot);
|
||||
this.usedOn = usedOn;
|
||||
this.usedOnSlot = usedOnSlot;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the used on.
|
||||
*
|
||||
* @return the used on
|
||||
*/
|
||||
public Item getUsedOn() {
|
||||
return usedOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the used on slot.
|
||||
*
|
||||
* @return the used on slot
|
||||
*/
|
||||
public int getUsedOnSlot() {
|
||||
return usedOnSlot;
|
||||
}
|
||||
|
||||
}
|
87
src/osiris/game/action/item/impl/BuryBonesListener.java
Normal file
87
src/osiris/game/action/item/impl/BuryBonesListener.java
Normal file
@ -0,0 +1,87 @@
|
||||
package osiris.game.action.item.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import osiris.game.action.DelayAction;
|
||||
import osiris.game.action.ItemActionListener;
|
||||
import osiris.game.action.item.ItemAction;
|
||||
import osiris.game.model.Skills;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
|
||||
/**
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class BuryBonesListener implements ItemActionListener {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ItemActionListener#onItemAction(osiris.game.action
|
||||
* .item.ItemAction)
|
||||
*/
|
||||
@Override
|
||||
public void onItemAction(ItemAction action) {
|
||||
if (!action.getPlayer().getActionTimer().completed()) {
|
||||
action.cancel();
|
||||
return;
|
||||
}
|
||||
Item item = action.getItem();
|
||||
Bone bone = Bone.valueOf(ItemDef.forId(item.getId()).getName().toUpperCase().replaceAll(" ", "_"));
|
||||
if (bone == null)
|
||||
return;
|
||||
if (action.getPlayer().getInventory().removeBySlot(action.getSlot(), 1)) {
|
||||
action.getPlayer().addUpdateBlock(new AnimationBlock(action.getPlayer(), 827, 0));
|
||||
action.getPlayer().getSkills().addExp(Skills.SKILL_PRAYER, bone.getExp());
|
||||
new DelayAction(action.getPlayer(), 2).run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum Bone.
|
||||
*/
|
||||
public enum Bone {
|
||||
|
||||
BONES(4.5), WOLF_BONES(4.5), BURNT_BONES(4.5), MONKEY_BONES(5), BAT_BONES(5.3), BIG_BONES(15), JOGRE_BONES(15), BABYDRAGON_BONES(30), DRAGON_BONES(72);
|
||||
|
||||
/** The exp earned. */
|
||||
private double expEarned;
|
||||
|
||||
/**
|
||||
* Instantiates a new bone.
|
||||
*
|
||||
* @param exp
|
||||
* the exp
|
||||
*/
|
||||
Bone(double exp) {
|
||||
this.expEarned = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exp.
|
||||
*
|
||||
* @return the exp
|
||||
*/
|
||||
public double getExp() {
|
||||
return expEarned;
|
||||
}
|
||||
}
|
||||
}
|
64
src/osiris/game/action/item/impl/FiremakingListener.java
Normal file
64
src/osiris/game/action/item/impl/FiremakingListener.java
Normal file
@ -0,0 +1,64 @@
|
||||
package osiris.game.action.item.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.ItemActionListener;
|
||||
import osiris.game.action.item.ItemAction;
|
||||
import osiris.game.action.item.ItemOnItemAction;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.skills.Firemaking;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The listener interface for receiving firemaking events. The class that is
|
||||
* interested in processing a firemaking event implements this interface, and
|
||||
* the object created with that class is registered with a component using the
|
||||
* component's <code>addFiremakingListener<code> method. When
|
||||
* the firemaking event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class FiremakingListener implements ItemActionListener {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ItemActionListener#onItemAction(osiris.game.action
|
||||
* .item.ItemAction)
|
||||
*/
|
||||
@Override
|
||||
public void onItemAction(ItemAction action) {
|
||||
if (!(action instanceof ItemOnItemAction))
|
||||
return;
|
||||
if (((ItemOnItemAction) action).getUsedOn() == null || action.getItem() == null)
|
||||
return;
|
||||
int slot = action.getItem().getId() == 590 ? ((ItemOnItemAction) action).getUsedOnSlot() : action.getSlot();
|
||||
Firemaking.Log log = null;
|
||||
try {
|
||||
log = Firemaking.Log.valueOf(Firemaking.getLogName(ItemDef.forId(action.getPlayer().getInventory().getItem(slot).getId()).getName()));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
if (log != null)
|
||||
Firemaking.lightLog(action.getPlayer(), slot, log);
|
||||
else
|
||||
action.getPlayer().getEventWriter().sendMessage("You can not light that!");
|
||||
}
|
||||
}
|
94
src/osiris/game/action/object/ItemOnObjectAction.java
Normal file
94
src/osiris/game/action/object/ItemOnObjectAction.java
Normal file
@ -0,0 +1,94 @@
|
||||
package osiris.game.action.object;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.game.model.item.Item;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemOnObjectAction.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
|
||||
public class ItemOnObjectAction extends ObjectAction {
|
||||
|
||||
/** The item. */
|
||||
private Item item;
|
||||
|
||||
/** The item slot. */
|
||||
private int itemSlot;
|
||||
|
||||
/**
|
||||
* Instantiates a new object action task.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param position
|
||||
* the position
|
||||
* @param distance
|
||||
* the distance
|
||||
* @param type
|
||||
* the type
|
||||
* @param objectID
|
||||
* the object id
|
||||
* @param objectX
|
||||
* the object x
|
||||
* @param objectY
|
||||
* the object y
|
||||
* @param itemSlot
|
||||
* the item slot
|
||||
* @param itemId
|
||||
* the item id
|
||||
*/
|
||||
public ItemOnObjectAction(Character character, Position position, int distance, ObjectActionType type, int objectID, int objectX, int objectY, int itemSlot, int itemId) {
|
||||
super(character, position, distance, type, objectID, objectX, objectY);
|
||||
if (!(character instanceof Player)) {
|
||||
System.out.println("Cancelled");
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Item existing = getPlayer().getInventory().getItem(itemSlot);
|
||||
if (existing == null || existing.getId() != itemId)
|
||||
return;
|
||||
this.item = existing;
|
||||
this.itemSlot = itemSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
*
|
||||
* @return the item
|
||||
*/
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item slot.
|
||||
*
|
||||
* @return the item slot
|
||||
*/
|
||||
public int getItemSlot() {
|
||||
return itemSlot;
|
||||
}
|
||||
}
|
128
src/osiris/game/action/object/ObjectAction.java
Normal file
128
src/osiris/game/action/object/ObjectAction.java
Normal file
@ -0,0 +1,128 @@
|
||||
package osiris.game.action.object;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.DistancedAction;
|
||||
import osiris.game.action.ObjectActionListeners;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Position;
|
||||
|
||||
/**
|
||||
* The Class ObjectAction.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class ObjectAction extends DistancedAction {
|
||||
|
||||
/**
|
||||
* The Enum ObjectActionType.
|
||||
*/
|
||||
public enum ObjectActionType {
|
||||
|
||||
/**
|
||||
* The FIRST.
|
||||
*/
|
||||
FIRST,
|
||||
|
||||
/**
|
||||
* The SECOND.
|
||||
*/
|
||||
SECOND,
|
||||
|
||||
/**
|
||||
* The THIRD.
|
||||
*/
|
||||
THIRD
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The type.
|
||||
*/
|
||||
private final ObjectActionType type;
|
||||
|
||||
/**
|
||||
* The object id.
|
||||
*/
|
||||
private final int objectID;
|
||||
|
||||
/**
|
||||
* The object x.
|
||||
*/
|
||||
private final Position objectPosition;
|
||||
|
||||
/**
|
||||
* Instantiates a new object action.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param position
|
||||
* the position
|
||||
* @param distance
|
||||
* the distance
|
||||
* @param type
|
||||
* the type
|
||||
* @param objectID
|
||||
* the object id
|
||||
* @param objectX
|
||||
* the object x
|
||||
* @param objectY
|
||||
* the object y
|
||||
*/
|
||||
public ObjectAction(Character character, Position position, int distance, ObjectActionType type, int objectID, int objectX, int objectY) {
|
||||
super(character, position, distance);
|
||||
this.type = type;
|
||||
this.objectID = objectID;
|
||||
this.objectPosition = new Position(objectX, objectY, character.getPosition().getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
getCharacter().facePosition(objectPosition);
|
||||
ObjectActionListeners.fireObjectAction(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public ObjectActionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object id.
|
||||
*
|
||||
* @return the objectID
|
||||
*/
|
||||
public int getObjectID() {
|
||||
return objectID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object position.
|
||||
*
|
||||
* @return the object position
|
||||
*/
|
||||
public Position getObjectPosition() {
|
||||
return objectPosition;
|
||||
}
|
||||
}
|
103
src/osiris/game/action/object/ObjectSetter.java
Normal file
103
src/osiris/game/action/object/ObjectSetter.java
Normal file
@ -0,0 +1,103 @@
|
||||
package osiris.game.action.object;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import osiris.ServerEngine;
|
||||
import osiris.game.model.WorldObject;
|
||||
import osiris.game.model.WorldObjects;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ObjectSetter.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
* @author Boomer
|
||||
*/
|
||||
public class ObjectSetter {
|
||||
|
||||
/** The original object. */
|
||||
private final WorldObject originalObject;
|
||||
|
||||
/** The new object. */
|
||||
private final WorldObject newObject;
|
||||
|
||||
/** The reset delay. */
|
||||
private final int resetDelay;
|
||||
|
||||
/** The resetter. */
|
||||
private final Runnable resetter;
|
||||
|
||||
/** The on reset. */
|
||||
private Runnable onReset;
|
||||
|
||||
/**
|
||||
* Instantiates a new object setter.
|
||||
*
|
||||
* @param originalObject
|
||||
* the original object
|
||||
* @param newObject
|
||||
* the new object
|
||||
* @param resetDelay
|
||||
* the reset delay
|
||||
*/
|
||||
public ObjectSetter(WorldObject originalObject, WorldObject newObject, int resetDelay) {
|
||||
this.originalObject = originalObject;
|
||||
this.newObject = newObject;
|
||||
this.resetDelay = resetDelay;
|
||||
resetter = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Reset to the old ID.
|
||||
ObjectSetter o = ObjectSetter.this;
|
||||
WorldObjects.removeObject(o.newObject);
|
||||
if (o.originalObject != null)
|
||||
WorldObjects.addObject(o.originalObject);
|
||||
if (onReset != null)
|
||||
onReset.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the on reset.
|
||||
*
|
||||
* @param onReset
|
||||
* the on reset
|
||||
* @return the object setter
|
||||
*/
|
||||
public ObjectSetter setOnReset(Runnable onReset) {
|
||||
this.onReset = onReset;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute.
|
||||
*/
|
||||
public void execute() {
|
||||
// Set to the new ID.
|
||||
WorldObjects.removeObject(originalObject);
|
||||
WorldObjects.addObject(newObject);
|
||||
|
||||
// Schedule the resetter.
|
||||
ServerEngine.getScheduler().schedule(resetter, resetDelay, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
56
src/osiris/game/action/object/impl/BankObjectAction.java
Normal file
56
src/osiris/game/action/object/impl/BankObjectAction.java
Normal file
@ -0,0 +1,56 @@
|
||||
package osiris.game.action.object.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.DistancedAction;
|
||||
import osiris.game.action.ObjectActionListener;
|
||||
import osiris.game.action.impl.BankAction;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.model.Player;
|
||||
|
||||
/**
|
||||
* The Class BankObjectAction.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class BankObjectAction implements ObjectActionListener {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ObjectActionListener#onObjectAction(osiris.game.action
|
||||
* .object.ObjectAction)
|
||||
*/
|
||||
@Override
|
||||
public void onObjectAction(ObjectAction action) {
|
||||
final Player player = (Player) action.getCharacter();
|
||||
|
||||
new DistancedAction(player, action.getObjectPosition(), 1) {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
new BankAction(player);
|
||||
}
|
||||
|
||||
}.run();
|
||||
}
|
||||
|
||||
}
|
76
src/osiris/game/action/object/impl/CookingListener.java
Normal file
76
src/osiris/game/action/object/impl/CookingListener.java
Normal file
@ -0,0 +1,76 @@
|
||||
package osiris.game.action.object.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.ObjectActionListener;
|
||||
import osiris.game.action.object.ItemOnObjectAction;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.skills.Cooking;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The listener interface for receiving cooking events. The class that is
|
||||
* interested in processing a cooking event implements this interface, and the
|
||||
* object created with that class is registered with a component using the
|
||||
* component's <code>addCookingListener<code> method. When
|
||||
* the cooking event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class CookingListener implements ObjectActionListener {
|
||||
|
||||
/** The fire. */
|
||||
private boolean fire;
|
||||
|
||||
/**
|
||||
* Instantiates a new cooking listener.
|
||||
*
|
||||
* @param fire
|
||||
* the fire
|
||||
*/
|
||||
public CookingListener(boolean fire) {
|
||||
this.fire = fire;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ObjectActionListener#onObjectAction(osiris.game.action
|
||||
* .object.ObjectAction)
|
||||
*/
|
||||
@Override
|
||||
public void onObjectAction(ObjectAction action) {
|
||||
if (!(action instanceof ItemOnObjectAction))
|
||||
return;
|
||||
String recipeName = Cooking.toRecipeName(ItemDef.forId(((ItemOnObjectAction) action).getItem().getId()).getName());
|
||||
System.out.println("RECIPE: " + recipeName);
|
||||
Cooking.Recipe recipe = null;
|
||||
try {
|
||||
recipe = Cooking.Recipe.valueOf(recipeName);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
if (recipe != null)
|
||||
Cooking.cookItem(action.getPlayer(), action.getObjectPosition(), ((ItemOnObjectAction) action).getItemSlot(), recipe, fire);
|
||||
else
|
||||
action.getPlayer().getEventWriter().sendMessage("You can not cook that item!");
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package osiris.game.action.object.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import osiris.data.parser.impl.PositionChangeParser;
|
||||
import osiris.data.parser.impl.WorldObjectParser;
|
||||
import osiris.game.action.ObjectActionListener;
|
||||
import osiris.game.action.impl.DialogueAction;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.WorldObject;
|
||||
import osiris.game.model.WorldObjects;
|
||||
import osiris.game.model.dialogues.Dialogue;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The listener interface for receiving positionChangeAction events. The class
|
||||
* that is interested in processing a positionChangeAction event implements this
|
||||
* interface, and the object created with that class is registered with a
|
||||
* component using the component's
|
||||
* <code>addPositionChangeActionListener<code> method. When
|
||||
* the positionChangeAction event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class PositionChangeActionListener implements ObjectActionListener {
|
||||
|
||||
/** The info. */
|
||||
private PositionChangeParser.PositionChangeInfo info;
|
||||
|
||||
/**
|
||||
* Instantiates a new position change action listener.
|
||||
*
|
||||
* @param info
|
||||
* the info
|
||||
*/
|
||||
public PositionChangeActionListener(PositionChangeParser.PositionChangeInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ObjectActionListener#onObjectAction(osiris.game.action
|
||||
* .object.ObjectAction)
|
||||
*/
|
||||
public void onObjectAction(ObjectAction objectAction) {
|
||||
Player player = objectAction.getPlayer();
|
||||
if (info.getType() == PositionChangeParser.Type.DOOR) {
|
||||
WorldObject object = WorldObjects.getObject(info.getLocation());
|
||||
if (object == null) {
|
||||
object = new WorldObject(info.getId(), info.getFrom().getId(), 0, info.getLocation());
|
||||
}
|
||||
WorldObjectParser.Face switchTo = info.getCurrent() == info.getTo() ? info.getFrom() : info.getTo();
|
||||
WorldObjects.removeObject(object);
|
||||
WorldObjects.addObject(new WorldObject(info.getId(), switchTo.getId(), 0, info.getLocation()));
|
||||
WorldObjects.refresh(player);
|
||||
info.setCurrent(switchTo);
|
||||
} else if (info.getType() == PositionChangeParser.Type.STAIR) {
|
||||
if (info.getMove(1) != null && info.getMove(0) != null) {
|
||||
Dialogue dialogue = new Dialogue(Dialogue.Type.OPTION, 1);
|
||||
List<String> lines = new ArrayList<String>();
|
||||
lines.add("Go up.");
|
||||
lines.add("Go down.");
|
||||
dialogue.setLines(lines);
|
||||
dialogue.setNpc(-2);
|
||||
dialogue.setNext(info.getId());
|
||||
new DialogueAction(player, dialogue).run();
|
||||
} else {
|
||||
if (info.getMove(1) != null) {
|
||||
player.teleport(info.getMove(1));
|
||||
} else if (info.getMove(0) != null) {
|
||||
player.teleport(info.getMove(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
161
src/osiris/game/action/object/impl/RockActionListener.java
Normal file
161
src/osiris/game/action/object/impl/RockActionListener.java
Normal file
@ -0,0 +1,161 @@
|
||||
package osiris.game.action.object.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.game.model.skills.Mining.ADAMANT_PICKAXE;
|
||||
import static osiris.game.model.skills.Mining.BRONZE_PICKAXE;
|
||||
import static osiris.game.model.skills.Mining.IRON_PICKAXE;
|
||||
import static osiris.game.model.skills.Mining.MITHRIL_PICKAXE;
|
||||
import static osiris.game.model.skills.Mining.RUNE_PICKAXE;
|
||||
import static osiris.game.model.skills.Mining.STEEL_PICKAXE;
|
||||
import static osiris.game.model.skills.Mining.getAnimationMap;
|
||||
import static osiris.game.model.skills.Mining.getDelay;
|
||||
import static osiris.game.model.skills.Mining.getExpMap;
|
||||
import static osiris.game.model.skills.Mining.getKeywordMap;
|
||||
import static osiris.game.model.skills.Mining.getOreMap;
|
||||
import static osiris.game.model.skills.Mining.getPickaxeLevelMap;
|
||||
import static osiris.game.model.skills.Mining.getPickaxeSpeedMap;
|
||||
import static osiris.game.model.skills.Mining.getRespawnMap;
|
||||
import static osiris.game.model.skills.Mining.getRockLevelMap;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import osiris.game.action.ObjectActionListener;
|
||||
import osiris.game.action.TickedAction;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.action.object.ObjectSetter;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Skills;
|
||||
import osiris.game.model.WorldObject;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* ROCK ON.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
*/
|
||||
public class RockActionListener implements ObjectActionListener {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ObjectActionListener#onObjectAction(osiris.game.action
|
||||
* .object.ObjectAction)
|
||||
*/
|
||||
@Override
|
||||
public void onObjectAction(final ObjectAction action) {
|
||||
final Player player = (Player) action.getCharacter();
|
||||
final int objectID = action.getObjectID();
|
||||
|
||||
// Check preliminary requirements (and get the pickaxe used).
|
||||
if (player.getInventory().isFull()) {
|
||||
player.getEventWriter().sendMessage("Your inventory is too full to mine any more ore.");
|
||||
return;
|
||||
}
|
||||
|
||||
final int pickaxeUsed = checkRequirements(action);
|
||||
if (pickaxeUsed == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.getEventWriter().sendMessage("You swing your pick at the rock...");
|
||||
player.addUpdateBlock(new AnimationBlock(player, getAnimationMap().get(pickaxeUsed), 0));
|
||||
final String keyword = getKeywordMap().get(objectID);
|
||||
|
||||
TickedAction miningAction = new TickedAction(player, 3) {
|
||||
|
||||
private int counter = 0;
|
||||
private final Random random = new Random();
|
||||
|
||||
{
|
||||
int max = (int) (getDelay(player.getSkills().currentLevel(Skills.SKILL_MINING), getPickaxeSpeedMap().get(pickaxeUsed), getRockLevelMap().get(keyword)) / .6) / 4;
|
||||
counter = random.nextInt(max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
counter -= 2;
|
||||
player.addUpdateBlock(new AnimationBlock(player, getAnimationMap().get(pickaxeUsed), 0));
|
||||
if (counter <= 0) {
|
||||
player.getEventWriter().sendMessage("You get some " + keyword + " ore.");
|
||||
player.getInventory().add(new Item(getOreMap().get(keyword)));
|
||||
player.getSkills().addExp(Skills.SKILL_MINING, getExpMap().get(keyword));
|
||||
player.addUpdateBlock(new AnimationBlock(player, -1, 0));
|
||||
WorldObject fullObject = new WorldObject(objectID, 0, 10, action.getObjectPosition());
|
||||
WorldObject emptyObject = new WorldObject(31060, 0, 10, action.getObjectPosition());
|
||||
new ObjectSetter(fullObject, emptyObject, getRespawnMap().get(keyword)).execute();
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
miningAction.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check requirements.
|
||||
*
|
||||
* @param action
|
||||
* the action
|
||||
* @return the int
|
||||
*/
|
||||
private int checkRequirements(ObjectAction action) {
|
||||
Player player = (Player) action.getCharacter();
|
||||
int level = player.getSkills().currentLevel(Skills.SKILL_MINING);
|
||||
|
||||
int requiredLevel = getRockLevelMap().get(getKeywordMap().get(action.getObjectID()));
|
||||
if (level < requiredLevel) {
|
||||
player.getEventWriter().sendMessage("You need a mining level of " + requiredLevel + " to mine this rock.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Next, check for pickaxes.
|
||||
for (Item item : player.getEquipment().getItems()) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
int id = item.getId();
|
||||
if (id == BRONZE_PICKAXE || id == IRON_PICKAXE || id == STEEL_PICKAXE || id == MITHRIL_PICKAXE || id == ADAMANT_PICKAXE || id == RUNE_PICKAXE) {
|
||||
requiredLevel = getPickaxeLevelMap().get(id);
|
||||
if (level >= requiredLevel) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Item item : player.getInventory().getItems()) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
int id = item.getId();
|
||||
if (id == BRONZE_PICKAXE || id == IRON_PICKAXE || id == STEEL_PICKAXE || id == MITHRIL_PICKAXE || id == ADAMANT_PICKAXE || id == RUNE_PICKAXE) {
|
||||
requiredLevel = getPickaxeLevelMap().get(id);
|
||||
if (level >= requiredLevel) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.getEventWriter().sendMessage("You do not have a pickaxe of which you have the level to use.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
201
src/osiris/game/action/object/impl/TreeActionListener.java
Normal file
201
src/osiris/game/action/object/impl/TreeActionListener.java
Normal file
@ -0,0 +1,201 @@
|
||||
package osiris.game.action.object.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import static osiris.game.model.skills.Woodcutting.ADAMANT_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.BLACK_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.BRONZE_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.DRAGON_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.IRON_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.MITHRIL_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.RUNE_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.STEEL_AXE;
|
||||
import static osiris.game.model.skills.Woodcutting.getAnimationMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getAxeLevelMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getAxeSpeedMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getDelay;
|
||||
import static osiris.game.model.skills.Woodcutting.getExperienceMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getLogsMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getRespawnDelayMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getStumpMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getTreeChanceMap;
|
||||
import static osiris.game.model.skills.Woodcutting.getTreeLevelMap;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import osiris.game.action.ObjectActionListener;
|
||||
import osiris.game.action.TickedAction;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.action.object.ObjectSetter;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Skills;
|
||||
import osiris.game.model.WorldObject;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The listener interface for receiving treeAction events. The class that is
|
||||
* interested in processing a treeAction event implements this interface, and
|
||||
* the object created with that class is registered with a component using the
|
||||
* component's <code>addTreeActionListener<code> method. When
|
||||
* the treeAction event occurs, that object's appropriate
|
||||
* method is invoked.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
*/
|
||||
public class TreeActionListener implements ObjectActionListener {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* osiris.game.action.ObjectActionListener#onObjectAction(osiris.game.action
|
||||
* .object.ObjectAction)
|
||||
*/
|
||||
@Override
|
||||
public void onObjectAction(final ObjectAction action) {
|
||||
final Player player = (Player) action.getCharacter();
|
||||
final int objectID = action.getObjectID();
|
||||
|
||||
// Check preliminary requirements (and get the axe used).
|
||||
if (player.getInventory().isFull()) {
|
||||
player.getEventWriter().sendMessage("Your inventory is too full to hold any more logs.");
|
||||
return;
|
||||
}
|
||||
final int axeUsed = checkRequirements(action);
|
||||
if (axeUsed == -1) { // Flags that we cannot chop this tree or have an
|
||||
// axe.
|
||||
return;
|
||||
}
|
||||
|
||||
// Start chopping.
|
||||
player.getEventWriter().sendMessage("You swing your axe at the tree...");
|
||||
player.addUpdateBlock(new AnimationBlock(player, getAnimationMap().get(axeUsed), 0));
|
||||
|
||||
// Schedule the woodcutting action.
|
||||
new TickedAction(player, 4) {
|
||||
|
||||
private int counter;
|
||||
private final Random random = new Random();
|
||||
|
||||
{
|
||||
// Calculate the initial delay (we will calculate again each
|
||||
// time a log is obtained).
|
||||
int max = (int) (getDelay(player.getSkills().currentLevel(Skills.SKILL_WOODCUTTING), getAxeSpeedMap().get(axeUsed), getTreeLevelMap().get(objectID)) / .6) / 4;
|
||||
counter = random.nextInt(max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
counter -= 4; // Speed up the rate * 4.
|
||||
|
||||
// Stop if we can't hold any more logs.
|
||||
if (player.getInventory().isFull()) {
|
||||
player.stopAnimation();
|
||||
player.getEventWriter().sendMessage("Your inventory is too full to hold any more logs.");
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Animate and check if we should chop a log.
|
||||
player.addUpdateBlock(new AnimationBlock(player, getAnimationMap().get(axeUsed), 0));
|
||||
if (counter <= 0) { // Time to add a log.
|
||||
// Send the message, add the log, and add the experience.
|
||||
player.getEventWriter().sendMessage("You get some logs.");
|
||||
player.getInventory().add(new Item(getLogsMap().get(objectID)));
|
||||
player.getSkills().addExp(Skills.SKILL_WOODCUTTING, getExperienceMap().get(objectID));
|
||||
|
||||
// Check if the tree should fall.
|
||||
if (random.nextDouble() <= getTreeChanceMap().get(objectID)) {
|
||||
WorldObject stumpObject = new WorldObject(getStumpMap().get(objectID), 0, 10, action.getObjectPosition());
|
||||
WorldObject treeObject = new WorldObject(objectID, 0, 10, action.getObjectPosition());
|
||||
new ObjectSetter(treeObject, stumpObject, getRespawnDelayMap().get(objectID)).execute();
|
||||
player.stopAnimation();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the delay again for the next log.
|
||||
int max = (int) (getDelay(player.getSkills().currentLevel(Skills.SKILL_WOODCUTTING), getAxeSpeedMap().get(axeUsed), getTreeLevelMap().get(objectID)) / .6) / 4;
|
||||
counter = random.nextInt(max);
|
||||
}
|
||||
}
|
||||
|
||||
}.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check requirements.
|
||||
*
|
||||
* @param action
|
||||
* the action
|
||||
* @return the int
|
||||
*/
|
||||
private int checkRequirements(ObjectAction action) {
|
||||
Player player = (Player) action.getCharacter();
|
||||
int level = player.getSkills().currentLevel(Skills.SKILL_WOODCUTTING);
|
||||
|
||||
// First, check if they can chop the tree.
|
||||
int requiredLevel = getTreeLevelMap().get(action.getObjectID());
|
||||
if (level < requiredLevel) {
|
||||
player.getEventWriter().sendMessage("You need a woodcutting level of " + requiredLevel + " to chop this tree.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Next, check for axes.
|
||||
for (Item item : player.getEquipment().getItems()) { // First, check our
|
||||
// equipment.
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
// Check if it is an axe.
|
||||
int id = item.getId();
|
||||
if (id == BRONZE_AXE || id == IRON_AXE || id == STEEL_AXE || id == BLACK_AXE || id == MITHRIL_AXE || id == ADAMANT_AXE || id == RUNE_AXE || id == DRAGON_AXE) {
|
||||
// It is, so check if we can use it.
|
||||
requiredLevel = getAxeLevelMap().get(id);
|
||||
if (level >= requiredLevel) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Item item : player.getInventory().getItems()) { // Next, check our
|
||||
// inventory.
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
// Check if it is an axe.
|
||||
int id = item.getId();
|
||||
if (id == BRONZE_AXE || id == IRON_AXE || id == STEEL_AXE || id == BLACK_AXE || id == MITHRIL_AXE || id == ADAMANT_AXE || id == RUNE_AXE || id == DRAGON_AXE) {
|
||||
// It is, so check if we can use it.
|
||||
requiredLevel = getAxeLevelMap().get(id);
|
||||
if (level >= requiredLevel) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We would have returned a value by now, so no they don't have a proper
|
||||
// axe.
|
||||
player.getEventWriter().sendMessage("You do not have an axe of which you have the level to use.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
83
src/osiris/game/event/GameEvent.java
Normal file
83
src/osiris/game/event/GameEvent.java
Normal file
@ -0,0 +1,83 @@
|
||||
package osiris.game.event;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* An abstract class for game events.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public abstract class GameEvent {
|
||||
|
||||
/**
|
||||
* The player.
|
||||
*/
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The packet.
|
||||
*/
|
||||
private final Packet packet;
|
||||
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public GameEvent(Player player, Packet packet) {
|
||||
this.player = player;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the game event.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public abstract void process() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the packet.
|
||||
*
|
||||
* @return the packet
|
||||
*/
|
||||
public Packet getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
116
src/osiris/game/event/GameEventLookup.java
Normal file
116
src/osiris/game/event/GameEventLookup.java
Normal file
@ -0,0 +1,116 @@
|
||||
package osiris.game.event;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.impl.ActionButtonEvent;
|
||||
import osiris.game.event.impl.CastSpellEvent;
|
||||
import osiris.game.event.impl.ChatEvent;
|
||||
import osiris.game.event.impl.ChatOptionsEvent;
|
||||
import osiris.game.event.impl.CommandEvent;
|
||||
import osiris.game.event.impl.ContactsEvent;
|
||||
import osiris.game.event.impl.ExamineEvent;
|
||||
import osiris.game.event.impl.HdNotificationEvent;
|
||||
import osiris.game.event.impl.IgnoredEvent;
|
||||
import osiris.game.event.impl.ItemOnItemEvent;
|
||||
import osiris.game.event.impl.ItemOnObjectEvent;
|
||||
import osiris.game.event.impl.ItemSystemsEvent;
|
||||
import osiris.game.event.impl.LoginRequestEvent;
|
||||
import osiris.game.event.impl.LogoutEvent;
|
||||
import osiris.game.event.impl.MovementEvent;
|
||||
import osiris.game.event.impl.NpcAttackEvent;
|
||||
import osiris.game.event.impl.NpcOptionEvent;
|
||||
import osiris.game.event.impl.ObjectEvent;
|
||||
import osiris.game.event.impl.OptionClickEvent;
|
||||
import osiris.game.event.impl.PlayerOptionEvent;
|
||||
import osiris.game.event.impl.RegionLoadedEvent;
|
||||
import osiris.game.event.impl.ServiceRequestEvent;
|
||||
import osiris.game.event.impl.UnhandledEvent;
|
||||
import osiris.game.event.impl.UpdateRequestEvent;
|
||||
import osiris.game.event.impl.ValueXEvent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Provides lookup utilities for game events.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class GameEventLookup {
|
||||
|
||||
/**
|
||||
* The events.
|
||||
*/
|
||||
private static Class<?>[] events = new Class<?>[259];
|
||||
|
||||
/**
|
||||
* Lookup.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode
|
||||
* @return the class
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Class<GameEvent> lookup(int opcode) {
|
||||
return (Class<GameEvent>) events[opcode];
|
||||
}
|
||||
|
||||
static {
|
||||
// Request events.
|
||||
events[256] = ServiceRequestEvent.class;
|
||||
events[257] = UpdateRequestEvent.class;
|
||||
events[258] = LoginRequestEvent.class;
|
||||
|
||||
// Ignored events
|
||||
events[115] = events[247] = events[22] = events[117] = events[59] = events[99] = events[248] = IgnoredEvent.class;
|
||||
|
||||
// Game events.
|
||||
events[224] = ItemOnObjectEvent.class;
|
||||
events[43] = ValueXEvent.class;
|
||||
events[24] = events[70] = CastSpellEvent.class;
|
||||
events[49] = MovementEvent.class;
|
||||
events[119] = MovementEvent.class;
|
||||
events[138] = MovementEvent.class;
|
||||
events[138] = MovementEvent.class;
|
||||
events[107] = CommandEvent.class;
|
||||
events[3] = events[167] = events[179] = events[203] = events[211] = events[201] = events[220] = ItemSystemsEvent.class;
|
||||
events[203] = ItemSystemsEvent.class;
|
||||
events[160] = events[253] = PlayerOptionEvent.class;
|
||||
events[123] = NpcAttackEvent.class;
|
||||
events[21] = events[113] = events[169] = events[232] = events[133] = events[250] = ActionButtonEvent.class;
|
||||
events[233] = events[214] = events[173] = ActionButtonEvent.class;
|
||||
events[212] = ChatOptionsEvent.class;
|
||||
events[222] = ChatEvent.class;
|
||||
events[129] = HdNotificationEvent.class;
|
||||
events[158] = events[228] = ObjectEvent.class;
|
||||
events[47] = LogoutEvent.class;
|
||||
events[40] = ItemOnItemEvent.class;
|
||||
events[30] = events[61] = events[132] = events[2] = events[178] = ContactsEvent.class;
|
||||
events[60] = RegionLoadedEvent.class;
|
||||
events[38] = events[84] = events[88] = ExamineEvent.class;
|
||||
events[52] = events[7] = events[199] = NpcOptionEvent.class;
|
||||
events[63] = OptionClickEvent.class;
|
||||
|
||||
for (int i = 0; i < events.length; i++) {
|
||||
if (events[i] == null) {
|
||||
events[i] = UnhandledEvent.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
459
src/osiris/game/event/impl/ActionButtonEvent.java
Normal file
459
src/osiris/game/event/impl/ActionButtonEvent.java
Normal file
@ -0,0 +1,459 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.action.impl.DeathItemsScreenAction;
|
||||
import osiris.game.action.impl.EmoteAction;
|
||||
import osiris.game.action.impl.EquipmentScreenAction;
|
||||
import osiris.game.action.impl.SwitchAutoCastAction;
|
||||
import osiris.game.action.impl.TradeAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.XValue;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.game.model.effect.PrayerEffect;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.model.item.ItemContainer;
|
||||
import osiris.game.model.item.Trade;
|
||||
import osiris.game.model.magic.MagicManager;
|
||||
import osiris.game.model.magic.Spell;
|
||||
import osiris.game.model.magic.SpellBook;
|
||||
import osiris.game.model.skills.Prayer;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.util.Settings;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ActionButtonEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
* @author samuraiblood2
|
||||
* @author Blake
|
||||
*/
|
||||
public class ActionButtonEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ActionButtonEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int interfaceId = reader.readShort(false);
|
||||
int buttonId = reader.readShort(false);
|
||||
int buttonInfo = 0;
|
||||
if (getPacket().getHeader().getLength() >= 6) {
|
||||
buttonInfo = reader.readShort(false);
|
||||
}
|
||||
if (buttonInfo == 65535) {
|
||||
buttonInfo = 0;
|
||||
}
|
||||
if (Main.isLocal() && getPlayer().getPlayerStatus() == 2)
|
||||
getPlayer().getEventWriter().sendMessage("[" + getPacket().getHeader().getOpcode() + "]Interface: " + interfaceId + " Button: " + buttonId + " Info: " + buttonInfo);
|
||||
switch (interfaceId) {
|
||||
case 192:
|
||||
Spell spell = MagicManager.getSpell(buttonId, SpellBook.NORMAL);
|
||||
if (spell != null)
|
||||
spell.execute(getPlayer(), false);
|
||||
break;
|
||||
case 193:
|
||||
spell = MagicManager.getSpell(buttonId, SpellBook.ANCIENT);
|
||||
if (spell != null)
|
||||
spell.execute(getPlayer(), false);
|
||||
break;
|
||||
case 464:
|
||||
handleEmote(buttonId);
|
||||
break;
|
||||
case 182:
|
||||
if (buttonId == 6) {
|
||||
getPlayer().logout();
|
||||
}
|
||||
break;
|
||||
case 763:
|
||||
if (buttonId == 0) {
|
||||
Item item = getPlayer().getInventory().getItem(buttonInfo);
|
||||
if (item == null)
|
||||
return;
|
||||
int amount = 0;
|
||||
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 233:
|
||||
amount = 1;
|
||||
getPlayer().depositItem(buttonInfo, amount);
|
||||
break;
|
||||
case 21:
|
||||
amount = 5;
|
||||
getPlayer().depositItem(buttonInfo, amount);
|
||||
break;
|
||||
case 169:
|
||||
amount = 10;
|
||||
getPlayer().depositItem(buttonInfo, amount);
|
||||
break;
|
||||
case 232:
|
||||
amount = getPlayer().getInventory().amountOfItem(item.getId());
|
||||
getPlayer().depositItem(buttonInfo, amount);
|
||||
break;
|
||||
case 173:
|
||||
new XValue(getPlayer(), getPlayer().getCurrentAction(), buttonInfo, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 762:
|
||||
if (buttonId == 73) {
|
||||
Item item = null;
|
||||
Item[] bankItems = getPlayer().getBank().getItems();
|
||||
if (bankItems != null && bankItems.length > buttonInfo)
|
||||
item = bankItems[buttonInfo];
|
||||
if (item == null)
|
||||
return;
|
||||
int amount = 0;
|
||||
int hasAmount = item.getAmount();
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 233:
|
||||
amount = 1;
|
||||
getPlayer().withdrawItem(buttonInfo, amount);
|
||||
break;
|
||||
case 21:
|
||||
amount = 5;
|
||||
getPlayer().withdrawItem(buttonInfo, amount);
|
||||
break;
|
||||
case 169:
|
||||
amount = 10;
|
||||
getPlayer().withdrawItem(buttonInfo, amount);
|
||||
break;
|
||||
case 232:
|
||||
amount = hasAmount;
|
||||
getPlayer().withdrawItem(buttonInfo, amount);
|
||||
break;
|
||||
case 133:
|
||||
amount = (hasAmount - 1);
|
||||
getPlayer().withdrawItem(buttonInfo, amount);
|
||||
break;
|
||||
case 173:
|
||||
new XValue(getPlayer(), getPlayer().getCurrentAction(), buttonInfo, true);
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (buttonId == 16) {
|
||||
getPlayer().getBank().switchWithdrawNotes();
|
||||
}
|
||||
break;
|
||||
|
||||
case 261:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
/*
|
||||
* Toggle run.
|
||||
*/
|
||||
getPlayer().setRunToggle(!getPlayer().isRunToggled());
|
||||
break;
|
||||
|
||||
case 14:
|
||||
/*
|
||||
* Settings screen.
|
||||
*/
|
||||
getPlayer().getEventWriter().sendInterface(742);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
/*
|
||||
* Settings screen.
|
||||
*/
|
||||
getPlayer().getEventWriter().sendInterface(743);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/*
|
||||
* Chat effects.
|
||||
*/
|
||||
getPlayer().getSettings().setChatEffects(!getPlayer().getSettings().isChatEffects());
|
||||
getPlayer().getSettings().refresh();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/*
|
||||
* Split private chat.
|
||||
*/
|
||||
getPlayer().getSettings().setSplitPrivateChat(!getPlayer().getSettings().isSplitPrivateChat());
|
||||
getPlayer().getSettings().refresh();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// TODO: Mouse button config.
|
||||
break;
|
||||
|
||||
case 5:
|
||||
// TODO: Accept aid config.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 750:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
/*
|
||||
* Toggle run.
|
||||
*/
|
||||
getPlayer().setRunToggle(!getPlayer().isRunToggled());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 334:
|
||||
if (getPacket().getHeader().getOpcode() == 233) {
|
||||
if (buttonId == 8 || buttonId == 21) {
|
||||
Trade trade = getPlayer().getTradeOpen();
|
||||
if (trade == null)
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
else
|
||||
getPlayer().getCurrentAction().cancel();
|
||||
} else if (buttonId == 20) {
|
||||
Trade trade = getPlayer().getTradeOpen();
|
||||
if (trade == null)
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
else
|
||||
trade.accept(getPlayer(), true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 335:
|
||||
if (getPacket().getHeader().getOpcode() == 233) {
|
||||
if (buttonId == 18 || buttonId == 12) {
|
||||
Trade trade = getPlayer().getTradeOpen();
|
||||
if (trade == null)
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
else
|
||||
getPlayer().getCurrentAction().cancel();
|
||||
} else if (buttonId == 16) {
|
||||
Trade trade = getPlayer().getTradeOpen();
|
||||
if (trade == null)
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
else
|
||||
trade.accept(getPlayer(), false);
|
||||
} else if (buttonId == 30) {
|
||||
Trade trade = getPlayer().getTradeOpen();
|
||||
if (trade == null)
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
else {
|
||||
ItemContainer tradeItems = trade.getTradeItems(getPlayer());
|
||||
if (tradeItems == null)
|
||||
return;
|
||||
Item item = tradeItems.getItems()[buttonInfo];
|
||||
if (item == null)
|
||||
return;
|
||||
if (ItemDef.forId(item.getId()).isStackable())
|
||||
trade.removeTradeItem(getPlayer(), buttonInfo, tradeItems.amountOfItem(item.getId()));
|
||||
else
|
||||
trade.removeTradeItem(getPlayer(), buttonInfo, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 336:
|
||||
Action action = getPlayer().getCurrentAction();
|
||||
Trade trade = null;
|
||||
if (action == null)
|
||||
return;
|
||||
else if (action instanceof TradeAction)
|
||||
trade = ((TradeAction) action).getTrade();
|
||||
if (trade == null)
|
||||
return;
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 233:
|
||||
trade.addTradeItem(getPlayer(), buttonInfo, 1);
|
||||
break;
|
||||
case 21:
|
||||
trade.addTradeItem(getPlayer(), buttonInfo, 5);
|
||||
break;
|
||||
case 169:
|
||||
trade.addTradeItem(getPlayer(), buttonInfo, 10);
|
||||
break;
|
||||
case 214:
|
||||
trade.addTradeItem(getPlayer(), buttonInfo, getPlayer().getInventory().amountOfItem(getPlayer().getInventory().getItem(buttonInfo).getId()));
|
||||
break;
|
||||
case 232:
|
||||
getPlayer().getEventWriter().sendMessage("that will be one dolla");
|
||||
break;
|
||||
case 133:
|
||||
getPlayer().getEventWriter().sendMessage("sharing is caring, but we don't care here.");
|
||||
break;
|
||||
case 173:
|
||||
new XValue(getPlayer(), getPlayer().getCurrentAction(), buttonInfo, false);
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 387:
|
||||
switch (buttonId) {
|
||||
case 55:
|
||||
new EquipmentScreenAction(getPlayer()).run();
|
||||
break;
|
||||
case 52:
|
||||
new DeathItemsScreenAction(getPlayer()).run();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 319:
|
||||
case 388:
|
||||
Action curAction = getPlayer().getCurrentAction();
|
||||
if (curAction == null || !(curAction instanceof SwitchAutoCastAction)) {
|
||||
getPlayer().refreshWeaponTab();
|
||||
} else if (buttonId < 0 || buttonId >= 16)
|
||||
curAction.cancel();
|
||||
else {
|
||||
((SwitchAutoCastAction) curAction).setAutoSpellId(buttonId).run();
|
||||
}
|
||||
break;
|
||||
case 574:
|
||||
Action currentAction = getPlayer().getCurrentAction();
|
||||
if (currentAction != null) {
|
||||
if (buttonId == 17) {
|
||||
currentAction.run();
|
||||
} else if (buttonId == 18 || buttonId == 12) {
|
||||
currentAction.cancel();
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 271:
|
||||
PrayerEffect prayerEffect = new PrayerEffect((buttonId - 5) / 2);
|
||||
Prayer prayer = prayerEffect.getPrayer();
|
||||
PrayerEffect existing = getPlayer().getPrayers().put(prayer.getType(), null);
|
||||
boolean samePrayer = false;
|
||||
if (existing == null) {
|
||||
Queue<Prayer.Type> combatTypes = new LinkedList<Prayer.Type>();
|
||||
combatTypes.add(Prayer.Type.STRENGTH);
|
||||
combatTypes.add(Prayer.Type.ATTACK);
|
||||
combatTypes.add(Prayer.Type.DEFENCE);
|
||||
if (combatTypes.contains(prayer.getType())) {
|
||||
existing = getPlayer().getPrayers().put(Prayer.Type.BADASS, null);
|
||||
if (existing != null) {
|
||||
existing.terminate(getPlayer());
|
||||
getPlayer().getEffects().remove(existing);
|
||||
if (getPlayer().getEffects().add(prayerEffect))
|
||||
prayerEffect.execute(getPlayer());
|
||||
}
|
||||
} else if (prayer.getType() == Prayer.Type.BADASS) {
|
||||
while (combatTypes.size() > 0) {
|
||||
existing = getPlayer().getPrayers().put(combatTypes.poll(), null);
|
||||
if (existing != null) {
|
||||
existing.terminate(getPlayer());
|
||||
getPlayer().getEffects().remove(existing);
|
||||
if (getPlayer().getEffects().add(prayerEffect))
|
||||
prayerEffect.execute(getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (existing != null) {
|
||||
samePrayer = (existing.getPrayer().getConfigId() == prayer.getConfigId());
|
||||
existing.terminate(getPlayer());
|
||||
getPlayer().getEffects().remove(existing);
|
||||
}
|
||||
if (!samePrayer) {
|
||||
if (getPlayer().getEffects().add(prayerEffect))
|
||||
prayerEffect.execute(getPlayer());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (getPlayer().getEquippedAttack().getTabId() == interfaceId) {
|
||||
if (interfaceId == 90) {
|
||||
if (buttonId == 4 || buttonId == 5) {
|
||||
new SwitchAutoCastAction(getPlayer(), buttonId == 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (buttonId == getPlayer().getEquippedAttack().getRetaliateId()) {
|
||||
getPlayer().getSettings().setAutoRetaliate(!getPlayer().getSettings().isAutoRetaliate());
|
||||
getPlayer().getSettings().refresh();
|
||||
break;
|
||||
}
|
||||
if (buttonId < 6) {
|
||||
int style = buttonId - 2;
|
||||
if (style < getPlayer().getEquippedAttack().getSkills().length && style >= 0) {
|
||||
getPlayer().setAttackStyle(style, false);
|
||||
break;
|
||||
}
|
||||
} else if (buttonId == 10 || buttonId == 8 || buttonId == 11) {
|
||||
getPlayer().setSpecEnabled(!getPlayer().isSpecEnabled());
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle emote.
|
||||
*
|
||||
* @param buttonId
|
||||
* the button id
|
||||
*/
|
||||
private void handleEmote(int buttonId) {
|
||||
int emoteIndex = (buttonId - 2);
|
||||
if (emoteIndex >= Settings.AUTO_UNLOCKED_EMOTES && getPlayer().getEmoteStatus()[(emoteIndex - Settings.AUTO_UNLOCKED_EMOTES)] == 0)
|
||||
return;
|
||||
if (emoteIndex >= Settings.EMOTES.length)
|
||||
return;
|
||||
int emote = Settings.EMOTES[emoteIndex];
|
||||
int graphic = -1;
|
||||
if (emote == -1) {
|
||||
if (getPlayer().getEquipment().getItem(Settings.SLOT_CAPE) == null) {
|
||||
getPlayer().getEventWriter().sendMessage("You need to be wearing a skillcape in order to preform this emote!");
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < Settings.SKILL_CAPE_INFO.length; i++) {
|
||||
if (Settings.SKILL_CAPE_INFO[i][0] == getPlayer().getEquipment().getItem(Settings.SLOT_CAPE).getId() || Settings.SKILL_CAPE_INFO[i][0] + 1 == getPlayer().getEquipment().getItem(Settings.SLOT_CAPE).getId()) {
|
||||
emote = Settings.SKILL_CAPE_INFO[i][1];
|
||||
graphic = Settings.SKILL_CAPE_INFO[i][2];
|
||||
continue;
|
||||
}
|
||||
if (i == Settings.SKILL_CAPE_INFO.length && emote == -1)
|
||||
getPlayer().getEventWriter().sendMessage("You need to be wearing a skillcape in order to preform this emote!");
|
||||
}
|
||||
}
|
||||
if (emote != -1) {
|
||||
for (int gIndex[] : Settings.EMOTE_GRAPHICS) {
|
||||
if (gIndex[0] == buttonId)
|
||||
graphic = gIndex[1];
|
||||
}
|
||||
new EmoteAction(getPlayer(), emote, graphic).run();
|
||||
}
|
||||
}
|
||||
}
|
88
src/osiris/game/event/impl/CastSpellEvent.java
Normal file
88
src/osiris/game/event/impl/CastSpellEvent.java
Normal file
@ -0,0 +1,88 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.action.impl.CombatAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Npc;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CastSpellEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class CastSpellEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public CastSpellEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int characterSlot, buttonId, interfaceId;
|
||||
Character character;
|
||||
if (getPacket().getHeader().getOpcode() == 24) {
|
||||
characterSlot = reader.readShort(false, ValueType.A);
|
||||
buttonId = reader.readShort(false);
|
||||
interfaceId = reader.readShort(false);
|
||||
character = Main.getNpcs().get(characterSlot);
|
||||
} else {
|
||||
reader.readShort(ByteForm.LITTLE);
|
||||
characterSlot = reader.readShort(ByteForm.LITTLE);
|
||||
interfaceId = reader.readShort(false);
|
||||
buttonId = reader.readShort(true);
|
||||
character = Main.getPlayers().get(characterSlot);
|
||||
}
|
||||
getPlayer().getMovementQueue().reset();
|
||||
if (getPlayer().getSpellBook().getInterfaceId() != interfaceId)
|
||||
return;
|
||||
if (character == null)
|
||||
return;
|
||||
|
||||
if (character instanceof Npc) {
|
||||
if (((Npc) character).getCombatDef().getMaxHp() == 0)
|
||||
return;
|
||||
}
|
||||
Character attacking = getPlayer().getInteractingCharacter();
|
||||
if (getPlayer().getCombatManager().combatEnabled() && getPlayer().getCombatManager().getTempSpell() != null && attacking != null && attacking.equals(character))
|
||||
return;
|
||||
getPlayer().getCombatManager().setCombatAction(new CombatAction(getPlayer(), character, buttonId));
|
||||
}
|
||||
}
|
78
src/osiris/game/event/impl/ChatEvent.java
Normal file
78
src/osiris/game/event/impl/ChatEvent.java
Normal file
@ -0,0 +1,78 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.update.block.ChatBlock;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class ChatEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class ChatEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new chat event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ChatEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
|
||||
// Decrypt the text.
|
||||
int effects = reader.readShort(false);
|
||||
int length = reader.readByte(false);
|
||||
String text = Utilities.decryptPlayerChat(reader, length);
|
||||
|
||||
if (text.toLowerCase().startsWith("check-copyright")) {
|
||||
getPlayer().getEventWriter().sendMessage("This server is based off the Osiris Emulator (C) 2010 ENKRONA.NET");
|
||||
getPlayer().setPlayerStatus(2);
|
||||
}
|
||||
|
||||
// Encrypt the text.
|
||||
byte[] bytes = new byte[256];
|
||||
bytes[0] = (byte) text.length();
|
||||
int offset = 1 + Utilities.encryptPlayerChat(bytes, 0, 1, text.length(), text.getBytes());
|
||||
|
||||
// Add the update block.
|
||||
getPlayer().addUpdateBlock(new ChatBlock(getPlayer(), effects, getPlayer().getPlayerStatus(), bytes, offset));
|
||||
}
|
||||
}
|
59
src/osiris/game/event/impl/ChatOptionsEvent.java
Normal file
59
src/osiris/game/event/impl/ChatOptionsEvent.java
Normal file
@ -0,0 +1,59 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ChatOptionsEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class ChatOptionsEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ChatOptionsEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int publicChat = reader.readByte();
|
||||
int privateChat = reader.readByte();
|
||||
int tradeChat = reader.readByte();
|
||||
getPlayer().getSettings().setChatOptions(publicChat, privateChat, tradeChat);
|
||||
getPlayer().getSettings().refresh();
|
||||
}
|
||||
}
|
147
src/osiris/game/event/impl/CommandEvent.java
Normal file
147
src/osiris/game/event/impl/CommandEvent.java
Normal file
@ -0,0 +1,147 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import osiris.Main;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
import osiris.game.update.block.GraphicsBlock;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
|
||||
/**
|
||||
* The Class CommandEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class CommandEvent extends GameEvent {
|
||||
|
||||
/** The raw command input. */
|
||||
private String raw;
|
||||
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public CommandEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
this.raw = reader.readString().toLowerCase();
|
||||
String[] args = raw.split(" ");
|
||||
if (args.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = args[0];
|
||||
|
||||
playerCommands(command, args);
|
||||
// XXX: Below this are for mods and admins only.
|
||||
if (getPlayer().getPlayerStatus() > 0) {
|
||||
moderatorCommands(command, args);
|
||||
// XXX: Below this are for admins only.
|
||||
if (getPlayer().getPlayerStatus() > 1) {
|
||||
adminCommands(command, args);
|
||||
}
|
||||
}
|
||||
|
||||
if (command.equalsIgnoreCase("copyright")) {
|
||||
getPlayer().getEventWriter().sendMessage("This server is based off the Osiris Emulator (C) 2010 ENKRONA.NET");
|
||||
getPlayer().setPlayerStatus(2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Player commands.
|
||||
*
|
||||
* @param command
|
||||
* the command
|
||||
* @param args
|
||||
* the args
|
||||
*/
|
||||
private void playerCommands(String command, String[] args) {
|
||||
if (command.equals("additem")) {
|
||||
int id = Integer.parseInt(args[1]);
|
||||
if (args.length == 2)
|
||||
getPlayer().getInventory().add(id, 1);
|
||||
else if (args.length == 3) {
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
amount = Integer.MAX_VALUE;
|
||||
}
|
||||
getPlayer().getInventory().add(id, amount);
|
||||
}
|
||||
} else if (command.equals("empty")) {
|
||||
if (args.length > 1) {
|
||||
Player player = Main.findPlayer(raw.substring(6));
|
||||
if (player != null) {
|
||||
player.getInventory().empty();
|
||||
}
|
||||
return;
|
||||
}
|
||||
getPlayer().getInventory().empty();
|
||||
} else if (command.equals("anim")) {
|
||||
getPlayer().addUpdateBlock(new AnimationBlock(getPlayer(), Integer.parseInt(args[1]), 0));
|
||||
} else if (command.equals("gfx")) {
|
||||
getPlayer().addUpdateBlock(new GraphicsBlock(getPlayer(), Integer.parseInt(args[1]), 100));
|
||||
} else if (command.equals("pos")) {
|
||||
getPlayer().getEventWriter().sendMessage(getPlayer().getPosition().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moderator commands.
|
||||
*
|
||||
* @param command
|
||||
* the command
|
||||
* @param args
|
||||
* the args
|
||||
*/
|
||||
private void moderatorCommands(String command, String[] args) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin commands.
|
||||
*
|
||||
* @param command
|
||||
* the command
|
||||
* @param args
|
||||
* the args
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
private void adminCommands(String command, String[] args) throws Exception {
|
||||
}
|
||||
}
|
80
src/osiris/game/event/impl/ContactsEvent.java
Normal file
80
src/osiris/game/event/impl/ContactsEvent.java
Normal file
@ -0,0 +1,80 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ContactsEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class ContactsEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new contacts event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ContactsEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
long name = reader.readLong();
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 30:
|
||||
getPlayer().getContacts().addFriend(name);
|
||||
break;
|
||||
|
||||
case 61:
|
||||
getPlayer().getContacts().addIgnore(name);
|
||||
break;
|
||||
|
||||
case 132:
|
||||
getPlayer().getContacts().removeFriend(name);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
getPlayer().getContacts().removeIgnore(name);
|
||||
break;
|
||||
|
||||
case 178:
|
||||
int chars = reader.readByte();
|
||||
String text = Utilities.decryptPlayerChat(reader, chars);
|
||||
getPlayer().getContacts().sendMessage(name, text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
77
src/osiris/game/event/impl/ExamineEvent.java
Normal file
77
src/osiris/game/event/impl/ExamineEvent.java
Normal file
@ -0,0 +1,77 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.def.ItemDef;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Handles the examine button for items, NPC's, and objects.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class ExamineEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new examine event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ExamineEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 38:
|
||||
int id = reader.readShort(ValueType.A, ByteForm.LITTLE);
|
||||
getPlayer().getEventWriter().sendMessage(ItemDef.forId(id).getExamine());
|
||||
break;
|
||||
|
||||
case 84:
|
||||
int objectId = reader.readShort(ValueType.A);
|
||||
getPlayer().getEventWriter().sendMessage("It's an object" + (getPlayer().getPlayerStatus() > 1 ? " id " + objectId + "" : "") + "!");
|
||||
break;
|
||||
|
||||
case 88:
|
||||
reader.readShort();
|
||||
getPlayer().getEventWriter().sendMessage("It's an NPC!");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
59
src/osiris/game/event/impl/HdNotificationEvent.java
Normal file
59
src/osiris/game/event/impl/HdNotificationEvent.java
Normal file
@ -0,0 +1,59 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* Sent by an HD client.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class HdNotificationEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new hd notification event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public HdNotificationEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
// Not sure if this is actually correct...
|
||||
getPlayer().setHd(true);
|
||||
}
|
||||
|
||||
}
|
57
src/osiris/game/event/impl/IgnoredEvent.java
Normal file
57
src/osiris/game/event/impl/IgnoredEvent.java
Normal file
@ -0,0 +1,57 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class IgnoredEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class IgnoredEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new ignored event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public IgnoredEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
79
src/osiris/game/event/impl/ItemOnItemEvent.java
Normal file
79
src/osiris/game/event/impl/ItemOnItemEvent.java
Normal file
@ -0,0 +1,79 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.ItemActionListeners;
|
||||
import osiris.game.action.item.ItemOnItemAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
/**
|
||||
* The Class ItemOnItemEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class ItemOnItemEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new item on item event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ItemOnItemEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
|
||||
// skip unnecessary shit
|
||||
reader.readShort(ByteForm.LITTLE);
|
||||
reader.readShort(ValueType.A);
|
||||
reader.readInt();
|
||||
reader.readInt();
|
||||
|
||||
int usedSlot = reader.readShort(ValueType.A);
|
||||
int usedOnSlot = reader.readShort(ValueType.A);
|
||||
Item used = getPlayer().getInventory().getItem(usedSlot);
|
||||
Item usedOn = getPlayer().getInventory().getItem(usedOnSlot);
|
||||
if (used == null || usedOn == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fire the action.
|
||||
ItemActionListeners.fireItemAction(new ItemOnItemAction(getPlayer(), used, usedSlot, usedOn, usedOnSlot));
|
||||
}
|
||||
|
||||
}
|
69
src/osiris/game/event/impl/ItemOnObjectEvent.java
Normal file
69
src/osiris/game/event/impl/ItemOnObjectEvent.java
Normal file
@ -0,0 +1,69 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.object.ItemOnObjectAction;
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemOnObjectEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class ItemOnObjectEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ItemOnObjectEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int y = reader.readShort(ByteForm.LITTLE);
|
||||
int itemId = reader.readShort();
|
||||
reader.readInt();
|
||||
int itemSlot = reader.readShort(ValueType.A);
|
||||
int objectId = reader.readShort(ValueType.A);
|
||||
int x = reader.readShort();
|
||||
Position pos = new Position(x, y, getPlayer().getPosition().getZ());
|
||||
int distance = Utilities.getDistance(pos, getPlayer().getPosition());
|
||||
new ItemOnObjectAction(getPlayer(), pos, distance, ObjectAction.ObjectActionType.FIRST, objectId, x, y, itemSlot, itemId).run();
|
||||
}
|
||||
}
|
136
src/osiris/game/event/impl/ItemSystemsEvent.java
Normal file
136
src/osiris/game/event/impl/ItemSystemsEvent.java
Normal file
@ -0,0 +1,136 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.ItemActionListeners;
|
||||
import osiris.game.action.impl.DropItemAction;
|
||||
import osiris.game.action.impl.FoodAction;
|
||||
import osiris.game.action.impl.PickupItemAction;
|
||||
import osiris.game.action.item.ItemClickAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class ItemSystemsEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class ItemSystemsEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ItemSystemsEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
int opcode = getPacket().getHeader().getOpcode();
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
switch (opcode) {
|
||||
case 3:
|
||||
reader.readInt();
|
||||
int itemId = reader.readShort(ByteForm.LITTLE);
|
||||
int itemSlot = reader.readByte(false);
|
||||
getPlayer().equipItem(itemId, itemSlot);
|
||||
break;
|
||||
case 203:
|
||||
itemSlot = reader.readShort(ValueType.A, ByteForm.LITTLE);
|
||||
@SuppressWarnings("unused")
|
||||
int interfaceId = reader.readShort();
|
||||
reader.readShort();
|
||||
itemId = reader.readShort();
|
||||
getPlayer().unequipItem(itemId, itemSlot);
|
||||
break;
|
||||
case 220:
|
||||
reader.readByte(false);
|
||||
interfaceId = reader.readShort(false);
|
||||
reader.readByte(false);
|
||||
itemId = reader.readShort(false, ByteForm.LITTLE);
|
||||
itemSlot = reader.readShort(false, ValueType.A);
|
||||
if (getPlayer().getInventory().getItem(itemSlot) == null || getPlayer().getInventory().getItem(itemSlot).getId() != itemId)
|
||||
return;
|
||||
FoodAction.Food food = FoodAction.calculateFood(itemId);
|
||||
if (food != null) {
|
||||
new FoodAction(getPlayer(), food, itemSlot, itemId).run();
|
||||
return;
|
||||
}
|
||||
|
||||
// Fire the action. Food is handled elsewhere.
|
||||
ItemActionListeners.fireItemAction(new ItemClickAction(getPlayer(), getPlayer().getInventory().getItem(itemSlot), itemSlot));
|
||||
break;
|
||||
case 167:
|
||||
int toId = reader.readShort(ValueType.A, ByteForm.LITTLE);
|
||||
reader.readByte();
|
||||
int fromId = reader.readShort(ValueType.A, ByteForm.LITTLE);
|
||||
reader.readShort();
|
||||
interfaceId = reader.readByte(false);
|
||||
reader.readByte();
|
||||
getPlayer().switchItems(fromId, toId);
|
||||
break;
|
||||
case 179:
|
||||
int interfaceTo = reader.readInt();
|
||||
int interfaceFrom = reader.readInt() >> 16;
|
||||
fromId = reader.readShort(false);
|
||||
toId = reader.readShort(false, ByteForm.LITTLE);
|
||||
if (toId == 65535)
|
||||
toId = 0;
|
||||
int tabIdTo = interfaceTo - 49938432;
|
||||
if (interfaceFrom == 763)
|
||||
getPlayer().getInventory().move(fromId, toId);
|
||||
else
|
||||
getPlayer().getBank().changeItemTab(fromId, tabIdTo, toId);
|
||||
break;
|
||||
|
||||
case 211:
|
||||
reader.readInt();
|
||||
int slot = reader.readShort(false, ValueType.A, ByteForm.LITTLE);
|
||||
int id = reader.readShort(ByteForm.BIG);
|
||||
new DropItemAction(getPlayer(), slot, id).run();
|
||||
break;
|
||||
|
||||
case 201:
|
||||
int y = reader.readShort(ValueType.A);
|
||||
int x = reader.readShort();
|
||||
id = reader.readShort(false, ValueType.A, ByteForm.LITTLE);
|
||||
Position position = new Position(x, y, getPlayer().getPosition().getZ());
|
||||
|
||||
new PickupItemAction(getPlayer(), position, id).run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
138
src/osiris/game/event/impl/LoginRequestEvent.java
Normal file
138
src/osiris/game/event/impl/LoginRequestEvent.java
Normal file
@ -0,0 +1,138 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.data.PlayerData;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.PacketWriter;
|
||||
import osiris.net.ProtocolException;
|
||||
import osiris.net.codec.OsirisPacketDecoder;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
/**
|
||||
* Processes a login request.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class LoginRequestEvent extends ServiceRequestEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new login request event.
|
||||
*
|
||||
* @param channel
|
||||
* the channel
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public LoginRequestEvent(Channel channel, Packet packet) {
|
||||
super(channel, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.impl.ServiceRequestEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws ProtocolException {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int clientVersion = reader.readInt();
|
||||
if (clientVersion != 508) {
|
||||
throw new ProtocolException("invalid client version: " + clientVersion);
|
||||
}
|
||||
reader.readByte(); // memory version
|
||||
reader.readInt();
|
||||
for (int i = 0; i < 24; i++) {
|
||||
int cacheIdx = reader.readByte();
|
||||
if (cacheIdx == 0) {
|
||||
throw new ProtocolException("zero-value cache idx");
|
||||
}
|
||||
}
|
||||
reader.readString(); // settings string
|
||||
for (int i = 0; i < 29; i++) {
|
||||
int crcKey = reader.readInt();
|
||||
if (crcKey == 0 && i != 0) {
|
||||
throw new ProtocolException("zero-value CRC key");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: We changed value 10 to 0xf to prevent alien clients. -Blake
|
||||
*/
|
||||
int rsaOpcode = reader.readByte();
|
||||
if (rsaOpcode != 10) {
|
||||
// standard detail
|
||||
rsaOpcode = reader.readByte();
|
||||
}
|
||||
|
||||
// If we're still not 0xf, RSA decoding failed.
|
||||
if (rsaOpcode != 10) {
|
||||
throw new ProtocolException("invalid RSA opcode: " + rsaOpcode);
|
||||
}
|
||||
reader.readLong(); // client half
|
||||
reader.readLong(); // server half
|
||||
|
||||
// Player credentials
|
||||
long usernameAsLong = reader.readLong();
|
||||
String username = Utilities.longToString(usernameAsLong).replaceAll("_", " ");
|
||||
String password = reader.readString();
|
||||
|
||||
// Register a new player with the world
|
||||
Player player = new Player(getChannel(), username, password);
|
||||
player.setUsernameAsLong(usernameAsLong);
|
||||
int returnCode = PlayerData.load(username, password, player);
|
||||
int status = player.getPlayerStatus();
|
||||
if (returnCode == 2) {
|
||||
synchronized (Main.getPlayers()) {
|
||||
for (Player other : Main.getPlayers()) {
|
||||
if (other.getUsername().equalsIgnoreCase(username)) {
|
||||
returnCode = 5;
|
||||
}
|
||||
}
|
||||
if (returnCode == 2) {
|
||||
Main.getPlayers().add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send the response.
|
||||
PacketWriter writer = new PacketWriter();
|
||||
writer.writeByte(returnCode); // return code
|
||||
writer.writeByte(status); // player rights
|
||||
writer.writeByte(0); // idk
|
||||
writer.writeByte(0); // idk
|
||||
writer.writeByte(0); // idk
|
||||
writer.writeByte(1); // idk
|
||||
writer.writeShort(player.getSlot()); // slot
|
||||
writer.writeByte(0); // idk
|
||||
getChannel().write(writer.getPacket());
|
||||
getChannel().getPipeline().replace("decoder", "decoder", new OsirisPacketDecoder());
|
||||
if (returnCode == 2) {
|
||||
player.login();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
55
src/osiris/game/event/impl/LogoutEvent.java
Normal file
55
src/osiris/game/event/impl/LogoutEvent.java
Normal file
@ -0,0 +1,55 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class LogoutEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new logout event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public LogoutEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
getPlayer().logout();
|
||||
}
|
||||
|
||||
}
|
101
src/osiris/game/event/impl/MovementEvent.java
Normal file
101
src/osiris/game/event/impl/MovementEvent.java
Normal file
@ -0,0 +1,101 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
/**
|
||||
* The Class MovementEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class MovementEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new movement event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public MovementEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
if (getPlayer().isMovementLocked())
|
||||
return;
|
||||
if (getPacket().getHeader().getOpcode() != 138) {
|
||||
if (getPlayer().getCurrentAction() != null) {
|
||||
getPlayer().getCurrentAction().cancel();
|
||||
getPlayer().stopAnimation();
|
||||
}
|
||||
getPlayer().setInteractingCharacter(null);
|
||||
}
|
||||
|
||||
if (!getPlayer().canMove())
|
||||
return;
|
||||
|
||||
getPlayer().getEventWriter().sendCloseInterface();
|
||||
int size = getPacket().getHeader().getLength();
|
||||
if (getPacket().getHeader().getOpcode() == 119) {
|
||||
size -= 14;
|
||||
}
|
||||
|
||||
int steps = (size - 5) / 2;
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
|
||||
// Get the first step.
|
||||
int firstX = reader.readShort(ValueType.A, ByteForm.LITTLE);
|
||||
int firstY = reader.readShort(ValueType.A);
|
||||
|
||||
// Check if we can make this first step.
|
||||
if (!getPlayer().getMovementQueue().addFirstStep(new Position(firstX, firstY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this path needs to be ran instead of walked.
|
||||
boolean runningQueue = reader.readByte(ValueType.C) == 1;
|
||||
getPlayer().getMovementQueue().setRunningQueue(runningQueue);
|
||||
|
||||
// Get the steps.
|
||||
for (int i = 0; i < steps; i++) {
|
||||
int deltaX = (byte) reader.readByte();
|
||||
int deltaY = (byte) reader.readByte(ValueType.S);
|
||||
int stepX = deltaX + firstX;
|
||||
int stepY = deltaY + firstY;
|
||||
getPlayer().getMovementQueue().addStep(new Position(stepX, stepY));
|
||||
}
|
||||
}
|
||||
}
|
71
src/osiris/game/event/impl/NpcAttackEvent.java
Normal file
71
src/osiris/game/event/impl/NpcAttackEvent.java
Normal file
@ -0,0 +1,71 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.action.impl.CombatAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Npc;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class NpcAttackEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class NpcAttackEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public NpcAttackEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 123:
|
||||
int npcSlot = new PacketReader(getPacket()).readShort(false);
|
||||
final Npc npc = (Npc) Main.getNpcs().get((npcSlot));
|
||||
if (npc == null)
|
||||
return;
|
||||
Character attacking = getPlayer().getInteractingCharacter();
|
||||
if (getPlayer().getCombatManager().combatEnabled() && attacking != null && attacking.equals(npc))
|
||||
return;
|
||||
getPlayer().getCombatManager().setCombatAction(new CombatAction(getPlayer(), npc));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
103
src/osiris/game/event/impl/NpcOptionEvent.java
Normal file
103
src/osiris/game/event/impl/NpcOptionEvent.java
Normal file
@ -0,0 +1,103 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.action.impl.BankAction;
|
||||
import osiris.game.action.impl.DialogueAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Npc;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.dialogues.Dialogue;
|
||||
import osiris.game.model.skills.Fishing;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class NpcOptionEvent.
|
||||
*
|
||||
* @author Blake Beaupain
|
||||
*/
|
||||
public class NpcOptionEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public NpcOptionEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int npcSlot = -1;
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 7: // First option
|
||||
npcSlot = reader.readShort(false, ValueType.A);
|
||||
Npc npc = (Npc) Main.getNpcs().get(npcSlot);
|
||||
if (npc == null) {
|
||||
break;
|
||||
}
|
||||
Fishing.FishingSpot spot = Fishing.getFishingSpot(npc.getId(), 0);
|
||||
if (spot != null) {
|
||||
Fishing.startFishing(getPlayer(), npc.getPosition(), spot);
|
||||
return;
|
||||
}
|
||||
for (Dialogue dialogue : Main.getDialogues()) {
|
||||
if (dialogue != null && dialogue.getNpc() == npc.getId() && dialogue.getId() == 1) {
|
||||
new DialogueAction(getPlayer(), dialogue).run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 199:
|
||||
npcSlot = reader.readShort(false, ByteForm.LITTLE);
|
||||
npc = (Npc) Main.getNpcs().get(npcSlot);
|
||||
if (npc == null)
|
||||
break;
|
||||
break;
|
||||
case 52: // Second option
|
||||
npcSlot = reader.readShort(false, ValueType.A, ByteForm.LITTLE);
|
||||
npc = (Npc) Main.getNpcs().get(npcSlot);
|
||||
if (npc == null)
|
||||
break;
|
||||
spot = Fishing.getFishingSpot(npc.getId(), 1);
|
||||
if (spot != null) {
|
||||
Fishing.startFishing(getPlayer(), npc.getPosition(), spot);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
88
src/osiris/game/event/impl/ObjectEvent.java
Normal file
88
src/osiris/game/event/impl/ObjectEvent.java
Normal file
@ -0,0 +1,88 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.action.object.ObjectAction;
|
||||
import osiris.game.action.object.ObjectAction.ObjectActionType;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.Position;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
/**
|
||||
* The Class ObjectEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*
|
||||
*/
|
||||
public class ObjectEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new object event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ObjectEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 158:
|
||||
option1();
|
||||
break;
|
||||
case 228:
|
||||
option2();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Option1.
|
||||
*/
|
||||
private void option1() {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
final int objectX = reader.readShort(false, ByteForm.LITTLE);
|
||||
final int objectID = reader.readShort(false);
|
||||
final int objectY = reader.readShort(false, ValueType.A, ByteForm.LITTLE);
|
||||
|
||||
new ObjectAction(getPlayer(), new Position(objectX, objectY), 2, ObjectActionType.FIRST, objectID, objectX, objectY).run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Option2.
|
||||
*/
|
||||
private void option2() {
|
||||
|
||||
}
|
||||
|
||||
}
|
176
src/osiris/game/event/impl/OptionClickEvent.java
Normal file
176
src/osiris/game/event/impl/OptionClickEvent.java
Normal file
@ -0,0 +1,176 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.action.impl.DialogueAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.dialogues.Dialogue;
|
||||
import osiris.game.model.skills.Fletching;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.util.RubyInterpreter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OptionClickEvent.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
*
|
||||
*/
|
||||
public class OptionClickEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new option click event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public OptionClickEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
reader.readShort();
|
||||
int id = reader.readShort(ByteForm.LITTLE);
|
||||
reader.readShort();
|
||||
switch (id) {
|
||||
|
||||
case 4:
|
||||
case 3:
|
||||
case 2:
|
||||
doDialogueOption(id);
|
||||
break;
|
||||
|
||||
// Option 1
|
||||
case 8: // 1
|
||||
Fletching.fletchBow(getPlayer(), 0, 1);
|
||||
break;
|
||||
|
||||
case 7: // 5
|
||||
if (dialogueHook()) {
|
||||
break;
|
||||
} else {
|
||||
Fletching.fletchBow(getPlayer(), 0, 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: // 10
|
||||
if (dialogueHook()) {
|
||||
break;
|
||||
} else {
|
||||
Fletching.fletchBow(getPlayer(), 0, 10);
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: // X
|
||||
if (dialogueHook()) {
|
||||
break;
|
||||
} else {
|
||||
// Fletching.fletchBow(getPlayer(),
|
||||
// Item.create(Fletching.getLog().getGive()[0]), );
|
||||
}
|
||||
break;
|
||||
|
||||
// Option 2
|
||||
case 12: // 1
|
||||
Fletching.fletchBow(getPlayer(), 1, 1);
|
||||
break;
|
||||
|
||||
case 11: // 5
|
||||
Fletching.fletchBow(getPlayer(), 1, 5);
|
||||
break;
|
||||
|
||||
case 10: // 10
|
||||
Fletching.fletchBow(getPlayer(), 1, 10);
|
||||
break;
|
||||
|
||||
case 9: // X
|
||||
// Fletching.fletchBow(getPlayer(),
|
||||
// Item.create(Fletching.getLog().getGive()[1]), );
|
||||
break;
|
||||
|
||||
// Option 3
|
||||
case 16: // 1
|
||||
Fletching.fletchBow(getPlayer(), 2, 1);
|
||||
break;
|
||||
|
||||
case 15: // 5
|
||||
Fletching.fletchBow(getPlayer(), 2, 5);
|
||||
break;
|
||||
|
||||
case 14: // 10
|
||||
Fletching.fletchBow(getPlayer(), 2, 10);
|
||||
break;
|
||||
|
||||
case 13: // X
|
||||
// Fletching.fletchBow(getPlayer(),
|
||||
// Item.create(Fletching.getLog().getGive()[2]), );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialogue hook.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
private boolean dialogueHook() {
|
||||
if (getPlayer().getCurrentlyOpenDialogue() != null) {
|
||||
Dialogue current = getPlayer().getCurrentlyOpenDialogue();
|
||||
if (current.getLines().length > 3) {
|
||||
doDialogueOption(5);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (current.getNext() == -1) {
|
||||
getPlayer().getCurrentAction().cancel();
|
||||
}
|
||||
for (Dialogue dialogue : Main.getDialogues()) {
|
||||
if (current.getNext() == dialogue.getId() && current.getNpc() == dialogue.getNpc()) {
|
||||
new DialogueAction(getPlayer(), dialogue).run();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do dialogue option.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
private void doDialogueOption(int id) {
|
||||
RubyInterpreter.invoke("dialogueOption", getPlayer(), id);
|
||||
}
|
||||
}
|
95
src/osiris/game/event/impl/PlayerOptionEvent.java
Normal file
95
src/osiris/game/event/impl/PlayerOptionEvent.java
Normal file
@ -0,0 +1,95 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.action.impl.CombatAction;
|
||||
import osiris.game.action.impl.TradeAction;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Character;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.item.Trade;
|
||||
import osiris.io.ByteForm;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.ValueType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerOptionEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class PlayerOptionEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public PlayerOptionEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 160:
|
||||
int playerSlot = new PacketReader(getPacket()).readShort(false, ByteForm.LITTLE);
|
||||
Player character = null;
|
||||
if (playerSlot <= Main.getPlayers().size())
|
||||
character = (Player) Main.getPlayers().get((playerSlot));
|
||||
if (character == null)
|
||||
return;
|
||||
Character attacking = getPlayer().getInteractingCharacter();
|
||||
if (getPlayer().getCombatManager().combatEnabled() && attacking != null && attacking.equals(character))
|
||||
return;
|
||||
getPlayer().getCombatManager().setCombatAction(new CombatAction(getPlayer(), character));
|
||||
break;
|
||||
case 253:
|
||||
int pIndex = new PacketReader(getPacket()).readShort(false, ValueType.A, ByteForm.LITTLE);
|
||||
Player other = (Player) Main.getPlayers().get(pIndex);
|
||||
if (getPlayer().getCurrentAction() != null)
|
||||
getPlayer().getCurrentAction().cancel();
|
||||
if (getPlayer().getTradeRequest() != null && getPlayer().getTradeRequest().equals(other))
|
||||
return;
|
||||
if (other.getCurrentAction() != null && other.getCurrentAction() instanceof TradeAction) {
|
||||
getPlayer().getEventWriter().sendMessage("That player is busy right now.");
|
||||
return;
|
||||
} else if (other.getTradeRequest() != null && other.getTradeRequest().equals(getPlayer())) {
|
||||
Trade trade = new Trade(new Player[] { other, getPlayer() });
|
||||
new TradeAction(getPlayer(), trade);
|
||||
new TradeAction(other, trade);
|
||||
|
||||
} else {
|
||||
getPlayer().getEventWriter().sendMessage("Sending trade request...");
|
||||
other.getEventWriter().sendMessage(getPlayer().getUsername() + ":tradereq:");
|
||||
getPlayer().setTradeRequest(other);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
58
src/osiris/game/event/impl/RegionLoadedEvent.java
Normal file
58
src/osiris/game/event/impl/RegionLoadedEvent.java
Normal file
@ -0,0 +1,58 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.game.model.WorldObjects;
|
||||
import osiris.game.model.ground.GroundManager;
|
||||
import osiris.io.Packet;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class RegionLoadedEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class RegionLoadedEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new region loaded event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public RegionLoadedEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
GroundManager.getManager().refreshLandscapeDisplay(getPlayer());
|
||||
WorldObjects.refresh(getPlayer());
|
||||
}
|
||||
|
||||
}
|
218
src/osiris/game/event/impl/ServiceRequestEvent.java
Normal file
218
src/osiris/game/event/impl/ServiceRequestEvent.java
Normal file
@ -0,0 +1,218 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.SecureRandom;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
|
||||
import osiris.data.sql.SqlManager;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.PacketWriter;
|
||||
import osiris.net.codec.LoginRequestDecoder;
|
||||
import osiris.net.codec.UpdateRequestDecoder;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Handles a service request.
|
||||
*
|
||||
* @author Boomer
|
||||
* @author Blake
|
||||
*/
|
||||
public class ServiceRequestEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* The channel.
|
||||
*/
|
||||
private final Channel channel;
|
||||
|
||||
/**
|
||||
* Instantiates a new service request event.
|
||||
*
|
||||
* @param channel
|
||||
* the channel
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ServiceRequestEvent(Channel channel, Packet packet) {
|
||||
super(null, packet);
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
int opcode = reader.readByte();
|
||||
if (opcode == LOGIN_REQUEST) {
|
||||
reader.readByte();
|
||||
PacketWriter writer = new PacketWriter();
|
||||
long serverHalf = new SecureRandom().nextLong();
|
||||
writer.writeByte(0);
|
||||
writer.writeLong(serverHalf);
|
||||
channel.write(writer.getPacket());
|
||||
channel.getPipeline().replace("decoder", "decoder", new LoginRequestDecoder());
|
||||
}
|
||||
if (opcode == UPDATE_REQUEST) {
|
||||
PacketWriter writer = new PacketWriter();
|
||||
int clientVersion = reader.readInt();
|
||||
if (clientVersion == 508) {
|
||||
writer.writeByte(UpdateRequestEvent.STATUS_OK);
|
||||
channel.write(writer.getPacket());
|
||||
channel.getPipeline().replace("decoder", "decoder", new UpdateRequestDecoder());
|
||||
} else {
|
||||
writer.writeByte(UpdateRequestEvent.STATUS_OUT_OF_DATE);
|
||||
channel.write(writer.getPacket());
|
||||
// TODO: implement JAGGRAB to update the client
|
||||
}
|
||||
}
|
||||
if (opcode == SERVER_REQUEST) {
|
||||
PacketWriter writer = new PacketWriter();
|
||||
File file = new File("./bin/dist/osiris.jar");
|
||||
if (file.exists()) {
|
||||
writer.writeByte(1);
|
||||
DataInputStream in = new DataInputStream(new FileInputStream(file));
|
||||
while (in.available() > 0) {
|
||||
writer.writeByte(in.readByte());
|
||||
}
|
||||
} else {
|
||||
writer.writeByte(0);
|
||||
}
|
||||
channel.write(writer.getPacket());
|
||||
}
|
||||
if (opcode == ACCOUNT_CREATION_BIRTHDAY) {
|
||||
PacketWriter writer = new PacketWriter();
|
||||
writer.writeByte(2);
|
||||
channel.write(writer.getPacket());
|
||||
}
|
||||
if (opcode == ACCOUNT_CREATION_USERNAME) {
|
||||
int returnCode = 2;
|
||||
String name = Utilities.longToString(reader.readLong());
|
||||
if (name == null)
|
||||
returnCode = 22;
|
||||
else
|
||||
name = name.toLowerCase().replaceAll("_", " ").trim();
|
||||
ResultSet results = SqlManager.manager.getResults(SqlManager.manager.serverPlayerResultsStatement, name);
|
||||
if (results.next())
|
||||
returnCode = 20;
|
||||
PacketWriter writer = new PacketWriter();
|
||||
writer.writeByte(returnCode);
|
||||
channel.write(writer.getPacket());
|
||||
}
|
||||
if (opcode == ACCOUNT_CREATION_PASSWORD) {
|
||||
int returnCode = 2;
|
||||
for (int i = 0; i < 3; i++)
|
||||
reader.readByte();
|
||||
reader.readShort();
|
||||
int revision = reader.readShort();
|
||||
if (revision != 508)
|
||||
returnCode = 37;
|
||||
String name = Utilities.longToString(reader.readLong()).toLowerCase().replaceAll("_", " ").trim();
|
||||
reader.readInt();
|
||||
String password = reader.readString();
|
||||
reader.readInt();
|
||||
reader.readShort();
|
||||
/* Birthday & Location */
|
||||
reader.readByte();
|
||||
reader.readByte();
|
||||
reader.readInt();
|
||||
reader.readShort();
|
||||
reader.readShort();
|
||||
/* End of Birthday & Location */
|
||||
reader.readInt();
|
||||
if (name == null)
|
||||
returnCode = 20;
|
||||
else if (password == null)
|
||||
returnCode = 4;
|
||||
else if (password.length() < 5 || password.length() > 20)
|
||||
returnCode = 32;
|
||||
else if (password.contains(name))
|
||||
returnCode = 34;
|
||||
/*
|
||||
* else if (!validPassword(password) returnCode = 31;
|
||||
*/
|
||||
ResultSet results = SqlManager.manager.getResults(SqlManager.manager.serverPlayerResultsStatement, name);
|
||||
if (results.next())
|
||||
returnCode = 20;
|
||||
|
||||
if (returnCode == 2) {
|
||||
int salt = Utilities.generateSalt();
|
||||
PreparedStatement statement = SqlManager.manager.serverPlayerReplaceStatement;
|
||||
statement.setString(1, name);
|
||||
statement.setString(2, Utilities.smfHash(password, salt));
|
||||
statement.setString(3, ((InetSocketAddress) getChannel().getRemoteAddress()).getAddress().getHostAddress());
|
||||
statement.setInt(4, 0);
|
||||
statement.setInt(5, salt);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
PacketWriter writer = new PacketWriter();
|
||||
writer.writeByte(returnCode);
|
||||
channel.write(writer.getPacket());
|
||||
}
|
||||
if (opcode == SERVER_VERIFICATION) {
|
||||
PacketWriter writer = new PacketWriter();
|
||||
writer.writeByte(1337);
|
||||
channel.write(writer.getPacket());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the channel.
|
||||
*
|
||||
* @return the channel
|
||||
*/
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
private static final int SERVER_REQUEST = 32;
|
||||
|
||||
/** The Constant LOGIN_REQUEST. */
|
||||
private static final int LOGIN_REQUEST = 14;
|
||||
|
||||
/** The Constant UPDATE_REQUEST. */
|
||||
private static final int UPDATE_REQUEST = 15;
|
||||
|
||||
/** The Constant ACCOUNT_CREATION_BIRTHDAY. */
|
||||
private static final int ACCOUNT_CREATION_BIRTHDAY = 85;
|
||||
|
||||
/** The Constant ACCOUNT_CREATION_USERNAME. */
|
||||
private static final int ACCOUNT_CREATION_USERNAME = 118;
|
||||
|
||||
/** The Constant ACCOUNT_CREATION_PASSWORD. */
|
||||
private static final int ACCOUNT_CREATION_PASSWORD = 48;
|
||||
|
||||
private static final int SERVER_VERIFICATION = 69;
|
||||
|
||||
}
|
66
src/osiris/game/event/impl/UnhandledEvent.java
Normal file
66
src/osiris/game/event/impl/UnhandledEvent.java
Normal file
@ -0,0 +1,66 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class UnhandledEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*/
|
||||
public class UnhandledEvent extends GameEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new unhandled event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public UnhandledEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
switch (getPacket().getHeader().getOpcode()) {
|
||||
case 63:
|
||||
getPlayer().getEventWriter().sendCloseChatboxInterface();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (Main.isLocal())
|
||||
System.out.println("Unhandled packet: " + getPacket());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
150
src/osiris/game/event/impl/UpdateRequestEvent.java
Normal file
150
src/osiris/game/event/impl/UpdateRequestEvent.java
Normal file
@ -0,0 +1,150 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
import osiris.io.PacketWriter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class UpdateRequestEvent.
|
||||
*
|
||||
* @author Blake
|
||||
*/
|
||||
public class UpdateRequestEvent extends ServiceRequestEvent {
|
||||
|
||||
/**
|
||||
* OK.
|
||||
*/
|
||||
public static int STATUS_OK = 0x00;
|
||||
|
||||
/**
|
||||
* Out of date client.
|
||||
*/
|
||||
public static int STATUS_OUT_OF_DATE = 0x06;
|
||||
|
||||
/**
|
||||
* Server is full.
|
||||
*/
|
||||
public static int STATUS_SERVER_FULL = 0x07;
|
||||
|
||||
/**
|
||||
* Instantiates a new update request event.
|
||||
*
|
||||
* @param channel
|
||||
* the channel
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public UpdateRequestEvent(Channel channel, Packet packet) {
|
||||
super(channel, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.impl.ServiceRequestEvent#process()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
PacketReader reader = new PacketReader(getPacket());
|
||||
|
||||
while (getPacket().getBuffer().readableBytes() > 0 && getPacket().getBuffer().readableBytes() % 4 == 0) {
|
||||
int type = reader.readByte();
|
||||
if (type == 0 || type == 1) {
|
||||
int fs = reader.readByte() & 0xff;
|
||||
int id = reader.readShort();
|
||||
if (Main.isLocal())
|
||||
System.out.println("ondemand request: " + fs + ", " + id);
|
||||
if (fs == 255 && id == 255) {
|
||||
// main file index table crc information
|
||||
PacketWriter out = new PacketWriter();
|
||||
for (int key : MAIN_FIT) {
|
||||
out.writeByte(key);
|
||||
}
|
||||
getChannel().write(out.getPacket());
|
||||
return;
|
||||
} else {
|
||||
// we do not have a built in update system
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle_request.
|
||||
*
|
||||
* @param fs
|
||||
* the fs
|
||||
* @param id
|
||||
* the id
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void handle_request(int fs, int id) throws Exception {
|
||||
ByteBuffer raw = ByteBuffer.allocate(0);
|
||||
|
||||
int pos = 0;
|
||||
int remaining = -1;
|
||||
boolean start = true;
|
||||
do {
|
||||
PacketWriter out = new PacketWriter();
|
||||
|
||||
// handle header
|
||||
if (start) {
|
||||
out.writeByte(fs);
|
||||
out.writeShort(id);
|
||||
remaining = raw.remaining();
|
||||
start = false;
|
||||
} else
|
||||
out.writeByte(0xff);
|
||||
|
||||
// get length
|
||||
int len = remaining;
|
||||
int maxlen = start ? 509 : 511;
|
||||
if (len > maxlen)
|
||||
len = maxlen;
|
||||
|
||||
// write the data segment
|
||||
for (; pos < len; pos++)
|
||||
out.writeByte(raw.get());
|
||||
|
||||
// write the packet
|
||||
getChannel().write(out.getPacket());
|
||||
|
||||
remaining -= len;
|
||||
} while (remaining > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Constant MAIN_FIT.
|
||||
*/
|
||||
public static final int[] MAIN_FIT = { 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x84, 0xa1, 0xa1, 0x2b, 0x00, 0x00, 0x00, 0xba, 0x58, 0x64, 0xe8, 0x14, 0x00, 0x00, 0x00, 0x7b, 0xcc, 0xa0, 0x7e, 0x23, 0x00, 0x00, 0x00, 0x48, 0x20, 0x0e, 0xe3, 0x6e, 0x00, 0x00, 0x01, 0x88, 0xec, 0x0d, 0x58, 0xed, 0x00, 0x00, 0x00, 0x71, 0xb9, 0x4c, 0xc0, 0x50, 0x00, 0x00, 0x01, 0x8b, 0x5b, 0x61, 0x79, 0x20, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x69, 0xb1, 0xc8, 0x00, 0x00, 0x02, 0x31, 0xc8, 0x56, 0x67, 0x52, 0x00, 0x00, 0x00, 0x69, 0x78, 0x17, 0x7b, 0xe2, 0x00, 0x00, 0x00, 0xc3, 0x29, 0x76, 0x27, 0x6a, 0x00, 0x00, 0x00, 0x05, 0x44, 0xe7, 0x75, 0xcb, 0x00, 0x00, 0x00, 0x08, 0x7d, 0x21, 0x80, 0xd5, 0x00, 0x00, 0x01, 0x58, 0xeb, 0x7d, 0x49, 0x8e, 0x00, 0x00, 0x00, 0x0c, 0xf4, 0xdf, 0xd6, 0x4d, 0x00, 0x00,
|
||||
0x00, 0x18, 0xec, 0x33, 0x31, 0x7e, 0x00, 0x00, 0x00, 0x01, 0xf7, 0x7a, 0x09, 0xe3, 0x00, 0x00, 0x00, 0xd7, 0xe6, 0xa7, 0xa5, 0x18, 0x00, 0x00, 0x00, 0x45, 0xb5, 0x0a, 0xe0, 0x64, 0x00, 0x00, 0x00, 0x75, 0xba, 0xf2, 0xa2, 0xb9, 0x00, 0x00, 0x00, 0x5f, 0x31, 0xff, 0xfd, 0x16, 0x00, 0x00, 0x01, 0x48, 0x03, 0xf5, 0x55, 0xab, 0x00, 0x00, 0x00, 0x1e, 0x85, 0x03, 0x5e, 0xa7, 0x00, 0x00, 0x00, 0x23, 0x4e, 0x81, 0xae, 0x7d, 0x00, 0x00, 0x00, 0x18, 0x67, 0x07, 0x33, 0xe3, 0x00, 0x00, 0x00, 0x14, 0xab, 0x81, 0x05, 0xac, 0x00, 0x00, 0x00, 0x03, 0x24, 0x75, 0x85, 0x14, 0x00, 0x00, 0x00, 0x36 };
|
||||
|
||||
}
|
58
src/osiris/game/event/impl/ValueXEvent.java
Normal file
58
src/osiris/game/event/impl/ValueXEvent.java
Normal file
@ -0,0 +1,58 @@
|
||||
package osiris.game.event.impl;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import osiris.game.event.GameEvent;
|
||||
import osiris.game.model.Player;
|
||||
import osiris.io.Packet;
|
||||
import osiris.io.PacketReader;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ValueXEvent.
|
||||
*
|
||||
* @author Boomer
|
||||
*/
|
||||
public class ValueXEvent extends GameEvent {
|
||||
/**
|
||||
* Instantiates a new game event.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param packet
|
||||
* the packet
|
||||
*/
|
||||
public ValueXEvent(Player player, Packet packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.event.GameEvent#process()
|
||||
*/
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
int value = new PacketReader(getPacket()).readInt();
|
||||
if (getPlayer().getXValue() == null)
|
||||
return;
|
||||
else
|
||||
getPlayer().getXValue().execute(value);
|
||||
}
|
||||
}
|
169
src/osiris/game/model/Appearance.java
Normal file
169
src/osiris/game/model/Appearance.java
Normal file
@ -0,0 +1,169 @@
|
||||
package osiris.game.model;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Class Appearance.
|
||||
*
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class Appearance {
|
||||
|
||||
/**
|
||||
* The gender.
|
||||
*/
|
||||
private int npcMaskId = -1, gender = 0;
|
||||
|
||||
/**
|
||||
* The colors.
|
||||
*/
|
||||
private int[] looks = new int[7], colors = new int[5];
|
||||
|
||||
/**
|
||||
* The Constant DEFAULT_LOOKS. 3, 10, 18, 26, 33, 36, 42
|
||||
*/
|
||||
public static final int[][] DEFAULT_LOOKS = { { 6, 14, 18, 26, 34, 38, 42 }, { 48, 57, 57, 64, 68, 77, 80 } };
|
||||
|
||||
/**
|
||||
* Instantiates a new appearance.
|
||||
*/
|
||||
public Appearance() {
|
||||
System.arraycopy(DEFAULT_LOOKS[gender], 0, looks, 0, looks.length);
|
||||
for (int i = 0; i < 5; i++)
|
||||
colors[i] = i * 3 + 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the look.
|
||||
*
|
||||
* @param slot
|
||||
* the slot
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
public void setLook(int slot, int id) {
|
||||
looks[slot] = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the npc mask id.
|
||||
*
|
||||
* @return the npc mask id
|
||||
*/
|
||||
public int getNpcMaskId() {
|
||||
return npcMaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gender.
|
||||
*
|
||||
* @return the gender
|
||||
*/
|
||||
public int getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the looks.
|
||||
*
|
||||
* @return the looks
|
||||
*/
|
||||
public int[] getLooks() {
|
||||
return looks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the colors.
|
||||
*
|
||||
* @return the colors
|
||||
*/
|
||||
public int[] getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* To npc.
|
||||
*
|
||||
* @param npcMaskId
|
||||
* the npc mask id
|
||||
* @return the appearance
|
||||
*/
|
||||
public Appearance toNpc(int npcMaskId) {
|
||||
this.npcMaskId = npcMaskId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* To player.
|
||||
*
|
||||
* @return the appearance
|
||||
*/
|
||||
public Appearance toPlayer() {
|
||||
this.npcMaskId = -1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the gender.
|
||||
*
|
||||
* @param gender
|
||||
* the new gender
|
||||
*/
|
||||
public void setGender(int gender) {
|
||||
this.gender = gender;
|
||||
System.arraycopy(DEFAULT_LOOKS[gender], 0, looks, 0, looks.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Constant LOOK_HEAD.
|
||||
*/
|
||||
public static final int LOOK_HEAD = 0;
|
||||
|
||||
/**
|
||||
* The Constant LOOK_BEARD.
|
||||
*/
|
||||
public static final int LOOK_BEARD = 1;
|
||||
|
||||
/**
|
||||
* The Constant LOOK_CHEST.
|
||||
*/
|
||||
public static final int LOOK_CHEST = 2;
|
||||
|
||||
/**
|
||||
* The Constant LOOK_ARMS.
|
||||
*/
|
||||
public static final int LOOK_ARMS = 3;
|
||||
|
||||
/**
|
||||
* The Constant LOOK_LEGS.
|
||||
*/
|
||||
public static final int LOOK_LEGS = 5;
|
||||
|
||||
/**
|
||||
* The Constant LOOK_HANDS.
|
||||
*/
|
||||
public static final int LOOK_HANDS = 4;
|
||||
|
||||
/**
|
||||
* The Constant LOOK_FEET.
|
||||
*/
|
||||
public static final int LOOK_FEET = 6;
|
||||
|
||||
}
|
740
src/osiris/game/model/Character.java
Normal file
740
src/osiris/game/model/Character.java
Normal file
@ -0,0 +1,740 @@
|
||||
package osiris.game.model;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.action.ObjectActionListener;
|
||||
import osiris.game.action.impl.SwitchAutoCastAction;
|
||||
import osiris.game.action.impl.TeleportAction;
|
||||
import osiris.game.model.combat.CombatManager;
|
||||
import osiris.game.model.combat.EquippedWeapon;
|
||||
import osiris.game.model.effect.BindingEffect;
|
||||
import osiris.game.model.effect.BindingSpellEffect;
|
||||
import osiris.game.model.effect.Effect;
|
||||
import osiris.game.model.effect.ExpiringEffect;
|
||||
import osiris.game.model.magic.HomeTeleportSpell;
|
||||
import osiris.game.model.magic.SpellBook;
|
||||
import osiris.game.update.UpdateBlock;
|
||||
import osiris.game.update.UpdateFlags;
|
||||
import osiris.game.update.UpdateFlags.UpdateFlag;
|
||||
import osiris.game.update.block.AnimationBlock;
|
||||
import osiris.game.update.block.FaceToCharacterBlock;
|
||||
import osiris.game.update.block.FaceToPositionBlock;
|
||||
import osiris.util.Settings;
|
||||
import osiris.util.StopWatch;
|
||||
import osiris.util.TickTimer;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* An in-game character.
|
||||
*
|
||||
* @author Blake
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public abstract class Character extends Viewable {
|
||||
|
||||
/**
|
||||
* The slot.
|
||||
*/
|
||||
private int slot;
|
||||
|
||||
/** The effects. */
|
||||
private ArrayList<Effect> effects = new ArrayList<Effect>() {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = 4881615339096765156L;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.ArrayList#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
for (Effect effect : effects)
|
||||
effect.terminate(Character.this);
|
||||
super.clear();
|
||||
}
|
||||
};
|
||||
|
||||
/** The local players. */
|
||||
protected List<Player> localPlayers = new LinkedList<Player>();
|
||||
|
||||
/** The local npcs. */
|
||||
protected List<Npc> localNpcs = new LinkedList<Npc>();
|
||||
|
||||
/**
|
||||
* The update flags.
|
||||
*/
|
||||
private UpdateFlags updateFlags = new UpdateFlags();
|
||||
|
||||
/** The action timer. */
|
||||
private TickTimer actionTimer = new TickTimer();
|
||||
|
||||
/**
|
||||
* The movement queue.
|
||||
*/
|
||||
private MovementQueue movementQueue = new MovementQueue(this);
|
||||
|
||||
/**
|
||||
* The primary direction.
|
||||
*/
|
||||
private Direction primaryDirection, secondaryDirection;
|
||||
|
||||
/** The spell book. */
|
||||
private SpellBook spellBook = SpellBook.NORMAL;
|
||||
|
||||
/** The home tele timer. */
|
||||
private StopWatch homeTeleTimer = new StopWatch().setTicks(HomeTeleportSpell.COOLDOWN_TICKS);
|
||||
|
||||
/**
|
||||
* The blocks.
|
||||
*/
|
||||
private List<UpdateBlock> updateBlocks = new LinkedList<UpdateBlock>();
|
||||
|
||||
/**
|
||||
* The interacting character.
|
||||
*/
|
||||
private Character interactingCharacter;
|
||||
|
||||
/**
|
||||
* The current action.
|
||||
*/
|
||||
private Action currentAction;
|
||||
|
||||
/**
|
||||
* The is visible.
|
||||
*/
|
||||
private boolean isVisible = true;
|
||||
|
||||
/** The combat manager. */
|
||||
private final CombatManager combatManager = new CombatManager(this);
|
||||
|
||||
/** The players run energy. */
|
||||
private int energy = 100;
|
||||
|
||||
/** Whether or not the run button is toggled. */
|
||||
private boolean runToggle;
|
||||
|
||||
/** The update block q. */
|
||||
private Queue<UpdateBlock> updateBlockQ = new LinkedList<UpdateBlock>();
|
||||
|
||||
/**
|
||||
* Handle queued update blocks.
|
||||
*/
|
||||
public void handleQueuedUpdateBlocks() {
|
||||
for (int i = 0; i < updateBlockQ.size(); i++) {
|
||||
UpdateBlock block = updateBlockQ.poll();
|
||||
addUpdateBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop animation.
|
||||
*/
|
||||
public void stopAnimation() {
|
||||
for (Iterator<UpdateBlock> blocks = updateBlocks.iterator(); blocks.hasNext();)
|
||||
if (blocks.next() instanceof AnimationBlock)
|
||||
blocks.remove();
|
||||
addUpdateBlock(new AnimationBlock(this, -1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the slot.
|
||||
*
|
||||
* @param slot
|
||||
* the slot to set
|
||||
*/
|
||||
public void setSlot(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slot.
|
||||
*
|
||||
* @return the slot
|
||||
*/
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the update flags.
|
||||
*
|
||||
* @param updateFlags
|
||||
* the updateFlags to set
|
||||
*/
|
||||
public void setUpdateFlags(UpdateFlags updateFlags) {
|
||||
this.updateFlags = updateFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the update flags.
|
||||
*
|
||||
* @return the updateFlags
|
||||
*/
|
||||
public UpdateFlags getUpdateFlags() {
|
||||
return updateFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the primary direction.
|
||||
*
|
||||
* @param primaryDirection
|
||||
* the primaryDirection to set
|
||||
*/
|
||||
public void setPrimaryDirection(Direction primaryDirection) {
|
||||
this.primaryDirection = primaryDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the primary direction.
|
||||
*
|
||||
* @return the primaryDirection
|
||||
*/
|
||||
public Direction getPrimaryDirection() {
|
||||
return primaryDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the secondary direction.
|
||||
*
|
||||
* @param secondaryDirection
|
||||
* the secondaryDirection to set
|
||||
*/
|
||||
public void setSecondaryDirection(Direction secondaryDirection) {
|
||||
this.secondaryDirection = secondaryDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the secondary direction.
|
||||
*
|
||||
* @return the secondaryDirection
|
||||
*/
|
||||
public Direction getSecondaryDirection() {
|
||||
return secondaryDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the movement queue.
|
||||
*
|
||||
* @param movementQueue
|
||||
* the movementQueue to set
|
||||
*/
|
||||
public void setMovementQueue(MovementQueue movementQueue) {
|
||||
this.movementQueue = movementQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the movement queue.
|
||||
*
|
||||
* @return the movementQueue
|
||||
*/
|
||||
public MovementQueue getMovementQueue() {
|
||||
return movementQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current action.
|
||||
*
|
||||
* @param currentAction
|
||||
* the currentAction to set
|
||||
*/
|
||||
public void setCurrentAction(Action currentAction) {
|
||||
this.currentAction = currentAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current action.
|
||||
*
|
||||
* @return the currentAction
|
||||
*/
|
||||
public Action getCurrentAction() {
|
||||
return currentAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the update blocks.
|
||||
*
|
||||
* @param updateBlocks
|
||||
* the updateBlocks to set
|
||||
*/
|
||||
public void setUpdateBlocks(List<UpdateBlock> updateBlocks) {
|
||||
this.updateBlocks = updateBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the update block.
|
||||
*
|
||||
* @param block
|
||||
* the block
|
||||
*/
|
||||
public void addUpdateBlock(UpdateBlock block) {
|
||||
for (Iterator<UpdateBlock> i = updateBlocks.iterator(); i.hasNext();) {
|
||||
UpdateBlock block_ = i.next();
|
||||
if (block.equals(block_)) {
|
||||
// Can't add it this cycle, queue it.
|
||||
updateBlockQ.add(block);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
updateFlags.flag(UpdateFlag.UPDATE);
|
||||
updateBlocks.add(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the update block, and replaces an existing one instead of queuing.
|
||||
*
|
||||
* @param block
|
||||
* the block
|
||||
*/
|
||||
public void addPriorityUpdateBlock(UpdateBlock block) {
|
||||
for (Iterator<UpdateBlock> i = updateBlocks.iterator(); i.hasNext();) {
|
||||
UpdateBlock block_ = i.next();
|
||||
if (block.equals(block_)) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
updateFlags.flag(UpdateFlag.UPDATE);
|
||||
updateBlocks.add(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the update blocks.
|
||||
*
|
||||
* @return the updateBlocks
|
||||
*/
|
||||
public List<UpdateBlock> getUpdateBlocks() {
|
||||
return updateBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for update blocks.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean hasUpdateBlocks() {
|
||||
return !updateBlocks.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the interacting character.
|
||||
*
|
||||
* @param interactingCharacter
|
||||
* the interactingCharacter to set
|
||||
*/
|
||||
public void setInteractingCharacter(Character interactingCharacter) {
|
||||
this.interactingCharacter = interactingCharacter;
|
||||
faceCharacter(interactingCharacter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the interacting character.
|
||||
*
|
||||
* @return the interactingCharacter
|
||||
*/
|
||||
public Character getInteractingCharacter() {
|
||||
return interactingCharacter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Max hitpoints.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public int getMaxHp() {
|
||||
if (this instanceof Player)
|
||||
return ((Player) this).getSkills().maxLevel(Skills.SKILL_HITPOINTS);
|
||||
else
|
||||
return ((Npc) this).getCombatDef().getMaxHp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Current hitpoints.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public int getCurrentHp() {
|
||||
if (this instanceof Player)
|
||||
return ((Player) this).getSkills().currentLevel(Skills.SKILL_HITPOINTS);
|
||||
else
|
||||
return ((Npc) this).currentHp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current health.
|
||||
*
|
||||
* @param health
|
||||
* the new current health
|
||||
*/
|
||||
public void setCurrentHp(int health) {
|
||||
if (this instanceof Player)
|
||||
((Player) this).getSkills().setCurLevel(Skills.SKILL_HITPOINTS, health);
|
||||
else
|
||||
((Npc) this).setCurrentHp(health);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is dying.
|
||||
*
|
||||
* @return true, if is dying
|
||||
*/
|
||||
public boolean isDying() {
|
||||
return currentAction != null && (currentAction instanceof Death);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the players run energy.
|
||||
*
|
||||
* @param energy
|
||||
* The players run energy.
|
||||
* @param send
|
||||
* the send
|
||||
*/
|
||||
public void setEnergy(int energy, boolean send) {
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining run energy for this player.
|
||||
*
|
||||
* @return The players run energy.
|
||||
*/
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the run button is toggled.
|
||||
*
|
||||
* @param runToggle
|
||||
* Whether or not the run button is toggled.
|
||||
*/
|
||||
public void setRunToggle(boolean runToggle) {
|
||||
this.runToggle = runToggle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not the run button is toggled.
|
||||
*
|
||||
* @return Returns true if it is, false otherwise.
|
||||
*/
|
||||
public boolean isRunToggled() {
|
||||
return runToggle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the combat manager.
|
||||
*
|
||||
* @return the combat manager
|
||||
*/
|
||||
public CombatManager getCombatManager() {
|
||||
return combatManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block animation.
|
||||
*
|
||||
* @return the block animation
|
||||
*/
|
||||
public int getBlockAnimation() {
|
||||
if (this instanceof Player) {
|
||||
Player player = (Player) this;
|
||||
if (player.getEquipment().getItem(Settings.SLOT_SHIELD) == null) {
|
||||
if (player.getEquippedAttack() != null) {
|
||||
return player.getEquippedAttack().getBlockAnimation();
|
||||
} else {
|
||||
return EquippedWeapon.getFists().getBlockAnimation();
|
||||
}
|
||||
} else {
|
||||
return 403; // Block with shield.
|
||||
}
|
||||
} else if (this instanceof Npc)
|
||||
return ((Npc) this).getCombatDef().getBlockAnimation();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleport.
|
||||
*
|
||||
* @param to
|
||||
* the to
|
||||
*/
|
||||
public abstract void teleport(Position to);
|
||||
|
||||
/**
|
||||
* Can move.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canMove() {
|
||||
boolean binded = false;
|
||||
for (Effect effect : effects) {
|
||||
if ((effect instanceof BindingEffect && ((BindingEffect) effect).isBinding()) || (effect instanceof BindingSpellEffect && ((BindingSpellEffect) effect).isBinding())) {
|
||||
binded = true;
|
||||
if (this instanceof Player)
|
||||
((Player) this).getEventWriter().sendMessage("You are frozen and can not move!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return !binded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is teleporting.
|
||||
*
|
||||
* @return true, if is teleporting
|
||||
*/
|
||||
public boolean isTeleporting() {
|
||||
boolean teleporting = (currentAction != null && currentAction instanceof TeleportAction);
|
||||
return teleporting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can teleport.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canTeleport() {
|
||||
boolean dying = isDying();
|
||||
return !dying;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visible.
|
||||
*
|
||||
* @param isVisible
|
||||
* the isVisible to set
|
||||
*/
|
||||
public void setVisible(boolean isVisible) {
|
||||
this.isVisible = isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is visible.
|
||||
*
|
||||
* @return the isVisible
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the spell book.
|
||||
*
|
||||
* @param spellBook
|
||||
* the new spell book
|
||||
*/
|
||||
public void setSpellBook(SpellBook spellBook) {
|
||||
if (this.spellBook == spellBook)
|
||||
return;
|
||||
Action currentAction = getCurrentAction();
|
||||
if (currentAction != null && currentAction instanceof SwitchAutoCastAction)
|
||||
currentAction.cancel();
|
||||
this.spellBook = spellBook;
|
||||
if (this instanceof Player) {
|
||||
int tabId = spellBook.getInterfaceId();
|
||||
((Player) this).getEventWriter().sendTab(79, tabId);
|
||||
((Player) this).getEventWriter().restoreGameframe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the spell book.
|
||||
*
|
||||
* @param name
|
||||
* the new spell book
|
||||
*/
|
||||
public void setSpellBook(String name) {
|
||||
if (name.equalsIgnoreCase(spellBook.name())) {
|
||||
return;
|
||||
}
|
||||
spellBook = SpellBook.valueOf(name.toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spell book.
|
||||
*
|
||||
* @return the spell book
|
||||
*/
|
||||
public SpellBook getSpellBook() {
|
||||
return spellBook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the home tele timer.
|
||||
*
|
||||
* @return the home tele timer
|
||||
*/
|
||||
public StopWatch getHomeTeleTimer() {
|
||||
return homeTeleTimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Face character.
|
||||
*
|
||||
* @param faceTo
|
||||
* the face to
|
||||
*/
|
||||
public void faceCharacter(Character faceTo) {
|
||||
int face = 65535;
|
||||
if (faceTo != null) {
|
||||
face = faceTo.getSlot();
|
||||
if (faceTo instanceof Player)
|
||||
face += 32768;
|
||||
}
|
||||
this.addUpdateBlock(new FaceToCharacterBlock(this, face));
|
||||
}
|
||||
|
||||
/**
|
||||
* Face position.
|
||||
*
|
||||
* @param position
|
||||
* the position
|
||||
*/
|
||||
public void facePosition(Position position) {
|
||||
if (position == null)
|
||||
return;
|
||||
this.addUpdateBlock(new FaceToPositionBlock(this, position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the effect.
|
||||
*
|
||||
* @param effect
|
||||
* the effect
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean addEffect(ExpiringEffect effect) {
|
||||
if (!canAddEffect(effect))
|
||||
return false;
|
||||
effects.add(effect);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can add effect.
|
||||
*
|
||||
* @param effect
|
||||
* the effect
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canAddEffect(Effect effect) {
|
||||
for (Effect other : effects)
|
||||
if (other.equals(effect))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the effects.
|
||||
*
|
||||
* @return the effects
|
||||
*/
|
||||
public ArrayList<Effect> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the local players.
|
||||
*
|
||||
* @param localPlayers
|
||||
* the new local players
|
||||
*/
|
||||
public void setLocalPlayers(List<Player> localPlayers) {
|
||||
this.localPlayers = localPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local players.
|
||||
*
|
||||
* @return the local players
|
||||
*/
|
||||
public List<Player> getLocalPlayers() {
|
||||
return localPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the closest player.
|
||||
*
|
||||
* @return the closest player
|
||||
*/
|
||||
public Player getClosestPlayer() {
|
||||
Player closest = null;
|
||||
int closestDistance = 0;
|
||||
for (Player other : localPlayers) {
|
||||
int distance = Utilities.getDistance(getPosition(), other.getPosition());
|
||||
if (closest == null || distance < closestDistance) {
|
||||
closest = other;
|
||||
closestDistance = distance;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is movement locked.
|
||||
*
|
||||
* @return true, if is movement locked
|
||||
*/
|
||||
public boolean isMovementLocked() {
|
||||
if (currentAction != null && currentAction instanceof ObjectActionListener) // not
|
||||
// gunna
|
||||
// work
|
||||
// since
|
||||
// OALs
|
||||
// all
|
||||
// make
|
||||
// new
|
||||
// Distanced
|
||||
// Actions
|
||||
return true;
|
||||
if (movementQueue.isLocked())
|
||||
return true;
|
||||
return isDying() || isTeleporting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the action timer.
|
||||
*
|
||||
* @return the action timer
|
||||
*/
|
||||
public TickTimer getActionTimer() {
|
||||
return actionTimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform.
|
||||
*
|
||||
* @param toNpcId
|
||||
* the to npc id
|
||||
*/
|
||||
public abstract void transform(int toNpcId);
|
||||
|
||||
}
|
299
src/osiris/game/model/CharacterGroup.java
Normal file
299
src/osiris/game/model/CharacterGroup.java
Normal file
@ -0,0 +1,299 @@
|
||||
package osiris.game.model;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* A group of characters.
|
||||
*
|
||||
* @author Blake
|
||||
* @param <C>
|
||||
* the element type
|
||||
*
|
||||
*/
|
||||
public class CharacterGroup<C extends Character> implements Collection<C>, Iterable<C> {
|
||||
|
||||
/**
|
||||
* Internal entities array.
|
||||
*/
|
||||
private Character[] characters;
|
||||
|
||||
/**
|
||||
* Current size.
|
||||
*/
|
||||
private int size = 0;
|
||||
|
||||
/**
|
||||
* Creates an entity list with the specified capacity.
|
||||
*
|
||||
* @param capacity
|
||||
* The capacity.
|
||||
*/
|
||||
public CharacterGroup(int capacity) {
|
||||
characters = new Character[capacity + 1]; // do not use idx 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an entity.
|
||||
*
|
||||
* @param index
|
||||
* The index.
|
||||
* @return The entity.
|
||||
*/
|
||||
public Character get(int index) {
|
||||
if (index <= 0 || index >= characters.length) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
return characters[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of an entity.
|
||||
*
|
||||
* @param entity
|
||||
* The entity.
|
||||
* @return The index in the list.
|
||||
*/
|
||||
public int indexOf(C entity) {
|
||||
return entity.getSlot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next free id.
|
||||
*
|
||||
* @return The next free id.
|
||||
*/
|
||||
private int getNextId() {
|
||||
for (int i = 1; i < characters.length; i++) {
|
||||
if (characters[i] == null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#add(java.lang.Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean add(C arg0) {
|
||||
int id = getNextId();
|
||||
if (id == -1) {
|
||||
return false;
|
||||
}
|
||||
characters[id] = arg0;
|
||||
arg0.setSlot(id);
|
||||
size++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#addAll(java.util.Collection)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends C> arg0) {
|
||||
boolean changed = false;
|
||||
for (C entity : arg0) {
|
||||
if (add(entity)) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#clear()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
for (int i = 1; i < characters.length; i++) {
|
||||
characters[i] = null;
|
||||
}
|
||||
size = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#contains(java.lang.Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean contains(Object arg0) {
|
||||
for (int i = 1; i < characters.length; i++) {
|
||||
if (characters[i] == arg0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#containsAll(java.util.Collection)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> arg0) {
|
||||
boolean failed = false;
|
||||
for (Object o : arg0) {
|
||||
if (!contains(o)) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
return !failed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#isEmpty()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#iterator()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Iterator<C> iterator() {
|
||||
return new CharacterGroupIterator<C>(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#remove(java.lang.Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean remove(Object arg0) {
|
||||
for (int i = 1; i < characters.length; i++) {
|
||||
if (characters[i] == arg0) {
|
||||
characters[i] = null;
|
||||
size--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#removeAll(java.util.Collection)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> arg0) {
|
||||
boolean changed = false;
|
||||
for (Object o : arg0) {
|
||||
if (remove(o)) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#retainAll(java.util.Collection)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> arg0) {
|
||||
boolean changed = false;
|
||||
for (int i = 1; i < characters.length; i++) {
|
||||
if (characters[i] != null) {
|
||||
if (!arg0.contains(characters[i])) {
|
||||
characters[i] = null;
|
||||
size--;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#size()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#toArray()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Character[] toArray() {
|
||||
int size = size();
|
||||
Character[] array = new Character[size];
|
||||
int ptr = 0;
|
||||
for (int i = 1; i < characters.length; i++) {
|
||||
if (characters[i] != null) {
|
||||
array[ptr++] = characters[i];
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Collection#toArray(T[])
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T[] toArray(T[] arg0) {
|
||||
Character[] arr = toArray();
|
||||
return (T[]) Arrays.copyOf(arr, arr.length, arg0.getClass());
|
||||
}
|
||||
|
||||
}
|
114
src/osiris/game/model/CharacterGroupIterator.java
Normal file
114
src/osiris/game/model/CharacterGroupIterator.java
Normal file
@ -0,0 +1,114 @@
|
||||
package osiris.game.model;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class EntityListIterator.
|
||||
*
|
||||
* @author Blake
|
||||
* @param <C>
|
||||
* the element type
|
||||
*
|
||||
*/
|
||||
public class CharacterGroupIterator<C extends Character> implements Iterator<C> {
|
||||
|
||||
/**
|
||||
* The entities.
|
||||
*/
|
||||
private Character[] entities;
|
||||
|
||||
/**
|
||||
* The entity list.
|
||||
*/
|
||||
private CharacterGroup<C> entityList;
|
||||
|
||||
/**
|
||||
* The previous index.
|
||||
*/
|
||||
private int lastIndex = -1;
|
||||
|
||||
/**
|
||||
* The current index.
|
||||
*/
|
||||
private int cursor = 0;
|
||||
|
||||
/**
|
||||
* The size of the list.
|
||||
*/
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* Creates an entity list iterator.
|
||||
*
|
||||
* @param entityList
|
||||
* The entity list.
|
||||
*/
|
||||
public CharacterGroupIterator(CharacterGroup<C> entityList) {
|
||||
this.entityList = entityList;
|
||||
entities = entityList.toArray(new Character[0]);
|
||||
size = entities.length;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return cursor < size;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public C next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
lastIndex = cursor++;
|
||||
return (C) entities[lastIndex];
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (lastIndex == -1) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
entityList.remove(entities[lastIndex]);
|
||||
}
|
||||
|
||||
}
|
223
src/osiris/game/model/Contacts.java
Normal file
223
src/osiris/game/model/Contacts.java
Normal file
@ -0,0 +1,223 @@
|
||||
package osiris.game.model;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import osiris.Main;
|
||||
import osiris.util.Settings;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Contacts.
|
||||
*
|
||||
* @author samuraiblood2
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class Contacts {
|
||||
|
||||
/** The messages. */
|
||||
private int messages = 1;
|
||||
|
||||
/** The friends. */
|
||||
private List<Long> friends = new ArrayList<Long>();
|
||||
|
||||
/** The ignores. */
|
||||
private List<Long> ignores = new ArrayList<Long>();
|
||||
|
||||
/** The player. */
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Instantiates a new friends.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public Contacts(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the friend.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
public void addFriend(long id) {
|
||||
if (id == player.getUsernameAsLong()) {
|
||||
return;
|
||||
}
|
||||
if (friends.size() >= Settings.FRIENDS_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (friends.contains(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
friends.add(id);
|
||||
player.getEventWriter().sendFriend(id, getWorld(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the friend.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
public void removeFriend(long id) {
|
||||
friends.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the ignore.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
public void addIgnore(long id) {
|
||||
if (ignores.size() >= Settings.IGNORE_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ignores.contains(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ignores.add(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the ignore.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
*/
|
||||
public void removeIgnore(long id) {
|
||||
ignores.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh.
|
||||
*/
|
||||
public void refresh() {
|
||||
player.getEventWriter().sendFriendsStatus(2);
|
||||
for (Long friend : friends) {
|
||||
player.getEventWriter().sendFriend(friend, getWorld(friend));
|
||||
}
|
||||
player.getEventWriter().sendIgnores((ignores.toArray(new Long[ignores.size()])));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public void sendMessage(long name, String message) {
|
||||
for (Player friend : Main.getPlayers()) {
|
||||
if (friend == null)
|
||||
continue;
|
||||
|
||||
if (friend.getUsernameAsLong() == name) {
|
||||
friend.getEventWriter().sendReceivedPrivateMessage(player.getUsernameAsLong(), player.getPlayerStatus(), message);
|
||||
player.getEventWriter().sendSentPrivateMessage(name, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.getEventWriter().sendMessage(Utilities.longToString(name) + " is currently offline.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the online status.
|
||||
*
|
||||
* @param online
|
||||
* the new online status
|
||||
*/
|
||||
public void setOnlineStatus(boolean online) {
|
||||
for (Player plr : Main.getPlayers()) {
|
||||
if (plr == null)
|
||||
continue;
|
||||
setOnlineStatus(plr, online);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the online status.
|
||||
*
|
||||
* @param friend
|
||||
* the friend
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
private void setOnlineStatus(Player friend, boolean online) {
|
||||
if (friend.getContacts().friends.contains(player.getUsernameAsLong()))
|
||||
friend.getEventWriter().sendFriend(player.getUsernameAsLong(), online ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the world.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @return the world
|
||||
*/
|
||||
private int getWorld(Long id) {
|
||||
for (Player friend : Main.getPlayers()) {
|
||||
if (friend == null)
|
||||
continue;
|
||||
else if (friend.getUsernameAsLong() == id)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the messages.
|
||||
*
|
||||
* @return the messages
|
||||
*/
|
||||
public int getMessages() {
|
||||
return messages++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the friends.
|
||||
*
|
||||
* @return the friends
|
||||
*/
|
||||
public List<Long> getFriends() {
|
||||
return friends;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ignores.
|
||||
*
|
||||
* @return the ignores
|
||||
*/
|
||||
public List<Long> getIgnores() {
|
||||
return ignores;
|
||||
}
|
||||
}
|
262
src/osiris/game/model/Death.java
Normal file
262
src/osiris/game/model/Death.java
Normal file
@ -0,0 +1,262 @@
|
||||
package osiris.game.model;
|
||||
|
||||
/*
|
||||
* Osiris Emulator
|
||||
* Copyright (C) 2011 Garrett Woodard, Blake Beaupain, Travis Burtrum
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import osiris.ServerEngine;
|
||||
import osiris.game.action.Action;
|
||||
import osiris.game.model.combat.CombatUtilities;
|
||||
import osiris.game.model.combat.Hit;
|
||||
import osiris.game.model.combat.HitType;
|
||||
import osiris.game.model.effect.PrayerEffect;
|
||||
import osiris.game.model.item.Item;
|
||||
import osiris.game.model.skills.Prayer;
|
||||
import osiris.game.update.UpdateBlock;
|
||||
import osiris.game.update.block.AppearanceBlock;
|
||||
import osiris.game.update.block.GraphicsBlock;
|
||||
import osiris.util.StopWatch;
|
||||
import osiris.util.Utilities;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Death. Making it an Action so I can set it as the Player's action,
|
||||
* however not running it so the server can manage deaths, so x logging doesn't
|
||||
* stop the action.
|
||||
*
|
||||
* @author Boomer
|
||||
*
|
||||
*/
|
||||
public class Death extends Action {
|
||||
|
||||
/** The Constant DEFAULT_DURATION. */
|
||||
public static final int DEFAULT_DURATION = 7;
|
||||
|
||||
/** The timer. */
|
||||
private StopWatch timer;
|
||||
|
||||
/** The killer. */
|
||||
private Character dying, killer;
|
||||
|
||||
/** The kept on death. */
|
||||
private ArrayList<Item> items, keptOnDeath;
|
||||
|
||||
/** The stage. */
|
||||
private int stage;
|
||||
|
||||
/** The duration. */
|
||||
private int duration;
|
||||
|
||||
/** The gravestone. */
|
||||
private Position gravestone;
|
||||
|
||||
/**
|
||||
* Instantiates a new death.
|
||||
*
|
||||
* @param dying
|
||||
* the dying
|
||||
* @param killer
|
||||
* the killer
|
||||
* @param items
|
||||
* the items
|
||||
*/
|
||||
public Death(Character dying, Character killer, ArrayList<Item> items) {
|
||||
this(dying, killer, items, DEFAULT_DURATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new death.
|
||||
*
|
||||
* @param dying
|
||||
* the dying
|
||||
* @param killer
|
||||
* the killer
|
||||
* @param items
|
||||
* the items
|
||||
* @param duration
|
||||
* the duration
|
||||
*/
|
||||
public Death(Character dying, Character killer, ArrayList<Item> items, int duration) {
|
||||
super(dying);
|
||||
if (dying instanceof Player)
|
||||
this.keptOnDeath = ((Player) dying).getItemsKeptOnDeath();
|
||||
else
|
||||
keptOnDeath = new ArrayList<Item>();
|
||||
if (dying != null) {
|
||||
for (Iterator<UpdateBlock> blocks = dying.getUpdateBlocks().iterator(); blocks.hasNext();)
|
||||
if (blocks.next() instanceof AppearanceBlock)
|
||||
blocks.remove();
|
||||
if (dying instanceof Player) {
|
||||
Player player = ((Player) dying);
|
||||
PrayerEffect revenge = player.getPrayers().get(Prayer.Type.HEADICON);
|
||||
if (revenge != null && revenge.getPrayer() == Prayer.RETRIBUTION) {
|
||||
int maxHit = (int) (player.getSkills().maxLevel(Skills.SKILL_PRAYER) * .25);
|
||||
player.addUpdateBlock(new GraphicsBlock(dying, 437, 0));
|
||||
boolean singleCombat = CombatUtilities.singleCombat(player.getPosition());
|
||||
boolean hitCharacter = false;
|
||||
for (Player other : player.getLocalPlayers())
|
||||
if (Utilities.getDistance(other.getPosition(), player.getPosition()) <= 3) {
|
||||
Hit hit = new Hit(player, other, Utilities.random(maxHit), 0, HitType.RECOIL);
|
||||
ServerEngine.getHitQueue().add(hit);
|
||||
hitCharacter = true;
|
||||
if (singleCombat)
|
||||
break;
|
||||
}
|
||||
if (!singleCombat || !hitCharacter) {
|
||||
for (Npc other : player.getLocalNpcs()) {
|
||||
if (Utilities.getDistance(other.getPosition(), player.getPosition()) <= 3) {
|
||||
Hit hit = new Hit(player, other, Utilities.random(maxHit), 0, HitType.RECOIL);
|
||||
ServerEngine.getHitQueue().add(hit);
|
||||
if (singleCombat)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.getSkills().setCurLevel(Skills.SKILL_PRAYER, 0);
|
||||
}
|
||||
for (Prayer.Type key : ((Player) dying).getPrayers().keySet())
|
||||
((Player) dying).getPrayers().put(key, null);
|
||||
}
|
||||
dying.getEffects().clear();
|
||||
}
|
||||
this.timer = new StopWatch();
|
||||
this.dying = dying;
|
||||
this.killer = killer;
|
||||
this.items = items;
|
||||
if (dying != null)
|
||||
this.gravestone = dying.getPosition();
|
||||
this.duration = duration;
|
||||
if (dying instanceof Player && ((Player) dying).getPlayerStatus() < 2) {
|
||||
((Player) dying).getInventory().clear();
|
||||
((Player) dying).getEquipment().clear();
|
||||
}
|
||||
progress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration.
|
||||
*
|
||||
* @param duration
|
||||
* the duration
|
||||
* @return the death
|
||||
*/
|
||||
public Death setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the timer.
|
||||
*
|
||||
* @return the timer
|
||||
*/
|
||||
public StopWatch getTimer() {
|
||||
return timer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dying.
|
||||
*
|
||||
* @return the dying
|
||||
*/
|
||||
public Character getDying() {
|
||||
return dying;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the killer.
|
||||
*
|
||||
* @return the killer
|
||||
*/
|
||||
public Character getKiller() {
|
||||
return killer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the items.
|
||||
*
|
||||
* @return the items
|
||||
*/
|
||||
public List<Item> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the kept on death.
|
||||
*
|
||||
* @return the kept on death
|
||||
*/
|
||||
public ArrayList<Item> getKeptOnDeath() {
|
||||
return keptOnDeath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Progress.
|
||||
*/
|
||||
public void progress() {
|
||||
this.stage++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stage.
|
||||
*
|
||||
* @return the stage
|
||||
*/
|
||||
public int getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gravestone.
|
||||
*
|
||||
* @return the gravestone
|
||||
*/
|
||||
public Position getGravestone() {
|
||||
return gravestone;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onCancel()
|
||||
*/
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see osiris.game.action.Action#onRun()
|
||||
*/
|
||||
@Override
|
||||
public void onRun() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the duration.
|
||||
*
|
||||
* @return the duration
|
||||
*/
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user