diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae9ce91
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,35 @@
+sm_*
+.*/
+scripting_ext/
+!scripting/include/guesswho/*
+!scripting/include/feedthetrolls
+!scripting/include/hideandseek
+!scripting/include/guessswho/*
+!scripting/hideandseek.sp
+!scripting/guessswho.sp
+!scripting/sm_namespamblock.sp
+!plugins/sm_namespamblock.smx
+.push.settings.jsonc*
+template.config.js
+scripting/sm_give.sp
+scripting/include/steamtools.inc
+scripting/L4D2Testing.sp
+plugins/L4D2Testing.smx
+scripting/cancer.sp
+plugins/sm_give.smx
+plugins/l4d2_stats_recorder.smx
+scripting/l4d2_stats_recorder.sp
+scripting/include/smlib.inc
+scripting/l4d2_custom.sp
+plugins/l4d2_custom.smx
+plugins/disable_cameras.smx
+plugins/l4d_esfp.smx
+plugins/customstatus.smx
+scripting/l4d_esfp.sp
+scripting/customstatus.sp
+plugins/ssh.smx
+scripting/include/ssh.inc
+scripting/ssh.sp
+scripting/l4d2_witch_force_attack_cmd.sp
+l4d2_stats_plugin/
+data
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f288702
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is 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. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ 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.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ 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 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. Use with the GNU Affero General Public License.
+
+ 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 Affero 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 special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 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 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 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.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ 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 GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9f2fb35
--- /dev/null
+++ b/README.md
@@ -0,0 +1,458 @@
+# sourcemod-plugins
+This is a collection of sourcemod plugins, most are used on my servers. The majority of the plugins are created by me, but some are modifications of other plugins.
+Some of the plugins / changes are very specific, but may be useful to someone.
+
+Not always the latest versions. If you have any interest with a plugin, I can make sure to upload the latest.
+
+Useful things:
+1. Netprop viewer https://jackz.me/netprops/l4d2
+
+## Plugin List
+
+### Created by Me
+* #### CSGO
+ * [csgo-knifehp](#csgo-knifehp) - First plugin I've made
+ * [CSGOTroll](#csgotroll) - Abandoned friend trolling plugin
+* #### L4D2
+ * [l4d2-manual-director](#l4d2-manual-director) - Spawn specials on demand via director or at your cursor
+ * [l4d2-info-cmd](#l4d2-info-cmd) - Prints a full state of all survivors, useful for external information
+ * [AutoWarpBot](#autowarpbot) - Abandoned
+ * [L4D2FFKickProtection](#l4d2ffkickprotection) - Prevents players being voted off from friendly firing and prevents admins from being kicked
+ * [l4d2_avoid_minigun](#l4d2_avoid_minigun) - Makes bots avoid being infront of any in-use miniguns. Useful for spawned miniguns
+ * [l4d2_ai_minigun](#l4d2_ai_minigun) - Based off [Silver's Survivor Bot Holdout plugin](https://forums.alliedmods.net/showthread.php?p=1741099), allows you to spawn survivor bots but with no limit.
+ * [L4D2Tools](#l4d2tools) - A collection of utilities, mostly just used with [l4d_survivor_identity_fix](#l4d_survivor_identity_fix) and the /model command
+ * [l4d2_swarm](#l4d2_swarm) - Uses vscript RushVictim to make all zombies target a player, like a more subtle vomitplayer
+ * [l4d2_feedthetrolls](#l4d2_feedthetrolls) - Full collection of tools to troll your friends or troll the trolls
+ * [l4d2_autobotcrown](#l4d2_autobotcrown) - Bots will auto crown
+ * [l4d2_extraplayeritems](#l4d2_extraplayeritems) - Includes tons of utilities for 5+ games, such as 5+ player hud, extra kit / item spawning, and more
+ * [l4d2_population_control](#l4d2_population_control) - Allows you to custom the type of zombies that spawn (% of clowns, mud men, etc..)
+ * [globalbans](#globalbans) - Bans synced via mysql, way lighter than the sourcebans cesspool.
+ * [l4d2_rollback](#l4d2_rollback) - Abandoned and broken, but makes periodic backup of all player's items
+ * [l4d2_autorestart](#l4d2_autorestart) - Restarts server if it's been on for a certain uptime or when empty with just bots.
+ * [l4d2_TKStopper](#l4d2_tkstopper) - All the teamkiller and shitty-aim player punishments. Auto increasing reverse ff and teamkill detection
+ * [l4d2_crescendo_control](#l4d2_crescendo_control) - Prevents players from running far ahead and starting events, and logs button presses
+ * [l4d2_vocalize_control](#l4d2_vocalize_control) - Allows you to locally mute someone from vocalizing
+ * [l4d2_guesswho](#l4d2_guesswho) - Garry's Mod's Guess Who in l4d2, inspired by hide and seek
+ * [l4d2_hideandseek](#l4d2_hideandseek) - An enhancement to the base hide and seek mutation
+ * [l4d2_hats](#l4d2_hats) - Entity Hats & Entity editing
+ * [l4d2_prophunt](#l4d2_prophunt) - Garry's Mod inspired prop hunt, inspired by hide and seek
+ * [sm_namespamblock](#sm_namespamblock) - Basic plugin that bans players if they change their name in rapid succession
+ * [l4d2-stats-plugin](https://github.com/jackzmc/l4d2-stats-plugin) - Custom stats recorder, see https://stats.jackz.me
+ * [l4d2-ai-tweaks](#l4d2_ai_tweaks) - Very minor tweaks to survivor bots' behavior
+
+### Modified Others
+* [200IQBots_FlyYouFools](#200iqbots_flyyoufools) - Improved code to make it support multiple tanks and work better
+* [l4d_survivor_identity_fix](#l4d_survivor_identity_fix) - Use with [L4D2Tools](#l4d2tools) to change models, some fixes
+* [BetterWitchAvoidance](#betterwitchavoidance)
+* l4d_anti_rush - Modified plugin to add a forward, so other plugins (like feedthetrolls) can do something. In addition, use highest flow value achieved for players (fixes issue when admins go back and players who haven't moved suddenly get punished)
+* [l4d2_sb_fix](#l4d2_sb_fix) - Updated to 1.11 & latest sourcepawn syntax & removed the FCVAR_NOTIFY from all cvars (why is that added?)
+* GrabEnt - Improved version that prevents moving certain entities (such as invisual walls, ragdolls, etc) and improved some code
+
+## Dependencies
+This is a list of most common dependencies, independent if they are used for a certain plugin.
+Check the plugin info for an exact list.
+
+* [Left 4 Dhooks Direct](https://forums.alliedmods.net/showthread.php?t=321696)
+* [Scene Processor](https://forums.alliedmods.net/showthread.php?p=2147410)
+
+### Development Dependencies
+Most L4D2 plugins use my own include: jutils.inc, it's provided in this repo.
+Some do require newer includes for my modified plugins (such as my improved survivor identity fix)
+
+## Descriptions
+
+### csgo-knifehp
+On knife kill, gives the player 100 HP (configurable)
+* **Convars:**
+ * `knifehp_enable <0/1>` - Enable regaining health on knife kill
+ * `knifehp_max_health <#>` - Maximum health to set an attacker to
+ * `knifehp_amount <#>` - Amount of health to give attacker
+
+
+### l4d2-manual-director
+~~Probably going to be posted publicly sometime.~~ Allows you to spawn specials on cursor, or via director, forcefully, bypassing limits
+* **Convars:**
+ * `manual_director_version|mandirector_version` - ... gets version
+ * `mandirector_notify_spawn <1/0>` - Should spawning specials notify on use?
+ * `mandirector_announce_level <0/1/2/3>` - Announcement types. 0 - None, 1 - Only bosses, 2 - Only specials+, 3 - Everything
+ * `mandirector_enable_tank <0/1>` - Should tanks be allowed to be spawned?
+ * `mandirector_enable_witch <0/1>` - Should witches be allowed to be spawned?
+ * `mandirector_enable_mob <0/1>` - Should mobs be allowed to be spawned
+* **Commands:**
+ * `sm_spawnspecial [amount]` - Spawn a special via director
+ * `sm_forcespecial [amount]` - Force spawn a special via director, bypassing spawn limits
+ * `sm_forcecursor [amount]` - Force spawn a special at cursor, bypassing spawn limits
+ * `sm_cursormenu` - Show the spawn menu for cursor spawning
+ * `sm_specialmenu` - Show the spawn menu for director spawning
+ * `sm_directormenu` (Same as sm_specialmenu for now)
+
+
+### l4d2-info-cmd
+Technically 'l4d2 game info', haven't changed name. Just prints general information, used for a project
+* **Commands:**
+ * `sm_gameinfo`
+* Example Response:
+ ```
+ >map,diff,mode,tempoState,totalSeconds
+ c1m1_hotel,1,coop,3,1622
+ >id,name,bot,health,status,throwSlot,kitSlot,pillSlot,survivorType,velocity,primaryWpn,secondaryWpn
+ 1,Jackz,0,80,alive,0,,first_aid_kit,,Bill,0,,pistol
+ 3,Zoey,1,75,alive,0,,first_aid_kit,,Zoey,0,,pistol
+ 4,Francis,1,76,alive,0,,,,Francis,0,,pistol
+ 5,Louis,1,90,alive,0,,first_aid_kit,,Louis,0,,pistol
+ ```
+
+
+### AutoWarpBot
+Simple l4d2 plugin that will auto teleport bots to checkpoint once all real players have reached the saferoom.
+Doesn't really work well. Abandoned.
+
+
+### 200IQBots_FlyYouFools
+Updated version of ConnerRia's plugin. Improves bots avoidance of tanks. Change from original is updated sourcepawn syntax, some optimizations/cleanup, and fixes such as bots avoiding tank that has not been activated, or not escaping in vehicle due to presence of tank.
+Latest version now has support for multiple tanks, the bots might not avoid them as effectively as they would with one tank but they still try their best.
+* **Convars:**
+ * `FlyYouFools_Version` - Prints the version of plugin
+
+
+### BetterWitchAvoidance
+Inspired by the 200IQBots_FlyYouFools. Bots avoid witch if its over 40% anger when close, or a little bigger range at 60% or more. Not recommended to use, normal behavior seems fine.
+
+
+### L4D2FFKickProtection
+Simple plugin that prevents a player that is being vote-kicked from doing any ff damage to teammates.
+It also prevents vote kicking of admins, instead will notify admins.
+It also makes any vote kicks created by an admin to instantly be accepted by all players
+
+* **Convars:**
+ * `sm_votekick_force_threshold <#>` - The threshold of damage where the offending player is just immediately kicked. 0 -> Any attempted damage, -1 -> No auto kick.
+
+
+### CSGOTroll
+Another joke plugin, with it configured, a victim will have a % chance their shots just fail. This can be for the AWP or all weapons at least for now.
+* **Convars:**
+ * `troll_enable <0/1>` - Enable troll. 0 -> OFF, 1 -> Shots
+ * `troll_shot_fail_percentage <0.0-1.0>` - percentage float (0.0 to 1.0) chance that victims' shots fail
+ * `troll_targets ` - comma separated list of steamid64 targets (ex: STEAM_0:0:75141700)
+ * `troll_shot_mode <0/1>` - 0 -> ALL Weapons, 1 -> AWP
+
+
+### l4d2_avoid_minigun
+Makes the bots avoid standing in front of or on top of the player that is using a minigun. It checks every 2.0 seconds if they are in the way, then forces them to move to behind you. There is no configuration, all automatic.
+
+
+### l4d2_ai_minigun
+Requires: [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+
+Spawn the holdout bots used in the passing. This supports all 8 characters, including with the minigun. They can spawn with any weapon or default to ak47.
+
+**Notes:**
+* The minigun holdout bot has to internally be Louis, so it will be Louis making sounds, with whatever model specified being shown. This doesn't apply for normal holdout bot.
+* \ can be "bill" or their numeric id (4).
+
+Code modified from https://forums.alliedmods.net/showthread.php?p=1741099
+
+* **Commands:**
+ * `sm_ai_minigun ` - Spawns an ai bot with minigun infront of wherever you are looking. Can also use numbers (0-7).
+ * `sm_ai_holdout [wpn]` - Spawns a normal ai holdout bot (no minigun), with any weapon w/ laser sight (default is ak).
+ * `sm_ai_remove_far` - Removes any holdout or minigun bots that are 750 units or more from any player.
+
+
+### L4D2Tools
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+* [Scene Processor](https://forums.alliedmods.net/showthread.php?p=2147410)
+* [Modified L4D Survivor Identity Fix](#l4d_survivor_identity_fix)
+
+A collection of small tools:
+ * Notification of when someone picks up laser sights (only the first user, includes bots),
+ * Record time it takes for a finale or gauntlet run to be completed.
+ * Record the amount of friendly fire damage done
+ * Set the survivor models of any survivor with updated [l4d_survivor_identity_fix](#l4d_survivor_identity_fix)
+ * Automatically returns melee weapons that an idle bot dropped once no longer idle
+ * Automatically make players go idle when ping spikes
+ * Slowly kill any zombies attacking survivor bot's blind spots (Fixes brain dead bots stuck taking damage and not killing them)
+
+* **Convars:**
+ * `sm_laser_use_notice <0/1>` - Enable notification of when a laser box was used first
+ * `sm_time_finale <0/1/2>` - Record the time it takes to complete finale. 0 -> OFF, 1 -> Gauntlets Only, 2 -> All finales
+ * `sm_ff_notice <0/1/2>` - Should we record FF damages? 0: OFF, 1: To chat, 2: To HUD text.
+ * `sm_autoidle_ping_max <30.0...>` - "The highest ping a player can have until they will automatically go idle.\n0=OFF, Min is 30
+* **Commands:**
+ * `sm_model ` - Sets the survivor model of the target player(s). 'character' is name or ID of character.
+ * `sm_surv ` - Sets the m_survivorCharacter prop only of the target player(s). 'character' is name or ID of character.
+
+
+### l4d2_swarm
+This plugin is used to counter trolls and otherwise bad players. It simply uses the new script function RushVictim() to make all zombies in X radius attack Y target. It's that simple.
+
+This really only affects wandering zombies, mobs and panic events, but it may work slightly when bile or pipes are thrown. It does not and can't change the targets of zombies.
+
+* **Convars:**
+ * `sm_swarm_default_range <20-Infinity>` - The default range for commands & menus. Defaults to 7,500
+* **Commands:**
+ * `sm_swarm [player] [range]` - Swarm a player, or random if none."
+ * Aliases: `sm_rush`
+ * `sm_rushmenu` - Opens a menu to quickly rush any player. Can be bound to a key to quickly rush as well
+ * Aliases: `sm_rmenu`
+ * `sm_swarmtoggle [range]` - Will continuously run the swarm method on the player at the range. Use the command again or type "disable" for player to disable. Switching players will not disable, just switches target.
+ * Aliases: `sm_rushtoggle`, `sm_rt`
+ * `sm_rushtogglemenu` - Will open a menu to quickly select a player to continuously rush.
+ * Aliases: `sm_rtmenu`
+
+
+### l4d2_feedthetrolls
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+* (Optional) [Scene Processor](https://forums.alliedmods.net/showthread.php?p=2147410)
+* (Optional) [Actions](https://forums.alliedmods.net/showthread.php?t=336374)
+* (Optional) [Modified L4D Antirush](#l4d_anti_rush)
+
+This plugin allows you to enact certain troll modes on any player, some are subtle some are less so. Either way, it works great to deal with a rusher, an asshole or even your friends.
+
+See updated list of trolls and their descriptions:
+https://admin.jackz.me/docs/ftt
+
+* **Convars:**
+ * `sm_ftt_autopunish_mode <#>` - (Not used, WIP) Sets the modes that auto punish will activate for. 1 -> Early crescendo activations
+ * `sm_ftt_autopunish_action <#>` - Which actions will autopunish activate? Add bits together. 0=None, 1=TankMagnet 2=SpecialMagnet 4=Swarm 8=VomitPlayer
+ * `sm_ftt_autopunish_expires <0...>` - How many minutes (in gameticks) until autopunish trolls are removed. 0 for never.
+* **Commands:**
+ * `sm_fta [player]` - The main command, opens a menu to select a troll to apply, with modifiers and flags
+ * `sm_ftr [player]` - Removes all active trolls from a player
+ * `sm_ftc [player]` - Opens a menu to select a combo of trolls
+ * `sm_ftl` - Lists all players that have a mode applied.
+ * `sm_ftm` - Lists all troll options & their descriptions
+ * `sm_mark` - Toggles marking a player to be banned when they fully disconnect
+ * `sm_insta [player] [special]` - (No arguments opens menu) - Spawns a special via the director that will only target the victim
+ * `sm_inface [player] [special]` - Identical to above, but special will be spawned as close as possible to survivor. Boomers auto explode, jockeys on their head, etc.
+ * `sm_bots_attack [target health]` - Slightly broken, but makes all bots shoot at player until they hit X health or a timeout is reached. Turn on `sb_friendlyfire` for it to be effective.
+ * `sm_stagger ` - Makes a player stagger, shortcut to the Stagger troll
+ * `sm_witch_attack ` - Makes all witches agro on the player
+ * `sm_scharge [timeout seconds]` - Will wait till there's no obstructions and players in the way, then spawns a charger behind them to charge them.
+ * `sm_healbots [# bots or 0 default]` - Makes n amount of bots chase a player down to heal them. Won't stop until they are healed, they die, or you run command again.
+ * `sm_csplat - Shortcut to Car Splat. Spawns car in top/front/back that hits the player`
+
+### l4d2_autobotcrown
+Makes any suitable bot (> 40 hp, has shotgun) automatically crown a witch. Supports multiple bots and witches, but only one bot can crown one witch at a time. Plugin is disabled in realism, and is really on suitable for coop or versus. Even works with idle players.
+
+Bots do sometimes miss, but sometimes still manage to kill witch. They also don't care if there is danger in the way (fire, acid, angry witch).
+
+* **Convars:**
+ * `l4d2_autocrown_allowed_difficulty ` - The difficulties the plugin is active on. 1=Easy, 2=Normal 4=Advanced 8=Expert. Add numbers together.
+ * `l4d2_autocrown_modes_tog ` - (Not implemented) - Turn on the plugin in these game modes. 0=All, 1=Coop, 2=Survival, 4=Versus, 8=Scavenge. Add numbers together
+
+
+### l4d2_extraplayeritems
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+* [L4D Info Editor](https://forums.alliedmods.net/showthread.php?p=2614626)
+* (Development dependency) Updated l4d2_weapon_stocks.inc
+
+A well rounded tool that provides extra utilities to a 5+ co-op campaign.
+
+Features:
+* Automatically giving extra kits for each extra player in saferooms
+* Increasing item count for items randomly depending on player count
+* Fix same-models survivors having to fight over ammo pack usage
+* Automatically lock the first saferoom door for every chapter, until a threshold of players or time has passed
+* Includes a HUD that shows all the survivors and their items, and optionally their ping (breaks randomly not sure why)
+* Includes a new 5+ special spawning director
+* Spawn an extra tank that scales with player count
+
+* **Convars:**
+ * `epi_item_chance` - The base chance (multiplied by player count) of an extra item being spawned. Default: 0.056
+ * `epi_kitmode` - Decides how extra kits should be added. Default is 0
+ * 0 -> Overwrites previous extra kits
+ * 1 -> Adds onto previous extra kits
+ * `epi_updateminplayers` - Should the plugin update abm's cvar min_players convar to the player count? (0 no, 1 yes)
+ * `epi_doorunlock_percent` - The percent of players that need to be loaded in before saferoom door is opened.
+ * Default is 0.8, set to 0 to disable door locking
+ * `epi_doorunlock_wait` - How many seconds after to unlock saferoom door. 0 to disable timer
+ * `epi_doorunlock_open` - Controls when or if the door automatically opens after unlocked. Add bits together.
+ * 0 = Never, 1 = When timer expires, 2 = When all players loaded in
+ * `epi_hudstate` - Controls when the extra player hud shows.
+ * 0 = Never, 1 = When 5+ players, 2 = Always on
+ * `epi_sp_spawning` - Determines what specials are spawned. Add bits together.
+ * 1 = Specials, 2 = Witches, 4 = Tanks
+ * `epi_enabled` - When should epi be enabled?
+ * 0 = OFF, 1 = Only when 5+ and official map, 2 = Only when 5+, 3 = Always
+ * `epi_tank_chunkhp` - The amount of health to add to a tank per extra player
+ * `epi_gamemodes` - Comma separated list of allowed gamemodes.
+
+
+### l4d_survivor_identity_fix
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+
+A fork of [Survivor Identity Fix plugin](https://forums.alliedmods.net/showthread.php?t=280539) that adds support for other plugins to update the model cache. This is used by [L4D2Tools](#L4D2Tools) to update the identity when someone changes their model with `sm_model`. It also will clear the memory of model when a player disconnects entirely or on a new map.
+
+In addition, has a fix for the passing finale, and will automatically temporarily change L4D characters to L4D2 until finale starts preventing game messing up their characters.
+
+
+### l4d2_population_control
+Allows you to set the chances that a common spawns as a certain uncommon. The order of the cvars is the order the percentages are ran
+* **Convars:**
+ * `l4d2_population_chance <0.0-1.0>` Default: 1.0, the chance that the code runs on a spawn (basically if 0.0, none of the % chances will run for all types)
+ * `l4d2_population_clowns <0.0-1.0>` The chance that on a common spawn that the special will be a clown.
+ * `l4d2_population_mud <0.0-1.0>` The chance that on a common spawn that the special will be a mud common.
+ * `l4d2_population_ceda <0.0-1.0>` The chance that on a common spawn that the special will be a ceda common.
+ * `l4d2_population_worker <0.0-1.0>` The chance that on a common spawn that the special will be a worker common.
+ * `l4d2_population_riot <0.0-1.0>` The chance that on a common spawn that the special will be a riot common.
+ * `l4d2_population_jimmy <0.0-1.0>` The chance that on a common spawn that the special will be a jimmy common
+ * `l4d2_population_common <#>` - The maximum amount of commons that can spawn.
+ * 0 will turn off,
+ * value > 0 will enforce the exact value
+ * value < 0 will enforce z_common_limit + | value |
+* **Commands:**
+ * `sm_populations` or `sm_population_list` - Lists all the cvar values
+
+### globalbans
+This plugin will store bans in a database and read from it on connect. This allows you to easily have bans global between servers.
+It will automatically intercept any ban that calls OnBanIdentity or OnBanClient (so sm_ban will work normally)
+Note: All admin players are ignored
+
+* **Convars:**
+ * `sm_globalbans_kick_type <0/1/2>`
+ * 0 = Do not kick, just notify
+ * 1 = Kick if banned
+ * 2 = Kick if cannot reach database
+
+
+### l4d2_rollback
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+
+An idea that you can either manually or have events (friendly fire, new player joining) trigger saving all the player's states. Then if say, a troll comes and kills you and/or incaps your team, you can just quick restore to exactly the point you were at with the same items, health, etc.
+
+Currently **abandoned.**
+
+Currently auto triggers:
+
+1. On any recent friendly fire (only triggers once per 100 game ticks)
+2. Any new player joins (only triggers once per 100 game ticks)
+
+* **Commands:**
+ * `sm_save` - Initiates a manual save of all player's states
+ * `sm_state` - Lists all the states
+ * `sm_restore ` - Restores the selected player's state. @all for all
+
+### l4d2_autorestart
+Plugin that automatically restarts server when the server is NOT hibernating, with bots around and no players.
+This fixes an issue with custom maps that force sb_all_bot_game to 1 and disable hibernation.
+
+### l4d2_TKStopper
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+
+Plugin that prevents team killers by checking multiple criterias. Default system is as:
+Any survivor that attacks another survivor
+
+1. If within first 2 minutes of joining, no damage is dealt to either victim or attacker. This prevents the next person to join being punished.
+2. If during the finale vehicle arrival, they do 0x damage to victim and take 2x reverse friendly fire
+3. If neither #1 or #2, both the victim and the attacker take 1/2 the original damage
+4. If victim is in a saferoom, no damage is dealt.
+
+See https://admin.jackz.me/docs/plugins#tkstopper for some more implementation information
+
+
+During any of the above three conditions, if they deal (or attempt to deal) over 75 HP in 15 seconds (configurable) they will be instantly banned for a set period of time (60 minutes). If they are for sure a team killer, it can be extended to a permanent ban.
+
+* **Cvars:**
+ * `l4d2_tk_forgiveness_time <#>` - The minimum amount of seconds to pass (in seconds) where a player's previous accumulated FF is forgive. Default is 15s
+ * `l4d2_tk_bantime` - How long in minutes should a player be banned for? 0 for permanently. Default is 60
+ * `l4d2_tk_ban_ff_threshold` - How much damage does a player need to do before being instantly banned. Default 75 HP
+ * `l4d2_tk_ban_join_time` - Upto how many minutes should any new player's FF be ignored. Default is 2 Minutes
+
+
+
+### l4d2_crescendo_control
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+
+This plugin prevents the activation of buttons ahead of the team. It will prevent players from starting crescendos (and some small other activities as a side effect) until a certain threshold of the team has reached the area.
+
+_This plugin is not perfect, sometimes it may trigger early, or not trigger at all depending on the map. Sometimes you need to as admins, move forward to allow non-admins to activate events._
+
+
+* **Cvars:**
+ * `l4d2_crescendo_percent`
+ * `l4d2_crescendo_range`
+
+
+### l4d2_vocalize_control
+A very small plugin that simply allows a player to mute another player's vocalizations only for them.
+
+* **Commands:**
+ * `sm_vgag ` - Vocalize gag or ungags selected player(s) for the command activator only
+
+### l4d2_sb_fix
+A fork of https://forums.alliedmods.net/showthread.php?p=2757330
+- Updated to latest sourcepawn syntax (now 1.11)
+- Fixed some stupid things (all cvars being FCVAR_NOTIFY)
+
+
+### l4d2_hideandseek
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+* [Scene Processor](https://forums.alliedmods.net/showthread.php?p=2147410)
+
+A sourcemod extenstion of the vscript gamemode (https://steamcommunity.com/sharedfiles/filedetails/?id=2467133506)
+- Player blockers, portals, and props to change and control the maps
+- Optional climbable infected ladders, and heart beat when seeker nearby
+- Some quality of life (winner messages, change seeker mid game, change map time)
+- and a lot more
+
+
+### l4d2_guesswho
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+* [Scene Processor](https://forums.alliedmods.net/showthread.php?p=2147410)
+
+Based off gmod guess who game, find the real players amongst a group of bots.
+All logic is written in this plugin, thus is required.
+Vscript required for hud & mutation
+
+Gamemode: https://steamcommunity.com/sharedfiles/filedetails/?id=2823719841
+
+Requires l4dtoolz and left4dhooks, and optionally skip intro cutscene
+
+### l4d2_prophunt
+Requires:
+* [Left4Dhooks](https://forums.alliedmods.net/showthread.php?t=321696)
+* [Scene Processor](https://forums.alliedmods.net/showthread.php?p=2147410)
+
+Based off gmod prop hunt, find the real players amongst a group of props.
+All logic is written in this plugin, thus is required.
+Vscript required for hud & mutation
+
+* Gamemode: https://steamcommunity.com/sharedfiles/filedetails/?id=2850550331
+
+* Demo Map: https://steamcommunity.com/sharedfiles/filedetails/?id=2855027013 (makes most prop_static -> prop_dynamic)
+
+Requires l4dtoolz and left4dhooks, and optionally skip intro cutscene
+
+### l4d2_hats
+
+Lets you hat any entity (has blacklist support), including players. Yeet, place, restore, and more with the hats.
+
+**Be warned, this can cause server crashes.** It's a lot stable now, but some features are disabled by default (reverse hats + visible hats) as they caused too many crashes. Most crashes are caused by hats and ladders, but default settings prevent it.
+
+It also includes an entity editor and invisible wall creator. View the file to see commands and cvars
+
+### sm_namespamblock
+
+If a user changes their name 3 times within 10 seconds, they will be temp banned for 10 minutes.
+Requires recompile to change.
+
+* **Commands:**
+ * `status2` - Shitty name, but shows all non-admin players, sorted by last joined ascending (up top). Shows steamid and the first name they joined the server as
+ * `sm_status2` - Same command, but allows /status2 in chat
+
+### l4d2_ai_tweaks
+
+Simply, prevents an idle bot (that is a bot for an idle player) from healing another player unless:
+1. The target is black and white
+2. The player has been idle for over **ALLOW_HEALING_MIN_IDLE_TIME** (a \#define) seconds (default is 3 minutes)
+
+Requires recompile to change.
diff --git a/data/ftt_phrases.cfg b/data/ftt_phrases.cfg
new file mode 100644
index 0000000..cb42447
--- /dev/null
+++ b/data/ftt_phrases.cfg
@@ -0,0 +1,251 @@
+"Phrases"
+{
+ "_Full Message Phrases"
+ {
+ "1" "I peed my pants"
+ "2" "I love peas"
+ "3" "I sure wish I was a zombie right now"
+ "4" "mexico menu"
+ "5" "Admin respect is essential"
+ "6" "I respect the admins of this server"
+ "7" "ok"
+ "8" "I think that you are all awesome"
+ "9" "You are all doing great!"
+ "10" "Honestly, I'm jealous of you all"
+ "11" "Pickles"
+ "12" "A chair is a piece of furniture with a raised surface supported by legs, commonly used to seat a single person."
+ "13" "meow"
+ "14" "honk"
+ "15" "Chairs are supported most often by four legs, and have a back; however, a chair can have three legs, or can have a different shape."
+ "16" "It's not admin abuse when the point of being an admin is to abuse"
+ "17" "Many are called but few are chosen"
+ "18" "Out of sight, out of mind"
+ "19" "Thou shalt not kill"
+ "20" "Life's not all beer and skittles"
+ "21" "Dollars to doughnuts"
+ "22" "I'll go to the foot of our stairs"
+ "23" "I could go for a BBQ bacon burger, and a large order of fries, and an orange soda with no ice, and a piece of hot apple pie."
+ "24" "I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese, and a large soda."
+ "25" "Lightning Never Strikes The Same Place Twice"
+ "26" "In peace, vigilance. In war, victory. In death, sacrifice."
+ "27" "Slotted spoons don't hold much soup"
+ "28" "Have you ever been on a shrimp boat?"
+ "29" "I am a pretty pink princess"
+ "30" "Jimmy crack corn, and I don't care"
+ "31" "Penquins are practically chickens"
+ "32" "I don't know about you, but I find fire very dramatic!"
+ "33" "gabe newell"
+ "34" "9 years of development"
+ "35" "nothing worse than a case of the fanny fungus"
+ "36" "Sometimes, I dream about cheese."
+ "37" "STRIDER!!!"
+ "38" "I thought that he was invinsible!"
+ "39" "Yeah, Canadians are DICKS."
+ "40" "I ever tell you about the time Keith and I made fireworks?"
+ "41" "Hey. We need to talk. I've got a proposition that might be mutually advantageous."
+ "42" "Now, I didn't know shit about chemistry, but Keith figured Gasoline burns, doesn't it?"
+ "43" "Heh, third-degree burns on 95 percent of his body. Man, people in the next city over were calling to complain about the smell of burning skin"
+ "44" "Yahoo!"
+ "45" "I have possibly made an oopsie in my pants"
+ "46" "DAVY!"
+ "47" "I hate myself"
+ "48" "I'm not a fan of you"
+ "49" "MOMMY!"
+ "50" "Barry later returns to express his gratitude to Vanessa, breaking the sacred rule that bees are not to communicate with humans."
+ "51" "Barry becomes a member of the Pollen Jocks, and they fly off to a flower patch. Armed with the pollen of the last flowers,"
+ "52" "According to all known laws of aviation, there is no way a bee should be able to fly. Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway"
+ "53" "Barry, I'm going to make it with the power of my mind. With a little help from my friends. See if you can't get them to join in."
+ "54" "Please exit your residency by 8:59 PM, or we will be forced to take legal"
+ "55" "Ooh, black and yellow! Let's shake it up a little."
+ "56" "Yellow, black. Yellow, black. Yellow, black. Yellow, black."
+ "57" "because bees don't care what humans think is impossible."
+ "58" "No i wanna help please"
+ "59" "thankls guy youre super good at the game :)"
+ "60" "everything french people do is not special."
+ "61" "i bet rats in nyc cook the food all the time but nobody gives a shit cause they’re not french."
+ "62" "NOT FAIR! NOT FAIR!"
+ "63" "wahhhhhhhhhhhhhhh"
+ "64" "i stuffed shrimp inside of me once"
+ "65" "I stick fireworks up my ass so when i poop its a real explosion"
+ "66" "I ordered a hooker online once, she had three legs."
+ "67" "i like to breastfeed my cat on flights"
+ "68" "I swear im just above the rest"
+ "69" "I find it pretty hard to find love"
+ "70" "Seeing my team sitting back while i deal with the horde"
+ "71" "I love the dick sucking buisness too"
+ "72" "Until you finally wake up and realize that i was right"
+ }
+ "fuck"
+ {
+ "1" "fudge"
+ "2" "mars bar"
+ "3" "fiddlestick"
+ "4" "fiddle"
+ "5" "ok"
+ "6" "i love"
+ }
+ "shit"
+ {
+ "1" "oopsie"
+ "2" "ok"
+ "3" "woopsie"
+ "4" "ope"
+ }
+ "nigger"
+ {
+ "1" "nice lady"
+ "2" "friendly person"
+ "3" "ok"
+ "4" "honk"
+ "5" "my mom"
+ "6" "my dad"
+ "7" "my brother"
+ "8" "my sister"
+ }
+ "whore"
+ {
+ "1" "lady who I respect"
+ "2" "respectable woman"
+ "3" "ok"
+ }
+ "cunt"
+ {
+ "1" "pickle"
+ "2" "pineapple"
+ "3" "ok"
+ }
+ "bitch"
+ {
+ "1" "my dog"
+ "2" "their dog"
+ "3" "your dog"
+ "4" "our dog"
+ }
+ "ass"
+ {
+ "1" "has"
+ "2" "caboose"
+ "3" "fanny pants"
+ }
+ "salty"
+ {
+ "1" "peppery"
+ "2" "sweet"
+ "3" "honey"
+ }
+ "dead"
+ {
+ "1" "alive"
+ }
+ "alive"
+ {
+ "1" "dead"
+ }
+ "zombie"
+ {
+ "1" "shrimp"
+ "2" "pineapple"
+ }
+ "boomer"
+ {
+ "1" "hunter"
+ "2" "smoker"
+ "3" "jockey"
+ "4" "charger"
+ "5" "witch"
+ "6" "tank"
+ "7" "spitter"
+ }
+ "smoker"
+ {
+ "1" "hunter"
+ "2" "boomer"
+ "3" "jockey"
+ "4" "charger"
+ "5" "witch"
+ "6" "tank"
+ "7" "spitter"
+ }
+ "hunter"
+ {
+ "1" "boomer"
+ "2" "smoker"
+ "3" "jockey"
+ "4" "charger"
+ "5" "witch"
+ "6" "tank"
+ "7" "spitter"
+ }
+ "jockey"
+ {
+ "1" "hunter"
+ "2" "smoker"
+ "3" "boomer"
+ "4" "charger"
+ "5" "witch"
+ "6" "tank"
+ "7" "spitter"
+ }
+ "spitter"
+ {
+ "1" "hunter"
+ "2" "smoker"
+ "3" "jockey"
+ "4" "charger"
+ "5" "witch"
+ "6" "tank"
+ "7" "boomer"
+ }
+ "charger"
+ {
+ "1" "hunter"
+ "2" "smoker"
+ "3" "jockey"
+ "4" "boomer"
+ "5" "witch"
+ "6" "tank"
+ "7" "spitter"
+ }
+ "witch"
+ {
+ "1" "hunter"
+ "2" "smoker"
+ "3" "jockey"
+ "4" "charger"
+ "5" "boomer"
+ "6" "tank"
+ "7" "spitter"
+ }
+ "tank"
+ {
+ "1" "hunter"
+ "2" "smoker"
+ "3" "jockey"
+ "4" "charger"
+ "5" "witch"
+ "6" "boomer"
+ "7" "spitter"
+ }
+ "dickhead"
+ {
+ "1" "poopie"
+ "2" "quack"
+ "3" "big brain"
+ "4" "cactus"
+ "5" "friend"
+ "6" "mom"
+ "7" "mommie"
+ }
+ "cock"
+ {
+ "1" "foot"
+ }
+ "dick"
+ {
+ "1" "Canadian"
+ }
+ "dicks"
+ {
+ "1" "Canadians"
+ }
+}
\ No newline at end of file
diff --git a/data/guesswho/config.cfg b/data/guesswho/config.cfg
new file mode 100644
index 0000000..a42efa4
--- /dev/null
+++ b/data/guesswho/config.cfg
@@ -0,0 +1,87 @@
+"guesswho"
+{
+ "c1m1_hotel"
+ {
+ "spawnpoint" "442.905334 5640.576660 2656.031250"
+ "ents"
+ {
+ "FENCE"
+ {
+ "origin" "1602.161499 5618.440917 2656.031250"
+ "rotation" "0.000000 -178.836151 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\barricade001_128_reference.mdl"
+ }
+ "VENDING"
+ {
+ "origin" "406.428405 5625.409667 2656.031250"
+ "rotation" "0.000000 90.238922 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_office\vending_machine.mdl"
+ }
+ }
+
+ }
+ "c8m5_rooftop"
+ {
+ "spawnpoint" "5386.052246 8413.505859 5536.031250"
+ }
+ "c2m2_fairgrounds"
+ {
+ "spawnpoint" "-3451.616943 -818.726989 128.031250"
+ "ents"
+ {
+ "DROP_BLOCK"
+ {
+ "origin" "-3073.630371 -910.963195 192.623626"
+ "scale" "30 260 100"
+ }
+ "ENTRANCE_BLOCK"
+ {
+ "origin" "-2826.833251 -1978.528808 -127.915451"
+ "rotation" "0.000000 -1.978949 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_urban\wood_fence001_128.mdl"
+ }
+ "ENTRANCE_BLOCK_PROP"
+ {
+ "origin" "-2826.833251 -1978.528808 -127.915451"
+ "scale" "20 100 500"
+ }
+ "STAIR_BLOCK_PROP"
+ {
+ "origin" "-3241.681884 -1817.223266 256.031250"
+ "rotation" "0.000000 92.011253 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "STAIR_BLOCK"
+ {
+ "origin" "-3321.681884 -1817.223266 300.031250"
+ "scale" "140 20 60"
+ }
+ }
+ }
+ "c11m4_terminal"
+ {
+ "spawnpoint" "3081.824951 4571.367187 152.031250"
+ "ents"
+ {
+ "ENTRANCE_BLOCKER"
+ {
+ "origin" "2700.844482 1865.502807 177.313140"
+ "scale" "200 100 200"
+ }
+ "fire"
+ {
+ "origin" "2700.844482 1865.502807 179.313140"
+ "type" "env_fire"
+ "scale" "1.0 256 8"
+ }
+ }
+ "inputs"
+ {
+ "checkpoint_entrance" "Kill"
+ }
+ }
+}
diff --git a/data/hideandseek.cfg b/data/hideandseek.cfg
new file mode 100644
index 0000000..698862d
--- /dev/null
+++ b/data/hideandseek.cfg
@@ -0,0 +1,2083 @@
+"hideandseek"
+{
+ "c4m1_milltown_a"
+ {
+ "spawnpoint" "-3904.694580 7205.333984 199.836639"
+ "ents"
+ {
+ "TRUCK_SKIP"
+ {
+ "origin" "-3369.870117 7448.359375 96.031250"
+ "rotation" "0.000000 24.135879 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "BARRICADE_1"
+ {
+ "origin" "2074.847167 2896.825439 96.031250"
+ "rotation" "0.000000 175.428447 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "BARRICADE_2"
+ {
+ "origin" "2065.847167 2779.825439 96.031250"
+ "rotation" "0.000000 175.428447 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "BARRICADE_3"
+ {
+ "origin" "2071 2670 96.031250"
+ "rotation" "0.000000 175.428447 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "DOOR_BLOCK"
+ {
+ "origin" "2000.038940 2530.103759 104.031250"
+ "rotation" "90.000000 180.681259 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_mill/wood_stack.mdl"
+ }
+ "BARRICADE_SIDE"
+ {
+ "origin" "1938.229248 2108.860839 96.353591"
+ "rotation" "0.000000 175.428447 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "HOUSE_BLOCK_1"
+ {
+ "origin" "1917.533691 2347.451416 104.031250"
+ "rotation" "0.000000 0.041839 0.000000"
+ "type" "prop_dynamic"
+ "model" "props/cs_office/bookshelf2.mdl"
+ }
+ "HOUSE_BLOCK_2"
+ {
+ "origin" "1917.533691 2247.451416 104.031250"
+ "rotation" "0.000000 0.041839 0.000000"
+ "type" "prop_dynamic"
+ "model" "props/cs_office/bookshelf2.mdl"
+ }
+ "TREEHOUSE_BLOCKER"
+ {
+ "origin" "2072.242675 3038.970703 206.251251"
+ "scale" "5.000000 1500.000000 400.000000"
+ "type" "env_physics_blocker"
+ }
+ "ENTRANCE_STOPPER"
+ {
+ "origin" "-4057.503173 7158.272949 201.491455"
+ "scale" "5.000000 2500.000000 800.000000"
+ "type" "env_physics_blocker"
+ }
+
+ }
+ }
+ "c5m4_quarter"
+ {
+ "spawnpoint" "-3663.735351 3156.915039 64.031250"
+ "sets"
+ {
+ "block"
+ {
+ "spawnpoint" "-1322.446411 2238.070800 72.031250"
+ }
+ "block_long"
+ {
+ "spawnpoint" "-1213.040527 325.299438 176.126968"
+ }
+ }
+ "ents"
+ {
+ "END_BLOCK"
+ {
+ "origin" "-1534.599975 -1606.185058 256.031250"
+ "rotation" "0.000000 -177.669448 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_urban/fridge001.mdl"
+ }
+ "END_BLOCK_2"
+ {
+ "origin" "-1802.811401 -1206.369750 260.031250"
+ "type" "env_physics_blocker"
+ "scale" "100 100 50"
+ }
+ "BEGIN_BLOCK"
+ {
+ "origin" "-1548.047607 2458.536437 60.044128"
+ "scale" "1600.000000 10.000000 400.000000"
+ "type" "env_physics_blocker"
+ "set" "block"
+ }
+ "STAIRS"
+ {
+ "origin" "-1118.047607 915.536437 244.044128"
+ "rotation" "0.000000 180.843437 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/stairs_house_01.mdl"
+ }
+ "GATE_TP"
+ {
+ "origin" "-1630.467895 -396.031250 184.031250"
+ "type" "_portal"
+ "offset" "-1623.645263 -332.286193 135.869384"
+ "scale" "10 10 10"
+ }
+ "PORTAL_1"
+ {
+ "origin" "-1446.877319 -358.595733 203.116073"
+ "type" "_relportal"
+ "offset" "0.000000 10.000000 0.000000"
+ "scale" "100 40 50"
+ }
+ "PORTAL_1_PROPA"
+ {
+ "origin" "-1575.466674 -420.767852 65.182296"
+ "rotation" "0.000000 180.843437 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/stairs_house_01.mdl"
+ }
+ "PORTAL_1_PROPB"
+ {
+ "origin" "-1575.466674 -310.767852 65.182296"
+ "rotation" "0.000000 180.843437 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/stairs_house_01.mdl"
+ }
+ "FLAT_BLOCK"
+ {
+ "origin" "-3188.373779 3200.747802 300.585388"
+ "scale" "500 400 50"
+ "type" "env_physics_blocker"
+ }
+ "FENCE_SKIP"
+ {
+ "origin" "-1555.620239 2514.195068 64.031250"
+ "rotation" "0.0 -71.973693 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "SHORT_BLOCK"
+ {
+ "origin" "-563.721069 1031.170043 143.387512"
+ "rotation" "62.338180 6.194050 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_interiors\couch.mdl"
+ "set" "block_long"
+ }
+ "SHORT_BLOCK_SUPPORT"
+ {
+
+ "origin" "-608.215881 1030.887817 96.031250"
+ "rotation" "0.530479 -82.875152 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "set" "block_long"
+ }
+ "SHORT_BLOCK_SUPPORT2"
+ {
+
+ "origin" "-608.215881 1030.887817 136.031250"
+ "rotation" "0.530479 -82.875152 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "set" "block_long"
+ }
+ "TRACTOR_EARLY_HELP"
+ {
+ "origin" "-1503.682861 539.312591 255.984069"
+ "rotation" "89.000000 0.671798 90.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors\fence002.mdl"
+ }
+ "GNOME"
+ {
+ "origin" "-3511.222656 2463.375488 432.031250"
+ "type" "prop_physics_multiplayer"
+ "model" "props_junk/gnome.mdl"
+ }
+ "lol"
+ {
+ "origin" "-2386.989013 1119.776489 80.031250"
+ "rotation" "0.000000 -86.269416 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_teenangst.mdl"
+ }
+ }
+ "inputs"
+ {
+ "float_tracktrain" "TeleportToPathTrack float_path2"
+ "float_final_nav_blocker" "BlockNav"
+ "float_music" "Kill"
+ "float_start_nav_blocker2" "Kill"
+ "float_start_nav_blocker3" "Kill"
+ "courtyard_spawn1_breakable" "Kill"
+ "courtyard_spawn2_breakable" "Kill"
+ }
+ }
+ "c8m3_sewers"
+ {
+ "ents"
+ {
+ "A"
+ {
+ "origin" "13265.965820 8547.057617 -250.7"
+ "type" "env_physics_blocker"
+ }
+ "B"
+ {
+ "origin" "14130.535156 8026.46386 -254.7"
+ "type" "env_physics_blocker"
+ }
+ "A_PROP"
+ {
+ "origin" "13265.965820 8497.057617 -240.7"
+ "type" "prop_dynamic"
+ "model" "props/cs_office/shelves_metal.mdl"
+ "rotation" "90 90 0"
+ }
+ "B_PROP"
+ {
+ "origin" "14130.535156 8026.46386 -254.7"
+ "type" "prop_dynamic"
+ "model" "props_swamp/river_sign01.mdl"
+ "rotation" "90 0 0"
+ }
+ "STAIR_HELP"
+ {
+ "origin" "11896.693359 7291.923828 143.372573"
+ "rotation" "0.000000 -90.646430 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ }
+ "ROOF_EXIT"
+ {
+ "origin" "11353 5861 204"
+ "rotation" "0 96 0"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "ROOF_FIX_FIXER"
+ {
+ "origin" "10579.599609 5120.623535 280.031250"
+ "scale" "20 1000 400"
+ "type" "env_physics_blocker"
+ }
+ "ROOF_FIX_FIXER_CORNER"
+ {
+ "origin" "10617.877929 5216.473144 280.031250"
+ "scale" "40 60 400"
+ "type" "env_physics_blocker"
+ }
+ "ROOF_NO_SNEAKY_JUMP"
+ {
+ "origin" "11127.424804 5662.353515 408.031250"
+ "scale" "20 300 500"
+ "type" "env_physics_blocker"
+ }
+ "ROOF_BRIDGE"
+ {
+ "origin" "12421.961914 4886.637207 568.031250"
+ "rotation" "-11.137193 -159.704940 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_unique\rope_bridge.mdl"
+
+ }
+ "ROOF_STOP"
+ {
+ "origin" "11895.786132 4616.688476 712.031250"
+ "rotation" "0.137193 0.704940 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_wasteland\coolingtank01.mdl"
+ }
+ "ROOF_STOP2"
+ {
+
+ "origin" "11641.057617 4630.232421 712.031250"
+ "rotation" "0.137193 0.704940 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_wasteland\coolingtank01.mdl"
+ }
+ "ROOF_STOP3"
+ {
+ "origin" "11432.921875 4660.313476 712.031250"
+ "rotation" "0.137193 0.704940 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_wasteland\coolingtank01.mdl"
+ }
+ "ROOF_STOP_WALL"
+ {
+ "origin" "11641.057617 4630.232421 712.031250"
+ "type" "env_physics_blocker"
+ "scale" "2000 90 600"
+ }
+ "ROOF_DEATH_PREVENT"
+ {
+ "origin" "12456.858398 4781.894042 568.031250"
+ "rotation" "0.000000 -131.235916 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\barricade001_128_reference.mdl"
+ }
+ "ROOF_DEATH_PREVENT_WALL"
+ {
+ "origin" "12310.758789 4753.980957 568.031250"
+ "type" "env_physics_blocker"
+ "scale" "120 60 400"
+ }
+ "ROOF_DEATH_PREVENT_PREVENTER"
+ {
+ "origin" "11994.040039 4736.263671 712.031250"
+ "rotation" "0.000000 -4.221647 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\barricade001_128_reference.mdl"
+ }
+ "STAIR_ACCESS"
+ {
+
+ "origin" "11100.574218 5208.395996 317.781250"
+ "rotation" "0.290893 -80.968573 32.000000"
+ "type" "prop_dynamic"
+ "model" "props_swamp\plank001b_192.mdl"
+ }
+ "GAS_STOP"
+ {
+ "origin" "12682.116210 5713.574218 568.031250"
+ "rotation" "0.000000 73.767333 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\barricade001_128_reference.mdl"
+ }
+ "GAS_STOP2"
+ {
+ "origin" "12580.110351 5731.003417 568.031250"
+ "rotation" "0.000000 73.767333 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\barricade001_128_reference.mdl"
+ }
+ "GAS_BLOCK"
+ {
+ "origin" "12812.621093 5929.395507 463.586090"
+ "type" "env_physics_blocker"
+ "scale" "300 1000 1000"
+ }
+ "NO_DIE"
+ {
+ "origin" "11323.022460 4793.813476 712.031250"
+ "rotation" "0.000000 -134.307327 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\barricade001_128_reference.mdl"
+ }
+ }
+ "inputs"
+ {
+ "anv_mapfixes_unattackable_wrongway1" "Kill"
+ }
+ }
+ "c3m1_plankcountry"
+ {
+ "spawnpoint" "-12070.341796 10517.305664 183.448410"
+ "sets"
+ {
+ "area2"
+ {
+ "spawnpoint" "-4240.322265 6052.394531 28.160285"
+ }
+ "end"
+ {
+ "spawnpoint" "-1030.998535 4821.037109 144.160293"
+ }
+ "large"
+ {
+ "spawnpoint" "-1030.998535 4821.037109 144.160293"
+ }
+ }
+ "ents"
+ {
+ "divider"
+ {
+ "origin" "-1023.450622 4939.198242 144.160293"
+ "rotation" "0.000000 -90.445228 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ "set" "area2"
+ }
+ "divider"
+ {
+ "origin" "-1023.450622 4939.198242 144.160293"
+ "rotation" "0.000000 -90.445228 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ "set" "end"
+ }
+ }
+ "inputs"
+ {
+ "func_breakable" "Break"
+ }
+ }
+ "c3m3_shantytown"
+ {
+ "sets"
+ {
+ "hut"
+ {
+ "spawnpoint" "-3914.085449 -3092.477050 62.502365"
+ }
+ "end-large"
+ {
+ "spawnpoint" "-557.272216 -2464.328125 4.269320"
+ "inputs"
+ {
+ "delete_coop_ents_postIO" "Trigger"
+ "bridge_minifinale" "Close"
+ "bridge_minifinale" "SetSpeed 200"
+ }
+ }
+ }
+ "ents"
+ {
+ "door_block"
+ {
+ "origin" "-4004.808593 -3011.982666 62.502365"
+ "rotation" "0 0 0"
+ "type" "prop_dynamic"
+ "model" "props_urban\fridge002.mdl"
+ }
+ "door_wall"
+ {
+ "origin" "-4000.808593 -3011.982666 62.502365"
+ "scale" "20 1050 300"
+ }
+ "door_block_tree"
+ {
+ "origin" "-4135.271972 -3837.605224 -0.291338"
+ "rotation" "-0.559620 173.978195 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_foliage\swamp_cypress_knee01.mdl"
+ }
+ "door_block_tree"
+ {
+ "origin" "-4116.226562 -3944.508056 0.005385"
+ "rotation" "-0.559620 173.978195 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_foliage\swamp_cypress_knee01.mdl"
+ }
+ "large_block"
+ {
+ "origin" "-1745.625976 -2745.440429 0.031250"
+ "set" "end-large"
+ "scale" "50 2000 400"
+ }
+ "large_block_prop"
+ {
+ "origin" "-1780.625976 -2880.440429 0.031250"
+ "type" "prop_dynamic"
+ "set" "end-large"
+ "rotation" "0 90 0"
+ "model" "props_debris\airliner_wreckage3.mdl"
+ }
+ "large_block_prop"
+ {
+ "origin" "-1573.762573 -3763.656494 -10.686201"
+ "type" "prop_dynamic"
+ "set" "end-large"
+ "rotation" "0 90 0"
+ "model" "props_debris\dead_cow_smallpile.mdl"
+ }
+ }
+ "inputs"
+ {
+ "bridge_button" "Kill"
+ }
+ }
+ "c3m4_plantation"
+ {
+ "sets"
+ {
+ "begin"
+ {
+
+ }
+ "mansion"
+ {
+ "climbing" "on"
+ "spawnpoint" "1656.207519 -120.207824 224.031250"
+ }
+ }
+ "defaultset" "begin"
+ "ents"
+ {
+ "A"
+ {
+ "origin" "2000.802612 -426.686829 402.803497"
+ "type" "env_physics_blocker"
+ "scale" "150.0 150.00 1.0"
+ "set" "begin"
+ }
+ "A_PROP"
+ {
+ "origin" "2000.802612 -426.686829 402.803497"
+ "type" "prop_dynamic"
+ "model" "props_swamp/boardwalk_384.mdl"
+ "rotation" "0 90 0"
+ "set" "begin"
+ }
+ "MANSION_ENT_RAIL"
+ {
+ "model" "props_exteriors/wood_railing004c.mdl"
+ "type" "prop_dynamic"
+ "origin" "2529.63 -804.10 642.56"
+ "angles" "0.00 178.84 0.00"
+ "set" "mansion"
+ }
+ "MANSION_ENT_BLOCK"
+ {
+ "origin" "2563.37 -818.00 366.03"
+ "type" "env_physics_blocker"
+ "scale" "441 10 400"
+ "set" "mansion"
+ }
+ "MANSION_ENT_GATE"
+ {
+ "model" "props_street/police_barricade_496in.mdl"
+ "origin" "1693.63 -1178.33 169.86"
+ "type" "prop_dynamic"
+ "set" "mansion"
+ }
+ }
+ "inputs"
+ {
+ "env_physics_blocker" "Kill"
+ "gate_explode_relay" "Trigger"
+ "prop_minigun" "Kill"
+ }
+ }
+ "c1m3_mall"
+ {
+ "sets"
+ {
+ "mid"
+ {
+ "spawnpoint" "1457.455078 -1059.256469 280.031250"
+ }
+ }
+ "defaultset" "begin"
+ "ents"
+ {
+ "A"
+ {
+ "origin" "1581.286865 -1029.394043 280.079254"
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster.mdl"
+ "rotation" "0 90 0"
+ }
+ "B"
+ {
+ "origin" "1714.133179 -1023.777527 347.735168"
+ "scale" "25.0 25.00 100.0"
+ "type" "env_physics_blocker"
+ "set" "begin"
+ }
+ "B"
+ {
+ "origin" "1714.133179 -1023.777527 347.735168"
+ "scale" "25.0 25.00 100.0"
+ "type" "env_physics_blocker"
+ "set" "mid"
+ }
+ "lol"
+ {
+ "origin" "2129.125976 -2346.968750 0.031250"
+ "rotation" "0.000000 39.811450 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_namvet.mdl"
+ }
+ "VENT_WARPER"
+ {
+ "origin" "1203.086791 -2000.914306 384.031250"
+ "type" "_portal"
+ "scale" "40 40 50"
+ "offset" "1159.986694 -2063.281738 456.013153"
+ "set" "mid"
+ }
+ "EXIT_BLOCK"
+ {
+ "origin" "1283.903686 -5341.520019 536.031250"
+ "rotation" "0.000000 0.968292 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_office\vending_machine.mdl"
+ "set" "mid"
+ }
+
+ }
+ "inputs"
+ {
+ "sound_alarm" "StopSound"
+ "sound_alarm" "Kill"
+ "blocker_stairwell" "Kill"
+ "hurt_stairwell" "Kill"
+ "door_stairwell" "Unlock"
+ "blocker_stairwell_clip" "Kill"
+ "door_hallway" "Kill"
+ "breakwall_bathroom_wall" "Break"
+ "breakble_glass_minifinale" "Break"
+ "env_player_blocker" "Kill"
+ "relay_elevator_path_02" "Trigger"
+ "soundscapes-hall" "StopSound"
+ "soundscapes-hall.entry" "StopSound"
+ }
+ }
+ "c6m2_bedlam"
+ {
+ "ents"
+ {
+ "A"
+ {
+ "origin" "349.935608 3156.456543 263.583710"
+ "scale" "100.0 50.00 300.0"
+ "type" "env_physics_blocker"
+ "set" "short"
+ }
+ "A_PROP"
+ {
+ "origin" "350.063263 3171.198730 198.247498"
+ "type" "prop_dynamic"
+ "model" "props_industrial/barrel_fuel.mdl"
+ "rotation" "0 -91 -0.000109"
+ "set" "short"
+ }
+ "B_PROP"
+ {
+ "origin" "1138.566650 1374.530884 -194.578400"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 180 0"
+ }
+ "B_PROP2"
+ {
+ "origin" "1363.922241 1381.682617 -194.578400"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 0 0"
+ }
+ "DOOR_BLOCK"
+ {
+ "origin" "1401.782592 4686.330566 -101.095458"
+ "type" "env_physics_blocker"
+ "scale" "60 20 100"
+ }
+ "DOOR_BLOCK_PROP"
+ {
+ "origin" "1401.782592 4686.330566 -160.095458"
+ "type" "prop_dynamic"
+ "model" "props\de_train\pallet_barrels.mdl"
+ "rotation" "0 -91 -0.000109"
+ }
+ "RETURN_HELPER"
+ {
+ "origin" "1251.872436 1316.629760 -78.262710"
+ "rotation" "0.000000 178.612152 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ }
+ "inputs"
+ {
+ "gate_1_alarm" "Kill"
+ "sound_alarm" "Kill"
+ "gate_2_alarm" "Kill"
+ }
+ }
+ "c7m1_docks"
+ {
+ "climbing" "off"
+ "spawnpoint" "11068.093750 -207.805831 -67.623802"
+ "ents"
+ {
+ "A_PROP"
+ {
+ "origin" "8469.404297 854.461121 14.257706"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 -90 0"
+ }
+ "B_PROP"
+ {
+ "origin" "3522.576416 647.513244 176.031250"
+ "rotation" "0.000000 -88.406250 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_doors/roll-up_door_full.mdl"
+ }
+ "B_PROP"
+ {
+ "origin" "3266.576416 647.513244 176.031250"
+ "rotation" "0.000000 -88.406250 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_doors/roll-up_door_full.mdl"
+ }
+ "DUMPSTER_EXIT"
+ {
+ "origin" "3604 263 149"
+ "model" "props_junk/dumpster_2.mdl"
+ "type" "prop_dynamic"
+ "rotation" "0 180 0"
+ }
+ "DUMPSTER_ENTER"
+ {
+ "origin" "3872.412841 588.284240 176.031250"
+ "model" "props_junk/dumpster_2.mdl"
+ "type" "prop_dynamic"
+ "rotation" "0 0 0"
+ }
+ "CRATE_SHORTCUT"
+ {
+ "origin" "5288.236328 596.502136 146.863418"
+ "rotation" "0.000000 178.612152 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "SPAWN_BLOCK_PROP"
+ {
+ "origin" "11404.483398 -227.757766 -63.968750"
+ "rotation" "0.966560 -176.921936 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "SPAWN_BLOCK"
+ {
+ "origin" "11404.483398 -227.757766 0.968750"
+ "scale" "20 1000 100"
+ "type" "env_physics_blocker"
+ }
+ "lol"
+ {
+ "origin" "7641.535644 2735.968750 240.031250"
+ "rotation" "8.966513 -31.319810 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_namvet.mdl"
+ }
+ }
+ "inputs"
+ {
+ "tankdoorin" "Open"
+ "tankdoorout" "Open"
+ "traincar_navblocker" "Kill"
+ "tankdoorin_button" "Kill"
+ "tankdoorout_button" "Kill"
+ "tank_door_clip" "Kill"
+ "tank_sound_timer" "Disable"
+ "delete_coop_ents_postIO" "Trigger"
+ "battlefield_cleared" "UnblockNav"
+ }
+ }
+ "c10m2_drainage"
+ {
+ "ents"
+ {
+ "TOP_HELPER"
+ {
+ "origin" "-9874.015625 -7637.003417 -467.968750"
+ "rotation" "0.000000 -90.964706 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_interiors/desk_executive.mdl"
+ }
+ "STAIRS"
+ {
+ "origin" "-8120.544433 -7200.660156 -561.968750"
+ "rotation" "0.000000 180.672305 -8.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ }
+ "BOX"
+ {
+ "origin" "-8713.857421 -7792.103027 -395.968750"
+ "rotation" "0.000000 90.578536 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "PORTAL1_ENT"
+ {
+ "origin" "-8713.857421 -7792.103027 -300.968750"
+ "type" "_relportal"
+ "offset" "0 150 50"
+ "scale" "60 30 5"
+ }
+ "PORTAL1_EXIT"
+ {
+
+ "origin" "-8698.404296 -7663.968750 -260.968750"
+ "type" "_portal"
+ "offset" "-8776.213867 -7811.048339 -395.968750"
+ "scale" "60 30 50"
+ }
+ "PORTAL2_EXIT"
+ {
+
+ "origin" "-9443.846679 -7276.223144 -307.968750"
+ "type" "_portal"
+ "offset" "-9520.279296 -7281.130859 -467.968750"
+ "scale" "20 100 100"
+ }
+ "PORTAL3_EXIT"
+ {
+
+ "origin" "-9867.969726 -6852.831054 -307.968750"
+ "type" "_portal"
+ "offset" "-9871.308593 -6921.020507 -467.968750"
+ "scale" "100 20 100"
+ }
+ "PORTAL4_EXIT"
+ {
+
+ "origin" "-8984.172851 -7881.412597 -307.968750"
+ "type" "_portal"
+ "offset" "-8928.278320 -7888.108886 -336.968750"
+ "scale" "20 100 100"
+ }
+ "FALL_BARRIER"
+ {
+ "origin" "-8830.380859 -8800.031250 -307.968750"
+ "rotation" "0.000000 94.068542 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors\fence002.mdl"
+ }
+ "PORTAL_5_ENTRANCE_PROP"
+ {
+ "origin" "-8932.521484 -8515.070312 -400.968750"
+ "rotation" "0.000000 -178.028656 0.000000"
+ "type" "prop_dynamic"
+ "model" "props/de_nuke/crate_small.mdl"
+ }
+ "PORTAL_5_ENTRACE"
+ {
+ "origin" "-8970.968750 -8521.311523 -307.968750"
+ "type" "_portal"
+ "offset" "-9147.531250 -8549.711914 -307.968750"
+ "scale" "5 50 20"
+ }
+ "PORTAL5_EXIT"
+ {
+
+ "origin" "-9072.031250 -8532.894531 -307.968750"
+ "type" "_portal"
+ "offset" "-8942.968750 -8528.318359 -330.968750"
+ "scale" "20 100 100"
+ }
+ "BRIDGE_COLLIDE"
+ {
+ "origin" "-8402.264648 -8553.781250 -400.065338"
+ "scale" "400 40 5"
+ "type" "env_physics_blocker"
+ }
+ "WINDOW_BLOCK_PROP"
+ {
+ "origin" "-6125.968750 -6989.230957 -63.608612"
+ "rotation" "0.000000 -177.974670 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/army_truck.mdl"
+ }
+ "WINDOW_BLOCK"
+ {
+ "origin" "-6131.369140 -7206.083496 -17.568002"
+ "scale" "50 200 200"
+ "type" "env_physics_blocker"
+ }
+ "PIPE_HELPER"
+ {
+ "origin" "-8035.905273 -8131.730468 -481.552062"
+ "scale" "20 80 10"
+ "type" "env_physics_blocker"
+ }
+ }
+ "inputs"
+ {
+ "sound_alarm" "Kill"
+ "sound_floodgate_loop" "Kill"
+ "watergate_bottom" "BlockNav"
+ "gate_push_01" "Disable"
+ "gate_blocker" "Disable"
+ "gate_collide" "Enable"
+ "watergate" "UnblockNav"
+ }
+ }
+ "c14m1_junkyard"
+ {
+ "ents"
+ {
+ "C"
+ {
+ "origin" "-1101.485352 -4729.446777 -109.968750"
+ "scale" "25.0 25.00 30.0"
+ "type" "env_physics_blocker"
+ }
+ "A_PROP"
+ {
+ "origin" "-1100.091553 -4585 -300.641998"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 90 0"
+ }
+ "B"
+ {
+ "origin" "-4259.611328 2193.898682 119.894897"
+ "scale" "55.0 55.00 100.0"
+ "type" "env_physics_blocker"
+ }
+ }
+ }
+ "c1m1_hotel"
+ {
+ "buttons" "no"
+ "ents"
+ {
+ "A"
+ {
+ "origin" "2164.177246 5723.599609 2526.031250"
+ "scale" "60 20 50"
+ "type" "env_physics_blocker"
+ }
+ }
+ "inputs"
+ {
+ "elevator_1_door2" "close"
+ "elevator_1_door1" "close"
+ }
+ }
+ "c2m2_fairgrounds"
+ {
+ "sets"
+ {
+ "rides" {
+ "spawnpoint" "362.696716 -268.582977 -16.631347"
+ }
+ }
+ "ents"
+ {
+ "END_STOP"
+ {
+ "origin" "495.141967 -279.631744 0.031250"
+ "scale" "5.000000 220.000000 200.000000"
+ "type" "env_physics_blocker"
+ }
+ "END_PROP"
+ {
+ "origin" "474.110717 -191.851898 -3.251148"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "END_PROP_2"
+ {
+ "origin" "474.110717 -323.851898 -3.251148"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "STAIRS"
+ {
+ "type" "prop_dynamic"
+ "origin" "1951.127319 -317.584213 5.031250"
+ "rotation" "0.843326 90.637062 0.000000"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ }
+ "HELPER"
+ {
+ "origin" "2108.085937 -463.634277 160.352081"
+ "rotation" "-26.078588 -90.851776 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster.mdl"
+ }
+ "HEDGE_SHOWER"
+ {
+ "set" "rides"
+ "origin" "-3043.151611 -5329.417480 -63.968750"
+ "rotation" "0.000000 1.148354 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster_2.mdl"
+ }
+ "NO_SAFEROOM"
+ {
+ "set" "rides"
+ "origin" "-3926.420166 -5486.845214 -66.968750"
+ "rotation" "0.000000 -11.019555 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fairgrounds\kiddyland_ridestructure_closed.mdl"
+ }
+ "binning_fence_explainer"
+ {
+ "set" "rides"
+ "origin" "-1559.084960 -1815.552001 128.996826"
+ "rotation" "0.185535 -60.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "binning_fence_explainer_inner"
+ {
+ "set" "rides"
+ "origin" "-702.269836 -2566.092041 128.031250"
+ "rotation" "0.185535 -90.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\police_barrier001_128_reference.mdl"
+ }
+ "binning_fence_explainer_innerb"
+ {
+ "set" "rides"
+ "origin" "-830.394409 -2502.136230 128.031250"
+ "rotation" "0.185535 -119.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\police_barrier001_128_reference.mdl"
+ }
+ "binning_fence_explainer_innerc"
+ {
+ "set" "rides"
+ "origin" "-572.269836 -2536.092041 128.031250"
+ "rotation" "0.185535 -80.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\police_barrier001_128_reference.mdl"
+ }
+ "shelf"
+ {
+ "set" "rides"
+ "origin" "-3134.213378 -336.267608 128.031250"
+ "rotation" "0.581893 89.038597 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_office\shelves_metal.mdl"
+ }
+ "HEDGE_SHOWER"
+ {
+ "set" "rides_short"
+ "origin" "-3043.151611 -5329.417480 -63.968750"
+ "rotation" "0.000000 1.148354 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster_2.mdl"
+ }
+ "NO_SAFEROOM"
+ {
+ "set" "rides_short"
+ "origin" "-3926.420166 -5486.845214 -66.968750"
+ "rotation" "0.000000 -11.019555 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fairgrounds\kiddyland_ridestructure_closed.mdl"
+ }
+ "binning_fence_explainer"
+ {
+ "set" "rides_short"
+ "origin" "-1559.084960 -1815.552001 128.996826"
+ "rotation" "0.185535 -60.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "binning_fence_explainer_inner"
+ {
+ "set" "rides_short"
+ "origin" "-702.269836 -2566.092041 128.031250"
+ "rotation" "0.185535 -90.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\police_barrier001_128_reference.mdl"
+ }
+ "binning_fence_explainer_innerb"
+ {
+ "set" "rides_short"
+ "origin" "-830.394409 -2502.136230 128.031250"
+ "rotation" "0.185535 -119.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\police_barrier001_128_reference.mdl"
+ }
+ "binning_fence_explainer_innerc"
+ {
+ "set" "rides_short"
+ "origin" "-572.269836 -2536.092041 128.031250"
+ "rotation" "0.185535 -80.982719 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications\police_barrier001_128_reference.mdl"
+ }
+ "shelf"
+ {
+ "set" "rides_short"
+ "origin" "-3134.213378 -336.267608 128.031250"
+ "rotation" "0.581893 89.038597 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_office\shelves_metal.mdl"
+ }
+ "short_bottom_block"
+ {
+ "origin" "-2300.978027 -3836.044189 -128.968750"
+ "rotation" "0 -90 0"
+ "type" "prop_dynamic"
+ "model" "props_urban\fence_gate001_256.mdl"
+ "set" "rides_short"
+ }
+ "short_bottom_block2"
+ {
+ "origin" "-2394.099365 -3841.655029 -126.968750"
+ "rotation" "0 -90 0"
+ "type" "prop_dynamic"
+ "model" "props_urban\fence_cover001_64.mdl"
+ "set" "rides_short"
+ }
+ "short_top_block"
+ {
+ "origin" "-2496.688232 -3847.620117 32.031250"
+ "rotation" "0 -90 0"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ "set" "rides_short"
+ }
+ "stairs_trains"
+ {
+ "origin" "-600.644897 520.514068 -82.156204"
+ "rotation" "0.000000 -90.962295 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors\wood_stairs_120.mdl"
+ }
+ "stairs_trains2"
+ {
+ "origin" "-600.644897 665.611511 20.675038"
+ "rotation" "0.000000 -90.962295 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors\wood_stairs_120.mdl"
+ }
+ "train_pole"
+ {
+ "origin" "-2723.161621 -784.884704 134.031250"
+ "rotation" "80.000000 172.499984 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_c17\utilitypole01d.mdl"
+ }
+ }
+ "inputs"
+ {
+ "coop_prop" "kill"
+ "anv_mapfixes_dispcollision_fairgrounds" "Kill"
+ "func_breakable" "Break"
+ "anv_mapfixes_cliprework_beanbinninga" "Kill"
+ "coop_blocker" "Kill"
+ "!3749406" "Kill"
+ "!3762835" "Kill"
+ "tol_clip_brush" "Kill"
+ }
+ }
+ "c2m3_coaster"
+ {
+ "spawnpoint" "2829.782958 2042.384155 21.309265"
+ "defaultset" "large"
+ "ents"
+ {
+ "SAFEROOM_BLOCK_PROP"
+ {
+ "origin" "3012.181884 2051.005371 60.447525"
+ "rotation" "0.000000 -175.885253 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "VENT_SUS_1"
+ {
+ "origin" "437.521789 3700.031250 208.031250"
+ "rotation" "0.000000 -151.672363 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_foliage\flower_barrel.mdl"
+ }
+ "VENT_SUS_2"
+ {
+ "origin" "179.974365 3701.934082 218.263107"
+ "rotation" "0.000000 93.777389 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_waterfront\footlocker01.mdl"
+ }
+ "COASTER_STOP"
+ {
+ "origin" "-1971.579467 2021.431396 0.031250"
+ "rotation" "0.000000 -168.560409 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles\deliveryvan_armored.mdl"
+ }
+ "COASTER_STOP_BLOCKER"
+ {
+ "origin" "-1816.031250 2094.495849 18.641880"
+ "type" "env_physics_blocker"
+ "scale" "20 20 100"
+ }
+ "END_PORTAL_INBOUNDS"
+ {
+ "origin" "-111.468742 3868.442138 -30.968750"
+ "type" "_portal_xen"
+ "offset" "-218.711853 3872.825927 -16.254243"
+ }
+ "END_PORTAL_OUTBOUNDS"
+ {
+ "origin" "-175.322891 3874.135742 -25.896236"
+ "type" "_portal_xen"
+ "offset" "-6.273283 3868.246337 -39.968750"
+ }
+ "ENT_PORTAL_OUTBOUNDS"
+ {
+ "origin" "781.968750 5089.447265 -12.105030"
+ "type" "_portal_xen"
+ "offset" "848.368774 4996.333496 44.031250"
+ }
+ "ENT_PORTAL_INBOUNDS"
+ {
+ "origin" "818.531250 5120.259765 5.968750"
+ "type" "_portal_xen"
+ "offset" "693.952026 5122.255859 2.038572"
+ "set" "large"
+ }
+ "NO_JUMP_HOLE_PROP"
+ {
+ "origin" "298.292388 3772.014892 200.059875"
+ "rotation" "-84.000000 90.560409 -10.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_militia\sheetrock_leaning.mdl"
+ "set" "short"
+ }
+ "NO_JUMP_WALL_PROP"
+ {
+ "origin" "-60.321926 3621.998046 208.031250"
+ "rotation" "0.000000 177.283248 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_assault\box_stack1.mdl"
+ "set" "short"
+ }
+ }
+ "inputs"
+ {
+ "finale_alarm_sound" "Kill"
+ "relay_start_onslaught" "Trigger"
+ "prop_gate_coaster" "Kill"
+ "navblock_coop" "Kill"
+ "func_detail_blocker" "Kill"
+ "brushes_coop" "Kill"
+ "func_brush" "Kill"
+ "breakwall" "Break"
+ }
+ }
+ "c2m4_barns"
+ {
+ "ents"
+ {
+ "gate_stop"
+ {
+ "origin" "-2251.308349 1434.023315 -255.968750"
+ "scale" "20 100 100"
+ }
+ "lol"
+ {
+ "origin" "-255.596389 712.626953 -205.968750"
+ "rotation" "0.000000 180.269416 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_teenangst.mdl"
+ }
+ }
+ "inputs"
+ {
+ "brushes_coop" "Kill"
+ "clips_coop" "Kill"
+ "navblock_coop" "Kill"
+ "props_coop" "Kill"
+ "minifinale_gates_door1" "Lock"
+ "minifinale_gates_door1" "Close"
+ "minifinale_gates_door2" "Lock"
+ "minifinale_gates_door2" "Close"
+ "minifinale_gates_door3" "Lock"
+ "minifinale_gates_door3" "Close"
+ "minifinale_gates_door4" "Lock"
+ "minifinale_gates_door4" "Close"
+ "minifinale_gates_door5" "Lock"
+ "minifinale_gates_door5" "Close"
+ "minifinale_gates_door6" "Lock"
+ "minifinale_gates_door6" "Close"
+ }
+ }
+ "c1m2_streets"
+ {
+ "climbing" "off"
+ "sets"
+ {
+ "cola"
+ {
+ "spawnpoint" "-5427.254882 938.835754 568.031250"
+ }
+ }
+ "ents"
+ {
+ "A_PROP"
+ {
+ "origin" "-2536 2258 0"
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2"
+ {
+ "origin" "-2536 2418 0"
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster.mdl"
+ "rotation" "0 0 0"
+ }
+ "B_PROP"
+ {
+ "origin" "-2305 2159 0"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "B_PROP2"
+ {
+ "origin" "-2305 2159 40"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "B_PROP3"
+ {
+ "origin" "-2305 2200 0"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "C_PROP"
+ {
+ "origin" "-4377.309570 1749.962646 80.593964"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 10 0"
+ }
+ "C_PROP2"
+ {
+ "origin" " -4383.500488 2161.401611 226.530548"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 10 0"
+ }
+ "C_PROP2"
+ {
+ "origin" " -4383.500488 2161.401611 266.530548"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 10 0"
+ }
+ "C_PROP2"
+ {
+ "origin" " -4383.500488 2121.401611 226.530548"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 10 0"
+ }
+ "D_Prop"
+ {
+ "origin" "-5170.352051 870.512817 465.251526"
+ "type" "prop_dynamic"
+ "model" "props_street/police_barricade.mdl"
+ "rotation" "0 180 0"
+ }
+ "D"
+ {
+ "origin" "-5180.282227 905.176453 540.750977"
+ "scale" "80 70 80"
+ }
+ "E_Prop"
+ {
+ "origin" "1399.475464 2483.173096 572.186157"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "E_Prop2"
+ {
+ "origin" "1315.670288 2500.615234 670.690247"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "BUSH_BLOCK"
+ {
+ "origin" "800.609313 2733.161376 695.719726"
+ "scale" "190 50 100"
+ }
+ "G_Prop"
+ {
+ "origin" "-2219.452637 1219.065308 2.395943"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 90 0"
+ }
+ "cola_replace"
+ {
+ "origin" "-7376.00 -1338.00 395.00"
+ "type" "prop_physics_multiplayer"
+ "model" "w_models/weapons/w_cola.mdl"
+ "rotation" "0 0 0"
+ }
+ "fence"
+ {
+ "origin" "-5458.898437 823.603088 610.031250"
+ "rotation" "0.000000 -89.520973 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_urban\fence002_128.mdl"
+ }
+ "fence_stop"
+ {
+ "origin" "-5250.609375 824.685974 746.281250"
+ "scale" "60 10 80"
+ }
+ "lol"
+ {
+ "origin" "-7634.699218 -373.631134 752.381225"
+ "rotation" "90.000000 -90.269416 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_teenangst.mdl"
+ }
+ "tug"
+ {
+ "origin" "-5836.837890 2780.815917 391.636169"
+ "rotation" "0.000000 -90.999050 -15.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles\boat_rescue_tug.mdl"
+ }
+ }
+ "inputs"
+ {
+ "store_door01_dynamic" "open"
+ "store_door02_dynamic" "open"
+ "store_alarm_generic" "StopSound"
+ "store_alarm_generic" "Kill"
+ "cola" "Kill"
+ "!100452" "_setteam"
+ "InstanceAuto36-gunshop.ent" "Disable"
+ "InstanceAuto36-stairwell.ent" "Disable"
+ "InstanceAuto36-stairwell.ent" "Disable"
+ "stripmall_door1_breakable" "Break"
+ "stripmall_door2_breakable" "Break"
+ "tanker_destroy_relay" "Trigger"
+ }
+ }
+ "c1m4_atrium"
+ {
+ "spawnpoint" "-4440.582519 -3930.253417 136.031250"
+ "ents"
+ {
+ "exitportalwarp"
+ {
+ "origin" "-4445.884277 -2288.304687 30.806552"
+ "scale" "40 65 80"
+ "offset" "0 60 0"
+ "type" "_relportal"
+ }
+ "lol"
+ {
+ "origin" "-5760.802246 -3997.028320 1024.031250"
+ "rotation" "0.608940 26.964090 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_teenangst.mdl"
+ }
+ "lol2"
+ {
+ "origin" "-3363.302001 -4017.320068 744.781250"
+ "rotation" "0.608940 159.964090 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_namvet.mdl"
+ }
+ "lol3"
+ {
+ "origin" "-5184.031250 -2790.462402 280.031250"
+ "rotation" "0.000000 0.649614 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_biker.mdl"
+ }
+ "lol4"
+ {
+ "origin" "-3024.509521 -4495.127929 536.031250"
+ "rotation" "0.000000 123.649614 0.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_manager.mdl"
+ }
+ "lol4_block"
+ {
+ "origin" "-3024.509521 -4495.127929 536.031250"
+ "scale" "40 25 100"
+ }
+ "cheater_warp"
+ {
+ "origin" "-3295.968750 -4299.645019 650.031250"
+ "type" "_portal"
+ "scale" "40 25 10"
+ "offset" "-3358.754394 -4298.374511 640"
+ }
+ "gnome"
+ {
+ "origin" "-4735.599609 -3408.180175 86.600860"
+ "rotation" "59.756366 -110.296585 0.000000"
+ "type" "prop_physics_multiplayer"
+ "model" "props_junk/gnome.mdl"
+ }
+ }
+ "inputs"
+ {
+ "anv_mapfixes_collision_atrium" "Kill"
+ "elevator" "SetMaxSpeed 1000"
+ "elevator" "MoveToFloor bottom"
+ "event_elevator_deny" "Kill"
+ "exitdoor_portal" "Trigger"
+ "fx_intro" "Kill"
+ "fade_outro_3" "Kill"
+ "camera_outro_wide" "Disable"
+ "camera_outro_wide" "Kill"
+ "camera_outro_tele" "Disable"
+ "camera_outro_tele" "Kill"
+ "trigger_finale" "Kill"
+ "trigger_finale" "Kill"
+ "escape_3" "Enable"
+ "escape_4" "Enable"
+ "escape_2" "Enable"
+ "escape_6" "Enable"
+ "escape_7" "Enable"
+ "escape_1" "Enable"
+ "env_player_blocker" "Kill"
+ "env_physics_blocker" "Kill"
+ "gas_nozzle" "Kill"
+ "relay_outro_endseq" "Trigger"
+ "cam_selector_2" "Trigger"
+ "exitdoor_portal" "Open"
+ "mall_directory" "Enable"
+ "charger_hurt" "Kill"
+ }
+ }
+ "c8m5_rooftop"
+ {
+ "ents"
+ {
+ "A_PROP"
+ {
+ "origin" "7255 8925 6085"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2"
+ {
+ "origin" "7255 8925 6125"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP3"
+ {
+ "origin" "7300 8925 6085"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ }
+ }
+ "c8m2_subway"
+ {
+ "ents"
+ {
+ "A_PROP"
+ {
+ "origin" "7498 3020 18"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2"
+ {
+ "origin" "7342 3020 130"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/wood_stairs_120.mdl"
+ "rotation" "0 0 0"
+ }
+ "C"
+ {
+ "origin" "8670 4958 200"
+ "scale" "50 700 200"
+ "type" "env_physics_blocker"
+ }
+ "B_PROP"
+ {
+ "origin" "8480 4970 15"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/semi_trailer_wrecked.mdl"
+ "rotation" "0 -25 -2"
+ }
+ "B_PROP2"
+ {
+ "origin" "8595 5355 12"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/taxi_rural.mdl"
+ "rotation" "0 -25 3"
+ }
+ "B_PROP3"
+ {
+ "origin" "8393 4642 12"
+ "type" "prop_dynamic"
+ "model" "props_junk/trashcluster01b_corner.mdl"
+ "rotation" "0 0 0"
+ }
+ }
+ }
+ "c11m3_garage"
+ {
+ "ents"
+ {
+ "A_PROP"
+ {
+ "origin" "-6055 -2213 12"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2"
+ {
+ "origin" "-6055 -2213 52"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP3"
+ {
+ "origin" "-6055 -2213 92"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROPB"
+ {
+ "origin" "-6055 -2253 12"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2B"
+ {
+ "origin" "-6055 -2253 52"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROPC"
+ {
+ "origin" "-6095 -2213 12"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2C"
+ {
+ "origin" "-6095 -2213 52"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "A_PROP2D"
+ {
+ "origin" "-6095 -2253 12"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ "rotation" "0 0 0"
+ }
+ "B_PROP"
+ {
+ "origin" "-2326.5 2005 29"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/taxi_rural.mdl"
+ "rotation" "0 180 -10"
+ }
+ "B"
+ {
+ "origin" "-2396.5 2005 29"
+ "scale" "100 5 150"
+ "type" "env_physics_blocker"
+ }
+ "C_PROP2"
+ {
+ "origin" "-2165.216797 1856.723877 16"
+ "rotation" "0 0 0 "
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster_2.mdl"
+ }
+ "C_PROP3"
+ {
+ "origin" "-2165.216797 1946.723877 16"
+ "rotation" "0 0 0 "
+ "type" "prop_dynamic"
+ "model" "props_junk/dumpster_2.mdl"
+ }
+ "C"
+ {
+ "origin" "-2210.216797 1900.723877 35"
+ "scale" "15 100 100"
+ "type" "env_physics_blocker"
+ }
+ "gnome"
+ {
+
+ "origin" "-5489.493164 1160.628540 36.031250"
+ "rotation" "0.000000 90.606277 0.000000"
+ "type" "prop_physics_multiplayer"
+ "model" "props_junk/gnome.mdl"
+ }
+ }
+ "inputs"
+ {
+ "construction_clip" "kill"
+ "fuel_barricade" "kill"
+ "barricade_gas_can" "kill"
+ "fuel_barricade_break1" "kill"
+ "fuel_barricade_break2" "kill"
+ "fuel_barricade_break3" "kill"
+ "door_exitl" "Lock"
+ "door_exitr" "Lock"
+ }
+ }
+ "c11m4_terminal"
+ {
+ "spawnpoint" "-482.813659 3566.486572 296.031250"
+ "sets"
+ {
+ "terminal"
+ {
+ "spawnpoint" "1811.834716 1570.712402 264.607604"
+ }
+ }
+ "ents"
+ {
+ "BAG_HOLE_A"
+ {
+ "origin" "382.787200 2708.387207 40.031250"
+ "rotation" "0.000000 -174.077285 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_unique/airport/luggage_pile1.mdl"
+ }
+ "BAG_HOLE_B"
+ {
+ "origin" "402.307434 2415.856201 40.031250"
+ "rotation" "0.000000 -174.077285 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_unique/airport/luggage_pile1.mdl"
+ }
+ "BAG_HOLE_C"
+ {
+ "origin" "401.137786 2110.304199 40.031250"
+ "rotation" "0.000000 -174.077285 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_unique/airport/luggage_pile1.mdl"
+ }
+ "DETECTOR_NO_DETECT"
+ {
+ "origin" "1023.898742 1750.977294 16.031250"
+ "scale" "20 650 300"
+ "set" "terminal"
+ }
+ "DETECTOR_PROP"
+ {
+ "origin" "1030.929931 1755.157714 37.031250"
+ "rotation" "90 0 0"
+ "type" "prop_dynamic"
+ "model" "props_interiors\chairs_airport.mdl"
+ "set" "terminal"
+ }
+ "lol"
+ {
+ "origin" "2350.819335 1851.536376 152.235565"
+ "rotation" "10.137485 -178.424728 15.000000"
+ "type" "prop_dynamic"
+ "model" "survivors/survivor_teenangst.mdl"
+ "set" "terminal"
+ }
+ }
+ "inputs"
+ {
+ "van_blocker" "Kill"
+ "van_start_relay" "Trigger"
+ "!3098419" "Kill"
+ "breakwall01" "Break"
+ "func_breakable" "Kill"
+ "breakwall01_illusionary" "Kill"
+ "!6802112" "Open"
+ "!6765323" "Kill"
+ "!6765365" "Kill"
+ "securityalarmlight1" "TurnOn"
+ "securityspotlight1" "LightOn"
+ "securityrotator1" "StopSound"
+ "securityalarmbase1" "Skin 1"
+ "securityalarmsprite1" "ShowSprite"
+ "alarm_safety_relay" "Kill"
+ "env_soundscape" "Kill"
+ }
+ }
+ "c12m1_hilltop"
+ {
+ "sets"
+ {
+ "A"
+ {
+ "spawnpoint" "-6506.025878 -6803.962402 377.974670"
+ }
+ }
+ }
+ "c12m4_barn"
+ {
+ "spawnpoint" "10523.914062 -6057.256347 -63.968750"
+ "ents"
+ {
+ "BRIDGE_STOP"
+ {
+ "origin" "10485.244140 -3690.727294 -60.199607"
+ "rotation" "0.000000 -87.237983 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/barricade001_128_reference.mdl"
+ }
+ "BRIDGE_STOP2"
+ {
+ "origin" "10403.553710 -3663.791503 -63.968750"
+ "rotation" "0.000000 89.303184 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_street/police_barricade.mdl"
+ }
+ "BRIDGE_BLOCK"
+ {
+ "origin" "10463 -3604 -63"
+ "scale" "120 100 200"
+ "type" "env_physics_blocker"
+ }
+ "FENCE_SKIP_HELPER"
+ {
+ "origin" "11317.451171 -4665.616210 -365.052124"
+ "rotation" "0.895275 90.865699 15.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles\deliveryvan_glass.mdl"
+ }
+ "FENCE_SKIP_HELPER"
+ {
+ "origin" "11317.451171 -4665.616210 -365.052124"
+ "rotation" "0.895275 90.865699 15.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles\deliveryvan.mdl"
+ }
+ "FENCE_SKIP_HELPER_B"
+ {
+ "origin" "11358.471679 -4625.372070 -259.812072"
+ "rotation" "15.114483 0.347351 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "FENCE_SKIP_HELPER_B2_TOP"
+ {
+ "origin" "11358.471679 -4625.372070 -220.812072"
+ "rotation" "15.114483 0.347351 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "FENCE_SKIP_HELPER_B2_TOP2"
+ {
+ "origin" "11368.471679 -4625.372070 -170.812072"
+ "rotation" "15.114483 0.347351 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\cs_militia\footlocker01_closed.mdl"
+ }
+ "FENCE_SKIP_HELPER_B3"
+ {
+ "origin" "11318.471679 -4625.372070 -249.812072"
+ "rotation" "15.114483 0.347351 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "FENCE_SKIP_EXIT_STAIRS"
+ {
+ "origin" "11307.600585 -4320.291992 -325.535629"
+ "rotation" "0.901843 90.274330 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/stairs_house_01.mdl"
+ }
+ "FENCE_SKIP_EXIT_STAIRS_2"
+ {
+ "origin" "11306.600585 -4108.039062 -498.862701"
+ "rotation" "0.901843 90.274330 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_exteriors/stairs_house_01.mdl"
+ }
+ "FENCE_SKIP_EXIT_STAIRS_SUPPORT"
+ {
+
+ "origin" "11324.499023 -4397.913574 -469.508117"
+ "rotation" "0 0 0"
+ "type" "prop_dynamic"
+ "model" "props_interiors\concretepillar01.mdl"
+ }
+ "FENCE_SKIP_EXIT_STAIRS_SUPPORT"
+ {
+ "origin" "11324.499023 -4397.913574 -341.508117"
+ "rotation" "0 0 0"
+ "type" "prop_dynamic"
+ "model" "props_interiors\concretepillar01.mdl"
+ }
+ "MY_SKIP_SUPPORT"
+ {
+ "origin" "11070.869140 -5625.584960 -65.968738"
+ "rotation" "0 0 0"
+ "type" "prop_dynamic"
+ "model" "props_swamp\plank001b_192.mdl"
+ }
+ "HOUSE_PLANKS"
+ {
+ "origin" "11070.869140 -5817.584960 -65.968738"
+ "rotation" "0 0 0"
+ "type" "prop_dynamic"
+ "model" "props_swamp\plank001b_192.mdl"
+ }
+ "HOUSE_PLANKS"
+ {
+ "origin" "11070.869140 -6009.24960 -65.968738"
+ "rotation" "0 0 0"
+ "type" "prop_dynamic"
+ "model" "props_swamp\plank001b_192.mdl"
+ }
+ "ROOF_ACCESS"
+ {
+ "origin" "10692.570312 -7545.357910 -76.285079"
+ "rotation" "0.000000 -105.753463 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\de_train\pallet_barrels.mdl"
+ }
+ "ROOF_ACCESS_TOP"
+ {
+ "origin" "10692.570312 -7545.357910 -26.285079"
+ "rotation" "0.000000 -105.753463 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\de_train\pallet_barrels.mdl"
+ }
+ "ROOF_ACCESS_2"
+ {
+ "origin" "10692.479492 -7470.440917 -76.285079"
+ "rotation" "0.000000 -105.753463 0.000000"
+ "type" "prop_dynamic"
+ "model" "props\de_train\pallet_barrels.mdl"
+ }
+ "OUT_OF_BOUNDS_ROOF"
+ {
+ "origin" "10630.428710 -7433.587890 274.640625"
+ "rotation" "86.179300 -90.960174 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_c17\utilitypole01d.mdl"
+ "set" "outbounds"
+ }
+ "ROOF_HELPER"
+ {
+ "origin" "10693.650390 -7695.398925 195.193389"
+ "rotation" "54.007286 -84.799293 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "BLOCK_SPAWN"
+ {
+ "type" "env_physics_blocker"
+ "origin" "10222.888671 -8366.800781 233.956771"
+ "scale" "55 400 300"
+ }
+
+ "MYPROP"
+ {
+ "origin" "10693.677734 -7559.968750 25.075805"
+ "rotation" "0.000000 0.139984 0.000000"
+ "type" "_lantern"
+ "model" "props_unique/spawn_apartment/lantern.mdl"
+ }
+ }
+ }
+ "c13m2_southpinestream"
+ {
+ "spawnpoint" "7472.512695 2728.908203 454.170593"
+ "sets"
+ {
+ "A"
+ {
+ "spawnpoint" "631.415039 3729.930664 329.250244"
+ }
+ }
+ "ents"
+ {
+ "A_HELPER"
+ {
+ "origin" "3266.013671 2010.126708 458.291046"
+ "rotation" "0.000000 148.362182 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "FENCE_JUMPER"
+ {
+ "origin" "1832.684692 2264.726562 422.658752"
+ "rotation" "0.000000 70.022712 -4.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/cement_truck01.mdl"
+ }
+ "RETURNER"
+ {
+ "origin" "539.416015 2654.438476 177.077484"
+ "rotation" "-30.582356 8.396564 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/airplane_piperwreck.mdl"
+ }
+ "RETURNER_SUPPORT_A"
+ {
+ "origin" "630.816955 2635.709228 196.630294"
+ "rotation" "-8.000000 120.049987 -32.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/car005a.mdl"
+ }
+ "RETURNER_SUPPORT_B"
+ {
+ "origin" "539.403564 2561.882568 129.099700"
+ "rotation" "-30.000000 32.022949 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_vehicles/car001a_phy.mdl"
+ }
+ "WALL"
+ {
+ "origin" "-837.842651 5280.024414 272.031250"
+ "rotation" "0.202026 -89.108253 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_fortifications/concrete_wall001_96_reference.mdl"
+ }
+ "WALL_BLOCK"
+ {
+ "origin" "-837.842651 5280.024414 272.031250"
+ "type" "env_physics_blocker"
+ "scale" "66 26 200"
+ }
+ "RETURN_A"
+ {
+ "origin" "3874.732421 1896.033325 405.846710"
+ "rotation" "0.000000 37.927692 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_crates/static_crate_40.mdl"
+ }
+ "SPAWN_BLOCK_PROP"
+ {
+ "origin" "7883.347167 3302.165527 534.600952"
+ "rotation" "0.000000 -5.696259 0.000000"
+ "type" "prop_dynamic"
+ "model" "props_wasteland/rock_cliff01.mdl"
+ }
+ "SPAWN_BLOCK"
+ {
+
+ "origin" "7848.883300 3287.961914 794.680236"
+ "type" "env_physics_blocker"
+ "scale" "900 900 900"
+ }
+ "TANKER_SKIP"
+ {
+ "origin" "443.717864 4325.977050 497.610931"
+ "type" "env_physics_blocker"
+ "scale" "100 100 150"
+ }
+ "TANKER_SKIP_2"
+ {
+ "origin" "673.124267 4100.726562 558.114318"
+ "type" "env_physics_blocker"
+ "scale" "100 100 150"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/data/prophunt/maps.cfg b/data/prophunt/maps.cfg
new file mode 100644
index 0000000..1324fa5
--- /dev/null
+++ b/data/prophunt/maps.cfg
@@ -0,0 +1,28 @@
+"prophunt"
+{
+ "c1m1_hotel"
+ {
+ "props"
+ {
+ "SOFA_1"
+ {
+ "model" "props_urban/hotel_chair001.mdl"
+ "origin" "1532.456787 4609 1184"
+ "rotation" "0 323.5 0"
+ }
+ "SOFA_2"
+ {
+ "origin" "1649 4529 1184"
+ "rotation" "0 170 0"
+ "model" "props_urban/hotel_chair001.mdl"
+ }
+ }
+ }
+ "c8m1_apartments"
+ {
+ "props"
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/data/prophunt/props.cfg b/data/prophunt/props.cfg
new file mode 100644
index 0000000..c524e38
--- /dev/null
+++ b/data/prophunt/props.cfg
@@ -0,0 +1,23 @@
+"props"
+{
+ "props/cs_office/Fire_Extinguisher.mdl" "5"
+ "props_urban/ashtray_stand001.mdl" "5"
+ "props_furniture/hotel_chair.mdl" "10"
+ "props_urban/hotel_chair001.mdl" "20"
+ "props_interiors/tv.mdl" "10"
+ "props_downtown/ironing_board.mdl" "15"
+ "props_urban/hotel_lamp001.mdl" "10"
+ "props_windows/hotel_window_glass001.mdl" "30"
+ "props/cs_office/shelves_metal1.mdl" "50"
+ "props/cs_office/shelves_metal.mdl" "50"
+ "props_downtown/dresser.mdl" "50"
+ "props_interiors_Hotel_Cart.mdl" "40"
+ "props_downtown/side_table.mdl" "10"
+ "props_interiors/ac_wallunit.mdl" "30"
+ "props_downtown/bed_motel01.mdl" "50"
+ "props_interiors/coffee_table_oval.mdl" "20"
+ "props_downtown/mini_fridge.mdl" "10"
+ "props_interiors/fridge_mini.mdl" "10"
+ "props/cs_office/vending_machine.mdl" "50"
+ "props_interiors/toilet.mdl" "30"
+}
\ No newline at end of file
diff --git a/data/randomizer/c1m1_hotel.json b/data/randomizer/c1m1_hotel.json
new file mode 100644
index 0000000..43398dc
--- /dev/null
+++ b/data/randomizer/c1m1_hotel.json
@@ -0,0 +1,26 @@
+{
+ "group1": {
+ "chance": 0.1,
+ "exclusions": ["group2"],
+ "variants": [
+ {
+ "weight": 1,
+ "entities": [
+
+ {
+ "origin": [1421.24, 5780.23, 2881.16],
+ "angles": [0.00, 0.00, 0.00],
+ "size": [5.00, 5.00, 5.00],
+ "model": "models/props/cs_assault/forklift.mdl"
+ },
+ {
+ "origin": [1139.59, 5685.23, 2883.25],
+ "angles": [0.00, 0.00, 0.00],
+ "size": [5.00, 5.00, 5.00],
+ "model": "models/props_unique/airportdeparturescreen01.mdl"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/randomizer/c8m1_apartment.json b/data/randomizer/c8m1_apartment.json
new file mode 100644
index 0000000..f9ae71b
--- /dev/null
+++ b/data/randomizer/c8m1_apartment.json
@@ -0,0 +1,123 @@
+{
+ "alleyskip": {
+ "chance": 0.30,
+ "variants": [
+ {
+ "weight": 1,
+ "entities": [
+ {
+ "model": "models/props_urban/fire_escape_wide_lower.mdl",
+ "origin": [2203.81, 2381.96, 212.84],
+ "angles": [0.00, 1.07, 0.00],
+ "size": [181.27, 2.22, 132.22]
+ },
+ {
+ "model": "models/props_vehicles/ambulance.mdl",
+ "origin": [2317.06, 2282.30, 16.03],
+ "angles": [0.00, 270.39, 0.00],
+ "size": [90.09, 115.60, 109.48]
+ },
+ {
+ "model": "models/props/cs_militia/boxes_garage_lower.mdl",
+ "origin": [2265.46, 2308.65, 124.13],
+ "angles": [0.00, 92.14, 0.00],
+ "size": [37.36, 35.15, 65.06]
+ },
+ {
+ "model": "models/props_fortifications/barricade001_128_reference.mdl",
+ "origin": [2013.47, 2254.53, 15.83],
+ "angles": [0.00, 178.81, 0.00],
+ "size": [21.75, 48.25, 144.25]
+ },
+ {
+ "model": "models/props_fortifications/barricade001_64_reference.mdl",
+ "origin": [2001.55, 2345.92, 15.51],
+ "angles": [0.00, 177.42, 0.00],
+ "size": [24.25, 24.25, 144.25]
+ }
+ ]
+ }
+ ]
+ },
+ "mainblock": {
+ "chance": 0.5,
+ "variants": [
+ {
+ "weight": 1,
+ "entities": [
+ {
+ "model": "models/props_street/police_barricade2.mdl",
+ "origin": [2744.79, 3975.41, 16.03],
+ "angles": [0.00, 105.00, 0.00],
+ "size": [28.70, 71.14, 119.31]
+ },
+ {
+ "model": "models/props_street/police_barricade_496in.mdl",
+ "origin": [2428.55, 3960.12, 8.03],
+ "angles": [0.00, 89.61, 0.00],
+ "size": [28.77, 245.37, 119.31]
+ },
+ {
+ "model": "models/props_street/police_barricade2.mdl",
+ "origin": [2120.48, 3963.20, 16.03],
+ "angles": [0.00, 87.27, 0.00],
+ "size": [28.70, 71.14, 119.31]
+ }
+ ]
+ }
+ ]
+ },
+ "subwayblock": {
+ "chance": 0.2,
+ "variants": [
+ {
+ "entities": [
+ {
+ "model": "models/props_vehicles/hmmwv.mdl",
+ "origin": [2755.60, 4139.53, 12.72],
+ "angles": [0.00, -180.00, 0.00],
+ "size": [57.97, 105.86, 124.61]
+ }
+ ]
+ },
+ {
+ "entities": [
+ {
+ "model": "models/props_vehicles/pickup_truck_78.mdl",
+ "origin": [2755.60, 4139.53, 12.72],
+ "angles": [0.00, -180.00, 0.00],
+ "size": [57.97, 105.86, 124.61]
+ }
+ ]
+ }
+ ]
+ },
+ "doorblock": {
+ "chance": 0.2,
+ "variants": [
+ {
+ "weight": 2,
+ "entities": [
+ {
+ "model": "models/props_junk/dumpster.mdl",
+ "origin": [1519.27, 2626.97, 55.79],
+ "angles": [0.00, -86.23, 90.00],
+ "size": [26.37, 40.17, 54.13]
+ }
+ ]
+ },
+ {
+ "weight": 1,
+ "entities": [
+ {
+ "model": "models/props_junk/dumpster.mdl",
+ "origin": [1498.78, 2630.72, 16.03],
+ "angles": [0.00, 3.76, 0.00],
+ "size": [26.37, 40.17, 54.13]
+ }
+ ]
+ }
+ ]
+ }
+}
+
diff --git a/data/walls_data.cfg b/data/walls_data.cfg
new file mode 100644
index 0000000..a38dc1a
--- /dev/null
+++ b/data/walls_data.cfg
@@ -0,0 +1,50 @@
+"WallData"
+{
+ "Shelter Fence"
+ {
+ "sizes"
+ {
+ "Small (64u)"
+ {
+ "model" "models/props_urban/fence_cover001_64.mdl"
+ }
+ "Medium (128u)" "models/props_urban/fence_cover001_128.mdl"
+ "Large (256u)" "models/props_urban/fence_cover001_256.mdl"
+ }
+ }
+ "Chain Link"
+ {
+ "sizes"
+ {
+ "Small (64u)" "models/props_urban/fence001_64.mdl"
+ "Medium (128u)" "models/props_urban/fence002_128.mdl"
+ "Large (256u)" "models/props_urban/fence002_256.mdl"
+ }
+ }
+ "Crash Barrier"
+ {
+ "sizes"
+ {
+ "Small" "models/props_fortifications/concrete_barrier01.mdl"
+ "Medium (96u)" "models/props_fortifications/concrete_barrier001_96_reference.mdl"
+ "Large (128u)" "models/props_fortifications/concrete_barrier001_128_reference.mdl"
+ }
+ }
+ "Sandbags"
+ {
+ "sizes"
+ {
+ "Normal (6l)" "models/props_fortifications/sandbags_line2.mdl"
+ "Corner (4l)" "models/props_fortifications/sandbags_corner3.mdl"
+ "Large (6l)" "models/props_fortifications/sandbags_corner2.mdl"
+ }
+ }
+ "Wooden Wall"
+ {
+ "sizes"
+ {
+ "Medium (128u)" "models/props_update/wood_128.mdl"
+ "Large (128u)" "models/props_update/wood_256.mdl"
+ }
+ }
+}
\ No newline at end of file
diff --git a/gamedata/feedthetrolls.txt b/gamedata/feedthetrolls.txt
new file mode 100644
index 0000000..e9c3305
--- /dev/null
+++ b/gamedata/feedthetrolls.txt
@@ -0,0 +1,16 @@
+"Games"
+{
+ "left4dead2"
+ {
+ "Signatures"
+ {
+ "WitchAttack::WitchAttack"
+ {
+ /* 55 8B EC 53 56 8B F1 C7 46 04 ? ? ? ? C7 46 2C 01 00 00 00 33 DB 33 C0 89 46 20 33 C9 89 4E 24 57 33 D2 89 56 28 33 FF 89 5E 0C 89 5E 10 89 5E 14 89 5E 18 89 5E 1C 89 5E 08 66 89 5E 30 89 7E 2C C7 06 ? ? ? ? C7 46 04 ? ? ? ? 53 */
+
+ "windows" "\x55\x8B\xEC\x53\x56\x8B\xF1\xC7\x46\x04\x2A\x2A\x2A\x2A\xC7\x46\x2C\x01\x00\x00\x00\x33\xDB\x33\xC0\x89\x46\x20\x33\xC9\x89\x4E\x24\x57\x33\xD2\x89\x56\x28\x33\xFF\x89\x5E\x0C\x89\x5E\x10\x89\x5E\x14\x89\x5E\x18\x89\x5E\x1C\x89\x5E\x08\x66\x89\x5E\x30\x89\x7E\x2C\xC7\x06\x2A\x2A\x2A\x2A\xC7\x46\x04\x2A\x2A\x2A\x2A\x53"
+ "linux" "@_ZN11WitchAttackC2EP11CBaseEntity"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/gamedata/l4d2_turret.txt b/gamedata/l4d2_turret.txt
new file mode 100644
index 0000000..b2d19e6
--- /dev/null
+++ b/gamedata/l4d2_turret.txt
@@ -0,0 +1,31 @@
+"Games"
+{
+ "left4dead2"
+ {
+ "Offsets"
+ {
+ "CBaseAnimating::StudioHdr"
+ {
+ "linux" "68"
+ }
+ }
+ "Signatures"
+ {
+ "CBaseAnimating::LookupPoseParameter"
+ {
+ "library" "server"
+ "linux" "@_ZN14CBaseAnimating19LookupPoseParameterEP10CStudioHdrPKc"
+ }
+ "ModelSoundsCache_LoadModel"
+ {
+ "library" "server"
+ "linux" "@_Z26ModelSoundsCache_LoadModelPKc"
+ }
+ "ModelSoundsCache_FinishModel"
+ {
+ "library" "server"
+ "linux" "@_Z28ModelSoundsCache_FinishModelP10CStudioHdr"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/gamedata/l4d2tools.txt b/gamedata/l4d2tools.txt
new file mode 100644
index 0000000..7b69321
--- /dev/null
+++ b/gamedata/l4d2tools.txt
@@ -0,0 +1,58 @@
+"Games" {
+
+ "#default" {
+ "Offsets" {
+ "OS" { // Thank you Sammy-ROCK!
+ "windows" "1"
+ "linux" "0"
+ }
+ }
+ }
+
+ // Big thanks to cravenge and Spirit_12 on AlliedModders for being awesome :D
+
+ "left4dead2" {
+ "Signatures" {
+ "State_Transition" {
+ "library" "server"
+ "linux" "@_ZN9CCSPlayer16State_TransitionE13CSPlayerState"
+ "windows" "\x55\x8B\xEC\x56\x8B\xF1\x8B\x86\x2A\x2A\x2A\x2A\x57\x8B\x7D\x2A\x85\xC0\x74\x2A\x83"
+ /* 55 8B EC 56 8B F1 8B 86 ? ? ? ? 57 8B 7D ? 85 C0 74 ? 83 */
+ }
+
+ "TakeOverZombieBot" {
+ "library" "server"
+ "linux" "@_ZN13CTerrorPlayer17TakeOverZombieBotEPS_"
+ "windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x2A\x2A\xA1\xD8\x2A\x2A\x2A\x33\xC5\x89\x45\x2A\x53\x8B\x5D\x2A\x80"
+ /* 55 8B EC 81 EC ? ? ? ? ? D8 ? ? ? 33 C5 89 45 ? 53 8B 5D ? 80 */
+ }
+
+ "RoundRespawn" {
+ "library" "server"
+ "linux" "@_ZN13CTerrorPlayer12RoundRespawnEv"
+ "windows" "\x56\x8B\xF1\xE8\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x84\xC0\x75"
+ /* 56 8B F1 E8 ? ? ? ? E8 ? ? ? ? 84 C0 75 */
+ }
+
+ "SetHumanSpec" {
+ "library" "server"
+ "linux" "@_ZN11SurvivorBot17SetHumanSpectatorEP13CTerrorPlayer"
+ "windows" "\x55\x8B\xEC\x56\x8B\xF1\x83\xBE\x2A\x2A\x2A\x2A\x00\x7E\x07\x32\xC0\x5E\x5D\xC2\x04\x00\x8B\x0D"
+ /* 55 8B EC 56 8B F1 83 BE ? ? ? ? 00 7E 07 32 C0 5E 5D C2 04 00 8B 0D */
+ }
+ "TakeOverBot" {
+ "library" "server"
+ "linux" "@_ZN13CTerrorPlayer11TakeOverBotEb"
+ "windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\xFC\x53\x56\x8D\x85"
+ /* 55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 53 56 8D 85 */
+ }
+ "GoAwayFromKeyboard"
+ {
+ "library" "server"
+ "linux" "@_ZN13CTerrorPlayer18GoAwayFromKeyboardEv"
+ "windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x53\x56\x57\x8B\xF1\x8B\x06\x8B\x90\xC8\x08\x00\x00"
+ /* ? ? ? ? ? ? 53 56 57 8B F1 8B 06 8B 90 C8 08 00 00 */
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/200IQBots_FlyYouFools.smx b/plugins/200IQBots_FlyYouFools.smx
new file mode 100644
index 0000000..35a605d
Binary files /dev/null and b/plugins/200IQBots_FlyYouFools.smx differ
diff --git a/plugins/AutoWarpBot.smx b/plugins/AutoWarpBot.smx
new file mode 100644
index 0000000..c3d1b6e
Binary files /dev/null and b/plugins/AutoWarpBot.smx differ
diff --git a/plugins/BetterWitchAvoidance.smx b/plugins/BetterWitchAvoidance.smx
new file mode 100644
index 0000000..be11d0c
Binary files /dev/null and b/plugins/BetterWitchAvoidance.smx differ
diff --git a/plugins/Block3Person.smx b/plugins/Block3Person.smx
new file mode 100644
index 0000000..220db70
Binary files /dev/null and b/plugins/Block3Person.smx differ
diff --git a/plugins/BumpMineGiver.smx b/plugins/BumpMineGiver.smx
new file mode 100644
index 0000000..04a48d7
Binary files /dev/null and b/plugins/BumpMineGiver.smx differ
diff --git a/plugins/CSGOTroll.smx b/plugins/CSGOTroll.smx
new file mode 100644
index 0000000..5cae2d4
Binary files /dev/null and b/plugins/CSGOTroll.smx differ
diff --git a/plugins/GrabEnt.smx b/plugins/GrabEnt.smx
new file mode 100644
index 0000000..191128c
Binary files /dev/null and b/plugins/GrabEnt.smx differ
diff --git a/plugins/L4D2FFKickProtection.smx b/plugins/L4D2FFKickProtection.smx
new file mode 100644
index 0000000..1c119ff
Binary files /dev/null and b/plugins/L4D2FFKickProtection.smx differ
diff --git a/plugins/L4D2PreventBotMovement.smx b/plugins/L4D2PreventBotMovement.smx
new file mode 100644
index 0000000..2311438
Binary files /dev/null and b/plugins/L4D2PreventBotMovement.smx differ
diff --git a/plugins/L4D2Template.smx b/plugins/L4D2Template.smx
new file mode 100644
index 0000000..ae518c7
Binary files /dev/null and b/plugins/L4D2Template.smx differ
diff --git a/plugins/L4D2Tools.smx b/plugins/L4D2Tools.smx
new file mode 100644
index 0000000..9bd90f0
Binary files /dev/null and b/plugins/L4D2Tools.smx differ
diff --git a/plugins/abm.smx b/plugins/abm.smx
new file mode 100644
index 0000000..b316310
Binary files /dev/null and b/plugins/abm.smx differ
diff --git a/plugins/activitymonitor.smx b/plugins/activitymonitor.smx
new file mode 100644
index 0000000..69217ec
Binary files /dev/null and b/plugins/activitymonitor.smx differ
diff --git a/plugins/adminpanel.smx b/plugins/adminpanel.smx
new file mode 100644
index 0000000..3c84337
Binary files /dev/null and b/plugins/adminpanel.smx differ
diff --git a/plugins/basechat.smx b/plugins/basechat.smx
new file mode 100644
index 0000000..c81a652
Binary files /dev/null and b/plugins/basechat.smx differ
diff --git a/plugins/csgo-knifehp.smx b/plugins/csgo-knifehp.smx
new file mode 100644
index 0000000..c3192c7
Binary files /dev/null and b/plugins/csgo-knifehp.smx differ
diff --git a/plugins/csgo-misc.smx b/plugins/csgo-misc.smx
new file mode 100644
index 0000000..fff0de8
Binary files /dev/null and b/plugins/csgo-misc.smx differ
diff --git a/plugins/globalbans.smx b/plugins/globalbans.smx
new file mode 100644
index 0000000..ffb780b
Binary files /dev/null and b/plugins/globalbans.smx differ
diff --git a/plugins/jutils.smx b/plugins/jutils.smx
new file mode 100644
index 0000000..bba3408
Binary files /dev/null and b/plugins/jutils.smx differ
diff --git a/plugins/l4d2-info-cmd.smx b/plugins/l4d2-info-cmd.smx
new file mode 100644
index 0000000..c898c5c
Binary files /dev/null and b/plugins/l4d2-info-cmd.smx differ
diff --git a/plugins/l4d2-manual-director.smx b/plugins/l4d2-manual-director.smx
new file mode 100644
index 0000000..c2e41db
Binary files /dev/null and b/plugins/l4d2-manual-director.smx differ
diff --git a/plugins/l4d2_TKStopper.smx b/plugins/l4d2_TKStopper.smx
new file mode 100644
index 0000000..36f6926
Binary files /dev/null and b/plugins/l4d2_TKStopper.smx differ
diff --git a/plugins/l4d2_ai_minigun.smx b/plugins/l4d2_ai_minigun.smx
new file mode 100644
index 0000000..b1c23b1
Binary files /dev/null and b/plugins/l4d2_ai_minigun.smx differ
diff --git a/plugins/l4d2_ai_tweaks.smx b/plugins/l4d2_ai_tweaks.smx
new file mode 100644
index 0000000..0f561d8
Binary files /dev/null and b/plugins/l4d2_ai_tweaks.smx differ
diff --git a/plugins/l4d2_autobotcrown.smx b/plugins/l4d2_autobotcrown.smx
new file mode 100644
index 0000000..0d41327
Binary files /dev/null and b/plugins/l4d2_autobotcrown.smx differ
diff --git a/plugins/l4d2_autorestart.smx b/plugins/l4d2_autorestart.smx
new file mode 100644
index 0000000..1a6a5cd
Binary files /dev/null and b/plugins/l4d2_autorestart.smx differ
diff --git a/plugins/l4d2_avoid_minigun.smx b/plugins/l4d2_avoid_minigun.smx
new file mode 100644
index 0000000..b8ebfd6
Binary files /dev/null and b/plugins/l4d2_avoid_minigun.smx differ
diff --git a/plugins/l4d2_baseball.smx b/plugins/l4d2_baseball.smx
new file mode 100644
index 0000000..623f516
Binary files /dev/null and b/plugins/l4d2_baseball.smx differ
diff --git a/plugins/l4d2_crescendo_control.smx b/plugins/l4d2_crescendo_control.smx
new file mode 100644
index 0000000..511a4d8
Binary files /dev/null and b/plugins/l4d2_crescendo_control.smx differ
diff --git a/plugins/l4d2_detections.smx b/plugins/l4d2_detections.smx
new file mode 100644
index 0000000..29e8fae
Binary files /dev/null and b/plugins/l4d2_detections.smx differ
diff --git a/plugins/l4d2_drop_secondary.smx b/plugins/l4d2_drop_secondary.smx
new file mode 100644
index 0000000..d67c828
Binary files /dev/null and b/plugins/l4d2_drop_secondary.smx differ
diff --git a/plugins/l4d2_extraplayeritems.smx b/plugins/l4d2_extraplayeritems.smx
new file mode 100644
index 0000000..c00f92c
Binary files /dev/null and b/plugins/l4d2_extraplayeritems.smx differ
diff --git a/plugins/l4d2_feedthetrolls.smx b/plugins/l4d2_feedthetrolls.smx
new file mode 100644
index 0000000..1003165
Binary files /dev/null and b/plugins/l4d2_feedthetrolls.smx differ
diff --git a/plugins/l4d2_forceset.smx b/plugins/l4d2_forceset.smx
new file mode 100644
index 0000000..71c5021
Binary files /dev/null and b/plugins/l4d2_forceset.smx differ
diff --git a/plugins/l4d2_guesswho.smx b/plugins/l4d2_guesswho.smx
new file mode 100644
index 0000000..267d711
Binary files /dev/null and b/plugins/l4d2_guesswho.smx differ
diff --git a/plugins/l4d2_hats.smx b/plugins/l4d2_hats.smx
new file mode 100644
index 0000000..fc5d48a
Binary files /dev/null and b/plugins/l4d2_hats.smx differ
diff --git a/plugins/l4d2_hideandseek.smx b/plugins/l4d2_hideandseek.smx
new file mode 100644
index 0000000..c688540
Binary files /dev/null and b/plugins/l4d2_hideandseek.smx differ
diff --git a/plugins/l4d2_perms.smx b/plugins/l4d2_perms.smx
new file mode 100644
index 0000000..c7bee8e
Binary files /dev/null and b/plugins/l4d2_perms.smx differ
diff --git a/plugins/l4d2_population_control.smx b/plugins/l4d2_population_control.smx
new file mode 100644
index 0000000..87c9c97
Binary files /dev/null and b/plugins/l4d2_population_control.smx differ
diff --git a/plugins/l4d2_prophunt.smx b/plugins/l4d2_prophunt.smx
new file mode 100644
index 0000000..d6f4a1a
Binary files /dev/null and b/plugins/l4d2_prophunt.smx differ
diff --git a/plugins/l4d2_randomizer.smx b/plugins/l4d2_randomizer.smx
new file mode 100644
index 0000000..3d318d2
Binary files /dev/null and b/plugins/l4d2_randomizer.smx differ
diff --git a/plugins/l4d2_rollback.smx b/plugins/l4d2_rollback.smx
new file mode 100644
index 0000000..ca615c2
Binary files /dev/null and b/plugins/l4d2_rollback.smx differ
diff --git a/plugins/l4d2_sb_fix.smx b/plugins/l4d2_sb_fix.smx
new file mode 100644
index 0000000..e550586
Binary files /dev/null and b/plugins/l4d2_sb_fix.smx differ
diff --git a/plugins/l4d2_skill_detect.smx b/plugins/l4d2_skill_detect.smx
new file mode 100644
index 0000000..c1eca08
Binary files /dev/null and b/plugins/l4d2_skill_detect.smx differ
diff --git a/plugins/l4d2_spawn_props.smx b/plugins/l4d2_spawn_props.smx
new file mode 100644
index 0000000..89de08d
Binary files /dev/null and b/plugins/l4d2_spawn_props.smx differ
diff --git a/plugins/l4d2_special_control.smx b/plugins/l4d2_special_control.smx
new file mode 100644
index 0000000..1421f26
Binary files /dev/null and b/plugins/l4d2_special_control.smx differ
diff --git a/plugins/l4d2_swarm.smx b/plugins/l4d2_swarm.smx
new file mode 100644
index 0000000..bdb7389
Binary files /dev/null and b/plugins/l4d2_swarm.smx differ
diff --git a/plugins/l4d2_tank_priority.smx b/plugins/l4d2_tank_priority.smx
new file mode 100644
index 0000000..9a69bef
Binary files /dev/null and b/plugins/l4d2_tank_priority.smx differ
diff --git a/plugins/l4d2_target_test.smx b/plugins/l4d2_target_test.smx
new file mode 100644
index 0000000..12792f7
Binary files /dev/null and b/plugins/l4d2_target_test.smx differ
diff --git a/plugins/l4d2_turret.smx b/plugins/l4d2_turret.smx
new file mode 100644
index 0000000..f8e87f1
Binary files /dev/null and b/plugins/l4d2_turret.smx differ
diff --git a/plugins/l4d2_vocalize_control.smx b/plugins/l4d2_vocalize_control.smx
new file mode 100644
index 0000000..5c09fda
Binary files /dev/null and b/plugins/l4d2_vocalize_control.smx differ
diff --git a/plugins/l4d2_witch_force_attack_cmd.smx b/plugins/l4d2_witch_force_attack_cmd.smx
new file mode 100644
index 0000000..599f950
Binary files /dev/null and b/plugins/l4d2_witch_force_attack_cmd.smx differ
diff --git a/plugins/l4d_anti_rush.smx b/plugins/l4d_anti_rush.smx
new file mode 100644
index 0000000..5450b62
Binary files /dev/null and b/plugins/l4d_anti_rush.smx differ
diff --git a/plugins/l4d_reservetheserver.smx b/plugins/l4d_reservetheserver.smx
new file mode 100644
index 0000000..89cc467
Binary files /dev/null and b/plugins/l4d_reservetheserver.smx differ
diff --git a/plugins/l4d_survivor_identity_fix.smx b/plugins/l4d_survivor_identity_fix.smx
new file mode 100644
index 0000000..c3835b9
Binary files /dev/null and b/plugins/l4d_survivor_identity_fix.smx differ
diff --git a/plugins/l4d_tank_hp_sprite.smx b/plugins/l4d_tank_hp_sprite.smx
new file mode 100644
index 0000000..5461441
Binary files /dev/null and b/plugins/l4d_tank_hp_sprite.smx differ
diff --git a/plugins/l4d_target_override.smx b/plugins/l4d_target_override.smx
new file mode 100644
index 0000000..c3887a0
Binary files /dev/null and b/plugins/l4d_target_override.smx differ
diff --git a/plugins/l4dunreservelobby.smx b/plugins/l4dunreservelobby.smx
new file mode 100644
index 0000000..8e92eca
Binary files /dev/null and b/plugins/l4dunreservelobby.smx differ
diff --git a/plugins/left4dhooks.smx b/plugins/left4dhooks.smx
new file mode 100644
index 0000000..9d923b1
Binary files /dev/null and b/plugins/left4dhooks.smx differ
diff --git a/plugins/misc.smx b/plugins/misc.smx
new file mode 100644
index 0000000..07b1162
Binary files /dev/null and b/plugins/misc.smx differ
diff --git a/plugins/sceneprocessor.smx b/plugins/sceneprocessor.smx
new file mode 100644
index 0000000..80f9f3d
Binary files /dev/null and b/plugins/sceneprocessor.smx differ
diff --git a/plugins/sm_namespamblock.smx b/plugins/sm_namespamblock.smx
new file mode 100644
index 0000000..bb0d236
Binary files /dev/null and b/plugins/sm_namespamblock.smx differ
diff --git a/plugins/sm_player_notes.smx b/plugins/sm_player_notes.smx
new file mode 100644
index 0000000..0c73931
Binary files /dev/null and b/plugins/sm_player_notes.smx differ
diff --git a/plugins/sm_player_recorder.smx b/plugins/sm_player_recorder.smx
new file mode 100644
index 0000000..ff4be29
Binary files /dev/null and b/plugins/sm_player_recorder.smx differ
diff --git a/plugins/spray_control.smx b/plugins/spray_control.smx
new file mode 100644
index 0000000..8697727
Binary files /dev/null and b/plugins/spray_control.smx differ
diff --git a/scripting/200IQBots_FlyYouFools.sp b/scripting/200IQBots_FlyYouFools.sp
new file mode 100644
index 0000000..e648d07
--- /dev/null
+++ b/scripting/200IQBots_FlyYouFools.sp
@@ -0,0 +1,202 @@
+#pragma semicolon 1
+#include
+#include
+#define PLUGIN_VERSION "1.5"
+#pragma newdecls required
+
+#define MAX_TANK_DISTANCE_FROM_SURVIVOR 1000
+#define MAX_TANK_DIST_SQUARED MAX_TANK_DISTANCE_FROM_SURVIVOR^2
+
+//#define DEBUG
+
+static bool bEscapeReady = false;
+static int iAliveTanks;
+static bool bIsTank[MAXPLAYERS+1];
+
+public Plugin myinfo =
+{
+ name = "Fly You Fools",
+ author = "ConnerRia & Jackzmc",
+ description = "Survivor bots will retreat from tank. Improved version.",
+ version = PLUGIN_VERSION,
+ url = "N/A"
+}
+
+
+public void OnPluginStart()
+{
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
+ {
+ SetFailState("Plugin supports Left 4 Dead series only.");
+ }
+
+ CreateConVar("FlyYouFools_Version", PLUGIN_VERSION, "FlyYouFools Version", FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_DONTRECORD);
+
+ HookEvent("map_transition", Event_RoundStart, EventHookMode_PostNoCopy);
+ HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
+ HookEvent("tank_spawn", Event_TankSpawn);
+ HookEvent("tank_killed", Event_TankDeath);
+ HookEvent("finale_vehicle_incoming", Event_FinaleArriving, EventHookMode_PostNoCopy);
+}
+
+
+public void OnMapStart() {
+ resetPlugin();
+}
+
+public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
+ resetPlugin();
+}
+
+public void Event_TankSpawn(Event event, const char[] name, bool dontBroadcast) {
+ int userID = GetClientOfUserId(GetEventInt(event, "userid"));
+ bIsTank[userID] = true;
+ if(iAliveTanks == 0 && !bEscapeReady) {
+ CreateTimer(0.1, BotControlTimerV2, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ }
+ iAliveTanks++;
+}
+public void Event_TankDeath(Event event, const char[] name, bool dontBroadcast) {
+ int userID = GetClientOfUserId(GetEventInt(event, "userid"));
+ bIsTank[userID] = false;
+ iAliveTanks--;
+}
+public void Event_FinaleArriving(Event event, const char[] name, bool dontBroadcast) {
+ bEscapeReady = true;
+}
+/*
+CommandABot:
+0 -> ATTACK
+1 -> MOVETO
+2 -> RUN AWAY
+3 -> RESET
+
+New logic overview:
+1. Loop all valid survivors
+2. Loop all tanks per survivor
+3. Find the closest tank
+4. Retreat if in close range (~300 units)
+*/
+Action BotControlTimerV2(Handle timer)
+{
+ //remove timer once tanks no longer exists/are all dead or finale escape vehicle arrived
+ if(bEscapeReady || iAliveTanks == 0) {
+ //Check if there is any existing bots, if escape NOT ready
+ if(!bEscapeReady) FindExistingTank();
+ return Plugin_Stop;
+ }
+ if(iAliveTanks == 0 || GetClientCount(true) == 0) return Plugin_Continue;
+
+ int botHealth, closestTank, tank_target;
+ float BotPosition[3], TankPosition[3], smallestDistance, distanceFromSurvivor;
+
+ //Loop all players, finding survivors. (survivor team, bots, not tank.)
+ for (int i = 1; i <= MaxClients; i++) {
+ if (IsClientInGame(i) && IsPlayerAlive(i) && IsFakeClient(i) && !bIsTank[i] && GetClientTeam(i) == 2) {
+ //Grab health of bot and current position
+ botHealth = GetClientHealth(i);
+ GetClientAbsOrigin(i, BotPosition);
+
+ smallestDistance = 0.0;
+ closestTank = -1;
+ //Loop all players, finding tanks (alive, bot, tank)
+ for(int tankID = 1; tankID <= MaxClients; tankID++) {
+ if (IsClientInGame(tankID) && IsPlayerAlive(tankID) && IsFakeClient(tankID) && bIsTank[tankID]) {
+ //Check if tank has a target. tank_target will be -1 if not activated
+ tank_target = GetEntPropEnt(tankID, Prop_Send, "m_lookatPlayer", 0);
+ if(tank_target > -1) {
+
+ //Fetch the tank's position
+ GetClientAbsOrigin(tankID, TankPosition);
+ //Get distance to survivor, and compare to get closest tank
+ distanceFromSurvivor = GetVectorDistance(BotPosition, TankPosition, true);
+ if(distanceFromSurvivor <= MAX_TANK_DIST_SQUARED && smallestDistance > distanceFromSurvivor || smallestDistance == 0.0) {
+ smallestDistance = distanceFromSurvivor;
+ closestTank = tankID;
+ }
+
+ }
+ }
+ }
+ //If the closest tank exists (-1 means no tank.) and is close, avoid.
+ if(closestTank > -1 && smallestDistance <= 300 && botHealth >= 40) {
+ //L4D2_RunScript("CommandABot({cmd=3,bot=GetPlayerFromUserID(%i)})", GetClientUserId(i));
+ L4D2_RunScript("CommandABot({cmd=2,bot=GetPlayerFromUserID(%i),target=GetPlayerFromUserID(%i)})", GetClientUserId(i), GetClientUserId(closestTank));
+ }
+ }
+ }
+ return Plugin_Continue;
+}
+
+void resetPlugin() {
+ bEscapeReady = false;
+ iAliveTanks = 0;
+ FindExistingTank();
+}
+
+
+void FindExistingTank() {
+ //Loop all valid clients, check if they a BOT and an infected. Check for a name that contains "Tank"
+ iAliveTanks = 0;
+ char name[16];
+ for (int i = 1; i < MaxClients+1 ;i++) {
+ if(IsClientInGame(i) && IsFakeClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3) {
+ GetClientName(i, name, sizeof(name));
+ if(StrContains(name, "Tank", true) > -1) {
+ bIsTank[i] = true;
+ //PrintToServer("Found existing tank: %N (%i)", i, i);
+ iAliveTanks++;
+ continue;
+ }
+ }
+ bIsTank[i] = false;
+
+ }
+ if(iAliveTanks > 0) {
+ CreateTimer(0.1, BotControlTimerV2, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ }
+}
+
+//Credits to Timocop for the stock :D
+/**
+* Runs a single line of vscript code.
+* NOTE: Dont use the "script" console command, it starts a new instance and leaks memory. Use this instead!
+*
+* @param sCode The code to run.
+* @noreturn
+*/
+stock void L4D2_RunScript(const char[] sCode, any ...) {
+ static int iScriptLogic = INVALID_ENT_REFERENCE;
+ if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
+ iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
+ if(iScriptLogic == INVALID_ENT_REFERENCE|| !IsValidEntity(iScriptLogic))
+ SetFailState("Could not create 'logic_script'");
+
+ DispatchSpawn(iScriptLogic);
+ }
+
+ static char sBuffer[512];
+ VFormat(sBuffer, sizeof(sBuffer), sCode, 2);
+
+ SetVariantString(sBuffer);
+ AcceptEntityInput(iScriptLogic, "RunScriptCode");
+}
+/**
+* Get the classname of an item in a slot
+*
+* @param client The client to check inventory from
+* @param slot The item slot index
+* @param buffer The char[] buffer to set text to
+* @param bufferSize The size of the buffer
+* @return True if item, false if no item
+*/
+stock bool GetItemSlotClassName(int client, int slot, char[] buffer, int bufferSize) {
+ int item = GetPlayerWeaponSlot(client, slot);
+ if(item > -1) {
+ GetEdictClassname(item, buffer, bufferSize);
+ return true;
+ }else{
+ return false;
+ }
+}
diff --git a/scripting/AutoWarpBot.sp b/scripting/AutoWarpBot.sp
new file mode 100644
index 0000000..d79d17d
--- /dev/null
+++ b/scripting/AutoWarpBot.sp
@@ -0,0 +1,81 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+#define DEBUG
+
+#define PLUGIN_NAME "L4D2 Auto Warp Survivors"
+#define PLUGIN_DESCRIPTION ""
+#define PLUGIN_AUTHOR "jackzmc"
+#define PLUGIN_VERSION "1.0"
+#define PLUGIN_URL ""
+
+#include
+#include
+//#include
+
+#pragma newdecls required
+
+public Plugin myinfo =
+{
+ name = PLUGIN_NAME,
+ author = PLUGIN_AUTHOR,
+ description = PLUGIN_DESCRIPTION,
+ version = PLUGIN_VERSION,
+ url = PLUGIN_URL
+};
+
+ConVar g_EnteredCheckpoint;
+
+public void OnPluginStart()
+{
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
+ {
+ SetFailState("This plugin is for L4D/L4D2 only.");
+ }
+ HookEvent("player_entered_checkpoint", Event_PlayerEnteredCheckpoint);
+ HookEvent("player_left_start_area",Event_RoundStart);
+ g_EnteredCheckpoint = CreateConVar("awb_status", "0", "Get status of plugin", FCVAR_SPONLY | FCVAR_DONTRECORD, true, 0.0, true, 1.0);
+}
+
+public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
+ if(g_EnteredCheckpoint.BoolValue) g_EnteredCheckpoint.BoolValue = false;
+}
+public void Event_PlayerEnteredCheckpoint(Event event, const char[] name, bool dontBroadcast) {
+ PrintToChatAll("boolvalue %d | client %d", g_EnteredCheckpoint.BoolValue, GetClientOfUserId(event.GetInt("userid")));
+ if(!g_EnteredCheckpoint.BoolValue) {
+
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ bool playersLeft = false;
+ for (int i = 1; i < MaxClients;i++) {
+ if (client == i) continue;
+ if (!IsClientInGame(i)) continue;
+ if (GetClientTeam(i) != 2) continue;
+ PrintToChatAll("playersLeft: %d . clientr %d", playersLeft, i);
+ if(!IsFakeClient(i)) {
+ playersLeft = true;
+ break;
+ }
+ }
+ if(!playersLeft) {
+ g_EnteredCheckpoint.BoolValue = true;
+ CheatCommand(client,"warp_all_survivors_to_checkpoint","","");
+ }
+ }
+}
+stock bool IsPlayerIncapped(int client)
+{
+ if (GetEntProp(client, Prop_Send, "m_isIncapacitated", 1)) return true;
+ return false;
+}
+
+stock void CheatCommand(int client, char[] command, char[] argument1, char[] argument2)
+{
+ int userFlags = GetUserFlagBits(client);
+ SetUserFlagBits(client, ADMFLAG_ROOT);
+ int flags = GetCommandFlags(command);
+ SetCommandFlags(command, flags & ~FCVAR_CHEAT);
+ FakeClientCommand(client, "%s %s %s", command, argument1, argument2);
+ SetCommandFlags(command, flags);
+ SetUserFlagBits(client, userFlags);
+}
\ No newline at end of file
diff --git a/scripting/BetterWitchAvoidance.sp b/scripting/BetterWitchAvoidance.sp
new file mode 100644
index 0000000..095c9a2
--- /dev/null
+++ b/scripting/BetterWitchAvoidance.sp
@@ -0,0 +1,126 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+#define PLUGIN_NAME "Better Witch Avoidance"
+#define PLUGIN_DESCRIPTION "Makes bots avoid witches better"
+#define PLUGIN_AUTHOR "jackzmc"
+#define PLUGIN_VERSION "1.0"
+#define PLUGIN_URL ""
+
+#include
+#include
+//#include
+
+
+public Plugin myinfo =
+{
+ name = PLUGIN_NAME,
+ author = PLUGIN_AUTHOR,
+ description = PLUGIN_DESCRIPTION,
+ version = PLUGIN_VERSION,
+ url = PLUGIN_URL
+};
+
+static int iWitchEntity = -1;
+
+public void OnPluginStart()
+{
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
+ {
+ SetFailState("This plugin is for L4D/L4D2 only.");
+ }
+ HookEvent("witch_spawn", Event_WitchSpawn);
+ HookEvent("witch_killed", Event_WitchKilled, EventHookMode_PostNoCopy);
+ //todo: existing witch find
+ //m_rage
+}
+
+
+public void Event_WitchSpawn(Event event, const char[] name, bool dontBroadcast) {
+ iWitchEntity = GetEventInt(event, "witchid");
+ CreateTimer(0.1, BotControlTimer, _, TIMER_REPEAT);
+}
+
+public void Event_WitchKilled(Event event, const char[] name, bool dontBroadcast) {
+ iWitchEntity = -1;
+}
+public Action BotControlTimer(Handle timer)
+{
+ //remove timer once witch is dead
+ if(iWitchEntity == -1 || !IsValidEntity(iWitchEntity)) {
+ //incase any other witches are available
+ //FindExistingWitch();
+ return Plugin_Stop;
+ }
+ if(HasEntProp(iWitchEntity,Prop_Send,"m_rage")) {
+ float witch_anger = GetEntPropFloat(iWitchEntity, Prop_Send, "m_rage", 0);
+ if(FloatCompare(witch_anger,0.4) == 1) {
+ float WitchPosition[3];
+ GetEntPropVector(iWitchEntity, Prop_Send, "m_vecOrigin", WitchPosition);
+ for (int i = 1; i < MaxClients; i++) {
+ if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2 && IsFakeClient(i)) {
+ float BotPosition[3];
+ GetClientAbsOrigin(i, BotPosition);
+
+ float distance = GetVectorDistance(BotPosition, WitchPosition);
+ if(distance <= 120 || (FloatCompare(witch_anger,0.6) == 1 && distance <= 220)) {
+ L4D2_RunScript("CommandABot({cmd=2,bot=GetPlayerFromUserID(%i),target=EntIndexToHScript(%d)})", GetClientUserId(i), iWitchEntity);
+ }
+ }
+ }
+ }
+ }
+
+ return Plugin_Handled;
+}
+public void FindExistingWitch() {
+ for (int i = MaxClients + 1; i < GetMaxEntities(); i++) {
+ if(IsValidEntity(i)) {
+ char name[16];
+ GetEntityClassname(i, name, sizeof(name));
+ if(StrContains(name,"Witch",true) > -1) {
+ PrintToServer("Found existing witch with id %d", i);
+ iWitchEntity = i;
+ CreateTimer(0.1, BotControlTimer, _, TIMER_REPEAT);
+ break;
+ }
+ }
+
+ }
+}
+
+//Credits to Timocop for the stock :D
+/**
+* Runs a single line of vscript code.
+* NOTE: Dont use the "script" console command, it starts a new instance and leaks memory. Use this instead!
+*
+* @param sCode The code to run.
+* @noreturn
+*/
+stock void L4D2_RunScript(const char[] sCode, any ...) {
+ static int iScriptLogic = INVALID_ENT_REFERENCE;
+ if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
+ iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
+ if(iScriptLogic == INVALID_ENT_REFERENCE|| !IsValidEntity(iScriptLogic))
+ SetFailState("Could not create 'logic_script'");
+
+ DispatchSpawn(iScriptLogic);
+ }
+
+ static char sBuffer[512];
+ VFormat(sBuffer, sizeof(sBuffer), sCode, 2);
+
+ SetVariantString(sBuffer);
+ AcceptEntityInput(iScriptLogic, "RunScriptCode");
+}
+stock void ShowHintToAll(const char[] format, any ...) {
+ char buffer[254];
+ VFormat(buffer, sizeof(buffer), format, 2);
+ static int hintInt = 0;
+ if(hintInt >= 9) {
+ PrintHintTextToAll("%s",buffer);
+ hintInt = 0;
+ }
+ hintInt++;
+}
\ No newline at end of file
diff --git a/scripting/Block3Person.sp b/scripting/Block3Person.sp
new file mode 100644
index 0000000..cdf3a96
--- /dev/null
+++ b/scripting/Block3Person.sp
@@ -0,0 +1,123 @@
+#define PLUGIN_VERSION "1.1"
+
+#pragma semicolon 1
+#pragma newdecls required
+
+#include
+
+public Plugin myinfo =
+{
+ name = "Block3person",
+ author = "Dragokas",
+ description = "Block 3-rd person view by creating blindness",
+ version = PLUGIN_VERSION,
+ url = "https://github.com/dragokas"
+}
+
+bool aBlinded[MAXPLAYERS];
+UserMsg g_FadeUserMsgId;
+
+static const int BLIND_DURATION = 50;
+
+
+public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
+{
+ char sGameName[12];
+ GetGameFolderName(sGameName, sizeof(sGameName));
+ if( strcmp(sGameName, "left4dead", false) )
+ {
+ strcopy(error, err_max, "Plugin only supports Left 4 Dead 1.");
+ return APLRes_SilentFailure;
+ }
+ g_FadeUserMsgId = GetUserMessageId("Fade");
+ if (g_FadeUserMsgId == INVALID_MESSAGE_ID) {
+ strcopy(error, err_max, "Cannot find Fade user message ID.");
+ return APLRes_SilentFailure;
+ }
+ return APLRes_Success;
+}
+
+public void OnPluginStart()
+{
+ LoadTranslations("Block3Person.phrases");
+ HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
+}
+
+public Action OnRoundStart(Event event, const char[] name, bool dontBroadcast)
+{
+ CreateTimer(0.9, Timer_CheckClientViewState, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
+ return Plugin_Continue;
+}
+
+public Action Timer_CheckClientViewState(Handle timer)
+{
+ for (int i = 1; i <= MaxClients; i++)
+ {
+ if(IsClientInGame(i) && GetClientTeam(i) == 2 && !IsFakeClient(i) && IsPlayerAlive(i))
+ QueryClientConVar(i, "c_thirdpersonshoulder", QueryClientConVarCallback);
+ }
+ return Plugin_Continue;
+}
+
+public void QueryClientConVarCallback(QueryCookie cookie, int client, ConVarQueryResult result, const char[] sCvarName, const char[] bCvarValue)
+{
+ if (StringToInt(bCvarValue) != 0) {
+ if (!aBlinded[client]) {
+ aBlinded[client] = true;
+ BlindClient(client, true);
+ PrintHintText(client, "%t", "Blind_Warning");
+ }
+ } else {
+ if (aBlinded[client]) {
+ aBlinded[client] = false;
+ PrintHintText(client, "%t", "Unblind_tip");
+ BlindClient(client, false);
+ }
+ }
+}
+
+void BlindClient(int target, bool bDoBlind = true)
+{
+ int targets[2];
+ targets[0] = target;
+
+ int holdtime;
+
+ int flags;
+ if (!bDoBlind)
+ {
+ flags = (0x0001 | 0x0010);
+ holdtime = 10000;
+ }
+ else
+ {
+ flags = (0x0002 | 0x0008);
+ holdtime = 10;
+ }
+
+ int color[4] = { 0, 0, 0, 0 };
+ color[3] = 255;
+
+ Handle message = StartMessageEx(g_FadeUserMsgId, targets, 1);
+ if (GetUserMessageType() == UM_Protobuf)
+ {
+ Protobuf pb = UserMessageToProtobuf(message);
+ pb.SetInt("duration", BLIND_DURATION);
+ pb.SetInt("hold_time", holdtime);
+ pb.SetInt("flags", flags);
+ pb.SetColor("clr", color);
+ }
+ else
+ {
+ BfWrite bf = UserMessageToBfWrite(message);
+ bf.WriteShort(BLIND_DURATION);
+ bf.WriteShort(holdtime);
+ bf.WriteShort(flags);
+ bf.WriteByte(color[0]);
+ bf.WriteByte(color[1]);
+ bf.WriteByte(color[2]);
+ bf.WriteByte(color[3]);
+ }
+
+ EndMessage();
+}
\ No newline at end of file
diff --git a/scripting/BumpMineGiver.sp b/scripting/BumpMineGiver.sp
new file mode 100644
index 0000000..73b70e1
--- /dev/null
+++ b/scripting/BumpMineGiver.sp
@@ -0,0 +1,114 @@
+#pragma semicolon 1
+
+#define DEBUG
+
+#define PLUGIN_AUTHOR ""
+#define PLUGIN_VERSION "0.00"
+
+#include
+#include
+#include
+//#include
+
+#pragma newdecls required
+
+ConVar g_bmgTTeam, g_bmgEnabled, g_bmgCmdLimit;
+
+int g_bmgBumpsGiven[MAXPLAYERS+1];
+
+public Plugin myinfo =
+{
+ name = "BumpMineGiver",
+ author = PLUGIN_AUTHOR,
+ description = "",
+ version = PLUGIN_VERSION,
+ url = ""
+};
+
+public void OnPluginStart()
+{
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
+ {
+ SetFailState("This plugin is for CSGO/CSS only.");
+ }
+ g_bmgEnabled = CreateConVar("bmg_enabled", "1", "Should BumpMineGiver be enabled?", FCVAR_NONE, true, 0.0, true, 1.0);
+ g_bmgTTeam = CreateConVar("bmg_restrict_team", "0", "Should BumpMineGiver be restricted to a team? 0 - All, 1 - Terrorists, 2 - CounterTerrorists", FCVAR_NONE, true, 0.0, true, 3.0);
+ g_bmgCmdLimit = CreateConVar("bmg_cmdlimit", "0", "Limit of amount of bumpmines to be given with !bmp. 0: Disabled, -1: Infinity", FCVAR_NONE);
+ HookEvent("round_start", Event_RoundStart);
+ HookEvent("player_spawn", Event_PlayerSpawn);
+
+ RegConsoleCmd("sm_bmp", Command_GiveBMP, "Give yourself a bump mine");
+ RegConsoleCmd("sm_bmg", Command_GiveBMP, "Give yourself a bump mine");
+ RegAdminCmd("sm_givebmp", Command_GiveOthersBMP, ADMFLAG_CHEATS, "Give someone x amount of bump mines. Usage: sm_givebmp ");
+ AutoExecConfig();
+}
+
+public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
+ for (int i = 0; i < sizeof(g_bmgBumpsGiven); i++) {
+ g_bmgBumpsGiven[i] = 0;
+ }
+}
+
+public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
+ if(g_bmgEnabled.BoolValue) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ int wpn_id = GetPlayerWeaponSlot(client, 4);
+ int team = GetClientTeam(client);
+ if(g_bmgTTeam.IntValue > 0) { //1 or 2
+ if (team != g_bmgTTeam.IntValue) return;
+ }
+ if(wpn_id == -1) {
+ GivePlayerItem(client, "weapon_bumpmine");
+ }
+ }
+}
+
+public Action Command_GiveBMP(int client, int args) {
+ if(g_bmgCmdLimit.IntValue == 0) {
+ ReplyToCommand(client, "You have hit the limit of bumpmines");
+ return Plugin_Handled;
+ }
+ //limit is enabled, check
+ if(g_bmgCmdLimit.IntValue > 0) {
+ if(g_bmgBumpsGiven[client] > g_bmgCmdLimit.IntValue) {
+ ReplyToCommand(client, "You have hit the limit of bumpmines");
+ return Plugin_Handled;
+ }
+ }
+ GivePlayerItem(client, "weapon_bumpmine");
+ g_bmgBumpsGiven[client]++;
+ return Plugin_Handled;
+}
+
+public Action Command_GiveOthersBMP(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_givebmp ");
+ }else{
+ char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MAXPLAYERS,
+ COMMAND_FILTER_ALIVE,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ for (int i = 0; i < target_count; i++)
+ {
+ GivePlayerItem(target_list[i], "weapon_bumpmine");
+ LogAction(client, target_list[i], "\"%L\" gave \"%L\" a bumpmine", client, target_list[i]);
+ }
+ }
+ return Plugin_Handled;
+}
\ No newline at end of file
diff --git a/scripting/CSGOTroll.sp b/scripting/CSGOTroll.sp
new file mode 100644
index 0000000..565415d
--- /dev/null
+++ b/scripting/CSGOTroll.sp
@@ -0,0 +1,112 @@
+#pragma semicolon 1
+
+#define DEBUG
+
+#define PLUGIN_AUTHOR ""
+#define PLUGIN_VERSION "0.00"
+
+#include
+#include
+#include
+#include
+
+EngineVersion g_Game;
+ConVar hTrollEnableState, hShotFailPercentage, hTrollTargets, hGunType;
+bool TrollTargets[MAXPLAYERS+1], lateLoaded;
+
+public Plugin myinfo =
+{
+ name = "",
+ author = PLUGIN_AUTHOR,
+ description = "",
+ version = PLUGIN_VERSION,
+ url = ""
+};
+
+public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
+ if(late) {
+ lateLoaded = true;
+ }
+}
+
+public OnPluginStart()
+{
+ g_Game = GetEngineVersion();
+ if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
+ {
+ SetFailState("This plugin is for CSGO/CSS only.");
+ }
+ //convars
+ hTrollEnableState = CreateConVar("troll_enable", "1.0", "Enable troll. 0 -> OFF, 1 -> Shots", FCVAR_NONE, true, 0.0, true, 1.0);
+ hShotFailPercentage = CreateConVar("troll_shot_fail_percentage", "0.4", "The percentage that the troll acts (shots fail). float 0-1", FCVAR_NONE, true, 0.0, true, 1.0);
+ hTrollTargets = CreateConVar("troll_targets", "", "comma seperated list of steamid64 targets (ex: STEAM_0:0:75141700)", FCVAR_NONE);
+ hGunType = CreateConVar("troll_shot_mode", "0", "0 -> ALL Weapons, 1 -> AWP", FCVAR_NONE, true, 0.0, true, 1.0);
+
+ if(lateLoaded) FindExistingVictims();
+}
+
+public void OnClientAuthorized(int client, const char[] auth) {
+ if(hTrollEnableState.IntValue > 0) {
+ if(StrContains(auth, "BOT", true) == -1) {
+ TestForTrollUser(client, auth);
+ }
+ }
+}
+public void OnClientPutInServer(int client) {
+ SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
+}
+public OnClientDisconnect(int client) {
+ TrollTargets[client] = false;
+}
+public void FindExistingVictims() {
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientInGame(i) && IsClientAuthorized(i)) {
+ if(!IsFakeClient(i)) {
+ char auth[64];
+ GetClientAuthId(i, AuthId_Steam2, auth, sizeof(auth));
+ TestForTrollUser(i, auth);
+ }
+ SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
+ }
+ }
+}
+public bool TestForTrollUser(int client, const char[] auth) {
+ char targets[32][8];
+ char raw_targets[64];
+ hTrollTargets.GetString(raw_targets, sizeof(raw_targets));
+ ExplodeString(raw_targets, ",", targets, 8, 32, false);
+ for(int i = 0; i < 8; i++) {
+ if(StrEqual(targets[i], auth, true)) {
+ PrintToServer("Troll victim detected with id %d and steamid %s", client, auth);
+ TrollTargets[client] = true;
+ return true;
+ }
+ }
+ return false;
+}
+public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) {
+ if(hTrollEnableState.IntValue == 1) {
+ if(TrollTargets[attacker]) {
+ bool try_failure = false;
+ char weapon_name[64];
+ GetClientWeapon(victim, weapon_name, sizeof(weapon_name));
+
+ if(hGunType.IntValue == 0) {
+ try_failure = true;
+ }else{
+ if(StrEqual(weapon_name, "weapon_awp", true)) {
+ try_failure = true;
+ }
+
+ }
+ float random_float = GetURandomFloat();
+ if(try_failure) {
+ if(FloatCompare(random_float, hShotFailPercentage.FloatValue) == -1) {
+ damage = 0.0;
+ return Plugin_Handled;
+ }
+ }
+ }
+ }
+ return Plugin_Continue;
+}
\ No newline at end of file
diff --git a/scripting/GrabEnt.sp b/scripting/GrabEnt.sp
new file mode 100644
index 0000000..80c94d1
--- /dev/null
+++ b/scripting/GrabEnt.sp
@@ -0,0 +1,594 @@
+#define DEBUG
+
+#define PLUGIN_AUTHOR "Stugger"
+#define PLUGIN_VERSION "2.2"
+
+#include
+#include
+#include
+#include
+
+public Plugin myinfo =
+{
+ name = "GrabEnt",
+ author = PLUGIN_AUTHOR,
+ description = "Grab then Move, Push/Pull or Rotate the entity you're looking at until released",
+ version = PLUGIN_VERSION,
+ url = ""
+};
+
+int g_pGrabbedEnt[MAXPLAYERS + 1];
+int g_eRotationAxis[MAXPLAYERS + 1] = { -1, ... };
+int g_eOriginalColor[MAXPLAYERS + 1][4];
+
+float g_pLastButtonPress[MAXPLAYERS + 1];
+float g_fGrabOffset[MAXPLAYERS + 1][3];
+float g_fGrabDistance[MAXPLAYERS + 1];
+
+MoveType g_pLastMoveType[MAXPLAYERS + 1];
+bool g_pInRotationMode[MAXPLAYERS + 1];
+bool g_eReleaseFreeze[MAXPLAYERS + 1] = { true, ... };
+bool g_bHighlightEntity[MAXPLAYERS+1];
+
+Handle g_eGrabTimer[MAXPLAYERS+1];
+
+int g_BeamSprite;
+int g_HaloSprite;
+int g_iLaserIndex;
+
+#define MAX_FORBIDDEN_CLASSNAMES 9
+static char FORBIDDEN_CLASSNAMES[MAX_FORBIDDEN_CLASSNAMES][] = {
+ // "env_physics_blocker",
+ // "env_player_blocker",
+ "func_brush",
+ "func_simpleladder",
+ "func_button",
+ "func_elevator",
+ "func_button_timed",
+ "func_movelinear",
+ "func_tracktrain",
+ // "infected",
+ "func_lod",
+ "prop_ragdoll"
+};
+
+#define MAX_FORBIDDEN_MODELS 1
+char FORBIDDEN_MODELS[MAX_FORBIDDEN_MODELS][] = {
+ "models/props_vehicles/c130.mdl",
+};
+
+#define MAX_HIGHLIGHTED_CLASSNAMES 3
+static char HIGHLIGHTED_CLASSNAMES[MAX_HIGHLIGHTED_CLASSNAMES][] = {
+ "env_physics_blocker",
+ "env_player_blocker",
+ "func_brush"
+}
+
+
+public void OnPluginStart()
+{
+ RegAdminCmd("sm_grabent_freeze", Cmd_ReleaseFreeze, ADMFLAG_CHEATS, "<0/1> - Toggle entity freeze/unfreeze on release.");
+ RegAdminCmd("sm_grab", Cmd_Grab, ADMFLAG_CHEATS, "Toggle Grab the entity in your crosshair.");
+ RegAdminCmd("+grabent", Cmd_Grab, ADMFLAG_CHEATS, "Grab the entity in your crosshair.");
+ RegAdminCmd("-grabent", Cmd_Release, ADMFLAG_CHEATS, "Release the grabbed entity.");
+}
+
+public void OnMapStart()
+{
+ g_iLaserIndex = PrecacheModel("materials/sprites/laserbeam.vmt");
+ g_BeamSprite = PrecacheModel("materials/sprites/laser.vmt", true);
+ g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt", true);
+
+ for (int i = 0; i < MAXPLAYERS; i++) {
+ g_pGrabbedEnt[i] = -1;
+ g_eRotationAxis[i] = -1;
+ g_pLastButtonPress[i] = 0.0;
+
+ g_pInRotationMode[i] = false;
+ g_eReleaseFreeze[i] = true;
+
+ g_eGrabTimer[i] = null;
+ }
+}
+public void OnClientDisconnect(client)
+{
+ if (g_pGrabbedEnt[client] != -1 && IsValidEntity(g_pGrabbedEnt[client]))
+ Cmd_Release(client, 0);
+
+ g_eRotationAxis[client] = -1;
+
+ g_pLastButtonPress[client] = 0.0;
+
+ g_pInRotationMode[client] = false;
+ g_eReleaseFreeze[client] = true;
+}
+
+//============================================================================
+// FREEZE SETTING COMMAND //
+//============================================================================
+public Action Cmd_ReleaseFreeze(client, args)
+{
+ if (args < 1) {
+ ReplyToCommand(client, "\x04[SM]\x01 \x05sm_grabent_freeze <0/1>\x01 -- \x050\x01: Entity unfreeze on release, \x051\x01: Entity freeze on release");
+ return Plugin_Handled;
+ }
+
+ char sArg[16];
+ GetCmdArg(1, sArg, sizeof(sArg)); TrimString(sArg);
+
+ if (!StrEqual(sArg, "0") && !StrEqual(sArg, "1")) {
+ ReplyToCommand(client, "\x04[SM]\x01 ERROR: Value can only be either 0 or 1");
+ return Plugin_Handled;
+ }
+
+ g_eReleaseFreeze[client] = StrEqual(sArg, "1");
+
+ PrintToChat(client, "\x04[SM]\x01 Entities will now be \x05%s\x01 on Release!", g_eReleaseFreeze[client] == true ? "Frozen" : "Unfrozen");
+ return Plugin_Handled;
+}
+
+//============================================================================
+// GRAB ENTITY COMMAND //
+//============================================================================
+public Action Cmd_Grab(client, args) {
+ if (client < 1 || client > MaxClients || !IsClientInGame(client))
+ return Plugin_Handled;
+
+ if (g_pGrabbedEnt[client] > 0 && IsValidEntity(g_pGrabbedEnt[client])) {
+ Cmd_Release(client, 0);
+ return Plugin_Handled;
+ }
+
+ // int ent = GetClientAimTarget(client, false);
+ int ent = GetLookingEntity(client, Filter_IgnoreForbidden);
+
+ if (ent == -1 || !IsValidEntity(ent))
+ return Plugin_Handled; //<-- timer to allow search for entity??
+
+ // Grab the parent
+ int parent = GetEntPropEnt(ent, Prop_Data, "m_hParent");
+ if(parent > 0) {
+ ent = parent;
+ }
+ if(!CheckBlacklist(ent)) {
+ return Plugin_Handled;
+ }
+
+ float entOrigin[3], playerGrabOrigin[3];
+ GetEntPropVector(ent, Prop_Send, "m_vecOrigin", entOrigin);
+ GetClientEyePosition(client, playerGrabOrigin);
+
+ g_pGrabbedEnt[client] = ent;
+
+ // Get the point at which the ray first hit the entity
+ float initialRay[3];
+ GetInitialRayPosition(client, initialRay);
+
+ // Calculate the offset between intitial ray hit and the entities origin
+ g_fGrabOffset[client][0] = entOrigin[0] - initialRay[0];
+ g_fGrabOffset[client][1] = entOrigin[1] - initialRay[1];
+ g_fGrabOffset[client][2] = entOrigin[2] - initialRay[2];
+
+ // Calculate the distance between ent and player
+ float xDis = Pow(initialRay[0]-(playerGrabOrigin[0]), 2.0);
+ float yDis = Pow(initialRay[1]-(playerGrabOrigin[1]), 2.0);
+ float zDis = Pow(initialRay[2]-(playerGrabOrigin[2]), 2.0);
+ g_fGrabDistance[client] = SquareRoot((xDis)+(yDis)+(zDis));
+
+ // Get and Store entities original color (useful if colored)
+ int entColor[4];
+ int colorOffset = GetEntSendPropOffs(ent, "m_clrRender");
+
+ if (colorOffset > 0)
+ {
+ entColor[0] = GetEntData(ent, colorOffset, 1);
+ entColor[1] = GetEntData(ent, colorOffset + 1, 1);
+ entColor[2] = GetEntData(ent, colorOffset + 2, 1);
+ entColor[3] = GetEntData(ent, colorOffset + 3, 1);
+ }
+
+ g_eOriginalColor[client][0] = entColor[0];
+ g_eOriginalColor[client][1] = entColor[1];
+ g_eOriginalColor[client][2] = entColor[2];
+ g_eOriginalColor[client][3] = entColor[3];
+
+ // Set entities color to grab color (green and semi-transparent)
+ SetEntityRenderMode(ent, RENDER_TRANSALPHA);
+ SetEntityRenderColor(ent, 0, 255, 0, 235);
+
+ // Freeze entity
+ char sClass[64];
+ GetEntityClassname(ent, sClass, sizeof(sClass)); TrimString(sClass);
+
+ if (StrEqual(sClass, "player", false)) {
+ g_pLastMoveType[ent] = GetEntityMoveType(ent);
+ SetEntityMoveType(ent, MOVETYPE_NONE);
+ } else
+ AcceptEntityInput(ent, "DisableMotion");
+
+
+ g_pLastMoveType[client] = GetEntityMoveType(client);
+ // Disable weapon prior to timer
+ SetWeaponDelay(client, 1.0);
+
+ // Make sure rotation mode can immediately be entered
+ g_pLastButtonPress[client] = GetGameTime() - 2.0;
+ g_pInRotationMode[client] = false;
+
+ g_bHighlightEntity[client] = false;
+ for(int i = 0; i < MAX_HIGHLIGHTED_CLASSNAMES; i++) {
+ if(StrEqual(HIGHLIGHTED_CLASSNAMES[i], sClass)) {
+ g_bHighlightEntity[client] = true;
+ break;
+ }
+ }
+
+ DataPack pack;
+ g_eGrabTimer[client] = CreateDataTimer(0.1, Timer_UpdateGrab, pack, TIMER_REPEAT);
+ pack.WriteCell(client);
+
+ return Plugin_Handled;
+}
+
+//============================================================================
+// TIMER FOR GRAB ENTITY //
+//============================================================================
+public Action Timer_UpdateGrab(Handle timer, DataPack pack) {
+ int client;
+ pack.Reset();
+ client = pack.ReadCell();
+
+ if (!IsValidEntity(client) || client < 1 || client > MaxClients || !IsClientInGame(client))
+ return Plugin_Stop;
+
+ if (g_pGrabbedEnt[client] == -1 || !IsValidEntity(g_pGrabbedEnt[client]))
+ return Plugin_Stop;
+
+ // Continuously delay use of weapon, as to not fire any bullets when pushing/pulling/rotating
+ SetWeaponDelay(client, 1.0);
+
+ if(g_bHighlightEntity[client]) {
+ char targetname[64];
+ GetEntPropString(g_pGrabbedEnt[client], Prop_Data, "m_iName", targetname, sizeof(targetname));
+ PrintCenterText(client, "%s", targetname);
+ GlowEntity(client, g_pGrabbedEnt[client]);
+ }
+
+ // *** Enable/Disable Rotation Mode
+ if (GetClientButtons(client) & IN_RELOAD) {
+ // Avoid instant enable/disable of rotation mode by requiring a one second buffer
+ if (GetGameTime() - g_pLastButtonPress[client] >= 1.0) {
+ g_pLastButtonPress[client] = GetGameTime();
+ g_pInRotationMode[client] = g_pInRotationMode[client] == true ? false : true;
+ PrintToChat(client, "\x04[SM]\x01 Rotation Mode \x05%s\x01", g_pInRotationMode[client] == true ? "Enabled" : "Disabled");
+
+ // Restore the entities color and alpha if enabling
+ if(g_pInRotationMode[client]) {
+ SetEntityRenderColor(g_pGrabbedEnt[client], 255, 255, 255, 255);
+ PrintToChat(client, "\x05[A]\x01 RED \x05[S]\x01 GREEN \x05[D]\x01 BLUE \x05[W]\x01 SHOW RINGS");
+ }
+ // Change back to grabbed color if disabling
+ else
+ SetEntityRenderColor(g_pGrabbedEnt[client], 0, 255, 0, 235);
+ }
+ }
+ // ***In Rotation Mode
+ if (g_pInRotationMode[client]) {
+ SetEntityMoveType(client, MOVETYPE_NONE);
+
+ float ang[3], pos[3], mins[3], maxs[3];
+ GetEntPropVector(g_pGrabbedEnt[client], Prop_Send, "m_angRotation", ang);
+ GetEntPropVector(g_pGrabbedEnt[client], Prop_Send, "m_vecOrigin", pos);
+ GetEntPropVector(g_pGrabbedEnt[client], Prop_Send, "m_vecMins", mins);
+ GetEntPropVector(g_pGrabbedEnt[client], Prop_Send, "m_vecMaxs", maxs);
+
+ // If the entity is a child, it will have a null position, so we'll hesitantly use the parents position
+ int parent = GetEntPropEnt(g_pGrabbedEnt[client], Prop_Data, "m_hMoveParent");
+ if (parent > 0 && IsValidEntity(parent))
+ GetEntPropVector(parent, Prop_Send, "m_vecOrigin", pos);
+
+ // Get rotation axis from button press
+ int buttonPress = GetClientButtons(client);
+ switch(buttonPress) {
+ case IN_FORWARD: {
+ g_eRotationAxis[client] = -1; // [W] = Show Rings
+ PrintToChat(client, "\x04[SM]\x01 Show Rings \x05On\x01");
+ }
+ case IN_MOVELEFT: {
+ g_eRotationAxis[client] = 0; // [A] = x axis
+ PrintToChat(client, "\x04[SM]\x01 Rotation Axis \x05X\x01");
+ }
+ case IN_BACK: {
+ g_eRotationAxis[client] = 1; // [S] = y axis
+ PrintToChat(client, "\x04[SM]\x01 Rotation Axis \x05Y\x01");
+ }
+ case IN_MOVERIGHT: {
+ g_eRotationAxis[client] = 2; // [D] = z axis
+ PrintToChat(client, "\x04[SM]\x01 Rotation Axis \x05Z\x01");
+ }
+ }
+
+
+ // Reset angles when A+S+D is pressed
+ if((buttonPress & IN_MOVELEFT) && (buttonPress & IN_BACK) && (buttonPress & IN_MOVERIGHT)) {
+ ang[0] = 0.0; ang[1] = 0.0; ang[2] = 0.0;
+ g_eRotationAxis[client] = -1;
+ }
+
+ // Largest side should dictate the diameter of the rings
+ float diameter, sendAng[3];
+ diameter = (maxs[0] > maxs[1]) ? (maxs[0] + 10.0) : (maxs[1] + 10.0);
+ diameter = ((maxs[2] + 10.0) > diameter) ? (maxs[2] + 10.0) : diameter;
+
+ // Sending original ang will cause non-stop rotation issue
+ sendAng = ang;
+
+ // Draw rotation rings
+ switch(g_eRotationAxis[client]) {
+ case -1: CreateRing(client, sendAng, pos, diameter, 0, true); // all 3 rings
+ case 0: CreateRing(client, sendAng, pos, diameter, 0, false); // red (x)
+ case 1: CreateRing(client, sendAng, pos, diameter, 1, false); // green (y)
+ case 2: CreateRing(client, sendAng, pos, diameter, 2, false); // blue (z)
+ }
+
+ // Rotate with mouse if on a rotation axis (A,S,D)
+ if (g_eRotationAxis[client] != -1) {
+ // + Rotate
+ if (GetClientButtons(client) & IN_ATTACK)
+ ang[g_eRotationAxis[client]] += 10.0;
+ // - Rotate
+ else if (GetClientButtons(client) & IN_ATTACK2)
+ ang[g_eRotationAxis[client]] -= 10.0;
+ }
+
+ TeleportEntity(g_pGrabbedEnt[client], NULL_VECTOR, ang, NULL_VECTOR);
+ }
+ // ***Not in Rotation Mode
+ if (!g_pInRotationMode[client] || g_eRotationAxis[client] == -1) {
+ // Keep track of player noclip as to avoid forced enable/disable
+ if(!g_pInRotationMode[client]) {
+ SetEntityMoveType(client, g_pLastMoveType[client])
+ }
+ // Push entity (Allowed if we're in rotation mode, not on a rotation axis (-1))
+ if (GetClientButtons(client) & IN_ATTACK)
+ {
+ if (g_fGrabDistance[client] < 80)
+ g_fGrabDistance[client] += 10;
+ else
+ g_fGrabDistance[client] += g_fGrabDistance[client] / 25;
+ }
+ // Pull entity (Allowed if we're in rotation mode, not on a rotation axis (-1))
+ else if (GetClientButtons(client) & IN_ATTACK2 && g_fGrabDistance[client] > 25)
+ {
+ if (g_fGrabDistance[client] < 80)
+ g_fGrabDistance[client] -= 10;
+ else
+ g_fGrabDistance[client] -= g_fGrabDistance[client] / 25;
+ }
+
+ g_eRotationAxis[client] = -1;
+ }
+
+ // *** Runs whether in rotation mode or not
+ float entNewPos[3];
+ int buttons = GetClientButtons(client);
+ GetEntNewPosition(client, entNewPos, buttons & IN_SPEED == 0);
+ entNewPos[0] += g_fGrabOffset[client][0];
+ entNewPos[1] += g_fGrabOffset[client][1];
+ entNewPos[2] += g_fGrabOffset[client][2];
+
+
+ float mins[3];
+ GetEntPropVector(g_pGrabbedEnt[client], Prop_Data, "m_vecMins", mins);
+ entNewPos[2] -= mins[2];
+
+ TeleportEntity(g_pGrabbedEnt[client], entNewPos, NULL_VECTOR, NULL_VECTOR);
+
+ return Plugin_Handled;
+}
+
+//============================================================================
+// RELEASE ENTITY COMMAND //
+//============================================================================
+public Action Cmd_Release(client, args) {
+ if (!IsValidEntity(client) || client < 1 || client > MaxClients || !IsClientInGame(client))
+ return Plugin_Handled;
+
+ if (g_pGrabbedEnt[client] == -1 || !IsValidEntity(g_pGrabbedEnt[client]))
+ return Plugin_Handled;
+
+ // Allow near-immediate use of weapon
+ SetWeaponDelay(client, 0.2);
+
+ SetEntityMoveType(client, g_pLastMoveType[client]);
+
+
+ // Unfreeze if target was a player and unfreeze if setting is set to 0
+ char sClass[64];
+ GetEntityClassname(g_pGrabbedEnt[client], sClass, sizeof(sClass)); TrimString(sClass);
+
+ if (StrEqual(sClass, "player", false))
+ SetEntityMoveType(g_pGrabbedEnt[client], g_pLastMoveType[g_pGrabbedEnt[client]]);
+ else if (g_eReleaseFreeze[client] == false)
+ AcceptEntityInput(g_pGrabbedEnt[client], "EnableMotion");
+
+ // Restore color and alpha to original prior to grab
+ SetEntityRenderColor(g_pGrabbedEnt[client], g_eOriginalColor[client][0], g_eOriginalColor[client][1], g_eOriginalColor[client][2], g_eOriginalColor[client][3]);
+
+ // Kill the grab timer and reset control values
+ if (IsValidHandle(g_eGrabTimer[client])) {
+ delete g_eGrabTimer[client];
+ }
+
+ g_pGrabbedEnt[client] = -1;
+ g_eRotationAxis[client] = -1;
+ g_pInRotationMode[client] = false;
+
+ return Plugin_Handled;
+}
+
+//============================================================================
+// *** UTILITIES *** //
+//============================================================================
+int GetLookingEntity(int client, TraceEntityFilter filter) {
+ static float pos[3], ang[3];
+ GetClientEyePosition(client, pos);
+ GetClientEyeAngles(client, ang);
+ TR_TraceRayFilter(pos, ang, MASK_ALL, RayType_Infinite, filter, client);
+ if(TR_DidHit()) {
+ return TR_GetEntityIndex();
+ }
+ return -1;
+}
+
+stock bool GetEntNewPosition(int client, float endPos[3], bool doCollision = true)
+{
+ if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
+ float clientEye[3], clientAngle[3], direction[3];
+ GetClientEyePosition(client, clientEye);
+ GetClientEyeAngles(client, clientAngle);
+
+ GetAngleVectors(clientAngle, direction, NULL_VECTOR, NULL_VECTOR);
+ ScaleVector(direction, g_fGrabDistance[client]);
+ AddVectors(clientEye, direction, endPos);
+
+ if(doCollision) {
+ TR_TraceRayFilter(clientEye, endPos, MASK_OPAQUE, RayType_EndPoint, TraceRayFilterEnt, client);
+ if (TR_DidHit(INVALID_HANDLE)) {
+ TR_GetEndPosition(endPos);
+ }
+ }
+ return true;
+ }
+
+ return false;
+}
+/////
+stock bool GetInitialRayPosition(int client, float endPos[3])
+{
+ if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
+ float clientEye[3], clientAngle[3];
+ GetClientEyePosition(client, clientEye);
+ GetClientEyeAngles(client, clientAngle);
+
+ TR_TraceRayFilter(clientEye, clientAngle, MASK_SOLID, RayType_Infinite, TraceRayFilterActivator, client);
+ if (TR_DidHit(INVALID_HANDLE))
+ TR_GetEndPosition(endPos);
+ return true;
+ }
+ return false;
+}
+/////
+stock void SetWeaponDelay(int client, float delay)
+{
+ if (IsValidEntity(client) && client > 0 && client <= MaxClients && IsClientInGame(client)) {
+ int pWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
+
+ if (IsValidEntity(pWeapon) && pWeapon != -1) {
+ SetEntPropFloat(pWeapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + delay);
+ SetEntPropFloat(pWeapon, Prop_Send, "m_flNextSecondaryAttack", GetGameTime() + delay);
+ }
+ }
+}
+/////
+stock void CreateRing(int client, float ang[3], float pos[3], float diameter, int axis, bool trio)
+{
+ if (!IsValidEntity(client) || client < 1 || client > MaxClients || !IsClientInGame(client))
+ return;
+
+ float ringVecs[26][3];
+ int ringColor[3][4];
+
+ ringColor[0] = { 255, 0, 0, 255 };
+ ringColor[1] = { 0, 255, 0, 255 };
+ ringColor[2] = { 0, 0, 255, 255 };
+
+ int numSides = (!trio) ? 26 : 17;
+ float angIncrement = (!trio) ? 15.0 : 24.0;
+
+ for (int i = 1; i < numSides; i++) {
+ float direction[3], endPos[3];
+ switch(axis) {
+ case 0: GetAngleVectors(ang, direction, NULL_VECTOR, NULL_VECTOR);
+ case 1:
+ {
+ ang[2] = 0.0;
+ GetAngleVectors(ang, NULL_VECTOR, direction, NULL_VECTOR);
+ }
+ case 2: GetAngleVectors(ang, NULL_VECTOR, NULL_VECTOR, direction);
+ }
+
+ ScaleVector(direction, diameter);
+ AddVectors(pos, direction, endPos);
+
+ if (i == 1) ringVecs[0] = endPos;
+
+ ringVecs[i] = endPos;
+ ang[axis] += angIncrement;
+
+ TE_SetupBeamPoints(ringVecs[i-1], ringVecs[i], g_BeamSprite, g_HaloSprite, 0, 15, 0.2, 2.5, 2.5, 1, 0.0, ringColor[axis], 10);
+ TE_SendToClient(client, 0.0);
+
+ if(trio && i == numSides-1 && axis < 2) {
+ i = 0;
+ ang[axis] -= angIncrement * (numSides-1);
+ axis += 1;
+ }
+ }
+}
+
+void GlowEntity(int client, int entity) {
+ float pos[3], mins[3], maxs[3], angles[3];
+ GetEntPropVector(entity, Prop_Send, "m_angRotation", angles);
+ GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
+ GetEntPropVector(entity, Prop_Send, "m_vecMins", mins);
+ GetEntPropVector(entity, Prop_Send, "m_vecMaxs", maxs);
+ Effect_DrawBeamBoxRotatableToClient(client, pos, mins, maxs, angles, g_iLaserIndex, 0, 0, 30, 0.1, 0.4, 0.4, 0, 0.1, { 0, 255, 0, 235 }, 0);
+}
+
+//============================================================================
+// *** FILTERS *** //
+//============================================================================
+
+public bool TraceRayFilterEnt(int entity, int mask, any:client)
+{
+ if (entity == client || entity == g_pGrabbedEnt[client])
+ return false;
+ return true;
+}
+/////
+public bool TraceRayFilterActivator(int entity, int mask, any:activator)
+{
+ if (entity == activator)
+ return false;
+ return true;
+}
+
+bool Filter_IgnoreForbidden(int entity, int mask, int data) {
+ if(entity == data || entity == 0) return false;
+ if(entity <= MaxClients) return true;
+ return CheckBlacklist(entity);
+}
+
+bool CheckBlacklist(int entity) {
+ static char buffer[64];
+ GetEntityClassname(entity, buffer, sizeof(buffer));
+ for(int i = 0; i < MAX_FORBIDDEN_CLASSNAMES; i++) {
+ if(StrEqual(FORBIDDEN_CLASSNAMES[i], buffer)) {
+ return false;
+ }
+ }
+ if(StrContains(buffer, "prop_") > -1) {
+ GetEntPropString(entity, Prop_Data, "m_ModelName", buffer, sizeof(buffer));
+ for(int i = 0; i < MAX_FORBIDDEN_MODELS; i++) {
+ if(StrEqual(FORBIDDEN_MODELS[i], buffer)) {
+ return false;
+ }
+ }
+ }
+ GetEntPropString(entity, Prop_Data, "m_iName", buffer, sizeof(buffer));
+ if(StrEqual(buffer, "l4d2_randomizer")) {
+ return false;
+ }
+ return true;
+}
\ No newline at end of file
diff --git a/scripting/L4D2FFKickProtection.sp b/scripting/L4D2FFKickProtection.sp
new file mode 100644
index 0000000..aef8057
--- /dev/null
+++ b/scripting/L4D2FFKickProtection.sp
@@ -0,0 +1,141 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+#define ANTI_ADMIN_KICK_MIN_TIME 120 // The number of seconds after joining where vote kicking an admin, kicks the caller
+#define PLUGIN_VERSION "1.1"
+
+#include
+#include
+#include
+
+static int disableFFClient = -1, ffDamageCount; //client to disable FF for
+static ConVar forceKickFFThreshold;
+
+public Plugin myinfo = {
+ name = "L4D2 FF Kick Protection",
+ author = "jackzmc",
+ description = "Prevents friendly firing from players being voted off and admins from being kicked",
+ version = PLUGIN_VERSION,
+ url = "https://github.com/Jackzmc/sourcemod-plugins"
+};
+
+public void OnPluginStart() {
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
+ {
+ SetFailState("This plugin is for L4D/L4D2 only.");
+ }
+ AddCommandListener(VoteStart, "callvote");
+ HookUserMessage(GetUserMessageId("VotePass"), VotePassFail);
+ HookUserMessage(GetUserMessageId("VoteFail"), VotePassFail);
+
+ forceKickFFThreshold = CreateConVar("sm_votekick_force_threshold","30.0","The threshold of amount of FF to then automatically kick.\n0: Any attempted damage\n -1: No auto kick.\n>0: When FF count > this", FCVAR_NONE, true, -1.0);
+}
+
+
+int iJoinTime[MAXPLAYERS+1];
+public void OnClientPutInServer(int client) {
+ int team = GetClientTeam(client);
+ if(team == 2) {
+ SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamage);
+ }
+ iJoinTime[client] = GetTime();
+}
+
+public void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast) {
+ if(!event.GetBool("disconnect")) {
+ int team = event.GetInt("team");
+ int userid = GetClientOfUserId(event.GetInt("userid"));
+ if(team == 2) {
+ SDKHook(userid, SDKHook_OnTakeDamageAlive, OnTakeDamage);
+ //add new hook
+ }else{
+ SDKUnhook(userid, SDKHook_OnTakeDamageAlive, OnTakeDamage);
+ }
+ }
+}
+public Action VoteStart(int client, const char[] command, int argc) {
+ if(!IsClientInGame(client)) {
+ PrintToServer("Preventing vote from user not in game: %N", client);
+ return Plugin_Handled;
+ }
+ if(GetClientCount(true) == 0 || client == 0 || client >= MaxClients) return Plugin_Handled; //prevent votes while server is empty or if server tries calling vote
+ if(argc >= 1) {
+ char issue[32];
+
+ GetCmdArg(1, issue, sizeof(issue));
+
+ if(StrEqual(issue, "Kick", false)) {
+ char option[32];
+ GetCmdArg(2, option, sizeof(option));
+
+ if(strlen(option) > 1) { //empty userid/console can't call votes
+ int target = GetClientOfUserId(StringToInt(option));
+ if(target <= 0 || target >= MaxClients || !IsClientInGame(target)) return Plugin_Continue; //invalid, pass it through
+ AdminId targetAdmin = GetUserAdmin(target);
+ bool isCallerAdmin = GetUserFlagBits(client) != 0;
+ bool isTargetAdmin = GetUserFlagBits(target) != 0;
+ PrintToServer("Caller Admin: %b | Target admin: %b", isCallerAdmin, isTargetAdmin);
+ //Only run if vote is against an admin
+ if(isTargetAdmin) {
+ for(int i = 1; i <= MaxClients; i++) {
+ if(target != i && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) {
+ PrintToChat(i, "%N attempted to vote-kick admin %N", client, target);
+ }
+ }
+ // Kick player if they are not an admin and just recently joined.
+ // Else, just tell the target
+ if(!isCallerAdmin && GetTime() - iJoinTime[client] <= ANTI_ADMIN_KICK_MIN_TIME) {
+ if(GetClientTeam(target) >= 2) {
+ KickClient(client, "No.");
+ PrintToChat(target, "%N has attempted to vote kick you and was kicked.", client);
+ } else {
+ PrintToChat(client, "%N is an admin and cannot be vote kicked", target);
+ PrintToChat(target, "%N has attempted to kick you while you were afk.", client);
+ }
+ } else {
+ PrintToChat(target, "%N has attempted to vote kick you.", client);
+ }
+ // TODO: remove debug
+ targetAdmin.GetUsername(option, sizeof(option));
+ PrintToServer("debug: admin immunity is %d. username: %s", targetAdmin.ImmunityLevel, option);
+ PrintToServer("ADMIN VOTE KICK BLOCKED | Target=%N | Caller=%N", target, client);
+ return Plugin_Handled;
+ } else if(isCallerAdmin) {
+ PrintToServer("Vote kick by admin, instantly passing");
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && !IsFakeClient(i) && GetClientTeam(i) == GetClientTeam(target)) {
+ ClientCommand(i, "vote Yes");
+ }
+ }
+ }
+ if(GetClientTeam(target) == 2) {
+ disableFFClient = target;
+ ffDamageCount = 0;
+ }
+ PrintToServer("VOTE KICK STARTED | Target=%N | Caller=%N", target, client);
+ return Plugin_Continue;
+ }
+ }
+ }
+ return Plugin_Continue;
+}
+
+public Action VotePassFail(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init) {
+ disableFFClient = -1;
+ ffDamageCount = 0;
+ return Plugin_Continue;
+}
+
+public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) {
+ if(disableFFClient == attacker && damage > 0.0 && victim > 0 && victim <= MaxClients && GetClientTeam(victim) == 2) {
+ if(forceKickFFThreshold.IntValue > -1 && ffDamageCount > 0.0) {
+ //auto kick
+ if(ffDamageCount > forceKickFFThreshold.FloatValue) {
+ BanClient(disableFFClient, 0, 0, "Kicked for excessive friendly fire", "Dick-Be-Gone", "noFF");
+ }
+ }
+ return Plugin_Handled;
+ }
+ return Plugin_Continue;
+}
diff --git a/scripting/L4D2PreventBotMovement.sp b/scripting/L4D2PreventBotMovement.sp
new file mode 100644
index 0000000..822071e
--- /dev/null
+++ b/scripting/L4D2PreventBotMovement.sp
@@ -0,0 +1,57 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+//#define DEBUG
+
+#define PLUGIN_NAME "L4D2 Prevent Bot Movement"
+#define PLUGIN_DESCRIPTION "Prevents bots from moving in the beginning of the round for a set period of time."
+#define PLUGIN_AUTHOR "jackzmc"
+#define PLUGIN_VERSION "1.0"
+#define PLUGIN_URL ""
+
+#include
+#include
+//#include
+
+public Plugin myinfo =
+{
+ name = PLUGIN_NAME,
+ author = PLUGIN_AUTHOR,
+ description = PLUGIN_DESCRIPTION,
+ version = PLUGIN_VERSION,
+ url = PLUGIN_URL
+};
+
+static ConVar hSBStop, hStopTime;
+
+public void OnPluginStart()
+{
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
+ {
+ SetFailState("This plugin is for L4D/L4D2 only.");
+ }
+ HookEvent("round_start",Event_RoundStart);
+
+ hStopTime = CreateConVar("sm_freeze_bot_time","20.0","How long should the bots be frozen for on beginning of round? 0 to disable",FCVAR_NONE,true,0.0);
+ hSBStop = FindConVar("sb_stop");
+}
+public void OnMapStart() {
+ if(hStopTime.IntValue != 0) {
+ PrintToChatAll("round start");
+ hSBStop.BoolValue = true;
+ CreateTimer(hStopTime.FloatValue, ResumeBots);
+ }
+}
+
+public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
+ if(hStopTime.IntValue != 0) {
+ PrintToChatAll("round start");
+ hSBStop.BoolValue = true;
+ CreateTimer(hStopTime.FloatValue, ResumeBots);
+ }
+}
+public Action ResumeBots(Handle timer) {
+ PrintToChatAll("Resuming bots");
+ hSBStop.BoolValue = false;
+}
diff --git a/scripting/L4D2Tools.sp b/scripting/L4D2Tools.sp
new file mode 100644
index 0000000..5125faa
--- /dev/null
+++ b/scripting/L4D2Tools.sp
@@ -0,0 +1,836 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+#define DEBUG 1
+
+#define PLUGIN_VERSION "1.0"
+
+#define PRECACHE_SOUNDS_COUNT 5
+char PRECACHE_SOUNDS[PRECACHE_SOUNDS_COUNT][] = {
+ "custom/meow1.mp3",
+ "custom/xen_teleport.mp3",
+ "custom/mariokartmusic.mp3",
+ "custom/spookyscaryskeletons.mp3",
+ "custom/wearenumberone2.mp3"
+};
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "l4d_survivor_identity_fix.inc"
+
+char MODELS[8][] = {
+ "models/survivors/survivor_gambler.mdl",
+ "models/survivors/survivor_producer.mdl",
+ "models/survivors/survivor_mechanic.mdl",
+ "models/survivors/survivor_coach.mdl",
+ "models/survivors/survivor_namvet.mdl",
+ "models/survivors/survivor_teenangst.mdl",
+ "models/survivors/survivor_biker.mdl",
+ "models/survivors/survivor_manager.mdl"
+};
+
+enum L4DModelId {
+ Model_Nick,
+ Model_Rochelle,
+ Model_Ellis,
+ Model_Coach,
+ Model_Bill,
+ Model_Zoey,
+ Model_Francis,
+ Model_Louis
+}
+
+static ArrayList LasersUsed;
+static ConVar hLaserNotice, hFinaleTimer, hFFNotice, hPingDropThres, hForceSurvivorSet, hPlayerLimit, hSVMaxPlayers, hHideMotd, hGamemode;
+static int iFinaleStartTime, botDropMeleeWeapon[MAXPLAYERS+1], iHighPingCount[MAXPLAYERS+1];
+static bool isHighPingIdle[MAXPLAYERS+1], isL4D1Survivors;
+static Handle hGoAwayFromKeyboard;
+static StringMap SteamIDs;
+static char lastSound[MAXPLAYERS+1][64], gamemode[32];
+
+static float OUT_OF_BOUNDS[3] = {0.0, -1000.0, 0.0};
+
+public Plugin myinfo = {
+ name = "L4D2 Misc Tools",
+ author = "Includes: Notice on laser use, Timer for gauntlet runs",
+ description = "jackzmc",
+ version = PLUGIN_VERSION,
+ url = "https://github.com/Jackzmc/sourcemod-plugins"
+};
+
+//TODO: On pickup ammo pack, mark dropped kit/defib
+
+public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
+{
+ MarkNativeAsOptional("IdentityFix_SetPlayerModel");
+ return APLRes_Success;
+}
+
+public void OnPluginStart() {
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_Left4Dead2) {
+ SetFailState("This plugin is for L4D2 only.");
+ }
+ LoadTranslations("common.phrases");
+ Handle hConfig = LoadGameConfigFile("l4d2tools");
+ if(hConfig == INVALID_HANDLE) SetFailState("Could not load l4d2tools gamedata.");
+
+ StartPrepSDKCall(SDKCall_Player);
+ PrepSDKCall_SetFromConf(hConfig, SDKConf_Signature, "GoAwayFromKeyboard");
+ hGoAwayFromKeyboard = EndPrepSDKCall();
+ delete hConfig;
+
+ if(hGoAwayFromKeyboard == INVALID_HANDLE) {
+ SetFailState("GoAwayFromKeyboard signature is invalid");
+ }
+
+ hLaserNotice = CreateConVar("sm_laser_use_notice", "1.0", "Enable notification of a laser box being used", FCVAR_NONE, true, 0.0, true, 1.0);
+ hFinaleTimer = CreateConVar("sm_time_finale", "0.0", "Record the time it takes to complete finale. 0 -> OFF, 1 -> Gauntlets Only, 2 -> All finales", FCVAR_NONE, true, 0.0, true, 2.0);
+ hFFNotice = CreateConVar("sm_ff_notice", "0.0", "Notify players if a FF occurs. 0 -> Disabled, 1 -> In chat, 2 -> In Hint text", FCVAR_NONE, true, 0.0, true, 2.0);
+ hPingDropThres = CreateConVar("sm_autoidle_ping_max", "0.0", "The highest ping a player can have until they will automatically go idle.\n0=OFF, Min is 30", FCVAR_NONE, true, 0.0, true, 1000.0);
+ hForceSurvivorSet = FindConVar("l4d_force_survivorset");
+ hHideMotd = CreateConVar("sm_hidemotd", "1", "Hide the MOTD when the server is running", FCVAR_NONE, true, 0.0, true, 1.0);
+
+ hSVMaxPlayers = FindConVar("sv_maxplayers");
+ if(hSVMaxPlayers != null) {
+ hPlayerLimit = CreateConVar("sm_player_limit", "0", "Overrides sv_maxplayers. 0 = off, > 0: limit", FCVAR_NONE, true, 0.0, false);
+ hPlayerLimit.AddChangeHook(Event_PlayerLimitChange);
+ hSVMaxPlayers.IntValue = hPlayerLimit.IntValue;
+ }
+
+ hFFNotice.AddChangeHook(CVC_FFNotice);
+ if(hFFNotice.IntValue > 0) {
+ HookEvent("player_hurt", Event_PlayerHurt);
+ }
+
+ LasersUsed = new ArrayList(1, 0);
+ SteamIDs = new StringMap();
+
+ hGamemode = FindConVar("mp_gamemode");
+ hGamemode.GetString(gamemode, sizeof(gamemode));
+ hGamemode.AddChangeHook(Event_GamemodeChange);
+ Event_GamemodeChange(hGamemode, gamemode, gamemode);
+
+ HookEvent("player_use", Event_PlayerUse);
+ HookEvent("round_end", Event_RoundEnd);
+ HookEvent("gauntlet_finale_start", Event_GauntletStart);
+ HookEvent("finale_start", Event_FinaleStart);
+ HookEvent("finale_vehicle_leaving", Event_FinaleEnd);
+ HookEvent("player_bot_replace", Event_BotPlayerSwap);
+ HookEvent("bot_player_replace", Event_BotPlayerSwap);
+ HookEvent("player_first_spawn", Event_PlayerFirstSpawn);
+ HookEvent("weapon_drop", Event_WeaponDrop);
+ HookEvent("player_disconnect", Event_PlayerDisconnect);
+
+ AutoExecConfig(true, "l4d2_tools");
+
+ for(int client = 1; client < MaxClients; client++) {
+ if(IsClientConnected(client) && IsClientInGame(client) && GetClientTeam(client) == 2) {
+ if(IsFakeClient(client)) {
+ SDKHook(client, SDKHook_OnTakeDamage, Event_OnTakeDamageBot);
+ SDKHook(client, SDKHook_WeaponDrop, Event_OnWeaponDrop);
+ } else {
+ SDKHook(client, SDKHook_WeaponEquip, Event_OnWeaponEquip);
+ }
+ }
+ }
+
+ HookUserMessage(GetUserMessageId("VGUIMenu"), VGUIMenu, true);
+
+ RegAdminCmd("sm_model", Command_SetClientModel, ADMFLAG_KICK);
+ RegAdminCmd("sm_surv", Cmd_SetSurvivor, ADMFLAG_KICK);
+ RegAdminCmd("sm_respawn_all", Command_RespawnAll, ADMFLAG_CHEATS, "Makes all dead players respawn in a closet");
+ RegAdminCmd("sm_playsound", Command_PlaySound, ADMFLAG_KICK, "Plays a gamesound for player");
+ RegAdminCmd("sm_stopsound", Command_StopSound, ADMFLAG_GENERIC, "Stops the last played gamesound for player");
+ RegAdminCmd("sm_swap", Command_SwapPlayer, ADMFLAG_KICK, "Swarms two player's locations");
+ RegConsoleCmd("sm_pmodels", Command_ListClientModels, "Lists all player's models");
+ RegAdminCmd("sm_skipoutro", Command_SkipOutro, ADMFLAG_KICK, "Skips the outro");
+
+ CreateTimer(8.0, Timer_CheckPlayerPings, _, TIMER_REPEAT);
+}
+
+void Event_GamemodeChange(ConVar cvar, const char[] oldValue, const char[] newValue) {
+ cvar.GetString(gamemode, sizeof(gamemode));
+}
+
+void Event_PlayerLimitChange(ConVar cvar, const char[] oldValue, const char[] newValue) {
+ if(cvar.IntValue > 0) {
+ hSVMaxPlayers.IntValue = cvar.IntValue;
+ }
+}
+
+Action Timer_CheckPlayerPings(Handle timer) {
+ if(StrEqual(gamemode, "hideandseek")) return Plugin_Continue;
+ if(hPingDropThres.IntValue != 0) {
+ for (int i = 1; i <= MaxClients; i++ ) {
+ if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(i) && GetClientTeam(i) > 1) {
+ int ping = GetEntProp(GetPlayerResourceEntity(), Prop_Send, "m_iPing", _, i);
+ if(isHighPingIdle[i] && ping <= hPingDropThres.IntValue) {
+ L4D_TakeOverBot(i);
+ isHighPingIdle[i] = false;
+ iHighPingCount[i] = 0;
+ }else if(ping > hPingDropThres.IntValue) {
+ if(iHighPingCount[i]++ > 2) {
+ PrintToChat(i, "Due to your high ping (%d ms) you have been moved to AFK.", ping);
+ PrintToChat(i, "You will be automatically switched back once your ping restores");
+ SDKCall(hGoAwayFromKeyboard, i);
+ //PrintToChat(i, "Type /pingignore to disable this feature.");
+ // L4D_ReplaceWithBot(i);
+ isHighPingIdle[i] = true;
+ iHighPingCount[i] = 0;
+ }
+
+ }
+ }
+ }
+ }
+ return Plugin_Continue;
+}
+
+void CVC_FFNotice(ConVar convar, const char[] oldValue, const char[] newValue) {
+ if(convar.IntValue > 0) {
+ HookEvent("player_hurt", Event_PlayerHurt);
+ } else {
+ UnhookEvent("player_hurt", Event_PlayerHurt);
+ }
+}
+
+public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) {
+ LasersUsed.Clear();
+}
+
+Action Command_RespawnAll(int client, int args) {
+ L4D_CreateRescuableSurvivors();
+ return Plugin_Handled;
+}
+
+Action Command_SwapPlayer(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_swap [another player (default: self)] [\"silent\"]");
+ } else {
+ char arg1[64], arg2[64], arg3[8];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ GetCmdArg(3, arg3, sizeof(arg3));
+
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ int target = target_list[0];
+ int target2 = client;
+ if(args == 2) {
+ if ((target_count = ProcessTargetString(
+ arg2,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ }
+ target2 = target_list[0];
+ }
+ float pos1[3], pos2[3];
+ float ang1[3], ang2[3];
+ GetClientAbsOrigin(target, pos1);
+ GetClientAbsOrigin(target2, pos2);
+ GetClientAbsAngles(target, ang1);
+ GetClientAbsAngles(target2, ang2);
+ TeleportEntity(target, pos2, ang2, NULL_VECTOR);
+ TeleportEntity(target2, pos1, ang1, NULL_VECTOR);
+ if(args < 3 || !StrEqual(arg3, "silent") && !StrEqual(arg2, "silent")) {
+ EmitSoundToClient(target, "custom/xen_teleport.mp3", target, 0);
+ EmitSoundToClient(target2, "custom/xen_teleport.mp3", target2);
+ }
+ }
+ return Plugin_Handled;
+}
+
+Action Command_SkipOutro(int client, int args) {
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i)) {
+ ClientCommand(i, "skipouttro");
+ }
+ }
+ return Plugin_Handled;
+}
+Action Command_ListClientModels(int client, int args) {
+ char model[64];
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2) {
+ GetClientModel(i, model, sizeof(model));
+ ReplyToCommand(client, "%N's model: %s", i, model);
+ }
+ }
+ return Plugin_Handled;
+}
+Action Command_PlaySound(int client, int args) {
+ if(args < 2) {
+ ReplyToCommand(client, "Usage: sm_playsound ");
+ }else{
+ char arg1[32], arg2[64], arg3[16];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ GetCmdArg(3, arg3, sizeof(arg3));
+
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MAXPLAYERS,
+ COMMAND_FILTER_CONNECTED,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ int target;
+ for (int i = 0; i < target_count; i++) {
+ target = target_list[i];
+ StopSound(target, 0, lastSound[target]);
+ }
+ PrecacheSound(arg2);
+ for (int i = 0; i < target_count; i++) {
+ target = target_list[i];
+ if(IsClientConnected(target) && IsClientInGame(target) && !IsFakeClient(target)) {
+ if(StrEqual(arg3, "direct"))
+ ClientCommand(target, "playgamesound %s", arg2);
+ else
+ EmitSoundToClient(target, arg2, target);
+ strcopy(lastSound[target], 64, arg2);
+ }
+ }
+ CShowActivity2(client, "[SM] ", "playing sound {olive}%s{default} to {yellow}%s", arg2, target_name);
+ }
+ return Plugin_Handled;
+}
+
+Action Command_StopSound(int client, int args) {
+ if(args < 2) {
+ ReplyToCommand(client, "Usage: sm_stopsound [soundpath or leave blank for previous]");
+ } else {
+ char arg1[32], arg2[64];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MAXPLAYERS,
+ COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ int target;
+ for (int i = 0; i < target_count; i++) {
+ target = target_list[i];
+ if(IsClientConnected(target) && IsClientInGame(target) && !IsFakeClient(target)) {
+ if(args < 2)
+ StopSound(target, 0, lastSound[target]);
+ else
+ StopSound(target, 0, arg2);
+ }
+ }
+ }
+ return Plugin_Handled;
+}
+
+Action Command_SetClientModel(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_model [player] ['keep']");
+ } else {
+ char arg1[2], arg2[16], arg3[8];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ GetCmdArg(3, arg3, sizeof(arg3));
+
+ int survivorId;
+ L4DModelId modelId;
+
+
+ bool isL4D1 = isL4D1Survivors;
+ if(hForceSurvivorSet != null && hForceSurvivorSet.IntValue > 0) isL4D1 = hForceSurvivorSet.IntValue == 1;
+
+ char s = CharToLower(arg1[0]);
+ if(s == 'b') {
+ survivorId = isL4D1 ? 0 : 4;
+ modelId = Model_Bill;
+ } else if(s == 'z') {
+ survivorId = isL4D1 ? 1 : 5;
+ modelId = Model_Zoey;
+ } else if(s == 'l') {
+ survivorId = isL4D1 ? 2 : 7;
+ modelId = Model_Louis;
+ } else if(s == 'f') {
+ survivorId = isL4D1 ? 3 : 6;
+ modelId = Model_Francis;
+ } else if(s == 'n') {
+ survivorId = 0;
+ modelId = Model_Nick;
+ if(isL4D1) PrintToChat(client, "Note: Only models for L4D2 characters are supported in L4D1 maps.");
+ } else if(s == 'r') {
+ survivorId = 1;
+ modelId = Model_Rochelle;
+ if(isL4D1) PrintToChat(client, "Note: Only models for L4D2 characters are supported in L4D1 maps.");
+ } else if(s== 'e') {
+ survivorId = 3;
+ modelId = Model_Ellis;
+ if(isL4D1) PrintToChat(client, "Note: Only models for L4D2 characters are supported in L4D1 maps.");
+ } else if(s == 'c') {
+ survivorId = 2;
+ modelId = Model_Coach;
+ if(isL4D1) PrintToChat(client, "Note: Only models for L4D2 characters are supported in L4D1 maps.");
+ } else {
+ ReplyToCommand(client, "Unknown survivor \"%s\". Syntax changed: model [player or none for self]", arg1);
+ return Plugin_Handled;
+ }
+
+ bool keep = StrEqual(arg2, "keep", false) || StrEqual(arg3, "keep", false);
+
+ if(args > 1) {
+ char target_name[1];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg2,
+ client,
+ target_list,
+ MAXPLAYERS,
+ COMMAND_FILTER_ALIVE | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ for (int i = 0; i < target_count; i++) {
+ int target = target_list[i];
+ int team = GetClientTeam(target);
+ if(team == 2 || team == 4) {
+ SetCharacter(target, survivorId, modelId, keep);
+ }
+ }
+ } else {
+ SetCharacter(client, survivorId, modelId, keep);
+ }
+ }
+ return Plugin_Handled;
+}
+
+void SetCharacter(int target, int survivorIndex, L4DModelId modelIndex, bool keepModel) {
+ SetEntProp(target, Prop_Send, "m_survivorCharacter", survivorIndex);
+ SetEntityModel(target, MODELS[view_as(modelIndex)]);
+ if (IsFakeClient(target)) {
+ char name[32];
+ GetSurvivorName(target, name, sizeof(name));
+ SetClientInfo(target, "name", name);
+ }
+ UpdatePlayerIdentity(target, view_as(survivorIndex), keepModel);
+
+ DataPack pack = new DataPack();
+ pack.WriteCell(GetClientUserId(target));
+ bool dualWield = false;
+ for(int slot = 0; slot <= 4; slot++) {
+ int weapon = AddWeaponSlot(target, slot, pack);
+ if(weapon > 0) {
+ if(slot == 1 && HasEntProp(weapon, Prop_Send, "m_isDualWielding")) {
+ dualWield = GetEntProp(weapon, Prop_Send, "m_isDualWielding") == 1;
+ SetEntProp(weapon, Prop_Send, "m_isDualWielding", 0);
+ }
+ SDKHooks_DropWeapon(target, weapon, NULL_VECTOR);
+ }
+ }
+ pack.WriteCell(dualWield);
+ CreateTimer(0.1, Timer_RequipWeapon, pack);
+}
+
+int AddWeaponSlot(int target, int slot, DataPack pack) {
+ int weapon = GetPlayerWeaponSlot(target, slot);
+ if( weapon > 0 ) {
+ pack.WriteCell(EntIndexToEntRef(weapon)); // Save last held weapon to switch back
+ return weapon;
+ } else {
+ pack.WriteCell(-1); // Save last held weapon to switch back
+ return -1;
+ }
+}
+
+public Action Timer_RequipWeapon(Handle hdl, DataPack pack) {
+ pack.Reset();
+ int client = GetClientOfUserId(pack.ReadCell());
+ if(client == 0) return Plugin_Handled;
+
+ int weapon, pistolSlotItem = -1;
+
+ for(int slot = 0; slot <= 4; slot++) {
+ weapon = pack.ReadCell();
+ if(EntRefToEntIndex(weapon) != INVALID_ENT_REFERENCE) {
+ if(slot == 1) {
+ pistolSlotItem = weapon;
+ }
+ EquipPlayerWeapon(client, weapon);
+ }
+ }
+ bool isDualWield = pack.ReadCell() == 1;
+ if(isDualWield && pistolSlotItem != -1 && HasEntProp(pistolSlotItem, Prop_Send, "m_isDualWielding")) {
+ SetEntProp(pistolSlotItem, Prop_Send, "m_isDualWielding", 1);
+ }
+ return Plugin_Handled;
+}
+
+Action Cmd_SetSurvivor(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_surv ");
+ } else {
+ char arg1[32], arg2[16];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+
+ int modelID = GetSurvivorId(arg2);
+ if(modelID == -1) {
+ ReplyToCommand(client, "Invalid survivor type entered. Case-sensitive, full name required.");
+ return Plugin_Handled;
+ }
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MAXPLAYERS,
+ COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ int target;
+ for (int i = 0; i < target_count; i++) {
+ target = target_list[i];
+ SetEntProp(target, Prop_Send, "m_survivorCharacter", modelID);
+ }
+ }
+ return Plugin_Handled;
+}
+
+// Hide MOTD
+Action VGUIMenu(UserMsg msg_id, Handle bf, const int[] players, int playersNum, bool reliable, bool init) {
+ if(!hHideMotd.BoolValue) return Plugin_Continue;
+ static char buffer[8];
+ // Show MOTD on versus games
+ hGamemode.GetString(buffer, sizeof(buffer));
+ if(StrEqual(buffer, "versus", false)) return Plugin_Continue;
+
+ BfReadString(bf, buffer, sizeof(buffer));
+ return strcmp(buffer, "info") == 0 ? Plugin_Handled : Plugin_Continue;
+}
+
+public void OnClientPutInServer(int client) {
+ if(!IsFakeClient(client))
+ SDKHook(client, SDKHook_WeaponEquip, Event_OnWeaponEquip);
+ else
+ SDKHook(client, SDKHook_OnTakeDamage, Event_OnTakeDamageBot);
+}
+
+public void OnClientDisconnect(int client) {
+ isHighPingIdle[client] = false;
+ iHighPingCount[client] = 0;
+ if(IsClientConnected(client) && IsClientInGame(client) && botDropMeleeWeapon[client] > -1 && IsValidEntity(botDropMeleeWeapon[client])) {
+ float pos[3];
+ GetClientAbsOrigin(client, pos);
+ TeleportEntity(botDropMeleeWeapon[client], pos, NULL_VECTOR, NULL_VECTOR);
+ botDropMeleeWeapon[client] = -1;
+ }
+}
+
+public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client && !IsFakeClient(client)) {
+ char auth[32];
+ GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
+ SteamIDs.Remove(auth);
+ }
+}
+
+int disabledItem[2048];
+//Can also probably prevent kit drop to pick them up
+public void Event_WeaponDrop(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ int weapon = event.GetInt("propid");
+ char newWpn[32];
+ GetEntityClassname(client, newWpn, sizeof(newWpn));
+ if(StrEqual(newWpn, "weapon_ammo_pack")) {
+ // prevent weapon from being picked up?
+ disabledItem[weapon] = client;
+ CreateTimer(10.0, Timer_AllowKitPickup, weapon);
+ }
+}
+public Action Event_OnWeaponEquip(int client, int weapon) {
+ if(disabledItem[weapon] > 0 && disabledItem[weapon] != client) return Plugin_Handled;
+ return Plugin_Continue;
+}
+public Action Timer_AllowKitPickup(Handle h, int entity) {
+ disabledItem[entity] = 0;
+ return Plugin_Handled;
+}
+public void OnMapStart() {
+ #if PRECACHE_SOUNDS_COUNT > 0
+ char buffer[128];
+ for(int i = 0; i < PRECACHE_SOUNDS_COUNT; i++) {
+ Format(buffer, sizeof(buffer), "sound/%s", PRECACHE_SOUNDS[i]);
+ AddFileToDownloadsTable(buffer);
+ PrecacheSound(PRECACHE_SOUNDS[i]);
+ }
+ #endif
+
+ HookEntityOutput("info_changelevel", "OnStartTouch", EntityOutput_OnStartTouchSaferoom);
+ HookEntityOutput("trigger_changelevel", "OnStartTouch", EntityOutput_OnStartTouchSaferoom);
+}
+public void OnConfigsExecuted() {
+ isL4D1Survivors = L4D2_GetSurvivorSetMap() == 1;
+ if(hSVMaxPlayers != null && hPlayerLimit.IntValue > 0) {
+ hSVMaxPlayers.IntValue = hPlayerLimit.IntValue;
+ }
+}
+
+public void OnSceneStageChanged(int scene, SceneStages stage) {
+ if(stage == SceneStage_Started) {
+ int activator = GetSceneInitiator(scene);
+ if(activator == 0) {
+ static char sceneFile[64];
+ GetSceneFile(scene, sceneFile, sizeof(sceneFile));
+ if(StrContains(sceneFile, "scenes/mechanic/dlc1_c6m1_initialmeeting") > -1 || StrEqual(sceneFile, "scenes/teengirl/dlc1_c6m1_initialmeeting07.vcd")) {
+ CancelScene(scene);
+ }else if(StrEqual(sceneFile, "scenes/teengirl/dlc1_c6m1_initialmeeting13.vcd") && activator == 0) {
+ CancelScene(scene);
+ }
+ }
+ }
+}
+///AFK BOT WEAPON FIX
+public void Event_BotPlayerSwap(Event event, const char[] name, bool dontBroadcast) {
+ int bot = GetClientOfUserId(event.GetInt("bot"));
+ if(StrEqual(name, "player_bot_replace")) {
+ // Bot replaced player, hook any drop events
+ SDKHook(bot, SDKHook_WeaponDrop, Event_OnWeaponDrop);
+ } else {
+ // Player replaced a bot
+ int client = GetClientOfUserId(event.GetInt("player"));
+ if(client && botDropMeleeWeapon[bot] > 0) {
+ int meleeOwnerEnt = GetEntPropEnt(botDropMeleeWeapon[bot], Prop_Send, "m_hOwnerEntity");
+ if(meleeOwnerEnt == -1) {
+ int currentWeapon = GetPlayerWeaponSlot(client, 1);
+ if(currentWeapon > 0) {
+ char buffer[32];
+ GetEntityClassname(currentWeapon, buffer, sizeof(buffer));
+ // Only delete their duplicate pistols, let melees get thrown out (into the world)
+ if(!StrEqual(buffer, "weapon_melee"))
+ RemoveEntity(currentWeapon);
+ }
+ EquipPlayerWeapon(client, botDropMeleeWeapon[bot]);
+ botDropMeleeWeapon[bot] = -1;
+ }
+ }
+ SDKUnhook(bot, SDKHook_WeaponDrop, Event_OnWeaponDrop);
+ }
+}
+Action Event_OnWeaponDrop(int client, int weapon) {
+ if(!IsValidEntity(weapon) || !IsFakeClient(client)) return Plugin_Continue;
+ if(GetEntProp(client, Prop_Send, "m_humanSpectatorUserID") > 0) {
+ char wpn[32];
+ GetEdictClassname(weapon, wpn, sizeof(wpn));
+ if(StrEqual(wpn, "weapon_melee") || StrEqual(wpn, "weapon_pistol_magnum")) {
+ #if defined DEBUG
+ PrintToServer("Bot %N dropped melee weapon %s", client, wpn);
+ #endif
+ RequestFrame(Frame_HideEntity, weapon);
+ botDropMeleeWeapon[client] = weapon;
+ }
+ }
+ return Plugin_Continue;
+}
+void Frame_HideEntity(int entity) {
+ if(IsValidEntity(entity))
+ TeleportEntity(entity, OUT_OF_BOUNDS, NULL_VECTOR, NULL_VECTOR);
+}
+// Only called for bots, kills zombies behind bots, preventing them being stuck when their AI doesn't want to keep them alive
+Action Event_OnTakeDamageBot(int victim, int& attacker, int& inflictor, float& damage, int& damagetype) {
+ if(attacker > MaxClients) {
+ static char name[16];
+ GetEdictClassname(attacker, name, sizeof(name));
+ if(!StrEqual(name, "infected", true)) {
+ return Plugin_Continue;
+ }
+
+ bool attackerVisible = IsEntityInSightRange(victim, attacker, 130.0, 10000.0);
+ if(!attackerVisible) {
+ //Zombie is behind the bot, reduce damage taken and slowly kill zombie (1/10 of default hp per hit)
+ damage /= 2.0;
+ SDKHooks_TakeDamage(attacker, victim, victim, 30.0);
+ return Plugin_Changed;
+ }
+ }
+ return Plugin_Continue;
+}
+//MINOR FIXES
+void EntityOutput_OnStartTouchSaferoom(const char[] output, int caller, int client, float time) {
+ if(client > 0 && client <= MaxClients && IsValidClient(client) && GetClientTeam(client) == 2) {
+ if(StrEqual(gamemode, "coop", false)) {
+ if(botDropMeleeWeapon[client] > 0) {
+ PrintToServer("Giving melee weapon back to %N", client);
+ float pos[3];
+ GetClientAbsOrigin(client, pos);
+ TeleportEntity(botDropMeleeWeapon[client], pos, NULL_VECTOR, NULL_VECTOR);
+ EquipPlayerWeapon(client, botDropMeleeWeapon[client]);
+ botDropMeleeWeapon[client] = -1;
+ }
+ } else if(StrEqual(gamemode, "tankrun", false)) {
+ if(!IsFakeClient(client)) {
+ CreateTimer(1.0, Timer_TPBots, client, TIMER_FLAG_NO_MAPCHANGE);
+ }
+ }
+ }
+}
+
+Action Timer_TPBots(Handle timer, int user) {
+ float pos[3];
+ GetClientAbsOrigin(user, pos);
+ for(int i = 1; i < MaxClients + 1; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsFakeClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
+ TeleportEntity(i, pos, NULL_VECTOR, NULL_VECTOR);
+ L4D2_RunScript("CommandABot({cmd=1,bot=GetPlayerFromUserID(%i),pos=Vector(%f,%f,%f)})", GetClientUserId(i), pos[0], pos[1], pos[2]);
+
+ }
+ }
+ return Plugin_Handled;
+}
+//FRIENDLY FIRE NOTICE
+public void Event_PlayerHurt(Event event, const char[] name, bool dontBroadcast) {
+ if(hFFNotice.IntValue > 0) {
+ int victim = GetClientOfUserId(event.GetInt("userid"));
+ int attacker = GetClientOfUserId(event.GetInt("attacker"));
+ int dmg = event.GetInt("dmg_health");
+ if(dmg > 0) {
+ if(attacker > 0 && !IsFakeClient(attacker) && attacker != victim) {
+ if(GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
+ if(hFFNotice.IntValue == 1) {
+ PrintHintTextToAll("%N has done %d HP of friendly fire damage to %N", attacker, dmg, victim);
+ }else{
+ PrintToChatAll("%N has done %d HP of friendly fire damage to %N", attacker, dmg, victim);
+ }
+ }
+ }
+ }
+ }
+}
+//LASER SIGHT NOTICE
+void Event_PlayerUse(Event event, const char[] name, bool dontBroadcast) {
+ if(hLaserNotice.BoolValue) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ int targetEntity = event.GetInt("targetid");
+
+ char classname[32];
+ GetEntityClassname(targetEntity, classname, sizeof(classname));
+
+ if(StrEqual(classname, "upgrade_laser_sight")) {
+ if(LasersUsed.FindValue(targetEntity) == -1) {
+ LasersUsed.Push(targetEntity);
+ PrintToChatAll("%N picked up laser sights", client);
+ }
+ }
+ }
+}
+//FINALE TIME INFO
+void Event_GauntletStart(Event event, const char[] name, bool dontBroadcast) {
+ if(hFinaleTimer.IntValue > 0) {
+ iFinaleStartTime = GetTime();
+ }
+}
+void Event_FinaleStart(Event event, const char[] name, bool dontBroadcast) {
+ if(hFinaleTimer.IntValue == 2) {
+ iFinaleStartTime = GetTime();
+ }
+}
+void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast) {
+ if(hFinaleTimer.IntValue != 0) {
+ if(iFinaleStartTime != 0) {
+ int difference = GetTime() - iFinaleStartTime;
+
+ char time[32];
+ FormatSeconds(difference, time, sizeof(time));
+ PrintToChatAll("Finale took %s to complete", time);
+ iFinaleStartTime = 0;
+ }
+ }
+}
+//Give kits to bots that replace kicked player
+void Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client > 0 && IsFakeClient(client) && HasEntProp(client, Prop_Send, "m_humanSpectatorUserID") && GetEntProp(client, Prop_Send, "m_humanSpectatorUserID") < 0) {
+ int ent = GivePlayerItem(client, "weapon_first_aid_kit");
+ EquipPlayerWeapon(client, ent);
+ }
+}
+/**
+ * Prints human readable duration from milliseconds
+ *
+ * @param ms The duration in milliseconds
+ * @param str The char array to use for text
+ * @param strSize The size of the string
+ */
+stock void FormatSeconds(int raw_sec, char[] str, int strSize) {
+ int hours = raw_sec / 3600;
+ int minutes = (raw_sec -(3600*hours))/60;
+ int seconds = (raw_sec -(3600*hours)-(minutes*60));
+ if(hours >= 1) {
+ Format(str, strSize, "%d hours, %d.%d minutes", hours, minutes, seconds);
+ }else if(minutes >= 1) {
+ Format(str, strSize, "%d minutes and %d seconds", minutes, seconds);
+ }else {
+ Format(str, strSize, "%d seconds", seconds);
+ }
+
+}
\ No newline at end of file
diff --git a/scripting/abm.sp b/scripting/abm.sp
new file mode 100644
index 0000000..aa50dc1
--- /dev/null
+++ b/scripting/abm.sp
@@ -0,0 +1,3774 @@
+//# vim: set filetype=cpp :
+
+/*
+ABM a SourceMod L4D2 Plugin
+Copyright (C) 2016-2017 Victor "NgBUCKWANGS" Gonzalez
+
+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.
+*/
+
+#include
+#include
+#include
+#undef REQUIRE_EXTENSIONS
+#include
+#undef REQUIRE_PLUGIN
+#include
+
+#pragma semicolon 1
+#pragma newdecls required
+
+#define PLUGIN_VERSION "0.1.97q"
+#define LOGFILE "addons/sourcemod/logs/abm.log" // TODO change this to DATE/SERVER FORMAT?
+
+Handle g_GameData = null;
+ArrayList g_sQueue;
+ArrayList g_iQueue;
+
+// menu parameters
+#define menuArgs g_menuItems[client] // Global argument tracking for the menu system
+#define menuArg0 g_menuItems[client][0] // GetItem(1...)
+#define menuArg1 g_menuItems[client][1] // GetItem(2...)
+int g_menuItems[MAXPLAYERS + 1][2];
+
+// menu tracking
+#define g_callBacks g_menuStack[client]
+ArrayStack g_menuStack[MAXPLAYERS + 1];
+Function callBack;
+
+char g_QKey[64]; // holds players by STEAM_ID
+StringMap g_QDB; // holds player records linked by STEAM_ID
+StringMap g_QRecord; // changes to an individual STEAM_ID mapping
+StringMap g_QRtmp; // temporary QRecord holder for checking records without changing the main
+StringMap g_Cvars; // locked cvars end up here
+
+char g_InfectedNames[6][] = {"Boomer", "Smoker", "Hunter", "Spitter", "Jockey", "Charger"};
+char g_SurvivorNames[8][] = {"Nick", "Rochelle", "Coach", "Ellis", "Bill", "Zoey", "Francis", "Louis"};
+char g_SurvivorPaths[8][] = {
+ "models/survivors/survivor_gambler.mdl",
+ "models/survivors/survivor_producer.mdl",
+ "models/survivors/survivor_coach.mdl",
+ "models/survivors/survivor_mechanic.mdl",
+ "models/survivors/survivor_namvet.mdl",
+ "models/survivors/survivor_teenangst.mdl",
+ "models/survivors/survivor_biker.mdl",
+ "models/survivors/survivor_manager.mdl",
+};
+
+int g_OS; // 0: Linux, 1: Windows (Prevent crash on Windows /w Zoey)
+char g_sB[512]; // generic catch all string buffer
+char g_pN[128]; // a dedicated buffer to storing a temporary name
+char g_name[128], g_tmpName[128]; // g_QDB client name
+int g_client, g_tmpClient; // g_QDB client id
+int g_target, g_tmpTarget; // g_QDB player (human or bot) id
+int g_lastid, g_tmpLastid; // g_QDB client's last known bot id
+int g_onteam, g_tmpOnteam = 1; // g_QDB client's team
+bool g_queued, g_tmpQueued; // g_QDB client's takeover state
+bool g_inspec, g_tmpInspec; // g_QDB check client's specator mode
+bool g_status, g_tmpStatus; // g_QDB client life state
+bool g_update, g_tmpUpdate; // g_QDB should we update this record?
+char g_model[32], g_tmpModel[32]; // g_QDB client's model
+char g_ghost[32], g_tmpGhost[32]; // g_QDB queued model for SwitchTeam
+float g_origin[3], g_tmpOrigin[3]; // g_QDB client's origin vector
+float g_rdelay, g_tmpRdelay; // g_QDB delay time for SI respawn
+Handle g_rDelays[MAXPLAYERS + 1]; // Individual respawn SI timers
+int g_models[8];
+
+Handle g_MkBotsTimer;
+Handle g_ADAssistant; // Tries to make sure the AD starts
+Handle g_AD; // Assistant Director Timer
+int g_survivorSet; // 0 = l4d2 survivors, 4 = l4d1 survivors
+bool g_survivorSetScan; // Check to discover the survivor set
+
+bool g_IsVs;
+bool g_IsCoop;
+bool g_AssistedSpawning = false;
+bool g_ADFreeze = true;
+bool g_AutoWave;
+int g_ADInterval;
+
+ConVar g_cvVersion; // abm_version
+ConVar g_cvLogLevel; int g_LogLevel; // abm_loglevel
+ConVar g_cvMinPlayers; int g_MinPlayers; // abm_minplayers
+ConVar g_cvPrimaryWeapon; char g_PrimaryWeapon[64]; // abm_primaryweapon
+ConVar g_cvSecondaryWeapon; char g_SecondaryWeapon[64]; // abm_secondaryweapon
+ConVar g_cvThrowable; char g_Throwable[64]; // abm_throwable
+ConVar g_cvHealItem; char g_HealItem[64]; // abm_healitem
+ConVar g_cvConsumable; char g_Consumable[64]; // abm_consumable
+ConVar g_cvTankChunkHp; int g_TankChunkHp; // abm_tankchunkhp
+ConVar g_cvSpawnInterval; int g_SpawnInterval; // abm_spawninterval
+ConVar g_cvAutoHard; int g_AutoHard; // abm_autohard
+ConVar g_cvUnlockSI; int g_UnlockSI; // abm_unlocksi
+ConVar g_cvJoinMenu; int g_JoinMenu; // abm_joinmenu
+ConVar g_cvTeamLimit; int g_TeamLimit; // abm_teamlimit
+ConVar g_cvOfferTakeover; int g_OfferTakeover; // abm_offertakeover
+ConVar g_cvStripKick; int g_StripKick; // abm_stripkick
+ConVar g_cvAutoModel; int g_AutoModel; // abm_automodel
+ConVar g_cvKeepDead; int g_KeepDead; // abm_keepdead
+ConVar g_cvIdentityFix; int g_IdentityFix; // abm_identityfix
+ConVar g_cvZoey; int g_Zoey; // abm_zoey
+ConVar g_cvRespawnDelay; float g_RespawnDelay; // abm_respawndelay
+ConVar g_cvWrapSwitch; int g_WrapSwitch; // _abm_wrapswitch
+ConVar g_cvMaxMinions; // z_minion_limit
+ConVar g_cvMaxSurvivors; // survivor_limit
+ConVar g_cvMaxInfecteds; // z_max_player_zombies
+int g_MaxMates; // X vs X
+int g_SILimits;
+
+ConVar g_cvTankHealth;
+ConVar g_cvMaxSwitches;
+ConVar g_cvGameMode;
+ConVar g_cvVDOUHandle;
+ConVar g_cvVDOUOrigin;
+ConVar g_cvConsistency; char g_consistency[2];
+char g_VDOUCurVal[2048];
+char g_VDOUOrigin[2048];
+
+public Plugin myinfo= {
+ name = "ABM",
+ author = "Victor \"NgBUCKWANGS\" Gonzalez",
+ description = "A 5+ Player Enhancement Plugin for L4D2",
+ version = PLUGIN_VERSION,
+ url = "https://gitlab.com/vbgunz/ABM"
+}
+
+public void OnPluginStart() {
+ Echo(2, "OnPluginStart");
+
+ g_GameData = LoadGameConfigFile("abm");
+ if (g_GameData == null) {
+ SetFailState("[ABM] Game data missing!");
+ }
+
+ HookEvent("player_first_spawn", OnSpawnHook);
+ HookEvent("player_spawn", OnAllSpawnHook);
+ HookEvent("player_death", OnDeathHook, EventHookMode_Pre);
+ HookEvent("player_disconnect", CleanQDBHook);
+ HookEvent("player_afk", GoIdleHook);
+ HookEvent("player_team", QTeamHook);
+ HookEvent("player_bot_replace", QAfkHook);
+ HookEvent("bot_player_replace", QBakHook);
+ HookEvent("player_activate", PlayerActivateHook, EventHookMode_Pre);
+ HookEvent("player_connect", PlayerActivateHook, EventHookMode_Pre);
+ HookEvent("round_end", RoundFreezeEndHook, EventHookMode_Pre);
+ HookEvent("mission_lost", RoundFreezeEndHook, EventHookMode_Pre);
+ HookEvent("round_freeze_end", RoundFreezeEndHook, EventHookMode_Pre);
+ HookEvent("map_transition", RoundFreezeEndHook, EventHookMode_Pre);
+ HookEvent("round_start", RoundStartHook, EventHookMode_Pre);
+
+ // base the following on a cvar
+ HookUserMessage(GetUserMessageId("SayText2"), UserMessageHook, true);
+
+ RegAdminCmd("abm", MainMenuCmd, ADMFLAG_GENERIC);
+ RegAdminCmd("abm-menu", MainMenuCmd, ADMFLAG_GENERIC, "Menu: (Main ABM menu)");
+ RegAdminCmd("abm-join", SwitchTeamCmd, ADMFLAG_GENERIC, "Menu/Cmd: | ");
+ RegAdminCmd("abm-takeover", SwitchToBotCmd, ADMFLAG_GENERIC, "Menu/Cmd: | ");
+ RegAdminCmd("abm-respawn", RespawnClientCmd, ADMFLAG_GENERIC, "Menu/Cmd: [ID]");
+ RegAdminCmd("abm-model", AssignModelCmd, ADMFLAG_GENERIC, "Menu/Cmd: | ");
+ RegAdminCmd("abm-strip", StripClientCmd, ADMFLAG_GENERIC, "Menu/Cmd: [SLOT]");
+ RegAdminCmd("abm-teleport", TeleportClientCmd, ADMFLAG_GENERIC, "Menu/Cmd: ");
+ RegAdminCmd("abm-cycle", CycleBotsCmd, ADMFLAG_GENERIC, "Menu/Cmd: | ");
+ RegAdminCmd("abm-reset", ResetCmd, ADMFLAG_GENERIC, "Cmd: (Use only in case of emergency)");
+ RegAdminCmd("abm-info", QuickClientPrintCmd, ADMFLAG_GENERIC, "Cmd: (Print some diagnostic information)");
+ RegAdminCmd("abm-mk", MkBotsCmd, ADMFLAG_GENERIC, "Cmd: ");
+ RegAdminCmd("abm-rm", RmBotsCmd, ADMFLAG_GENERIC, "Cmd: | ");
+ RegAdminCmd("abm-debug", DebugCmd, ADMFLAG_GENERIC, "");
+ RegConsoleCmd("takeover", SwitchToBotCmd, "Menu/Cmd: | ");
+ RegConsoleCmd("join", SwitchTeamCmd, "Menu/Cmd: | ");
+
+ g_OS = GetOS(); // 0: Linux 1: Windows
+ g_QDB = new StringMap();
+ g_QRecord = new StringMap();
+ g_QRtmp = new StringMap();
+ g_Cvars = new StringMap();
+ g_sQueue = new ArrayList(2);
+ g_iQueue = new ArrayList(2);
+
+ char zoeyId[2];
+ switch(g_OS) {
+ case 0: zoeyId = "5"; // 5 is the real Zoey
+ case 1: zoeyId = "1"; // Zoey crashes Windows servers, 1 is Rochelle
+ }
+
+ // remember vscript director options unlocker settings between reloads
+ g_cvVDOUHandle = FindConVar("l4d2_directoroptions_overwrite");
+ SetupCvar(g_cvVDOUOrigin, "_abm_vdouorigin", ";", "DO NOT EDIT");
+
+ if (g_cvVDOUHandle != null) {
+ HookConVarChange(g_cvVDOUHandle, UpdateConVarsHook);
+ GetConVarString(g_cvVDOUOrigin, g_VDOUOrigin, sizeof(g_VDOUOrigin));
+ GetConVarString(g_cvVDOUHandle, g_VDOUCurVal, sizeof(g_VDOUCurVal));
+
+ if(g_VDOUOrigin[0] != ';')
+ UpdateConVarsHook(g_cvVDOUHandle, g_VDOUOrigin, g_VDOUOrigin);
+ else
+ UpdateConVarsHook(g_cvVDOUHandle, g_VDOUCurVal, g_VDOUCurVal);
+ }
+
+ g_cvTankHealth = FindConVar("z_tank_health");
+ g_cvMaxSwitches = FindConVar("vs_max_team_switches");
+ g_cvConsistency = FindConVar("sv_consistency");
+ HookConVarChange(g_cvConsistency, UpdateConVarsHook);
+ g_cvGameMode = FindConVar("mp_gamemode");
+ HookConVarChange(g_cvGameMode, UpdateConVarsHook);
+ UpdateGameMode();
+
+ float maxClients = float(MaxClients);
+ g_cvMaxMinions = FindConVar("z_minion_limit");
+ SetConVarFloat(g_cvMaxMinions, maxClients);
+
+ g_cvMaxInfecteds = FindConVar("z_max_player_zombies");
+ SetConVarBounds(g_cvMaxInfecteds, ConVarBound_Upper, true, maxClients);
+ SetConVarFloat(g_cvMaxInfecteds, maxClients);
+
+ g_cvMaxSurvivors = FindConVar("survivor_limit");
+ SetConVarBounds(g_cvMaxSurvivors, ConVarBound_Upper, true, maxClients);
+ SetConVarFloat(g_cvMaxSurvivors, maxClients);
+
+ // thanks to bl4nk
+ int flags = GetConVarFlags(g_cvMaxSurvivors);
+ flags &= ~FCVAR_NOTIFY;
+ SetConVarFlags(g_cvMaxSurvivors, flags);
+
+ SetupCvar(g_cvVersion, "abm_version", PLUGIN_VERSION, "ABM plugin version");
+ SetupCvar(g_cvLogLevel, "abm_loglevel", "-1", "Development logging level -1: Off, 6: Max");
+ SetupCvar(g_cvMinPlayers, "abm_minplayers", "4", "Pruning extra survivors stops at this size");
+ SetupCvar(g_cvPrimaryWeapon, "abm_primaryweapon", "shotgun_chrome", "5+ survivor primary weapon");
+ SetupCvar(g_cvSecondaryWeapon,"abm_secondaryweapon", "baseball_bat", "5+ survivor secondary weapon");
+ SetupCvar(g_cvThrowable, "abm_throwable", "", "5+ survivor throwable item");
+ SetupCvar(g_cvHealItem, "abm_healitem", "", "5+ survivor healing item");
+ SetupCvar(g_cvConsumable, "abm_consumable", "adrenaline", "5+ survivor consumable item");
+ SetupCvar(g_cvTankChunkHp, "abm_tankchunkhp", "2500", "Health chunk per survivor on 5+ missions");
+ SetupCvar(g_cvSpawnInterval, "abm_spawninterval", "36", "SI full team spawn in (5 x N)");
+ SetupCvar(g_cvAutoHard, "abm_autohard", "1", "0: Off 1: Non-Vs > 4 2: Non-Vs >= 1");
+ SetupCvar(g_cvUnlockSI, "abm_unlocksi", "0", "0: Off 1: Use Left 4 Downtown 2 2: Use VScript Director Options Unlocker");
+ SetupCvar(g_cvJoinMenu, "abm_joinmenu", "1", "0: Off 1: Admins only 2: Everyone");
+ SetupCvar(g_cvTeamLimit, "abm_teamlimit", "16", "Humans on team limit");
+ SetupCvar(g_cvOfferTakeover, "abm_offertakeover", "1", "0: Off 1: Survivors 2: Infected 3: All");
+ SetupCvar(g_cvStripKick, "abm_stripkick", "0", "0: Don't strip removed bots 1: Strip removed bots");
+ SetupCvar(g_cvAutoModel, "abm_automodel", "1", "1: Full set of survivors 0: Map set of survivors");
+ SetupCvar(g_cvKeepDead, "abm_keepdead", "0", "0: The dead return alive 1: the dead return dead");
+ SetupCvar(g_cvIdentityFix, "abm_identityfix", "1", "0: Do not assign identities 1: Assign identities");
+ SetupCvar(g_cvZoey, "abm_zoey", zoeyId, "0:Nick 1:Rochelle 2:Coach 3:Ellis 4:Bill 5:Zoey 6:Francis 7:Louis");
+ SetupCvar(g_cvRespawnDelay, "abm_respawndelay", "1.0", "SI respawn delay time in non-competitive modes");
+ SetupCvar(g_cvWrapSwitch, "abm_wrapswitch", "0", "Intercept chooseteam/jointeam commands");
+
+ // clean out client menu stacks
+ for (int i = 1; i <= MaxClients; i++) {
+ g_menuStack[i] = new ArrayStack(128);
+ }
+
+ // Register everyone that we can find
+ for (int i = 1; i <= MaxClients; i++) {
+ SetQRecord(i, true);
+ }
+
+ AddCommandListener(TeamSwitchIntercept, "jointeam");
+ AddCommandListener(CmdIntercept, "z_spawn");
+ AddCommandListener(CmdIntercept, "z_spawn_old");
+ AddCommandListener(CmdIntercept, "z_add");
+ AutoExecConfig(true, "abm");
+ StartAD();
+}
+
+public void OnPluginEnd() {
+ Echo(2, "OnPluginEnd");
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (GetQRecord(i)) {
+ SetClientName(i, g_name);
+ }
+ }
+}
+
+public Action UserMessageHook(UserMsg MsgId, Handle hBitBuffer, const int[] iPlayers, int iNumPlayers, bool bReliable, bool bInit) {
+ Echo(2, "UserMessageHook: %d %d %d", iNumPlayers, bReliable, bInit);
+ // thanks https://forums.alliedmods.net/showpost.php?p=914509&postcount=10
+
+ // Skip the first two bytes
+ BfReadByte(hBitBuffer);
+ BfReadByte(hBitBuffer);
+
+ // Read the message
+ static char strMessage[1024];
+ BfReadString(hBitBuffer, strMessage, sizeof(strMessage));
+
+ // If the message equals to the string we want to filter, skip.
+ if (StrEqual(strMessage, "#Cstrike_Name_Change")) {
+ return Plugin_Handled;
+ }
+
+ return Plugin_Continue;
+}
+
+public Action TeamSwitchIntercept(int client, const char[] cmd, int args) {
+ Echo(2, "TeamSwitchIntercept: %d %s %d", client, cmd, args);
+
+ if (g_WrapSwitch) {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+
+ if (IsClientValid(client)) {
+ if (StrEqual(g_sB, "survivor", false) || StrEqual(g_sB, "2")) {
+ SwitchTeam(client, 2);
+ }
+
+ else if (StrEqual(g_sB, "infected", false) || StrEqual(g_sB, "3")) {
+ if (g_IsVs || IsAdmin(client)) {
+ SwitchTeam(client, 3);
+ }
+ }
+
+ else if (StrEqual(g_sB, "0") || StrEqual(g_sB, "1")) {
+ SwitchTeam(client, StringToInt(g_sB));
+ }
+
+ else {
+ SwitchTeamCmd(client, 0);
+ }
+
+ return Plugin_Handled;
+ }
+ }
+
+ return Plugin_Continue;
+}
+
+void SetupCvar(Handle &cvHandle, char[] name, char[] value, char[] details) {
+ Echo(2, "SetupCvar: %s %s %s", name, value, details);
+
+ cvHandle = CreateConVar(name, value, details);
+ HookConVarChange(cvHandle, UpdateConVarsHook);
+ UpdateConVarsHook(cvHandle, value, value);
+}
+
+Action CmdIntercept(int client, const char[] cmd, int args) {
+ Echo(2, "CmdIntercept: %d %s %d", client, cmd, args);
+
+ if (g_AssistedSpawning) {
+ GhostsModeProtector();
+ }
+ return Plugin_Continue;
+}
+
+public void OnMapStart() {
+ Echo(2, "OnMapStart:");
+ PrecacheModels();
+}
+
+public void OnMapEnd() {
+ Echo(2, "OnMapEnd:");
+
+ StopAD();
+ StringMapSnapshot keys = g_QDB.Snapshot();
+ g_iQueue.Clear();
+ g_sQueue.Clear();
+
+// if (!g_IsVs) {
+// SetConVarInt(g_cvMaxSurvivors, g_MinPlayers);
+// }
+
+ for (int i; i < keys.Length; i++) {
+ keys.GetKey(i, g_sB, sizeof(g_sB));
+ g_QDB.GetValue(g_sB, g_QRecord);
+
+ g_QRecord.GetValue("onteam", g_onteam);
+ g_QRecord.GetValue("client", g_client);
+ g_QRecord.GetValue("target", g_target);
+ g_QRecord.SetValue("status",true,true);
+
+ if (g_onteam >= 2) {
+ g_QRecord.SetValue("inspec", false, true);
+ }
+
+ if (g_IsVs) {
+ g_QRecord.SetString("model", "", true);
+ }
+
+ else if (g_onteam == 3) {
+ //SwitchToSpec(g_client);
+ g_QRecord.SetValue("status",false, true);
+ g_QRecord.SetString("model", "", true);
+ QueueUp(g_client,3);
+ }
+ }
+
+ delete keys;
+}
+
+public void OnEntityCreated(int ent, const char[] clsName) {
+ Echo(2, "OnEntityCreated: %d %s", ent, clsName);
+
+ if (clsName[0] == 'f') {
+ bool gClip = !StrEqual(clsName, "func_playerghostinfected_clip", false);
+ bool iClip = !StrEqual(clsName, "func_playerinfected_clip", false);
+
+ if (!(gClip && iClip)) {
+ CreateTimer(2.0, KillEntTimer, EntIndexToEntRef(ent));
+ }
+ }
+
+ else if (clsName[0] == 's' && StrEqual(clsName, "survivor_bot")) {
+ SDKHook(ent, SDKHook_SpawnPost, AutoModel);
+ }
+}
+
+public Action KillEntTimer(Handle timer, any ref) {
+ Echo(2, "KillEntTimer: %d", ref);
+
+ int ent = EntRefToEntIndex(ref);
+ if (ent != INVALID_ENT_REFERENCE || IsEntityValid(ent)) {
+ AcceptEntityInput(ent, "kill");
+ }
+
+ return Plugin_Stop;
+}
+
+public Action L4D_OnGetScriptValueInt(const char[] key, int &retVal) {
+ Echo(5, "L4D_OnGetScriptValueInt: %s, %d", key, retVal);
+
+ // see UpdateConVarsHook "g_UnlockSI" for VScript Director Options Unlocker
+
+ if (g_UnlockSI == 1 && g_MaxMates > 4) {
+ int val = retVal;
+
+ if (StrEqual(key, "DominatorLimit")) val = g_MaxMates;
+ else if (StrEqual(key, "MaxSpecials")) val = g_MaxMates;
+ else if (StrEqual(key, "BoomerLimit")) val = g_SILimits;
+ else if (StrEqual(key, "SmokerLimit")) val = g_SILimits;
+ else if (StrEqual(key, "HunterLimit")) val = g_SILimits;
+ else if (StrEqual(key, "ChargerLimit")) val = g_SILimits;
+ else if (StrEqual(key, "SpitterLimit")) val = g_SILimits;
+ else if (StrEqual(key, "JockeyLimit")) val = g_SILimits;
+
+ if (val != retVal) {
+ retVal = val;
+ return Plugin_Handled;
+ }
+ }
+
+ return Plugin_Continue;
+}
+
+public void RoundFreezeEndHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "RoundFreezeEndHook: %s", name);
+ OnMapEnd();
+}
+
+public void PlayerActivateHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "PlayerActivateHook: %s", name);
+
+ int userid = GetEventInt(event, "userid");
+ int client = GetClientOfUserId(userid);
+ PlayerActivate(client);
+}
+
+void PlayerActivate(int client) {
+ Echo(2, "PlayerActivate: %d", client);
+
+ if (GetQRecord(client)) {
+ g_QRecord.SetString("model", "", true);
+ StartAD();
+
+ if (!g_IsVs && g_onteam == 3) {
+ //SwitchTeam(client, 3);
+ QueueUp(client, 3);
+ AddInfected();
+ }
+ }
+}
+
+int GetRealClient(int client) {
+ Echo(2, "GetRealClient: %d", client);
+
+ if (IsClientValid(client, 0)) {
+ if (HasEntProp(client, Prop_Send, "m_humanSpectatorUserID")) {
+ int userid = GetEntProp(client, Prop_Send, "m_humanSpectatorUserID");
+ int target = GetClientOfUserId(userid);
+
+ if (IsClientValid(target)) {
+ client = target;
+ }
+
+ else {
+ for (int i = 1; i <= MaxClients; i++) {
+ if (GetQRtmp(i) && g_tmpTarget == client) {
+ client = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ else {
+ client = 0;
+ }
+
+ return client;
+}
+
+Action LifeCheckTimer(Handle timer, int target) {
+ Echo(2, "LifeCheckTimer: %d", target);
+
+ if (GetQRecord(GetRealClient(target))) {
+ int status = IsPlayerAlive(target);
+
+ if(g_model[0] != EOS) {
+ AssignModel(target, g_model, g_IdentityFix);
+ } else {
+ GetBotCharacter(target, g_model);
+ g_QRecord.SetString("model", g_model, true);
+ }
+
+ g_QRecord.SetValue("status", status, true);
+ AssignModel(g_client, g_model, g_IdentityFix);
+ }
+ return Plugin_Handled;
+}
+
+public void OnAllSpawnHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "OnAllSpawnHook: %s", name);
+
+ int userid = GetEventInt(event, "userid");
+ int client = GetClientOfUserId(userid);
+
+ if (GetQRtmp(client)) {
+ CreateTimer(0.5, LifeCheckTimer, client);
+
+ if (!g_IsVs && g_tmpOnteam == 3 && !g_tmpStatus) {
+ g_QRtmp.SetValue("status", 1, true);
+ State_TransitionSig(client, 8);
+ }
+ }
+}
+
+public void RoundStartHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "RoundStartHook: %s", name);
+ StartAD();
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (GetQRtmp(i)) {
+ if (!g_IsVs && g_tmpOnteam == 3) {
+ //SwitchTeam(i, 3);
+ QueueUp(i, 3);
+ AddInfected();
+ }
+ }
+ }
+}
+
+bool StopAD() {
+ Echo(2, "StopAD");
+
+ if (g_AD != null) {
+ g_ADFreeze = true;
+ g_AssistedSpawning = false;
+ g_survivorSetScan = true;
+ g_ADInterval = 0;
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (g_rDelays[i] != null) {
+ KillTimer(g_rDelays[i]);
+ g_rDelays[i] = null;
+ }
+ }
+
+ if (g_MkBotsTimer != null) {
+ KillTimer(g_MkBotsTimer);
+ g_MkBotsTimer = null;
+ }
+
+ KillTimer(g_AD); // delete causes errors?
+ g_AD = null;
+ }
+
+ return g_AD == null;
+}
+
+bool StartAD(float interval=0.5) {
+ Echo(2, "StartAD");
+
+ if (g_ADAssistant == null) {
+ g_ADAssistant = CreateTimer(0.1, StartADTimer, _, TIMER_REPEAT);
+ }
+
+ if (StopAD()) {
+ g_AD = CreateTimer(interval, ADTimer, _, TIMER_REPEAT);
+ }
+
+ return g_AD != null;
+}
+
+public Action StartADTimer(Handle timer) {
+ Echo(6, "StartADTimer");
+
+ if (g_AD == null) {
+ StartAD();
+ return Plugin_Continue;
+ }
+
+ g_ADAssistant = null;
+ return Plugin_Stop;
+}
+
+bool AllClientsLoadedIn() {
+ Echo(2, "AllClientsLoadedIn");
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (IsClientConnected(i) && !IsClientInGame(i)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+public Action ADTimer(Handle timer) {
+ Echo(6, "ADTimer");
+
+ g_MaxMates = CountTeamMates(2);
+
+ if (g_MaxMates == 0) {
+ return Plugin_Continue;
+ }
+
+ static bool takeover;
+ takeover = !g_IsVs || (g_IsVs && !g_ADFreeze);
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (g_ADFreeze) {
+ g_ADInterval = 0;
+
+ if (g_MaxMates >= 4 || AllClientsLoadedIn()) {
+ while (CountTeamMates(2) < g_MinPlayers) {
+ AddSurvivor();
+ }
+
+ if (AllClientsLoadedIn() && StartAD(5.0)) {
+ RmBots(g_MinPlayers * -1, 2);
+ //SetConVarInt(g_cvMaxSurvivors, MaxClients);
+ g_AssistedSpawning = false;
+ g_ADFreeze = false;
+ }
+ }
+ }
+
+ if (IsClientValid(GetRealClient(i), 2, 0)) {
+ if (IsPlayerAlive(i)) {
+ _AutoModel(i);
+ }
+ }
+
+ else if (GetQRtmp(i)) {
+
+ //if (IsClientValid(g_tmpTarget, 2, 0)) {
+ // ResetClientSpecUserId(i, g_tmpTarget);
+ //}
+
+ if (g_tmpOnteam == 3) {
+ if (!g_IsVs) {
+ g_AssistedSpawning = true;
+
+ if (!g_tmpInspec && GetClientTeam(i) <= 1) {
+ QueueUp(i, 3);
+ AddInfected();
+ }
+ }
+ }
+
+ else if (!g_tmpInspec && GetClientTeam(i) <= 1) {
+ if (takeover) {
+ g_QRtmp.SetValue("onteam", 0,true);
+ CreateTimer(0.1, TakeoverTimer, i);
+ }
+ }
+ }
+ }
+
+ static int lastSize;
+
+ if (lastSize != g_MaxMates) {
+ lastSize = g_MaxMates;
+
+ g_SILimits = 1;
+ while (g_SILimits * 6 < g_MaxMates) {
+ g_SILimits++;
+ }
+
+ VDOUnlocker();
+ g_AutoWave = false;
+
+ if (g_IsCoop) {
+ g_AutoWave = (g_AutoHard == 2 || g_MaxMates > 4 && g_AutoHard == 1);
+ AutoSetTankHp();
+ }
+ }
+
+ if (g_AutoWave || g_AssistedSpawning) {
+ if (g_SpawnInterval > 0 && g_ADInterval >= g_SpawnInterval) {
+ if (g_ADInterval % g_SpawnInterval == 0) {
+ Echo(2, " -- Assisting SI %d: Matching Full Team", g_ADInterval);
+ MkBots(g_MaxMates * -1, 3);
+ }
+
+ else if (g_ADInterval % (g_SpawnInterval / 2) == 0) {
+ Echo(2, " -- Assisting SI %d: Matching Half Team", g_ADInterval);
+ MkBots((g_MaxMates / 2) * -1, 3);
+ }
+
+ else if (g_ADInterval % (g_SpawnInterval / 3) == 0) {
+ Echo(2, " -- Assisting SI %d: Matching a Quarter", g_ADInterval);
+ MkBots((g_MaxMates / 4) * -1, 3);
+ }
+ }
+ }
+
+ g_ADInterval++;
+ return Plugin_Continue;
+}
+
+public void UpdateConVarsHook(Handle convar, const char[] oldCv, const char[] newCv) {
+ GetConVarName(convar, g_sB, sizeof(g_sB));
+ Echo(2, "UpdateConVarsHook: %s %s %s", g_sB, oldCv, newCv);
+
+ static char name[32]; name = "";
+ static char value[2048]; value = "";
+
+ Format(name, sizeof(name), g_sB);
+ Format(value, sizeof(value), "%s", newCv);
+ TrimString(value);
+
+ if (StrContains(newCv, "-l") == 0) {
+ strcopy(value, sizeof(value), value[2]);
+ TrimString(value);
+ g_Cvars.SetString(name, value, true);
+ }
+
+ else if (StrContains(newCv, "-u") == 0) {
+ strcopy(value, sizeof(value), value[2]);
+ TrimString(value);
+ g_Cvars.Remove(name);
+ }
+
+ g_Cvars.GetString(name, value, sizeof(value));
+ if (!StrEqual(newCv, value)) {
+ SetConVarString(convar, value);
+ return;
+ }
+
+ if (name[0] == 'a') {
+ if (name[4] == 'a') {
+ if (name[8] == 'h' && StrEqual(name, "abm_autohard")) {
+ g_AutoHard = GetConVarInt(g_cvAutoHard);
+ AutoSetTankHp();
+ }
+
+ else if (name[8] == 'm' && StrEqual(name, "abm_automodel")) {
+ g_AutoModel = GetConVarInt(g_cvAutoModel);
+ }
+ }
+
+ else if (name[4] == 'c' && StrEqual(name, "abm_consumable")) {
+ GetConVarString(g_cvConsumable, g_Consumable, sizeof(g_Consumable));
+ }
+
+ else if (name[4] == 'h' && StrEqual(name, "abm_healitem")) {
+ GetConVarString(g_cvHealItem, g_HealItem, sizeof(g_HealItem));
+ }
+
+ else if (name[4] == 'i' && StrEqual(name, "abm_identityfix")) {
+ g_IdentityFix = GetConVarInt(g_cvIdentityFix);
+ }
+
+ else if (name[4] == 'j' && StrEqual(name, "abm_joinmenu")) {
+ g_JoinMenu = GetConVarInt(g_cvJoinMenu);
+ }
+
+ else if (name[4] == 'k' && StrEqual(name, "abm_keepdead")) {
+ g_KeepDead = GetConVarInt(g_cvKeepDead);
+ }
+
+ else if (name[4] == 'l' && StrEqual(name, "abm_loglevel")) {
+ g_LogLevel = GetConVarInt(g_cvLogLevel);
+ }
+
+ else if (name[4] == 'm' && StrEqual(name, "abm_minplayers")) {
+ g_MinPlayers = GetConVarInt(g_cvMinPlayers);
+ }
+
+ else if (name[4] == 'o' && StrEqual(name, "abm_offertakeover")) {
+ g_OfferTakeover = GetConVarInt(g_cvOfferTakeover);
+ }
+
+ else if (name[4] == 'p' && StrEqual(name, "abm_primaryweapon")) {
+ GetConVarString(g_cvPrimaryWeapon, g_PrimaryWeapon, sizeof(g_PrimaryWeapon));
+ }
+
+ else if (name[4] == 'r' && StrEqual(name, "abm_respawndelay")) {
+ g_RespawnDelay = GetConVarFloat(g_cvRespawnDelay);
+
+ StringMapSnapshot keys = g_QDB.Snapshot();
+ for (int i; i < keys.Length; i++) {
+ keys.GetKey(i, g_sB, sizeof(g_sB));
+ g_QDB.GetValue(g_sB, g_QRecord);
+ g_QRecord.SetValue("rdelay", g_RespawnDelay, true);
+ }
+
+ delete keys;
+ }
+
+ else if (name[4] == 's') {
+ if (name[5] == 'e' && StrEqual(name, "abm_secondaryweapon")) {
+ GetConVarString(g_cvSecondaryWeapon, g_SecondaryWeapon, sizeof(g_SecondaryWeapon));
+ }
+
+ else if (name[5] == 'p' && StrEqual(name, "abm_spawninterval")) {
+ g_SpawnInterval = GetConVarInt(g_cvSpawnInterval);
+ }
+
+ else if (name[5] == 't' && StrEqual(name, "abm_stripkick")) {
+ g_StripKick = GetConVarInt(g_cvStripKick);
+ }
+ }
+
+ else if (name[4] == 't') {
+ if (name[5] == 'a' && StrEqual(name, "abm_tankchunkhp")) {
+ g_TankChunkHp = GetConVarInt(g_cvTankChunkHp);
+ AutoSetTankHp();
+ }
+
+ else if (name[5] == 'e' && StrEqual(name, "abm_teamlimit")) {
+ g_TeamLimit = GetConVarInt(g_cvTeamLimit);
+ }
+
+ else if (name[5] == 'h' && StrEqual(name, "abm_throwable")) {
+ GetConVarString(g_cvThrowable, g_Throwable, sizeof(g_Throwable));
+ }
+ }
+
+ else if (name[4] == 'u' && StrEqual(name, "abm_unlocksi")) {
+ g_UnlockSI = GetConVarInt(g_cvUnlockSI);
+
+ switch (g_UnlockSI) {
+ case 2: VDOUnlocker();
+ default: RestoreVDOU();
+ }
+ }
+
+ else if (name[4] == 'z' && StrEqual(name, "abm_zoey")) {
+ g_Zoey = GetConVarInt(g_cvZoey);
+ }
+ }
+
+ else if (name[0] == 'l' && StrEqual(name, "l4d2_directoroptions_overwrite")) {
+ g_VDOUCurVal = value;
+
+ if (g_UnlockSI != 2) {
+ g_VDOUOrigin = value;
+ SetConVarString(g_cvVDOUOrigin, value);
+ }
+ }
+
+ else if (name[0] == 'm' && StrEqual(name, "mp_gamemode")) {
+ UpdateGameMode();
+ }
+
+ else if (name[0] == 's' && StrEqual(name, "sv_consistency")) {
+ GetConVarString(g_cvConsistency, g_consistency, sizeof(g_consistency));
+ }
+
+ else if (name[5] == 'w' && StrEqual(name, "_abm_wrapswitch")) {
+ g_WrapSwitch = GetConVarInt(g_cvWrapSwitch);
+ }
+}
+
+int GetGameType() {
+ Echo(2, "GetGameType");
+
+ // 0: coop 1: versus 2: scavenge 3: survival
+ GetConVarString(g_cvGameMode, g_sB, sizeof(g_sB));
+
+ switch (g_sB[0]) {
+ case 'c': {
+ if (StrEqual(g_sB, "coop")) return 0;
+ else if (StrEqual(g_sB, "community1")) return 0; // Special Delivery
+ else if (StrEqual(g_sB, "community2")) return 0; // Flu Season
+ else if (StrEqual(g_sB, "community3")) return 1; // Riding My Survivor
+ else if (StrEqual(g_sB, "community4")) return 3; // Nightmare
+ else if (StrEqual(g_sB, "community5")) return 0; // Death's Door
+ }
+
+ case 'm': {
+ if (StrEqual(g_sB, "mutation1")) return 0; // Last Man on Earth
+ else if (StrEqual(g_sB, "mutation2")) return 0; // Headshot!
+ else if (StrEqual(g_sB, "mutation3")) return 0; // Bleed Out
+ else if (StrEqual(g_sB, "mutation4")) return 0; // Hard Eight
+ else if (StrEqual(g_sB, "mutation5")) return 0; // Four Swordsmen
+ else if (StrEqual(g_sB, "mutation7")) return 0; // Chainsaw Massacre
+ else if (StrEqual(g_sB, "mutation8")) return 0; // Ironman
+ else if (StrEqual(g_sB, "mutation9")) return 0; // Last Gnome on Earth
+ else if (StrEqual(g_sB, "mutation10")) return 0; // Room for One
+ else if (StrEqual(g_sB, "mutation11")) return 1; // Healthpackalypse
+ else if (StrEqual(g_sB, "mutation12")) return 1; // Realism Versus
+ else if (StrEqual(g_sB, "mutation13")) return 2; // Follow the Liter
+ else if (StrEqual(g_sB, "mutation14")) return 0; // Gib Fest
+ else if (StrEqual(g_sB, "mutation15")) return 1; // Versus Survival
+ else if (StrEqual(g_sB, "mutation16")) return 0; // Hunting Party
+ else if (StrEqual(g_sB, "mutation17")) return 0; // Lone Gunman
+ else if (StrEqual(g_sB, "mutation18")) return 1; // Bleed Out Versus
+ else if (StrEqual(g_sB, "mutation19")) return 1; // Taaannnkk!
+ else if (StrEqual(g_sB, "mutation20")) return 0; // Healing Gnome
+ }
+
+ case 'r': {
+ if (StrEqual(g_sB, "realism")) return 0;
+ }
+
+ case 's': {
+ if (StrEqual(g_sB, "scavenge")) return 2;
+ else if (StrEqual(g_sB, "survival")) return 3;
+ }
+
+ case 't': {
+ if (StrEqual(g_sB, "teamscavenge")) return 2;
+ else if (StrEqual(g_sB, "teamversus")) return 1;
+ }
+
+ case 'v': {
+ if (StrEqual(g_sB, "versus")) return 1;
+ }
+ }
+
+ return -1;
+}
+
+void UpdateGameMode() {
+ Echo(2, "UpdateGameMode");
+
+ switch (GetGameType()) {
+ case 0: {
+ g_IsCoop = true;
+ g_IsVs = false;
+ }
+
+ case 1, 2: {
+ g_IsVs = true;
+ g_IsCoop = false;
+ }
+
+ case 3: {
+ g_IsVs = false;
+ g_IsCoop = false;
+ }
+ }
+}
+
+void SetVDOU(char[] val, any ...) {
+ Echo(2, "SetVDOU");
+
+ static const char tmp[128] = "\
+ DominatorLimit=%s;\
+ MaxSpecials=%s;\
+ BoomerLimit=%s;\
+ SmokerLimit=%s;\
+ HunterLimit=%s;\
+ ChargerLimit=%s;\
+ SpitterLimit=%s;\
+ JockeyLimit=%s;";
+
+ VFormat(val, sizeof(tmp), tmp, 2);
+}
+
+void VDOUnlocker() {
+ Echo(2, "VDOUnlocker");
+
+ if (g_cvVDOUHandle != null) {
+ static bool restore = false;
+ g_MaxMates = CountTeamMates(2);
+
+ if (g_UnlockSI == 2 && g_MaxMates > 4) {
+ static char m[3]; static char l[3];
+ Format(m, sizeof(m), "%d", g_MaxMates);
+ Format(l, sizeof(l), "%d", g_SILimits);
+ SetVDOU(g_VDOUCurVal, m, m, l, l, l, l, l, l);
+ SetConVarString(g_cvVDOUHandle, g_VDOUCurVal);
+ restore = true;
+ }
+
+ else if (restore) {
+ RestoreVDOU();
+ restore = false;
+ }
+ }
+}
+
+void RestoreVDOU() {
+ Echo(2, "RestoreVDOU");
+
+ if (!g_ADFreeze && g_cvVDOUHandle != null) {
+ static char origin[2048];
+ origin = g_VDOUOrigin;
+
+ SetVDOU(g_VDOUCurVal, "","","","","","","","");
+ SetConVarString(g_cvVDOUHandle, g_VDOUCurVal);
+ SetConVarString(g_cvVDOUHandle, origin);
+ }
+}
+
+void AutoSetTankHp() {
+ Echo(2, "AutoSetTankHp");
+
+ static int tankHp;
+ GetConVarDefault(g_cvTankHealth, g_sB, sizeof(g_sB));
+ tankHp = StringToInt(g_sB);
+
+ if (g_TankChunkHp != 0 && (g_IsCoop || g_IsVs)) {
+ if (g_AutoHard == 2 || g_MaxMates > 4 && g_AutoHard == 1) {
+ tankHp = g_MaxMates * g_TankChunkHp;
+ }
+ }
+
+ SetConVarInt(g_cvTankHealth, tankHp);
+}
+
+public void OnConfigsExecuted() {
+ Echo(2, "OnConfigsExecuted");
+
+ // extend the base cfg with a map specific cfg
+ GetCurrentMap(g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "cfg/sourcemod/abm/%s.cfg", g_sB);
+
+ if (FileExists(g_sB, true)) {
+ strcopy(g_sB, sizeof(g_sB), g_sB[4]);
+ ServerCommand("exec \"%s\"", g_sB);
+ Echo(1, "Extending ABM: %s", g_sB);
+ }
+
+ // some servers don't pick up on this automatically
+ else if (FileExists("cfg/sourcemod/abm.cfg", true)) {
+ ServerCommand("exec \"sourcemod/abm.cfg\"");
+ }
+}
+
+public void OnClientPostAdminCheck(int client) {
+ Echo(2, "OnClientPostAdminCheck: %d", client);
+
+ if (!IsFakeClient(client)) {
+ if (GetQRecord(client) && !g_update) {
+ return;
+ }
+
+ if (IsAdmin(client) || !GetQRecord(client)) {
+ SetQRecord(client, true);
+ }
+
+ else {
+ int status = g_status;
+ int onteam = g_onteam;
+
+ if (SetQRecord(client, true) >= 0) {
+ g_QRecord.SetValue("status", status, true);
+ g_QRecord.SetValue("onteam", onteam, true);
+ }
+ }
+
+ if (g_JoinMenu == 2 || g_JoinMenu == 1 && IsAdmin(client)) {
+ GoIdle(client, 1);
+ menuArg0 = client;
+ SwitchTeamHandler(client, 1, "");
+ }
+
+ else if (CountTeamMates(2) >= 1) {
+ CreateTimer(0.1, TakeoverTimer, client);
+ CreateTimer(0.5, AutoIdleTimer, client, TIMER_REPEAT);
+ }
+ }
+}
+
+public Action AutoIdleTimer(Handle timer, int client) {
+ Echo(2, "AutoIdleTimer: %d", client);
+
+ if (g_IsVs || !IsClientValid(client)) {
+ return Plugin_Stop;
+ }
+
+ static int onteam;
+ onteam = GetClientTeam(client);
+
+ if (onteam >= 2) {
+ if (onteam == 2) {
+ GoIdle(client, 0);
+ }
+
+ return Plugin_Stop;
+ }
+
+ return Plugin_Continue;
+}
+
+public void GoIdleHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "GoIdleHook: %s", name);
+ int player = GetEventInt(event, "player");
+ int client = GetClientOfUserId(player);
+
+ if (GetQRecord(client)) {
+ switch (g_onteam) {
+ case 2: GoIdle(client);
+ case 3: SwitchTeam(client, 3);
+ }
+ }
+}
+
+void GoIdle(int client, int onteam=0) {
+ Echo(2, "GoIdle: %d %d", client, onteam);
+
+ if (GetQRecord(client)) {
+ int spec_target;
+
+ // going from idle survivor to infected, leaves an icon behind
+ if (IsClientValid(g_target, 2, 0)) {
+ SwitchToBot(client, g_target);
+ }
+
+ if (g_onteam == 2) {
+ SwitchToSpec(client);
+
+ if (onteam == 0) {
+ SetHumanSpecSig(g_target, client);
+ }
+
+ if (onteam == 1) {
+ SwitchToSpec(client);
+ Unqueue(client);
+ }
+
+ AssignModel(g_target, g_model, g_IdentityFix);
+ }
+
+ else {
+ SwitchToSpec(client);
+ }
+
+ if (g_onteam == 3 && onteam <= 1) {
+ g_QRecord.SetString("model", "", true);
+ }
+
+ spec_target = IsClientValid(g_target, 0, 0) ? g_target : GetSafeSurvivor(client);
+
+ if (IsClientValid(spec_target)) {
+ SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", spec_target);
+ SetEntProp(client, Prop_Send, "m_iObserverMode", 5);
+ }
+ }
+}
+
+public void CleanQDBHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "CleanQDBHook: %s", name);
+
+ int userid = GetEventInt(event, "userid");
+ int client = GetClientOfUserId(userid);
+ RemoveQDBKey(client);
+}
+
+void RemoveQDBKey(int client) {
+ Echo(2, "RemoveQDBKey: %d", client);
+
+ if (GetQRecord(client)) {
+ SetClientName(client, g_name);
+ g_QRecord.SetValue("update", true, true);
+ g_QRecord.SetString("model", "", true);
+
+ if (CountTeamMates(2) > g_MinPlayers) {
+ CreateTimer(1.0, RmBotsTimer, 1);
+ }
+ }
+}
+
+Action RmBotsTimer(Handle timer, any asmany) {
+ Echo(4, "RmBotsTimer: %d", asmany);
+
+ if (!g_IsVs) {
+ RmBots(asmany, 2);
+ }
+ return Plugin_Handled;
+}
+
+bool IsAdmin(int client) {
+ Echo(2, "IsAdmin: %d", client);
+ return CheckCommandAccess(
+ client, "generic_admin", ADMFLAG_GENERIC, false
+ );
+}
+
+bool IsEntityValid(int ent) {
+ Echo(2, "IsEntityValid: %d", ent);
+ return (ent > MaxClients && ent <= 2048 && IsValidEntity(ent));
+}
+
+bool IsClientValid(int client, int onteam=0, int mtype=2) {
+ Echo(6, "IsClientValid: %d, %d, %d", client, onteam, mtype);
+
+ if (client >= 1 && client <= MaxClients) {
+ if (IsClientConnected(client)) {
+ if (IsClientInGame(client)) {
+
+ if (onteam != 0 && GetClientTeam(client) != onteam) {
+ return false;
+ }
+
+ switch (mtype) {
+ case 0: return IsFakeClient(client);
+ case 1: return !IsFakeClient(client);
+ }
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool CanClientTarget(int client, int target) {
+ Echo(2, "CanClientTarget: %d %d", client, target);
+
+ if (client == target) {
+ return true;
+ }
+
+ else if (!IsClientValid(client) || !IsClientValid(target)) {
+ return false;
+ }
+
+ else if (IsFakeClient(target)) {
+ int manager = GetClientManager(target);
+
+ if (manager != -1) {
+ if (manager == 0) {
+ return true;
+ }
+
+ else {
+ return CanClientTarget(client, manager);
+ }
+ }
+ }
+
+ return CanUserTarget(client, target);
+}
+
+int GetPlayClient(int client) {
+ Echo(3, "GetPlayClient: %d", client);
+
+ if (GetQRecord(client)) {
+ return g_target;
+ }
+
+ else if (IsClientValid(client)) {
+ return client;
+ }
+
+ return -1;
+}
+
+int ClientHomeTeam(int client) {
+ Echo(2, "ClientHomeTeam: %d", client);
+
+ if (GetQRecord(client)) {
+ return g_onteam;
+ }
+
+ else if (IsClientValid(client)) {
+ return GetClientTeam(client);
+ }
+
+ return -1;
+}
+
+// ================================================================== //
+// g_QDB MANAGEMENT
+// ================================================================== //
+
+bool SetQKey(int client) {
+ Echo(3, "SetQKey: %d", client);
+
+ if (IsClientValid(client, 0, 1)) {
+ if (GetClientAuthId(client, AuthId_Steam2, g_QKey, sizeof(g_QKey), true)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool GetQRtmp(int client) {
+ Echo(3, "GetQRtmp: %d", client);
+
+ bool result;
+ static char QKey[64];
+ QKey = g_QKey;
+
+ if (SetQKey(client)) {
+ if (g_QDB.GetValue(g_QKey, g_QRtmp)) {
+
+ if (IsClientValid(client) && IsPlayerAlive(client)) {
+ GetClientAbsOrigin(client, g_tmpOrigin);
+ g_QRtmp.SetArray("origin", g_tmpOrigin, sizeof(g_tmpOrigin), true);
+ }
+
+ g_QRtmp.GetValue("client", g_tmpClient);
+ g_QRtmp.GetValue("target", g_tmpTarget);
+ g_QRtmp.GetValue("lastid", g_tmpLastid);
+ g_QRtmp.GetValue("onteam", g_tmpOnteam);
+ g_QRtmp.GetValue("queued", g_tmpQueued);
+ g_QRtmp.GetValue("inspec", g_tmpInspec);
+ g_QRtmp.GetValue("status", g_tmpStatus);
+ g_QRtmp.GetValue("update", g_tmpUpdate);
+ g_QRtmp.GetValue("rdelay", g_tmpRdelay);
+ g_QRtmp.GetString("ghost", g_tmpGhost, sizeof(g_tmpGhost));
+ g_QRtmp.GetString("model", g_tmpModel, sizeof(g_tmpModel));
+ g_QRtmp.GetString("name", g_tmpName, sizeof(g_tmpName));
+
+ if (g_tmpModel[0] == EOS || g_tmpOnteam == 3) {
+ GetBotCharacter(g_tmpTarget, g_tmpModel);
+ g_QRtmp.SetString("model", g_tmpModel, true);
+
+ if (!g_IsVs && g_tmpOnteam == 3 && IsPlayerAlive(client)) {
+ SetClientName(client, g_tmpModel);
+ }
+ }
+
+ result = true;
+ }
+ }
+
+ g_QKey = QKey;
+ return result;
+}
+
+bool GetQRecord(int client) {
+ Echo(3, "GetQRecord: %d", client);
+
+ if (SetQKey(client)) {
+ if (g_QDB.GetValue(g_QKey, g_QRecord)) {
+
+ if (IsClientValid(client) && IsPlayerAlive(client)) {
+ GetClientAbsOrigin(client, g_origin);
+ g_QRecord.SetArray("origin", g_origin, sizeof(g_origin), true);
+ }
+
+ g_QRecord.GetValue("client", g_client);
+ g_QRecord.GetValue("target", g_target);
+ g_QRecord.GetValue("lastid", g_lastid);
+ g_QRecord.GetValue("onteam", g_onteam);
+ g_QRecord.GetValue("queued", g_queued);
+ g_QRecord.GetValue("inspec", g_inspec);
+ g_QRecord.GetValue("status", g_status);
+ g_QRecord.GetValue("update", g_update);
+ g_QRecord.GetValue("rdelay", g_rdelay);
+ g_QRecord.GetString("ghost", g_ghost, sizeof(g_ghost));
+ g_QRecord.GetString("model", g_model, sizeof(g_model));
+ g_QRecord.GetString("name", g_name, sizeof(g_name));
+
+ if (g_model[0] == EOS || g_onteam == 3) {
+ GetBotCharacter(g_target, g_model);
+ g_QRecord.SetString("model", g_model, true);
+
+ if (!g_IsVs && g_onteam == 3 && IsPlayerAlive(client)) {
+ SetClientName(client, g_model);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool NewQRecord(int client) {
+ Echo(3, "NewQRecord: %d", client);
+
+ g_QRecord = new StringMap();
+
+ GetClientAbsOrigin(client, g_origin);
+ g_QRecord.SetArray("origin", g_origin, sizeof(g_origin), true);
+ g_QRecord.SetValue("client", client, true);
+ g_QRecord.SetValue("target", client, true);
+ g_QRecord.SetValue("lastid", client, true);
+ g_QRecord.SetValue("onteam", GetClientTeam(client), true);
+ g_QRecord.SetValue("queued", false, true);
+ g_QRecord.SetValue("inspec", false, true);
+ g_QRecord.SetValue("status", true, true);
+ g_QRecord.SetValue("update", false, true);
+ g_QRecord.SetValue("rdelay", g_RespawnDelay, true);
+ g_QRecord.SetString("ghost", "", true);
+ g_QRecord.SetString("model", "", true);
+
+ GetClientName(client, g_name, sizeof(g_name));
+ g_QRecord.SetString("name", g_name, true);
+ return true;
+}
+
+int SetQRecord(int client, bool update=false) {
+ Echo(3, "SetQRecord: %d %d", client, update);
+
+ int result = -1;
+
+ if (SetQKey(client)) {
+ if (g_QDB.GetValue(g_QKey, g_QRecord) && !update) {
+ result = 0;
+ }
+
+ else if (NewQRecord(client)) {
+ GetClientName(client, g_pN, sizeof(g_pN));
+ Echo(0, "AUTH ID: %s, (%s) ADDED TO QDB.", g_QKey, g_pN);
+ g_QDB.SetValue(g_QKey, g_QRecord, true);
+ result = 1;
+ }
+
+ GetQRecord(client);
+ }
+
+ return result;
+}
+
+void QueueUp(int client, int onteam) {
+ Echo(2, "QueueUp: %d %d", client, onteam);
+
+ if (onteam >= 2 && onteam <= 3 && GetQRecord(client)) {
+ Unqueue(client);
+
+ switch (onteam) {
+ case 2: g_sQueue.Push(client);
+ case 3: g_iQueue.Push(client);
+ }
+
+ g_QRecord.SetValue("target", client, true);
+ g_QRecord.SetValue("inspec", false, true);
+ g_QRecord.SetValue("onteam", onteam, true);
+ g_QRecord.SetValue("queued", true, true);
+ }
+}
+
+void Unqueue(int client) {
+ Echo(2, "Unqueue: %d", client);
+
+ if (GetQRecord(client)) {
+ g_QRecord.SetValue("queued", false, true);
+
+ int iLength = g_iQueue.Length;
+ int sLength = g_sQueue.Length;
+
+ if (iLength > 0) {
+ for (int i = iLength - 1; i > -1; i--) {
+ if (g_iQueue.Get(i) == client) {
+ g_iQueue.Erase(i);
+ }
+ }
+ }
+
+ if (sLength > 0) {
+ for (int i = sLength - 1; i > -1; i--) {
+ if (g_sQueue.Get(i) == client) {
+ g_sQueue.Erase(i);
+ }
+ }
+ }
+ }
+}
+
+public Action OnSpawnHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "OnSpawnHook: %s", name);
+
+ int userid = GetEventInt(event, "userid");
+ int target = GetClientOfUserId(userid);
+
+ GetClientName(target, g_pN, sizeof(g_pN));
+ if (g_pN[0] == 'A' && StrContains(g_pN, "ABMclient") >= 0) {
+ return Plugin_Handled;
+ }
+
+ int onteam = GetClientTeam(target);
+ int client;
+
+ if (onteam == 3) {
+ int zClass = GetEntProp(target, Prop_Send, "m_zombieClass");
+
+ if (g_iQueue.Length == 0 && g_UnlockSI != 0) {
+ if (CountTeamMates(3) > g_MaxMates && zClass != 8) {
+ if (IsFakeClient(target)) {
+ KickClient(target);
+ return Plugin_Handled;
+ }
+ }
+ }
+
+ if (!g_IsVs) {
+ if (g_AssistedSpawning) {
+ if (zClass == 8) {
+
+ int j = 1;
+ static int i = 1;
+
+ for (; i <= MaxClients + 1; i++) {
+ if (j++ == MaxClients + 1) { // join 3 Tank requires +1
+ return Plugin_Handled;
+ }
+
+ if (i > MaxClients) {
+ i = 1;
+ }
+
+ if (GetQRecord(i) && g_onteam == 3 && !g_inspec) {
+ if (GetEntProp(i, Prop_Send, "m_zombieClass") != 8) {
+ client = i;
+ i++;
+ break;
+ }
+ }
+ }
+
+ if(IsClientValid(client)) {
+ SwitchToBot(client, target);
+ } else {
+ CreateTimer(1.0, TankAssistTimer, target, TIMER_REPEAT);
+ }
+ }
+ }
+
+ if (g_iQueue.Length > 0) {
+ client = g_iQueue.Get(0);
+ if (IsClientValid(client) && !IsPlayerAlive(client)) {
+ SwitchToBot(client, target);
+ }
+
+ return Plugin_Handled;
+ }
+ }
+ }
+
+ if (onteam == 2) {
+ // AutoModeling now takes place in OnEntityCreated
+ CreateTimer(0.4, OnSpawnHookTimer, target);
+ return Plugin_Handled;
+ }
+
+ return Plugin_Continue;
+}
+
+public Action TankAssistTimer(Handle timer, any client) {
+ Echo(4, "TankAssistTimer: %d", client);
+
+ /*
+ * Human players on the infected team in modes that do not officially
+ * support them, can get Tanks stuck in "stasis" until they die. This
+ * function works around the issue by watching Tanks for movement. If
+ * a Tank does not move in 11 seconds, it is replaced with another.
+ */
+
+ float origin[3];
+ static const float nullOrigin[3];
+ static int times[MAXPLAYERS + 1] = {11, ...};
+ static float origins[MAXPLAYERS + 1][3];
+ static int i;
+
+ if (IsClientValid(client)) {
+ i = times[client]--;
+
+ if (i == 11) {
+ GetClientAbsOrigin(client, origins[client]);
+ return Plugin_Continue;
+ }
+
+ else if (i >= 0) {
+ GetClientAbsOrigin(client, origin);
+
+ if (origin[0] == origins[client][0]) {
+ if (i == 0) {
+ TeleportEntity(client, nullOrigin, NULL_VECTOR, NULL_VECTOR);
+ ForcePlayerSuicide(client);
+ AddInfected("tank");
+ }
+
+ return Plugin_Continue;
+ }
+ }
+ }
+
+ i = times[client] = 11;
+ return Plugin_Stop;
+}
+
+public Action ForceSpawnTimer(Handle timer, any client) {
+ Echo(4, "ForceSpawnTimer: %d", client);
+
+ static int times[MAXPLAYERS + 1] = {20, ...};
+ static int i;
+
+ if (IsClientValid(client)) {
+ i = times[client]--;
+
+ if (GetEntProp(client, Prop_Send, "m_zombieClass") != 8) {
+ i = times[client] = 20;
+ return Plugin_Stop;
+ }
+
+ if (GetEntProp(client, Prop_Send, "m_isGhost") == 1) {
+ if (i >= 1) {
+ PrintHintText(client, "FORCING SPAWN IN: %d", i);
+ return Plugin_Continue;
+ }
+
+ if (GetEntProp(client, Prop_Send, "m_ghostSpawnState") <= 2) {
+ SetEntProp(client, Prop_Send, "m_isGhost", 0);
+ }
+
+ return Plugin_Continue;
+ }
+ }
+
+ if (!IsEntityValid(GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"))) {
+ i = CreateEntityByName("weapon_tank_claw");
+ if (IsEntityValid(i) && DispatchSpawn(i)) {
+ EquipPlayerWeapon(client, i);
+ }
+ }
+
+ i = times[client] = 20;
+ PrintHintText(client, "KILL ALL HUMANS");
+ return Plugin_Stop;
+}
+
+Action OnSpawnHookTimer(Handle timer, any target) {
+ Echo(2, "OnSpawnHookTimer: %d", target);
+
+ if (g_sQueue.Length > 0) {
+ SwitchToBot(g_sQueue.Get(0), target);
+ }
+ return Plugin_Handled;
+}
+
+public void OnDeathHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(4, "OnDeathHook: %s", name);
+
+ int userid = GetEventInt(event, "userid");
+ int client = GetClientOfUserId(userid);
+
+ if (GetQRecord(client)) {
+ GetClientAbsOrigin(client, g_origin);
+ g_QRecord.SetValue("target", client, true);
+ g_QRecord.SetArray("origin", g_origin, sizeof(g_origin), true);
+ g_QRecord.SetValue("status", false, true);
+ bool offerTakeover;
+
+ switch (g_onteam) {
+ case 3: {
+ g_QRecord.SetString("model", "", true);
+
+ if (!g_IsVs) {
+ QueueSI(client, g_rdelay);
+
+ switch (g_OfferTakeover) {
+ case 2, 3: {
+ GoIdle(client, 1);
+ offerTakeover = true;
+ }
+
+ default: SwitchTeam(client, 3);
+ }
+ }
+ }
+
+ case 2: {
+ switch (g_OfferTakeover) {
+ case 1, 3: offerTakeover = true;
+ }
+ }
+ }
+
+ if (offerTakeover) {
+ GenericMenuCleaner(client);
+ menuArg0 = client;
+ SwitchToBotHandler(client, 1);
+ }
+ }
+
+ else if (GetQRecord(GetRealClient(client))) {
+ g_QRecord.SetValue("status", false, true);
+ }
+}
+
+public void QTeamHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "QTeamHook: %s", name);
+
+ int userid = GetEventInt(event, "userid");
+ int client = GetClientOfUserId(userid);
+ int onteam = GetEventInt(event, "team");
+
+ if (GetQRecord(client)) {
+
+ if (!g_IsVs && g_onteam == 3) {
+ SetClientName(client, g_name);
+ }
+
+ if (onteam >= 2) {
+ g_QRecord.SetValue("inspec", false, true);
+ g_QRecord.SetValue("target", client, true);
+ g_QRecord.SetValue("onteam", onteam, true);
+
+ // attempt to apply a model asap
+ if (g_ADFreeze && onteam == 2 && g_model[0] != EOS) {
+ AssignModel(client, g_model, g_IdentityFix);
+ }
+ }
+
+ if (onteam <= 1) { // cycling requires 0.2 or higher?
+ CreateTimer(0.2, QTeamHookTimer, client);
+ }
+ }
+}
+
+Action QTeamHookTimer(Handle timer, any client) {
+ Echo(2, "QTeamHookTimer: %d", client);
+
+ if (GetQRecord(client) && !g_inspec) {
+ if (g_onteam == 2) {
+ if (IsClientValid(g_target) && g_target != client) {
+ SetHumanSpecSig(g_target, client);
+ }
+ }
+ }
+ return Plugin_Handled;
+}
+
+public void QAfkHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "QAfkHook: %s", name);
+
+ int client = GetClientOfUserId(GetEventInt(event, "player"));
+ int target = GetClientOfUserId(GetEventInt(event, "bot"));
+ int clientTeam = GetClientTeam(client);
+ int targetTeam = GetClientTeam(target);
+
+ if (GetQRecord(client)) {
+ int onteam = GetClientTeam(client);
+
+ if (onteam == 2) {
+ g_QRecord.SetValue("target", target, true);
+ AssignModel(target, g_model, g_IdentityFix);
+ }
+ }
+
+ if (targetTeam == 2 && IsClientValid(client)) {
+ if (IsClientInKickQueue(client)) {
+ if (client && target && clientTeam == targetTeam) {
+ int safeClient = GetSafeSurvivor(target);
+ RespawnClient(target, safeClient);
+ }
+ }
+ }
+}
+
+public void QBakHook(Handle event, const char[] name, bool dontBroadcast) {
+ Echo(2, "QBakHook: %s", name);
+
+ int client = GetClientOfUserId(GetEventInt(event, "player"));
+ int target = GetClientOfUserId(GetEventInt(event, "bot"));
+
+ if (GetQRecord(client)) {
+ if (g_target != target) {
+ g_QRecord.SetValue("lastid", target);
+ g_QRecord.SetValue("target", client);
+ }
+
+ if (GetClientTeam(client) == 2) {
+ AssignModel(client, g_model, g_IdentityFix);
+ }
+ }
+}
+
+// ================================================================== //
+// UNORGANIZED AS OF YET
+// ================================================================== //
+
+void StripClient(int client) {
+ Echo(2, "StripClient: %d", client);
+
+ if (IsClientValid(client)) {
+ if (GetClientTeam(client) == 2) {
+ for (int i = 4; i >= 0; i--) {
+ StripClientSlot(client, i);
+ }
+ }
+ }
+}
+
+void StripClientSlot(int client, int slot) {
+ Echo(2, "StripClientSlot: %d %d", client, slot);
+
+ client = GetPlayClient(client);
+
+ if (IsClientValid(client)) {
+ if (GetClientTeam(client) == 2) {
+ int ent = GetPlayerWeaponSlot(client, slot);
+ if (IsEntityValid(ent)) {
+ RemovePlayerItem(client, ent);
+ AcceptEntityInput(ent,"kill");
+ }
+ }
+ }
+}
+
+void RespawnClient(int client, int target=0) {
+ Echo(2, "RespawnClient: %d %d", client, target);
+
+ if (!IsClientValid(client)) {
+ return;
+ }
+
+ else if (GetQRecord(client)) {
+ if (g_onteam == 3) {
+ Takeover(client, 3);
+ return;
+ }
+ }
+
+ client = GetPlayClient(client);
+ target = GetPlayClient(target);
+ bool weaponizePlayer = true;
+ static const float pos0[3];
+ static float pos1[3];
+ pos1 = pos0;
+
+ if (client != GetRealClient(target) && IsClientValid(target)) {
+ GetClientAbsOrigin(target, pos1);
+ }
+
+ else if (GetQRtmp(client)) {
+ pos1 = g_origin;
+ if (pos1[0] != 0 && pos1[1] != 0 && pos1[2] != 0) {
+ weaponizePlayer = false;
+ }
+ }
+
+ if (pos1[0] != 0 && pos1[1] != 0 && pos1[2] != 0) {
+ RoundRespawnSig(client);
+
+ if (!g_ADFreeze && weaponizePlayer) {
+ QuickCheat(client, "give", g_PrimaryWeapon);
+ QuickCheat(client, "give", g_SecondaryWeapon);
+ QuickCheat(client, "give", g_Throwable);
+ QuickCheat(client, "give", g_HealItem);
+ QuickCheat(client, "give", g_Consumable);
+ }
+
+ TeleportEntity(client, pos1, NULL_VECTOR, NULL_VECTOR);
+ }
+}
+
+void TeleportClient(int client, int target) {
+ Echo(2, "TeleportClient: %d %d", client, target);
+
+ float origin[3];
+ client = GetPlayClient(client);
+ target = GetPlayClient(target);
+
+ if (IsClientValid(client) && IsClientValid(target)) {
+ GetClientAbsOrigin(target, origin);
+ TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
+ }
+}
+
+int GetSafeSurvivor(int client) {
+ Echo(2, "GetSafeSurvivor: %d", client);
+
+
+ float lowestIntensity;
+ int lowestClient = -1;
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (IsClientValid(i) && i != client && IsPlayerAlive(i) && GetClientTeam(i) == 2) {
+
+ // Skip if incapped or on a ledge
+ if (GetEntProp(i, Prop_Send, "m_isHangingFromLedge") || GetEntProp(i, Prop_Send, "m_isIncapacitated")) {
+ continue;
+ }
+
+ float intensity = L4D_GetPlayerIntensity(i);
+ if(intensity < lowestIntensity || lowestClient == -1) {
+ lowestIntensity = intensity;
+ lowestClient = i;
+ }
+ }
+ }
+
+ return lowestClient;
+}
+
+bool AddSurvivor() {
+ Echo(2, "AddSurvivor");
+
+ if (GetClientCount(false) >= MaxClients - 1) {
+ return false;
+ }
+
+ bool result = false;
+ if(GetFeatureStatus(FeatureType_Native, "NextBotCreatePlayerBotSurvivorBot") != FeatureStatus_Available) {
+ // Fallback to manual kick trick if no CreateSurvivorBot API
+ int i = CreateFakeClient("ABMclient2");
+ if (IsClientValid(i)) {
+ if (DispatchKeyValue(i, "classname", "SurvivorBot")) {
+ ChangeClientTeam(i, 2);
+
+ if (DispatchSpawn(i)) {
+ result = true;
+ }
+ }
+ KickClient(i);
+ }
+ } else {
+ result = CreateSurvivorBot() > 0;
+ }
+ return result;
+}
+
+bool AddInfected(char model[32]="", int version=0) {
+ Echo(2, "AddInfected: '%s' %d", model, version);
+
+ if (GetClientCount(false) >= MaxClients - 1) {
+ return false;
+ }
+
+ CleanSIName(model);
+ int i = CreateFakeClient("ABMclient3");
+
+ if (IsClientValid(i)) {
+ ChangeClientTeam(i, 3);
+ Format(g_sB, sizeof(g_sB), "%s auto area", model);
+
+ switch (version) {
+ case 0: QuickCheat(i, "z_spawn_old", g_sB);
+ case 1: QuickCheat(i, "z_spawn", g_sB);
+ }
+
+ KickClient(i);
+ return true;
+ }
+
+ return false;
+}
+
+void GhostsModeProtector(int state=0) {
+ Echo(2, "GhostsModeProtector: %d", state);
+ // CAREFUL: 0 starts this function and you must close it with 1 or
+ // risk breaking things. Close this with 1 immediately when done.
+
+ // e.g.,
+ // GhostsModeProtector(0);
+ // z_spawn_old tank auto;
+ // GhostsModeProtector(1);
+
+ static int ghosts[MAXPLAYERS + 1];
+ static int lifeState[MAXPLAYERS + 1]; // prevent early rise from the dead
+
+ switch (state) {
+ case 0: {
+ for (int i = 1; i <= MaxClients; i++) {
+ if (GetQRtmp(i) && g_tmpOnteam == 3) {
+ if (GetEntProp(i, Prop_Send, "m_isGhost") == 1 || g_tmpQueued) {
+ SetEntProp(i, Prop_Send, "m_isGhost", 0);
+ ghosts[i] = 1;
+ }
+
+ if (GetEntProp(i, Prop_Send, "m_lifeState") == 1) {
+ SetEntProp(i, Prop_Send, "m_lifeState", 0);
+ g_QRtmp.SetValue("status", 1, true);
+ lifeState[i] = 1;
+ }
+ }
+ }
+ }
+
+ case 1: {
+ for (int i = 1; i <= MaxClients; i++) {
+ if (ghosts[i] == 1) {
+ SetEntProp(i, Prop_Send, "m_isGhost", 1);
+ }
+
+ if (lifeState[i] == 1) {
+ SetEntProp(i, Prop_Send, "m_lifeState", 1);
+ }
+
+ ghosts[i] = 0;
+ lifeState[i] = 0;
+ }
+ }
+ }
+
+ if (state == 0) {
+ RequestFrame(GhostsModeProtector, 1);
+ }
+}
+
+void CleanSIName(char model[32]) {
+ Echo(2, "CleanSIName: %s", model);
+
+ int i;
+ static char tmpModel[32];
+
+ if (model[0] != EOS) {
+ for (i = 0; i < sizeof(g_InfectedNames); i++) {
+ strcopy(tmpModel, sizeof(tmpModel), g_InfectedNames[i]);
+ if (StrContains(tmpModel, model, false) == 0) {
+ model = tmpModel;
+ return;
+ }
+ }
+
+ if (StrContains("Tank", model, false) == 0) {
+ model = "Tank";
+ return;
+ }
+ }
+
+ i = GetRandomInt(0, sizeof(g_InfectedNames) - 1);
+ strcopy(model, sizeof(model), g_InfectedNames[i]);
+}
+
+void SwitchToSpec(int client, int onteam=1) {
+ Echo(2, "SwitchToSpec: %d %d", client, onteam);
+
+ if (GetQRecord(client)) {
+ // clearparent jockey bug switching teams (thanks to Lux)
+ AcceptEntityInput(client, "clearparent");
+ g_QRecord.SetValue("inspec", true, true);
+ ChangeClientTeam(client, onteam);
+
+ if (GetRealClient(g_target) == client) {
+ if (g_onteam == 2) {
+ AssignModel(g_target, g_model, g_IdentityFix);
+ }
+
+ if (HasEntProp(g_target, Prop_Send, "m_humanSpectatorUserID")) {
+ SetEntProp(g_target, Prop_Send, "m_humanSpectatorUserID", 0);
+ }
+ }
+ }
+}
+
+void QuickCheat(int client, char [] cmd, char [] arg) {
+ Echo(2, "QuickCheat: %d %s %s", client, cmd, arg);
+
+ int flags = GetCommandFlags(cmd);
+ SetCommandFlags(cmd, flags & ~FCVAR_CHEAT);
+ FakeClientCommand(client, "%s %s", cmd, arg);
+ SetCommandFlags(cmd, flags);
+}
+
+void SwitchToBot(int client, int target, bool si_ghost=true) {
+ Echo(2, "SwitchToBot: %d %d %d", client, target, si_ghost);
+
+ if (IsClientValid(target, 0, 0)) {
+ Unqueue(client);
+
+ switch (GetClientTeam(target)) {
+ case 2: TakeoverBotSig(client, target);
+ case 3: TakeoverZombieBotSig(client, target, si_ghost);
+ }
+ }
+}
+
+void Takeover(int client, int onteam) {
+ Echo(2, "Takeover: %d %d", client, onteam);
+
+ if (GetQRecord(client)) {
+ if (IsClientValid(g_target, 0, 0)) {
+ if (client != g_target && GetClientTeam(g_target) == onteam) {
+ SwitchToBot(client, g_target);
+ return;
+ }
+ }
+
+ int nextBot;
+ nextBot = GetNextBot(onteam, 0, true);
+
+ if (IsClientValid(nextBot)) {
+ SwitchToBot(client, nextBot);
+ return;
+ }
+
+ switch (onteam) {
+ case 2: {
+ if (g_KeepDead == 1 && !g_status) {
+ if (g_onteam == 2 && CountTeamMates(2, 0) == 0) {
+ ChangeClientTeam(client, 2);
+ ForcePlayerSuicide(client); // without this player may spawn if survivors are close to start
+ }
+
+ return;
+ }
+
+ QueueUp(client, 2);
+ AddSurvivor();
+ }
+
+ case 3: {
+ QueueUp(client, 3);
+ AddInfected();
+ }
+ }
+ }
+}
+
+public Action TakeoverTimer(Handle timer, any client) {
+ Echo(4, "TakeoverTimer: %d", client);
+
+ if (CountTeamMates(2) <= 0) {
+ return Plugin_Handled;
+ }
+
+ static int team2;
+ static int team3;
+ static int teamX;
+
+ if (GetQRecord(client)) {
+ if (GetClientTeam(client) >= 2) {
+ return Plugin_Handled;
+ }
+
+ teamX = 2;
+ if (g_onteam == 3) {
+ teamX = 3;
+ }
+
+ if (g_IsVs && g_onteam <= 1) {
+ team2 = CountTeamMates(2, 1);
+ team3 = CountTeamMates(3, 1);
+
+ if (team3 < team2) {
+ teamX = 3;
+ }
+ }
+
+ if (CountTeamMates(teamX, 1) < g_TeamLimit) {
+ Takeover(client, teamX);
+ }
+ }
+
+ return Plugin_Handled;
+}
+
+int CountTeamMates(int onteam, int mtype=2) {
+ Echo(2, "CountTeamMates: %d %d", onteam, mtype);
+
+ // mtype 0: counts only bots
+ // mtype 1: counts only humans
+ // mtype 2: counts all players on team
+
+ static int clients, bots, humans;
+ clients = bots = humans = 0;
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (IsClientValid(i, onteam)) {
+ clients++;
+
+ if(IsFakeClient(GetRealClient(i))) {
+ bots++;
+ } else {
+ humans++;
+ }
+ }
+ }
+
+ switch (mtype) {
+ case 0: clients = bots;
+ case 1: clients = humans;
+ }
+
+ return clients;
+}
+
+int GetClientManager(int target) {
+ Echo(4, "GetClientManager: %d", target);
+
+ int result = -1;
+ target = GetRealClient(target);
+
+ if (IsClientValid(target)) {
+ result = IsFakeClient(target) ? 0 : target;
+ }
+
+ return result;
+}
+
+int GetNextBot(int onteam, int start=1, bool alive=false) {
+ Echo(2, "GetNextBot: %d %d %d", onteam, start, alive);
+
+ static int bot, j;
+ bot = 0;
+ j = start;
+
+ if (onteam == 3) {
+ alive = true;
+ }
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (j > 32) {
+ j = 1;
+ }
+
+ if (IsClientValid(j, onteam, 0)) {
+ if (GetClientManager(j) == 0) {
+ if (onteam == 2) {
+ bot = j;
+ }
+
+ if (alive && IsPlayerAlive(j)) {
+ return j;
+ }
+
+ else if (!alive) {
+ return j;
+ }
+ }
+ }
+
+ j++;
+ }
+
+ return bot;
+}
+
+void CycleBots(int client, int onteam) {
+ Echo(2, "CycleBots: %d %d", client, onteam);
+
+ if (onteam <= 1) {
+ return;
+ }
+
+ if (GetQRecord(client)) {
+ int bot = GetNextBot(onteam, g_lastid, true);
+ if (IsClientValid(bot, onteam, 0)) {
+ SwitchToBot(client, bot, false);
+ }
+ }
+}
+
+void SwitchTeam(int client, int onteam, char model[32]="") {
+ Echo(2, "SwitchTeam: %d %d", client, onteam);
+
+ if (GetQRecord(client)) {
+ if (GetClientTeam(client) >= 2) {
+ if (onteam == 2 && onteam == g_onteam) {
+ return; // keep survivors from rejoining survivors
+ }
+ }
+
+ if (g_onteam == 2 && onteam <= 1) {
+ if (IsClientValid(g_target, 0, 0)) {
+ SwitchToBot(client, g_target);
+ }
+ }
+
+ switch (onteam) {
+ case 0: GoIdle(client, 0);
+ case 1: GoIdle(client, 1);
+ //case 4: ChangeClientTeam(client, 4);
+ default: {
+ if (onteam <= 3 && onteam >= 2) {
+ if (g_onteam != onteam) {
+ GoIdle(client, 1);
+ }
+
+ g_QRecord.SetString("model", model, true);
+
+ if (onteam == 3) {
+ if (g_IsVs) { // see if a proper way to get on team 2 exist
+ static int switches; // A Lux idea
+ switches = GetConVarInt(g_cvMaxSwitches);
+ SetConVarInt(g_cvMaxSwitches, 9999);
+ ChangeClientTeam(client, onteam);
+ SetConVarInt(g_cvMaxSwitches, switches);
+ return;
+ }
+
+ g_QRecord.SetValue("onteam", onteam,true);
+ g_QRecord.SetString("ghost", model, true);
+ QueueSI(client, g_rdelay);
+ return;
+ }
+
+ Takeover(client, onteam);
+ }
+ }
+ }
+ }
+}
+
+void QueueSI(int client, float delay=1.0) {
+ Echo(2, "QueueSI: %d %f", client, delay);
+
+ if (g_rDelays[client] != null) {
+ KillTimer(g_rDelays[client]);
+ g_rDelays[client] = null;
+ }
+
+ g_rDelays[client] = CreateTimer(
+ delay, QueueSITimer, client, TIMER_REPEAT
+ );
+}
+
+Action QueueSITimer(Handle Timer, int client) {
+ Echo(2, "QueueSITimer: %d", client);
+
+ if (GetQRecord(client) && g_onteam == 3) {
+ QueueUp(client, 3);
+
+ if (AddInfected(g_ghost, 1)) {
+ g_QRecord.SetValue("rdelay", g_RespawnDelay, true);
+ g_QRecord.SetString("ghost", "", true);
+ }
+ }
+
+ g_rDelays[client] = null;
+ return Plugin_Stop;
+}
+
+Action MkBotsCmd(int client, int args) {
+ Echo(2, "MkBotsCmd: %d", client);
+
+ switch(args) {
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ int asmany = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ int onteam = StringToInt(g_sB);
+
+ if (onteam >= 2 || onteam <= 3) {
+ MkBots(asmany, onteam);
+ }
+ }
+ }
+ return Plugin_Handled;
+}
+
+void MkBots(int asmany, int onteam) {
+ Echo(2, "MkBots: %d %d", asmany, onteam);
+
+ if (asmany < 0) {
+ asmany = asmany * -1 - CountTeamMates(onteam);
+ }
+
+ float rate;
+ DataPack pack = new DataPack();
+
+ switch (onteam) {
+ case 2: rate = 0.2;
+ case 3: rate = 0.4;
+ }
+
+ g_MkBotsTimer = CreateDataTimer(rate, MkBotsTimer, pack, TIMER_REPEAT);
+ pack.WriteCell(asmany);
+ pack.WriteCell(onteam);
+}
+
+public Action MkBotsTimer(Handle timer, Handle pack) {
+ Echo(2, "MkBotsTimer");
+
+ static int i;
+
+ ResetPack(pack);
+ int asmany = ReadPackCell(pack);
+ int onteam = ReadPackCell(pack);
+
+ if (i++ < asmany) {
+ switch (onteam) {
+ case 2: AddSurvivor();
+ case 3: AddInfected();
+ }
+
+ return Plugin_Continue;
+ }
+
+ i = 0;
+ g_MkBotsTimer = null;
+ return Plugin_Stop;
+}
+
+Action RmBotsCmd(int client, int args) {
+ Echo(2, "RmBotsCmd: %d", client);
+
+ int asmany;
+ int onteam;
+
+ switch(args) {
+ case 1: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ onteam = StringToInt(g_sB);
+ asmany = MaxClients;
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ asmany = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ onteam = StringToInt(g_sB);
+ }
+ }
+
+ if (onteam >= 2 || onteam <= 3) {
+ RmBots(asmany, onteam);
+ }
+ return Plugin_Handled;
+}
+
+void RmBots(int asmany, int onteam) {
+ Echo(2, "RmBots: %d %d", asmany, onteam);
+
+ int j;
+
+ if (onteam == 0) {
+ onteam = asmany;
+ asmany = MaxClients;
+ }
+
+ else if (asmany == -0) {
+ return;
+ }
+
+ else if (asmany < 0) {
+ asmany += CountTeamMates(onteam);
+ if (asmany <= 0) {
+ return;
+ }
+ }
+
+ for (int i = MaxClients; i >= 1; i--) {
+ if (GetClientManager(i) == 0 && GetClientTeam(i) == onteam) {
+
+ j++;
+ if (g_StripKick == 1) {
+ StripClient(i);
+ }
+
+ KickClient(i);
+
+ if (j >= asmany) {
+ break;
+ }
+ }
+ }
+}
+
+// ================================================================== //
+// MODEL FEATURES
+// ================================================================== //
+
+
+void AutoModel(int client) {
+ Echo(5, "AutoModel: %d", client);
+ RequestFrame(_AutoModel, client);
+}
+
+public void _AutoModel(int client) {
+ Echo(5, "_AutoModel: %d", client);
+
+ if (IsClientValid(client, 2)) {
+ SDKUnhook(client, SDKHook_SpawnPost, AutoModel);
+ }
+
+ if (g_AutoModel && IsClientValid(client, 2)) {
+ static int realClient;
+ realClient = GetRealClient(client);
+ if (GetQRecord(realClient) && g_model[0] != EOS) {
+ return;
+ }
+
+ static int set, survivors, character;
+ set = GetSurvivorSet(client);
+ GetAllSurvivorModels(client);
+
+ survivors = CountTeamMates(2);
+ character = g_models[GetClientModelIndex(client)];
+ if (character == 0 || character < survivors / 8) {
+ return;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ for (int index = set; index < sizeof(g_models); index++) {
+ if (g_models[index] <= i) {
+ g_models[index]++;
+ AssignModel(client, g_SurvivorNames[index], g_IdentityFix);
+ i = 4; // we want to fall through
+ break;
+ }
+
+ if (set != 0 && index + 1 == sizeof(g_models)) {
+ index=-1; set=0;
+ }
+ }
+ }
+ }
+}
+
+int GetSurvivorSet(int client) {
+ Echo(6, "GetSurvivorSet: %d", client);
+
+ if (g_survivorSetScan && IsClientValid(client, 2)) {
+ g_survivorSetScan = false;
+ g_survivorSet = GetClientModelIndex(client);
+
+ if (g_survivorSet >= 0 && g_survivorSet <= 3) {
+ g_survivorSet = 0;
+ } else {
+ g_survivorSet = 4;
+ }
+ }
+
+ return g_survivorSet;
+}
+
+void GetAllSurvivorModels(int client=-1) {
+ Echo(2, "GetAllSurvivorModels");
+
+ static int index;
+ static const int models[8];
+ g_models = models;
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (client == i) {
+ continue;
+ }
+
+ index = -1;
+
+ if (GetQRecord(i) && g_onteam == 2 && g_model[0] != EOS) {
+ index = GetModelIndexByName(g_model, 2);
+ }
+
+ else if (IsClientValid(i, 2, 0) && GetRealClient(i) == i) {
+ index = GetClientModelIndex(i);
+ }
+
+ if (index >= 0) {
+ g_models[index]++;
+ }
+ }
+}
+
+void PrecacheModels() {
+ Echo(2, "PrecacheModels");
+
+ for (int i = 0; i < sizeof(g_SurvivorPaths); i++) {
+ PrecacheModel(g_SurvivorPaths[i]);
+ }
+}
+
+void AssignModel(int client, char [] model, int identityFix) {
+ Echo(2, "AssignModel: %d %s %d", client, model, identityFix);
+
+ if (identityFix == 1 && IsClientValid(client, 2)) {
+ if (IsClientsModel(client, model)) {
+ return;
+ }
+
+ int i = GetModelIndexByName(model);
+ int realClient = GetRealClient(client);
+
+ if (i >= 0 && i < sizeof(g_SurvivorPaths)) {
+ if(i == 5) {
+ SetEntProp(client, Prop_Send, "m_survivorCharacter", g_Zoey);
+ } else {
+ SetEntProp(client, Prop_Send, "m_survivorCharacter", i);
+ }
+
+ SetEntityModel(client, g_SurvivorPaths[i]);
+ Format(g_pN, sizeof(g_pN), "%s", g_SurvivorNames[i]);
+
+ if (IsFakeClient(client)) {
+ SetClientInfo(client, "name", g_pN);
+ }
+
+ if (GetQRecord(realClient)) {
+ g_QRecord.SetString("model", g_pN, true);
+ }
+ }
+ }
+}
+
+int GetClientModelIndex(int client) {
+ Echo(3, "GetClientModelIndex: %d", client);
+
+ if (!IsClientValid(client)) {
+ return -2;
+ }
+
+ char modelName[64];
+
+ GetEntPropString(client, Prop_Data, "m_ModelName", modelName, sizeof(modelName));
+ for (int i = 0; i < sizeof(g_SurvivorPaths); i++) {
+ if (StrEqual(modelName, g_SurvivorPaths[i], false)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+int GetModelIndexByName(char [] name, int onteam=2) {
+ Echo(2, "GetModelIndexByName: %s %d", name, onteam);
+
+ if (onteam == 2) {
+ for (int i; i < sizeof(g_SurvivorNames); i++) {
+ if (StrContains(name, g_SurvivorNames[i], false) != -1) {
+ return i;
+ }
+ }
+ }
+
+ else if (onteam == 3) {
+ for (int i; i < sizeof(g_InfectedNames); i++) {
+ if (StrContains(g_InfectedNames[i], name, false) != -1) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+}
+
+bool IsClientsModel(int client, char [] name) {
+ Echo(2, "IsClientsModel: %d %s", client, name);
+
+ int modelIndex = GetClientModelIndex(client);
+ Format(g_sB, sizeof(g_sB), "%s", g_SurvivorNames[modelIndex]);
+ return StrEqual(name, g_sB);
+}
+
+void GetBotCharacter(int client, char strBuffer[32]) {
+ Echo(2, "GetBotCharacter: %d", client);
+
+ if (IsClientValid(client)) {
+ strBuffer = "";
+
+ switch (GetClientTeam(client)) {
+ case 2: GetSurvivorCharacter(client, strBuffer);
+ case 3: GetInfectedCharacter(client, strBuffer);
+ }
+ }
+}
+
+void GetSurvivorCharacter(int client, char strBuffer[32]) {
+ Echo(2, "GetSurvivorCharacter: %d %s", client, strBuffer);
+
+ GetEntPropString(client, Prop_Data, "m_ModelName", g_sB, sizeof(g_sB));
+ for (int i = 0; i < sizeof(g_SurvivorPaths); i++) {
+ if (StrEqual(g_SurvivorPaths[i], g_sB)) {
+ Format(strBuffer, sizeof(strBuffer), g_SurvivorNames[i]);
+ break;
+ }
+ }
+}
+
+void GetInfectedCharacter(int client, char strBuffer[32]) {
+ Echo(2, "GetInfectedCharacter: %d %s", client, strBuffer);
+
+ switch (GetEntProp(client, Prop_Send, "m_zombieClass")) {
+ case 1: strBuffer = "Smoker";
+ case 2: strBuffer = "Boomer";
+ case 3: strBuffer = "Hunter";
+ case 4: strBuffer = "Spitter";
+ case 5: strBuffer = "Jockey";
+ case 6: strBuffer = "Charger";
+ case 8: strBuffer = "Tank";
+ }
+}
+
+// ================================================================== //
+// BLACK MAGIC SIGNATURES. SOME SPOOKY SHIT.
+// ================================================================== //
+
+int GetOS() {
+ Echo(2, "GetOS");
+ return GameConfGetOffset(g_GameData, "OS");
+}
+
+void RoundRespawnSig(int client) {
+ Echo(2, "RoundRespawnSig: %d", client);
+
+ static Handle hRoundRespawn;
+ if (hRoundRespawn == null) {
+ StartPrepSDKCall(SDKCall_Player);
+ PrepSDKCall_SetFromConf(g_GameData, SDKConf_Signature, "RoundRespawn");
+ hRoundRespawn = EndPrepSDKCall();
+ }
+
+ if (hRoundRespawn != null) {
+ SDKCall(hRoundRespawn, client);
+ }
+
+ else {
+ PrintToChat(client, "[ABM] RoundRespawnSig Signature broken.");
+ SetFailState("[ABM] RoundRespawnSig Signature broken.");
+ }
+}
+
+void SetHumanSpecSig(int bot, int client) {
+ Echo(2, "SetHumanSpecSig: %d %d", bot, client);
+
+ static Handle hSpec;
+ if (hSpec == null) {
+ StartPrepSDKCall(SDKCall_Player);
+ PrepSDKCall_SetFromConf(g_GameData, SDKConf_Signature, "SetHumanSpec");
+ PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
+ hSpec = EndPrepSDKCall();
+ }
+
+ if (IsClientValid(client) && IsClientValid(bot)) {
+ if(hSpec != null) {
+ SDKCall(hSpec, bot, client);
+ ResetClientSpecUserId(client, bot);
+ }
+
+ else {
+ PrintToChat(client, "[ABM] SetHumanSpecSig Signature broken.");
+ SetFailState("[ABM] SetHumanSpecSig Signature broken.");
+ }
+ }
+}
+
+void ResetClientSpecUserId(int client, int target) {
+ Echo(2, "ResetClientSpecUserId: %d %d", client, target);
+
+ if (!IsClientValid(client) || !IsClientValid(target)) {
+ return;
+ }
+
+ static int spec, userid;
+ userid = GetClientUserId(client);
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (IsClientValid(i, 2, 0)) {
+ if (HasEntProp(i, Prop_Send, "m_humanSpectatorUserID")) {
+ spec = GetEntProp(i, Prop_Send, "m_humanSpectatorUserID");
+ if (userid == spec && i != target) {
+ SetEntProp(i, Prop_Send, "m_humanSpectatorUserID", 0);
+ }
+ }
+ }
+ }
+}
+
+void State_TransitionSig(int client, int mode) {
+ Echo(2, "State_TransitionSig: %d %d", client, mode);
+
+ static Handle hSpec;
+ if (hSpec == null) {
+ StartPrepSDKCall(SDKCall_Player);
+ PrepSDKCall_SetFromConf(g_GameData, SDKConf_Signature, "State_Transition");
+ PrepSDKCall_AddParameter(SDKType_PlainOldData , SDKPass_Plain);
+ hSpec = EndPrepSDKCall();
+ }
+
+ if(hSpec != null) {
+ SDKCall(hSpec, client, mode); // mode 8, press 8 to get closer
+ }
+
+ else {
+ PrintToChat(client, "[ABM] State_TransitionSig Signature broken.");
+ SetFailState("[ABM] State_TransitionSig Signature broken.");
+ }
+}
+
+bool TakeoverBotSig(int client, int target) {
+ Echo(2, "TakeoverBotSig: %d %d", client, target);
+
+ if (!GetQRecord(client)) {
+ return false;
+ }
+
+ static Handle hSwitch;
+
+ if (hSwitch == null) {
+ StartPrepSDKCall(SDKCall_Player);
+ PrepSDKCall_SetFromConf(g_GameData, SDKConf_Signature, "TakeOverBot");
+ PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
+ hSwitch = EndPrepSDKCall();
+ }
+
+ if (hSwitch != null) {
+ if (IsClientInKickQueue(target)) {
+ KickClient(target);
+ }
+
+ else if (IsClientValid(target, 2, 0)) {
+ SwitchToSpec(client);
+
+ if (GetRealClient(target) != client) {
+ GetBotCharacter(target, g_model);
+ g_QRecord.SetString("model", g_model, true);
+ }
+
+ SetHumanSpecSig(target, client);
+ SDKCall(hSwitch, client, true);
+
+ GetConVarString(g_cvGameMode, g_sB, sizeof(g_sB));
+ SendConVarValue(client, g_cvGameMode, g_sB);
+ return true;
+ }
+ }
+
+ else {
+ PrintToChat(client, "[ABM] TakeoverBotSig Signature broken.");
+ SetFailState("[ABM] TakeoverBotSig Signature broken.");
+ }
+
+ g_QRecord.SetValue("lastid", target, true);
+ if (GetClientTeam(client) == 1) {
+ QueueUp(client, 2);
+ }
+
+ return false;
+}
+
+bool TakeoverZombieBotSig(int client, int target, bool si_ghost) {
+ Echo(2, "TakeoverZombieBotSig: %d %d %d", client, target, si_ghost);
+
+ if (!GetQRecord(client)) {
+ return false;
+ }
+
+ static Handle hSwitch;
+
+ if (hSwitch == null) {
+ StartPrepSDKCall(SDKCall_Player);
+ PrepSDKCall_SetFromConf(g_GameData, SDKConf_Signature, "TakeOverZombieBot");
+ PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
+ hSwitch = EndPrepSDKCall();
+ }
+
+ if (hSwitch != null) {
+ if (IsClientInKickQueue(target)) {
+ KickClient(target);
+ }
+
+ else if (IsClientValid(target, 3, 0) && IsPlayerAlive(target)) {
+ SwitchToSpec(client);
+ SDKCall(hSwitch, client, target);
+
+ if (si_ghost) {
+ State_TransitionSig(client, 8);
+ if (GetEntProp(client, Prop_Send, "m_zombieClass") == 8) {
+ CreateTimer(1.0, ForceSpawnTimer, client, TIMER_REPEAT);
+ }
+ }
+
+ // trade off, see ladders, not survivors
+ SendConVarValue(client, g_cvGameMode, "versus");
+ SendConVarValue(client, g_cvConsistency, g_consistency);
+ return true;
+ }
+ }
+
+ else {
+ PrintToChat(client, "[ABM] TakeoverZombieBotSig Signature broken.");
+ SetFailState("[ABM] TakeoverZombieBotSig Signature broken.");
+ }
+
+ g_QRecord.SetValue("lastid", target, true);
+ if (GetClientTeam(client) == 1) {
+ QueueUp(client, 3);
+ }
+
+ return false;
+}
+
+// ================================================================== //
+// PUBLIC INTERFACE AND MENU HANDLERS
+// ================================================================== //
+
+public Action TeleportClientCmd(int client, int args) {
+ Echo(2, "TeleportClientCmd: %d", client);
+
+ int level;
+
+ switch(args) {
+ case 1: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+ }
+
+ if (args) {
+ level = 2;
+ }
+
+ TeleportClientHandler(client, level);
+ return Plugin_Handled;
+}
+
+public void TeleportClientHandler(int client, int level) {
+ Echo(2, "TeleportClientHandler: %d %d", client, level);
+
+ if (!RegMenuHandler(client, "TeleportClientHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Teleport Client", 2, 1);
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Teleporting", g_sB);
+ TeamMatesMenu(client, g_sB, 2, 1);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (GetClientTeam(menuArg0) <= 1) {
+ menuArg0 = GetPlayClient(menuArg0);
+ }
+
+ TeleportClient(menuArg0, menuArg1);
+ }
+
+ GenericMenuCleaner(client);
+ }
+ }
+}
+
+public Action SwitchTeamCmd(int client, int args) {
+ Echo(2, "SwitchTeamCmd: %d", client);
+
+ int level;
+
+ char model[32];
+ GetCmdArg(args, model, sizeof(model));
+ int result = StringToInt(model);
+ CleanSIName(model);
+
+ if (args == 1 || args == 2 && result == 0) {
+ menuArg0 = client;
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+
+ else if (args >= 2) {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+
+ if (args) {
+ level = 2;
+ }
+
+ else if (!IsAdmin(client)) {
+ menuArg0 = client;
+ level = 1;
+ }
+
+ if (menuArg1 != 3) {
+ model = "";
+ }
+
+ SwitchTeamHandler(client, level, model);
+ return Plugin_Handled;
+}
+
+public void SwitchTeamHandler(int client, int level, char model[32]) {
+ Echo(2, "SwitchTeamHandler: %d %d %s", client, level, model);
+
+ if (!RegMenuHandler(client, "SwitchTeamHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Switch Client's Team", 1);
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Switching", g_sB);
+ TeamsMenu(client, g_sB);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (!g_IsVs && !IsAdmin(client) && menuArg1 == 3) {
+ GenericMenuCleaner(client);
+ return;
+ }
+
+ if (GetQRecord(menuArg0)) {
+ g_QRecord.SetValue("rdelay", 0.1, true);
+ SwitchToSpec(menuArg0);
+ }
+
+ SwitchTeam(menuArg0, menuArg1, model);
+ }
+
+ GenericMenuCleaner(client);
+ }
+ }
+}
+
+public Action AssignModelCmd(int client, int args) {
+ Echo(2, "AssignModelCmd: %d", client);
+
+ int level;
+
+ switch(args) {
+ case 1: {
+ menuArg0 = client;
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg1 = GetModelIndexByName(g_sB);
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg1 = GetModelIndexByName(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ }
+ }
+
+ if (args) {
+ level = 2;
+ }
+
+ AssignModelHandler(client, level);
+ return Plugin_Handled;
+}
+
+public void AssignModelHandler(int client, int level) {
+ Echo(2, "AssignModelHandler: %d %d", client, level);
+
+ if (!RegMenuHandler(client, "AssignModelHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Change Client's Model", 2, 0, false);
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Modeling", g_sB);
+ ModelsMenu(client, g_sB);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (GetClientTeam(menuArg0) <= 1) {
+ menuArg0 = GetPlayClient(menuArg0);
+ }
+
+ AssignModel(menuArg0, g_SurvivorNames[menuArg1], 1);
+ }
+
+ GenericMenuCleaner(client);
+ }
+ }
+}
+
+public Action SwitchToBotCmd(int client, int args) {
+ Echo(2, "SwitchToBotCmd: %d", client);
+
+ int level;
+
+ switch(args) {
+ case 1: {
+ menuArg0 = client;
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+ }
+
+ if (args) {
+ level = 2;
+ }
+
+ else if (!IsAdmin(client)) {
+ menuArg0 = client;
+ level = 1;
+ }
+
+ SwitchToBotHandler(client, level);
+ return Plugin_Handled;
+}
+
+public void SwitchToBotHandler(int client, int level) {
+ Echo(2, "SwitchToBotHandler: %d %d", client, level);
+
+ int homeTeam = ClientHomeTeam(client);
+ if (!RegMenuHandler(client, "SwitchToBotHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Takeover Bot", 1);
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Takeover", g_sB);
+ TeamMatesMenu(client, g_sB, 0, 0, true, false, homeTeam);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (IsClientValid(menuArg1)) {
+ if (homeTeam != 3 && GetClientTeam(menuArg1) == 3) {
+ if (!IsAdmin(client)) {
+ GenericMenuCleaner(client);
+ return;
+ }
+ }
+
+ if (GetClientManager(menuArg1) == 0) {
+ SwitchToBot(menuArg0, menuArg1, false);
+ }
+ }
+ }
+
+ GenericMenuCleaner(client);
+ }
+ }
+}
+
+public Action RespawnClientCmd(int client, int args) {
+ Echo(2, "RespawnClientCmd: %d", client);
+
+ int level;
+
+ switch(args) {
+ case 1: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ menuArg1 = menuArg0;
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+ }
+
+ if (args) {
+ level = 2;
+ }
+
+ RespawnClientHandler(client, level);
+ return Plugin_Handled;
+}
+
+public void RespawnClientHandler(int client, int level) {
+ Echo(2, "RespawnClientHandler: %d %d", client, level);
+
+ if (!RegMenuHandler(client, "RespawnClientHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Respawn Client");
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Respawning", g_sB);
+ TeamMatesMenu(client, g_sB);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (GetClientTeam(menuArg0) <= 1) {
+ menuArg0 = GetPlayClient(menuArg0);
+ }
+
+ RespawnClient(menuArg0, menuArg1);
+ }
+
+ GenericMenuCleaner(client);
+ }
+ }
+}
+
+public Action CycleBotsCmd(int client, int args) {
+ Echo(2, "CycleBotsCmd: %d", client);
+
+ int level;
+
+ switch(args) {
+ case 1: {
+ menuArg0 = client;
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+ }
+
+ if (args) {
+ if (menuArg1 > 3 || menuArg1 < 2) {
+ return Plugin_Handled;
+ }
+
+ level = 2;
+ }
+
+ CycleBotsHandler(client, level);
+ return Plugin_Handled;
+}
+
+public void CycleBotsHandler(int client, int level) {
+ Echo(2, "CycleBotsHandler: %d %d", client, level);
+
+ if (!RegMenuHandler(client, "CycleBotsHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Cycle Client", 1);
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Cycling", g_sB);
+ TeamsMenu(client, g_sB, false);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (!IsAdmin(client) && menuArg1 == 3) {
+ GenericMenuCleaner(client);
+ return;
+ }
+
+ CycleBots(menuArg0, menuArg1);
+ menuArg1 = 0;
+ }
+
+ CycleBotsHandler(client, 1);
+ }
+ }
+}
+
+public Action StripClientCmd(int client, int args) {
+ Echo(2, "StripClientCmd: %d", client);
+
+ int target;
+ int level;
+
+ switch(args) {
+ case 1: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ target = StringToInt(g_sB);
+ target = GetPlayClient(target);
+
+ if (CanClientTarget(client, target)) {
+ StripClient(target);
+ }
+
+ return Plugin_Handled;
+ }
+
+ case 2: {
+ GetCmdArg(1, g_sB, sizeof(g_sB));
+ menuArg0 = StringToInt(g_sB);
+ GetCmdArg(2, g_sB, sizeof(g_sB));
+ menuArg1 = StringToInt(g_sB);
+ }
+ }
+
+ if (args) {
+ level = 2;
+ }
+
+ StripClientHandler(client, level);
+ return Plugin_Handled;
+}
+
+public void StripClientHandler(int client, int level) {
+ Echo(2, "StripClientHandler: %d %d", client, level);
+
+ if (!RegMenuHandler(client, "StripClientHandler", level, 0)) {
+ return;
+ }
+
+ switch(level) {
+ case 0: TeamMatesMenu(client, "Strip Client", 2, 1);
+ case 1: {
+ GetClientName(menuArg0, g_sB, sizeof(g_sB));
+ Format(g_sB, sizeof(g_sB), "%s: Stripping", g_sB);
+ InvSlotsMenu(client, menuArg0, g_sB);
+ }
+
+ case 2: {
+ if (CanClientTarget(client, menuArg0)) {
+ if (GetClientTeam(menuArg0) <= 1) {
+ menuArg0 = GetPlayClient(menuArg0);
+ }
+
+ StripClientSlot(menuArg0, menuArg1);
+ menuArg1 = 0;
+ StripClientHandler(client, 1);
+ }
+ }
+ }
+}
+
+public Action ResetCmd(int client, int args) {
+ Echo(2, "ResetCmd: %d", client);
+
+ for (int i = 1; i <= MaxClients; i++) {
+ GenericMenuCleaner(i);
+ if (GetQRecord(i)) {
+ CancelClientMenu(i, true, null);
+ }
+ }
+ return Plugin_Handled;
+}
+
+bool RegMenuHandler(int client, char [] handler, int level, int clearance=0) {
+ Echo(2, "RegMenuHandler: %d %s %d %d", client, handler, level, clearance);
+
+ g_callBacks.PushString(handler);
+ if (!IsAdmin(client) && level <= clearance) {
+ GenericMenuCleaner(client);
+ return false;
+ }
+
+ return true;
+}
+
+public Action MainMenuCmd(int client, int args) {
+ Echo(2, "MainMenuCmd: %d", client);
+
+ GenericMenuCleaner(client);
+ MainMenuHandler(client, 0);
+ return Plugin_Handled;
+}
+
+public void MainMenuHandler(int client, int level) {
+ Echo(2, "MainMenuHandler: %d %d", client, level);
+
+ if (!RegMenuHandler(client, "MainMenuHandler", level, 0)) {
+ return;
+ }
+
+ int cmd = menuArg0;
+ menuArg0 = 0;
+
+ char title[32];
+ Format(title, sizeof(title), "ABM Menu %s", PLUGIN_VERSION);
+
+ switch(level) {
+ case 0: MainMenu(client, title);
+ case 1: {
+ switch(cmd) {
+ case 0: TeleportClientCmd(client, 0);
+ case 1: SwitchTeamCmd(client, 0);
+ case 2: AssignModelCmd(client, 0);
+ case 3: SwitchToBotCmd(client, 0);
+ case 4: RespawnClientCmd(client, 0);
+ case 5: CycleBotsCmd(client, 0);
+ case 6: StripClientCmd(client, 0);
+ }
+ }
+ }
+}
+
+// ================================================================== //
+// MENUS BACKBONE
+// ================================================================== //
+
+void GenericMenuCleaner(int client, bool clearStack=true) {
+ Echo(2, "GenericMenuCleaner: %d %d", client, clearStack);
+
+ for (int i = 0; i < sizeof(g_menuItems[]); i++) {
+ g_menuItems[client][i] = 0;
+ }
+
+ if (clearStack == true) {
+ if (g_callBacks != null) {
+ delete g_callBacks;
+ }
+
+ g_callBacks = new ArrayStack(128);
+ }
+}
+
+public int GenericMenuHandler(Menu menu, MenuAction action, int param1, int param2) {
+ Echo(2, "GenericMenuHandler: %d %d", param1, param2);
+
+ int client = param1;
+ int i; // -1;
+ char sB[128];
+
+ if (IsClientValid(param1)) {
+ for (i = 0; i < sizeof(g_menuItems[]); i++) {
+ if (menuArgs[i] == 0) {
+ break;
+ }
+ }
+ }
+
+ switch(action) {
+ case MenuAction_Select: {
+ menu.GetItem(param2, g_sB, sizeof(g_sB));
+ menuArgs[i] = StringToInt(g_sB);
+ i = i + 1;
+ }
+
+ case MenuAction_Cancel: {
+ if (param2 == MenuCancel_ExitBack) {
+ if (i > 0) {
+ i = i - 1;
+ menuArgs[i] = 0;
+ }
+
+ else if (i == 0) {
+
+ if (g_callBacks.Empty) {
+ GenericMenuCleaner(param1);
+ return 0;
+ }
+
+ g_callBacks.PopString(g_sB, sizeof(g_sB));
+ GenericMenuCleaner(param1, false);
+
+ while (!g_callBacks.Empty) {
+ g_callBacks.PopString(sB, sizeof(sB));
+
+ if (!StrEqual(g_sB, sB)) {
+ g_callBacks.PushString(sB);
+ break;
+ }
+ }
+
+ if (g_callBacks.Empty) {
+ GenericMenuCleaner(param1);
+ return 0;
+ }
+ }
+ }
+
+ else {
+ return 0;
+ }
+ }
+
+ case MenuAction_End: {
+ delete menu;
+ return 0;
+ }
+ }
+
+ if (g_callBacks == null || g_callBacks.Empty) {
+ GenericMenuCleaner(param1);
+ return 0;
+ }
+
+ g_callBacks.PopString(g_sB, sizeof(g_sB));
+ callBack = GetFunctionByName(null, g_sB);
+
+ Call_StartFunction(null, callBack);
+ Call_PushCell(param1);
+ Call_PushCell(i);
+ Call_Finish();
+ return 0;
+}
+
+// ================================================================== //
+// MENUS
+// ================================================================== //
+
+void MainMenu(int client, char [] title) {
+ Echo(2, "MainMenu: %d %s", client, title);
+
+ Menu menu = new Menu(GenericMenuHandler);
+ menu.SetTitle(title);
+ menu.AddItem("0", "Teleport Client"); // "Telespiznat"); // teleport
+ menu.AddItem("1", "Switch Client Team"); //"Swintootle"); // switch team
+ menu.AddItem("2", "Change Client Model"); //"Changdangle"); // makeover
+ menu.AddItem("3", "Switch Client Bot"); //"Inbosnachup"); // takeover
+ menu.AddItem("4", "Respawn Client"); //"Respiggle"); // respawn
+ menu.AddItem("5", "Cycle Client"); //"Cycolicoo"); // cycle
+ menu.AddItem("6", "Strip Client"); //"Upsticky"); // strip
+ menu.ExitBackButton = true;
+ menu.ExitButton = true;
+ menu.Display(client, 120);
+}
+
+void InvSlotsMenu(int client, int target, char [] title) {
+ Echo(2, "InvSlotsMenu: %d %d %s", client, target, title);
+
+ int ent;
+ char weapon[64];
+ Menu menu = new Menu(GenericMenuHandler);
+ menu.SetTitle(title);
+
+ for (int i; i < 5; i++) {
+ IntToString(i, g_sB, sizeof(g_sB));
+ ent = GetPlayerWeaponSlot(target, i);
+
+ if (IsEntityValid(ent)) {
+ GetEntityClassname(ent, weapon, sizeof(weapon));
+ menu.AddItem(g_sB, weapon);
+ }
+ }
+
+ menu.ExitBackButton = true;
+ menu.ExitButton = true;
+ menu.Display(client, 120);
+}
+
+void ModelsMenu(int client, char [] title) {
+ Echo(2, "ModelsMenu: %d %s", client, title);
+
+ Menu menu = new Menu(GenericMenuHandler);
+ menu.SetTitle(title);
+
+ for (int i; i < sizeof(g_SurvivorNames); i++) {
+ IntToString(i, g_sB, sizeof(g_sB));
+ menu.AddItem(g_sB, g_SurvivorNames[i]);
+ }
+
+ menu.ExitBackButton = true;
+ menu.ExitButton = true;
+ menu.Display(client, 120);
+}
+
+void TeamsMenu(int client, char [] title, bool all=true) {
+ Echo(2, "TeamsMenu: %d %s %d", client, title, all);
+
+ Menu menu = new Menu(GenericMenuHandler);
+ menu.SetTitle(title);
+
+ if (all) {
+ menu.AddItem("0", "Idler");
+ menu.AddItem("1", "Spectator");
+ }
+
+ menu.AddItem("2", "Survivor");
+ if (g_IsVs || IsAdmin(client)) {
+ menu.AddItem("3", "Infected");
+ }
+
+ menu.ExitBackButton = true;
+ menu.ExitButton = true;
+ menu.Display(client, 120);
+}
+
+void TeamMatesMenu(int client, char [] title, int mtype=2, int target=0, bool incDead=true,
+ bool repeat=false, int homeTeam=0) {
+ Echo(2, "TeamMatesMenu: %d %s %d %d %d %d %d", client, title, mtype, target, incDead, repeat, homeTeam);
+
+ Menu menu = new Menu(GenericMenuHandler);
+ menu.SetTitle(title);
+ int isAdmin = IsAdmin(client);
+ char health[32];
+ bool mflag = false;
+ int isAlive;
+ int playClient;
+ int bossClient;
+ int targetClient;
+ int manager;
+
+ for (int i = 1; i <= MaxClients; i++) {
+ bossClient = i;
+ playClient = i;
+
+ if (GetQRecord(i)) {
+
+ if (mtype == 0) {
+ continue;
+ }
+
+ if (mtype == 1 || mtype == 2) {
+ mflag = true;
+ }
+
+ if (IsClientValid(g_target) && g_target != i) {
+ isAlive = IsPlayerAlive(g_target);
+ playClient = g_target;
+ }
+
+ else {
+ isAlive = IsPlayerAlive(i);
+ }
+ }
+
+ else if (IsClientValid(i)) {
+ isAlive = IsPlayerAlive(i);
+
+ if (mtype == 0 || mtype == 2) {
+ mflag = true;
+ }
+
+ manager = GetClientManager(i);
+
+ if (manager != 0) {
+ if (target == 0 || !repeat) {
+ mflag = false;
+ continue;
+ }
+
+ bossClient = manager;
+ }
+ }
+
+ else {
+ continue;
+ }
+
+ // at this point the client is valid.
+ // bossClient is the human (if there is one)
+ // playClient is the bot (or human if not idle)
+
+ if (!isAlive && !incDead) {
+ continue;
+ }
+
+ if (GetClientTeam(playClient) != homeTeam && !isAdmin) {
+ continue;
+ }
+
+ switch(target) {
+ case 0: targetClient = bossClient;
+ case 1: targetClient = playClient;
+ }
+
+ if (mflag) {
+ mflag = false;
+
+ Format(health, sizeof(health), "%d", GetClientHealth(playClient));
+ if (!IsPlayerAlive(playClient)) {
+ Format(health, sizeof(health), "DEAD");
+ }
+
+ else if (GetEntProp(playClient, Prop_Send, "m_isIncapacitated")) {
+ Format(health, sizeof(health), "DOWN");
+ }
+
+ GetClientName(bossClient, g_pN, sizeof(g_pN));
+ Format(g_pN, sizeof(g_pN), "%s (%s)", g_pN, health);
+ IntToString(targetClient, g_sB, sizeof(g_sB));
+
+ if(bossClient == client && menu.ItemCount > 0) {
+ menu.InsertItem(0, g_sB, g_pN);
+ } else {
+ menu.AddItem(g_sB, g_pN);
+ }
+ }
+ }
+
+ menu.ExitBackButton = true;
+ menu.ExitButton = true;
+ menu.Display(client, 120);
+}
+
+// ================================================================== //
+// MISC STUFF USEFUL FOR TROUBLESHOOTING
+// ================================================================== //
+
+void Echo(int level, char [] format, any ...) {
+ static char g_dB[512];
+
+ if (g_LogLevel >= level) {
+ VFormat(g_dB, sizeof(g_dB), format, 3);
+ LogToFile(LOGFILE, g_dB);
+ PrintToServer("%s", g_dB);
+ }
+}
+
+void QDBCheckCmd(int client) {
+ Echo(2, "QDBCheckCmd");
+
+ PrintToConsole(client, "-- STAT: QDB Size is %d", g_QDB.Size);
+ PrintToConsole(client, "-- MinPlayers is %d", g_MinPlayers);
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (GetQRtmp(i)) {
+ PrintToConsole(client, "\n -");
+ GetClientName(i, g_pN, sizeof(g_pN));
+
+ float x = g_origin[0];
+ float y = g_origin[1];
+ float z = g_origin[2];
+
+ PrintToConsole(client, " - Name: %s", g_pN);
+ PrintToConsole(client, " - Origin: {%d.0, %d.0, %d.0}", x, y, z);
+ PrintToConsole(client, " - Status: %d", g_tmpStatus);
+ PrintToConsole(client, " - Client: %d", g_tmpClient);
+ PrintToConsole(client, " - Target: %d", g_tmpTarget);
+ PrintToConsole(client, " - LastId: %d", g_tmpLastid);
+ PrintToConsole(client, " - OnTeam: %d", g_tmpOnteam);
+ PrintToConsole(client, " - Queued: %d", g_tmpQueued);
+ PrintToConsole(client, " - InSpec: %d", g_tmpInspec);
+ PrintToConsole(client, " - Model: %s", g_tmpModel);
+ PrintToConsole(client, " -\n");
+ }
+ }
+}
+
+Action QuickClientPrintCmd(int client, int args) {
+ Echo(2, "QuickClientPrintCmd: %d", client);
+
+ int onteam;
+ int state;
+ int manager;
+
+ PrintToConsole(client, "\nTeam\tState\tId\tManager\tName");
+
+ for (int i = 1; i <= MaxClients; i++) {
+ if (IsClientValid(i)) {
+ manager = i;
+ GetClientName(i, g_pN, sizeof(g_pN));
+ onteam = GetClientTeam(i);
+ state = IsPlayerAlive(i);
+
+
+ if (IsFakeClient(i)) {
+ manager = GetClientManager(i);
+ }
+
+ PrintToConsole(client,
+ "%d, \t%d, \t%d, \t%d, \t%s", onteam, state, i, manager, g_pN
+ );
+ }
+ }
+
+ QDBCheckCmd(client);
+ return Plugin_Handled;
+}
+Action DebugCmd(int client, int args) {
+ ReplyToCommand(client, "CreateSurvivorBot: %b", GetFeatureStatus(FeatureType_Native, "NextBotCreatePlayerBotSurvivorBot") == FeatureStatus_Available);
+ return Plugin_Handled;
+}
\ No newline at end of file
diff --git a/scripting/activitymonitor.sp b/scripting/activitymonitor.sp
new file mode 100644
index 0000000..e63f560
--- /dev/null
+++ b/scripting/activitymonitor.sp
@@ -0,0 +1,305 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+//#define DEBUG
+#define PUSH_TIMER 60.0
+
+#define PLUGIN_VERSION "1.0"
+
+#include
+#include
+//#include
+
+public Plugin myinfo =
+{
+ name = "Admin Activity Log",
+ author = "jackzmc",
+ description = "",
+ version = PLUGIN_VERSION,
+ url = "https://github.com/Jackzmc/sourcemod-plugins"
+};
+
+enum struct Log {
+ char name[32];
+ char clientSteamID[32];
+ char targetSteamID[32];
+ char message[256];
+ int timestamp;
+}
+// Plugin data
+static ArrayList logs;
+static Database g_db;
+static char serverID[64];
+static Handle pushTimer;
+static ConVar hLogCvarChanges;
+static char lastMap[64];
+
+//Plugin related
+static bool lateLoaded;
+static EngineVersion g_Game;
+
+//L4d2 Specific
+static char L4D2_ZDifficulty[16];
+//Generic
+static char currentGamemode[32];
+
+char playerLastName[MAXPLAYERS+1][32];
+
+public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
+{
+ CreateNative("ActivityMonitor_AddLog", Native_AddLog);
+ lateLoaded = late;
+ return APLRes_Success;
+}
+
+public void OnPluginStart() {
+ g_Game = GetEngineVersion();
+ logs = new ArrayList(sizeof(Log));
+
+ if(!SQL_CheckConfig("activitymonitor")) {
+ SetFailState("No database entry for 'activitymonitor'; no database to connect to.");
+ } else if(!ConnectDB()) {
+ SetFailState("Failed to connect to database.");
+ }
+
+ hLogCvarChanges = CreateConVar("sm_activitymonitor_log_cvar", "0", "Should this plugin log cvar changes (when using sm_cvar from console)");
+ ConVar hServerID = CreateConVar("sm_activitymonitor_id", "", "The name to use for the 'server' column", FCVAR_DONTRECORD);
+ hServerID.GetString(serverID, sizeof(serverID));
+ hServerID.AddChangeHook(CVAR_ServerIDChanged);
+
+ HookEvent("player_first_spawn", Event_Connection);
+ HookEvent("player_disconnect", Event_Connection);
+ if(g_Game == Engine_Left4Dead2 || g_Game == Engine_Left4Dead) {
+ HookEvent("player_incapacitated", Event_L4D2_Incapped);
+ HookEvent("player_death", Event_L4D2_Death);
+ ConVar zDifficulty = FindConVar("z_difficulty");
+ zDifficulty.GetString(L4D2_ZDifficulty, sizeof(L4D2_ZDifficulty));
+ CVAR_DifficultyChanged(zDifficulty, "", L4D2_ZDifficulty);
+ zDifficulty.AddChangeHook(CVAR_DifficultyChanged);
+
+ zDifficulty.GetString(L4D2_ZDifficulty, sizeof(L4D2_ZDifficulty));
+ CVAR_DifficultyChanged(zDifficulty, "", L4D2_ZDifficulty);
+ zDifficulty.AddChangeHook(CVAR_DifficultyChanged);
+ }
+
+ ConVar mpGamemode = FindConVar("mp_gamemode");
+ if(mpGamemode != null) {
+ mpGamemode.GetString(currentGamemode, sizeof(currentGamemode));
+ mpGamemode.AddChangeHook(CVAR_GamemodeChanged);
+ }
+
+
+ if(!lateLoaded) {
+ AddLog("INFO", "", "", "Server has started up");
+ }
+
+ pushTimer = CreateTimer(PUSH_TIMER, Timer_PushLogs, _, TIMER_REPEAT);
+ // AutoExecConfig(true, "activitymonitor");
+}
+
+public void OnPluginEnd() {
+ TriggerTimer(pushTimer, true);
+}
+
+public void OnMapEnd() {
+ TriggerTimer(pushTimer, true);
+}
+
+public void OnMapStart() {
+ static char curMap[64];
+ GetCurrentMap(curMap, sizeof(curMap));
+ if(!StrEqual(lastMap, curMap)) {
+ strcopy(lastMap, sizeof(lastMap), curMap);
+ if(g_Game == Engine_Left4Dead2 || g_Game == Engine_Left4Dead)
+ Format(curMap, sizeof(curMap), "Map changed to %s (%s %s)", curMap, L4D2_ZDifficulty, currentGamemode);
+ else
+ Format(curMap, sizeof(curMap), "Map changed to %s (%s)", curMap, currentGamemode);
+ AddLog("INFO", "", "", curMap);
+ }
+ TriggerTimer(pushTimer, true);
+}
+
+public void CVAR_GamemodeChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
+ strcopy(currentGamemode, sizeof(currentGamemode), newValue);
+}
+
+public void CVAR_ServerIDChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
+ strcopy(serverID, sizeof(serverID), newValue);
+}
+
+public void CVAR_DifficultyChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
+ if(StrEqual(newValue, "Hard", false)) strcopy(L4D2_ZDifficulty, sizeof(L4D2_ZDifficulty), "Advanced");
+ else if(StrEqual(newValue, "Impossible", false)) strcopy(L4D2_ZDifficulty, sizeof(L4D2_ZDifficulty), "Expert");
+ else {
+ strcopy(L4D2_ZDifficulty, sizeof(L4D2_ZDifficulty), newValue);
+ // CVAR value could be lowercase 'normal', convert to 'Normal'
+ L4D2_ZDifficulty[0] = CharToUpper(L4D2_ZDifficulty[0]);
+ }
+}
+
+bool ConnectDB() {
+ char error[255];
+ g_db = SQL_Connect("activitymonitor", true, error, sizeof(error));
+ if (g_db == null) {
+ LogError("Database error %s", error);
+ delete g_db;
+ return false;
+ } else {
+ PrintToServer("[ACTM] Connected to database \"activitymonitor\"");
+ SQL_LockDatabase(g_db);
+ SQL_FastQuery(g_db, "SET NAMES \"UTF8mb4\"");
+ SQL_UnlockDatabase(g_db);
+ g_db.SetCharset("utf8mb4");
+ return true;
+ }
+}
+
+public Action Timer_PushLogs(Handle h) {
+ static char query[1024];
+ static Log log;
+ int length = logs.Length;
+
+ if(length > 0) {
+ Transaction transaction = new Transaction();
+ for(int i = 0; i < length; i++) {
+ logs.GetArray(i, log, sizeof(log));
+ g_db.Format(query, sizeof(query), "INSERT INTO `activity_log` (`timestamp`, `server`, `type`, `client`, `target`, `message`) VALUES (%d, NULLIF('%s', ''), '%s', NULLIF('%s', ''), NULLIF('%s', ''), NULLIF('%s', ''))",
+ log.timestamp,
+ serverID,
+ log.name,
+ log.clientSteamID,
+ log.targetSteamID,
+ log.message
+ );
+ transaction.AddQuery(query);
+ }
+ logs.Resize(logs.Length - length);
+ g_db.Execute(transaction, _, SQL_TransactionFailed, length, DBPrio_Low);
+ }
+ return Plugin_Continue;
+}
+void SQL_TransactionFailed(Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData) {
+ LogError("Push transaction failed: %s at query %d/%d", error, failIndex, numQueries);
+}
+
+public void Event_Connection(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client > 0 && !IsFakeClient(client)) {
+ static char clientName[32];
+ if(GetClientAuthId(client, AuthId_Steam2, clientName, sizeof(clientName))) {
+ if(name[7] == 'f') {
+ AddLog("JOIN", clientName, "", "");
+ GetClientName(client, playerLastName[client], 32);
+ } else {
+ static char reason[64];
+ event.GetString("reason", reason, sizeof(reason));
+ Format(reason, sizeof(reason), " left: \"%s\"", reason);
+ AddLog("QUIT", clientName, "", reason);
+ }
+ }
+ }
+}
+
+public void Event_PlayerInfo(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client && !IsFakeClient(client) && GetUserAdmin(client) == INVALID_ADMIN_ID) {
+ char clientName[32];
+ if(GetClientAuthId(client, AuthId_Steam2, clientName, sizeof(clientName))) {
+ AddLogCustom("INFO", clientName, "", "\"%s\" changed their name to \"%L\"", playerLastName[client], client);
+ GetClientName(client, playerLastName[client], 32);
+ }
+ }
+}
+
+public Action OnLogAction(Handle source, Identity identity, int client, int target, const char[] message) {
+ // Ignore cvar changed msgs (from server.cfg)
+ if(client == 0 && !hLogCvarChanges.BoolValue && strcmp(message[31], "changed cvar") >= 0) return Plugin_Continue;
+
+ static char clientName[32], targetName[32];
+ if(client == 0) clientName = "Server";
+ else if(client > 0) GetClientAuthId(client, AuthId_Steam2, clientName, sizeof(clientName));
+ else clientName[0] = '\0';
+
+ if(target > 0 && !IsFakeClient(target)) GetClientAuthId(target, AuthId_Steam2, targetName, sizeof(targetName));
+ else targetName[0] = '\0';
+
+ AddLog("ACTION", clientName, targetName, message);
+ return Plugin_Continue;
+}
+
+public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) {
+ if(client > 0 && !IsFakeClient(client)) {
+ static char clientName[32];
+ GetClientAuthId(client, AuthId_Steam2, clientName, sizeof(clientName));
+ AddLog("CHAT", clientName, "", sArgs);
+ }
+}
+
+public void Event_L4D2_Death(Event event, const char[] name, bool dontBroadcast) {
+ int victim = GetClientOfUserId(event.GetInt("userid"));
+ int attacker = GetClientOfUserId(event.GetInt("attacker"));
+ if(victim > 0 && GetClientTeam(victim) == 2) { //victim is a survivor
+ static char victimName[32], attackerName[32];
+
+ if(IsFakeClient(victim)) GetClientName(victim, victimName, sizeof(victimName));
+ else GetClientAuthId(victim, AuthId_Steam2, victimName, sizeof(victimName));
+
+ if(attacker > 0 && attacker != victim) {
+ if(IsFakeClient(attacker)) GetClientName(attacker, attackerName, sizeof(attackerName));
+ else GetClientAuthId(attacker, AuthId_Steam2, attackerName, sizeof(attackerName));
+
+ AddLogCustom("STATE", attackerName, victimName, "\"%L\" killed \"%L\"", attacker, victim);
+ } else {
+ AddLogCustom("STATE", "", victimName, "\"%L\" died", victim);
+ }
+ }
+}
+//Player was incapped by Jockey
+//Player was incapped (by world/zombie, no msg)
+public void Event_L4D2_Incapped(Event event, const char[] name, bool dontBroadcast) {
+ int victim = GetClientOfUserId(event.GetInt("userid"));
+ int attacker = GetClientOfUserId(event.GetInt("attacker"));
+ if(victim > 0 && GetClientTeam(victim) == 2) {
+ static char victimName[32], attackerName[32];
+ if(IsFakeClient(victim)) GetClientName(victim, victimName, sizeof(victimName));
+ else GetClientAuthId(victim, AuthId_Steam2, victimName, sizeof(victimName));
+
+ if(attacker > 0 && attacker != victim) {
+ if(IsFakeClient(attacker)) GetClientName(attacker, attackerName, sizeof(attackerName));
+ else GetClientAuthId(attacker, AuthId_Steam2, attackerName, sizeof(attackerName));
+
+ AddLogCustom("STATE", attackerName, victimName, "\"%L\" incapped \"%L\"", attacker, victim);
+ } else {
+ AddLogCustom("STATE", "", victimName, "\"%L\" was incapped", victim);
+ }
+ }
+}
+
+void AddLog(const char[] type, const char[] clientName, const char[] targetName, const char[] message) {
+ if(StrEqual(clientName, "Bot")) return;
+ Log log;
+ strcopy(log.name, sizeof(log.name), type);
+ strcopy(log.clientSteamID, sizeof(log.clientSteamID), clientName);
+ strcopy(log.targetSteamID, sizeof(log.targetSteamID), targetName);
+ strcopy(log.message, sizeof(log.message), message);
+ log.timestamp = GetTime();
+ logs.PushArray(log);
+}
+
+void AddLogCustom(const char[] type, const char[] clientName, const char[] targetName, const char[] format, any ...) {
+ static char message[254];
+ if(StrEqual(clientName, "Bot")) return;
+
+ VFormat(message, sizeof(message), format, 5);
+ AddLog(type, clientName, targetName, message);
+}
+
+public any Native_AddLog(Handle plugin, int numParams) {
+ char type[32], clientName[32], targetName[32], message[256];
+ if(GetNativeString(1, type, sizeof(type)) != SP_ERROR_NONE) return false;
+ if(GetNativeString(2, clientName, sizeof(clientName)) != SP_ERROR_NONE) return false;
+ if(GetNativeString(3, targetName, sizeof(targetName)) != SP_ERROR_NONE) return false;
+ if(GetNativeString(4, message, sizeof(message)) != SP_ERROR_NONE) return false;
+ AddLog(type, clientName, targetName, message);
+ return true;
+}
diff --git a/scripting/adminpanel.sp b/scripting/adminpanel.sp
new file mode 100644
index 0000000..f42e3d9
--- /dev/null
+++ b/scripting/adminpanel.sp
@@ -0,0 +1,423 @@
+#pragma semicolon 1
+
+#define DEBUG
+
+// Update intervals (only sends when > 0 players)
+// The update interval when there are active viewers
+#define UPDATE_INTERVAL 5.0
+// The update interval when there are no viewers on.
+// We still need to poll to know how many viewers are watching
+#define UPDATE_INTERVAL_SLOW 20.0
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#pragma newdecls required
+
+public Plugin myinfo =
+{
+ name = "Admin Panel",
+ author = "Jackz",
+ description = "Plugin to integrate with admin panel",
+ version = "1.0.0",
+ url = "https://github.com/jackzmc/l4d2-admin-dash"
+};
+
+ConVar cvar_debug;
+ConVar cvar_postAddress; char postAddress[128];
+ConVar cvar_authKey; char authKey[512];
+ConVar cvar_gamemode; char gamemode[32];
+
+char currentMap[64];
+int numberOfPlayers = 0;
+int lastSuccessTime;
+int campaignStartTime;
+int lastErrorCode;
+int uptime;
+bool fastUpdateMode = false;
+
+Handle updateTimer = null;
+
+char steamidCache[MAXPLAYERS+1][32];
+char nameCache[MAXPLAYERS+1][MAX_NAME_LENGTH];
+int g_icBeingHealed[MAXPLAYERS+1];
+int playerJoinTime[MAXPLAYERS+1];
+
+
+public void OnPluginStart()
+{
+ uptime = GetTime();
+ cvar_debug = CreateConVar("sm_adminpanel_debug", "0", "Turn on debug mode", FCVAR_DONTRECORD, true, 0.0, true, 1.0);
+
+ cvar_postAddress = CreateConVar("sm_adminpanel_url", "", "The base address to post updates to", FCVAR_NONE);
+ cvar_postAddress.AddChangeHook(OnCvarChanged);
+ cvar_postAddress.GetString(postAddress, sizeof(postAddress));
+ cvar_authKey = CreateConVar("sm_adminpanel_key", "", "The authentication key", FCVAR_NONE);
+ cvar_authKey.AddChangeHook(OnCvarChanged);
+ cvar_authKey.GetString(authKey, sizeof(authKey));
+
+ cvar_gamemode = FindConVar("mp_gamemode");
+ cvar_gamemode.AddChangeHook(OnCvarChanged);
+ cvar_gamemode.GetString(gamemode, sizeof(gamemode));
+
+ HookEvent("game_init", Event_GameStart);
+ HookEvent("heal_success", Event_HealStop);
+ HookEvent("heal_interrupted", Event_HealStop);
+ HookEvent("player_first_spawn", Event_PlayerFirstSpawn);
+
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i)) {
+ OnClientPutInServer(i);
+ }
+ }
+
+ TryStartTimer(true);
+
+ AutoExecConfig(true, "adminpanel");
+
+ RegAdminCmd("sm_panel_status", Command_PanelStatus, ADMFLAG_GENERIC);
+
+}
+
+#define DATE_FORMAT "%F at %I:%M %p"
+Action Command_PanelStatus(int client, int args) {
+ ReplyToCommand(client, "Active: %b", updateTimer != null);
+ ReplyToCommand(client, "#Players: %d", numberOfPlayers);
+ ReplyToCommand(client, "Update Interval: %0f s", fastUpdateMode ? UPDATE_INTERVAL : UPDATE_INTERVAL_SLOW);
+ char buffer[32];
+ ReplyToCommand(client, "Last Error Code: %d", lastErrorCode);
+ if(lastSuccessTime > 0)
+ FormatTime(buffer, sizeof(buffer), DATE_FORMAT, lastSuccessTime);
+ else
+ Format(buffer, sizeof(buffer), "(none)");
+ ReplyToCommand(client, "Last Success: %s", buffer);
+ return Plugin_Handled;
+}
+
+void TryStartTimer(bool fast = true) {
+ if(numberOfPlayers > 0 && updateTimer == null && postAddress[0] != '\0' && authKey[0] != 0) {
+ fastUpdateMode = fast;
+ float interval = fast ? UPDATE_INTERVAL : UPDATE_INTERVAL_SLOW;
+ updateTimer = CreateTimer(interval, Timer_PostStatus, _, TIMER_REPEAT);
+ PrintToServer("[AdminPanel] Updating every %.1f seconds", interval);
+ }
+}
+
+
+void Event_GameStart(Event event, const char[] name, bool dontBroadcast) {
+ campaignStartTime = GetTime();
+}
+
+void Event_HealStart(Event event, const char[] name, bool dontBroadcast) {
+ int healing = GetClientOfUserId(event.GetInt("subject"));
+ g_icBeingHealed[healing] = true;
+}
+void Event_HealStop(Event event, const char[] name, bool dontBroadcast) {
+ int healing = GetClientOfUserId(event.GetInt("subject"));
+ g_icBeingHealed[healing] = false;
+}
+
+void Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ playerJoinTime[client] = GetTime();
+ RecalculatePlayerCount();
+}
+
+void RecalculatePlayerCount() {
+ int players = 0;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i)) {
+ players++;
+ }
+ }
+ numberOfPlayers = players;
+}
+
+public void OnMapStart() {
+ GetCurrentMap(currentMap, sizeof(currentMap));
+ numberOfPlayers = 0;
+}
+
+// Player counts
+public void OnClientPutInServer(int client) {
+ GetClientName(client, nameCache[client], MAX_NAME_LENGTH);
+ if(!IsFakeClient(client)) {
+ GetClientAuthId(client, AuthId_SteamID64, steamidCache[client], 32);
+ numberOfPlayers++;
+ TryStartTimer(true);
+ } else {
+ strcopy(steamidCache[client], 32, "BOT");
+ }
+}
+
+public void OnClientDisconnect(int client) {
+ steamidCache[client][0] = '\0';
+ nameCache[client][0] = '\0';
+ if(!IsFakeClient(client)) {
+ numberOfPlayers--;
+ // Incase somehow we lost track
+ if(numberOfPlayers < 0) {
+ numberOfPlayers = 0;
+ }
+ if(numberOfPlayers == 0 && updateTimer != null) {
+ delete updateTimer;
+ }
+ }
+}
+
+// Cvar updates
+void OnCvarChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
+ if(cvar_postAddress == convar) {
+ strcopy(postAddress, sizeof(postAddress), newValue);
+ PrintToServer("[AdminPanel] Update Url has updated");
+ } else if(cvar_authKey == convar) {
+ strcopy(authKey, sizeof(authKey), newValue);
+ PrintToServer("[AdminPanel] Auth key has been updated");
+ } else if(cvar_gamemode == convar) {
+ strcopy(gamemode, sizeof(gamemode), newValue);
+ }
+ TryStartTimer(true);
+}
+
+bool isSubmitting;
+Action Timer_PostStatus(Handle h) {
+ if(isSubmitting) return Plugin_Continue;
+ isSubmitting = true;
+ // TODO: optimize only if someone is requesting live
+ HTTPRequest req = new HTTPRequest(postAddress);
+ JSONObject obj = GetObject();
+ req.SetHeader("x-authtoken", authKey);
+ // req.AppendFormParam("playerCount", "%d", numberOfPlayers);
+ // req.AppendFormParam("map", currentMap);
+ if(cvar_debug.BoolValue) PrintToServer("[AdminPanel] Submitting");
+ req.Post(obj, Callback_PostStatus);
+ delete obj;
+ // req.PostForm(Callback_PostStatus);
+ return Plugin_Continue;
+}
+
+void Callback_PostStatus(HTTPResponse response, any value, const char[] error) {
+ isSubmitting = false;
+ if(response.Status == HTTPStatus_NoContent || response.Status == HTTPStatus_OK) {
+ lastErrorCode = 0;
+ lastSuccessTime = GetTime();
+ if(cvar_debug.BoolValue)
+ PrintToServer("[AdminPanel] Response: OK/204");
+ // We have subscribers, kill timer and recreate it in fast mode (if not already):
+ if(!fastUpdateMode) {
+ PrintToServer("[AdminPanel] Switching to fast update interval for active viewers.");
+ if(updateTimer != null)
+ delete updateTimer;
+ TryStartTimer(true);
+ }
+
+ } else if(response.Status == HTTPStatus_Gone) {
+ lastErrorCode = 0;
+ // We have no subscribers, kill timer and recreate it in slow mode (if not already):
+ if(fastUpdateMode) {
+ PrintToServer("[AdminPanel] Switching to slow update interval, no viewers");
+ if(updateTimer != null)
+ delete updateTimer;
+ TryStartTimer(false);
+ }
+ } else {
+ lastErrorCode = view_as(response.Status);
+ lastSuccessTime = 0;
+ // TODO: backoff
+ PrintToServer("[AdminPanel] Getting response: %d", response.Status);
+ if(cvar_debug.BoolValue) {
+ char buffer[64];
+ JSONObject json = view_as(response.Data);
+ if(false && json.GetString("error", buffer, sizeof(buffer))) {
+ PrintToServer("[AdminPanel] Got %d response from server: \"%s\"", view_as(response.Status), buffer);
+ json.GetString("message", buffer, sizeof(buffer));
+ PrintToServer("[AdminPanel] Error message: \"%s\"", buffer);
+ } else {
+ PrintToServer("[AdminPanel] Got %d response from server: \n%s", view_as(response.Status), error);
+ }
+ }
+ if(response.Status == HTTPStatus_Unauthorized || response.Status == HTTPStatus_Forbidden) {
+ PrintToServer("[AdminPanel] API Key seems to be invalid, killing timer.");
+ if(updateTimer != null)
+ delete updateTimer;
+ }
+ }
+}
+
+JSONObject GetObject() {
+ JSONObject obj = new JSONObject();
+ obj.SetInt("playerCount", numberOfPlayers);
+ obj.SetString("map", currentMap);
+ obj.SetString("gamemode", gamemode);
+ obj.SetInt("startTime", uptime);
+ obj.SetInt("commonsCount", L4D_GetCommonsCount());
+ obj.SetFloat("fps", 1.0 / GetGameFrameTime());
+ AddFinaleInfo(obj);
+ JSONArray players = GetPlayers();
+ obj.Set("players", players);
+ delete players;
+ obj.SetFloat("refreshInterval", UPDATE_INTERVAL);
+ obj.SetInt("lastUpdateTime", GetTime());
+ obj.SetInt("campaignStartTime", campaignStartTime);
+ return obj;
+}
+
+void AddFinaleInfo(JSONObject parentObj) {
+ if(L4D_IsMissionFinalMap()) {
+ JSONObject obj = new JSONObject();
+ obj.SetBool("escapeLeaving", L4D_IsFinaleEscapeInProgress());
+ obj.SetInt("finaleStage", L4D2_GetCurrentFinaleStage());
+ parentObj.Set("finaleInfo", obj);
+ delete obj;
+ }
+}
+
+JSONArray GetPlayers() {
+ JSONArray players = new JSONArray();
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i)) {
+ int team = GetClientTeam(i);
+ if( team == 2 || team == 3) {
+ JSONObject player = GetPlayer(i);
+ players.Push(player);
+ delete player;
+ }
+ }
+ }
+ return players;
+}
+
+
+enum {
+ Action_BeingHealed = -1,
+ Action_None = 0, // No use action active
+ Action_Healing = 1, // Includes healing yourself or a teammate.
+ Action_AmmoPack = 2, // When deploying the ammo pack that was never added into the game
+ Action_Defibing = 4, // When defib'ing a dead body.
+ Action_GettingDefibed = 5, // When comming back to life from a dead body.
+ Action_DeployIncendiary = 6, // When deploying Incendiary ammo
+ Action_DeployExplosive = 7, // When deploying Explosive ammo
+ Action_PouringGas = 8, // Pouring gas into a generator
+ Action_Cola = 9, // For Dead Center map 2 cola event, when handing over the cola to whitalker.
+ Action_Button = 10, // Such as buttons, timed buttons, generators, etc.
+ Action_UsePointScript = 11 // When using a "point_script_use_target" entity
+}
+
+int GetAction(int client) {
+ if(g_icBeingHealed[client]) return Action_BeingHealed;
+ return view_as(L4D2_GetPlayerUseAction(client));
+}
+
+enum {
+ Move_UnderAttack = -3,
+ Move_Hanging = -2,
+ Move_Incapped = -1,
+ Move_Idle = 0,
+ Move_Walk = 1,
+ Move_Run = 2,
+ Move_Crouched = 3,
+ Move_Ladder = 4
+}
+
+stock float GetPlayerSpeed(int client) {
+ int iVelocity = FindSendPropInfo("CTerrorPlayer", "m_vecVelocity[0]");
+ float velocity[3];
+ GetEntDataVector(client, iVelocity, velocity);
+ return GetVectorLength(velocity, false);
+}
+
+int GetPlayerMovement(int client) {
+ MoveType moveType = GetEntityMoveType(client);
+ if(moveType == MOVETYPE_LADDER) return Move_Ladder;
+ else if(GetEntProp(client, Prop_Send, "m_bDucked", 1)) return Move_Crouched;
+ else if(GetEntProp(client, Prop_Send, "m_isIncapacitated", 1)) return Move_Incapped;
+ else if(GetEntProp(client, Prop_Send, "m_isHangingFromLedge", 1)) return Move_Hanging;
+ else if(L4D_GetPinnedSurvivor(client)) return Move_UnderAttack; // TODO: optimize for events
+ float velocity = GetPlayerSpeed(client);
+ if(velocity > 85.0) return Move_Run;
+ else if(velocity > 1.0) return Move_Walk;
+ return Move_Idle;
+}
+
+// TODO: pursued by witch
+enum {
+ pState_BlackAndWhite = 1,
+ pState_InSaferoom = 2,
+ pState_IsCalm = 4,
+ pState_IsBoomed = 8
+}
+
+stock bool IsPlayerBoomed(int client) {
+ return (GetEntPropFloat(client, Prop_Send, "m_vomitStart") + 20.1) > GetGameTime();
+}
+
+int GetPlayerStates(int client) {
+ int state = 0;
+ if(L4D_IsInLastCheckpoint(client) || L4D_IsInFirstCheckpoint(client))
+ state |= pState_InSaferoom;
+ if(GetEntProp(client, Prop_Send, "m_bIsOnThirdStrike", 1)) state |= pState_BlackAndWhite;
+ if(GetEntProp(client, Prop_Send, "m_isCalm")) state |= pState_IsCalm;
+ if(IsPlayerBoomed(client)) state |= pState_IsBoomed;
+ return state;
+}
+
+JSONObject GetPlayer(int client) {
+ int team = GetClientTeam(client);
+ JSONObject player = new JSONObject();
+ player.SetString("steamid", steamidCache[client]);
+ player.SetInt("userId", GetClientUserId(client));
+ player.SetString("name", nameCache[client]);
+ player.SetInt("team", team);
+ player.SetBool("isAlive", IsPlayerAlive(client));
+ player.SetInt("joinTime", playerJoinTime[client]);
+ player.SetInt("permHealth", GetEntProp(client, Prop_Send, "m_iHealth"));
+ if(team == 2) {
+ // Include idle players (player here is their idle bot)
+ if(IsFakeClient(client)) {
+ int idlePlayer = L4D_GetIdlePlayerOfBot(client);
+ if(idlePlayer > 0) {
+ player.SetString("idlePlayerId", steamidCache[idlePlayer]);
+ if(IsClientInGame(idlePlayer)) {
+ JSONObject idlePlayerObj = GetPlayer(idlePlayer);
+ player.Set("idlePlayer", idlePlayerObj);
+ delete idlePlayerObj;
+ }
+ }
+ }
+ player.SetInt("action", GetAction(client));
+ player.SetInt("flowProgress", L4D2_GetVersusCompletionPlayer(client));
+ player.SetFloat("flow", L4D2Direct_GetFlowDistance(client));
+ player.SetBool("isPinned", L4D2_GetInfectedAttacker(client) > 0);
+ player.SetInt("tempHealth", L4D_GetPlayerTempHealth(client));
+ player.SetInt("states", GetPlayerStates(client));
+ player.SetInt("move", GetPlayerMovement(client));
+ player.SetInt("survivor", GetEntProp(client, Prop_Send, "m_survivorCharacter"));
+ JSONArray weapons = GetPlayerWeapons(client);
+ player.Set("weapons", weapons);
+ delete weapons;
+ } else if(team == 3) {
+ player.SetInt("class", L4D2_GetPlayerZombieClass(client));
+ player.SetInt("maxHealth", GetEntProp(client, Prop_Send, "m_iMaxHealth"));
+ int victim = L4D2_GetSurvivorVictim(client);
+ if(victim > 0)
+ player.SetString("pinnedSurvivorId", steamidCache[victim]);
+ }
+ return player;
+}
+
+JSONArray GetPlayerWeapons(int client) {
+ JSONArray weapons = new JSONArray();
+ static char buffer[64];
+ for(int slot = 0; slot < 6; slot++) {
+ if(GetClientWeaponNameSmart(client, slot, buffer, sizeof(buffer))) {
+ weapons.PushString(buffer);
+ } else {
+ weapons.PushNull();
+ }
+ }
+ return weapons;
+}
\ No newline at end of file
diff --git a/scripting/basechat.sp b/scripting/basechat.sp
new file mode 100644
index 0000000..d00c1db
--- /dev/null
+++ b/scripting/basechat.sp
@@ -0,0 +1,441 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod Basic Chat Plugin
+ * Implements basic communication commands.
+ *
+ * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#pragma semicolon 1
+
+#include
+
+#pragma newdecls required
+
+public Plugin myinfo =
+{
+ name = "Basic Chat+",
+ author = "AlliedModders LLC",
+ description = "Basic Communication Commands",
+ version = SOURCEMOD_VERSION,
+ url = "http://www.sourcemod.net/"
+};
+
+#define CHAT_SYMBOL '@'
+
+char g_ColorNames[13][10] = {"White", "Red", "Green", "Blue", "Yellow", "Purple", "Cyan", "Orange", "Pink", "Olive", "Lime", "Violet", "Lightblue"};
+int g_Colors[13][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255},{255,128,0},{255,0,128},{128,255,0},{0,255,128},{128,0,255},{0,128,255}};
+
+ConVar g_Cvar_Chatmode;
+
+EngineVersion g_GameEngine = Engine_Unknown;
+
+public void OnPluginStart()
+{
+ LoadTranslations("common.phrases");
+
+ g_GameEngine = GetEngineVersion();
+
+ g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0);
+
+ RegAdminCmd("sm_say", Command_SmSay, ADMFLAG_CHAT, "sm_say - sends message to all players");
+ RegAdminCmd("sm_csay", Command_SmCsay, ADMFLAG_CHAT, "sm_csay - sends centered message to all players");
+
+ /* HintText does not work on Dark Messiah */
+ if (g_GameEngine != Engine_DarkMessiah)
+ {
+ RegAdminCmd("sm_hsay", Command_SmHsay, ADMFLAG_CHAT, "sm_hsay - sends hint message to all players");
+ }
+
+ RegAdminCmd("sm_tsay", Command_SmTsay, ADMFLAG_CHAT, "sm_tsay [color] - sends top-left message to all players");
+ RegAdminCmd("sm_chat", Command_SmChat, ADMFLAG_CHAT, "sm_chat - sends message to admins");
+ RegAdminCmd("sm_psay", Command_SmPsay, ADMFLAG_CHAT, "sm_psay - sends private message");
+ RegAdminCmd("sm_msay", Command_SmMsay, ADMFLAG_CHAT, "sm_msay - sends message as a menu panel");
+}
+
+public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
+{
+ int startidx;
+ if (sArgs[startidx] != CHAT_SYMBOL)
+ return Plugin_Continue;
+
+ startidx++;
+
+ if (strcmp(command, "say", false) == 0)
+ {
+ if (sArgs[startidx] != CHAT_SYMBOL) // sm_say alias
+ {
+ if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT))
+ {
+ return Plugin_Continue;
+ }
+
+ SendChatToAdmins(client, sArgs[startidx]);
+ LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, sArgs[startidx]);
+
+ return Plugin_Stop;
+ }
+
+ startidx++;
+
+ if (sArgs[startidx] != CHAT_SYMBOL) // sm_psay alias
+ {
+ if (!CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT))
+ {
+ return Plugin_Continue;
+ }
+
+ char arg[64];
+
+ int len = BreakString(sArgs[startidx], arg, sizeof(arg));
+ int target = FindTarget(client, arg, true, false);
+
+ if (target == -1 || len == -1) {
+ PrintToChat(client, "Cannot send a private msg: Invalid user specified.");
+ } else {
+ SendPrivateChat(client, target, sArgs[startidx+len]);
+ }
+
+
+ return Plugin_Stop;
+ }
+
+ startidx++;
+
+ // sm_csay alias
+ if (!CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT))
+ {
+ return Plugin_Continue;
+ }
+
+ DisplayCenterTextToAll(client, sArgs[startidx]);
+ LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, sArgs[startidx]);
+
+ return Plugin_Stop;
+ }
+ else if (strcmp(command, "say_team", false) == 0 || strcmp(command, "say_squad", false) == 0)
+ {
+ if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !g_Cvar_Chatmode.BoolValue)
+ {
+ return Plugin_Continue;
+ }
+
+ SendChatToAdmins(client, sArgs[startidx]);
+ LogAction(client, -1, "\"%L\" triggered sm_chat (text %s)", client, sArgs[startidx]);
+
+ return Plugin_Stop;
+ }
+
+ return Plugin_Continue;
+}
+
+public Action Command_SmSay(int client, int args)
+{
+ if (args < 1)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_say ");
+ return Plugin_Handled;
+ }
+
+ char text[192];
+ GetCmdArgString(text, sizeof(text));
+
+ SendChatToAll(client, text);
+ LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, text);
+
+ return Plugin_Handled;
+}
+
+public Action Command_SmCsay(int client, int args)
+{
+ if (args < 1)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_csay ");
+ return Plugin_Handled;
+ }
+
+ char text[192];
+ GetCmdArgString(text, sizeof(text));
+
+ DisplayCenterTextToAll(client, text);
+
+ LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, text);
+
+ return Plugin_Handled;
+}
+
+public Action Command_SmHsay(int client, int args)
+{
+ if (args < 1)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_hsay ");
+ return Plugin_Handled;
+ }
+
+ char text[192];
+ GetCmdArgString(text, sizeof(text));
+
+ char nameBuf[MAX_NAME_LENGTH];
+
+ for (int i = 1; i <= MaxClients; i++)
+ {
+ if (!IsClientInGame(i) || IsFakeClient(i))
+ {
+ continue;
+ }
+ FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
+ PrintHintText(i, "%s: %s", nameBuf, text);
+ }
+
+ LogAction(client, -1, "\"%L\" triggered sm_hsay (text %s)", client, text);
+
+ return Plugin_Handled;
+}
+
+public Action Command_SmTsay(int client, int args)
+{
+ if (args < 1)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_tsay ");
+ return Plugin_Handled;
+ }
+
+ char text[192], colorStr[16];
+ GetCmdArgString(text, sizeof(text));
+
+ int len = BreakString(text, colorStr, 16);
+
+ int color = FindColor(colorStr);
+ char nameBuf[MAX_NAME_LENGTH];
+
+ if (color == -1)
+ {
+ color = 0;
+ len = 0;
+ }
+
+ for (int i = 1; i <= MaxClients; i++)
+ {
+ if (!IsClientInGame(i) || IsFakeClient(i))
+ {
+ continue;
+ }
+ FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
+ SendDialogToOne(i, color, "%s: %s", nameBuf, text[len]);
+ }
+
+ LogAction(client, -1, "\"%L\" triggered sm_tsay (text %s)", client, text);
+
+ return Plugin_Handled;
+}
+
+public Action Command_SmChat(int client, int args)
+{
+ if (args < 1)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_chat ");
+ return Plugin_Handled;
+ }
+
+ char text[192];
+ GetCmdArgString(text, sizeof(text));
+
+ SendChatToAdmins(client, text);
+ LogAction(client, -1, "\"%L\" triggered sm_chat (text %s)", client, text);
+
+ return Plugin_Handled;
+}
+
+public Action Command_SmPsay(int client, int args)
+{
+ if (args < 2)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_psay ");
+ return Plugin_Handled;
+ }
+
+ char text[192], arg[64];
+ GetCmdArgString(text, sizeof(text));
+
+ int len = BreakString(text, arg, sizeof(arg));
+
+ int target = FindTarget(client, arg, true, false);
+
+ if (target == -1)
+ return Plugin_Handled;
+
+ SendPrivateChat(client, target, text[len]);
+
+ return Plugin_Handled;
+}
+
+public Action Command_SmMsay(int client, int args)
+{
+ if (args < 1)
+ {
+ ReplyToCommand(client, "[SM] Usage: sm_msay ");
+ return Plugin_Handled;
+ }
+
+ char text[192];
+ GetCmdArgString(text, sizeof(text));
+
+ SendPanelToAll(client, text);
+
+ LogAction(client, -1, "\"%L\" triggered sm_msay (text %s)", client, text);
+
+ return Plugin_Handled;
+}
+
+int FindColor(const char[] color)
+{
+ for (int i = 0; i < sizeof(g_ColorNames); i++)
+ {
+ if (strcmp(color, g_ColorNames[i], false) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+void SendChatToAll(int client, const char[] message)
+{
+ char nameBuf[MAX_NAME_LENGTH];
+
+ for (int i = 1; i <= MaxClients; i++)
+ {
+ if (!IsClientInGame(i) || IsFakeClient(i))
+ {
+ continue;
+ }
+ FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
+
+ if (g_GameEngine == Engine_CSGO)
+ PrintToChat(i, " \x01\x0B\x04%t: \x01%s", "Say all", nameBuf, message);
+ else
+ PrintToChat(i, "\x04%t: \x01%s", "Say all", nameBuf, message);
+ }
+}
+
+void DisplayCenterTextToAll(int client, const char[] message)
+{
+ char nameBuf[MAX_NAME_LENGTH];
+
+ for (int i = 1; i <= MaxClients; i++)
+ {
+ if (!IsClientInGame(i) || IsFakeClient(i))
+ {
+ continue;
+ }
+ FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
+ PrintCenterText(i, "%s: %s", nameBuf, message);
+ }
+}
+
+void SendChatToAdmins(int from, const char[] message)
+{
+ int fromAdmin = CheckCommandAccess(from, "sm_chat", ADMFLAG_CHAT);
+ for (int i = 1; i <= MaxClients; i++)
+ {
+ if (IsClientInGame(i) && (from == i || CheckCommandAccess(i, "sm_chat", ADMFLAG_CHAT)))
+ {
+ if (g_GameEngine == Engine_CSGO)
+ PrintToChat(i, " \x01\x0B\x04%t: \x01%s", fromAdmin ? "Chat admins" : "Chat to admins", from, message);
+ else
+ PrintToChat(i, "\x04%t: \x01%s", fromAdmin ? "Chat admins" : "Chat to admins", from, message);
+ }
+ }
+}
+
+void SendDialogToOne(int client, int color, const char[] text, any ...)
+{
+ char message[100];
+ VFormat(message, sizeof(message), text, 4);
+
+ KeyValues kv = new KeyValues("Stuff", "title", message);
+ kv.SetColor("color", g_Colors[color][0], g_Colors[color][1], g_Colors[color][2], 255);
+ kv.SetNum("level", 1);
+ kv.SetNum("time", 10);
+
+ CreateDialog(client, kv, DialogType_Msg);
+
+ delete kv;
+}
+
+void SendPrivateChat(int client, int target, const char[] message)
+{
+ if (!client)
+ {
+ PrintToServer("(Private to %N) %N: %s", target, client, message);
+ }
+ else if (target != client)
+ {
+ if (g_GameEngine == Engine_CSGO)
+ PrintToChat(client, " \x01\x0B\x04%t: \x01%s", "Private say to", target, client, message);
+ else
+ PrintToChat(client, "\x04%t: \x01%s", "Private say to", target, client, message);
+ }
+
+ if (g_GameEngine == Engine_CSGO)
+ PrintToChat(target, " \x01\x0B\x04%t: \x01%s", "Private say to", target, client, message);
+ else
+ PrintToChat(target, "\x04%t: \x01%s", "Private say to", target, client, message);
+ LogAction(client, target, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message);
+}
+
+void SendPanelToAll(int from, char[] message)
+{
+ char title[100];
+ Format(title, 64, "%N:", from);
+
+ ReplaceString(message, 192, "\\n", "\n");
+
+ Panel mSayPanel = new Panel();
+ mSayPanel.SetTitle(title);
+ mSayPanel.DrawItem("", ITEMDRAW_SPACER);
+ mSayPanel.DrawText(message);
+ mSayPanel.DrawItem("", ITEMDRAW_SPACER);
+ mSayPanel.CurrentKey = GetMaxPageItems(mSayPanel.Style);
+ mSayPanel.DrawItem("Exit", ITEMDRAW_CONTROL);
+
+ for(int i = 1; i <= MaxClients; i++)
+ {
+ if(IsClientInGame(i) && !IsFakeClient(i))
+ {
+ mSayPanel.Send(i, Handler_DoNothing, 10);
+ }
+ }
+
+ delete mSayPanel;
+}
+
+public int Handler_DoNothing(Menu menu, MenuAction action, int param1, int param2)
+{
+ return 0;
+ /* Do nothing */
+}
diff --git a/scripting/csgo-knifehp.sp b/scripting/csgo-knifehp.sp
new file mode 100644
index 0000000..7f2ad7c
--- /dev/null
+++ b/scripting/csgo-knifehp.sp
@@ -0,0 +1,68 @@
+#pragma semicolon 1
+
+#define DEBUG
+
+#define PLUGIN_NAME "CSGO Knife Regen"
+#define PLUGIN_AUTHOR "jackzmc"
+#define PLUGIN_VERSION "1.00"
+#define PLUGIN_DESCRIPTION ""
+
+#include
+#include
+#include
+//#include
+
+EngineVersion g_Game;
+
+public Plugin myinfo =
+{
+ name = PLUGIN_NAME,
+ author = PLUGIN_AUTHOR,
+ description = PLUGIN_DESCRIPTION,
+ version = PLUGIN_VERSION,
+ url = ""
+};
+
+ConVar g_bKnifeHPEnabled, g_iKnifeHPMax, g_iKnifeHPRegain;
+
+public OnPluginStart()
+{
+ g_Game = GetEngineVersion();
+ if (g_Game != Engine_CSGO && g_Game != Engine_CSS)
+ {
+ SetFailState("This plugin is for CSGO/CSS only.");
+ }
+
+ g_bKnifeHPEnabled = CreateConVar("knifehp_enable", "1", "Enable regaining health on knife kill", FCVAR_NONE, true, 0.0, true, 1.0);
+ g_iKnifeHPMax = CreateConVar("knifehp_max_health", "100", "Maximum health to set an attacker to", FCVAR_NONE, true, 0.0);
+ g_iKnifeHPRegain = CreateConVar("knifehp_amount", "100", "Amount of health to give attacker", FCVAR_NONE, true, 0.0);
+ HookEvent("player_death", Event_PlayerDeath);
+
+ AutoExecConfig(true, "csgo_knifehp");
+}
+
+public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
+{
+ if (g_bKnifeHPEnabled.BoolValue) {
+ char weapon_name[64];
+ event.GetString("weapon", weapon_name, sizeof(weapon_name));
+ if (StrContains(weapon_name, "knife", false) > -1) {
+ int attacker = event.GetInt("attacker");
+ int client = GetClientOfUserId(attacker);
+
+ //get the new health value (current client hp + the regen amount)
+ int new_health = GetClientHealth(client) + g_iKnifeHPRegain.IntValue;
+ //50 + 20 <= max
+ if (IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client)) {
+ if(new_health <= g_iKnifeHPMax.IntValue) { //if the new health is less than max, set it to it
+ SetEntityHealth(client, new_health);
+ }else{ //if > max, set it to max
+ SetEntityHealth(client, g_iKnifeHPMax.IntValue);
+ }
+ }
+
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/scripting/csgo-misc.sp b/scripting/csgo-misc.sp
new file mode 100644
index 0000000..f039622
--- /dev/null
+++ b/scripting/csgo-misc.sp
@@ -0,0 +1,60 @@
+#pragma semicolon 1
+
+#define DEBUG
+
+#define PLUGIN_AUTHOR ""
+#define PLUGIN_VERSION "0.00"
+
+#include
+#include
+#include
+//#include
+
+#pragma newdecls required
+
+public Plugin myinfo =
+{
+ name = "",
+ author = PLUGIN_AUTHOR,
+ description = "",
+ version = PLUGIN_VERSION,
+ url = ""
+};
+
+public void OnPluginStart()
+{
+ EngineVersion g_Game = GetEngineVersion();
+ if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
+ {
+ SetFailState("This plugin is for CSGO/CSS only.");
+ }
+ RegConsoleCmd("sm_first", Command_FirstPov, "Go back to first person");
+ RegConsoleCmd("sm_third", Command_ThirdPov, "Go to third person");
+}
+public Action Command_FirstPov(int client, int args) {
+ if(client == 0) {
+ ReplyToCommand(client, "This command is for clients only");
+ return Plugin_Handled;
+ }
+ CheatCommand(client, "firstperson", "", "");
+ return Plugin_Handled;
+}
+public Action Command_ThirdPov(int client, int args) {
+ if(client == 0) {
+ ReplyToCommand(client, "This command is for clients only");
+ return Plugin_Handled;
+ }
+ CheatCommand(client, "thirdperson", "", "");
+ return Plugin_Handled;
+}
+
+stock void CheatCommand(int client, char[] command, char[] argument1, char[] argument2)
+{
+ int userFlags = GetUserFlagBits(client);
+ SetUserFlagBits(client, ADMFLAG_ROOT);
+ int flags = GetCommandFlags(command);
+ SetCommandFlags(command, flags & ~FCVAR_CHEAT);
+ FakeClientCommand(client, "%s %s %s", command, argument1, argument2);
+ SetCommandFlags(command, flags);
+ SetUserFlagBits(client, userFlags);
+}
\ No newline at end of file
diff --git a/scripting/disable_cameras.sp b/scripting/disable_cameras.sp
new file mode 100644
index 0000000..b7bc167
--- /dev/null
+++ b/scripting/disable_cameras.sp
@@ -0,0 +1,84 @@
+#include
+#include
+#include
+
+// Fixed issues:
+// - Server crash when kicking a bot who have been an active target of camera (point_viewcontrol_survivor)
+// - Multiple visual spectator bugs after team swap in finale
+
+public void Event_round_start_pre_entity(Event event, const char[] name, bool dontBroadcast)
+{
+ static char classes[][] = {
+ "point_viewcontrol",
+ "point_viewcontrol_survivor",
+ "point_viewcontrol_multiplayer",
+ };
+
+ for (int i = 0; i < sizeof(classes); i++) {
+ int entity = INVALID_ENT_REFERENCE;
+ while ((entity = FindEntityByClassname(entity, classes[i])) != INVALID_ENT_REFERENCE) {
+ // Invoke a "Disable" input on camera entities to free all players
+ // Doing so on round_start_pre_entity should help to not let map logic kick in too early
+ AcceptEntityInput(entity, "Disable");
+ }
+ }
+}
+
+public void OnClientDisconnect(int client)
+{
+ if (!IsClientInGame(client)) {
+ return;
+ }
+
+ int viewEntity = GetEntPropEnt(client, Prop_Send, "m_hViewEntity");
+ if (!IsValidEdict(viewEntity)) {
+ return;
+ }
+
+ char cls[64];
+ GetEdictClassname(viewEntity, cls, sizeof(cls));
+ if (strncmp(cls, "point_viewcontrol", 17) != 0) {
+ return;
+ }
+
+ // Matches CSurvivorCamera, CTriggerCamera
+ if (strcmp(cls[17], "_survivor") == 0 || cls[17] == '\0') {
+ // Disable entity to prevent CMoveableCamera::FollowTarget to cause a crash
+ // m_hTargetEnt EHANDLE is not checked for existence and can be NULL
+ // CBaseEntity::GetAbsAngles being called on causing a crash
+ AcceptEntityInput(viewEntity, "Disable");
+ }
+
+ // Matches CTriggerCameraMultiplayer
+ if (strcmp(cls[17], "_multiplayer") == 0) {
+ AcceptEntityInput(viewEntity, "RemovePlayer", client);
+ }
+}
+
+public void OnPluginStart()
+{
+ HookEvent("round_start_pre_entity", Event_round_start_pre_entity, EventHookMode_PostNoCopy);
+}
+
+public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
+{
+ switch (GetEngineVersion()) {
+ case Engine_Left4Dead2, Engine_Left4Dead:
+ {
+ return APLRes_Success;
+ }
+ }
+
+ strcopy(error, err_max, "Plugin only supports Left 4 Dead and Left 4 Dead 2.");
+
+ return APLRes_SilentFailure;
+}
+
+public Plugin myinfo =
+{
+ name = "[L4D/2] Unlink Camera Entities",
+ author = "shqke",
+ description = "Frees cached players from camera entity",
+ version = "1.1",
+ url = "https://github.com/shqke/sp_public"
+};
diff --git a/scripting/globalbans.sp b/scripting/globalbans.sp
new file mode 100644
index 0000000..dd1cb8e
--- /dev/null
+++ b/scripting/globalbans.sp
@@ -0,0 +1,323 @@
+#pragma semicolon 1
+#pragma newdecls required
+
+#define DEBUG 0
+#define PLUGIN_VERSION "1.0"
+#define DB_NAME "globalbans"
+
+#define BANFLAG_NONE 0
+#define BANFLAG_IPBANNED 1
+#define BANFLAG_SUSPENDED 2
+
+#include
+#include
+
+public Plugin myinfo =
+{
+ name = "Global Bans",
+ author = "jackzmc",
+ description = "Manages bans via MySQL",
+ version = PLUGIN_VERSION,
+ url = "https://github.com/Jackzmc/sourcemod-plugins"
+};
+
+static Database g_db;
+static ConVar hKickType;
+static StringMap pendingInsertQueries;
+
+static int iPendingCounter;
+
+
+public void OnPluginStart() {
+ if(!SQL_CheckConfig(DB_NAME)) {
+ SetFailState("No database entry for " ... DB_NAME ... "; no database to connect to.");
+ }
+ if(!ConnectDB()) {
+ SetFailState("Failed to connect to database.");
+ }
+
+ pendingInsertQueries = new StringMap();
+
+ hKickType = CreateConVar("sm_globalbans_kick_type", "1", "0 = Do not kick, just notify\n1 = Kick if banned\n 2 = Kick if cannot reach database", FCVAR_NONE, true, 0.0, true, 2.0);
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// DB Connections
+///////////////////////////////////////////////////////////////////////////////
+
+bool ConnectDB() {
+ static char error[255];
+ g_db = SQL_Connect(DB_NAME, true, error, sizeof(error));
+ if (g_db == null) {
+ LogError("Database error %s", error);
+ delete g_db;
+ return false;
+ } else {
+ PrintToServer("Connected to sm database " ... DB_NAME);
+ SQL_LockDatabase(g_db);
+ SQL_FastQuery(g_db, "SET NAMES \"UTF8mb4\"");
+ SQL_UnlockDatabase(g_db);
+ g_db.SetCharset("utf8mb4");
+ return true;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// EVENTS
+///////////////////////////////////////////////////////////////////////////////
+
+public void OnClientAuthorized(int client, const char[] auth) {
+ if(!StrEqual(auth, "BOT", true)) {
+ static char query[256], ip[32];
+ GetClientIP(client, ip, sizeof(ip));
+ g_db.Format(query, sizeof(query), "SELECT `reason`, `steamid`, `expired`, `public_message`, `flags`, `id` FROM `bans` WHERE `expired` = 0 AND `steamid` LIKE 'STEAM_%%:%%:%s' OR ip = '%s'", auth[10], ip);
+ g_db.Query(DB_OnConnectCheck, query, GetClientUserId(client), DBPrio_High);
+ }
+}
+
+public Action OnBanIdentity(const char[] identity, int time, int flags, const char[] reason, const char[] command, any source) {
+ if(flags == BANFLAG_AUTHID) {
+ char executor[32];
+ if(source > 0 && source <= MaxClients) {
+ GetClientAuthId(source, AuthId_Steam2, executor, sizeof(executor));
+ }else{
+ executor = "CONSOLE";
+ }
+
+ char query[512];
+
+
+ // Setup expiration date
+ char expiresDate[64];
+ if(time > 0) {
+ Format(expiresDate, sizeof(expiresDate), "%d", GetTime() + (time * 60000));
+ }else{
+ Format(expiresDate, sizeof(expiresDate), "NULL");
+ }
+
+ g_db.Format(query, sizeof(query), "INSERT INTO bans"
+ ..."(steamid, reason, expires, executor, flags, timestamp)"
+ ..."VALUES ('%s', '%s', %s, '%s', %d, UNIX_TIMESTAMP())",
+ identity,
+ reason,
+ expiresDate,
+ executor,
+ BANFLAG_NONE
+ );
+
+ static char strKey[8];
+ int key = ++iPendingCounter;
+ IntToString(key, strKey, sizeof(strKey));
+ pendingInsertQueries.SetString(strKey, query);
+
+ g_db.Format(query, sizeof(query), "SELECT `flags` FROM `bans` WHERE `expired` = 0 AND `steamid` LIKE 'STEAM_%%:%%:%s' OR ip = '%s'", identity[10], identity);
+ g_db.Query(DB_OnBanPreCheck, query, key);
+ PrintToServer("Adding %s to OnBanClient queue. Key: %d", identity, key);
+
+ }else if(flags == BANFLAG_IP) {
+ LogMessage("Cannot save IP without steamid: %s [Source: %s]", identity, source);
+ }
+ return Plugin_Continue;
+}
+
+public Action OnBanClient(int client, int time, int flags, const char[] reason, const char[] kick_message, const char[] command, any source) {
+ if(GetUserAdmin(client) != INVALID_ADMIN_ID) {
+ LogMessage("Ignoring OnBanClient with admin id as target");
+ return Plugin_Stop;
+ }
+
+
+ char executor[32], identity[32], ip[32];
+ GetClientAuthId(client, AuthId_Steam2, identity, sizeof(identity));
+
+ LogMessage("OnBanClient client=%d flags=%d source=%d, command=%s", client, flags, source, command);
+
+ DataPack pack;
+ if(source > 0 && source <= MaxClients && IsClientConnected(source) && GetClientAuthId(source, AuthId_Steam2, executor, sizeof(executor))) {
+ pack = new DataPack();
+ pack.WriteString(identity);
+ pack.WriteCell(source);
+ }else{
+ executor = "CONSOLE";
+ }
+
+ GetClientIP(client, ip, sizeof(ip));
+ char query[512];
+
+ char expiresDate[64];
+ if(time > 0) {
+ Format(expiresDate, sizeof(expiresDate), "%d", GetTime() + (time * 60));
+ } else {
+ Format(expiresDate, sizeof(expiresDate), "NULL");
+ }
+
+ g_db.Format(query, sizeof(query), "INSERT INTO bans"
+ ..."(steamid, ip, reason, public_message, expires, executor, flags, timestamp)"
+ ..."VALUES ('%s', '%s', '%s', '%s', %s, '%s', %d, UNIX_TIMESTAMP())",
+ identity,
+ ip,
+ reason,
+ kick_message,
+ expiresDate,
+ executor,
+ BANFLAG_NONE
+ );
+
+ static char strKey[8];
+ int key = ++iPendingCounter;
+ IntToString(key, strKey, sizeof(strKey));
+ pendingInsertQueries.SetString(strKey, query);
+
+ g_db.Format(query, sizeof(query), "SELECT `flags` FROM `bans` WHERE `expired` = 0 AND `steamid` LIKE 'STEAM_%%:%%:%s' OR ip = '%s'", identity[10], identity);
+ g_db.Query(DB_OnBanPreCheck, query, key);
+
+ PrintToServer("Adding %N to OnBanClient queue. Key: %d", client, key);
+
+ // TODO: REMOVE : FOR DEBUG
+ return Plugin_Handled;
+ return Plugin_Continue;
+}
+
+
+
+public Action OnRemoveBan(const char[] identity, int flags, const char[] command, any source) {
+ if(flags == BANFLAG_AUTHID) {
+ static char query[128];
+ g_db.Format(query, sizeof(query), "DELETE FROM `bans` WHERE steamid = '%s'", identity);
+ g_db.Query(DB_GenericCallback, query, flags);
+ }
+ return Plugin_Continue;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// DB Callbacks
+///////////////////////////////////////////////////////////////////////////////
+//] DB_OnBanQuery returned error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
+public void DB_OnBanPreCheck(Database db, DBResultSet results, const char[] error, int key) {
+ static char strKey[8];
+ IntToString(key, strKey, sizeof(strKey));
+ static char query[255];
+ pendingInsertQueries.GetString(strKey, query, sizeof(query));
+
+ if(results == null || db == INVALID_HANDLE) {
+ LogError("Ban Pre-check: Cannot check for existing ban, ignoring ban attempt. [Query: %s]", query);
+ } else {
+ if(results.FetchRow()) {
+ int flags = results.FetchInt(0);
+ if(~flags & BANFLAG_SUSPENDED) {
+ LogMessage("Ban Pre-check: Found existing non-suspended ban, ignoring ban attempt. [Query: %s]", query);
+ return;
+ }
+ }
+
+ g_db.Query(DB_OnBanQuery, query);
+ }
+}
+
+
+public void DB_OnConnectCheck(Database db, DBResultSet results, const char[] error, int user) {
+ int client = GetClientOfUserId(user);
+ if(db == INVALID_HANDLE || results == null) {
+ LogError("DB_OnConnectCheck returned error: %s", error);
+ if(client > 0 && hKickType.IntValue == 2) {
+ KickClient(client, "Could not authenticate at this time.");
+ LogMessage("Could not connect to database to authorize user '%N' (#%d)", client, user);
+ }
+ } else {
+ //No failure, check the data.
+ while(client > 0 && results.FetchRow()) { //Is there a ban found?
+ static char reason[255], steamid[64], public_message[255];
+ DBResult colResult;
+
+ results.FetchString(0, reason, sizeof(reason), colResult);
+ results.FetchString(1, steamid, sizeof(steamid));
+ if(colResult == DBVal_Null) {
+ reason[0] = '\0';
+ }
+
+ bool expired = results.FetchInt(2) == 1; //Check if computed column 'expired' is true
+ if(results.IsFieldNull(2)) { //If expired null, delete i guess. lol
+ DeleteBan(steamid);
+ } else {
+ int flags = results.FetchInt(4);
+ if(!expired && (~flags & BANFLAG_SUSPENDED)) {
+ LogAction(-1, client, "\"%L\" (%s), is banned from server: \"%s\"", client, steamid, reason);
+ // Fetch public message
+ results.FetchString(3, public_message, sizeof(public_message), colResult);
+ if(colResult == DBVal_Null || strlen(public_message) == 0) {
+ public_message = reason;
+ }
+
+ int id = results.FetchInt(5);
+
+ if(hKickType.IntValue > 0) {
+ if(public_message[0] != '\0')
+ KickClient(client, "Banned:\n%s\nAppeal at jackz.me/apl/%d", public_message, id);
+ else
+ KickClient(client, "You have been banned from this server.\nAppeal at jackz.me/apl/%d", id);
+ static char query[128];
+ g_db.Format(query, sizeof(query), "UPDATE bans SET times_tried=times_tried+1 WHERE steamid = '%s'", steamid);
+ g_db.Query(DB_GenericCallback, query);
+ } else {
+ PrintChatToAdmins("\"%L\" was banned from this server for: \"%s\"", client, reason);
+ }
+ static char query[128];
+ g_db.Format(query, sizeof(query), "UPDATE bans SET times_tried=times_tried+1 WHERE steamid = '%s'", steamid);
+ g_db.Query(DB_GenericCallback, query);
+ } else {
+ LogAction(-1, client, "\"%L\" was previously banned from server: \"%s\"", client, reason);
+ // User was previously banned
+ PrintChatToAdmins("%N (%s) has a previous suspended/expired ban of reason \"%s\"", client, steamid, reason);
+ }
+ }
+ }
+ }
+}
+
+void DeleteBan(const char[] steamid) {
+ static char query[128];
+ g_db.Format(query, sizeof(query), "DELETE FROM `bans` WHERE steamid = '%s'", steamid);
+ g_db.Query(DB_GenericCallback, query);
+}
+
+
+public void DB_OnBanQuery(Database db, DBResultSet results, const char[] error, any data) {
+ if(db == INVALID_HANDLE || results == null) {
+ LogError("DB_OnBanQuery returned error: %s", error);
+ DataPack pack = data;
+ if(pack != null) {
+ pack.Reset();
+ static char id[32];
+ pack.ReadString(id, sizeof(id));
+ int source = pack.ReadCell();
+
+ if(StrContains(error, "Duplicate entry") > 0) {
+ PrintToChat(source, "Could not ban \"%s\", as they were previously banned. Please edit the ban manually on the website (or yell at jackz).", id);
+ } else {
+ PrintToChat(source, "Could not ban \"%s\" due to an error: %s", id, error);
+ }
+ }
+ }
+}
+
+public void DB_GenericCallback(Database db, DBResultSet results, const char[] error, any data) {
+ if(db == INVALID_HANDLE || results == null) {
+ LogError("DB_OnRemoveBanQuery returned error: %s", error);
+ }
+}
+
+stock void PrintChatToAdmins(const char[] format, any ...) {
+ char buffer[254];
+ VFormat(buffer, sizeof(buffer), format, 2);
+ for(int i = 1; i < MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i)) {
+ AdminId admin = GetUserAdmin(i);
+ if(admin != INVALID_ADMIN_ID) {
+ PrintToChat(i, "%s", buffer);
+ }
+ }
+ }
+ PrintToServer("%s", buffer);
+}
diff --git a/scripting/include/CreateSurvivorBot.inc b/scripting/include/CreateSurvivorBot.inc
new file mode 100644
index 0000000..ef108d5
--- /dev/null
+++ b/scripting/include/CreateSurvivorBot.inc
@@ -0,0 +1,43 @@
+#if defined _CreateSurvivorBot_included
+ #endinput
+#endif
+#define _CreateSurvivorBot_included
+
+native int NextBotCreatePlayerBotSurvivorBot(const char[] _szName = NULL_STRING);
+
+native bool CTerrorPlayerRoundRespawn(int _iClientIndex);
+
+stock int CreateSurvivorBot()
+{
+ int bot = NextBotCreatePlayerBotSurvivorBot(NULL_STRING);
+ if( IsValidEntity(bot) )
+ {
+ ChangeClientTeam(bot, 2);
+
+ if( !IsPlayerAlive(bot) )
+ {
+ CTerrorPlayerRoundRespawn(bot);
+ }
+ return bot;
+ }
+ return -1;
+}
+
+public SharedPlugin __pl_shope =
+{
+ name = "CreateSurvivorBot",
+ file = "CreateSurvivorBot.smx",
+ #if defined REQUIRE_PLUGIN
+ required = 1
+ #else
+ required = 0
+ #endif
+};
+
+#if !defined REQUIRE_PLUGIN
+public void __pl_CreateSurvivorBot_SetNTVOptional()
+{
+ MarkNativeAsOptional("NextBotCreatePlayerBotSurvivorBot");
+ MarkNativeAsOptional("CTerrorPlayerRoundRespawn");
+}
+#endif
\ No newline at end of file
diff --git a/scripting/include/SteamWorks.inc b/scripting/include/SteamWorks.inc
new file mode 100644
index 0000000..94b38f5
--- /dev/null
+++ b/scripting/include/SteamWorks.inc
@@ -0,0 +1,413 @@
+#if defined _SteamWorks_Included
+ #endinput
+#endif
+#define _SteamWorks_Included
+
+/* results from UserHasLicenseForApp */
+enum EUserHasLicenseForAppResult
+{
+ k_EUserHasLicenseResultHasLicense = 0, // User has a license for specified app
+ k_EUserHasLicenseResultDoesNotHaveLicense = 1, // User does not have a license for the specified app
+ k_EUserHasLicenseResultNoAuth = 2, // User has not been authenticated
+};
+
+/* General result codes */
+enum EResult
+{
+ k_EResultOK = 1, // success
+ k_EResultFail = 2, // generic failure
+ k_EResultNoConnection = 3, // no/failed network connection
+// k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
+ k_EResultInvalidPassword = 5, // password/ticket is invalid
+ k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
+ k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
+ k_EResultInvalidParam = 8, // a parameter is incorrect
+ k_EResultFileNotFound = 9, // file was not found
+ k_EResultBusy = 10, // called method busy - action not taken
+ k_EResultInvalidState = 11, // called object was in an invalid state
+ k_EResultInvalidName = 12, // name is invalid
+ k_EResultInvalidEmail = 13, // email is invalid
+ k_EResultDuplicateName = 14, // name is not unique
+ k_EResultAccessDenied = 15, // access is denied
+ k_EResultTimeout = 16, // operation timed out
+ k_EResultBanned = 17, // VAC2 banned
+ k_EResultAccountNotFound = 18, // account not found
+ k_EResultInvalidSteamID = 19, // steamID is invalid
+ k_EResultServiceUnavailable = 20, // The requested service is currently unavailable
+ k_EResultNotLoggedOn = 21, // The user is not logged on
+ k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party)
+ k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
+ k_EResultInsufficientPrivilege = 24, // Insufficient privilege
+ k_EResultLimitExceeded = 25, // Too much of a good thing
+ k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes)
+ k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired
+ k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again
+ k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time
+ k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user
+ k_EResultIPNotFound = 31, // IP address not found
+ k_EResultPersistFailed = 32, // failed to write change to the data store
+ k_EResultLockingFailed = 33, // failed to acquire access lock for this operation
+ k_EResultLogonSessionReplaced = 34,
+ k_EResultConnectFailed = 35,
+ k_EResultHandshakeFailed = 36,
+ k_EResultIOFailure = 37,
+ k_EResultRemoteDisconnect = 38,
+ k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested
+ k_EResultBlocked = 40, // a user didn't allow it
+ k_EResultIgnored = 41, // target is ignoring sender
+ k_EResultNoMatch = 42, // nothing matching the request found
+ k_EResultAccountDisabled = 43,
+ k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now
+ k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available
+ k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin
+ k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol.
+ k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another.
+ k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed.
+ k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait
+ k_EResultSuspended = 51, // Long running operation (content download) suspended/paused
+ k_EResultCancelled = 52, // Operation canceled (typically by user: content download)
+ k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable
+ k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
+ k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
+ k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side
+ k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account
+ k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
+ k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first
+ k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
+ k_EResultIllegalPassword = 61, // The requested new password is not legal
+ k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
+ k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
+ k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
+ k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
+ k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
+ k_EResultHardwareNotCapableOfIPT = 67, //
+ k_EResultIPTInitError = 68, //
+ k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user
+ k_EResultFacebookQueryError = 70, // Facebook query returned an error
+ k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired
+ k_EResultIPLoginRestrictionFailed = 72,
+ k_EResultAccountLockedDown = 73,
+ k_EResultAccountLogonDeniedVerifiedEmailRequired = 74,
+ k_EResultNoMatchingURL = 75,
+ k_EResultBadResponse = 76, // parse failure, missing field, etc.
+ k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password
+ k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range
+ k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen
+ k_EResultDisabled = 80, // The requested service has been configured to be unavailable
+ k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid !
+ k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action
+ k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted
+ k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent
+ k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login
+ k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted
+ k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker
+ k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch
+ k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match
+ k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners
+ k_EResultNotModified = 91, // data not modified
+ k_EResultNoMobileDevice = 92, // the account does not have a mobile device associated with it
+ k_EResultTimeNotSynced = 93, // the time presented is out of range or tolerance
+ k_EResultSmsCodeFailed = 94, // SMS code failure (no match, none pending, etc.)
+ k_EResultAccountLimitExceeded = 95, // Too many accounts access this resource
+ k_EResultAccountActivityLimitExceeded = 96, // Too many changes to this account
+ k_EResultPhoneActivityLimitExceeded = 97, // Too many changes to this phone
+ k_EResultRefundToWallet = 98, // Cannot refund to payment method, must use wallet
+ k_EResultEmailSendFailure = 99, // Cannot send an email
+ k_EResultNotSettled = 100, // Can't perform operation till payment has settled
+ k_EResultNeedCaptcha = 101, // Needs to provide a valid captcha
+ k_EResultGSLTDenied = 102, // a game server login token owned by this token's owner has been banned
+ k_EResultGSOwnerDenied = 103, // game server owner is denied for other reason (account lock, community ban, vac ban, missing phone)
+ k_EResultInvalidItemType = 104 // the type of thing we were requested to act on is invalid
+};
+
+/* This enum is used in client API methods, do not re-number existing values. */
+enum EHTTPMethod
+{
+ k_EHTTPMethodInvalid = 0,
+ k_EHTTPMethodGET,
+ k_EHTTPMethodHEAD,
+ k_EHTTPMethodPOST,
+ k_EHTTPMethodPUT,
+ k_EHTTPMethodDELETE,
+ k_EHTTPMethodOPTIONS,
+ k_EHTTPMethodPATCH,
+
+ // The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for
+ // a compliant general purpose server. We'll likely add more as we find uses for them.
+
+ // k_EHTTPMethodTRACE,
+ // k_EHTTPMethodCONNECT
+};
+
+
+/* HTTP Status codes that the server can send in response to a request, see rfc2616 section 10.3 for descriptions
+ of each of these. */
+enum EHTTPStatusCode
+{
+ // Invalid status code (this isn't defined in HTTP, used to indicate unset in our code)
+ k_EHTTPStatusCodeInvalid = 0,
+
+ // Informational codes
+ k_EHTTPStatusCode100Continue = 100,
+ k_EHTTPStatusCode101SwitchingProtocols = 101,
+
+ // Success codes
+ k_EHTTPStatusCode200OK = 200,
+ k_EHTTPStatusCode201Created = 201,
+ k_EHTTPStatusCode202Accepted = 202,
+ k_EHTTPStatusCode203NonAuthoritative = 203,
+ k_EHTTPStatusCode204NoContent = 204,
+ k_EHTTPStatusCode205ResetContent = 205,
+ k_EHTTPStatusCode206PartialContent = 206,
+
+ // Redirection codes
+ k_EHTTPStatusCode300MultipleChoices = 300,
+ k_EHTTPStatusCode301MovedPermanently = 301,
+ k_EHTTPStatusCode302Found = 302,
+ k_EHTTPStatusCode303SeeOther = 303,
+ k_EHTTPStatusCode304NotModified = 304,
+ k_EHTTPStatusCode305UseProxy = 305,
+ //k_EHTTPStatusCode306Unused = 306, (used in old HTTP spec, now unused in 1.1)
+ k_EHTTPStatusCode307TemporaryRedirect = 307,
+
+ // Error codes
+ k_EHTTPStatusCode400BadRequest = 400,
+ k_EHTTPStatusCode401Unauthorized = 401, // You probably want 403 or something else. 401 implies you're sending a WWW-Authenticate header and the client can sent an Authorization header in response.
+ k_EHTTPStatusCode402PaymentRequired = 402, // This is reserved for future HTTP specs, not really supported by clients
+ k_EHTTPStatusCode403Forbidden = 403,
+ k_EHTTPStatusCode404NotFound = 404,
+ k_EHTTPStatusCode405MethodNotAllowed = 405,
+ k_EHTTPStatusCode406NotAcceptable = 406,
+ k_EHTTPStatusCode407ProxyAuthRequired = 407,
+ k_EHTTPStatusCode408RequestTimeout = 408,
+ k_EHTTPStatusCode409Conflict = 409,
+ k_EHTTPStatusCode410Gone = 410,
+ k_EHTTPStatusCode411LengthRequired = 411,
+ k_EHTTPStatusCode412PreconditionFailed = 412,
+ k_EHTTPStatusCode413RequestEntityTooLarge = 413,
+ k_EHTTPStatusCode414RequestURITooLong = 414,
+ k_EHTTPStatusCode415UnsupportedMediaType = 415,
+ k_EHTTPStatusCode416RequestedRangeNotSatisfiable = 416,
+ k_EHTTPStatusCode417ExpectationFailed = 417,
+ k_EHTTPStatusCode4xxUnknown = 418, // 418 is reserved, so we'll use it to mean unknown
+ k_EHTTPStatusCode429TooManyRequests = 429,
+
+ // Server error codes
+ k_EHTTPStatusCode500InternalServerError = 500,
+ k_EHTTPStatusCode501NotImplemented = 501,
+ k_EHTTPStatusCode502BadGateway = 502,
+ k_EHTTPStatusCode503ServiceUnavailable = 503,
+ k_EHTTPStatusCode504GatewayTimeout = 504,
+ k_EHTTPStatusCode505HTTPVersionNotSupported = 505,
+ k_EHTTPStatusCode5xxUnknown = 599,
+};
+
+/* list of possible return values from the ISteamGameCoordinator API */
+enum EGCResults
+{
+ k_EGCResultOK = 0,
+ k_EGCResultNoMessage = 1, // There is no message in the queue
+ k_EGCResultBufferTooSmall = 2, // The buffer is too small for the requested message
+ k_EGCResultNotLoggedOn = 3, // The client is not logged onto Steam
+ k_EGCResultInvalidMessage = 4, // Something was wrong with the message being sent with SendMessage
+};
+
+native bool SteamWorks_IsVACEnabled();
+native bool SteamWorks_GetPublicIP(int ipaddr[4]);
+native void SteamWorks_GetPublicIPCell();
+native bool SteamWorks_IsLoaded();
+native bool SteamWorks_SetGameData(const char[] sData);
+native bool SteamWorks_SetGameDescription(const char[] sDesc);
+native bool SteamWorks_SetMapName(const char[] sMapName);
+native bool SteamWorks_IsConnected();
+native bool SteamWorks_SetRule(const char[] sKey, const char[] sValue);
+native bool SteamWorks_ClearRules();
+native bool SteamWorks_ForceHeartbeat();
+native bool SteamWorks_GetUserGroupStatus(int client, int groupid);
+native bool SteamWorks_GetUserGroupStatusAuthID(int authid, int groupid);
+
+native EUserHasLicenseForAppResult SteamWorks_HasLicenseForApp(int client, int app);
+native EUserHasLicenseForAppResult SteamWorks_HasLicenseForAppId(int authid, int app);
+native void SteamWorks_GetClientSteamID(int client, char[] sSteamID, int length);
+
+native bool SteamWorks_RequestStatsAuthID(int authid, int appid);
+native bool SteamWorks_RequestStats(int client, int appid);
+native bool SteamWorks_GetStatCell(int client, const char[] sKey, int &value);
+native bool SteamWorks_GetStatAuthIDCell(int authid, const char[] sKey, int &value);
+native bool SteamWorks_GetStatFloat(int client, const char[] sKey, float &value);
+native bool SteamWorks_GetStatAuthIDFloat(int authid, const char[] sKey, float &value);
+
+native Handle SteamWorks_CreateHTTPRequest(EHTTPMethod method, const char[] sURL);
+native bool SteamWorks_SetHTTPRequestContextValue(Handle hHandle, any data1, any data2 = 0);
+native bool SteamWorks_SetHTTPRequestNetworkActivityTimeout(Handle hHandle, int timeout);
+native bool SteamWorks_SetHTTPRequestHeaderValue(Handle hHandle, const char[] sName, const char[] sValue);
+native bool SteamWorks_SetHTTPRequestGetOrPostParameter(Handle hHandle, const char[] sName, const char[] sValue);
+native bool SteamWorks_SetHTTPRequestUserAgentInfo(Handle hHandle, const char[] sUserAgentInfo);
+native bool SteamWorks_SetHTTPRequestRequiresVerifiedCertificate(Handle hHandle, bool bRequireVerifiedCertificate);
+native bool SteamWorks_SetHTTPRequestAbsoluteTimeoutMS(Handle hHandle, int unMilliseconds);
+
+#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 9
+typeset SteamWorksHTTPRequestCompleted
+{
+ function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode);
+ function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data1);
+ function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data1, any data2);
+};
+
+typeset SteamWorksHTTPHeadersReceived
+{
+ function void (Handle hRequest, bool bFailure);
+ function void (Handle hRequest, bool bFailure, any data1);
+ function void (Handle hRequest, bool bFailure, any data1, any data2);
+};
+
+typeset SteamWorksHTTPDataReceived
+{
+ function void (Handle hRequest, bool bFailure, int offset, int bytesreceived);
+ function void (Handle hRequest, bool bFailure, int offset, int bytesreceived, any data1);
+ function void (Handle hRequest, bool bFailure, int offset, int bytesreceived, any data1, any data2);
+};
+
+typeset SteamWorksHTTPBodyCallback
+{
+ function void (const char[] sData);
+ function void (const char[] sData, any value);
+ function void (const int[] data, any value, int datalen);
+};
+
+#else
+
+funcenum SteamWorksHTTPRequestCompleted
+{
+ public(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode:eStatusCode),
+ public(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode:eStatusCode, any:data1),
+ public(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode:eStatusCode, any:data1, any:data2)
+};
+
+funcenum SteamWorksHTTPHeadersReceived
+{
+ public(Handle hRequest, bool bFailure),
+ public(Handle hRequest, bool bFailure, any:data1),
+ public(Handle hRequest, bool bFailure, any:data1, any:data2)
+};
+
+funcenum SteamWorksHTTPDataReceived
+{
+ public(Handle hRequest, bool bFailure, offset, bytesreceived),
+ public(Handle hRequest, bool bFailure, offset, bytesreceived, any:data1),
+ public(Handle hRequest, bool bFailure, offset, bytesreceived, any:data1, any:data2)
+};
+
+funcenum SteamWorksHTTPBodyCallback
+{
+ public(const char sData[]),
+ public(const char sData[], any:value),
+ public(const data[], any:value, datalen)
+};
+
+#endif
+
+native bool SteamWorks_SetHTTPCallbacks(Handle hHandle, SteamWorksHTTPRequestCompleted fCompleted = INVALID_FUNCTION, SteamWorksHTTPHeadersReceived fHeaders = INVALID_FUNCTION, SteamWorksHTTPDataReceived fData = INVALID_FUNCTION, Handle hCalling = INVALID_HANDLE);
+native bool SteamWorks_SendHTTPRequest(Handle hRequest);
+native bool SteamWorks_SendHTTPRequestAndStreamResponse(Handle hRequest);
+native bool SteamWorks_DeferHTTPRequest(Handle hRequest);
+native bool SteamWorks_PrioritizeHTTPRequest(Handle hRequest);
+native bool SteamWorks_GetHTTPResponseHeaderSize(Handle hRequest, const char[] sHeader, int &size);
+native bool SteamWorks_GetHTTPResponseHeaderValue(Handle hRequest, const char[] sHeader, char[] sValue, int size);
+native bool SteamWorks_GetHTTPResponseBodySize(Handle hRequest, int &size);
+native bool SteamWorks_GetHTTPResponseBodyData(Handle hRequest, char[] sBody, int length);
+native bool SteamWorks_GetHTTPStreamingResponseBodyData(Handle hRequest, int cOffset, char[] sBody, int length);
+native bool SteamWorks_GetHTTPDownloadProgressPct(Handle hRequest, float &percent);
+native bool SteamWorks_GetHTTPRequestWasTimedOut(Handle hRequest, bool & bWasTimedOut);
+native bool SteamWorks_SetHTTPRequestRawPostBody(Handle hRequest, const char[] sContentType, const char[] sBody, int bodylen);
+native bool SteamWorks_SetHTTPRequestRawPostBodyFromFile(Handle hRequest, const char[] sContentType, const char[] sFileName);
+
+native bool SteamWorks_GetHTTPResponseBodyCallback(Handle hRequest, SteamWorksHTTPBodyCallback fCallback, any data = 0, Handle hPlugin = INVALID_HANDLE); /* Look up, moved definition for 1.7+ compat. */
+native bool SteamWorks_WriteHTTPResponseBodyToFile(Handle hRequest, const char[] sFileName);
+
+forward void SW_OnValidateClient(int ownerauthid, int authid);
+forward void SteamWorks_OnValidateClient(int ownerauthid, int authid);
+forward void SteamWorks_SteamServersConnected();
+forward void SteamWorks_SteamServersConnectFailure(EResult result);
+forward void SteamWorks_SteamServersDisconnected(EResult result);
+
+forward Action SteamWorks_RestartRequested();
+forward void SteamWorks_TokenRequested(char[] sToken, int maxlen);
+
+forward void SteamWorks_OnClientGroupStatus(int authid, int groupid, bool isMember, bool isOfficer);
+
+forward EGCResults SteamWorks_GCSendMessage(int unMsgType, const char[] pubData, int cubData);
+forward void SteamWorks_GCMsgAvailable(int cubData);
+forward EGCResults SteamWorks_GCRetrieveMessage(int punMsgType, const char[] pubDest, int cubDest, int pcubMsgSize);
+
+native EGCResults SteamWorks_SendMessageToGC(int unMsgType, const char[] pubData, int cubData);
+
+public Extension __ext_SteamWorks =
+{
+ name = "SteamWorks",
+ file = "SteamWorks.ext",
+#if defined AUTOLOAD_EXTENSIONS
+ autoload = 1,
+#else
+ autoload = 0,
+#endif
+#if defined REQUIRE_EXTENSIONS
+ required = 1,
+#else
+ required = 0,
+#endif
+};
+
+#if !defined REQUIRE_EXTENSIONS
+public __ext_SteamWorks_SetNTVOptional()
+{
+ MarkNativeAsOptional("SteamWorks_IsVACEnabled");
+ MarkNativeAsOptional("SteamWorks_GetPublicIP");
+ MarkNativeAsOptional("SteamWorks_GetPublicIPCell");
+ MarkNativeAsOptional("SteamWorks_IsLoaded");
+ MarkNativeAsOptional("SteamWorks_SetGameData");
+ MarkNativeAsOptional("SteamWorks_SetGameDescription");
+ MarkNativeAsOptional("SteamWorks_IsConnected");
+ MarkNativeAsOptional("SteamWorks_SetRule");
+ MarkNativeAsOptional("SteamWorks_ClearRules");
+ MarkNativeAsOptional("SteamWorks_ForceHeartbeat");
+ MarkNativeAsOptional("SteamWorks_GetUserGroupStatus");
+ MarkNativeAsOptional("SteamWorks_GetUserGroupStatusAuthID");
+
+ MarkNativeAsOptional("SteamWorks_HasLicenseForApp");
+ MarkNativeAsOptional("SteamWorks_HasLicenseForAppId");
+ MarkNativeAsOptional("SteamWorks_GetClientSteamID");
+
+ MarkNativeAsOptional("SteamWorks_RequestStatsAuthID");
+ MarkNativeAsOptional("SteamWorks_RequestStats");
+ MarkNativeAsOptional("SteamWorks_GetStatCell");
+ MarkNativeAsOptional("SteamWorks_GetStatAuthIDCell");
+ MarkNativeAsOptional("SteamWorks_GetStatFloat");
+ MarkNativeAsOptional("SteamWorks_GetStatAuthIDFloat");
+
+ MarkNativeAsOptional("SteamWorks_SendMessageToGC");
+
+ MarkNativeAsOptional("SteamWorks_CreateHTTPRequest");
+ MarkNativeAsOptional("SteamWorks_SetHTTPRequestContextValue");
+ MarkNativeAsOptional("SteamWorks_SetHTTPRequestNetworkActivityTimeout");
+ MarkNativeAsOptional("SteamWorks_SetHTTPRequestHeaderValue");
+ MarkNativeAsOptional("SteamWorks_SetHTTPRequestGetOrPostParameter");
+
+ MarkNativeAsOptional("SteamWorks_SetHTTPCallbacks");
+ MarkNativeAsOptional("SteamWorks_SendHTTPRequest");
+ MarkNativeAsOptional("SteamWorks_SendHTTPRequestAndStreamResponse");
+ MarkNativeAsOptional("SteamWorks_DeferHTTPRequest");
+ MarkNativeAsOptional("SteamWorks_PrioritizeHTTPRequest");
+ MarkNativeAsOptional("SteamWorks_GetHTTPResponseHeaderSize");
+ MarkNativeAsOptional("SteamWorks_GetHTTPResponseHeaderValue");
+ MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodySize");
+ MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodyData");
+ MarkNativeAsOptional("SteamWorks_GetHTTPStreamingResponseBodyData");
+ MarkNativeAsOptional("SteamWorks_GetHTTPDownloadProgressPct");
+ MarkNativeAsOptional("SteamWorks_SetHTTPRequestRawPostBody");
+ MarkNativeAsOptional("SteamWorks_SetHTTPRequestRawPostBodyFromFile");
+
+ MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodyCallback");
+ MarkNativeAsOptional("SteamWorks_WriteHTTPResponseBodyToFile");
+}
+#endif
diff --git a/scripting/include/actions.inc b/scripting/include/actions.inc
new file mode 100644
index 0000000..9273ce4
--- /dev/null
+++ b/scripting/include/actions.inc
@@ -0,0 +1,962 @@
+#if defined _actions_included
+ #endinput
+#endif
+
+#define _actions_included
+
+#define ACTION_NAME_LENGTH 32
+
+enum ActionResultType
+{
+ CONTINUE, // continue executing this action next frame - nothing has changed
+ CHANGE_TO, // change actions next frame
+ SUSPEND_FOR, // put the current action on hold for the new action
+ DONE, // this action has finished, resume suspended action
+ SUSTAIN, // for use with event handlers - a way to say "It's important to keep doing what I'm doing"
+};
+
+enum EventResultPriorityType
+{
+ RESULT_NONE, // no result
+ RESULT_TRY, // use this result, or toss it out, either is ok
+ RESULT_IMPORTANT, // try extra-hard to use this result
+ RESULT_CRITICAL // this result must be used - emit an error if it can't be
+};
+
+enum BehaviorAction
+{
+ INVALID_ACTION
+};
+
+/**
+ * @brief Callback called for every entity action.
+ *
+ * @param action Action address
+ *
+ * @noreturn
+ */
+typedef ActionsIteratorCallback = function void (BehaviorAction action);
+
+/**
+ * @brief Called whenever action is created
+ *
+ * @param action Created action address
+ * @param actor Actor of the action
+ * @param name Name of the action
+ *
+ * @noreturn
+ */
+forward void OnActionCreated( BehaviorAction action, int actor, const char[] name );
+
+/**
+ * @brief Called whenever action is destroyed
+ * @note You are in action destructor!
+ *
+ * @param action Destroyed action address
+ * @param actor Actor of the action
+ * @param name Name of the action
+ *
+ * @noreturn
+ */
+forward void OnActionDestroyed( BehaviorAction action, int actor, const char[] name );
+
+methodmap ActionResult
+{
+ /**
+ * @brief Gets action result reason
+ *
+ * @param destination Buffer to store reason
+ * @param maxlength Length of the buffer
+ *
+ * @noreturn
+ */
+ public native void GetReason( char[] destination, int maxlength );
+
+ /**
+ * @brief Sets action result reason
+ *
+ * @param reason String with reason
+ *
+ * @noreturn
+ */
+ public native void SetReason( const char[] reason );
+
+ /**
+ * @brief Property to get/set result type
+ *
+ * @return Result type (see ActionResultType)
+ */
+ property ActionResultType type
+ {
+ public native get();
+ public native set(ActionResultType type);
+ }
+
+ /**
+ * @brief Property to get/set result action
+ *
+ * @return Result action
+ */
+ property BehaviorAction action
+ {
+ public native get();
+ public native set(BehaviorAction action);
+ }
+
+ /**
+ * @brief Checks if result is requesting change
+ *
+ * @return true if it is requesting, false otherwise
+ */
+ public bool IsRequestingChange()
+ {
+ ActionResultType type = this.type;
+
+ return (type == CHANGE_TO || type == SUSPEND_FOR || type == DONE);
+ }
+}
+
+methodmap ActionDesiredResult < ActionResult
+{
+ /**
+ * @brief Property to get/set result priority
+ *
+ * @return Result priority
+ */
+ property EventResultPriorityType priority
+ {
+ public native get();
+ public native set(EventResultPriorityType priority);
+ }
+}
+
+typeset ActionHandler
+{
+ /* OnStart, OnSuspend, OnResume */
+ function Action (BehaviorAction action, int actor, BehaviorAction priorAction, ActionResult result);
+
+ /* OnUpdate */
+ function Action (BehaviorAction action, int actor, float interval, ActionResult result);
+
+ /* OnEnd */
+ function void (BehaviorAction action, int actor, BehaviorAction priorAction, ActionResult result);
+
+ /* InitialContainedAction */
+ function Action (BehaviorAction action, int actor, BehaviorAction& action);
+
+ /* OnLeaveGround, OnLandOnGround, OnDrop, OnShoved, OnBlinded, OnHitByVomitJar, OnCommandAttack */
+ function Action (BehaviorAction action, int actor, int entity, ActionDesiredResult result);
+
+ /* OnContact */
+ function Action (BehaviorAction action, int actor, int entity, Address trace, ActionDesiredResult result);
+
+ /* OnMoveToSuccess */
+ function Action (BehaviorAction action, int actor, Address path, ActionDesiredResult result);
+
+ /* OnMoveToFailure */
+ function Action (BehaviorAction action, int actor, Address path, any type, ActionDesiredResult result);
+
+ /* OnStuck, OnUnStuck, OnPostureChanged, OnIgnite, OnModelChanged, OnEnteredSpit, OnCommandAssault, OnCommandResume */
+ function Action (BehaviorAction action, int actor, ActionDesiredResult result);
+
+ /* OnAnimationActivityComplete, OnAnimationActivityInterrupted */
+ function Action (BehaviorAction action, int actor, int activity, ActionDesiredResult result);
+
+ /* OnAnimationEvent */
+ function Action (BehaviorAction action, int actor, Address animevent, ActionDesiredResult result);
+
+ /* OnInjured, OnKilled */
+ function Action (BehaviorAction action, int actor, Address takedamageinfo, ActionDesiredResult result);
+
+ /* OnOtherKilled */
+ function Action (BehaviorAction action, int actor, int other, Address takedamageinfo, ActionDesiredResult result);
+
+ /* OnSight, OnLostSight, OnThreatChanged */
+ function Action (BehaviorAction action, int actor, int entity, ActionDesiredResult result);
+
+ /* OnSound */
+ function Action (BehaviorAction action, int actor, int entity, const float pos[3], Address keyvalues, ActionDesiredResult result);
+
+ /* OnSpokeConcept */
+ function Action (BehaviorAction action, int actor, int who, Address concept, Address response, Address unknown, ActionDesiredResult result);
+
+ /* OnNavAreaChanged */
+ function Action (BehaviorAction action, int actor, Address newArea, Address oldArea, ActionDesiredResult result);
+
+ /* OnPickUp */
+ function Action (BehaviorAction action, int actor, int entity, int giver, ActionDesiredResult result);
+
+ /* OnCommandApproachVector */
+ function Action (BehaviorAction action, int actor, const float pos[3], float range, ActionDesiredResult result);
+
+ /* OnCommandApproachEntity */
+ function Action (BehaviorAction action, int actor, int goal, ActionDesiredResult result);
+
+ /* OnCommandRetreat */
+ function Action (BehaviorAction action, int actor, int threat, float range, ActionDesiredResult result);
+
+ /* OnCommandPause */
+ function Action (BehaviorAction action, int actor, float duration, ActionDesiredResult result);
+
+ /* OnCommandString */
+ function Action (BehaviorAction action, int actor, const char[] command, ActionDesiredResult result);
+
+ /* IsAbleToBlockMovementOf */
+ function Action (BehaviorAction action, int actor, Address nextbot, ActionDesiredResult result);
+}
+
+methodmap ActionsManager
+{
+ /**
+ * @brief Creates action template with given name
+ * @note Use this to create your own actions
+ *
+ * @param name New action name
+ *
+ * @return Action address
+ */
+ public static native BehaviorAction Create( const char[] name );
+
+ /**
+ * @brief Allocates memory with given size
+ * @note Use this with game action constructor to create game actions
+ *
+ * @param size Size to allocate
+ *
+ * @return Allocated memory start address
+ */
+ public static native BehaviorAction Allocate( int size );
+
+ /**
+ * @brief Deallocates memory
+ * @note Actually used only for deallocating actions
+ *
+ * @param action Action to deallocate
+ *
+ * @noreturn
+ */
+ public static native void Deallocate( BehaviorAction action );
+
+ /**
+ * @brief Used to iterate over all entity actions
+ *
+ * @param entity Entity index
+ * @param callback Iterator callback
+ *
+ * @return Number of actions entity has
+ */
+ public static native int Iterator( int entity, ActionsIteratorCallback callback = INVALID_FUNCTION );
+
+ /**
+ * @brief Returns entity action with given name
+ *
+ * @param entity Entity index
+ * @param name Action name to find
+ *
+ * @return Action address, INVALID_ACTION if not found
+ */
+ public static native BehaviorAction GetAction( int entity, const char[] name );
+}
+
+methodmap BehaviorAction
+{
+ public BehaviorAction(any action)
+ {
+ return view_as(action);
+ }
+
+ /**
+ * @brief Stores pending event result
+ * @note This is almost same as changing result via event handler but this one violates semantics
+ *
+ * @param type Result type (See ActionResultType)
+ * @param action Action
+ * @param priority Priority
+ * @param reason Reason
+ *
+ * @error Invalid action passed
+ * @noreturn
+ */
+ public native void StorePendingEventResult( ActionResultType type = CONTINUE, BehaviorAction action = INVALID_ACTION, EventResultPriorityType priority = RESULT_TRY, const char[] reason = NULL_STRING );
+
+ /**
+ * @brief Gets action name
+ *
+ * @param destination Buffer to store name
+ * @param maxlength Buffer length
+ *
+ * @error Invalid action passed
+ * @return Number of bytes written?
+ */
+ public native int GetName( char[] destination, int maxlength = ACTION_NAME_LENGTH );
+
+ /**
+ * @brief Simple wrapper to get action data
+ *
+ * @param int Offset to data
+ * @param type How many bytes read (See NumberType)
+ *
+ * @return Stored data
+ */
+ public any Get( int offset, NumberType type = NumberType_Int32 )
+ {
+ return view_as(LoadFromAddress(view_as(this) + view_as(offset), type));
+ }
+
+ /**
+ * @brief Simple wrapper to set action data
+ *
+ * @param int Offset to data
+ * @param data Data to set
+ * @param type How many bytes set (See NumberType)
+ *
+ * @noreturn
+ */
+ #if SOURCEMOD_V_MINOR < 11
+ public void Set( int offset, any data, NumberType type = NumberType_Int32 )
+ {
+ StoreToAddress(view_as(this) + view_as(offset), data, type);
+ }
+ #else
+ public void Set( int offset, any data, NumberType type = NumberType_Int32, bool updateMemAccess = true )
+ {
+ StoreToAddress(view_as(this) + view_as(offset), data, type, updateMemAccess);
+ }
+ #endif
+ // ====================================================================================================
+ // ACTION PROPERTIES
+ // ====================================================================================================
+
+ /**
+ * @brief Property to get/set parent action
+ *
+ * @return Parent action
+ */
+ property BehaviorAction Parent
+ {
+ public native get();
+ }
+
+ /**
+ * @brief Property to get/set child action
+ *
+ * @return Child action
+ */
+ property BehaviorAction Child
+ {
+ public native get();
+ }
+
+ /**
+ * @brief Property to get/set "under" action
+ * @note if we are suspender then this will return a suspended action
+ *
+ * @return Under action
+ */
+ property BehaviorAction Under
+ {
+ public native get();
+ }
+
+ /**
+ * @brief Property to get/set "above" action
+ * @note if we are suspended action then this will return a suspender
+ *
+ * @return Above action
+ */
+ property BehaviorAction Above
+ {
+ public native get();
+ }
+
+ /**
+ * @brief Property to get actor of action
+ * @note returns 0 if action hasn't been started yet
+ *
+ * @return Action actor
+ */
+ property int Actor
+ {
+ public native get();
+ }
+
+ /**
+ * @brief Property to get/set suspended state of action
+ *
+ * @return true if suspended, false otherwise
+ */
+ property bool IsSuspended
+ {
+ public native get();
+ public native set(bool suspended);
+ }
+
+ /**
+ * @brief Property to get/set started state of action
+ * @note if this returns true then OnStart handled has already been called
+ *
+ * @return true if started, false otherwise
+ */
+ property bool IsStarted
+ {
+ public native get();
+ public native set(bool started);
+ }
+
+ // ====================================================================================================
+ // ACTION PRE EVENT HANDLERS
+ // ====================================================================================================
+
+ property ActionHandler OnStart
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnUpdate
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnEnd
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSuspend
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnResume
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnInitialContainedAction
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnLeaveGround
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnLandOnGround
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnContact
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnMoveToSuccess
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnMoveToFailure
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnStuck
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnUnStuck
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnPostureChanged
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnAnimationActivityComplete
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnAnimationActivityInterrupted
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnAnimationEvent
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnIgnite
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnInjured
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnKilled
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnOtherKilled
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSight
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnLostSight
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnThreatChanged
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSound
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSpokeConcept
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnNavAreaChanged
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnModelChanged
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnPickUp
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnShoved
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnBlinded
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnEnteredSpit
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnHitByVomitJar
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandAttack
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandAssault
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandApproachV
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandApproachE
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandRetreat
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandPause
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandResume
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandString
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler IsAbleToBlockMovementOf
+ {
+ public native set(ActionHandler func);
+ }
+
+ // ====================================================================================================
+ // ACTION POST EVENT HANDLERS
+ // ====================================================================================================
+
+ property ActionHandler OnStartPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnUpdatePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnEndPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSuspendPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnResumePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnInitialContainedActionPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnLeaveGroundPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnLandOnGroundPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnContactPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnMoveToSuccessPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnMoveToFailurePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnStuckPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnUnStuckPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnPostureChangedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnAnimationActivityCompletePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnAnimationActivityInterruptedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnAnimationEventPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnIgnitePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnInjuredPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnKilledPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnOtherKilledPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSightPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnLostSightPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnThreatChangedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSoundPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnSpokeConceptPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnNavAreaChangedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnModelChangedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnPickUpPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnShovedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnBlindedPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnEnteredSpitPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnHitByVomitJarPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandAttackPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandAssaultPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandApproachVPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandApproachEPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandRetreatPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandPausePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandResumePost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler OnCommandStringPost
+ {
+ public native set(ActionHandler func);
+ }
+
+ property ActionHandler IsAbleToBlockMovementOfPost
+ {
+ public native set(ActionHandler func);
+ }
+};
+
+// ====================================================================================================
+// PL NTV
+// ====================================================================================================
+
+public Extension __ext_actions =
+{
+ name = "Actions",
+ file = "actions.ext",
+ autoload = 1,
+#if defined REQUIRE_EXTENSIONS
+ required = 1,
+#else
+ required = 0,
+#endif
+};
+
+#if !defined REQUIRE_EXTENSIONS
+public void __ext_actions_SetNTVOptional()
+{
+ MarkNativeAsOptional("ActionResult.GetReason");
+ MarkNativeAsOptional("ActionResult.SetReason");
+ MarkNativeAsOptional("ActionResult.type.get");
+ MarkNativeAsOptional("ActionResult.type.set");
+ MarkNativeAsOptional("ActionResult.action.get");
+ MarkNativeAsOptional("ActionResult.action.set");
+ MarkNativeAsOptional("ActionDesiredResult.priority.get");
+ MarkNativeAsOptional("ActionDesiredResult.priority.set");
+ MarkNativeAsOptional("ActionsManager.Create");
+ MarkNativeAsOptional("ActionsManager.Allocate");
+ MarkNativeAsOptional("ActionsManager.Deallocate");
+ MarkNativeAsOptional("ActionsManager.Iterator");
+ MarkNativeAsOptional("ActionsManager.GetAction");
+ MarkNativeAsOptional("BehaviorAction.StorePendingEventResult");
+ MarkNativeAsOptional("BehaviorAction.GetName");
+ MarkNativeAsOptional("BehaviorAction.Parent.get");
+ MarkNativeAsOptional("BehaviorAction.Child.get");
+ MarkNativeAsOptional("BehaviorAction.Under.get");
+ MarkNativeAsOptional("BehaviorAction.Above.get");
+ MarkNativeAsOptional("BehaviorAction.Actor.get");
+ MarkNativeAsOptional("BehaviorAction.IsSuspended.get");
+ MarkNativeAsOptional("BehaviorAction.IsSuspended.set");
+ MarkNativeAsOptional("BehaviorAction.IsStarted.get");
+ MarkNativeAsOptional("BehaviorAction.IsStarted.set");
+ MarkNativeAsOptional("BehaviorAction.OnStart.set");
+ MarkNativeAsOptional("BehaviorAction.OnUpdate.set");
+ MarkNativeAsOptional("BehaviorAction.OnEnd.set");
+ MarkNativeAsOptional("BehaviorAction.OnSuspend.set");
+ MarkNativeAsOptional("BehaviorAction.OnResume.set");
+ MarkNativeAsOptional("BehaviorAction.OnInitialContainedAction.set");
+ MarkNativeAsOptional("BehaviorAction.OnLeaveGround.set");
+ MarkNativeAsOptional("BehaviorAction.OnLandOnGround.set");
+ MarkNativeAsOptional("BehaviorAction.OnContact.set");
+ MarkNativeAsOptional("BehaviorAction.OnMoveToSuccess.set");
+ MarkNativeAsOptional("BehaviorAction.OnMoveToFailure.set");
+ MarkNativeAsOptional("BehaviorAction.OnStuck.set");
+ MarkNativeAsOptional("BehaviorAction.OnUnStuck.set");
+ MarkNativeAsOptional("BehaviorAction.OnPostureChanged.set");
+ MarkNativeAsOptional("BehaviorAction.OnAnimationActivityComplete.set");
+ MarkNativeAsOptional("BehaviorAction.OnAnimationActivityInterrupted.set");
+ MarkNativeAsOptional("BehaviorAction.OnAnimationEvent.set");
+ MarkNativeAsOptional("BehaviorAction.OnIgnite.set");
+ MarkNativeAsOptional("BehaviorAction.OnInjured.set");
+ MarkNativeAsOptional("BehaviorAction.OnKilled.set");
+ MarkNativeAsOptional("BehaviorAction.OnOtherKilled.set");
+ MarkNativeAsOptional("BehaviorAction.OnSight.set");
+ MarkNativeAsOptional("BehaviorAction.OnLostSight.set");
+ MarkNativeAsOptional("BehaviorAction.OnThreatChanged.set");
+ MarkNativeAsOptional("BehaviorAction.OnSound.set");
+ MarkNativeAsOptional("BehaviorAction.OnSpokeConcept.set");
+ MarkNativeAsOptional("BehaviorAction.OnNavAreaChanged.set");
+ MarkNativeAsOptional("BehaviorAction.OnModelChanged.set");
+ MarkNativeAsOptional("BehaviorAction.OnPickUp.set");
+ MarkNativeAsOptional("BehaviorAction.OnShoved.set");
+ MarkNativeAsOptional("BehaviorAction.OnBlinded.set");
+ MarkNativeAsOptional("BehaviorAction.OnEnteredSpit.set");
+ MarkNativeAsOptional("BehaviorAction.OnHitByVomitJar.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandAttack.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandAssault.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandApproachV.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandApproachE.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandRetreat.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandPause.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandResume.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandString.set");
+ MarkNativeAsOptional("BehaviorAction.IsAbleToBlockMovementOf.set");
+ MarkNativeAsOptional("BehaviorAction.OnStartPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnUpdatePost.set");
+ MarkNativeAsOptional("BehaviorAction.OnEndPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnSuspendPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnResumePost.set");
+ MarkNativeAsOptional("BehaviorAction.OnInitialContainedActionPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnLeaveGroundPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnLandOnGroundPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnContactPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnMoveToSuccessPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnMoveToFailurePost.set");
+ MarkNativeAsOptional("BehaviorAction.OnStuckPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnUnStuckPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnPostureChangedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnAnimationActivityCompletePost.set");
+ MarkNativeAsOptional("BehaviorAction.OnAnimationActivityInterruptedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnAnimationEventPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnIgnitePost.set");
+ MarkNativeAsOptional("BehaviorAction.OnInjuredPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnKilledPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnOtherKilledPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnSightPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnLostSightPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnThreatChangedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnSoundPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnSpokeConceptPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnNavAreaChangedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnModelChangedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnPickUpPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnShovedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnBlindedPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnEnteredSpitPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnHitByVomitJarPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandAttackPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandAssaultPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandApproachVPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandApproachEPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandRetreatPost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandPausePost.set");
+ MarkNativeAsOptional("BehaviorAction.OnCommandResumePost.set");
+ MarkNativeAsOptional("BehaviorAction.IsAbleToBlockMovementOfPost.set");
+}
+#endif
\ No newline at end of file
diff --git a/scripting/include/activitymonitor.inc b/scripting/include/activitymonitor.inc
new file mode 100644
index 0000000..c58c76d
--- /dev/null
+++ b/scripting/include/activitymonitor.inc
@@ -0,0 +1,6 @@
+#if defined _activitymonitor_included_
+ #endinput
+#endif
+#define _activitymonitor_included_
+
+native bool AddLog(const char[] type, const char[] clientName, const char[] targetName, const char[] message);
\ No newline at end of file
diff --git a/scripting/include/colors.inc b/scripting/include/colors.inc
new file mode 100644
index 0000000..45fd1ef
--- /dev/null
+++ b/scripting/include/colors.inc
@@ -0,0 +1,446 @@
+/**************************************************************************
+ * *
+ * Colored Chat Functions *
+ * Author: exvel *
+ * Version: 1.0.5 *
+ * *
+ **************************************************************************/
+
+#if defined _colors_included
+ #endinput
+#endif
+#define _colors_included
+
+#define MAX_MESSAGE_LENGTH 250
+#define MAX_COLORS 6
+
+#define SERVER_INDEX 0
+#define NO_INDEX -1
+#define NO_PLAYER -2
+
+enum Colors
+{
+ Color_Default = 0,
+ Color_Green,
+ Color_Lightgreen,
+ Color_Red,
+ Color_Blue,
+ Color_Olive
+}
+
+/* Colors' properties */
+new String:CTag[][] = {"{default}", "{green}", "{lightgreen}", "{red}", "{blue}", "{olive}"};
+new String:CTagCode[][] = {"\x01", "\x04", "\x03", "\x03", "\x03", "\x05"};
+new bool:CTagReqSayText2[] = {false, false, true, true, true, false};
+new bool:CEventIsHooked = false;
+new bool:CSkipList[MAXPLAYERS+1] = {false,...};
+
+/* Game default profile */
+new bool:CProfile_Colors[] = {true, true, false, false, false, false};
+new CProfile_TeamIndex[] = {NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX};
+new bool:CProfile_SayText2 = false;
+
+/**
+ * Prints a message to a specific client in the chat area.
+ * Supports color tags.
+ *
+ * @param client Client index.
+ * @param szMessage Message (formatting rules).
+ * @return No return
+ *
+ * On error/Errors: If the client is not connected an error will be thrown.
+ */
+stock CPrintToChat(client, const String:szMessage[], any:...)
+{
+ if (client <= 0 || client > MaxClients)
+ ThrowError("Invalid client index %d", client);
+
+ if (!IsClientInGame(client))
+ ThrowError("Client %d is not in game", client);
+
+ decl String:szBuffer[MAX_MESSAGE_LENGTH];
+ decl String:szCMessage[MAX_MESSAGE_LENGTH];
+ SetGlobalTransTarget(client);
+ Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
+ VFormat(szCMessage, sizeof(szCMessage), szBuffer, 3);
+
+ new index = CFormat(szCMessage, sizeof(szCMessage));
+ if (index == NO_INDEX)
+ {
+ PrintToChat(client, szCMessage);
+ }
+ else
+ {
+ CSayText2(client, index, szCMessage);
+ }
+}
+
+/**
+ * Prints a message to all clients in the chat area.
+ * Supports color tags.
+ *
+ * @param client Client index.
+ * @param szMessage Message (formatting rules)
+ * @return No return
+ */
+stock CPrintToChatAll(const String:szMessage[], any:...)
+{
+ decl String:szBuffer[MAX_MESSAGE_LENGTH];
+
+ for (new i = 1; i <= MaxClients; i++)
+ {
+ if (IsClientInGame(i) && !IsFakeClient(i) && !CSkipList[i])
+ {
+ SetGlobalTransTarget(i);
+ VFormat(szBuffer, sizeof(szBuffer), szMessage, 2);
+ CPrintToChat(i, szBuffer);
+ }
+
+ CSkipList[i] = false;
+ }
+}
+
+/**
+ * Prints a message to a specific client in the chat area.
+ * Supports color tags and teamcolor tag.
+ *
+ * @param client Client index.
+ * @param author Author index whose color will be used for teamcolor tag.
+ * @param szMessage Message (formatting rules).
+ * @return No return
+ *
+ * On error/Errors: If the client or author are not connected an error will be thrown.
+ */
+stock CPrintToChatEx(client, author, const String:szMessage[], any:...)
+{
+ if (client <= 0 || client > MaxClients)
+ ThrowError("Invalid client index %d", client);
+
+ if (!IsClientInGame(client))
+ ThrowError("Client %d is not in game", client);
+
+ if (author < 0 || author > MaxClients)
+ ThrowError("Invalid client index %d", author);
+
+ decl String:szBuffer[MAX_MESSAGE_LENGTH];
+ decl String:szCMessage[MAX_MESSAGE_LENGTH];
+ SetGlobalTransTarget(client);
+ Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
+ VFormat(szCMessage, sizeof(szCMessage), szBuffer, 4);
+
+ new index = CFormat(szCMessage, sizeof(szCMessage), author);
+ if (index == NO_INDEX)
+ {
+ PrintToChat(client, szCMessage);
+ }
+ else
+ {
+ CSayText2(client, author, szCMessage);
+ }
+}
+
+/**
+ * Prints a message to all clients in the chat area.
+ * Supports color tags and teamcolor tag.
+ *
+ * @param author Author index whos color will be used for teamcolor tag.
+ * @param szMessage Message (formatting rules).
+ * @return No return
+ *
+ * On error/Errors: If the author is not connected an error will be thrown.
+ */
+stock CPrintToChatAllEx(author, const String:szMessage[], any:...)
+{
+ if (author < 0 || author > MaxClients)
+ ThrowError("Invalid client index %d", author);
+
+ if (!IsClientInGame(author))
+ ThrowError("Client %d is not in game", author);
+
+ decl String:szBuffer[MAX_MESSAGE_LENGTH];
+
+ for (new i = 1; i <= MaxClients; i++)
+ {
+ if (IsClientInGame(i) && !IsFakeClient(i) && !CSkipList[i])
+ {
+ SetGlobalTransTarget(i);
+ VFormat(szBuffer, sizeof(szBuffer), szMessage, 3);
+ CPrintToChatEx(i, author, szBuffer);
+ }
+
+ CSkipList[i] = false;
+ }
+}
+
+/**
+ * Removes color tags from the string.
+ *
+ * @param szMessage String.
+ * @return No return
+ */
+stock CRemoveTags(String:szMessage[], maxlength)
+{
+ for (new i = 0; i < MAX_COLORS; i++)
+ {
+ ReplaceString(szMessage, maxlength, CTag[i], "");
+ }
+
+ ReplaceString(szMessage, maxlength, "{teamcolor}", "");
+}
+
+/**
+ * This function should only be used right in front of
+ * CPrintToChatAll or CPrintToChatAllEx and it tells
+ * to those funcions to skip specified client when printing
+ * message to all clients. After message is printed client will
+ * no more be skipped.
+ *
+ * @param client Client index
+ * @return No return
+ */
+stock CSkipNextClient(client)
+{
+ if (client <= 0 || client > MaxClients)
+ ThrowError("Invalid client index %d", client);
+
+ CSkipList[client] = true;
+}
+
+/**
+ * Replaces color tags in a string with color codes
+ *
+ * @param szMessage String.
+ * @param maxlength Maximum length of the string buffer.
+ * @return Client index that can be used for SayText2 author index
+ *
+ * On error/Errors: If there is more then one team color is used an error will be thrown.
+ */
+stock CFormat(String:szMessage[], maxlength, author=NO_INDEX)
+{
+ /* Hook event for auto profile setup on map start */
+ if (!CEventIsHooked)
+ {
+ CSetupProfile();
+ HookEvent("server_spawn", CEvent_MapStart, EventHookMode_PostNoCopy);
+ CEventIsHooked = true;
+ }
+
+ new iRandomPlayer = NO_INDEX;
+
+ /* If author was specified replace {teamcolor} tag */
+ if (author != NO_INDEX)
+ {
+ if (CProfile_SayText2)
+ {
+ ReplaceString(szMessage, maxlength, "{teamcolor}", "\x03");
+ iRandomPlayer = author;
+ }
+ /* If saytext2 is not supported by game replace {teamcolor} with green tag */
+ else
+ {
+ ReplaceString(szMessage, maxlength, "{teamcolor}", CTagCode[Color_Green]);
+ }
+ }
+ else
+ {
+ ReplaceString(szMessage, maxlength, "{teamcolor}", "");
+ }
+
+ /* For other color tags we need a loop */
+ for (new i = 0; i < MAX_COLORS; i++)
+ {
+ /* If tag not found - skip */
+ if (StrContains(szMessage, CTag[i]) == -1)
+ {
+ continue;
+ }
+ /* If tag is not supported by game replace it with green tag */
+ else if (!CProfile_Colors[i])
+ {
+ ReplaceString(szMessage, maxlength, CTag[i], CTagCode[Color_Green]);
+ }
+ /* If tag doesn't need saytext2 simply replace */
+ else if (!CTagReqSayText2[i])
+ {
+ ReplaceString(szMessage, maxlength, CTag[i], CTagCode[i]);
+ }
+ /* Tag needs saytext2 */
+ else
+ {
+ /* If saytext2 is not supported by game replace tag with green tag */
+ if (!CProfile_SayText2)
+ {
+ ReplaceString(szMessage, maxlength, CTag[i], CTagCode[Color_Green]);
+ }
+ /* Game supports saytext2 */
+ else
+ {
+ /* If random player for tag wasn't specified replace tag and find player */
+ if (iRandomPlayer == NO_INDEX)
+ {
+ /* Searching for valid client for tag */
+ iRandomPlayer = CFindRandomPlayerByTeam(CProfile_TeamIndex[i]);
+
+ /* If player not found replace tag with green color tag */
+ if (iRandomPlayer == NO_PLAYER)
+ {
+ ReplaceString(szMessage, maxlength, CTag[i], CTagCode[Color_Green]);
+ }
+ /* If player was found simply replace */
+ else
+ {
+ ReplaceString(szMessage, maxlength, CTag[i], CTagCode[i]);
+ }
+
+ }
+ /* If found another team color tag throw error */
+ else
+ {
+ //ReplaceString(szMessage, maxlength, CTag[i], "");
+ ThrowError("Using two team colors in one message is not allowed");
+ }
+ }
+
+ }
+ }
+
+ return iRandomPlayer;
+}
+
+/**
+ * Founds a random player with specified team
+ *
+ * @param color_team Client team.
+ * @return Client index or NO_PLAYER if no player found
+ */
+stock CFindRandomPlayerByTeam(color_team)
+{
+ if (color_team == SERVER_INDEX)
+ {
+ return 0;
+ }
+ else
+ {
+ for (new i = 1; i <= MaxClients; i++)
+ {
+ if (IsClientInGame(i) && GetClientTeam(i) == color_team)
+ {
+ return i;
+ }
+ }
+ }
+
+ return NO_PLAYER;
+}
+
+/**
+ * Sends a SayText2 usermessage to a client
+ *
+ * @param szMessage Client index
+ * @param maxlength Author index
+ * @param szMessage Message
+ * @return No return.
+ */
+stock CSayText2(client, author, const String:szMessage[])
+{
+ new Handle:hBuffer = StartMessageOne("SayText2", client);
+ BfWriteByte(hBuffer, author);
+ BfWriteByte(hBuffer, true);
+ BfWriteString(hBuffer, szMessage);
+ EndMessage();
+}
+
+/**
+ * Creates game color profile
+ * This function must be edited if you want to add more games support
+ *
+ * @return No return.
+ */
+stock CSetupProfile()
+{
+ decl String:szGameName[30];
+ GetGameFolderName(szGameName, sizeof(szGameName));
+
+ if (StrEqual(szGameName, "cstrike", false))
+ {
+ CProfile_Colors[Color_Lightgreen] = true;
+ CProfile_Colors[Color_Red] = true;
+ CProfile_Colors[Color_Blue] = true;
+ CProfile_Colors[Color_Olive] = true;
+ CProfile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
+ CProfile_TeamIndex[Color_Red] = 2;
+ CProfile_TeamIndex[Color_Blue] = 3;
+ CProfile_SayText2 = true;
+ }
+ else if (StrEqual(szGameName, "tf", false))
+ {
+ CProfile_Colors[Color_Lightgreen] = true;
+ CProfile_Colors[Color_Red] = true;
+ CProfile_Colors[Color_Blue] = true;
+ CProfile_Colors[Color_Olive] = true;
+ CProfile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
+ CProfile_TeamIndex[Color_Red] = 2;
+ CProfile_TeamIndex[Color_Blue] = 3;
+ CProfile_SayText2 = true;
+ }
+ else if (StrEqual(szGameName, "left4dead", false) || StrEqual(szGameName, "left4dead2", false))
+ {
+ CProfile_Colors[Color_Lightgreen] = true;
+ CProfile_Colors[Color_Red] = true;
+ CProfile_Colors[Color_Blue] = true;
+ CProfile_Colors[Color_Olive] = true;
+ CProfile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
+ CProfile_TeamIndex[Color_Red] = 3;
+ CProfile_TeamIndex[Color_Blue] = 2;
+ CProfile_SayText2 = true;
+ }
+ else if (StrEqual(szGameName, "hl2mp", false))
+ {
+ /* hl2mp profile is based on mp_teamplay convar */
+ if (GetConVarBool(FindConVar("mp_teamplay")))
+ {
+ CProfile_Colors[Color_Red] = true;
+ CProfile_Colors[Color_Blue] = true;
+ CProfile_Colors[Color_Olive] = true;
+ CProfile_TeamIndex[Color_Red] = 3;
+ CProfile_TeamIndex[Color_Blue] = 2;
+ CProfile_SayText2 = true;
+ }
+ else
+ {
+ CProfile_SayText2 = false;
+ CProfile_Colors[Color_Olive] = true;
+ }
+ }
+ else if (StrEqual(szGameName, "dod", false))
+ {
+ CProfile_Colors[Color_Olive] = true;
+ CProfile_SayText2 = false;
+ }
+ /* Profile for other games */
+ else
+ {
+ if (GetUserMessageId("SayText2") == INVALID_MESSAGE_ID)
+ {
+ CProfile_SayText2 = false;
+ }
+ else
+ {
+ CProfile_Colors[Color_Red] = true;
+ CProfile_Colors[Color_Blue] = true;
+ CProfile_TeamIndex[Color_Red] = 2;
+ CProfile_TeamIndex[Color_Blue] = 3;
+ CProfile_SayText2 = true;
+ }
+ }
+}
+
+public Action:CEvent_MapStart(Handle:event, const String:name[], bool:dontBroadcast)
+{
+ CSetupProfile();
+
+ for (new i = 1; i <= MaxClients; i++)
+ {
+ CSkipList[i] = false;
+ }
+}
\ No newline at end of file
diff --git a/scripting/include/dhooks.inc b/scripting/include/dhooks.inc
new file mode 100644
index 0000000..448be8c
--- /dev/null
+++ b/scripting/include/dhooks.inc
@@ -0,0 +1,1015 @@
+#if defined _dhooks_included
+#endinput
+#endif
+#define _dhooks_included
+
+// Needed for the SDKFuncConfSource enum.
+#include
+
+#define INVALID_HOOK_ID -1
+
+enum ObjectValueType
+{
+ ObjectValueType_Int = 0,
+ ObjectValueType_Bool,
+ ObjectValueType_Ehandle,
+ ObjectValueType_Float,
+ ObjectValueType_CBaseEntityPtr,
+ ObjectValueType_IntPtr,
+ ObjectValueType_BoolPtr,
+ ObjectValueType_EhandlePtr,
+ ObjectValueType_FloatPtr,
+ ObjectValueType_Vector,
+ ObjectValueType_VectorPtr,
+ ObjectValueType_CharPtr,
+ ObjectValueType_String
+};
+
+enum ListenType
+{
+ ListenType_Created,
+ ListenType_Deleted
+};
+
+enum ReturnType
+{
+ ReturnType_Unknown,
+ ReturnType_Void,
+ ReturnType_Int,
+ ReturnType_Bool,
+ ReturnType_Float,
+ ReturnType_String, //Note this is a string_t
+ ReturnType_StringPtr, //Note this is a string_t *
+ ReturnType_CharPtr,
+ ReturnType_Vector,
+ ReturnType_VectorPtr,
+ ReturnType_CBaseEntity,
+ ReturnType_Edict
+};
+
+enum HookParamType
+{
+ HookParamType_Unknown,
+ HookParamType_Int,
+ HookParamType_Bool,
+ HookParamType_Float,
+ HookParamType_String, //Note this is a string_t
+ HookParamType_StringPtr, //Note this is a string_t *
+ HookParamType_CharPtr,
+ HookParamType_VectorPtr,
+ HookParamType_CBaseEntity,
+ HookParamType_ObjectPtr,
+ HookParamType_Edict,
+ HookParamType_Object
+};
+
+enum ThisPointerType
+{
+ ThisPointer_Ignore,
+ ThisPointer_CBaseEntity,
+ ThisPointer_Address
+};
+
+enum HookType
+{
+ HookType_Entity,
+ HookType_GameRules,
+ HookType_Raw
+};
+
+enum CallingConvention
+{
+ CallConv_CDECL,
+ CallConv_THISCALL,
+ CallConv_STDCALL,
+ CallConv_FASTCALL,
+};
+
+enum HookMode
+{
+ Hook_Pre, // Callback will be executed BEFORE the original function.
+ Hook_Post // Callback will be executed AFTER the original function.
+};
+
+enum MRESReturn
+{
+ MRES_ChangedHandled = -2, // Use changed values and return MRES_Handled
+ MRES_ChangedOverride, // Use changed values and return MRES_Override
+ MRES_Ignored, // plugin didn't take any action
+ MRES_Handled, // plugin did something, but real function should still be called
+ MRES_Override, // call real function, but use my return value
+ MRES_Supercede // skip real function; use my return value
+};
+
+enum DHookPassFlag
+{
+ DHookPass_ByVal = (1<<0), /**< Passing by value */
+ DHookPass_ByRef = (1<<1), /**< Passing by reference */
+ DHookPass_ODTOR = (1<<2), /**< Object has a destructor */
+ DHookPass_OCTOR = (1<<3), /**< Object has a constructor */
+ DHookPass_OASSIGNOP = (1<<4), /**< Object has an assignment operator */
+};
+
+enum DHookRegister
+{
+ // Don't change the register and use the default for the calling convention.
+ DHookRegister_Default,
+
+ // 8-bit general purpose registers
+ DHookRegister_AL,
+ DHookRegister_CL,
+ DHookRegister_DL,
+ DHookRegister_BL,
+ DHookRegister_AH,
+ DHookRegister_CH,
+ DHookRegister_DH,
+ DHookRegister_BH,
+
+ // 32-bit general purpose registers
+ DHookRegister_EAX,
+ DHookRegister_ECX,
+ DHookRegister_EDX,
+ DHookRegister_EBX,
+ DHookRegister_ESP,
+ DHookRegister_EBP,
+ DHookRegister_ESI,
+ DHookRegister_EDI,
+
+ // 128-bit XMM registers
+ DHookRegister_XMM0,
+ DHookRegister_XMM1,
+ DHookRegister_XMM2,
+ DHookRegister_XMM3,
+ DHookRegister_XMM4,
+ DHookRegister_XMM5,
+ DHookRegister_XMM6,
+ DHookRegister_XMM7,
+
+ // 80-bit FPU registers
+ DHookRegister_ST0
+};
+
+typeset ListenCB
+{
+ //Deleted
+ function void (int entity);
+
+ //Created
+ function void (int entity, const char[] classname);
+};
+
+typeset DHookRemovalCB
+{
+ function void (int hookid);
+};
+typeset DHookCallback
+{
+ //Function Example: void Ham::Test() with this pointer ignore
+ function MRESReturn ();
+
+ //Function Example: void Ham::Test() with this pointer passed
+ function MRESReturn (int pThis);
+
+ //Function Example: void Ham::Test(int cake) with this pointer ignore
+ function MRESReturn (DHookParam hParams);
+
+ //Function Example: void Ham::Test(int cake) with this pointer passed
+ function MRESReturn (int pThis, DHookParam hParams);
+
+ //Function Example: int Ham::Test() with this pointer ignore
+ function MRESReturn (DHookReturn hReturn);
+
+ //Function Example: int Ham::Test() with this pointer passed
+ function MRESReturn (int pThis, DHookReturn hReturn);
+
+ //Function Example: int Ham::Test(int cake) with this pointer ignore
+ function MRESReturn (DHookReturn hReturn, DHookParam hParams);
+
+ //Function Example: int Ham::Test(int cake) with this pointer passed
+ function MRESReturn (int pThis, DHookReturn hReturn, DHookParam hParams);
+
+ //Address NOW
+
+ //Function Example: void Ham::Test() with this pointer passed
+ function MRESReturn (Address pThis);
+
+ //Function Example: void Ham::Test(int cake) with this pointer passed
+ function MRESReturn (Address pThis, DHookParam hParams);
+
+ //Function Example: int Ham::Test() with this pointer passed
+ function MRESReturn (Address pThis, DHookReturn hReturn);
+
+ //Function Example: int Ham::Test(int cake) with this pointer passed
+ function MRESReturn (Address pThis, DHookReturn hReturn, DHookParam hParams);
+
+};
+
+// Represents the parameters of the hooked function.
+methodmap DHookParam < Handle
+{
+ // Get the value of a parameter.
+ // Use only for: int, entity, edict, bool or float parameter types.
+ //
+ // @param num Parameter number to get, starting at 1. Parameter number 0 returns
+ // the number of parameters.
+ //
+ // @return Value if num greater than 0. If 0 returns parameter count.
+ // If CBaseEntity returns entity index.
+ // @error Invalid handle, invalid param number or invalid param type.
+ public native any Get(int num);
+
+ // Get the value of a vector parameter.
+ // Use only for: vector or vectorptr parameter types.
+ //
+ // @param num Parameter number to get, starting at 1.
+ // @param vec Vector buffer to store result.
+ //
+ // @error Invalid handle, invalid param number or invalid param type.
+ public native void GetVector(int num, float vec[3]);
+
+ // Get the value of a string parameter.
+ // Use only for: string, stringptr or charptr parameter types.
+ //
+ // @param num Parameter number to get, starting at 1.
+ // @param buffer String buffer to store result.
+ // @param size Buffer size.
+ //
+ // @error Invalid handle, invalid param number or invalid param type.
+ public native void GetString(int num, char[] buffer, int size);
+
+ // Set the value of a parameter.
+ // Use only for: int, entity, edict, bool or float parameter types.
+ //
+ // The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
+ // is returned in the callback.
+ //
+ // @param num Parameter number to set starting at 1.
+ // @param value Value to set it as (only pass int, bool, float or entity index).
+ //
+ // @error Invalid handle, invalid param number or invalid param type.
+ public native void Set(int num, any value);
+
+ // Set the value of a vector parameter.
+ // Use only for: vector or vectorptr parameter types.
+ //
+ // The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
+ // is returned in the callback.
+ //
+ // @param num Parameter number to set, starting at 1.
+ // @param vec Value to set vector as.
+ //
+ // @error Invalid handle, invalid param number or invalid param type.
+ public native void SetVector(int num, const float vec[3]);
+
+ // Set the value of a string parameter.
+ // Use only for: string, stringptr or charptr parameter types.
+ //
+ // The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
+ // is returned in the callback.
+ //
+ // @param num Parameter number to set, starting at 1.
+ // @param value Value to set string as.
+ //
+ // @error Invalid handle, invalid param number or invalid param type.
+ public native void SetString(int num, const char[] value);
+
+ // Gets an object's variable value.
+ //
+ // @param num Parameter number to get, starting at 1.
+ // @param offset Byte offset within the object to the var to get.
+ // @param type Type of var it is.
+ //
+ // @return Value of the objects var. If EHANDLE type or entity returns entity index.
+ // @error Invalid handle, invalid param number, invalid param type or invalid Object type.
+ public native any GetObjectVar(int num, int offset, ObjectValueType type);
+
+ // Gets an object's vector variable value.
+ //
+ // @param num Parameter number to get, starting at 1.
+ // @param offset Byte offset within the object to the var to get.
+ // @param type Type of var it is.
+ // @param vec Buffer to store the result vector.
+ //
+ // @error Invalid handle, invalid param number, invalid param type or invalid Object type.
+ public native void GetObjectVarVector(int num, int offset, ObjectValueType type, float vec[3]);
+
+ // Gets an object's string variable value.
+ //
+ // @param num Parameter number to get, starting at 1.
+ // @param offset Byte offset within the object to the var to get.
+ // @param type Type of var it is.
+ // @param buffer Buffer to store the result string.
+ // @param size Size of the buffer.
+ //
+ // @error Invalid handle, invalid param number, invalid param type or invalid Object type.
+ public native void GetObjectVarString(int num, int offset, ObjectValueType type, char[] buffer, int size);
+
+ // Sets an object's variable value.
+ //
+ // The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
+ // is returned in the callback.
+ //
+ // @param num Parameter number to set, starting at 1.
+ // @param offset Byte offset within the object to the var to set.
+ // @param type Type of var it is.
+ // @param value The value to set the var to.
+ //
+ // @error Invalid handle, invalid param number, invalid param type or invalid Object type.
+ public native void SetObjectVar(int num, int offset, ObjectValueType type, any value);
+
+ // Sets an object's vector variable value.
+ //
+ // The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
+ // is returned in the callback.
+ //
+ // @param num Parameter number to set, starting at 1.
+ // @param offset Byte offset within the object to the var to set.
+ // @param type Type of var it is.
+ // @param vec The value to set the vector var to.
+ //
+ // @error Invalid handle, invalid param number, invalid param type or invalid Object type.
+ public native void SetObjectVarVector(int num, int offset, ObjectValueType type, const float vec[3]);
+
+ // No setter for object strings yet. Open an issue if you really need it.
+
+ // Checks if a pointer parameter is null.
+ //
+ // @param num Parameter number to check, starting at 1.
+ //
+ // @return True if null, false otherwise.
+ // @error Non-pointer parameter.
+ public native bool IsNull(int num);
+};
+
+
+// Represents the return value of the hooked function.
+methodmap DHookReturn < Handle
+{
+ // Retrieves or sets the return value.
+ // Use only for: int, entity, edict, bool or float return types.
+ //
+ // The return value is only readable in a post hook.
+ // The value is only applied when MRES_Override or MRES_Supercede is returned
+ // in the callback.
+ property any Value {
+ public native get();
+ public native set(any value);
+ }
+
+ // Get return vector value.
+ // Use only for: vector or vectorptr return types.
+ //
+ // Only useful in post hooks.
+ //
+ // @param vec Vector buffer to store result in.
+ //
+ // @error Invalid Handle or invalid type.
+ public native void GetVector(float vec[3]);
+
+ // Get return string value.
+ // Use only for: string, stringptr or charptr return types.
+ //
+ // Only useful in post hooks.
+ //
+ // @param buffer String buffer to store result in.
+ // @param size String buffer size.
+ //
+ // @error Invalid Handle or invalid type.
+ public native void GetString(char[] buffer, int size);
+
+ // Set return vector value.
+ // Use only for: vector or vectorptr return types.
+ //
+ // The value is only applied when MRES_Override or MRES_Supercede is returned
+ // in the callback.
+ //
+ // @param vec Value to set return vector to.
+ //
+ // @error Invalid Handle or invalid type.
+ public native void SetVector(const float vec[3]);
+
+ // Set return string value.
+ // Use only for: string, stringptr or charptr return types.
+ //
+ // The value is only applied when MRES_Override or MRES_Supercede is returned
+ // in the callback.
+ //
+ // @param buffer Value to set return string to.
+ //
+ // @error Invalid Handle or invalid type.
+ public native void SetString(const char[] buffer);
+};
+
+// Base method map for common functions between virtual hooks and detours.
+methodmap DHookSetup < Handle
+{
+ // Load address or offset for a vtable hook or detour from a gamedata file.
+ //
+ // @param gameconf GameData handle.
+ // @param source Whether to look in Offsets, Signatures, or Addresses.
+ // @param name Name of the property to find.
+ //
+ // @return True on success, false if nothing was found.
+ // @error Invalid setup or gamedata handle.
+ public native bool SetFromConf(GameData gameconf, SDKFuncConfSource source, const char[] name);
+
+ // Adds a parameter to a hook setup.
+ //
+ // @param type Parameter type.
+ // @param size Used for Objects (not Object ptr) to define the size of the object.
+ // @param flag Used to change the pass type (ignored by detours).
+ // @param custom_register The register this argument is passed in instead of the stack (ignored by vhooks).
+ //
+ // @error Invalid setup handle or too many params added (request upping the max in thread).
+ public native void AddParam(HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default);
+};
+
+// A DynamicHook allows to hook a virtual function on any C++ object.
+// Currently CBaseEntity and CGameRules have a convenience API for easy entity hooking,
+// but it's possible to provide a raw this-pointer to hook any object in memory too.
+//
+// Internally this intercepts function calls by replacing the function pointer
+// in the virtual table of the object with our own function.
+methodmap DynamicHook < DHookSetup
+{
+ // Creates a vtable hook.
+ //
+ // @param offset Virtual table offset of function to hook.
+ // @param hooktype Type of hook.
+ // @param returntype Type of return value.
+ // @param thistype Type of this pointer or ignore (ignore can be used if not needed).
+ //
+ // @error Failed to create hook setup handle or invalid callback function.
+ public native DynamicHook(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype);
+
+ // Setup a vtable hook for a function as described in a "Functions" section in gamedata.
+ // The "Functions" section is parsed once the gamedata file is loaded and cached globally.
+ //
+ // @param gameconf GameData handle to use for address lookup.
+ // Doesn't have to be the same as the one with the "Functions" section.
+ // @param name Name of the function in a "Functions" section to load.
+ //
+ // @return Setup handle for the detour or null if offset wasn't found.
+ // @error Failed to create detour setup handle, invalid gamedata handle,
+ // invalid callback function or failed to find function in cached "Functions" sections.
+ public static native DynamicHook FromConf(GameData gameconf, const char[] name);
+
+ // Hook an entity.
+ //
+ // Entity hooks are auto-removed when the entity is destroyed.
+ // If you need to read the return value of the function, choose a post hook.
+ //
+ // @param mode The desired hook mode - pre or post.
+ // A pre hook calls your callback BEFORE the original function is called.
+ // You can access the parameters, set the return value, and skip the original function.
+ // A post hook calls your callback AFTER the original function executed.
+ // You can access the parameters and get/set the return value.
+ // @param entity Entity index to hook on.
+ // @param callback Callback function.
+ // @param removalcb Optional callback for when the hook is removed.
+ //
+ // @return A hookid on success, INVALID_HOOK_ID otherwise.
+ // @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
+ public native int HookEntity(HookMode mode, int entity, DHookCallback callback, DHookRemovalCB removalcb=INVALID_FUNCTION);
+
+ // Hook gamerules object.
+ //
+ // Game rules hooks are auto-removed on map end.
+ // If you need to read the return value of the function, choose a post hook.
+ //
+ // @param mode The desired hook mode - pre or post.
+ // A pre hook calls your callback BEFORE the original function is called.
+ // You can access the parameters, set the return value, and skip the original function.
+ // A post hook calls your callback AFTER the original function executed.
+ // You can access the parameters and get/set the return value.
+ // @param callback Callback function.
+ // @param removalcb Optional callback for when the hook is removed.
+ //
+ // @return A hookid on success, INVALID_HOOK_ID otherwise.
+ // @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
+ public native int HookGamerules(HookMode mode, DHookCallback callback, DHookRemovalCB removalcb=INVALID_FUNCTION);
+
+ // Hook a raw this-pointer.
+ // If you need to read the return value of the function, choose a post hook.
+ //
+ // @param mode The desired hook mode - pre or post.
+ // A pre hook calls your callback BEFORE the original function is called.
+ // You can access the parameters, set the return value, and skip the original function.
+ // A post hook calls your callback AFTER the original function executed.
+ // You can access the parameters and get/set the return value.
+ // @param addr This pointer address.
+ // @param callback Callback function.
+ //
+ // @return A hookid on success, INVALID_HOOK_ID otherwise.
+ // @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
+ public native int HookRaw(HookMode mode, Address addr, DHookCallback callback);
+
+ // Remove hook by hook id:
+ // This will NOT fire the removal callback!
+ //
+ // @param hookid Hook id to remove.
+ //
+ // @return True on success, false otherwise
+ public static native bool RemoveHook(int hookid);
+};
+
+// A DynamicDetour is a way to hook and block any function in memory.
+// Given the address of a function, it can call a callback in your script whenever
+// the function gets called. The callback has access to all parameters of the function
+// as well as the return value.
+//
+// Internally this works by replacing the first instructions of the function
+// with a jump to our own code. This means that the signature used to find
+// the function address in the first place might not match anymore after a detour.
+// If you need to detour the same function in different plugins make sure to
+// wildcard \x2a the first 6 bytes of the signature to accommodate for the patched
+// jump introduced by the detour.
+methodmap DynamicDetour < DHookSetup
+{
+ // Creates a detour.
+ //
+ // @param funcaddr The address of the function to detour.
+ // Can be Address_Null if you want to load the address from gamedata using DHookSetFromConf.
+ // @param callConv Calling convention of the function.
+ // @param returnType Type of the return value.
+ // @param thisType Type of this pointer or ignore (ignore can be used if not needed).
+ // Only used for thiscall detours.
+ //
+ // @error Failed to create detour setup handle.
+ public native DynamicDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thisType=ThisPointer_Ignore);
+
+ // Setup a detour for a function as described in a "Functions" section in gamedata.
+ // The "Functions" section is parsed once the gamedata file is loaded and cached globally.
+ //
+ // @param gameconf GameData handle to use for address lookup.
+ // Doesn't have to be the same as the one with the "Functions" section.
+ // @param name Name of the function in a "Functions" section to load.
+ //
+ // @return Setup handle for the detour or null if offset wasn't found.
+ // @error Failed to create detour setup handle, invalid gamedata handle,
+ // invalid callback function or failed to find function in cached "Functions" sections.
+ public static native DynamicDetour FromConf(GameData gameconf, const char[] name);
+
+ // Enable the detour of the function described in this detour setup.
+ // If you need to read the return value of the function, choose a post hook.
+ //
+ // @param mode The desired hook mode - pre or post.
+ // A pre hook calls your callback BEFORE the original function is called.
+ // You can access the parameters, set the return value, and skip the original function.
+ // A post hook calls your callback AFTER the original function executed.
+ // You can access the parameters and get/set the return value.
+ // @param callback Callback function.
+ //
+ // @return True if detour was enabled, false otherwise.
+ // @error Hook handle is not setup for a detour.
+ public native bool Enable(HookMode mode, DHookCallback callback);
+
+ // Disable the detour of the function described in this detour setup.
+ //
+ // @param mode The hook mode to disable - pre or post.
+ // @param callback Callback function.
+ //
+ // @return True if detour was disabled, false otherwise.
+ // @error Hook handle is not setup for a detour or function is not detoured.
+ public native bool Disable(HookMode mode, DHookCallback callback);
+};
+
+/* Adds an entity listener hook
+ *
+ * @param type Type of listener to add
+ * @param callback Callback to use
+ *
+ * @noreturn
+*/
+native void DHookAddEntityListener(ListenType type, ListenCB callback);
+
+/* Removes an entity listener hook
+ *
+ * @param type Type of listener to remove
+ * @param callback Callback this listener was using
+ *
+ * @return True if one was removed false otherwise.
+*/
+native bool DHookRemoveEntityListener(ListenType type, ListenCB callback);
+
+/* Creates a hook
+ *
+ * @param offset vtable offset of function to hook
+ * @param hooktype Type of hook
+ * @param returntype Type of return value
+ * @param thistype Type of this pointer or ignore (ignore can be used if not needed)
+ * @param callback Optional callback function, if not set here must be set when hooking.
+ *
+ * @return Returns setup handle for the hook.
+ * @error Failed to create hook setup handle or invalid callback function.
+*/
+native DynamicHook DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback=INVALID_FUNCTION);
+
+/**
+ * Creates a detour
+ *
+ * @param funcaddr The address of the function to detour.
+ * Can be Address_Null if you want to load the address from gamedata using DHookSetFromConf.
+ * @param callConv Calling convention of the function.
+ * @param returnType Type of the return value.
+ * @param thisType Type of this pointer or ignore (ignore can be used if not needed)
+ *
+ * @return Setup handle for the detour.
+ * @error Failed to create detour setup handle.
+ */
+native DynamicDetour DHookCreateDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thisType);
+
+/**
+ * Setup a detour or hook for a function as described in a "Functions" section in gamedata.
+ *
+ * @param gameconf GameConfig handle
+ * @param name Name of the function in the gamedata to load.
+ *
+ * @return Setup handle for the detour or INVALID_HANDLE if offset/signature/address wasn't found.
+ * @error Failed to create detour setup handle, invalid gamedata handle, invalid callback function or failed to find function in gamedata.
+ */
+native DHookSetup DHookCreateFromConf(Handle gameconf, const char[] name);
+
+/**
+ * Load details for a vhook or detour from a gamedata file.
+ *
+ * @param setup Hook setup handle to set the offset or address on.
+ * @param gameconf GameConfig handle
+ * @param source Whether to look in Offsets or Signatures.
+ * @param name Name of the property to find.
+ *
+ * @return True on success, false if nothing was found.
+ * @error Invalid setup or gamedata handle.
+ */
+native bool DHookSetFromConf(Handle setup, Handle gameconf, SDKFuncConfSource source, const char[] name);
+
+/**
+ * Enable the detour of the function described in the hook setup handle.
+ *
+ * @param setup Hook setup handle
+ * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
+ * @param callback Callback function
+ *
+ * @return True if detour was enabled, false otherwise.
+ * @error Hook handle is not setup for a detour.
+ */
+native bool DHookEnableDetour(Handle setup, bool post, DHookCallback callback);
+
+/**
+ * Disable the detour of the function described in the hook setup handle.
+ *
+ * @param setup Hook setup handle
+ * @param post True to disable a post hook.
+ * @param callback Callback function
+ *
+ * @return True if detour was disabled, false otherwise.
+ * @error Hook handle is not setup for a detour or function is not detoured.
+ */
+native bool DHookDisableDetour(Handle setup, bool post, DHookCallback callback);
+
+/* Adds param to a hook setup
+ *
+ * @param setup Setup handle to add the param to.
+ * @param type Param type
+ * @param size Used for Objects (not Object ptr) to define the size of the object.
+ * @param flag Used to change the pass type.
+ * @param custom_register The register this argument is passed in instead of the stack.
+ *
+ * @error Invalid setup handle or too many params added (request upping the max in thread)
+ * @noreturn
+*/
+native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default);
+
+/* Hook entity
+ *
+ * @param setup Setup handle to use to add the hook.
+ * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
+ * @param entity Entity index to hook on.
+ * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback)
+ * @param callback Optional callback function, if not set here must be set when creating the hook.
+ *
+ * @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
+ * @return INVALID_HOOK_ID on fail a hookid on success
+*/
+native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
+
+/* Hook gamerules
+ *
+ * @param setup Setup handle to use to add the hook.
+ * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
+ * @param removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback)
+ * @param callback Optional callback function, if not set here must be set when creating the hook.
+ *
+ * @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
+ * @return INVALID_HOOK_ID on fail a hookid on success
+*/
+native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
+
+/* Hook a raw pointer
+ *
+ * @param setup Setup handle to use to add the hook.
+ * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
+ * @param addr This pointer address.
+ * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback)
+ * @param callback Optional callback function, if not set here must be set when creating the hook.
+ *
+ * @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
+ * @return INVALID_HOOK_ID on fail a hookid on success
+*/
+native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
+
+/* Remove hook by hook id
+ *
+ * @param hookid Hook id to remove
+ *
+ * @return true on success false otherwise
+ * @note This will not fire the removal callback!
+*/
+native bool DHookRemoveHookID(int hookid);
+
+/* Get param value (Use only for: int, entity, bool or float param types)
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored)
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type.
+ * @return value if num greater than 0. If 0 returns paramcount.
+*/
+native any DHookGetParam(Handle hParams, int num);
+
+/* Get vector param value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.)
+ * @param vec Vector buffer to store result.
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type.
+ * @noreturn
+*/
+native void DHookGetParamVector(Handle hParams, int num, float vec[3]);
+
+/* Get string param value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.)
+ * @param buffer String buffer to store result
+ * @param size Buffer size
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type.
+ * @noreturn
+*/
+native void DHookGetParamString(Handle hParams, int num, char[] buffer, int size);
+
+/* Set param value (Use only for: int, entity, bool or float param types)
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.)
+ * @param value Value to set it as (only pass int, bool, float or entity index)
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type.
+ * @noreturn
+*/
+native void DHookSetParam(Handle hParams, int num, any value);
+
+/* Set vector param value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.)
+ * @param vec Value to set vector as.
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type.
+ * @noreturn
+*/
+native void DHookSetParamVector(Handle hParams, int num, float vec[3]);
+
+/* Set string param value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.)
+ * @param value Value to set string as.
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type.
+ * @noreturn
+*/
+native void DHookSetParamString(Handle hParams, int num, char[] value);
+
+/* Get return value (Use only for: int, entity, bool or float return types)
+ *
+ * @param hReturn Handle to return structure
+ *
+ * @error Invalid Handle, invalid type.
+ * @return Returns default value if prehook returns actual value if post hook.
+*/
+native any DHookGetReturn(Handle hReturn);
+
+/* Get return vector value
+ *
+ * @param hReturn Handle to return structure
+ * @param vec Vector buffer to store result in. (In pre hooks will be default value (0.0,0.0,0.0))
+ *
+ * @error Invalid Handle, invalid type.
+ * @noreturn
+*/
+native void DHookGetReturnVector(Handle hReturn, float vec[3]);
+
+/* Get return string value
+ *
+ * @param hReturn Handle to return structure
+ * @param buffer String buffer to store result in. (In pre hooks will be default value "")
+ * @param size String buffer size
+ *
+ * @error Invalid Handle, invalid type.
+ * @noreturn
+*/
+native void DHookGetReturnString(Handle hReturn, char[] buffer, int size);
+
+/* Set return value (Use only for: int, entity, bool or float return types)
+ *
+ * @param hReturn Handle to return structure
+ * @param value Value to set return as
+ *
+ * @error Invalid Handle, invalid type.
+ * @noreturn
+*/
+native void DHookSetReturn(Handle hReturn, any value);
+
+/* Set return vector value
+ *
+ * @param hReturn Handle to return structure
+ * @param vec Value to set return vector as
+ *
+ * @error Invalid Handle, invalid type.
+ * @noreturn
+*/
+native void DHookSetReturnVector(Handle hReturn, float vec[3]);
+
+/* Set return string value
+ *
+ * @param hReturn Handle to return structure
+ * @param value Value to set return string as
+ *
+ * @error Invalid Handle, invalid type.
+ * @noreturn
+*/
+native void DHookSetReturnString(Handle hReturn, char[] value);
+
+//WE SHOULD WRAP THESE AROUND STOCKS FOR NON PTR AS WE SUPPORT BOTH WITH THESE NATIVE'S
+
+/* Gets an objects variable value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to get.
+ * @param offset Offset within the object to the var to get.
+ * @param type Type of var it is
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
+ * @return Value of the objects var. If EHANDLE type or entity returns entity index.
+*/
+native any DHookGetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type);
+
+/* Sets an objects variable value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to set.
+ * @param offset Offset within the object to the var to set.
+ * @param type Type of var it is
+ * @param value The value to set the var to.
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
+ * @noreturn
+*/
+native void DHookSetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type, any value);
+
+/* Gets an objects vector variable value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to get.
+ * @param offset Offset within the object to the var to get.
+ * @param type Type of var it is
+ * @param buffer Buffer to store the result vector
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
+ * @noreturn
+*/
+native void DHookGetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float buffer[3]);
+
+/* Sets an objects vector variable value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to set.
+ * @param offset Offset within the object to the var to set.
+ * @param type Type of var it is
+ * @param value The value to set the vector var to.
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
+ * @noreturn
+*/
+native void DHookSetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float value[3]);
+
+/* Gets an objects string variable value
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to get.
+ * @param offset Offset within the object to the var to get.
+ * @param type Type of var it is
+ * @param buffer Buffer to store the result vector
+ * @param size Size of the buffer
+ *
+ * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
+ * @noreturn
+*/
+native void DHookGetParamObjectPtrString(Handle hParams, int num, int offset, ObjectValueType type, char[] buffer, int size);
+
+/* Checks if a pointer param is null
+ *
+ * @param hParams Handle to params structure
+ * @param num Param number to check.
+ *
+ * @error Non pointer param
+ * @return True if null false otherwise.
+*/
+native bool DHookIsNullParam(Handle hParams, int num);
+
+public Extension __ext_dhooks =
+{
+ name = "dhooks",
+ file = "dhooks.ext",
+#if defined AUTOLOAD_EXTENSIONS
+ autoload = 1,
+#else
+ autoload = 0,
+#endif
+#if defined REQUIRE_EXTENSIONS
+ required = 1,
+#else
+ required = 0,
+#endif
+};
+
+#if !defined REQUIRE_EXTENSIONS
+public __ext_dhooks_SetNTVOptional()
+{
+ MarkNativeAsOptional("DHookAddEntityListener");
+ MarkNativeAsOptional("DHookRemoveEntityListener");
+ MarkNativeAsOptional("DHookCreate");
+ MarkNativeAsOptional("DHookCreateDetour");
+ MarkNativeAsOptional("DHookCreateFromConf");
+ MarkNativeAsOptional("DHookSetFromConf");
+ MarkNativeAsOptional("DHookEnableDetour");
+ MarkNativeAsOptional("DHookDisableDetour");
+ MarkNativeAsOptional("DHookAddParam");
+ MarkNativeAsOptional("DHookEntity");
+ MarkNativeAsOptional("DHookGamerules");
+ MarkNativeAsOptional("DHookRaw");
+ MarkNativeAsOptional("DHookRemoveHookID");
+ MarkNativeAsOptional("DHookGetParam");
+ MarkNativeAsOptional("DHookGetParamVector");
+ MarkNativeAsOptional("DHookGetParamString");
+ MarkNativeAsOptional("DHookSetParam");
+ MarkNativeAsOptional("DHookSetParamVector");
+ MarkNativeAsOptional("DHookSetParamString");
+ MarkNativeAsOptional("DHookGetReturn");
+ MarkNativeAsOptional("DHookGetReturnVector");
+ MarkNativeAsOptional("DHookGetReturnString");
+ MarkNativeAsOptional("DHookSetReturn");
+ MarkNativeAsOptional("DHookSetReturnVector");
+ MarkNativeAsOptional("DHookSetReturnString");
+ MarkNativeAsOptional("DHookGetParamObjectPtrVar");
+ MarkNativeAsOptional("DHookSetParamObjectPtrVar");
+ MarkNativeAsOptional("DHookGetParamObjectPtrVarVector");
+ MarkNativeAsOptional("DHookSetParamObjectPtrVarVector");
+ MarkNativeAsOptional("DHookIsNullParam");
+ MarkNativeAsOptional("DHookGetParamObjectPtrString");
+
+ MarkNativeAsOptional("DHookParam.IsNull");
+ MarkNativeAsOptional("DHookParam.Get");
+ MarkNativeAsOptional("DHookParam.GetVector");
+ MarkNativeAsOptional("DHookParam.GetString");
+ MarkNativeAsOptional("DHookParam.Set");
+ MarkNativeAsOptional("DHookParam.SetVector");
+ MarkNativeAsOptional("DHookParam.SetString");
+ MarkNativeAsOptional("DHookParam.GetObjectVar");
+ MarkNativeAsOptional("DHookParam.GetObjectVarVector");
+ MarkNativeAsOptional("DHookParam.GetObjectVarString");
+ MarkNativeAsOptional("DHookParam.SetObjectVar");
+ MarkNativeAsOptional("DHookParam.SetObjectVarVector");
+ MarkNativeAsOptional("DHookReturn.Value.get");
+ MarkNativeAsOptional("DHookReturn.Value.set");
+ MarkNativeAsOptional("DHookReturn.GetVector");
+ MarkNativeAsOptional("DHookReturn.GetString");
+ MarkNativeAsOptional("DHookReturn.SetVector");
+ MarkNativeAsOptional("DHookReturn.SetString");
+ MarkNativeAsOptional("DHookSetup.SetFromConf");
+ MarkNativeAsOptional("DHookSetup.AddParam");
+ MarkNativeAsOptional("DynamicHook.DynamicHook");
+ MarkNativeAsOptional("DynamicHook.FromConf");
+ MarkNativeAsOptional("DynamicHook.HookEntity");
+ MarkNativeAsOptional("DynamicHook.HookGamerules");
+ MarkNativeAsOptional("DynamicHook.HookRaw");
+ MarkNativeAsOptional("DynamicHook.RemoveHook");
+ MarkNativeAsOptional("DynamicDetour.DynamicDetour");
+ MarkNativeAsOptional("DynamicDetour.FromConf");
+ MarkNativeAsOptional("DynamicDetour.Enable");
+ MarkNativeAsOptional("DynamicDetour.Disable");
+}
+#endif
\ No newline at end of file
diff --git a/scripting/include/epi/director.sp b/scripting/include/epi/director.sp
new file mode 100644
index 0000000..99b22b0
--- /dev/null
+++ b/scripting/include/epi/director.sp
@@ -0,0 +1,521 @@
+// SETTINGS
+// TODO: make cvars
+#define DIRECTOR_TIMER_INTERVAL 3.0
+#define DIRECTOR_WITCH_MIN_TIME 120 // The minimum amount of time to pass since last witch spawn for the next extra witch to spawn
+#define DIRECTOR_WITCH_CHECK_TIME 30.0 // How often to check if a witch should be spawned
+#define DIRECTOR_WITCH_MAX_WITCHES 5 // The maximum amount of extra witches to spawn
+#define DIRECTOR_WITCH_ROLLS 3 // The number of dice rolls, increase if you want to increase freq
+#define DIRECTOR_MIN_SPAWN_TIME 13.0 // Possibly randomized, per-special
+#define DIRECTOR_SPAWN_CHANCE 0.04 // The raw chance of a spawn
+#define DIRECTOR_CHANGE_LIMIT_CHANCE 0.05 // The chance that the maximum amount per-special is changed
+#define DIRECTOR_SPECIAL_TANK_CHANCE 0.05 // The chance that specials can spawn when a tank is active
+#define DIRECTOR_STRESS_CUTOFF 0.75 // The minimum chance a random cut off stress value is chosen [this, 1.0]
+#define DIRECTOR_REST_CHANCE 0.04 // The chance the director ceases spawning
+#define DIRECTOR_REST_MAX_COUNT 8 // The maximum amount of rest given (this * DIRECTOR_TIMER_INTERVAL)
+
+#define DIRECTOR_DEBUG_SPAWN 1 // Dont actually spawn
+
+/// DEFINITIONS
+#define NUM_SPECIALS 6
+#define TOTAL_NUM_SPECIALS 8
+char SPECIAL_IDS[TOTAL_NUM_SPECIALS][] = {
+ "smoker",
+ "boomer",
+ "hunter",
+ "spitter",
+ "jockey",
+ "charger",
+ "witch",
+ "tank"
+};
+enum specialType {
+ Special_Smoker = 0,
+ Special_Boomer = 1,
+ Special_Hunter = 2,
+ Special_Spitter = 3,
+ Special_Jockey = 4,
+ Special_Charger = 5,
+ Special_Witch = 6,
+ Special_Tank = 7,
+};
+enum directorState {
+ DState_Normal,
+ DState_NoPlayersOrNotCoop,
+ DState_PendingMinFlowOrDisabled,
+ DState_MaxSpecialTime,
+ DState_PlayerChance,
+ DState_Resting,
+ DState_TankInPlay,
+ DState_HighStress,
+ DState_MaxDirectorSpecials,
+}
+char DIRECTOR_STATE[9][] = {
+ "normal",
+ "no players / not coop",
+ "pending minflow OR disabled",
+ "max special in window",
+ "player scaled chance",
+ "rest period",
+ "tank in play",
+ "high stress",
+ "director MaxSpecials"
+};
+static directorState g_lastState;
+
+static float g_highestFlowAchieved;
+static float g_lastSpawnTime[TOTAL_NUM_SPECIALS];
+static float g_lastSpecialSpawnTime; // for any special
+static int g_spawnLimit[TOTAL_NUM_SPECIALS];
+static int g_spawnCount[TOTAL_NUM_SPECIALS];
+static int gd_maxSpecials;
+static float g_minFlowSpawn; // The minimum flow for specials to start spawning (waiting for players to leave saferom)
+static float g_maxStressIntensity; // The max stress that specials arent allowed to spawn
+
+int g_extraWitchCount;
+static int g_infectedCount;
+int g_restCount;
+static Handle witchSpawnTimer = null;
+
+float g_extraWitchFlowPositions[DIRECTOR_WITCH_MAX_WITCHES] = {};
+
+/// EVENTS
+
+void Director_OnMapStart() {
+ // Only spawn witches if enabled, and not loate loaded
+ if(!g_isLateLoaded && cvEPISpecialSpawning.IntValue & 2 && IsEPIActive()) {
+ InitExtraWitches();
+ }
+ float time = GetGameTime();
+ for(int i = 0; i < TOTAL_NUM_SPECIALS; i++) {
+ g_lastSpawnTime[i] = time;
+ g_spawnLimit[i] = 1;
+ g_spawnCount[i] = 0;
+ }
+ g_highestFlowAchieved = 0.0;
+ g_lastSpecialSpawnTime = time;
+ g_infectedCount = 0;
+ g_restCount = 0;
+ Director_RandomizeThings();
+}
+
+void Director_OnMapEnd() {
+ for(int i = 0; i < DIRECTOR_WITCH_MAX_WITCHES; i++) {
+ g_extraWitchFlowPositions[i] = 0.0;
+ }
+ delete witchSpawnTimer;
+}
+
+void Cvar_SpecialSpawningChange(ConVar convar, const char[] oldValue, const char[] newValue) {
+ if(convar.IntValue & 2) {
+ if(witchSpawnTimer == null)
+ witchSpawnTimer = CreateTimer(DIRECTOR_WITCH_CHECK_TIME, Timer_DirectorWitch, _, TIMER_REPEAT);
+ } else {
+ delete witchSpawnTimer;
+ }
+}
+
+void Event_WitchSpawn(Event event, const char[] name, bool dontBroadcast) {
+ g_spawnCount[Special_Witch]++;
+}
+void Director_OnClientPutInServer(int client) {
+ // Wait a frame for the bot to be assigned a team
+ RequestFrame(Director_CheckClient, client);
+}
+void Director_CheckClient(int client) {
+ if(IsClientConnected(client) && GetClientTeam(client) == 3) {
+ // To bypass director limits many plugins spawn an infected "bot" that immediately gets kicked, which allows a window to spawn a special
+ // The fake bot's class is usually 9, an invalid
+ int class = GetEntProp(client, Prop_Send, "m_zombieClass") - 1;
+ if(class > view_as(Special_Tank)) {
+ return;
+ } else if(IsFakeClient(client)) {
+ // Sometimes the bot class is _not_ invalid, but usually has BOT in its name. Ignore those players.
+ char name[32];
+ GetClientName(client, name, sizeof(name));
+ if(StrContains(name, "bot", false) != -1) {
+ return;
+ }
+ }
+
+ if(IsFakeClient(client) && class == view_as(Special_Tank)) {
+ OnTankBotSpawn(client);
+ }
+
+ g_spawnCount[class]++;
+ float time = GetGameTime();
+ g_lastSpawnTime[class] = time;
+ g_lastSpecialSpawnTime = time;
+ g_infectedCount++;
+
+ }
+}
+
+static int g_newTankHealth = 0;
+void OnTankBotSpawn(int client) {
+ if(!IsEPIActive() || !(cvEPISpecialSpawning.IntValue & 4)) return;
+ // Check if any finale is active
+ if(g_newTankHealth > 0) {
+ // A split tank has spawned, set its health
+ PrintDebug(DEBUG_SPAWNLOGIC, "OnTankBotSpawn: split tank spawned, setting health to %d", g_newTankHealth);
+ SetEntProp(client, Prop_Send, "m_iHealth", g_newTankHealth);
+ g_newTankHealth = 0;
+ return;
+ } else if(g_realSurvivorCount >= hExtraTankThreshold.IntValue && g_extraFinaleTankEnabled && hExtraFinaleTank.IntValue > 1) {
+ // If we have hExtraTankThreshold or more and finale tanks enabled, spawn finale tanks:
+ if(g_finaleStage == Stage_Active) {
+ // 1st tank spawned
+ PrintDebug(DEBUG_SPAWNLOGIC, "OnTankBotSpawn: [FINALE] 1st tank spawned");
+ int health = CalculateExtraTankHealth(client);
+ SetEntProp(client, Prop_Send, "m_iHealth", health);
+ g_finaleStage = Stage_FirstTankSpawned;
+ return;
+ } else if(g_realSurvivorCount < 6 && g_finaleStage == Stage_FirstTankSpawned) {
+ // 2nd tank spawned
+ PrintDebug(DEBUG_SPAWNLOGIC, "OnTankBotSpawn: [FINALE] 2nd tank spawned");
+ float duration = GetRandomFloat(EXTRA_TANK_MIN_SEC, EXTRA_TANK_MAX_SEC);
+ // Pass it 0, which doesnt make it a split tank, has default health
+ CreateTimer(duration, Timer_SpawnSplitTank, 0);
+ int health = CalculateExtraTankHealth(client);
+ SetEntProp(client, Prop_Send, "m_iHealth", health);
+ g_finaleStage = Stage_SecondTankSpawned;
+ return;
+ }
+ }
+
+ // End finale logic:
+ if(g_finaleStage == Stage_SecondTankSpawned) {
+ PrintDebug(DEBUG_SPAWNLOGIC, "OnTankBotSpawn: [FINALE] Health set, tank logic done");
+ g_finaleStage = Stage_ActiveDone;
+ // We don't return, letting the 2nd 5+ finale tank get buffed:
+ }
+ // This should not run on active finales (different than finale maps, such as swamp fever's, where finale isnt full map)
+ // Normal tank (not stage 2 / not secondary tank) spawned. Set its health and spawn split tank
+ int health = CalculateExtraTankHealth(client);
+
+ /* Split tank can only spawn if:
+ (1) not finale
+ (2) over threshold hExtraTankThreshold
+ (3) split tanks enabled
+ (4) random chance set by hSplitTankChance
+ Otherwise, just scale health based on survivor count
+ */
+ if(g_finaleStage == Stage_Inactive && g_realSurvivorCount >= hExtraTankThreshold.IntValue && hExtraFinaleTank.IntValue & 1 && GetURandomFloat() <= hSplitTankChance.FloatValue) {
+ float duration = GetRandomFloat(EXTRA_TANK_MIN_SEC, EXTRA_TANK_MAX_SEC);
+ int splitHealth = health / 2;
+ PrintDebug(DEBUG_SPAWNLOGIC, "OnTankBotSpawn: split tank in %.1fs, health=%d", duration, splitHealth);
+ CreateTimer(duration, Timer_SpawnSplitTank, splitHealth);
+ SetEntProp(client, Prop_Send, "m_iHealth", splitHealth);
+ } else {
+ PrintDebug(DEBUG_SPAWNLOGIC, "OnTankBotSpawn: Setting tank health to %d", health);
+ SetEntProp(client, Prop_Send, "m_iHealth", health);
+ }
+}
+
+int CalculateExtraTankHealth(int client) {
+ int health = GetEntProp(client, Prop_Send, "m_iHealth");
+ float additionalHealth = float(g_survivorCount - 4) * cvEPITankHealth.FloatValue;
+ health += RoundFloat(additionalHealth);
+ return health;
+}
+
+Action Timer_SpawnSplitTank(Handle h, int health) {
+ PrintDebug(DEBUG_SPAWNLOGIC, "Timer_SpawnSplitTank(%d)", health);
+ g_newTankHealth = health;
+ DirectorSpawn(Special_Tank);
+ return Plugin_Handled;
+}
+
+void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client > 0) {
+ int team = GetClientTeam(client);
+ if(team == 3) {
+ int class = GetEntProp(client, Prop_Send, "m_zombieClass") - 1;
+ if(class > view_as(Special_Tank)) return;
+ g_spawnCount[class]--;
+ if(g_spawnCount[class] < 0) {
+ g_spawnCount[class] = 0;
+ }
+ g_infectedCount--;
+ if(g_infectedCount < 0) {
+ g_infectedCount = 0;
+ }
+ } else if(team == 2) {
+ TryGrantRest();
+ }
+ }
+}
+
+void Event_PlayerIncapped(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client > 0 && GetClientTeam(client) == 2) {
+ TryGrantRest();
+ }
+}
+
+/// METHODS
+
+
+/*
+Extra Witch Algo:
+On map start, knowing # of total players, compute a random number of witches.
+The random number calculated by DiceRoll with 2 rolls and biased to the left. [min, 6]
+The minimum number in the dice is shifted to the right by the # of players (abmExtraCount-4)/4 (1 extra=0, 10 extra=2)
+
+Then, with the # of witches, as N, calculate N different flow values between [0, L4D2Direct_GetMapMaxFlowDistance()]
+Timer_Director then checks if highest flow achieved (never decreases) is >= each flow value, if one found, a witch is spawned
+(the witch herself is not spawned at the flow, just her spawning is triggered)
+*/
+void InitExtraWitches() {
+ float flowMax = L4D2Direct_GetMapMaxFlowDistance() - FLOW_CUTOFF;
+ // Just in case we don't have max flow or the map is extremely tiny, don't run:
+ if(flowMax > 0.0) {
+ int count = g_survivorCount;
+ if(count < 4) count = 4;
+ // Calculate the number of witches we want to spawn.
+ // We bias the dice roll to the right. We slowly increase min based on player count to shift distribution to the right
+ int min = RoundToFloor(float(count - 5) / 4.0);
+ int max = RoundToFloor(float(count) / 4.0);
+
+ // TODO: inc chance based on map max flow
+ g_extraWitchCount = DiceRoll(min, DIRECTOR_WITCH_MAX_WITCHES, DIRECTOR_WITCH_ROLLS, BIAS_LEFT);
+ PrintDebug(DEBUG_SPAWNLOGIC, "InitExtraWitches: %d witches (min=%d, max=%d, rolls=%d) checkInterval=%f", g_extraWitchCount, min, max, DIRECTOR_WITCH_ROLLS, DIRECTOR_WITCH_CHECK_TIME);
+ for(int i = 0; i < g_extraWitchCount; i++) {
+ g_extraWitchFlowPositions[i] = GetURandomFloat() * (flowMax-FLOW_CUTOFF) + FLOW_CUTOFF;
+ PrintDebug(DEBUG_SPAWNLOGIC, "Witch position #%d: flow %.2f (%.0f%%)", i, g_extraWitchFlowPositions[i], g_extraWitchFlowPositions[i] / flowMax);
+ }
+ witchSpawnTimer = CreateTimer(DIRECTOR_WITCH_CHECK_TIME, Timer_DirectorWitch, _, TIMER_REPEAT);
+ }
+ // TODO: spawn them early instead
+}
+
+void Director_PrintDebug(int client) {
+ PrintToConsole(client, "State: %s(%d)", DIRECTOR_STATE[g_lastState], g_lastState);
+ float eCount = float(g_survivorCount - 3);
+ float chance = (eCount - float(g_infectedCount)) / eCount;
+ PrintToConsole(client, "Player Scale Chance: %f%%", chance * 100.0);
+ PrintToConsole(client, "Map Bounds: [%f, %f]", FLOW_CUTOFF, L4D2Direct_GetMapMaxFlowDistance() - (FLOW_CUTOFF*2.0));
+ PrintToConsole(client, "Total Witches Spawned: %d | Target: %d", g_spawnCount[Special_Witch], g_extraWitchCount);
+ for(int i = 0; i < g_extraWitchCount && i < DIRECTOR_WITCH_MAX_WITCHES; i++) {
+ PrintToConsole(client, "%d. %f", i+1, g_extraWitchFlowPositions[i]);
+ }
+ PrintToConsole(client, "highestFlow = %f, g_minFlowSpawn = %f, current flow = %f", g_highestFlowAchieved, g_minFlowSpawn, L4D2Direct_GetFlowDistance(client));
+ PrintToConsole(client, "g_maxStressIntensity = %f, current avg = %f", g_maxStressIntensity, L4D_GetAvgSurvivorIntensity());
+ PrintToConsole(client, "TankInPlay=%b, FinaleStage=%d, FinaleEscapeReady=%b, DirectorTankCheck:%b", L4D2_IsTankInPlay(), g_finaleStage, g_isFinaleEnding, L4D2_IsTankInPlay() && !g_isFinaleEnding);
+ char buffer[128];
+ float time = GetGameTime();
+ PrintToConsole(client, "Last Spawn Deltas: (%.1f s) (min %f)", time - g_lastSpecialSpawnTime, DIRECTOR_MIN_SPAWN_TIME);
+ for(int i = 0; i < TOTAL_NUM_SPECIALS; i++) {
+ Format(buffer, sizeof(buffer), "%s %s=%.1f", buffer, SPECIAL_IDS[i], time-g_lastSpawnTime[i]);
+ }
+ PrintToConsole(client, "\t%s", buffer);
+ buffer[0] = '\0';
+ PrintToConsole(client, "Spawn Counts: (%d/%d)", g_infectedCount, g_survivorCount - 4);
+ for(int i = 0; i < TOTAL_NUM_SPECIALS; i++) {
+ Format(buffer, sizeof(buffer), "%s %s=%d/%d", buffer, SPECIAL_IDS[i], g_spawnCount[i], g_spawnLimit[i]);
+ }
+ PrintToConsole(client, "\t%s", buffer);
+ PrintToConsole(client, "timer interval=%.0f, rest count=%d, rest time left=%.0fs", DIRECTOR_TIMER_INTERVAL, g_restCount, float(g_restCount) * DIRECTOR_TIMER_INTERVAL);
+}
+
+void Director_RandomizeLimits() {
+ // We add +1 to spice it up
+ int max = RoundToCeil(float(g_survivorCount - 4) / 4) + 1;
+ for(int i = 0; i < NUM_SPECIALS; i++) {
+ g_spawnLimit[i] = GetRandomInt(0, max);
+ // PrintDebug(DEBUG_SPAWNLOGIC, "new spawn limit (special=%d, b=[0,%d], limit=%d)", i, max, g_spawnLimit[i]);
+ }
+ gd_maxSpecials = L4D2_GetScriptValueInt("MaxSpecials", 0);
+}
+void Director_RandomizeThings() {
+ g_maxStressIntensity = GetRandomFloat(DIRECTOR_STRESS_CUTOFF, 1.0);
+ g_minFlowSpawn = GetRandomFloat(500.0 + FLOW_CUTOFF, FLOW_CUTOFF * 2);
+ Director_RandomizeLimits();
+}
+
+bool Director_ShouldRest() {
+ if(g_restCount > 0) {
+ g_restCount--;
+ return true;
+ }
+ TryGrantRest();
+ return false;
+}
+
+void TryGrantRest() {
+ if(GetURandomFloat() <= DIRECTOR_REST_CHANCE) {
+ g_restCount = GetRandomInt(0, DIRECTOR_REST_MAX_COUNT);
+ }
+}
+
+// Little hacky, need to track when one leaves instead
+void Director_CheckSpawnCounts() {
+ if(!IsEPIActive()) return;
+ for(int i = 0; i < TOTAL_NUM_SPECIALS; i++) {
+ g_spawnCount[i] = 0;
+ }
+ g_infectedCount = 0;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientInGame(i) && GetClientTeam(i) == 3) {
+ int class = GetEntProp(i, Prop_Send, "m_zombieClass") - 1; // make it 0-based
+ if(class > view_as(Special_Tank)) continue;
+ g_spawnCount[class]++;
+ g_infectedCount++;
+ }
+ }
+}
+
+/// TIMERS
+
+// TODO: maybe make specials spaw nmore during horde events (alarm car, etc)
+// less during calms, making that the automatic rest periods?
+directorState Director_Think() {
+ if(!IsEPIActive()) return DState_NoPlayersOrNotCoop;
+ float time = GetGameTime();
+
+ // Calculate the new highest flow
+ int highestPlayer = L4D_GetHighestFlowSurvivor();
+ if(highestPlayer <= 0) return DState_NoPlayersOrNotCoop;
+ float flow = L4D2Direct_GetFlowDistance(highestPlayer);
+ if(flow > g_highestFlowAchieved) {
+ g_highestFlowAchieved = flow;
+ }
+
+
+ // Only run once until:
+ // A. They reach minimum flow (little past start saferoom)
+ // B. Under the total limited (equal to player count)
+ // C. Special spawning is enabled
+ gd_maxSpecials = L4D2_GetScriptValueInt("MaxSpecials", 0);
+ if(gd_maxSpecials <= 0) return DState_MaxDirectorSpecials;
+ if( ~cvEPISpecialSpawning.IntValue & 1 || !L4D_HasAnySurvivorLeftSafeArea() || g_highestFlowAchieved < g_minFlowSpawn) return DState_PendingMinFlowOrDisabled;
+
+ // Check if a rest period is given
+ if(Director_ShouldRest()) {
+ return DState_Resting;
+ }
+
+ // Only spawn more than one special within 2s at 10%
+ // TODO: randomized time between spawns? 0, ?? instead of repeat timer?
+ if(time - g_lastSpecialSpawnTime < 1.0 && GetURandomFloat() > 0.45) return DState_MaxSpecialTime;
+
+ if(GetURandomFloat() < DIRECTOR_CHANGE_LIMIT_CHANCE) {
+ Director_RandomizeLimits();
+ }
+
+ // Decrease chance of spawning based on how close to infected count
+ // abmExtraCount=6 g_infectedCount=0 chance=1.0 ((abmExtraCount-g_infectedCount)/abmExtraCount)
+ // abmExtraCount=6 g_infectedCount=1 chance=0.9 ((6-1)/6)) = (5/6)
+ // abmExtraCount=6 g_infectedCount=6 chance=0.2
+ // TODO: in debug calculate this
+ float eCount = float(g_survivorCount - 3);
+ float chance = (eCount - float(g_infectedCount)) / eCount;
+ // TODO: verify (abmExtraCount-4)
+ if(GetURandomFloat() > chance) return DState_PlayerChance;
+
+
+ float curAvgStress = L4D_GetAvgSurvivorIntensity();
+ // Don't spawn specials when tanks active, but have a small chance (DIRECTOR_SPECIAL_TANK_CHANCE) to bypass
+ if((L4D2_IsTankInPlay() && !g_isFinaleEnding) && GetURandomFloat() > DIRECTOR_SPECIAL_TANK_CHANCE) {
+ return DState_TankInPlay;
+ } else if(curAvgStress >= g_maxStressIntensity) {
+ // Stop spawning when players are stressed from a random value chosen by [DIRECTOR_STRESS_CUTOFF, 1.0]
+ return DState_HighStress;
+ }
+ // Scale the chance where stress = 0.0, the chance is 50% more, and stress = 1.0, the chance is 50% less
+ float spawnChance = DIRECTOR_SPAWN_CHANCE + ((0.5 - curAvgStress) / 10.0);
+ for(int i = 0; i < NUM_SPECIALS; i++) {
+ specialType special = view_as(i);
+ // Skip if we hit our limit, or too soon:
+ if(g_spawnCount[i] >= g_spawnLimit[i]) continue;
+ if(time - g_lastSpawnTime[i] < DIRECTOR_MIN_SPAWN_TIME) continue;
+
+ if(GetURandomFloat() <= spawnChance) {
+ DirectorSpawn(special);
+ }
+ }
+
+ return DState_Normal;
+}
+
+Action Timer_Director(Handle h) {
+ g_lastState = Director_Think();
+ return Plugin_Continue;
+}
+
+
+Action Timer_DirectorWitch(Handle h) {
+ // TODO: instead of +1, do it when director spawned a witch
+ if(!IsEPIActive()) return Plugin_Continue;
+ if(g_spawnCount[Special_Witch] < g_extraWitchCount + 1) { //&& time - g_lastSpawnTimes.witch > DIRECTOR_WITCH_MIN_TIME
+ for(int i = 0; i <= g_extraWitchCount; i++) {
+ if(g_extraWitchFlowPositions[i] > 0.0 && g_highestFlowAchieved >= g_extraWitchFlowPositions[i]) {
+ // Reset the flow so we don't spawn another
+ g_extraWitchFlowPositions[i] = 0.0;
+ int target = L4D_GetHighestFlowSurvivor();
+ if(!target) return Plugin_Continue;
+ DirectorSpawn(Special_Witch, target);
+ return Plugin_Continue;
+ }
+ }
+ }
+ witchSpawnTimer = null;
+ return Plugin_Stop;
+}
+
+// UTIL functions
+void DirectorSpawn(specialType special, int player = -1) {
+ if(player <= 0)
+ player = GetSuitableVictim();
+ if(special != Special_Witch && special != Special_Tank) {
+ // Bypass director
+ int bot = CreateFakeClient("EPI_BOT");
+ if (bot != 0) {
+ ChangeClientTeam(bot, 3);
+ CreateTimer(0.1, Timer_Kick, bot);
+ }
+ }
+ float pos[3];
+ if(L4D_GetRandomPZSpawnPosition(player, view_as(special) + 1, 10, pos)) {
+ // They use 1-index
+ if(special == Special_Tank) {
+ L4D2_SpawnTank(pos, NULL_VECTOR);
+ } else {
+ L4D2_SpawnSpecial(view_as(special) + 1, pos, NULL_VECTOR);
+ }
+ }
+}
+
+// Finds a player that is suitable (lowest intensity)
+// TODO: biased random (lower intensity : bias)
+// dice roll, #sides = #players, sort list of players by intensity
+// then use biased left dice, therefore lower intensity = higher random weight
+int g_iLastVictim;
+int GetSuitableVictim() {
+ // TODO: randomize?
+ return GetRandomSurvivor(1, -1);
+ // ArrayList survivors = new ArrayList(2);
+ // for(int i = 1; i <= MaxClients; i++) {
+ // if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
+ // int index = survivors.Push(i);
+ // survivors.Set(index, 1, L4D_GetPlayerIntensity(i));
+ // }
+ // }
+ // // Soe
+ // survivors.SortCustom()
+
+ int victim = -1;
+ float lowestIntensity = 0.0;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(g_iLastVictim != i && IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
+ float intensity = L4D_GetPlayerIntensity(i);
+ // TODO: possibly add perm health into calculations
+ if(intensity < lowestIntensity || victim == -1) {
+ lowestIntensity = intensity;
+ victim = i;
+ }
+ }
+ }
+ g_iLastVictim = victim;
+ return victim;
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls.inc b/scripting/include/feedthetrolls.inc
new file mode 100644
index 0000000..7af8ceb
--- /dev/null
+++ b/scripting/include/feedthetrolls.inc
@@ -0,0 +1,18 @@
+#if defined _ftt_included_
+ #endinput
+#endif
+#define _ftt_included_
+
+
+enum TrollModifier {
+ TrollMod_Invalid = 0,
+ TrollMod_Instant = 1 << 0,
+ TrollMod_Constant = 1 << 1,
+ TrollMod_PlayerOnly = 1 << 2, // Does the troll only work on players, not bots? If set, troll only applied on real user. If not, troll applied to both bot and idler
+}
+
+native void ApplyTroll(int victim, const char[] name, TrollModifier modifier = TrollMod_Invalid, int flags, int activator, bool silent = false);
+
+forward void OnTrollApplied(int victim, const char[] trollName, int flags = 0, int activator = 0);
+
+forward void OnTrollMarked(int activator, int victim);
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/base.inc b/scripting/include/feedthetrolls/base.inc
new file mode 100644
index 0000000..cc3a067
--- /dev/null
+++ b/scripting/include/feedthetrolls/base.inc
@@ -0,0 +1,507 @@
+
+#define MAX_TROLL_NAME_LENGTH 32
+#define MAX_TROLL_FLAG_LENGTH 32
+//Allow MAX_TROLLS to be defined elsewhere
+#if defined MAX_TROLLS
+#else
+ #define MAX_TROLLS 55
+#endif
+
+enum trollModifier {
+ TrollMod_Invalid = 0,
+ TrollMod_Instant = 1 << 0,
+ TrollMod_Constant = 1 << 1,
+ TrollMod_PlayerOnly = 1 << 2, // Does the troll only work on players, not bots? If set, troll only applied on real user. If not, troll applied to both bot and idler
+}
+
+enum TrollEffectResponse {
+ TE_Success, // Success, continue menu
+ TE_Error, // Error, continue menu (retry)
+ TE_Menu // Switching menus / etc, don't continue menu
+}
+
+StringMap trollKV;
+char trollIds[MAX_TROLLS+1][MAX_TROLL_NAME_LENGTH];
+char DEFAULT_FLAG_PROMPT_MULTIPLE[] = "Enable options (Multiple)";
+char DEFAULT_FLAG_PROMPT[] = "Select an option";
+bool SilentMenuSelected[MAXPLAYERS+1];
+
+static int g_trollAddPromptIndex;
+ArrayList gRandomClients;
+
+char SPECIAL_NAMES[][] = {
+ "Smoker", "Boomer", "Hunter", "Spitter", "Jockey", "Charger", "Witch", "Tank"
+};
+
+enum struct TrollFlagPrompt {
+ char promptText[MAX_TROLL_FLAG_LENGTH];
+ int flags;
+ int defaults;
+ bool multiselect;
+ int requireFlags;
+
+ void GetPromptText(char[] prompt, int maxlength) {
+ if(this.promptText[0] != '\0') {
+ strcopy(prompt, maxlength, this.promptText);
+ } else if(this.multiselect) {
+ strcopy(prompt, maxlength, DEFAULT_FLAG_PROMPT_MULTIPLE);
+ } else {
+ strcopy(prompt, maxlength, DEFAULT_FLAG_PROMPT);
+ }
+ }
+}
+
+
+// Very hacky but map a power (say 16, 32) to the index in a list
+// Used to get the name of a flag (flag #16 for example) in ArrayList of flag names
+int GetIndexFromPower(int powerOfTwo) {
+ for(int i = 0; i < 16; i++) {
+ if(1 << i == powerOfTwo) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+enum struct Troll {
+ int id; // The id or the index into the global Trolls[] array
+ int categoryID; // The category this troll belongs in
+
+ char name[MAX_TROLL_NAME_LENGTH];
+ char description[128];
+ bool hidden;
+
+ int mods; // Combination of valid modifiers. Only two are ever supported
+
+ // Flags
+ int activeFlagClients[MAXPLAYERS+1];
+ ArrayList flagNames;
+ ArrayList flagPrompts;
+
+ // Custom timer
+ Timer timerFunction;
+ Handle timerHandles[MAXPLAYERS+1];
+ float timerInterval;
+ int timerRequiredFlags;
+
+ void SetTimer(float interval, Timer timer, int requiredFlags = 0) {
+ this.timerInterval = interval;
+ this.timerFunction = timer;
+ this.timerRequiredFlags = requiredFlags;
+ for(int i = 0; i <= MAXPLAYERS; i++) {
+ this.timerHandles[i] = null;
+ }
+ }
+
+ bool HasMod(trollModifier mod) {
+ return ((this.mods >> (view_as(mod)) - 1) & 1) == 1;
+ }
+
+ // Gets the default modifier to use
+ trollModifier GetDefaultMod() {
+ // If the flags is equal to the 2^n flag, then it must be the only flag:
+ if(this.mods == view_as(TrollMod_Instant)) return TrollMod_Instant;
+ else if(this.mods == view_as(TrollMod_Constant)) return TrollMod_Constant;
+ else return TrollMod_Invalid;
+ }
+
+/////// FLAGS
+
+ bool GetFlagName(int index, char[] buffer, int maxlength) {
+ if(this.flagNames == null || index >= this.flagNames.Length) return false;
+ this.flagNames.GetString(index, buffer, maxlength);
+ return true;
+ }
+
+ bool GetFlagNames(int client, char[] output, int maxlength) {
+ if(this.flagNames == null) return false;
+ char buffer[16];
+ for(int i = 0; i < this.flagNames.Length; i++) {
+ int value = 1 << i;
+ // If client has this flag:
+ if(this.activeFlagClients[client] & value) {
+ this.flagNames.GetString(i, buffer, sizeof(buffer));
+ Format(output, maxlength, "%s%s,", output, buffer);
+ }
+ }
+ return true;
+ }
+
+ int AddCustomFlagPrompt(const char[] promptText, bool multiselect = false, int requireFlags = 0) {
+ TrollFlagPrompt prompt;
+ prompt.multiselect = multiselect;
+ prompt.requireFlags = requireFlags;
+ strcopy(prompt.promptText, MAX_TROLL_FLAG_LENGTH, promptText);
+ int index = this.flagPrompts.PushArray(prompt);
+ g_trollAddPromptIndex = index;
+ return index;
+ }
+
+ int AddFlagPrompt(bool multiselect = false, int requireFlags = 0) {
+ //g_trollAddPromptIndex
+ TrollFlagPrompt prompt;
+ prompt.multiselect = multiselect;
+ prompt.requireFlags = requireFlags;
+ int index = this.flagPrompts.PushArray(prompt);
+ g_trollAddPromptIndex = index;
+ return index;
+ }
+
+ int AddFlag(const char[] name, bool defaultOn) {
+ if(this.flagNames == null) {
+ this.flagNames = new ArrayList(MAX_TROLL_FLAG_LENGTH);
+ }
+
+ // Check if flag already added
+ int flagIndex = this.GetFlagIndex(name);
+ if(flagIndex == -1) flagIndex = this.flagNames.PushString(name);
+
+ // Grab the prompt
+ static TrollFlagPrompt prompt;
+ // TODO: CHECK IF MISSING PROMPT
+ if(g_trollAddPromptIndex >= this.flagPrompts.Length) {
+ ThrowError("No prompt added for troll \"%s\", for flag \"%s\"", this.id, name);
+ }
+ this.flagPrompts.GetArray(g_trollAddPromptIndex, prompt);
+
+
+ prompt.flags |= (1 << flagIndex);
+
+ if(defaultOn) {
+ // If out of bounds, set to default -1 -> pick global prompt
+ if(this.flagPrompts.Length == 0) {
+ ThrowError("Troll \"%s\" does not have any flag prompts, thus a default value cannot be set. (flag=\"%s\")", this.name, name);
+ return -1;
+ }
+ if(!prompt.multiselect && prompt.defaults > 0) {
+ ThrowError("Flag \"%s\" cannot be set as default flag in single select mode, as one has already been set for prompt %d", name, g_trollAddPromptIndex);
+ return -1;
+ }
+ prompt.defaults |= (1 << flagIndex);
+ }
+ this.flagPrompts.SetArray(g_trollAddPromptIndex, prompt); //May not be required
+ return flagIndex;
+ }
+
+ int GetFlagIndex(const char[] flagName) {
+ static char comprFlag[MAX_TROLL_FLAG_LENGTH];
+ for(int i = 0; i < this.flagNames.Length; i++) {
+ this.flagNames.GetString(i, comprFlag, sizeof(comprFlag));
+ if(StrEqual(comprFlag, flagName)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ bool HasFlags() {
+ return this.flagNames != null && this.flagNames.Length > 0 && this.flagPrompts.Length > 0;
+ }
+
+ int GetFlagCount() {
+ return this.flagNames != null ? this.flagNames.Length : 0;
+ }
+
+ int GetClientFlags(int client) {
+ return this.activeFlagClients[client];
+ }
+ void GetFlagPrompt(int index, TrollFlagPrompt prompt) {
+ this.flagPrompts.GetArray(index, prompt);
+ }
+
+/////// TROLL ACTIVATION
+
+ TrollEffectResponse Activate(int client, int activator, trollModifier modifier = TrollMod_Invalid, int flags = 0, bool silent = false) {
+ if(modifier == TrollMod_Invalid) modifier = this.GetDefaultMod();
+ // Sadly, unable to pass in to ApplyTroll, so it has to do unnecessary lookup via string
+ return ApplyTroll(client, this.name, activator, modifier, flags, silent);
+ }
+
+
+ void Toggle(int client, int flags) {
+ if(this.IsActive(client)) {
+ this.Disable(client);
+ } else {
+ this.Enable(client, flags);
+ }
+ }
+
+ void Enable(int client, int flags) {
+ this.activeFlagClients[client] = flags;
+ // If a timer is assigned, start it:
+ if(this.timerHandles[client] != null) {
+ delete this.timerHandles[client];
+ PrintToServer("FTT Debug: Old timer for %N, killing", client);
+ }
+ if(this.timerInterval > 0.0) {
+ this.timerHandles[client] = CreateTimer(this.timerInterval, this.timerFunction, GetClientUserId(client), TIMER_REPEAT);
+ }
+ }
+
+ void Disable(int client) {
+ this.activeFlagClients[client] = -1;
+ // Stop any running timer:
+ if(this.timerHandles[client] != null) {
+ PrintToServer("FTT Debug: Disabling timer for %N", client);
+ delete this.timerHandles[client];
+ }
+ }
+
+ bool IsActive(int client) {
+ return this.activeFlagClients[client] != -1;
+ }
+
+ int GetRandomClient(int start = 0) {
+ gRandomClients.Clear();
+ for(int i = start + 1; i <= MaxClients; i++) {
+ if(this.activeFlagClients[i] != -1) {
+ gRandomClients.Push(i);
+ }
+ }
+ if(gRandomClients.Length == 0) return -1;
+ return GetRandomInt(0, gRandomClients.Length);
+ }
+}
+
+Troll Trolls[MAX_TROLLS+1];
+
+ArrayList categories;
+static int categoryID = -1;
+
+void ResetClient(int victim, bool wipe = true) {
+ if(victim == 0 || !IsClientConnected(victim)) return;
+ if(wipe) {
+ for(int i = 0; i <= MAX_TROLLS; i++) {
+ Trolls[i].Disable(victim);
+ }
+ }
+ noRushingUsSpeed[victim] = 1.0;
+ BaseComm_SetClientMute(victim, false);
+ SetEntityGravity(victim, 1.0);
+ SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
+ SetEntProp(victim, Prop_Send, "m_iHideHUD", 0)
+ SDKUnhook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
+ int wpn = GetClientWeaponEntIndex(victim, 0);
+ if(wpn > -1)
+ SDKUnhook(wpn, SDKHook_Reload, Event_WeaponReload);
+}
+
+int SetupTroll(const char[] name, const char description[128], int mods) {
+ static int i = 0;
+ if(mods == 0) {
+ ThrowError("Troll \"%s\" has no modifiers defined.", name);
+ return -1;
+ } else if(i == MAX_TROLLS + 1) {
+ ThrowError("Maximum number of trolls (%d) reached. Up MAX_TROLLS value.", MAX_TROLLS);
+ return -1;
+ }
+ g_trollAddPromptIndex = 0;
+ Trolls[i].id = i;
+ strcopy(Trolls[i].name, MAX_TROLL_NAME_LENGTH, name);
+ strcopy(Trolls[i].description, 128, description);
+ Trolls[i].categoryID = categoryID;
+ Trolls[i].mods = mods;
+ Trolls[i].flagPrompts = new ArrayList(sizeof(TrollFlagPrompt));
+
+ strcopy(trollIds[i], MAX_TROLL_NAME_LENGTH, name);
+ trollKV.SetValue(name, i);
+ return i++;
+}
+
+// Gets the Troll enum struct via name
+// Returns index of troll enum
+int GetTroll(const char[] name, Troll troll) {
+ static int i = 0;
+ if(trollKV.GetValue(name, i)) {
+ troll = Trolls[i];
+ return i;
+ }
+ ThrowError("GetTroll: Troll was not found \"%s\"", name);
+ return -1;
+}
+int GetTrollID(const char[] name) {
+ static int i = 0;
+ if(trollKV.GetValue(name, i)) {
+ return i;
+ }
+ PrintToServer("GetTrollID: Troll was not found \"%s\"", name);
+ return -1;
+}
+
+bool IsAnyTrollActive(int victim) {
+ for(int i = 0; i <= MAX_TROLLS; i++) {
+ if(Trolls[i].activeFlagClients[victim] >= 0) return true;
+ }
+ return false;
+}
+// Gets the Troll enum struct via key index
+// Returns index of troll enum
+void GetTrollByKeyIndex(int index, Troll troll) {
+ troll = Trolls[index];
+}
+
+void SetTrollFlags(int client, const char[] name, int flags = -1) {
+ int index = GetTrollID(name);
+ if(flags == -1)
+ Trolls[index].Disable(client);
+ else
+ Trolls[index].Enable(client, flags);
+}
+
+
+TrollEffectResponse ApplyTroll(int victim, const char[] name, int activator, trollModifier modifier, int flags = 0, bool silent = false) {
+ static Troll troll;
+ int trollIndex = GetTroll(name, troll);
+ if(trollIndex == -1) {
+ ReplyToCommand(activator, "Unknown troll \"%s\"", name);
+ PrintToServer("[FTT] %N attempted to apply unknown troll: %s", activator, name);
+ return TE_Error;
+ }
+
+ bool isActive = Trolls[trollIndex].activeFlagClients[victim] > -1;
+
+ // Clear troll specific timer:
+ if(Trolls[trollIndex].timerInterval > 0.0) {
+ if(!isActive) {
+ if(modifier & TrollMod_Constant && (Trolls[trollIndex].timerRequiredFlags == 0 || Trolls[trollIndex].timerRequiredFlags & flags)) {
+ Trolls[trollIndex].timerHandles[victim] = CreateTimer(Trolls[trollIndex].timerInterval, Trolls[trollIndex].timerFunction, victim, TIMER_REPEAT);
+ }
+ } else if(Trolls[trollIndex].timerHandles[victim] != null) {
+ delete Trolls[trollIndex].timerHandles[victim];
+ }
+ }
+
+
+ if(!silent && SilentMenuSelected[activator]) silent = true;
+
+ static int MetaInverseTrollID;
+ if(!MetaInverseTrollID) MetaInverseTrollID = GetTrollID("Meta: Inverse");
+
+ if(activator > 0 && Trolls[MetaInverseTrollID].IsActive(activator)) {
+ float max = 1.0;
+ if(Trolls[MetaInverseTrollID].activeFlagClients[activator] & 2) max = 0.5;
+ else if(Trolls[MetaInverseTrollID].activeFlagClients[activator] & 4) max = 0.1;
+ if(GetURandomFloat() <= max) {
+ victim = activator;
+ }
+ }
+
+ // If victim is a survivor bot, check if has an idle player
+ if(IsFakeClient(victim) && GetClientTeam(victim) == 2) {
+ int player = GetSpectatorClient(victim);
+ if(player > 0) {
+ // If there is an idle player, apply troll to them
+ ApplyTroll(player, name, activator, modifier, flags, silent);
+ // And continue IF there is TrollMod_PlayerOnly mod
+ if(troll.mods & view_as(TrollMod_PlayerOnly)) return TE_Success;
+ // Don't want to show two logs, so just ignore the bot
+ silent = true;
+ }
+ }
+
+
+ // Toggle on flags for client, if it's not a single run.
+ if(modifier & TrollMod_Constant) {
+ Trolls[trollIndex].activeFlagClients[victim] = isActive ? -1 : flags;
+ }
+
+ // Applies any custom logic needed for a troll, mostly only used for TrollMod_Instant
+ TrollEffectResponse response = ApplyAffect(victim, troll, activator, modifier, flags);
+ if(response != TE_Success) return response; // Let the menu handler deal with checking
+
+ // Log all actions, indicating if constant or single-fire, and if any flags
+ if(!silent) {
+ if(isActive) {
+ CShowActivityEx(activator, "[FTT] ", "deactivated {yellow}%s{default} on %N. ", troll.name, victim);
+ LogAction(activator, victim, "\"%L\" deactivated \"%s\" on \"%L\"", activator, troll.name, victim);
+ } else {
+ char flagName[MAX_TROLL_FLAG_LENGTH];
+ // strcopy(flagName, sizeof(flagName), troll.name)
+ // Call_StartForward(g_TrollAppliedForward);
+ // Call_PushCell(victim);
+ // Call_PushString(flagName);
+ // Call_PushCell(flags);
+ // Call_PushCell(activator);
+ // Call_Finish();
+ if(flags > 0) {
+ troll.GetFlagNames(victim, flagName, sizeof(flagName));
+ // Checks if there is not more than one flag set on the bitfield
+ // if(flags & flags - 1 == 0 && flags & flags + 1 == 0) {
+ // // Get the flag name if there is only one flag set
+ // troll.GetFlagName(GetIndexFromPower(flags), flagName, sizeof(flagName));
+ // } else {
+ // Format(flagName, sizeof(flagName), "%d", flags);
+ // }
+ Format(flagName, sizeof(flagName), " (\x04%s|%d\x01)", flagName, flags);
+ // CFormatColor(flagName, sizeof(flagName));
+ }
+
+ if(modifier & TrollMod_Constant) {
+ CShowActivityEx(activator, "[FTT] ", "activated constant {yellow}%s{default}%s for %N. ", troll.name, flagName, victim);
+ } else {
+ CShowActivityEx(activator, "[FTT] ", "activated {yellow}%s{default}%s for %N. ", troll.name, flagName, victim);
+ }
+ LogAction(activator, victim, "\"%L\" activated \"%s\" (%d) for \"%L\"", activator, troll.name, flags, victim);
+ }
+ } else {
+ CReplyToCommand(activator, "[FTT] Applied silently {yellow}\"%s\"{default} on %N with flags=%d", troll.name, victim, flags);
+ }
+ return TE_Success;
+}
+
+bool IsTrollActive(int client, const char[] troll) {
+ if(troll[0] == '\0') {
+ ThrowError("Troll name is empty");
+ return false;
+ }
+ static int i = 0;
+ if(trollKV.GetValue(troll, i)) {
+ return Trolls[i].activeFlagClients[client] != -1;
+ }
+ ThrowError("Troll \"%s\" does not exist", troll);
+ return false; //errors instead but compiler no like
+}
+
+bool IsTrollActiveByRawID(int client, int id) {
+ return Trolls[id].activeFlagClients[client] != -1;
+}
+
+
+void EnableTroll(int client, const char[] troll, int flags = 0) {
+ SetTrollFlags(client, troll, flags);
+}
+
+void DisableTroll(int client, const char[] troll) {
+ SetTrollFlags(client, troll, -1);
+}
+
+public void SetCategory(const char[] newCat) {
+ categoryID = categories.FindString(newCat);
+ if(categoryID == -1)
+ categoryID = categories.PushString(newCat);
+}
+void GetCategory(int category, char[] buffer, int size) {
+ categories.GetString(category, buffer, size);
+}
+
+
+public int Native_ApplyTroll(Handle plugin, int numParams) {
+ int victim = GetNativeCell(1);
+ char name[MAX_TROLL_NAME_LENGTH];
+ GetNativeString(2, name, sizeof(name));
+ trollModifier modifier = view_as(GetNativeCell(3));
+ if(view_as(modifier) < 0) {
+ ThrowNativeError(SP_ERROR_NATIVE, "Provided modifier is invalid (out of range)");
+ }
+ int flags = GetNativeCell(4);
+ int activator = GetNativeCell(5);
+
+ int index = GetTrollID(name);
+ if(index > 0) {
+ Trolls[index].Activate(victim, activator, modifier, flags, GetNativeCell(6));
+ } else {
+ ThrowNativeError(SP_ERROR_NATIVE, "Could not find troll with name \"%s\"", name);
+ }
+ return 0;
+}
+
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/combos.inc b/scripting/include/feedthetrolls/combos.inc
new file mode 100644
index 0000000..acb9e90
--- /dev/null
+++ b/scripting/include/feedthetrolls/combos.inc
@@ -0,0 +1,95 @@
+
+ArrayList combos;
+
+enum struct SpecifiedTroll {
+ int id;
+ trollModifier mod;
+ int flags;
+}
+enum struct TrollCombo {
+ char name[32];
+ ArrayList trolls;
+
+ void AddTroll(const char[] name, int flags = 0, trollModifier mod = TrollMod_Invalid) {
+ int id = GetTrollID(name);
+ if(mod == TrollMod_Invalid) mod = Trolls[id].GetDefaultMod();
+ SpecifiedTroll troll;
+ troll.id = id;
+ troll.mod = mod;
+ troll.flags = flags;
+ this.trolls.PushArray(troll, sizeof(troll));
+ }
+
+ void Activate(int client, int target) {
+ for(int i = 0; i < this.trolls.Length; i++) {
+ SpecifiedTroll troll;
+ this.trolls.GetArray(i, troll, sizeof(troll));
+ Trolls[troll.id].Activate(target, client, troll.mod, troll.flags);
+ }
+ }
+}
+
+void SetupCombo(TrollCombo combo, const char[] name) {
+ strcopy(combo.name, sizeof(combo.name), name);
+ combo.trolls = new ArrayList(sizeof(SpecifiedTroll));
+ combos.PushArray(combo, sizeof(combo));
+}
+
+void SetupsTrollCombos() {
+ combos = new ArrayList(sizeof(TrollCombo));
+
+ TrollCombo combo;
+ SetupCombo(combo, "Magnet Galore");
+ combo.AddTroll("Special Magnet");
+ combo.AddTroll("Tank Magnet");
+ #if defined _behavior_included
+ combo.AddTroll("Witch Magnet");
+ #endif
+
+ SetupCombo(combo, "Rush Stopper");
+ combo.AddTroll("Special Magnet");
+ combo.AddTroll("Tank Magnet");
+ #if defined _behavior_included
+ combo.AddTroll("Witch Magnet");
+ #endif
+ combo.AddTroll("No Button Touchie", 17, TrollMod_Constant);
+ combo.AddTroll("Slow Speed", 2, TrollMod_Constant);
+ combo.AddTroll("Instant Commons", 1, TrollMod_Instant);
+ // combo.AddTroll("Swarm", TrollMod_Instant);
+ combo.AddTroll("Vomit Player");
+ combo.AddTroll("Dull Melee", .flags=2);
+
+ SetupCombo(combo, "Tank Run Noob");
+ combo.AddTroll("Slow Speed");
+ combo.AddTroll("Tank Magnet");
+
+ SetupCombo(combo, "Nuclear");
+ combo.AddTroll("Slow Speed");
+ combo.AddTroll("Special Magnet", .flags=1);
+ combo.AddTroll("Tank Magnet", .flags=1);
+ #if defined _behavior_included
+ combo.AddTroll("Witch Magnet");
+ #endif
+ combo.AddTroll("Reverse FF", .flags=2);
+ combo.AddTroll("Vomit Player");
+
+ SetupCombo(combo, "No more survival");
+ combo.AddTroll("No Pickup", .flags = 8)
+ combo.AddTroll("Throw It All", .flags = 1)
+
+ SetupCombo(combo, "Shut up");
+ combo.AddTroll("Vocalize Gag");
+ combo.AddTroll("Honk / Meow / Woof", .flags=1);
+
+ SetupCombo(combo, "Weakness Compels You");
+ combo.AddTroll("No Shove");
+ combo.AddTroll("Dull Melee", .flags=2);
+ combo.AddTroll("Temp Health Quick Drain");
+
+ SetupCombo(combo, "Blindness");
+ combo.AddTroll("Vomit Player", 0, TrollMod_Constant);
+ combo.AddTroll("Shakey Camera", .flags=16);
+ combo.AddTroll("Randomize Angles", .flags=16);
+
+ PrintToServer("[FTT] Loaded %d troll combos", combos.Length);
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/commands.inc b/scripting/include/feedthetrolls/commands.inc
new file mode 100644
index 0000000..6d844f2
--- /dev/null
+++ b/scripting/include/feedthetrolls/commands.inc
@@ -0,0 +1,787 @@
+Action Command_InstaSpecial(int client, int args) {
+ if(args < 1) {
+ Menu menu = new Menu(Insta_PlayerHandler);
+ menu.SetTitle("InstaSpecial: Choose a player");
+ for(int i = 1; i < MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2) {
+ static char userid[8], display[16];
+ Format(userid, sizeof(userid), "%d|0", GetClientUserId(i));
+ GetClientName(i, display, sizeof(display));
+ menu.AddItem(userid, display);
+ }
+ }
+ menu.ExitButton = true;
+ menu.Display(client, 0);
+ } else {
+ char arg1[32], arg2[32] = "jockey";
+ GetCmdArg(1, arg1, sizeof(arg1));
+ if(args >= 2) {
+ GetCmdArg(2, arg2, sizeof(arg2));
+ }
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MaxClients,
+ COMMAND_FILTER_ALIVE,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ SpecialType specialType = GetSpecialType(arg2);
+ if(specialType == Special_Invalid) {
+ ReplyToCommand(client, "Unknown special \"%s\"", arg2);
+ return Plugin_Handled;
+ }
+
+ int successes = 0;
+ for (int i = 0; i < target_count; i++) {
+ int target = target_list[i];
+ if(GetClientTeam(target) == 2) {
+ if(SpawnSpecialForTarget(specialType, target, view_as(Special_AlwaysTarget))) {
+ LogAction(client, target, "\"%L\" spawned Insta-%s™ nearby \"%L\"", client, arg2, target);
+ successes++;
+ } else {
+ ReplyToCommand(client, "[FTT] Could not spawn %s near %s", arg2, target_name);
+ }
+ } else {
+ ReplyToTargetError(client, target_count);
+ }
+ }
+ if(successes > 0)
+ CShowActivityEx(client, "[FTT] ", "spawned {green}Insta-%s™{default} near {green}%s", arg2, target_name);
+ }
+
+
+ return Plugin_Handled;
+}
+
+Action Command_InstaSpecialFace(int client, int args) {
+ if(args < 1) {
+ Menu menu = new Menu(Insta_PlayerHandler);
+ menu.SetTitle("Inface: Choose a player");
+ for(int i = 1; i < MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2) {
+ static char userid[8], display[16];
+ Format(userid, sizeof(userid), "%d|1", GetClientUserId(i));
+ GetClientName(i, display, sizeof(display));
+ menu.AddItem(userid, display);
+ }
+ }
+ menu.ExitButton = true;
+ menu.Display(client, 0);
+ } else {
+ char arg1[32], arg2[32] = "jockey";
+ GetCmdArg(1, arg1, sizeof(arg1));
+ if(args >= 2) {
+ GetCmdArg(2, arg2, sizeof(arg2));
+ }
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MaxClients,
+ COMMAND_FILTER_ALIVE,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ SpecialType specialType = GetSpecialType(arg2);
+ if(specialType == Special_Invalid) {
+ ReplyToCommand(client, "Unknown special \"%s\"", arg2);
+ return Plugin_Handled;
+ }
+
+ int successes = 0;
+ for (int i = 0; i < target_count; i++) {
+ int target = target_list[i];
+ if(GetClientTeam(target) == 2) {
+ if(SpawnSpecialForTarget(specialType, target, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget))) {
+ LogAction(client, target, "\"%L\" spawned Insta-%s™ at player \"%L\"", client, arg2, target);
+ successes++;
+ } else {
+ ReplyToCommand(client, "[FTT] Could not spawn %s on %s", arg2, target_name);
+ }
+ }else{
+ ReplyToTargetError(client, target_count);
+ }
+ }
+ if(successes > 0)
+ CShowActivityEx(client, "[FTT] ", "spawned {olive}Insta-%s™{default} on {olive}%s", arg2, target_name);
+ }
+ return Plugin_Handled;
+}
+
+
+Action Command_WitchAttack(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_witch_attack [# of witches or 0 for all]");
+ }else{
+ char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[1], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_ALIVE, /* Only allow alive players */
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0)
+ {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ int target = target_list[0];
+ if(GetClientTeam(target) == 2) {
+ GetCmdArg(2, arg1, sizeof(arg1));
+
+ int maxCount = StringToInt(arg1);
+ if(maxCount < 0) maxCount = 0;
+ int count;
+
+ int witch = INVALID_ENT_REFERENCE;
+ while ((witch = FindEntityByClassname(witch, "witch")) != INVALID_ENT_REFERENCE) {
+ if(SetWitchTarget(witch, target)) {
+ ++count;
+ }
+ if(maxCount > 0 && count >= maxCount) break;
+ }
+ ShowActivity(client, "set %d witches to target %s", count, target_name);
+ }else{
+ ReplyToTargetError(client, target_count);
+ }
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_FeedTheCrescendoTroll(int client, int args) {
+ if(lastCrescendoUser > -1) {
+ ActivateAutoPunish(lastCrescendoUser);
+ ReplyToCommand(client, "Activated auto punish on %N", lastCrescendoUser);
+ LogAction(client, lastCrescendoUser, "\"%L\" autopunished crescendo rusher \"%L\"", client, lastCrescendoUser);
+ ShowActivityEx(client, "[FTT] ", "activated autopunish for crescendo activator %N",lastCrescendoUser);
+ }else{
+ ReplyToCommand(client, "No player could be found to autopunish.");
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_ResetUser(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_ftr ");
+ }else{
+ char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MAXPLAYERS,
+ COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_IMMUNITY, /* Only allow alive players */
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ for (int i = 0; i < target_count; i++) {
+ if(IsAnyTrollActive(target_list[i])) {
+ LogAction(client, target_list[i], "\"%L\" reset all troll effects for \"%L\"", client, target_list[i]);
+ }
+ ResetClient(target_list[i], true);
+ }
+ ShowActivityEx(client, "[FTT] ", "reset troll effects for %s.",target_name);
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_ApplyUser(int client, int args) {
+ if(args < 1) {
+ SilentMenuSelected[client] = false;
+ ShowTrollMenu(client, false);
+ }else{
+ char arg1[32], arg2[16];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ StringToLower(arg2);
+
+ static char target_name[MAX_TARGET_LENGTH];
+ int target_list[1], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_NO_MULTI | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ && target_list[0] == 0) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ if(args == 2) {
+ static char key[32];
+ for(int i = 0; i < categories.Length; i++) {
+ categories.GetString(i, key, sizeof(key));
+ if(StrEqual(key, arg2, false)) {
+ SilentMenuSelected[client] = false;
+ ShowTrollsForCategory(client, GetClientUserId(target_list[0]), i);
+ return Plugin_Handled;
+ }
+ }
+ ReplyToCommand(client, "[FTT] Unknown category: '%s'", arg2);
+ } else if(args == 1) {
+ SetupCategoryMenu(client, GetClientUserId(target_list[0]));
+ }
+
+ SilentMenuSelected[client] = false;
+ SetupCategoryMenu(client, GetClientUserId(target_list[0]));
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_ApplyComboTrolls(int client, int args) {
+ if(args < 1) {
+ ShowTrollMenu(client, true);
+ }else{
+ char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+
+ static char target_name[MAX_TARGET_LENGTH];
+ int target_list[1], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_NO_MULTI,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ && target_list[0] > 0) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ ShowTrollCombosMenu(client, GetClientUserId(target_list[0]));
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_ApplyUserSilent(int client, int args) {
+ if(args < 1) {
+ SilentMenuSelected[client] = true;
+ ShowTrollMenu(client, false);
+ }else{
+ char arg1[32], arg2[16];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ StringToLower(arg2);
+
+ static char target_name[MAX_TARGET_LENGTH];
+ int target_list[1], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_NO_MULTI,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ && target_list[0] > 0) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ SilentMenuSelected[client] = true;
+ if(args == 2) {
+ static char key[32];
+ for(int i = 0; i < categories.Length; i++) {
+ categories.GetString(i, key, sizeof(key));
+ if(StrEqual(key, arg2, false)) {
+ ShowTrollsForCategory(client, GetClientUserId(target_list[0]), i);
+ return Plugin_Handled;
+ }
+ }
+ ReplyToCommand(client, "[FTT] Unknown category: '%s'", arg2);
+ }
+ SetupCategoryMenu(client, GetClientUserId(target_list[0]));
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_ListModes(int client, int args) {
+ for(int i = 0; i <= MAX_TROLLS; i++) {
+ if(Trolls[i].hidden) continue;
+ ReplyToCommand(client, "%d. %s - %s", i, Trolls[i].name, Trolls[i].description);
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_ListTheTrolls(int client, int args) {
+ // View more info about a user
+ if(args == 1) {
+ char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+
+ static char target_name[MAX_TARGET_LENGTH];
+ int target_list[MAXPLAYERS], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MAXPLAYERS,
+ 0,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ || target_list[0] == 0) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ for(int p = 0; p < target_count; p++) {
+ int target = target_list[p];
+ if(IsPlayerAlive(target))
+ ReplyToCommand(client, "> Active Trolls for %N:", target);
+ else
+ ReplyToCommand(client, "> Active Trolls for %N: (Paused)", target);
+
+ if(IsFakeClient(target)) {
+ int player = GetRealClient(target);
+ if(player != -1) target = player;
+ }
+
+ for(int j = 1; j <= MAX_TROLLS; j++) {
+ if(Trolls[j].hidden) continue;
+ if(trollIds[j][0] != '\0' && IsTrollActive(target, trollIds[j])) {
+ if(Trolls[j].activeFlagClients[target] > 0) {
+ static char list[MAX_TROLL_FLAG_LENGTH*8]; //May in future need to up magic number 8 (supports 8 active flags )
+ static char buffer[MAX_TROLL_FLAG_LENGTH];
+ for(int i = 0; i < Trolls[j].flagNames.Length; i++) {
+ int a = (1 << i);
+ if(Trolls[j].activeFlagClients[target] & a) {
+ Trolls[j].flagNames.GetString(i, buffer, sizeof(buffer));
+ Format(list, sizeof(list), "%s%s;", list, buffer);
+ } else {
+ Trolls[j].flagNames.GetString(i, buffer, sizeof(buffer));
+ }
+ }
+ ReplyToCommand(client, "\"%s\" Flags: %s", trollIds[j], list);
+ } else
+ ReplyToCommand(client, trollIds[j]);
+ }
+ }
+ }
+ return Plugin_Handled;
+ }
+
+ int count = 0;
+ char[][] modeListArr = new char[MAX_TROLLS+1][MAX_TROLL_NAME_LENGTH];
+ static char modeList[255];
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) > 1 && IsAnyTrollActive(i)) {
+ if(IsFakeClient(i)) {
+ int player = GetRealClient(i);
+ if(player != -1) i = player;
+ }
+ int modeCount = 0;
+ for(int j = 1; j <= MAX_TROLLS; j++) {
+ if(trollIds[j][0] != '\0' && IsTrollActive(i, trollIds[j])) {
+ if(Trolls[j].activeFlagClients[i] > 0)
+ Format(modeListArr[modeCount], MAX_TROLL_NAME_LENGTH, "%s(%d)", trollIds[j], Trolls[j].activeFlagClients[i]);
+ else
+ strcopy(modeListArr[modeCount], MAX_TROLL_NAME_LENGTH, trollIds[j]);
+ modeCount++;
+ }
+ }
+
+ ImplodeStrings(modeListArr, modeCount, ", ", modeList, sizeof(modeList));
+ if(IsPlayerAlive(i))
+ ReplyToCommand(client, "%N | %s", i, modeList);
+ else
+ ReplyToCommand(client, "%N (Paused) | %s", i, modeList);
+ count++;
+ }
+ }
+ if(count == 0) {
+ ReplyToCommand(client, "No clients have a mode applied.");
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_MarkPendingTroll(int client, int args) {
+ if(args == 0) {
+ Menu menu = new Menu(ChooseMarkedTroll);
+ menu.SetTitle("Choose a troll to mark");
+ static char userid[8], display[16];
+ for(int i = 1; i < MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i)) {
+ if(GetUserAdmin(i) == INVALID_ADMIN_ID) {
+ Format(userid, sizeof(userid), "%d", GetClientUserId(i));
+ GetClientName(i, display, sizeof(display));
+ menu.AddItem(userid, display);
+ } else {
+ ReplyToCommand(client, "%N is an admin cannot be marked.", i);
+ }
+ }
+ }
+ menu.ExitButton = true;
+ menu.Display(client, 0);
+ } else {
+ static char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ char target_name[MAX_TARGET_LENGTH];
+ int target_list[1], target_count;
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_NO_MULTI , /* Only allow alive players */
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+ int target = target_list[0];
+ if (GetClientTeam(target) == 2) {
+ ToggleMarkPlayer(client, target);
+ } else {
+ ReplyToCommand(client, "Player does not exist or is not a survivor.");
+ }
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_FeedTheTrollMenu(int client, int args) {
+ ReplyToCommand(client, "sm_ftl [player(s)] - Lists all the active trolls on players. Will show flag names if a player is specified.");
+ ReplyToCommand(client, "sm_ftm - Lists all available trolls & descriptions");
+ ReplyToCommand(client, "sm_ftr - Resets target users' of any active trolls");
+ ReplyToCommand(client, "sm_fta [player] [category] - Apply a troll on a player, with optional shortcut to player and/or category");
+ ReplyToCommand(client, "sm_ftt - Shows this text");
+ ReplyToCommand(client, "sm_ftc - Will apply a punishment to the last crescendo/event activator");
+ ReplyToCommand(client, "sm_mark - Marks the user to be banned on disconnect, prevents their FF.");
+ return Plugin_Handled;
+}
+
+public Action Command_BotsAttack(int client, int args) {
+ if(args > 0) {
+ static char arg1[32], arg2[4];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+
+ int targetHP;
+ if(StringToIntEx(arg2, targetHP) == 0 || targetHP < 0 || targetHP > 100) {
+ ReplyToCommand(client, "Invalid target HP value. Must be between 0 and 100");
+ return Plugin_Handled;
+ }
+
+ int target_list[1], target_count;
+ static char target_name[MAX_TARGET_LENGTH];
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_ALIVE | COMMAND_FILTER_NO_MULTI,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ int target = target_list[0];
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsFakeClient(i) && GetClientTeam(i) == 2) {
+ if(!SetBotTarget(target, i, targetHP, 80)) {
+ ReplyToCommand(client, "%N could not target %s", i, target_name);
+ }
+ }
+ }
+ ShowActivity(client, "set all bots to attack %s", target_name);
+ } else {
+ ReplyToCommand(client, "syntax: sm_bots_attack [target-hp]");
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_Stagger(int client, int args) {
+ if(args > 0) {
+ static char arg1[32];
+ GetCmdArg(1, arg1, sizeof(arg1));
+
+ int target_list[MAXPLAYERS], target_count;
+ static char target_name[MAX_TARGET_LENGTH];
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ MaxClients,
+ COMMAND_FILTER_ALIVE,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ for(int i = 0; i < target_count; i++) {
+ L4D_StaggerPlayer(target_list[i], target_list[i], NULL_VECTOR);
+ }
+ } else {
+ ReplyToCommand(client, "syntax: sm_stagger ");
+ }
+ return Plugin_Handled;
+}
+
+public Action Command_SmartCharge(int client, int args) {
+ if(args > 0) {
+ static char arg1[32], arg2[8];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ int timeout = StringToInt(arg2);
+ if(timeout == 0) timeout = 15;
+
+ int target_list[1], target_count;
+ static char target_name[MAX_TARGET_LENGTH];
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_ALIVE | COMMAND_FILTER_NO_MULTI,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ if(pdata[target_list[0]].smartChargeActivator > 0) {
+ ReplyToCommand(client, "Target already has auto smart charge enabled");
+ } else {
+ pdata[target_list[0]].smartChargeAttempts = 0;
+ pdata[target_list[0]].smartChargeMaxAttempts = timeout;
+ pdata[target_list[0]].smartChargeActivator = GetClientUserId(client);
+ CreateTimer(1.0, Timer_CheckForChargerOpportunity, GetClientUserId(target_list[0]), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ ShowActivity(client, "Enabling smart auto-charge on %N for %d seconds", target_list[0], timeout);
+ }
+ } else {
+ ReplyToCommand(client, "syntax: sm_smartcharge [timeout or default 10s]");
+ }
+ return Plugin_Handled;
+}
+
+Action Command_HealTarget(int client, int args) {
+ if(args > 0) {
+ char arg1[32], arg2[4];
+ GetCmdArg(1, arg1, sizeof(arg1));
+ GetCmdArg(2, arg2, sizeof(arg2));
+ int target_list[1], target_count;
+ static char target_name[MAX_TARGET_LENGTH];
+ bool tn_is_ml;
+ if ((target_count = ProcessTargetString(
+ arg1,
+ client,
+ target_list,
+ 1,
+ COMMAND_FILTER_ALIVE | COMMAND_FILTER_NO_MULTI | COMMAND_FILTER_NO_IMMUNITY,
+ target_name,
+ sizeof(target_name),
+ tn_is_ml)) <= 0
+ ) {
+ /* This function replies to the admin with a failure message */
+ ReplyToTargetError(client, target_count);
+ return Plugin_Handled;
+ }
+
+ int target = target_list[0];
+ int targetUserId = GetClientUserId(target);
+ if(targetUserId == healTargetPlayer) {
+ ShowActivity(client, "cleared bots healing for %N", target);
+ StopHealingBots();
+ } else {
+ healTargetPlayer = targetUserId;
+ CreateTimer(2.0, Timer_UpdateHealTargetPos, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+
+ int limit = StringToInt(arg2);
+ bool addBots = limit < 0;
+ if(limit < 0) limit = -limit;
+ else if(limit == 0) limit = MaxClients;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2 && IsFakeClient(i)) {
+ int kit = GetPlayerWeaponSlot(i, 3);
+ if(kit > 0) {
+ GetEntityClassname(kit, arg1, sizeof(arg1));
+ if(StrEqual(arg1, "weapon_first_aid_kit")) {
+ pdata[i].flags |= view_as(Flag_IsTargettingHealer);
+
+ if(--limit == 0) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(addBots && limit > 0) {
+ wasAbmAutoHard = hAbmAutoHard.IntValue;
+ hAbmAutoHard.IntValue = 0;
+ CreateTimer(0.2, Timer_SpawnHealBots, limit, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
+ }
+ ShowActivity(client, "made all bots heal %N", target);
+ wasSbFixEnabled = hSbFixEnabled.BoolValue;
+ hSbFixEnabled.BoolValue = false;
+ }
+ } else {
+ ReplyToCommand(client, "Usage: /healbots [# of bots or 0 for all]");
+ }
+ return Plugin_Handled;
+}
+Action Command_SetReverseFF(int client, int args) {
+ if(args < 2) {
+ ReplyToCommand(client, "Usage: sm_rff [fire/explosion]*");
+ return Plugin_Handled;
+ }
+ char arg[32];
+ GetCmdArg(1, arg, sizeof(arg));
+ int target = GetSinglePlayer(client, arg, COMMAND_FILTER_NO_BOTS);
+ if(target <= 0) {
+ return Plugin_Handled;
+ }
+ GetCmdArg(1, arg, sizeof(arg));
+ GetCmdArg(2, arg, sizeof(arg));
+ int flag = -1;
+ if(StrEqual(arg, "0") || StrEqual(arg, "0.0")) {
+ flag = 8;
+ } else if(StrEqual(arg, "2")) {
+ flag = 2;
+ } else if(StrEqual(arg, "0.5") || StrEqual(arg, ".5")) {
+ flag = 4;
+ } else if(StrEqual(arg, "3")) {
+ flag = 8;
+ } else if(StrEqual(arg, "1")) {
+ flag = 1;
+ } else {
+ ReplyToCommand(client, "Unsupported amount. Possible values: 0, 2, 0.5, 3, 1");
+ return Plugin_Handled;
+ }
+ // args are 1-indexed so <=
+ for(int i = 3; i <= args; i++) {
+ GetCmdArg(i, arg, sizeof(arg));
+ if(arg[0] == 'f') {
+ flag |= 32;
+ } else if(arg[0] == 'e') {
+ flag |= 64;
+ } else {
+ ReplyToCommand(client, "Unknown arg: %s", arg);
+ }
+
+ }
+ ApplyTroll(target, "Reverse FF", client, TrollMod_Constant, flag);
+ return Plugin_Handled;
+}
+
+Action Command_SetMagnetShortcut(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_magnet ");
+ return Plugin_Handled;
+ }
+ char arg[32];
+ GetCmdArg(1, arg, sizeof(arg));
+ int target = GetSinglePlayer(client, arg, COMMAND_FILTER_NO_BOTS);
+ if(target <= 0) {
+ return Plugin_Handled;
+ }
+ ShowTrollsForCategory(client, GetClientUserId(target), 0);
+ return Plugin_Handled;
+}
+Action Command_CarSplat(int client, int args) {
+ if(args < 1) {
+ ReplyToCommand(client, "Usage: sm_magnet [top/front/back]");
+ return Plugin_Handled;
+ }
+ char arg[32];
+ GetCmdArg(1, arg, sizeof(arg));
+ int target = GetSinglePlayer(client, arg, COMMAND_FILTER_ALIVE);
+ if(target <= 0) {
+ return Plugin_Handled;
+ }
+ if(args == 2) {
+ GetCmdArg(2, arg, sizeof(arg));
+ float speed = 450.0;
+ if(args == 3) {
+ GetCmdArg(3, arg, sizeof(arg));
+ speed = StringToFloat(arg);
+ if(speed <= 0.0) speed = 450.0;
+ }
+ if(StrEqual(arg, "top")) {
+ SpawnCarOnPlayer(target);
+ } else if(StrEqual(arg, "front")) {
+ SpawnCarToPlayer(target, speed);
+ } else if(StrEqual(arg, "back")) {
+ SpawnCarToPlayer(target, -speed);
+ } else {
+ ReplyToCommand(client, "Invalid direction: top/front/back or blank for menu");
+ return Plugin_Handled;
+ }
+ LogAction(client, target, "spawned car on/in %s of \"%L\"", arg, target);
+ ShowActivity(client, "spawned car (%s) of %N", arg, target);
+ } else {
+ Troll troll;
+ GetTroll("Car Splat", troll);
+ ShowSelectFlagMenu(client, GetClientUserId(target), view_as(TrollMod_Instant), troll);
+ }
+ return Plugin_Handled;
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/events.inc b/scripting/include/feedthetrolls/events.inc
new file mode 100644
index 0000000..fb85a37
--- /dev/null
+++ b/scripting/include/feedthetrolls/events.inc
@@ -0,0 +1,1108 @@
+public void OnConfigsExecuted() {
+ hSbFixEnabled = FindConVar("sb_fix_enabled");
+ hAbmAutoHard = FindConVar("abm_autohard");
+}
+
+public void OnMapStart() {
+ if(hBotReverseFFDefend.IntValue > 0) hSbFriendlyFire.BoolValue = true;
+ AddFileToDownloadsTable("sound/custom/meow1.mp3");
+ PrecacheSound("custom/meow1.mp3");
+ AddFileToDownloadsTable("sound/custom/woof1.mp3");
+ PrecacheSound("custom/woof1.mp3");
+
+
+ lastButtonUser = -1;
+ HookEntityOutput("func_button", "OnPressed", Event_ButtonPress);
+ CreateTimer(MAIN_TIMER_INTERVAL_S, Timer_Main, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ PrecacheSound("player/footsteps/clown/concrete1.wav");
+ PrecacheSound("weapons/ceda_jar/ceda_jar_explode.wav");
+ PrecacheSound("weapons/molotov/molotov_detonate_1.wav");
+
+ PrecacheModel(MODEL_CAR);
+
+ g_spSpawnQueue.Clear();
+ spIsActive = false;
+ //CreateTimer(30.0, Timer_AutoPunishCheck, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+}
+public void OnClientPutInServer(int client) {
+ pdata[client].pendingTrollBan = 0;
+ pdata[client].shootAtTarget = 0;
+ fAntiRushFrequencyCounter[client] = 0.0;
+ if(IsTrollActive(client, "Voice Mute"))
+ BaseComm_SetClientMute(client, true);
+ SDKHook(client, SDKHook_OnTakeDamage, Event_TakeDamage);
+ SDKHook(client, SDKHook_OnTakeDamageAlive, NerfGun_OnTakeDamage);
+}
+
+public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
+ if(spIsActive || g_iPendingSurvivorAdd) {
+ int userid = event.GetInt("userid");
+ CreateTimer(0.1, Timer_CheckSpecial, userid);
+ }
+}
+
+
+
+public void OnEntityCreated(int entity, const char[] classname) {
+ if(entity >= MaxClients) {
+ if(StrEqual(classname, "infected", false))
+ SDKHook(entity, SDKHook_OnTakeDamageAlive, NerfGun_OnTakeDamage);
+ else if(StrEqual(classname, "prop_physics")) {
+ HookSingleEntityOutput(entity, "OnHitByTank", OnCarHitByTank);
+ } else if(StrEqual(classname, "prop_car_alarm")) {
+ HookSingleEntityOutput(entity, "OnHitByTank", OnCarHitByTank);
+ } else if(StrEqual(classname, "tank_rock") || StrContains(classname, "_projectile", true) > -1 ) {
+ RequestFrame(EntityCreateCallback, entity);
+ }
+ }
+}
+
+void OnCarHitByTank(const char[] output, int caller, int activator, float delay) {
+ entLastHeight[activator] = -10000.0;
+ CreateTimer(0.1, Timer_WaitForApex, EntIndexToEntRef(activator), TIMER_REPEAT);
+}
+
+void EntityCreateCallback(int entity) {
+ if(!HasEntProp(entity, Prop_Send, "m_hOwnerEntity") || !IsValidEntity(entity)) return;
+ static char class[16];
+
+ static int badThrowID;
+ if(badThrowID == 0) badThrowID = GetTrollID("Bad Throw");
+
+ GetEntityClassname(entity, class, sizeof(class));
+ int entOwner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
+ if(entOwner > 0 && entOwner <= MaxClients) {
+ if(Trolls[badThrowID].IsActive(entOwner)) {
+ static float pos[3];
+ GetClientEyePosition(entOwner, pos);
+ if(Trolls[badThrowID].activeFlagClients[entOwner] & 1 && StrEqual(class, "vomitjar_projectile", true)) {
+ RemoveEntity(entity);
+ if(hBadThrowHitSelf.FloatValue > 0.0 && GetRandomFloat() <= hBadThrowHitSelf.FloatValue) {
+ L4D_CTerrorPlayer_OnVomitedUpon(entOwner, entOwner);
+ EmitSoundToAll("weapons/ceda_jar/ceda_jar_explode.wav", entOwner);
+ FindClosestClient(entOwner, false, pos);
+ }
+ SpawnItem("vomitjar", pos);
+ } else if(Trolls[badThrowID].activeFlagClients[entOwner] & 2 && StrEqual(class, "molotov_projectile", true)) {
+ // Burn them if no one near :)
+ if(hBadThrowHitSelf.FloatValue > 0.0 && GetRandomFloat() <= hBadThrowHitSelf.FloatValue) {
+ GetClientAbsOrigin(entOwner, pos);
+ // Kill molotov if too close to a player, else teleport to feet
+ if(IsAnyPlayerNear(entOwner, 500.0)) {
+ RemoveEntity(entity);
+ EmitSoundToAll("weapons/molotov/molotov_detonate_1.wav", entOwner);
+ } else {
+ float vel[3];
+ vel[2] -= 50.0;
+ pos[2] += 50.0;
+ TeleportEntity(entity, pos, NULL_VECTOR, vel);
+ }
+ } else {
+ SpawnItem("molotov", pos);
+ AcceptEntityInput(entity, "Kill");
+ }
+ } else if(Trolls[badThrowID].activeFlagClients[entOwner] & 3 && StrEqual(class, "pipe_bomb_projectile", true)) {
+ if(hBadThrowHitSelf.FloatValue > 0.0 && GetRandomFloat() <= hBadThrowHitSelf.FloatValue) {
+ TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
+ ExplodeProjectile(entity);
+ }
+ SpawnItem("pipe_bomb", pos);
+ }
+ return;
+ } else if(Trolls[t_slipperyShoesIndex].IsActive(entOwner)) {
+ if(Trolls[t_slipperyShoesIndex].activeFlagClients[entOwner] & 4) {
+ L4D_StaggerPlayer(entOwner, entOwner, NULL_VECTOR);
+ }
+ return;
+ }
+ }
+ entLastHeight[entity] = -10000.0;
+ CreateTimer(0.1, Timer_WaitForApex, EntIndexToEntRef(entity), TIMER_REPEAT);
+}
+
+enum ProjectileMagnetType {
+ ProjType_Specials = 1,
+ ProjType_Survivors = 2,
+ ProjType_Cars = 4,
+}
+
+
+
+public void Event_DoorToggle(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client && Trolls[t_slipperyShoesIndex].IsActive(client) && Trolls[t_slipperyShoesIndex].activeFlagClients[client] & 2) {
+ L4D_StaggerPlayer(client, client, NULL_VECTOR);
+ }
+}
+
+void Event_SecondaryHealthUsed(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client && Trolls[t_slipperyShoesIndex].IsActive(client) && Trolls[t_slipperyShoesIndex].activeFlagClients[client] & 8) {
+ L4D_StaggerPlayer(client, client, NULL_VECTOR);
+ }
+}
+
+static float SPIT_VEL[3] = { 0.0, 0.0, -1.0 };
+Action Timer_CheckSpecial(Handle h, int specialID) {
+ int special = GetClientOfUserId(specialID);
+ if(special == 0) return Plugin_Continue;
+ // Check if new player is the spawned special:
+ if(g_iPendingSurvivorAdd && GetClientTeam(special) == 2 && GetEntProp(special, Prop_Send, "m_humanSpectatorUserID") == 0) {
+ g_iPendingSurvivorAdd = false;
+ isCustomSurvivor[special] = true;
+ PrintToServer("EPI Debug: Custom Survivor %N", special);
+ } else if(spIsActive && IsFakeClient(special)) {
+ //g_iPendingSurvivorAdd
+ if(GetClientTeam(special) == 3) {
+ SpecialType type = view_as(GetEntProp(special, Prop_Send, "m_zombieClass"));
+ if(type == spActiveRequest.type) {
+ // Ignore any fake clients with 'Bot' in name
+ static char buf[32];
+ GetClientName(special, buf, sizeof(buf));
+ if(StrContains(buf, "bot", false) == -1) {
+ // Set the special's target and flags
+ pdata[special].attackerTargetUid = spActiveRequest.targetUserId;
+ pdata[special].specialAttackFlags = spActiveRequest.flags;
+ // Warp to the spawn location
+ TeleportEntity(special, spActiveRequest.position, spActiveRequest.angle, NULL_VECTOR);
+ // Kill on spawn if enabled
+ if(spActiveRequest.flags & view_as(SPI_KillOnSpawn)) {
+ if(type == Special_Spitter) {
+ // Bug fix, spitter drops small puddle, so we spawn our own
+ float pos[3];
+ GetClientEyePosition(special, pos);
+ L4D2_SpitterPrj(special, pos, SPIT_VEL);
+ }
+ RequestFrame(Frame_Boom, special);
+ }
+
+ // Special spawned, run the next in the queue:
+ g_iSpId++;
+ ProcessSpecialQueue();
+ }
+ }
+ }
+ }
+ return Plugin_Handled;
+}
+public void Frame_Boom(int special) {
+ SDKHooks_TakeDamage(special, special, special, 1000.0);
+}
+public void Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client > 0)
+ ResetClient(client, true);
+}
+
+public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
+ int userid = event.GetInt("userid");
+ int client = GetClientOfUserId(userid);
+ if(client > 0) {
+ if(pdata[client].attackerTargetUid > 0) {
+ // If special died, clear & subtract one from counter
+ pdata[client].attackerTargetUid = 0;
+ pdata[client].specialAttackFlags = 0;
+ } else {
+ // If player died, stop the targetting
+ for(int i = 1; i <= MaxClients; i++) {
+ if(pdata[i].attackerTargetUid == userid) {
+ pdata[i].attackerTargetUid = 0;
+ pdata[i].specialAttackFlags = 0;
+ break;
+ }
+ }
+ }
+ }
+}
+public Action Event_WeaponReload(int weapon) {
+ int client = GetEntPropEnt(weapon, Prop_Send, "m_hOwner");
+ if(client > 0 && IsTrollActive(client, "Gun Jam")) {
+ if(GetRandomFloat() < 0.10) { //10% chance gun jams
+ return Plugin_Stop;
+ }
+ }
+ return Plugin_Continue;
+}
+public Action L4D2_CGasCan_EventKilled(int gascan, int &inflictor, int &attacker) {
+ static int noButtonPressIndex;
+ if(!noButtonPressIndex) noButtonPressIndex = GetTrollID("No Button Touchie");
+ if(attacker > 0 && attacker <= MaxClients) {
+ if(Trolls[noButtonPressIndex].IsActive(attacker)) {
+ if(Trolls[noButtonPressIndex].activeFlagClients[attacker] & 1) {
+ return Plugin_Handled;
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[attacker] & 2) {
+ L4D_CTerrorPlayer_OnVomitedUpon(attacker, attacker);
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[attacker] & 4) {
+ L4D_SetPlayerIncapacitatedState(attacker, true);
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[attacker] & 8) {
+ ServerCommand("sm_slay #%d", GetClientUserId(attacker));
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[attacker] & 16) {
+ float speed = GetEntPropFloat(attacker, Prop_Send, "m_flLaggedMovementValue");
+ if(speed > 0.9) speed = 0.80;
+ speed -= 5.0;
+ SetEntPropFloat(attacker, Prop_Send, "m_flLaggedMovementValue", speed);
+ PrintToConsoleAdmins("[FTT] NoButtonTouchie: %N speed is now %f", speed);
+ }
+ }
+ lastButtonUser = attacker;
+ }
+ return Plugin_Continue;
+}
+public Action Event_ButtonPress(const char[] output, int entity, int client, float delay) {
+ static int noButtonPressIndex;
+ if(!noButtonPressIndex) noButtonPressIndex = GetTrollID("No Button Touchie");
+ if(client > 0 && client <= MaxClients) {
+ if(Trolls[noButtonPressIndex].IsActive(client)) {
+ if(Trolls[noButtonPressIndex].activeFlagClients[client] & 1) {
+ AcceptEntityInput(entity, "Lock");
+ RequestFrame(Frame_ResetButton, entity);
+ return Plugin_Handled;
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[client] & 2) {
+ L4D_CTerrorPlayer_OnVomitedUpon(client, client);
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[client] & 4) {
+ L4D_SetPlayerIncapacitatedState(client, true);
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[client] & 8) {
+ ServerCommand("sm_slay #%d", GetClientUserId(client));
+ }
+ if(Trolls[noButtonPressIndex].activeFlagClients[client] & 16) {
+ float speed = GetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue");
+ if(speed > 0.9) speed = 0.80;
+ speed -= 5.0;
+ SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", speed);
+ PrintToConsoleAdmins("[FTT] NoButtonTouchie: %N speed is now %f", speed);
+ }
+ }
+ lastButtonUser = client;
+ }
+ return Plugin_Continue;
+}
+
+public void Frame_ResetButton(int entity) {
+ AcceptEntityInput(entity, "Unlock");
+}
+
+public void Event_PanicEventCreate(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(client) {
+ lastButtonUser = client;
+ }
+}
+public void Event_CarAlarm(Event event, const char[] name, bool dontBroadcast) {
+ int user = event.GetInt("userid");
+ int client = GetClientOfUserId(user);
+ if(client) {
+ PrintToChatAll("%N has alerted the horde!", client);
+ CreateTimer(0.2, RushPlayer, user);
+ CreateTimer(0.6, RushPlayer, user);
+ CreateTimer(1.5, RushPlayer, user);
+ }
+ //Ignore car alarms for autopunish
+ lastButtonUser = -1;
+}
+public Action RushPlayer(Handle h, int user) {
+ L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", user, 15000);
+ return Plugin_Handled;
+}
+public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
+ static int spMagnetID, tankMagnetID;
+ if(spMagnetID == 0) spMagnetID = GetTrollID("Special Magnet");
+ if(tankMagnetID == 0) tankMagnetID = GetTrollID("Tank Magnet");
+
+ L4D2Infected class = view_as(GetEntProp(attacker, Prop_Send, "m_zombieClass"));
+ // Check for any existing victims
+ int existingTarget = GetClientOfUserId(pdata[attacker].attackerTargetUid);
+ if(existingTarget > 0) {
+ if(IsPlayerAlive(existingTarget)) {
+ // Insta-specials ALWAYS target, if target has any attackers remaining
+ if(pdata[attacker].specialAttackFlags & view_as(SPI_AlwaysTarget)) {
+ curTarget = existingTarget;
+ return Plugin_Changed;
+ }
+ // Stop targetting if no longer magnetted:
+ if(class == L4D2Infected_Tank) {
+ if(!Trolls[tankMagnetID].IsActive(existingTarget) || !WillMagnetRun(Trolls[tankMagnetID], existingTarget)) return Plugin_Continue;
+ } else if(class != L4D2Infected_Tank) {
+ if(!Trolls[spMagnetID].IsActive(existingTarget) || !WillMagnetRun(Trolls[spMagnetID], existingTarget)) return Plugin_Continue;
+ }
+
+ // Only set target based on incap rules:
+ if(class == L4D2Infected_Tank && (!IsPlayerIncapped(existingTarget) || hMagnetTargetMode.IntValue & 2) && WillMagnetRun(Trolls[tankMagnetID], existingTarget)) {
+ curTarget = existingTarget;
+ return Plugin_Changed;
+ } else if(class != L4D2Infected_Tank && (!IsPlayerIncapped(existingTarget) || hMagnetTargetMode.IntValue & 1) && WillMagnetRun(Trolls[spMagnetID], existingTarget)) {
+ curTarget = existingTarget;
+ return Plugin_Changed;
+ }
+ } else {
+ if(pdata[attacker].specialAttackFlags & view_as(SPI_KillOnTargetIncap)) {
+ ForcePlayerSuicide(attacker);
+ }
+ PrintToServer("target (%N) not alive, resetting target for %d", existingTarget, attacker)
+ pdata[attacker].attackerTargetUid = 0;
+ }
+ }
+
+ // If no existing target, find closest valid victim
+ float closestDistance, survPos[3], spPos[3];
+ GetClientAbsOrigin(attacker, spPos);
+ int closestClient = -1;
+
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
+ if(class == L4D2Infected_Tank) {
+ if(!Trolls[tankMagnetID].IsActive(i) || !WillMagnetRun(Trolls[tankMagnetID], i)) continue;
+ } else if(class != L4D2Infected_Tank) {
+ if(!Trolls[spMagnetID].IsActive(i) || !WillMagnetRun(Trolls[spMagnetID], i)) continue;
+ }
+
+ if(IsPlayerIncapped(i)) {
+ if(class == L4D2Infected_Tank && hMagnetTargetMode.IntValue & 2 == 0) continue;
+ if(class != L4D2Infected_Tank && hMagnetTargetMode.IntValue & 1 == 0) continue;
+ }
+
+ GetClientAbsOrigin(i, survPos);
+ float dist = GetVectorDistance(survPos, spPos, true);
+ if(dist < closestDistance || closestClient == -1) {
+ closestDistance = dist;
+ closestClient = i;
+ }
+ }
+ }
+
+ // If found, set, else just let game decide
+ if(closestClient > 0) {
+ pdata[attacker].attackerTargetUid = GetClientUserId(closestClient);
+ curTarget = closestClient;
+ return Plugin_Changed;
+ }
+ return Plugin_Continue;
+}
+
+bool WillMagnetRun(const Troll troll, int i) {
+ // In the case none of the flags are set, return true (100% chance)
+ // Some systems may give magnet w/ no flags
+ if(troll.activeFlagClients[i] == 0) return true;
+
+ float cChance = 1.0;
+ //Skip first bit as it is ('Always')
+ if(troll.activeFlagClients[i] & 2) // 2nd: 50%
+ cChance = 0.5;
+ else if(troll.activeFlagClients[i] & 4) //3rd: 10%
+ cChance = 0.1;
+ return GetRandomFloat() <= cChance;
+}
+
+public Action L4D2_OnEntityShoved(int client, int entity, int weapon, float vecDir[3], bool bIsHighPounce) {
+ if(client > 0 && client <= MaxClients) {
+ static int noShoveIndex;
+ if(noShoveIndex == 0) noShoveIndex == GetTrollID("No Shove");
+ if(Trolls[noShoveIndex].IsActive(client) && GetRandomFloat() < hShoveFailChance.FloatValue) {
+ float shoveTime = L4D2Direct_GetNextShoveTime(client);
+ L4D2Direct_SetNextShoveTime(client, shoveTime + 2.0);
+ return Plugin_Handled;
+ }
+ }
+ return Plugin_Continue;
+}
+
+public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs) {
+ if(client <= 0 || sArgs[0] == '@') return Plugin_Continue; //Ignore admin chat or console
+
+ static int honkID;
+ static int profanityID;
+ static int typooId;
+ if(honkID == 0) honkID = GetTrollID("Honk / Meow / Woof");
+ if(profanityID == 0) profanityID = GetTrollID("No Profanity");
+ if(typooId == 0) typooId = GetTrollID("Typoos");
+
+ if(Trolls[honkID].IsActive(client) && Trolls[honkID].activeFlagClients[client] & 1) {
+ // Honk Processing
+ static char strings[32][8];
+ int words = ExplodeString(sArgs, " ", strings, sizeof(strings), 5);
+
+ for(int i = 0; i < words; i++) {
+ // Strings should be padded by 7 characters (+ null term) to fill up 8 bytes
+ if(GetRandomFloat() <= 0.8) strings[i] = "honk ";
+ else strings[i] = "squeak ";
+ }
+ int length = 8 * words;
+ char[] message = new char[length];
+ ImplodeStrings(strings, 32, " ", message, length);
+ if(Trolls[honkID].activeFlagClients[client] & 1)
+ CPrintToChatAll("{blue}%N {default}: %s", client, message);
+ else {
+ CPrintToChat(client, "{blue}%N {default}: %s", client, message);
+ bool showOriginalToOthers = Trolls[honkID].activeFlagClients[client] & 4 != 0;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && i != client) {
+ if(showOriginalToOthers)
+ CPrintToChat(i, "{blue}%N {default}: %s", client, sArgs);
+ else
+ CPrintToChat(i, "{blue}%N {default}: %s", client, message);
+ }
+ }
+ }
+ PrintToServer("%N: %s", client, sArgs);
+ return Plugin_Handled;
+ } else if(IsTrollActive(client, "Reversed")) {
+ int length = strlen(sArgs);
+ char[] message = new char[length+1];
+ int j = 0;
+ for(int i = length - 1; i >= 0; i--) {
+ message[j++] = sArgs[i];
+ }
+ message[j] = '\0';
+ CPrintToChatAll("{blue}%N {default}: %s", client, message);
+ PrintToServer("%N: %s", client, sArgs);
+ return Plugin_Handled;
+ }else if(IsTrollActive(client, "iCantSpellNoMore")) {
+ int type = GetRandomInt(1, 14 + 3);
+ char letterSrc, replaceChar;
+ switch(type) {
+ case 1: {
+ letterSrc = 'e';
+ replaceChar = 'b';
+ }
+ case 2: {
+ letterSrc = 't';
+ replaceChar = 'e';
+ }
+ case 3: {
+ letterSrc = 'i';
+ replaceChar = 'e';
+ }
+ case 4: {
+ letterSrc = 'a';
+ replaceChar = 's';
+ }
+ case 5: {
+ letterSrc = 'u';
+ replaceChar = 'i';
+ }
+ case 6: {
+ letterSrc = '.';
+ replaceChar = '/';
+ }
+ case 7: {
+ letterSrc = 'm';
+ replaceChar = 'n';
+ }
+ case 8: {
+ letterSrc = 'n';
+ replaceChar = 'm';
+ }
+ case 9: {
+ letterSrc = 'l';
+ replaceChar = 'b';
+ }
+ case 10: {
+ letterSrc = 'l';
+ replaceChar = 'b';
+ }
+ case 11: {
+ letterSrc = 'h';
+ replaceChar = 'j';
+ }
+ case 12: {
+ letterSrc = 'o';
+ replaceChar = 'i';
+ }
+ case 13: {
+ letterSrc = 'e';
+ replaceChar = 'r';
+ }
+ case 14: {
+ letterSrc = 'w';
+ replaceChar = 'h';
+ }
+
+ default:
+ return Plugin_Continue;
+ }
+ int strLength = strlen(sArgs);
+ char[] newMessage = new char[strLength + 20];
+ int n = 0;
+ while (sArgs[n] != '\0') {
+ if(sArgs[n] == letterSrc) {
+ newMessage[n] = replaceChar;
+ }else{
+ newMessage[n] = sArgs[n];
+ }
+ n++;
+ }
+ PrintToServer("%N: %s", client, sArgs);
+ CPrintToChatAll("{blue}%N {default}: %s", client, newMessage);
+ return Plugin_Handled;
+ }else if(Trolls[profanityID].IsActive(client)) {
+ char strings[32][MAX_PHRASE_LENGTH];
+ static ArrayList phrases;
+ bool foundWord = false;
+ int words = ExplodeString(sArgs, " ", strings, 32, MAX_PHRASE_LENGTH);
+ // Replace all swear words
+ for(int i = 0; i < words; i++) {
+ phrases = GetPhrasesArray(strings[i]);
+ if(phrases != null && phrases.Length > 0) {
+ foundWord = true;
+ phrases.GetString(GetRandomInt(0, phrases.Length - 1), strings[i], MAX_PHRASE_LENGTH);
+ }
+ }
+ int length = MAX_PHRASE_LENGTH * words;
+ char[] message = new char[length];
+
+ if(foundWord) {
+ // Found at least one word, keep modified intact
+ ImplodeStrings(strings, 32, " ", message, length);
+ } else if(Trolls[profanityID].activeFlagClients[client] & 2) {
+ // Replace full message content if flag enabled
+ if(!fullMessagePhraseList) {
+ PrintToServer("[FTT] Error: Could not find full message phrases!!!");
+ return Plugin_Continue;
+ }
+ fullMessagePhraseList.GetString(GetRandomInt(0, fullMessagePhraseList.Length - 1), message, MAX_PHRASE_LENGTH);
+ } else {
+ // Flag off, keep original text
+ return Plugin_Continue;
+ }
+
+ if(Trolls[profanityID].activeFlagClients[client] & 8) { //If 'show original' enabled
+ CPrintToChat(client, "{blue}%N {default}: %s", client, sArgs);
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && i != client) {
+ CPrintToChat(i, "{blue}%N {default}: %s", client, message);
+ }
+ }
+ } else { //else show modified to all
+ CPrintToChatAll("{blue}%N {default}: %s", client, message);
+ }
+ // Print original in console no matter what
+ PrintToServer("%N: %s", client, sArgs);
+ return Plugin_Handled;
+ } else if(Trolls[typooId].IsActive(client)) {
+ char strings[32][MAX_TYPOS_LENGTH];
+ int words = ExplodeString(sArgs, " ", strings, 32, MAX_TYPOS_LENGTH);
+ // Replace all typos
+ static char typoReplacement[32];
+ for(int i = 0; i < words; i++) {
+ if(TYPOS_DICT.GetString(strings[i], typoReplacement, sizeof(typoReplacement))) {
+ strcopy(strings[i], MAX_TYPOS_LENGTH, typoReplacement);
+ }
+ }
+ int length = MAX_TYPOS_LENGTH * words;
+ char[] message = new char[length];
+ ImplodeStrings(strings, 32, " ", message, length);
+
+ CPrintToChatAll("{blue}%N {default}: %s", client, message);
+ PrintToServer("%N: %s", client, sArgs);
+ return Plugin_Handled;
+ }
+ return Plugin_Continue;
+}
+static char SMG[8] = "smg";
+static char AWP[16] = "sniper_awp";
+
+public Action Event_ItemPickup(int client, int weapon) {
+ static int NoPickupIndex;
+ if(NoPickupIndex == 0) NoPickupIndex = GetTrollID("No Pickup");
+ static int SpicyGasIndex;
+ if(SpicyGasIndex == 0) SpicyGasIndex = GetTrollID("Spicy Gas");
+ static int UziRulesIndex;
+ if(UziRulesIndex == 0) UziRulesIndex = GetTrollID("UziRules / AwpSmells");
+
+ static char wpnName[64];
+ if(Trolls[NoPickupIndex].IsActive(client)) {
+ int flags = Trolls[NoPickupIndex].activeFlagClients[client];
+ if(flags & 1 && GetPlayerWeaponSlot(client, view_as(L4DWeaponSlot_Primary)) == weapon) {
+ // No Primary
+ return Plugin_Handled;
+ } else if(flags & 2 && GetEntityClassname(weapon, wpnName, sizeof(wpnName)) && StrEqual(wpnName, "weapon_melee")) {
+ // No melee
+ return Plugin_Handled;
+ } else if(flags & 4 && GetPlayerWeaponSlot(client, view_as(L4DWeaponSlot_Grenade)) == weapon) {
+ // No throwables
+ return Plugin_Handled;
+ } else if(flags & 8 && GetEntityClassname(weapon, wpnName, sizeof(wpnName)) && StrEqual(wpnName, "weapon_first_aid_kit")) {
+ // No Kits
+ return Plugin_Handled;
+ } else if(flags & 16 && GetPlayerWeaponSlot(client, view_as(L4DWeaponSlot_Pills)) == weapon) {
+ // No Pills / Adr
+ return Plugin_Handled;
+ } else if(flags & 32 && GetEntityClassname(weapon, wpnName, sizeof(wpnName)) && StrEqual(wpnName, "weapon_gascan")) {
+ return Plugin_Handled;
+ }
+ } else if(Trolls[UziRulesIndex].IsActive(client) || IsTrollActive(client, "Primary Disable")) {
+ GetEdictClassname(weapon, wpnName, sizeof(wpnName));
+ if(strcmp(wpnName[7], "rifle") >= 0
+ || strcmp(wpnName[7], "smg") >= 0
+ || StrEqual(wpnName[7], "grenade_launcher")
+ || strcmp(wpnName[7], "sniper") > -1
+ || StrContains(wpnName, "shotgun") > -1
+ ) {
+ //If 4: Only UZI, if 5: Can't switch.
+ if(Trolls[UziRulesIndex].IsActive(client)) {
+ static char comp[16];
+ if(Trolls[UziRulesIndex].activeFlagClients[client] & 1)
+ strcopy(comp, sizeof(comp), SMG);
+ else
+ strcopy(comp, sizeof(comp), AWP);
+ static char currentWpn[32];
+ GetClientWeaponName(client, 0, currentWpn, sizeof(currentWpn));
+ if(StrEqual(wpnName[7], comp)) {
+ return Plugin_Continue;
+ } else if(StrEqual(currentWpn[7], comp)) {
+ return Plugin_Stop;
+ } else {
+ int flags = GetCommandFlags("give");
+ SetCommandFlags("give", flags & ~FCVAR_CHEAT);
+ FakeClientCommand(client, "give %s", comp);
+ SetCommandFlags("give", flags);
+ return Plugin_Stop;
+ }
+ } else if(IsTrollActive(client, "Primary Disable")) {
+ return Plugin_Stop;
+ }
+ }
+ } else if(Trolls[SpicyGasIndex].IsActive(client)) {
+ if(GetEntityClassname(weapon, wpnName, sizeof(wpnName))) {
+ float max = 1.0;
+ if(Trolls[SpicyGasIndex].activeFlagClients[client] & 2) max = 0.5;
+ else if(Trolls[SpicyGasIndex].activeFlagClients[client] & 4) max = 0.1;
+ if(GetRandomFloat() <= max) {
+ if(StrEqual(wpnName, "weapon_gascan")) {
+ AcceptEntityInput(weapon, "Ignite", client, client);
+ } else if(StrEqual(wpnName, "weapon_propanetank") || StrEqual(wpnName, "weapon_oxygentank")) {
+ ExplodeProjectile(weapon, false);
+ }
+ }
+ }
+ }
+ return Plugin_Continue;
+}
+
+public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
+ int healTarget = GetClientOfUserId(healTargetPlayer);
+ if(healTarget > 0 && pdata[client].flags & view_as(Flag_IsTargettingHealer) && healTarget != client) {
+ static float pos[3];
+ GetClientAbsOrigin(client, pos);
+ LookAtClient(client, healTarget);
+ if(GetVectorDistance(pos, healTargetPos, true) < 10000.0) {
+ if(GetClientAimTarget(client, true) == healTarget) {
+ buttons |= IN_ATTACK2;
+ return Plugin_Changed;
+ }
+ }
+ }
+
+ // If 'KillMeSoftly' activated:
+ if(pdata[client].flags & view_as(Flag_PendingItemGive) && !(buttons & IN_ATTACK2)) {
+ int target = GetClientAimTarget(client, true);
+ if(target > -1) {
+ ClientCommand(client, "slot5");
+ buttons |= IN_ATTACK2;
+ RequestFrame(StopItemGive, client);
+ return Plugin_Changed;
+ }
+ return Plugin_Continue;
+ }
+
+
+ if(pdata[client].shootAtTarget > 0 && (buttons & IN_ATTACK) == 0) {
+ if(GetClientAimTarget(client, true) == pdata[client].shootAtTarget) {
+ if(!IsActorBusy(client))
+ PerformScene(client, "PlayerLaugh");
+ buttons |= IN_ATTACK &~ (IN_RELOAD);
+ return Plugin_Changed;
+ } else {
+ if(!IsClientConnected(pdata[client].shootAtTarget)) {
+ pdata[client].shootAtTarget = 0;
+ } else {
+ LookAtClient(client, pdata[client].shootAtTarget);
+ }
+ }
+ }
+
+ // Inverted control code:
+ if(Trolls[t_invertedTrollIndex].IsActive(client)) {
+ if(buttons & IN_MOVELEFT || buttons & IN_MOVERIGHT) {
+ vel[1] = -vel[1];
+ }
+ if(buttons & IN_FORWARD || buttons & IN_BACK) {
+ vel[0] = -vel[0];
+ }
+ if(buttons & IN_JUMP) {
+ buttons = buttons & ~IN_JUMP | IN_DUCK;
+ } else if(buttons & IN_DUCK) {
+ buttons = buttons & ~IN_DUCK | IN_JUMP;
+ }
+ if(buttons & IN_RUN) {
+ buttons = buttons & ~IN_RUN | IN_WALK;
+ } else if(buttons & IN_WALK) {
+ buttons = buttons & ~IN_WALK | IN_RUN;
+ }
+ if(buttons & IN_RELOAD) {
+ buttons = buttons & ~IN_RELOAD | IN_ATTACK2;
+ } else if(buttons & IN_ATTACK2) {
+ buttons = buttons & ~IN_ATTACK2 | IN_RELOAD;
+ }
+ return Plugin_Changed;
+ }
+ return Plugin_Continue;
+}
+
+public Action NerfGun_OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype) {
+ static int nerfGunIndex;
+ if(nerfGunIndex == 0) nerfGunIndex = GetTrollID("Nerf Gun");
+ if(attacker > 0 && attacker <= MaxClients && GetClientTeam(attacker) == 2 && Trolls[nerfGunIndex].IsActive(attacker)) {
+ damage = 0.0;
+ return Plugin_Changed;
+ }
+ return Plugin_Continue;
+}
+
+// Only triggered for players, victim is 0 < victim <= MaxClients
+Action Event_TakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype) {
+ // Ignore passing bots from FF
+ if(attacker > 0 && attacker <= MaxClients) {
+ if(GetClientTeam(attacker) == 4 && IsFakeClient(attacker)) return Plugin_Continue;
+ }
+ // Boost all damage no matter what
+ if(Trolls[t_damageBoostIndex].IsActive(victim)) {
+ damage * 2;
+ return Plugin_Changed;
+ }
+ // Only apply for when attackers are players
+ if(attacker > 0 && attacker <= MaxClients && IsClientInGame(attacker) && IsPlayerAlive(attacker)) {
+ if(pdata[attacker].shootAtTarget == victim) return Plugin_Continue;
+ bool isSameTeam = GetClientTeam(attacker) == GetClientTeam(victim);
+ if(pdata[attacker].pendingTrollBan > 0 && isSameTeam) {
+ return Plugin_Stop;
+ }
+ if(Trolls[t_slotRouletteIndex].IsActive(victim) && GetURandomFloat() < 0.10) {
+ SetSlot(victim, -1);
+ }
+ if(victim != attacker) {
+ if(damage > 0.0 && Trolls[t_slipperyShoesIndex].IsActive(victim) && Trolls[t_slipperyShoesIndex].activeFlagClients[victim] & 16) {
+ L4D_StaggerPlayer(victim, victim, NULL_VECTOR);
+ }
+ if(isSameTeam && Trolls[t_reverseFFIndex].IsActive(attacker)) {
+ // Should this be applied? (as in no FF granted)
+ bool disableFF = false;
+ if(damagetype == DMG_BURN) {
+ disableFF = Trolls[t_reverseFFIndex].activeFlagClients[attacker] & 32 != 0;
+ } else if(damagetype == DMG_BLAST) {
+ disableFF = Trolls[t_reverseFFIndex].activeFlagClients[attacker] & 64 != 0;
+ } else {
+ // Does not run if DMG_BURN or DMG_BLAST
+ disableFF = true;
+ }
+
+ if(disableFF) {
+ float returnDmg = damage; //default is 1:1
+ if(Trolls[t_reverseFFIndex].activeFlagClients[attacker] & 2) {
+ returnDmg *= 2.0;
+ } else if(Trolls[t_reverseFFIndex].activeFlagClients[attacker] & 4) {
+ returnDmg /= 2.0;
+ } else if(Trolls[t_reverseFFIndex].activeFlagClients[attacker] & 8) {
+ returnDmg = 0.0;
+ } else if(Trolls[t_reverseFFIndex].activeFlagClients[attacker] & 16) {
+ returnDmg *= 3.0;
+ }
+ SDKHooks_TakeDamage(attacker, attacker, attacker, returnDmg, damagetype, -1);
+ damage = 0.0;
+ return Plugin_Changed;
+ }
+ }
+ // Only retailate if 2 (anyone) or 1 and they aren't an admin. If we are also a bot.
+ if(IsFakeClient(victim) && (hBotReverseFFDefend.IntValue == 2 || GetUserAdmin(attacker) == INVALID_ADMIN_ID)) {
+ // If the attacker is not a bot and on our team, then retaliate
+ if(!IsFakeClient(attacker) && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
+ if(hBotDefendChance.IntValue >= GetURandomFloat()) {
+ if(pdata[victim].shootAtTarget == attacker) {
+ pdata[attacker].shootAtTargetHealth -= RoundToCeil(damage);
+ pdata[victim].shootAtLoops += 4;
+ return Plugin_Continue;
+ } else if(pdata[victim].shootAtTarget > 0) {
+ // Don't switch, wait for timer to stop
+ return Plugin_Continue;
+ }
+ SetBotTarget(attacker, victim, GetClientRealHealth(attacker) - RoundFloat(damage));
+ }
+ }
+ }
+ }
+ // If FF is fire / blast, allow through unless its from a bot, then stop.
+ // Prevents players with no FF from lighting team on fire and disconnecting, making their new bot do the FF
+ if(damagetype & DMG_BURN || damagetype & DMG_BLAST) {
+ if(IsFakeClient(attacker)) return Plugin_Handled;
+ else return Plugin_Continue;
+ }
+ // Don't let bots do damage to the wrong targets if they are "defending" themselves
+ if(hBotReverseFFDefend.IntValue > 0 && IsFakeClient(attacker) && pdata[attacker].shootAtTarget == 0 && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) return Plugin_Stop;
+ }
+ return Plugin_Continue;
+}
+
+public Action OnVocalizeCommand(int client, const char[] vocalize, int initiator) {
+ static int vocalGagID;
+ static int noRushingUsID;
+ if(vocalGagID == 0) vocalGagID = GetTrollID("Vocalize Gag");
+ if(noRushingUsID == 0) noRushingUsID = GetTrollID("No Rushing Us");
+ if(Trolls[noRushingUsID].IsActive(client) && (StrEqual(vocalize, "PlayerHurryUp") || StrEqual(vocalize, "PlayerYellRun") || StrEqual(vocalize, "PlayerMoveOn") || StrEqual(vocalize, "PlayerLeadOn"))) {
+ noRushingUsSpeed[client] -= 0.01;
+ if(noRushingUsSpeed[client] < 0.05) {
+ noRushingUsSpeed[client] = 0.05;
+ }
+ SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", noRushingUsSpeed[client]);
+ PrintToConsoleAdmins("[FTT] NoRushingUs: Dropping speed for %N (now %.1f%)", client, noRushingUsSpeed[client] * 100.0);
+ }
+ if(Trolls[t_slotRouletteIndex].IsActive(client) && GetURandomFloat() < 0.10) {
+ SetSlot(client, -1);
+ }
+ if(Trolls[vocalGagID].IsActive(client)) {
+ return Plugin_Handled;
+ }
+ return Plugin_Continue;
+}
+
+#if defined _sceneprocessor_included
+public void OnSceneStageChanged(int scene, SceneStages stage) {
+ if(stage == SceneStage_Spawned) {
+ static int vocalGagID, vocalizeSpecials;
+ if(vocalizeSpecials == 0) vocalizeSpecials = GetTrollID("Vocalize Specials");
+
+
+ int activator = GetSceneInitiator(scene);
+ if(activator > 0 && activator <= MaxClients) {
+ if(Trolls[vocalizeSpecials].IsActive(activator)) {
+ static char sceneFile[32];
+ GetSceneFile(scene, sceneFile, sizeof(sceneFile));
+ if(StrContains(sceneFile, "warnboomer") > -1) {
+ SpawnSpecialForTarget(Special_Boomer, activator, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget));
+ } else if(StrContains(sceneFile, "warnhunter") > -1) {
+ SpawnSpecialForTarget(Special_Hunter, activator, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget));
+ } else if(StrContains(sceneFile, "warnsmoker") > -1) {
+ SpawnSpecialForTarget(Special_Smoker, activator, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget));
+ } else if(StrContains(sceneFile, "warnspitter") > -1) {
+ SpawnSpecialForTarget(Special_Spitter, activator, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget));
+ } else if(StrContains(sceneFile, "warnjockey") > -1) {
+ SpawnSpecialForTarget(Special_Jockey, activator, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget));
+ } else if(StrContains(sceneFile, "warncharger") > -1) {
+ SpawnSpecialForTarget(Special_Charger, activator, view_as(Special_OnTarget) | view_as(Special_AlwaysTarget));
+ }
+
+ if(Trolls[vocalizeSpecials].activeFlagClients[activator] & 1) {
+ CancelScene(scene);
+ }
+ } else if(Trolls[vocalGagID].IsActive(activator)) {
+ CancelScene(scene);
+ }
+ }
+ }
+}
+#endif
+
+public Action SoundHook(int clients[MAXPLAYERS], int& numClients, char sample[PLATFORM_MAX_PATH], int& entity, int& channel, float& volume, int& level, int& pitch, int& flags, char soundEntry[PLATFORM_MAX_PATH], int& seed) {
+ static int honkID;
+ static int vocalGagID;
+ if(honkID == 0) honkID = GetTrollID("Honk / Meow / Woof");
+ if(vocalGagID == 0) vocalGagID = GetTrollID("Vocalize Gag");
+
+ if(lastButtonUser > 0 && IsClientConnected(lastButtonUser) && !IsFakeClient(lastButtonUser) && StrEqual(sample, "npc/mega_mob/mega_mob_incoming.wav")) {
+ PrintToConsoleAll("CRESCENDO STARTED BY %N", lastButtonUser);
+ #if defined DEBUG
+ PrintToChatAll("CRESCENDO STARTED BY %N", lastButtonUser);
+ #endif
+
+ lastCrescendoUser = lastButtonUser;
+ if(IsPlayerFarDistance(lastButtonUser, AUTOPUNISH_FLOW_MIN_DISTANCE)) {
+ PrintChatToAdmins("Autopunishing player %N for activation of event far from team", lastButtonUser);
+ ShowActivityEx(0, "[FTT] ", "activated autopunish for crescendo activator %N (auto)", lastButtonUser);
+ LogAction(0, lastButtonUser, "\"%L\" automatic autopunish for crescendo activator \"%L\"", 0, lastButtonUser);
+ ActivateAutoPunish(lastButtonUser);
+ }
+ lastButtonUser = -1;
+ }else if(numClients > 0 && entity > 0 && entity <= MaxClients) {
+ if(StrContains(sample, "survivor\\voice") > -1) {
+ if(Trolls[honkID].IsActive(entity)) {
+ if(Trolls[honkID].activeFlagClients[entity] & 1)
+ strcopy(sample, sizeof(sample), "player/footsteps/clown/concrete1.wav");
+ else if(Trolls[honkID].activeFlagClients[entity] & 2)
+ strcopy(sample, sizeof(sample), "custom/meow1.mp3");
+ else if(Trolls[honkID].activeFlagClients[entity] & 4)
+ strcopy(sample, sizeof(sample), "custom/woof1.mp3");
+ else
+ return Plugin_Continue;
+ return Plugin_Changed;
+ } else if(Trolls[vocalGagID].IsActive(entity)) {
+ if(Trolls[vocalGagID].activeFlagClients[entity] & 2) {
+ clients[0] = entity;
+ numClients = 1;
+ return Plugin_Changed;
+ }
+ return Plugin_Handled;
+ }
+ }
+ }
+ return Plugin_Continue;
+}
+
+public void Event_WitchVictimSet(Event event, const char[] name, bool dontBroadcast) {
+ static int witchTrollID;
+ if(witchTrollID == 0) witchTrollID = GetTrollID("Witch Magnet");
+
+ int witch = event.GetInt("witchid"), closestClient = -1;
+ float closestDistance, survPos[3], witchPos[3];
+ GetEntPropVector(witch, Prop_Send, "m_vecOrigin", witchPos);
+
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
+ //Ignore incapped players if hWitchIgnoreIncapp turned on:
+ if(IsPlayerIncapped(i) && ~hMagnetTargetMode.IntValue & 4) {
+ continue;
+ }
+
+ if(Trolls[witchTrollID].IsActive(i)) {
+ GetClientAbsOrigin(i, survPos);
+ float dist = GetVectorDistance(survPos, witchPos, true);
+ if(closestClient == -1 || dist < closestDistance) {
+ closestDistance = dist;
+ closestClient = i;
+ }
+ }
+ }
+ }
+
+ if(closestClient > 0) {
+ DataPack pack;
+ CreateDataTimer(0.1, Timer_NextWitchSet, pack);
+ pack.WriteCell(GetClientUserId(closestClient));
+ pack.WriteCell(witch);
+ CreateDataTimer(0.2, Timer_NextWitchSet, pack);
+ pack.WriteCell(GetClientUserId(closestClient));
+ pack.WriteCell(witch);
+ }
+}
+
+public Action L4D2_MeleeGetDamageForVictim(int client, int weapon, int victim, float &damage) {
+ static int dullMeleeID;
+ if(!dullMeleeID) dullMeleeID = GetTrollID("Dull Melee");
+ if(Trolls[dullMeleeID].IsActive(client)) {
+ float max = 1.0;
+ if(Trolls[dullMeleeID].activeFlagClients[client] & 2) max = 0.5;
+ else if(Trolls[dullMeleeID].activeFlagClients[client] & 4) max = 0.1;
+ if(GetRandomFloat() <= max) {
+ damage = 0.0;
+ return Plugin_Changed;
+ }
+ }
+ return Plugin_Continue;
+}
+
+stock int FindClosestVisibleClient(int source) {
+ static float pos[3], ang[3];
+ GetClientEyePosition(source, pos);
+ GetClientEyeAngles(source, ang);
+ TR_TraceRayFilter(pos, ang, MASK_VISIBLE, RayType_Infinite, TraceEntityFilterPlayer, source);
+ return TR_GetEntityIndex();
+}
+
+public bool TraceEntityFilterPlayer(int entity, int mask, any data) {
+ return data != entity && entity <= MaxClients && GetClientTeam(entity) == 2 && IsPlayerAlive(entity);
+}
+
+// TODO: Increase the frequency of spawns the longer they are in antirush. Possibly increase int and decrease over time
+public Action OnAntiRush(int client, int &type, float distance) {
+ if(client && client > 0 && client <= MaxClients && type == 3 && !IsFakeClient(client) && IsPlayerAlive(client) && !IsPlayerIncapped(client)) {
+ if(GetGameTime() - fLastAntiRushEvent[client] > hAntirushBaseFreq.FloatValue - fAntiRushFrequencyCounter[client]) {
+ if(fAntiRushFrequencyCounter[client] < hAntirushBaseFreq.FloatValue) {
+ fAntiRushFrequencyCounter[client] += hAntirushIncFreq.FloatValue;
+ }
+ SpecialType special = view_as(GetRandomInt(1,6));
+ fLastAntiRushEvent[client] = GetGameTime();
+ SpawnSpecialForTarget(special, client, view_as(Special_SpawnDirectOnFailure | Special_OnTarget | Special_AlwaysTarget));
+ PrintToConsoleAll("[FTT] Spawning anti-rush special on %N (dist=%f) (special=%s)", client, distance, SPECIAL_NAMES[view_as(special)-1]);
+ }
+ }
+ return Plugin_Continue;
+}
+
+Action Timer_DecreaseAntiRush(Handle h) {
+ for(int i = 1; i <= MaxClients; i++) {
+ if(fAntiRushFrequencyCounter[i] > 1.0) {
+ fAntiRushFrequencyCounter[i]--;
+ } else {
+ fAntiRushFrequencyCounter[i] = 0.0;
+ }
+ }
+ return Plugin_Continue;
+}
+
+public void L4D2_CInsectSwarm_CanHarm_Post(int acid, int spitter, int entity) {
+ if(entity <= MaxClients)
+ pdata[entity].lastInSpitTime = GetGameTime();
+}
+
+public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("userid"));
+ if(Trolls[t_stickyGooIndex].IsActive(client)) {
+ int flags = Trolls[t_stickyGooIndex].activeFlagClients[client];
+ float movement = 0.0;
+ if(flags & 1) movement = 0.9;
+ else if(flags & 2) movement = 0.8;
+ else if(flags & 4) movement = 0.7;
+ else if(flags & 8) movement = 0.5;
+ else if(flags & 16) movement = 0.3;
+ SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", movement);
+ pdata[client].lastInSpitTime = GetGameTime();
+ if(~pdata[client].flags & view_as(Flag_HasSpitTimer)) {
+ CreateTimer(0.2, Timer_CheckIsInSpit, GetClientUserId(client), TIMER_REPEAT);
+ pdata[client].flags |= view_as(Flag_HasSpitTimer);
+ }
+ }
+
+}
+
+public void Event_BotPlayerSwap(Event event, const char[] name, bool dontBroadcast) {
+ //Player replaced their idle bot
+ int client = GetClientOfUserId(event.GetInt("player"));
+ if(client > 0) {
+ bool debug_hadTroll = false;
+ for(int i = 1; i <= MAX_TROLLS; i++) {
+ if(Trolls[i].IsActive(client) && Trolls[i].HasMod(TrollMod_Constant)) { //Add activeFlagClients >= 0 check possibly?
+ ApplyAffect(client, Trolls[i], -1, TrollMod_Constant, Trolls[i].activeFlagClients[client]);
+ debug_hadTroll = true;
+ }
+ }
+ if(debug_hadTroll)
+ PrintToServer("[FTT] Re-applied trolls for was-idle player %N", client);
+ }
+}
+
+void Event_HealSuccess(Event event, const char[] name, bool dontBroadcast) {
+ int userid = event.GetInt("subject");
+ int client = GetClientOfUserId(userid);
+ if(client > 0 && userid == healTargetPlayer) {
+ StopHealingBots();
+ }
+}
+
+public void L4D_OnVomitedUpon_Post(int victim, int attacker, bool boomerExplosion) {
+ if(Trolls[t_slotRouletteIndex].IsActive(victim) && GetURandomFloat() < 0.10) {
+ SetSlot(victim, -1);
+ }
+}
+void Event_Incapped(Event event, const char[] name, bool dontBroadcast) {
+ int client = GetClientOfUserId(event.GetInt("subject"));
+ int attacker = GetClientOfUserId(event.GetInt("attacker"));
+ if(client > 0 && attacker > 0 && attacker <= MaxClients && IsFakeClient(attacker) && GetClientTeam(attacker) == 3) {
+ if(pdata[attacker].specialAttackFlags & view_as(SPI_KillOnTargetIncap)) {
+ ForcePlayerSuicide(attacker);
+ }
+ }
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/menus.inc b/scripting/include/feedthetrolls/menus.inc
new file mode 100644
index 0000000..5c62874
--- /dev/null
+++ b/scripting/include/feedthetrolls/menus.inc
@@ -0,0 +1,549 @@
+public int Insta_PlayerHandler(Menu menu, MenuAction action, int client, int param2) {
+ /* If an option was selected, tell the client about the item. */
+ if (action == MenuAction_Select) {
+ static char info[16];
+ menu.GetItem(param2, info, sizeof(info));
+
+ static char str[2][8];
+ ExplodeString(info, "|", str, 2, 8, false);
+
+ int userid = StringToInt(str[0]);
+ int instaMode = StringToInt(str[1]);
+ ShowInstaSpecialChooser(client, userid, instaMode);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+void ShowInstaSpecialChooser(int activator, int userid, int instaMode) {
+ Menu menu = new Menu(Insta_SpecialHandler);
+ menu.SetTitle("Choose a Insta-Special™");
+ char data[16];
+ for(int i = 1; i <= 8; i++) {
+ Format(data, sizeof(data), "%d|%d|%d", userid, instaMode, i);
+ menu.AddItem(data, SPECIAL_NAMES[i-1]);
+ }
+ menu.ExitButton = true;
+ menu.Display(activator, 0);
+}
+
+public int Insta_SpecialHandler(Menu menu, MenuAction action, int client, int param2) {
+ /* If an option was selected, tell the client about the item. */
+ if (action == MenuAction_Select) {
+ static char info[16];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[3][8];
+ ExplodeString(info, "|", str, 3, 8, false);
+ int userid = StringToInt(str[0]);
+ int target = GetClientOfUserId(userid);
+ bool inFace = StrEqual(str[1], "1");
+ int specialInt = StringToInt(str[2]);
+ if(specialInt < 0 || specialInt > 8) {
+ ReplyToCommand(client, "Invalid special id");
+ return 0;
+ }
+ SpecialType special = view_as(specialInt);
+ if(inFace) {
+ if(SpawnSpecialForTarget(special, target, view_as(Special_OnTarget) | view_as(Special_SpawnDirectOnFailure) | view_as(Special_AlwaysTarget))) {
+ LogAction(client, target, "\"%L\" spawned Insta-%s™ on \"%L\"", client, SPECIAL_NAMES[specialInt-1], target);
+ CShowActivityEx(client, "[FTT] ", "spawned {olive}Insta-%s™{default} on {olive}%N", SPECIAL_NAMES[specialInt-1], target);
+ } else {
+ ReplyToCommand(client, "Could not spawn special.");
+ }
+ } else {
+ if(SpawnSpecialForTarget(special, target, view_as(Special_AlwaysTarget))) {
+ CShowActivityEx(client, "[FTT] ", "spawned {green}Insta-%s™{default} near {green}%N", SPECIAL_NAMES[specialInt-1], target);
+ LogAction(client, target, "\"%L\" spawned Insta-%s™ near \"%L\"", client, SPECIAL_NAMES[specialInt-1], target);
+ } else {
+ ReplyToCommand(client, "Could not spawn special.");
+ }
+ }
+ ShowInstaSpecialChooser(client, userid, inFace);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+
+public int ChooseMarkedTroll(Menu menu, MenuAction action, int activator, int param2) {
+ if (action == MenuAction_Select) {
+ static char info[16];
+ menu.GetItem(param2, info, sizeof(info));
+ int target = GetClientOfUserId(StringToInt(info));
+ ToggleMarkPlayer(activator, target);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+public int ChoosePlayerHandler(Menu menu, MenuAction action, int param1, int param2) {
+ /* If an option was selected, tell the client about the item. */
+ if (action == MenuAction_Select) {
+ static char info[8];
+ menu.GetItem(param2, info, sizeof(info));
+ int userid = StringToInt(info);
+ int victim = GetClientOfUserId(userid);
+
+ if(victim == 0) {
+ ReplyToCommand(param1, "FTT: Could not acquire player");
+ return 0;
+ }
+
+ SetupCategoryMenu(param1, userid);
+ } else if (action == MenuAction_End) {
+ delete menu;
+ }
+ return 0;
+}
+
+public int ChoosePlayerHandlerForCombos(Menu menu, MenuAction action, int client, int param2) {
+ if (action == MenuAction_Select) {
+ static char info[8];
+ menu.GetItem(param2, info, sizeof(info));
+ int userid = StringToInt(info);
+ int victim = GetClientOfUserId(userid);
+
+ if(victim == 0) {
+ ReplyToCommand(victim, "FTT: Could not acquire player");
+ return 0;
+ }
+
+ ShowTrollCombosMenu(client, userid);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+public int ChooseComboHandler(Menu menu, MenuAction action, int client, int param2) {
+ if (action == MenuAction_Select) {
+ static char info[16];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[2][8];
+ ExplodeString(info, "|", str, 2, 8, false);
+ int userid = StringToInt(str[0]);
+ int victim = GetClientOfUserId(userid);
+ int comboID = StringToInt(str[1]);
+
+ if(victim == 0) {
+ ReplyToCommand(client, "FTT: Could not acquire player");
+ return 0;
+ }
+
+ static TrollCombo combo;
+ combos.GetArray(comboID, combo, sizeof(combo));
+ combo.Activate(client, victim);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+static int iMenuVictimID[MAXPLAYERS+1];
+public int ChooseCategoryHandler(Menu menu, MenuAction action, int param1, int param2) {
+ if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack)
+ ShowTrollMenu(param1, false);
+ else if (action == MenuAction_Select) {
+ static char info[32];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[2][8];
+ ExplodeString(info, "|", str, 2, 8, false);
+ int userid = StringToInt(str[0]);
+ int victim = GetClientOfUserId(userid);
+ if(victim == 0) {
+ ReplyToCommand(param1, "FTT/ChooseCategoryHandler: Could not acquire player");
+ return 0;
+ }
+
+ iMenuVictimID[param1] = userid;
+ int category = StringToInt(str[1]);
+
+ // Reset troll:
+ if(category == -1) {
+ ApplyTroll(GetClientOfUserId(userid), "Reset User", param1, TrollMod_Instant);
+ return 0;
+ }
+
+ ShowTrollsForCategory(param1, userid, category);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+public int ChooseModeMenuHandler(Menu menu, MenuAction action, int param1, int param2) {
+ if (action == MenuAction_Cancel) {
+ if(param2 == MenuCancel_ExitBack) {
+ if(iMenuVictimID[param1] == 0) {
+ ReplyToCommand(param1, "FTT/ChooseModeMenuHandler: Could not acquire player");
+ }
+ SetupCategoryMenu(param1, iMenuVictimID[param1]);
+ }
+ } else if (action == MenuAction_Select) {
+ static char info[32];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[2][8];
+ ExplodeString(info, "|", str, 2, 8, false);
+ int userid = StringToInt(str[0]);
+ int client = GetClientOfUserId(userid);
+ if(client == 0) {
+ ReplyToCommand(param1, "FTT: Could not acquire player");
+ return 0;
+ }
+
+ int keyIndex = StringToInt(str[1]);
+ static Troll troll;
+ GetTrollByKeyIndex(keyIndex, troll);
+ //If troll has multiple flags, prompt:
+ if(StrEqual(troll.name, "Throw It All")) {
+ // Setup menu to call itself, but with an extra data point
+ ShowThrowItAllMenu(param1, userid);
+ } else if(!troll.IsActive(client) && troll.HasMod(TrollMod_Instant) && troll.HasMod(TrollMod_Constant)) {
+ Menu modiferMenu = new Menu(ChooseTrollModiferHandler);
+ Format(info, sizeof(info), "%s: Choose Modifier", troll.name);
+ modiferMenu.SetTitle(info);
+
+ Format(info, sizeof(info), "%d|%d|1", userid, keyIndex);
+ modiferMenu.AddItem(info, "Activate Once");
+ Format(info, sizeof(info), "%d|%d|2", userid, keyIndex);
+ modiferMenu.AddItem(info, "Activate Periodically");
+ Format(info, sizeof(info), "%d|%d|3", userid, keyIndex);
+ modiferMenu.AddItem(info, "Activate Periodically & Instantly");
+
+ modiferMenu.ExitButton = true;
+ modiferMenu.Display(param1, 0);
+ } else if(!troll.IsActive(client) && troll.HasFlags()) {
+ ShowSelectFlagMenu(param1, userid, -1, troll);
+ } else {
+ TrollEffectResponse response = troll.Activate(client, param1);
+ // Only show menu if success or error, not TE_Menu
+ if(response != TE_Menu)
+ ShowTrollsForCategory(param1, userid, troll.categoryID);
+ }
+
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+public int ChooseClumsySlotHandler(Menu menu, MenuAction action, int param1, int param2) {
+ if (action == MenuAction_Select) {
+ char info[32];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[2][8];
+ ExplodeString(info, "|", str, 2, 8, false);
+ int userid = StringToInt(str[0]);
+ int client = GetClientOfUserId(userid);
+ int slot = StringToInt(str[1]);
+ if(client == 0) {
+ ReplyToCommand(param1, "FTT: Could not acquire player");
+ return 0;
+ }else if(slot == -1) {
+ for(int i = 0; i <= 4; i++) {
+ ThrowItemToPlayer(client, param1, i);
+ }
+ } else if(slot == -2) {
+ ShowThrowItAllMenu(param1, userid);
+ } else {
+ if(!GetClientWeaponNameSmart(client, slot, info, sizeof(info))) {
+ strcopy(info, sizeof(info), "-unk-");
+ }
+ CShowActivityEx(param1, "[FTT] ", "activated troll {yellow}Throw It All{default} ({olive}%s|%d{default}) for \"%N\"", info, slot, client);
+ LogAction(param1, client, "\"%L\" activated troll \"Throw It All\" (%s) for \"%L\". ", param1, info, client);
+ ThrowItemToPlayer(client, param1, slot);
+ }
+
+ ShowThrowItAllMenu(param1, userid);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+public int ChooseTrollModiferHandler(Menu menu, MenuAction action, int param1, int param2) {
+ if (action == MenuAction_Select) {
+ static char info[16];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[3][8];
+ ExplodeString(info, "|", str, 3, 8, false);
+ int userid = StringToInt(str[0]);
+ int client = GetClientOfUserId(userid);
+ int keyIndex = StringToInt(str[1]);
+ int modifiers = StringToInt(str[2]);
+
+ if(client == 0) {
+ ReplyToCommand(param1, "FTT: Could not acquire player");
+ return 0;
+ }
+
+ static Troll troll;
+ GetTrollByKeyIndex(keyIndex, troll);
+
+ if(!troll.IsActive(client) && troll.HasFlags()) {
+ // Show flag selection if troll is not enabled already
+ ShowSelectFlagMenu(param1, userid, modifiers, troll);
+ } else {
+ TrollEffectResponse response;
+ if(modifiers == 1 || modifiers == 3)
+ response = troll.Activate(client, param1, TrollMod_Instant);
+ if(modifiers == 2 || modifiers == 3)
+ response = troll.Activate(client, param1, TrollMod_Constant);
+ if(response != TE_Menu)
+ ShowTrollsForCategory(param1, userid, troll.categoryID);
+ }
+
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+public int ChooseTrollFlagHandler(Menu menu, MenuAction action, int param1, int param2) {
+ if (action == MenuAction_Select) {
+ static char info[32];
+ menu.GetItem(param2, info, sizeof(info));
+ static char str[6][8];
+ ExplodeString(info, "|", str, 6, 8, false);
+ int userid = StringToInt(str[0]);
+ int client = GetClientOfUserId(userid);
+ int keyIndex = StringToInt(str[1]);
+ int modifiers = StringToInt(str[2]);
+ int flags = StringToInt(str[3]);
+ int index = StringToInt(str[4]);
+ bool isDone = StringToInt(str[5]) == 1; // 0 = cont, 1 = done
+
+ if(client == 0) {
+ ReplyToCommand(param1, "FTT: Could not acquire player");
+ return 0;
+ }
+
+ static Troll troll;
+ GetTrollByKeyIndex(keyIndex, troll);
+
+ // If told to go to next prompt, find the next VALID prompt
+ // Valid prompt is one where the required flags for it, are active
+
+ if(isDone || index == -1) {
+ int nextIndex = GetNextPrompt(troll, flags, index);
+ // If there is a prompt available, show it, else fall down
+ if(nextIndex != -1) {
+ ShowSelectFlagMenu(param1, userid, modifiers, troll, flags, nextIndex);
+ return 0;
+ }
+ // else fall through & apply
+ } else {
+ ShowSelectFlagMenu(param1, userid, modifiers, troll, flags, index);
+ return 0;
+ }
+
+ TrollEffectResponse response;
+ // Done with prompts, apply flags & modifiers
+ if(modifiers > 0) {
+ if(modifiers & view_as(TrollMod_Instant))
+ response = troll.Activate(client, param1, TrollMod_Instant, flags);
+ if(modifiers & view_as(TrollMod_Constant))
+ response = troll.Activate(client, param1, TrollMod_Constant, flags);
+ } else {
+ response = troll.Activate(client, param1, TrollMod_Invalid, flags);
+ }
+ // Jump back to selection screen
+ if(response != TE_Menu)
+ ShowTrollsForCategory(param1, userid, troll.categoryID);
+ } else if (action == MenuAction_End)
+ delete menu;
+ return 0;
+}
+
+
+public void StopItemGive(int client) {
+ pdata[client].flags &= ~view_as(Flag_PendingItemGive);
+}
+
+void SetupCategoryMenu(int client, int victimUserID) {
+ iMenuVictimID[client] = victimUserID;
+ Menu categoryMenu = new Menu(ChooseCategoryHandler);
+ static char category[64], id[16];
+ // Title with [ in name cause failure
+ Format(category, sizeof(category), "Choose troll category");
+ categoryMenu.SetTitle(category);
+
+ Format(id, sizeof(id), "%d|-1", victimUserID);
+ categoryMenu.AddItem(id, "Reset User");
+ for(int i = 0; i < categories.Length; i++) {
+ categories.GetString(i, category, sizeof(category));
+ Format(id, sizeof(id), "%d|%d", victimUserID, i);
+ categoryMenu.AddItem(id, category);
+ }
+ categoryMenu.ExitButton = true;
+ categoryMenu.ExitBackButton = true;
+ categoryMenu.Display(client, 0);
+}
+
+void ShowTrollCombosMenu(int client, int victimUserID) {
+ Menu comboMenu = new Menu(ChooseComboHandler);
+ static char id[32];
+ Format(id, sizeof(id), "Choose troll combo");
+ comboMenu.SetTitle(id);
+
+ static TrollCombo combo;
+
+ if(combos.Length == 0) {
+ ReplyToCommand(client, "FTT: No troll combos available");
+ return;
+ }
+
+ for(int i = 0; i < combos.Length; i++) {
+ combos.GetArray(i, combo, sizeof(combo));
+ Format(id, sizeof(id), "%d|%d", victimUserID, i);
+ comboMenu.AddItem(id, combo.name);
+ }
+
+ comboMenu.ExitButton = true;
+ comboMenu.ExitBackButton = true;
+ comboMenu.Display(client, 0);
+}
+
+void ShowTrollMenu(int client, bool isComboList) {
+ Menu menu = isComboList ? new Menu(ChoosePlayerHandlerForCombos) : new Menu(ChoosePlayerHandler);
+ menu.SetTitle("Choose a player to troll");
+ // If player idle, say they are survivor
+ int clientTeam = GetClientTeam(client);
+ if(clientTeam < 2) {
+ if(L4D_IsPlayerIdle(client)) clientTeam = 2;
+ }
+
+ static char userid[8], display[64];
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && (hAllowEnemyTeam.BoolValue || GetClientTeam(i) == clientTeam)) {
+ IntToString(GetClientUserId(i), userid, sizeof(userid));
+ GetMenuDisplayName(i, display, sizeof(display));
+ menu.AddItem(userid, display);
+ }
+ }
+ menu.ExitButton = true;
+ menu.Display(client, 0);
+}
+
+void ShowTrollsForCategory(int client, int userid, int category) {
+ static char info[32];
+ Menu trollMenu = new Menu(ChooseModeMenuHandler);
+ GetCategory(category, info, sizeof(info));
+ Format(info, sizeof(info), "Category: %s", info);
+ trollMenu.SetTitle(info);
+
+ static Troll troll;
+
+ int victim = GetClientOfUserId(userid);
+
+ // Add all menus that have same category ID to list
+ static char name[MAX_TROLL_NAME_LENGTH+8];
+ for(int i = 0; i < trollKV.Size; i++) {
+ GetTrollByKeyIndex(i, troll);
+ // If troll is hidden and using normal menu, do not show
+ if(troll.hidden && !SilentMenuSelected[client]) continue;
+ if(troll.categoryID == category) {
+ Format(info, sizeof(info), "%d|%d", userid, i);
+ if(troll.IsActive(victim)) {
+ Format(name, sizeof(name), "%s (Active)", troll.name);
+ trollMenu.AddItem(info, name);
+ } else
+ trollMenu.AddItem(info, troll.name);
+ }
+ }
+ trollMenu.ExitButton = true;
+ trollMenu.ExitBackButton = true;
+ trollMenu.Display(client, 0);
+}
+
+// Called with defaults on start, then recalled by ChooseTrollFlagHandler until prompt selection finished
+void ShowSelectFlagMenu(int activator, int victimUserID, int modifiers, Troll troll, int prevFlags = -1, int promptIndex = 0) {
+ static char info[MAX_TROLL_NAME_LENGTH+16]; //victimUSERID|trollID|modifiers|flags||flagIndex
+ static char name[32];
+
+ Menu flagMenu = new Menu(ChooseTrollFlagHandler);
+
+ TrollFlagPrompt prompt;
+ troll.GetFlagPrompt(promptIndex, prompt);
+ prompt.GetPromptText(info, sizeof(info));
+
+ Format(info, sizeof(info), "%s: %s", troll.name, info);
+ flagMenu.SetTitle(info);
+
+ if(prompt.multiselect) {
+ if(prevFlags == -1) prevFlags = prompt.defaults;
+
+ Format(info, sizeof(info), "%d|%d|%d|%d|%d|1", victimUserID, troll.id, modifiers, prevFlags, promptIndex);
+ flagMenu.AddItem(info, "Apply / Next Prompt");
+
+ for(int i = 0; i < troll.flagNames.Length; i++) {
+ int a = 1 << i;
+ if(prompt.flags & a) {
+ troll.flagNames.GetString(i, name, sizeof(name));
+ // If flag is enabled, show indication (On)
+ if(prevFlags > 0 && prevFlags & a)
+ Format(name, sizeof(name), "%s ✓", name);
+ int newFlags = prevFlags ^ a; //Toggle the flag instead of setting like below, as it's toggleable here
+ Format(info, sizeof(info), "%d|%d|%d|%d|%d|0", victimUserID, troll.id, modifiers, newFlags, promptIndex);
+ flagMenu.AddItem(info, name);
+ }
+ }
+ } else {
+ // Single choice only
+ if(prevFlags == -1) prevFlags = 0;
+ for(int i = 0; i < troll.flagNames.Length; i++) {
+ int a = 1 << i;
+ if(prompt.flags & a) {
+ troll.flagNames.GetString(i, name, sizeof(name));
+ // Add (default) indicator
+
+ if(prompt.defaults & a)
+ Format(name, sizeof(name), "%s (default)", name);
+ int newFlags = prevFlags | a; //Set flag with any from previous prompts
+ Format(info, sizeof(info), "%d|%d|%d|%d|%d|1", victimUserID, troll.id, modifiers, newFlags, promptIndex);
+ flagMenu.AddItem(info, name);
+ }
+ }
+ }
+ flagMenu.ExitButton = true;
+ flagMenu.Display(activator, 0);
+}
+
+void ShowThrowItAllMenu(int client, int userid) {
+ static char info[32];
+ Menu itmMenu = new Menu(ChooseClumsySlotHandler);
+ itmMenu.SetTitle("Choose Item To Throw");
+
+ static char itmName[32];
+ Format(info, sizeof(info), "%d|-2", userid);
+ itmMenu.AddItem(info, "Refresh");
+
+ Format(info, sizeof(info), "%d|-1", userid);
+ itmMenu.AddItem(info, "All Items");
+
+ int victim = GetClientOfUserId(userid);
+ if(victim == 0) {
+ ReplyToCommand(client, "FTT: Could not acquire player");
+ return;
+ }
+
+ // Grab all the items the player has, add to menu
+ for(int slot = 0; slot <= 5; slot++) {
+ int item = GetClientWeaponNameSmart2(victim, slot, itmName, sizeof(itmName));
+ if(item > -1) {
+ Format(info, sizeof(info), "%d|%d", userid, slot);
+ itmMenu.AddItem(info, itmName);
+ }
+ }
+
+ itmMenu.ExitButton = true;
+ itmMenu.Display(client, 0);
+}
+
+int GetNextPrompt(Troll troll, int flags, int currentPrompt = 0) {
+ static TrollFlagPrompt prompt;
+ //If this prompt requires flags but they don't exist, skip to next that is valid or be done:
+ if(currentPrompt + 1 == troll.flagPrompts.Length) return -1;
+ for(int i = currentPrompt + 1; i < troll.flagPrompts.Length; i++) {
+ troll.GetFlagPrompt(i, prompt);
+ if(flags & prompt.requireFlags == prompt.requireFlags) {
+ return i;
+ }
+ }
+ // No suitable prompts found, mark it as done:
+ return -1;
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/misc.inc b/scripting/include/feedthetrolls/misc.inc
new file mode 100644
index 0000000..d3336c3
--- /dev/null
+++ b/scripting/include/feedthetrolls/misc.inc
@@ -0,0 +1,580 @@
+#define AUTOPUNISH_FLOW_MIN_DISTANCE 5000.0
+#define AUTOPUNISH_MODE_COUNT 3
+// #define DEBUG_PHRASE_LOAD 1
+
+void ActivateAutoPunish(int client) {
+ if(hAutoPunish.IntValue & 2 == 2)
+ ApplyTroll(client, "Special Magnet", 0, TrollMod_Constant);
+ if(hAutoPunish.IntValue & 1 == 1)
+ ApplyTroll(client, "Tank Magnet", 0, TrollMod_Constant);
+ if(hAutoPunish.IntValue & 8 == 8)
+ ApplyTroll(client, "Vomit Player", 0, TrollMod_Instant);
+ else if(hAutoPunish.IntValue & 4 == 4)
+ ApplyTroll(client, "Swarm", 0, TrollMod_Instant);
+ if(hAutoPunishExpire.IntValue > 0) {
+ CreateTimer(60.0 * hAutoPunishExpire.FloatValue, Timer_ResetAutoPunish, GetClientOfUserId(client));
+ }
+}
+
+// NOTE: Only supports one target at a time, stored globally
+bool SetWitchTarget(int witch, int target) {
+ #if defined _actions_included
+ g_iWitchAttackVictim = target;
+ BehaviorAction action = ActionsManager.GetAction(witch, "WitchBehavior");
+ if(action == INVALID_ACTION || action.Child == INVALID_ACTION) {
+ return false;
+ }
+ action = action.Child;
+ action.OnUpdate = OnWitchActionUpdate;
+ return true;
+ #else
+ PrintToServer("[FTT] SetWitchTarget() called when behaviors plugin not found");
+ return false;
+ #endif
+}
+
+bool ToggleMarkPlayer(int client, int target) {
+ if(pdata[target].pendingTrollBan > 0) {
+ pdata[target].pendingTrollBan = 0;
+ LogAction(client, target, "\"%L\" unmarked \"%L\" as troll", client, target);
+ ShowActivityEx(client, "[FTT] ", "unmarked %N as troll", target);
+ return true;
+ }else{
+ bool isClientAdmin = GetUserAdmin(client) != INVALID_ADMIN_ID;
+ if(!isClientAdmin) {
+ ReplyToCommand(client, "cannot mark %N as troll as you are not an admin.", target);
+ return false;
+ }
+ bool isTargetAdmin = GetUserAdmin(target) != INVALID_ADMIN_ID;
+ if(isTargetAdmin) {
+ ReplyToCommand(client, "cannot mark %N as troll as they are an admin.", target);
+ return false;
+ }
+
+ Call_StartForward(g_PlayerMarkedForward);
+ Call_PushCell(client);
+ Call_PushCell(target);
+ Call_Finish();
+ pdata[target].pendingTrollBan = GetClientUserId(client);
+ EnableTroll(target, "No Profanity");
+ LogAction(client, target, "\"%L\" marked \"%L\" as troll", client, target);
+ ShowActivityEx(client, "[FTT] ", "marked %N as troll", target);
+ return true;
+ }
+}
+
+// Finds the survivor bot that took over an idle player
+int GetSpectatorClient(int bot) {
+ if(!IsFakeClient(bot)) return -1;
+ static char netclass[16];
+ GetEntityNetClass(bot, netclass, sizeof(netclass));
+ if(strcmp(netclass, "SurvivorBot") == 0 ) {
+ int user = GetEntProp(bot, Prop_Send, "m_humanSpectatorUserID");
+ if(user > 0) return GetClientOfUserId(user);
+ }
+ return -1;
+}
+
+stock bool IsPlayerIncapped(int client) {
+ return GetEntProp(client, Prop_Send, "m_isIncapacitated") == 1;
+}
+
+#define MAX_TYPOS_LENGTH 16
+StringMap TYPOS_DICT;
+void LoadTypos() {
+ TYPOS_DICT.Clear();
+ char sPath[PLATFORM_MAX_PATH];
+ BuildPath(Path_SM, sPath, sizeof(sPath), "data/ftt_typos.txt");
+
+ if(!FileExists(sPath)) {
+ PrintToServer("[FTT] Missing typos list: data/ftt_typos.txt");
+ return;
+ }
+ File file = OpenFile(sPath, "r", false, NULL_STRING);
+ if(file == null) {
+ PrintToServer("[FTT] Cannot open: data/ftt_typos.txt");
+ return;
+ }
+
+
+ char buffer[140], key[32];
+ while(file.ReadLine(buffer, sizeof(buffer))) {
+ int index = SplitString(buffer, " ", key, sizeof(key));
+ TYPOS_DICT.SetString(key, buffer[index]);
+ }
+
+ file.Close();
+}
+
+#define MAX_PHRASES_PER_WORD 8
+#define MAX_PHRASE_LENGTH 191
+StringMap REPLACEMENT_PHRASES;
+ArrayList fullMessagePhraseList;
+
+/* Example:
+exWord
+{
+ "1" "phrase1"
+ "2" "phrase2"
+}
+*/
+void LoadPhrases() {
+ KeyValues kv = new KeyValues("Phrases");
+ ArrayList phrases = new ArrayList(ByteCountToCells(MAX_PHRASE_LENGTH));
+
+ char sPath[PLATFORM_MAX_PATH];
+ BuildPath(Path_SM, sPath, sizeof(sPath), "data/ftt_phrases.cfg");
+
+ if(!FileExists(sPath) || !kv.ImportFromFile(sPath)) {
+ delete kv;
+ PrintToServer("[FTT] Could not load phrase list from data/ftt_phrases.cfg");
+ return;
+ }
+ char word[32];
+ char phrase[MAX_PHRASE_LENGTH];
+ // Go through all the words:
+ kv.GotoFirstSubKey();
+ int i = 0;
+ char buffer[4];
+ do {
+ kv.GetSectionName(word, sizeof(word));
+ StringToLower(word);
+ phrases.Clear();
+ for(;;) {
+ IntToString(++i, buffer, sizeof(buffer));
+ kv.GetString(buffer, phrase, MAX_PHRASE_LENGTH, "_null");
+ if(strcmp(phrase, "_null") == 0) break;
+ phrases.PushString(phrase);
+ }
+ i = 0;
+ if(StrEqual(word, "_full message phrases")) {
+ fullMessagePhraseList = phrases.Clone();
+ continue;
+ }
+ #if defined DEBUG_PHRASE_LOAD
+ PrintToServer("Loaded %d phrases for word \"%s\"", phrases.Length, word);
+ #endif
+ REPLACEMENT_PHRASES.SetValue(word, phrases.Clone(), true);
+ } while (kv.GotoNextKey(false));
+ delete kv;
+}
+
+ArrayList GetPhrasesArray(const char[] key) {
+ int len = strlen(key);
+ char[] keyLower = new char[len];
+ for(int i = 0; i < len; i++) {
+ keyLower[i] = CharToLower(key[i]);
+ }
+ ArrayList phrases;
+ if(REPLACEMENT_PHRASES.GetValue(keyLower, phrases)) {
+ return phrases;
+ } else {
+ return null;
+ }
+}
+
+
+stock int FindClosestClientAdminPriority(int source, float pos[3]) {
+ int c = FindClosestAdmin(source, pos);
+ if(c == -1) return FindClosestClient(source, true,pos);
+ else return c;
+}
+
+stock int FindClosestClient(int source, bool ignoreBots, float pos[3]) {
+ int closest = -1;
+ float minDist = -1.0;
+ static float pos1[3];
+ static float pos2[3];
+ GetClientAbsOrigin(source, pos1);
+ for(int i = 1; i <= MaxClients; i++) {
+ if(i != source && IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i) && (!ignoreBots || !IsFakeClient(i)) ) {
+ GetClientAbsOrigin(i, pos2);
+ float dist = GetVectorDistance(pos1, pos2);
+ if(minDist == -1.0 || dist <= minDist) {
+ closest = i;
+ minDist = dist;
+ }
+ }
+ }
+ GetClientEyePosition(closest, pos);
+ return closest;
+}
+
+stock int FindClosestAdmin(int source, float pos[3]) {
+ int closest = -1;
+ float minDist = -1.0;
+ static float pos1[3];
+ static float pos2[3];
+ GetClientAbsOrigin(source, pos);
+ for(int i = 1; i <= MaxClients; i++) {
+ if(i != source && IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i) && !IsFakeClient(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) {
+ GetClientAbsOrigin(i, pos2);
+ float dist = GetVectorDistance(pos1, pos2, true);
+ if(minDist == -1.0 || dist <= minDist) {
+ closest = i;
+ minDist = dist;
+ }
+ }
+ }
+ GetClientEyePosition(closest, pos);
+ return closest;
+}
+
+int SpawnItem(const char[] itemName, float pos[3], float ang[3] = NULL_VECTOR) {
+ static char classname[32];
+ Format(classname, sizeof(classname), "weapon_%s", itemName);
+ int spawner = CreateEntityByName(classname);
+ if(spawner == -1) return -1;
+ DispatchKeyValue(spawner, "solid", "6");
+ // DispatchKeyValue(entity_weapon, "model", g_bLeft4Dead2 ? g_sWeaponModels2[model] : g_sWeaponModels[model]);
+ DispatchKeyValue(spawner, "rendermode", "3");
+ DispatchKeyValue(spawner, "disableshadows", "1");
+ TeleportEntity(spawner, pos, ang, NULL_VECTOR);
+ DispatchSpawn(spawner);
+ TeleportEntity(spawner, pos, ang, NULL_VECTOR);
+ return spawner;
+}
+
+bool IsAnyPlayerNear(int source, float range) {
+ static float pos1[3];
+ static float pos2[3];
+ GetClientAbsOrigin(source, pos1);
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i) && i != source) {
+ GetClientAbsOrigin(i, pos2);
+ float dist = GetVectorDistance(pos1, pos2);
+ if(dist <= range) return true;
+ }
+ }
+ return false;
+}
+
+void ThrowItemToPlayer(int victim, int target, int slot) {
+ int wpn = GetPlayerWeaponSlot(victim, slot);
+ if(wpn > 0 && (slot != 1 || DoesClientHaveMelee(victim))) {
+ static float pos[3];
+ GetClientAbsOrigin(target, pos);
+ SDKHooks_DropWeapon(victim, wpn, pos);
+ }
+}
+
+
+stock void AddInFrontOf(float fVecOrigin[3], float fVecAngle[3], float fUnits, float fOutPut[3]) {
+ float fVecView[3]; GetViewVector(fVecAngle, fVecView);
+
+ fOutPut[0] = fVecView[0] * fUnits + fVecOrigin[0];
+ fOutPut[1] = fVecView[1] * fUnits + fVecOrigin[1];
+ fOutPut[2] = fVecView[2] * fUnits + fVecOrigin[2];
+}
+stock void GetViewVector(float fVecAngle[3], float fOutPut[3]) {
+ fOutPut[0] = Cosine(fVecAngle[1] / (180 / FLOAT_PI));
+ fOutPut[1] = Sine(fVecAngle[1] / (180 / FLOAT_PI));
+ fOutPut[2] = -Sine(fVecAngle[0] / (180 / FLOAT_PI));
+}
+stock void LookAtClient(int iClient, int iTarget) {
+ static float fTargetPos[3];
+ static float fTargetAngles[3];
+ static float fClientPos[3];
+ static float fFinalPos[3];
+
+ GetClientEyePosition(iClient, fClientPos);
+ GetClientEyePosition(iTarget, fTargetPos);
+ GetClientEyeAngles(iTarget, fTargetAngles);
+
+ float fVecFinal[3];
+ AddInFrontOf(fTargetPos, fTargetAngles, 7.0, fVecFinal);
+ MakeVectorFromPoints(fClientPos, fVecFinal, fFinalPos);
+
+ GetVectorAngles(fFinalPos, fFinalPos);
+
+ TeleportEntity(iClient, NULL_VECTOR, fFinalPos, NULL_VECTOR);
+}
+
+
+stock int GetClientRealHealth(int client) {
+ if(!client || !IsValidEntity(client) || !IsClientInGame(client) || !IsPlayerAlive(client) || IsClientObserver(client)) {
+ return -1;
+ } else if(GetClientTeam(client) != 2) {
+ return GetClientHealth(client);
+ }
+ float buffer = GetEntPropFloat(client, Prop_Send, "m_healthBuffer");
+ float tempHealth = 0.0;
+ if(buffer > 0.0) {
+ float difference = GetGameTime() - GetEntPropFloat(client, Prop_Send, "m_healthBufferTime");
+ float decay = FindConVar("pain_pills_decay_rate").FloatValue;
+ float constant = 1.0 / decay;
+ tempHealth = buffer - (difference / constant);
+ if(tempHealth < 0.0) {
+ tempHealth = 0.0;
+ }
+ }
+ return RoundToFloor(GetClientHealth(client) + tempHealth);
+}
+
+
+/// Returns TRUE if set, FALSE if not (if no weapon to shoot)
+bool SetBotTarget(int bot, int target, int targetHP, int loops = 15) {
+ if(pdata[target].shootAtTarget == bot) {
+ return false;
+ } else if(pdata[target].shootAtTarget > 0) {
+ return false;
+ }
+ LookAtClient(target, bot);
+ int weapon = GetPlayerWeaponSlot(target, 0);
+ if(weapon > -1) {
+ pdata[target].shootAtTarget = bot;
+ pdata[target].shootAtLoops = loops;
+ pdata[bot].shootAtTargetHealth = targetHP;
+ int ammo = GetEntProp(weapon, Prop_Send, "m_iClip1");
+ DataPack pack = new DataPack();
+ // Reverse target and bot:
+ pack.WriteCell(target);
+ pack.WriteCell(bot);
+ pack.WriteCell(weapon);
+ pack.WriteCell(ammo);
+ CreateTimer(0.1, Timer_ShootReverse, pack, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Taken from https://forums.alliedmods.net/showthread.php?t=220132&page=2
+stock void ExplodeProjectile(int entity, bool smoke = true) {
+ SetEntProp(entity, Prop_Data, "m_takedamage", 2);
+ SetEntProp(entity, Prop_Data, "m_iHealth", 1);
+ SDKHooks_TakeDamage(entity, 0, 0, 1.0);
+ if(smoke)
+ SetEntProp(entity, Prop_Data, "m_nNextThinkTick", 1); //for smoke
+}
+
+stock int CreateProp(const char[] entClass, const char[] model, const float pos[3], const float ang[3] = { 0.0, 0.0, 0.0 }, const float vel[3] = {0.0, 0.0, 0.0}) {
+ int entity = CreateEntityByName(entClass);
+ DispatchKeyValue(entity, "model", model);
+ DispatchKeyValue(entity, "solid", "6");
+ DispatchKeyValue(entity, "targetname", "hsprop");
+ DispatchKeyValue(entity, "disableshadows", "1");
+ TeleportEntity(entity, pos, ang, vel);
+ DispatchSpawn(entity);
+ TeleportEntity(entity, pos, ang, vel);
+ #if defined DEBUG_LOG_MAPSTART
+ PrintToServer("spawn prop %.1f %.1f %.1f model %s", pos[0], pos[1], pos[2], model[7]);
+ #endif
+ return entity;
+}
+
+
+public bool Filter_Solid(int entity, int contentsMask, any data) {
+ return entity <= 0;
+}
+
+
+float VEH_MIN[3] = { -30.0, -30.0, 2.0};
+float VEH_MAX[3] = { 30.0, 30.0, 20.0 };
+
+bool SpawnCarToPlayer(int target, float distance) {
+ float pos[3], ang[3];
+ GetClientAbsOrigin(target, pos);
+ pos[2] += 40.0;
+ GetClientEyeAngles(target, ang);
+ ang[2] = ang[0] = 0.0;
+
+ float endPos[3];
+ GetHorizontalPositionFromOrigin(pos, ang, distance, endPos);
+
+ TR_TraceHullFilter(endPos, pos, VEH_MIN, VEH_MAX, MASK_SOLID, Filter_Solid);
+ if(TR_DidHit()) {
+ return false;
+ }
+ if(distance > 0.0)
+ ang[1] -= 180;
+ float vel[3];
+ vel[0] = Cosine(DegToRad(ang[1])) * 1500.0;
+ vel[1] = Sine(DegToRad(ang[1])) * 1500.0;
+ int id = CreateProp("prop_physics", MODEL_CAR, endPos, ang, vel);
+ CreateTimer(6.0, Timer_Delete, id);
+ return true;
+}
+
+bool SpawnCarOnPlayer(int target) {
+ float min[3] = { -30.0, -30.0, -2.0};
+ float max[3] = { 30.0, 30.0, 50.0 };
+ float pos[3];
+ float ang[3];
+ GetClientEyePosition(target, pos);
+ GetClientEyeAngles(target, ang);
+ if(IsAreaClear(pos, ang, min, max)) {
+ pos[2] += 40.0;
+ int id = CreateProp("prop_physics", MODEL_CAR, pos, ang);
+ CreateTimer(4.0, Timer_Delete, id);
+ return true;
+ }
+ return false;
+}
+
+bool g_iPendingSurvivorAdd;
+int isCustomSurvivor[MAXPLAYERS+1];
+
+bool AddSurvivor() {
+ if (GetClientCount(false) >= MaxClients - 1) {
+ return false;
+ }
+
+ int i = CreateFakeClient("FTTSurvivorBot");
+ bool result;
+ if (i > 0) {
+ if (DispatchKeyValue(i, "classname", "SurvivorBot")) {
+ ChangeClientTeam(i, 2);
+
+ if (DispatchSpawn(i)) {
+ result = true;
+ }
+ }
+
+ g_iPendingSurvivorAdd = true;
+ CreateTimer(0.2, Timer_KickBot, i);
+ }
+ return result;
+}
+
+void ClearInventory(int client) {
+ for(int i = 0; i <= 5; i++) {
+ int item = GetPlayerWeaponSlot(client, i);
+ if(item > 0) {
+ AcceptEntityInput(item, "Kill");
+ }
+ }
+}
+
+void StopHealingBots() {
+ healTargetPlayer = 0;
+ for(int i = 1; i <= MaxClients; i++) {
+ pdata[i].flags &= ~view_as(Flag_IsTargettingHealer);
+ if(isCustomSurvivor[i]) {
+ ClearInventory(i);
+ KickClient(i);
+ }
+ }
+ delete stopHealingTimer;
+ if(hAbmAutoHard != null) hAbmAutoHard.IntValue = wasAbmAutoHard;
+ if(hSbFixEnabled != null) hSbFixEnabled.BoolValue = wasSbFixEnabled;
+}
+
+
+bool IsAnySurvivorInRange(const float origin[3], float range, int ignorePlayer = 0) {
+ float pos[3];
+ range = range * range;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(i != ignorePlayer && IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
+ GetClientAbsOrigin(i, pos);
+ if(GetVectorDistance(origin, pos, true) <= range) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+int GetRandomThrowableMagnetTarget(ProjectileMagnetType type, int owner = -1) {
+ static int throwMagnetIndex;
+ if(throwMagnetIndex == 0) throwMagnetIndex = GetTrollID("Projectile Magnet");
+ ArrayList checkList = new ArrayList();
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && Trolls[throwMagnetIndex].IsActive(i)) {
+ if(type == ProjType_Survivors) {
+ // If the projectile is not owned by player, check if troll flag not enabled
+ if(owner != i && ~Trolls[throwMagnetIndex].activeFlagClients[i] & view_as(ProjType_Survivors)) continue;
+ } else if(~Trolls[throwMagnetIndex].activeFlagClients[i] & view_as(type)) {
+ // Skip if client does not have flag
+ continue;
+ }
+ checkList.Push(i);
+ }
+ }
+ int target = -1;
+ if(checkList.Length > 0) {
+ target = checkList.Get(0, checkList.Length - 1);
+ }
+ delete checkList;
+ return target;
+}
+
+stock bool CanSeePoint(const float origin[3], const float point[3]) {
+ TR_TraceRay(origin, point, MASK_ALL, RayType_EndPoint);
+
+ return !TR_DidHit(); // Can see point if no collisions
+}
+
+stock LookAtPoint(int entity, const float destination[3]){
+ float angles[3], pos[3], result[3];
+ GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
+ MakeVectorFromPoints(destination, pos, result);
+ GetVectorAngles(result, angles);
+ if(angles[0] >= 270){
+ angles[0] -= 270;
+ angles[0] = (90-angles[0]);
+ }else{
+ if(angles[0] <= 90){
+ angles[0] *= -1;
+ }
+ }
+ angles[1] -= 180;
+ TeleportEntity(entity, NULL_VECTOR, angles, NULL_VECTOR);
+}
+stock void PrintToConsoleAdmins(const char[] format, any ...) {
+ char buffer[254];
+
+ VFormat(buffer, sizeof(buffer), format, 2);
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i)) {
+ AdminId admin = GetUserAdmin(i);
+ if(admin != INVALID_ADMIN_ID) {
+ PrintToConsole(i, "%s", buffer);
+ }
+ }
+ }
+ PrintToServer("%s", buffer);
+}
+
+/**
+ * Shakes a client's screen with the specified amptitude,
+ * frequency & duration.
+ *
+ * @param client Client Index.
+ * @param amplitude Shake magnitude/amplitude.
+ * @param frequency Shake noise frequency.
+ * @param duration Shake lasts this long.
+ * @return True on success, false otherwise.
+ */
+stock bool ShakePlayer(int client, float amplitude=50.0, float frequency=150.0, float duration=3.0) {
+ if (amplitude <= 0.0) {
+ return false;
+ }
+ Handle userMessage = StartMessageOne("Shake", client);
+ if (userMessage == INVALID_HANDLE) {
+ return false;
+ }
+
+ if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available
+ && GetUserMessageType() == UM_Protobuf) {
+ PbSetInt(userMessage, "command", 0);
+ PbSetFloat(userMessage, "local_amplitude", amplitude);
+ PbSetFloat(userMessage, "frequency", frequency);
+ PbSetFloat(userMessage, "duration", duration);
+ } else {
+ BfWriteByte(userMessage, 0); // Shake Command
+ BfWriteFloat(userMessage, amplitude); // shake magnitude/amplitude
+ BfWriteFloat(userMessage, frequency); // shake noise frequency
+ BfWriteFloat(userMessage, duration); // shake lasts this long
+ }
+ EndMessage();
+ return true;
+}
+
+void SetSlot(int client, int slot) {
+ if(slot == -1)
+ slot = GetRandomInt(0, 4);
+ static char slotStr[8];
+ Format(slotStr, sizeof(slotStr), "slot%d", slot);
+ ClientCommand(client, slotStr);
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/specials.inc b/scripting/include/feedthetrolls/specials.inc
new file mode 100644
index 0000000..e7e7e0b
--- /dev/null
+++ b/scripting/include/feedthetrolls/specials.inc
@@ -0,0 +1,222 @@
+
+enum SpecialType {
+ Special_Invalid = -1,
+ Special_Smoker = 1,
+ Special_Boomer,
+ Special_Hunter,
+ Special_Spitter,
+ Special_Jockey,
+ Special_Charger,
+ Special_Witch,
+ Special_Tank
+}
+
+
+enum struct SpecialSpawnRequest {
+ SpecialType type;
+ int targetUserId;
+ float position[3];
+ float angle[3];
+ int flags;
+}
+
+ArrayList g_spSpawnQueue;
+
+// Finds position, sends to SpawnSpecialAtPosition
+// target client index
+stock bool SpawnSpecialForTarget(SpecialType specialType, int target, int spawnFlags = view_as(Special_Anywhere)) {
+ static float pos[3];
+
+ if(spawnFlags & view_as(Special_OnTarget)) {
+ static float ang[3];
+ static float testPos[3];
+ testPos = pos;
+
+ GetClientAbsOrigin(target, pos);
+ GetClientEyeAngles(target, ang);
+
+ if(specialType == Special_Jockey || specialType == Special_Boomer || specialType == Special_Spitter) { // Else spawn a little bit off, and above (above for jockeys)
+ pos[2] += 25.0;
+ pos[0] += 5.0;
+ } else { //If not jockey/hunter find a suitable area that is at least 5 m away
+ float minDistance = GetIdealMinDistance(specialType);
+ GetHorizontalPositionFromOrigin(pos, ang, minDistance, testPos);
+ if(!FindSuitablePosition(pos, testPos, minDistance, 100)) {
+ PrintToServer("[FTT] Could not find suitable position, trying in front");
+ GetHorizontalPositionFromOrigin(pos, ang, -minDistance, testPos);
+ if(!FindSuitablePosition(pos, testPos, minDistance, 50)) {
+ PrintToServer("[FTT] Could not find suitable position, falling back");
+ if(spawnFlags & view_as(Special_SpawnDirectOnFailure))
+ GetClientAbsOrigin(target, testPos);
+ else
+ L4D_GetRandomPZSpawnPosition(target, view_as(specialType), 10, testPos);
+ }
+ }
+ pos = testPos;
+ }
+ pos[2] += 1.0;
+ return SpawnSpecialAtPosition(specialType, pos, ang, target, spawnFlags);
+ }
+ // Spawn via director, or fail
+ if(!L4D_GetRandomPZSpawnPosition(target, view_as(specialType), 10, pos)) {
+ if(spawnFlags & view_as(Special_SpawnDirectOnFailure))
+ GetClientAbsOrigin(target, pos);
+ else
+ return false;
+ }
+ return SpawnSpecialAtPosition(specialType, pos, NULL_VECTOR, target, spawnFlags);
+}
+
+// Target is optional
+stock bool SpawnSpecialAtPosition(SpecialType specialType, const float destination[3], const float angle[3], int target = 0, int spawnFlags = 0) {
+ int internalFlags = 0;
+ if(spawnFlags & view_as(Special_AlwaysTarget)) {
+ internalFlags |= view_as(SPI_AlwaysTarget);
+ }
+ if(spawnFlags & view_as(Special_KillOnIncap)) {
+ internalFlags |= view_as(SPI_KillOnTargetIncap);
+ }
+ if(spawnFlags & view_as(Special_OnTarget)) {
+ if(specialType == Special_Boomer || specialType == Special_Spitter)
+ internalFlags |= view_as(SPI_KillOnSpawn);
+ }
+ SpecialSpawnRequest request;
+ request.type = specialType;
+ if(target)
+ request.targetUserId = GetClientUserId(target);
+ request.flags = internalFlags;
+ request.position = destination;
+ request.angle = angle;
+ g_spSpawnQueue.PushArray(request);
+ if(!spIsActive) ProcessSpecialQueue();
+ return true;
+}
+
+SpecialSpawnRequest spActiveRequest;
+
+// On spawn, keep id
+// timer checks if passed id still == kept id, if so, it failed.
+int g_iSpId;
+
+bool ProcessSpecialQueue() {
+ if(g_spSpawnQueue.Length > 0) {
+ if(g_spSpawnQueue.GetArray(0, spActiveRequest, sizeof(spActiveRequest))) {
+ spIsActive = true;
+ CreateTimer(2.0, Timer_CheckSpecialSpawned, g_iSpId);
+ }
+ g_spSpawnQueue.Erase(0);
+
+ int target = GetClientOfUserId(spActiveRequest.targetUserId);
+ if(view_as(spActiveRequest.type) <= 6) {
+ // CreateTimer(2.0, Timer_CheckSpecialSpawn, spCurrentId);
+ int bot = CreateFakeClient("FTTSpecialBot");
+ if (bot != 0) {
+ ChangeClientTeam(bot, 3);
+ CreateTimer(0.1, Timer_KickBot, bot);
+ }
+ CheatCommand(target, "z_spawn_old", SPECIAL_NAMES[view_as(spActiveRequest.type) - 1], "auto");
+ return true;
+ } else if(spActiveRequest.type == Special_Witch) {
+ int witch = L4D2_SpawnWitch(spActiveRequest.position, spActiveRequest.angle);
+ DataPack pack;
+ CreateDataTimer(0.2, Timer_SetWitchTarget, pack);
+ pack.WriteCell(witch);
+ pack.WriteCell(spActiveRequest.targetUserId);
+ if(witch != -1)
+ SetWitchTarget(witch, target);
+ spIsActive = false;
+ return ProcessSpecialQueue();
+ } else if(spActiveRequest.type == Special_Tank) {
+ // BypassLimit();
+ int tank = L4D2_SpawnTank(spActiveRequest.position, spActiveRequest.angle);
+ if(tank > 0 && IsClientConnected(tank)) {
+ TeleportEntity(tank, spActiveRequest.position, spActiveRequest.angle, NULL_VECTOR);
+ pdata[tank].attackerTargetUid = spActiveRequest.targetUserId;
+ pdata[tank].specialAttackFlags = view_as(SPI_AlwaysTarget);
+ }
+ spIsActive = false;
+ return ProcessSpecialQueue();
+ }
+ return false;
+ }
+ spIsActive = false;
+ return false;
+}
+
+Action Timer_SetWitchTarget(Handle h, DataPack pack) {
+ pack.Reset();
+ int witch = pack.ReadCell();
+ int target = GetClientOfUserId(pack.ReadCell());
+ if(IsValidEntity(witch) && target > 0) {
+ SetWitchTarget(witch, target);
+ }
+ return Plugin_Handled;
+}
+
+stock SpecialType GetSpecialType(const char[] input) {
+ for(int i = 0; i < 8; i++) {
+ if(strcmp(SPECIAL_NAMES[i], input, false) == 0) return view_as(i + 1);
+ }
+ return Special_Invalid;
+}
+
+stock bool FindSuitablePosition(const float pos[3], float outputPos[3], float minDistance = 19000.0, int tries = 100) {
+ outputPos = pos;
+ for(int i = tries; i > 0; i--) {
+ // Shift position aroudn randomly
+ outputPos[1] += GetRandomFloat(-35.0, 35.0);
+ float dist = GetVectorDistance(outputPos, pos, true);
+ if(dist >= minDistance && L4D2Direct_GetTerrorNavArea(outputPos) != Address_Null) { //5m^2
+ return true;
+ }
+ }
+ return false;
+}
+
+float GetIdealMinDistance(SpecialType specialType) {
+ switch(specialType) {
+ // /*Boomer*/ case 2: return 1200.0;
+ case Special_Charger: return 19510.0;
+ case Special_Smoker: return 20000.0;
+ case Special_Tank: return 20000.0;
+ case Special_Spitter: return 15000.0;
+ default:
+ return 12000.0;
+ }
+}
+
+static float TARGET_GROUND_BOUNDS[3] = { 35.0, 35.0, 32.0 };
+
+stock bool GetGroundBehind(int client, float vPos[3], float vAng[3]) {
+ GetClientEyePosition(client, vPos);
+ GetClientEyeAngles(client, vAng);
+ vAng[1] -= 180.0; //Flip to behind
+ vAng[2] = 35.0; //Angle downwards
+ // vPos[2] -= 500.0;
+ Handle trace = TR_TraceHullFilterEx(vPos, vAng, TARGET_GROUND_BOUNDS, TARGET_GROUND_BOUNDS, MASK_SOLID, RayFilter_NonClient);
+ if(!TR_DidHit(trace)) {
+ delete trace;
+ return false;
+ }
+ TR_GetEndPosition(vPos, trace);
+ vPos[2] += 32.0;
+ // FindSuitablePosition(vPos, vPos, 100.0, 100);
+ delete trace;
+
+ GetClientAbsAngles(client, vAng);
+ return true;
+}
+
+stock bool RayFilter_NonClient(int entity, int contentsMask) {
+ if (entity <= 0 || entity > MaxClients) {
+ if (IsValidEntity(entity)) {
+ static char eClass[128];
+ if (GetEntityClassname(entity, eClass, sizeof(eClass))) {
+ if (strcmp(eClass, "prop_physics") >= 0)
+ return false;
+ }
+ return true;
+ }
+ }
+ return false;
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/timers.inc b/scripting/include/feedthetrolls/timers.inc
new file mode 100644
index 0000000..cb0712e
--- /dev/null
+++ b/scripting/include/feedthetrolls/timers.inc
@@ -0,0 +1,484 @@
+
+Action Timer_ThrowTimer(Handle timer, int client) {
+ if(!IsClientInGame(client)) {
+ Trolls[t_throwItAllIndex].timerHandles[client] = null;
+ return Plugin_Stop;
+ }
+ ThrowAllItems(client);
+ return Plugin_Continue;
+}
+int instantCommonRef[MAXPLAYERS+1];
+
+Action Timer_RandomVelocity(Handle h, int client) {
+ if(!IsClientInGame(client)) {
+ Trolls[t_randomizeVelocityIndex].timerHandles[client] = null;
+ return Plugin_Stop;
+ }
+ float bounds = 50.0;
+ if(Trolls[t_randomizeVelocityIndex].activeFlagClients[client] & 2) bounds = 100.0;
+ else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[client] & 4) bounds = 200.0;
+ else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[client] & 8) bounds = 500.0;
+ else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[client] & 16) bounds = 1000.0;
+ float vel[3];
+ GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel);
+ vel[0] += GetRandomFloat(-bounds, bounds);
+ vel[1] += GetRandomFloat(-bounds, bounds);
+ vel[2] += GetRandomFloat(-20.0, 100.0);
+ SetAbsVelocity(client, vel);
+ return Plugin_Continue;
+}
+
+Action Timer_Main(Handle timer) {
+ static int loopTick;
+
+ static int slowDrainIndex;
+ if(!slowDrainIndex) slowDrainIndex = GetTrollID("Slow Drain");
+ static int tempHealthQuickDrainIndex;
+ if(!tempHealthQuickDrainIndex) tempHealthQuickDrainIndex = GetTrollID("Temp Health Quick Drain");
+ static int swarmIndex;
+ if(!swarmIndex) swarmIndex = GetTrollID("Swarm");
+ static int instantCommonIndex;
+ if(!instantCommonIndex) instantCommonIndex = GetTrollID("Instant Commons");
+ static int randomizeAmmoIndex;
+ if(!randomizeAmmoIndex) randomizeAmmoIndex = GetTrollID("Randomize Clip Ammo");
+
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2) {
+ if(Trolls[t_randomizeAnglesIndex].IsActive(i)) {
+ float chance = 0.10;
+ if(Trolls[t_randomizeAnglesIndex].activeFlagClients[i] & 2) chance = 0.35;
+ else if(Trolls[t_randomizeAnglesIndex].activeFlagClients[i] & 4) chance = 0.58;
+ else if(Trolls[t_randomizeAnglesIndex].activeFlagClients[i] & 8) chance = 0.90;
+ else if(Trolls[t_randomizeAnglesIndex].activeFlagClients[i] & 16) chance = 1.00;
+ if(GetURandomFloat() < chance) {
+ float ang[3];
+ ang[0] = GetRandomFloat(-180.0, 180.0);
+ ang[1] = GetRandomFloat(-180.0, 180.0);
+ TeleportEntity(i, NULL_VECTOR, ang, NULL_VECTOR);
+ }
+ }
+ if(Trolls[t_randomizeVelocityIndex].IsActive(i)) {
+ float bounds = 50.0;
+ if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 2) bounds = 100.0;
+ else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 4) bounds = 200.0;
+ else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 8) bounds = 500.0;
+ else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 16) bounds = 1000.0;
+ float vel[3];
+ GetEntPropVector(i, Prop_Data, "m_vecVelocity", vel);
+ vel[0] += GetRandomFloat(-bounds, bounds);
+ vel[1] += GetRandomFloat(-bounds, bounds);
+ vel[2] += GetRandomFloat(-100.0, 150.0);
+ SetAbsVelocity(i, vel);
+ }
+ if(Trolls[slowDrainIndex].IsActive(i)) {
+ if(loopTick % 4 == 0) {
+ int hp = GetClientHealth(i);
+ if(hp > 50) {
+ SetEntProp(i, Prop_Send, "m_iHealth", hp - 1);
+ }
+ }
+ }
+ if(Trolls[tempHealthQuickDrainIndex].IsActive(i)) {
+ if(loopTick % 3 == 0) {
+ float bufferTime = GetEntPropFloat(i, Prop_Send, "m_healthBufferTime");
+ float tempHealth = L4D_GetTempHealth(i);
+ if(tempHealth > 0.0) {
+ SetEntPropFloat(i, Prop_Send, "m_healthBufferTime", bufferTime - 7.0);
+ }
+ }
+ }
+ if(Trolls[swarmIndex].IsActive(i)) {
+ L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", GetClientUserId(i), 15000);
+ }
+ if(Trolls[t_slipperyShoesIndex].IsActive(i) && Trolls[t_slipperyShoesIndex].activeFlagClients[i] & 1) {
+ if(GetRandomFloat() <= 0.4) {
+ L4D_StaggerPlayer(i, i, NULL_VECTOR);
+ }
+ }
+ if(Trolls[instantCommonIndex].IsActive(i)) {
+ int common = EntRefToEntIndex(instantCommonRef[i]);
+ if(common <= 0 || !IsValidEntity(common)) {
+ static float pos[3];
+ GetHorizontalPositionFromClient(i, Trolls[instantCommonIndex].activeFlagClients[i] & 1 ? -40.0 : 40.0, pos);
+ common = L4D_SpawnCommonInfected(pos);
+ instantCommonRef[i] = EntIndexToEntRef(common);
+ }
+ SetEntPropEnt(common, Prop_Send, "m_clientLookatTarget", i);
+ SetEntProp(common, Prop_Send, "m_nSequence", 96);
+ }
+ if(loopTick % 60 && Trolls[randomizeAmmoIndex].IsActive(i)) {
+ int primaryWpn = GetPlayerWeaponSlot(i, 0);
+ if(primaryWpn > 0) {
+ int maxCap = GetEntProp(primaryWpn, Prop_Send, "m_iClip1");
+ SetEntProp(primaryWpn, Prop_Send, "m_iClip1", GetRandomInt(0, maxCap));
+ }
+ }
+ if(Trolls[t_vomitPlayerIndex].IsActive(i)) {
+ if(loopTick % 4 == 0) {
+ L4D_CTerrorPlayer_OnVomitedUpon(i, i);
+ }
+ }
+ if(Trolls[t_shakeyCameraIndex].IsActive(i)) {
+ float amplitude = 1.0;
+ float freq = 1.0;
+ if(Trolls[t_shakeyCameraIndex].activeFlagClients[i] & 1) {
+ amplitude = 1.0;
+ freq = 1.0;
+ } else if(Trolls[t_shakeyCameraIndex].activeFlagClients[i] & 2) {
+ amplitude = 5.0;
+ freq = 5.0;
+ } else if(Trolls[t_shakeyCameraIndex].activeFlagClients[i] & 4) {
+ amplitude = 20.0;
+ freq = 20.0;
+ } else if(Trolls[t_shakeyCameraIndex].activeFlagClients[i] & 8) {
+ amplitude = 50.0;
+ freq = 50.0;
+ } else if(Trolls[t_shakeyCameraIndex].activeFlagClients[i] & 16) {
+ amplitude = 100.0;
+ freq = 200.0;
+ }
+ ShakePlayer(i, amplitude, freq, MAIN_TIMER_INTERVAL_S + 2.0);
+ }
+ if(Trolls[t_slotRouletteIndex].IsActive(i) && Trolls[t_slotRouletteIndex].activeFlagClients[i] & 8) {
+ float chance = 1.0;
+ if(Trolls[t_slotRouletteIndex].activeFlagClients[i] & 16) {
+ chance = 0.05;
+ } else if(Trolls[t_slotRouletteIndex].activeFlagClients[i] & 32) {
+ chance = 0.2;
+ } else if(Trolls[t_slotRouletteIndex].activeFlagClients[i] & 64) {
+ chance = 0.4;
+ }
+
+ if(GetURandomFloat() < chance) {
+ SetSlot(i, -1);
+ }
+ }
+ if(Trolls[t_hideHUDIndex].IsActive(i)) {
+ HideHUDRandom(i);
+ }
+ }
+ }
+ if(++loopTick >= 60) {
+ loopTick = 0;
+ }
+ return Plugin_Continue;
+}
+Action Timer_SlotRoulette(Handle h, int client) {
+ if(!IsClientInGame(client)) {
+ Trolls[t_slotRouletteIndex].timerHandles[client] = null;
+ return Plugin_Stop;
+ }
+ if(Trolls[t_slotRouletteIndex].activeFlagClients[client] & 8) {
+ float chance = 1.0;
+ if(Trolls[t_slotRouletteIndex].activeFlagClients[client] & 16) {
+ chance = 0.1;
+ } else if(Trolls[t_slotRouletteIndex].activeFlagClients[client] & 32) {
+ chance = 0.3;
+ } else if(Trolls[t_slotRouletteIndex].activeFlagClients[client] & 64) {
+ chance = 0.5;
+ }
+
+ if(GetURandomFloat() < chance) {
+ SetSlot(client, -1);
+ }
+ }
+ return Plugin_Continue;
+}
+Action Timer_GivePistol(Handle timer, int user) {
+ int client = GetClientOfUserId(user);
+ if(client > 0) {
+ int flags = GetCommandFlags("give");
+ SetCommandFlags("give", flags & ~FCVAR_CHEAT);
+ FakeClientCommand(client, "give pistol");
+ SetCommandFlags("give", flags);
+ }
+ return Plugin_Handled;
+}
+
+Action Timer_ThrowWeapon(Handle timer, Handle pack) {
+ ResetPack(pack);
+ float dest[3];
+ dest[0] = ReadPackFloat(pack);
+ dest[1] = ReadPackFloat(pack);
+ dest[2] = ReadPackFloat(pack);
+ int slot = ReadPackCell(pack);
+ int victim = ReadPackCell(pack);
+
+ int wpnRef = GetPlayerWeaponSlot(victim, slot);
+ if(wpnRef != -1) {
+ int wpn = EntRefToEntIndex(wpnRef);
+ if(wpn != INVALID_ENT_REFERENCE) {
+ if(slot == 1) {
+ static char name[16];
+ GetEdictClassname(wpn, name, sizeof(name));
+ if(!StrEqual(name, "weapon_pistol", false)) {
+ SDKHooks_DropWeapon(victim, wpn, dest);
+ CreateTimer(0.2, Timer_GivePistol, GetClientUserId(victim));
+ }
+ }else
+ SDKHooks_DropWeapon(victim, wpn, dest);
+ }
+ }
+ return Plugin_Handled;
+}
+
+Action Timer_ResetAutoPunish(Handle timer, int user) {
+ int client = GetClientOfUserId(user);
+ if(client) {
+ if(hAutoPunish.IntValue & 2 == 2)
+ DisableTroll(client, "Special Magnet");
+ if(hAutoPunish.IntValue & 1 == 1)
+ DisableTroll(client, "Tank Magnet");
+ }
+ return Plugin_Handled;
+}
+
+Action Timer_NextWitchSet(Handle timer, DataPack pack) {
+ pack.Reset();
+ int client = GetClientOfUserId(pack.ReadCell());
+ int witch = pack.ReadCell();
+ SetWitchTarget(witch, client);
+ return Plugin_Handled;
+}
+
+Action Timer_KickBot(Handle timer, int client) {
+ if(IsClientInGame(client) && !IsClientInKickQueue(client) && IsFakeClient(client)) {
+ KickClient(client);
+ }
+ return Plugin_Handled;
+}
+
+Action Timer_Delete(Handle h, int id) {
+ if(IsValidEntity(id))
+ AcceptEntityInput(id, "Kill");
+ return Plugin_Handled;
+}
+
+Action Timer_ShootReverse(Handle h, DataPack pack) {
+ pack.Reset();
+ int attacker = pack.ReadCell();
+ int target = pack.ReadCell();
+ int weapon = pack.ReadCell();
+ int ammo = pack.ReadCell();
+
+
+ if(!IsClientConnected(target) || !IsClientConnected(attacker) || attacker > MaxClients || target > MaxClients) return Plugin_Stop;
+ static float targetPos[3], botAngles[3], botPosition[3];
+ GetClientAbsOrigin(attacker, targetPos);
+ GetClientAbsAngles(attacker, botAngles);
+ GetClientAbsOrigin(attacker, botPosition);
+
+ botAngles[1] = RadToDeg(ArcTangent2( botPosition[1] - targetPos[1], botPosition[0] - targetPos[0])) + 180.0;
+ TeleportEntity(attacker, NULL_VECTOR, botAngles, NULL_VECTOR);
+ pdata[attacker].shootAtLoops--;
+ if(IsValidEntity(weapon))
+ SetEntProp(weapon, Prop_Send, "m_iClip1", ammo);
+ if(pdata[attacker].shootAtLoops > 0 && GetClientRealHealth(target) > pdata[target].shootAtTargetHealth) {
+ return Plugin_Continue;
+ } else {
+ pdata[attacker].shootAtTarget = 0;
+ pdata[attacker].shootAtLoops = 0;
+ pdata[attacker].shootAtTargetHealth = 0;
+ return Plugin_Stop;
+ }
+}
+// We check if the special never spawned (g_iSpId never advances, and run the next in queue)
+// Prevents the queue from stalling
+Action Timer_CheckSpecialSpawned(Handle h, int id) {
+ if(g_iSpId == id) {
+ PrintToServer("[FTT] Special did not spawn in time, continuing.");
+ g_iSpId++;
+ ProcessSpecialQueue();
+ }
+ return Plugin_Handled;
+}
+
+Action Timer_CheckIsInSpit(Handle h, int userid) {
+ int client = GetClientOfUserId(userid);
+ if(client && GetGameTime() - pdata[userid].lastInSpitTime > 3.0) {
+ SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", 1.0);
+ pdata[client].flags &= ~view_as(Flag_HasSpitTimer);
+ return Plugin_Stop;
+ }
+ return Plugin_Continue;
+}
+
+float CHARGER_CHECK_MIN[3] = { -15.0, -15.0, 2.0};
+float CHARGER_CHECK_MAX[3] = { 15.0, 15.0, 20.0 };
+
+Action Timer_CheckForChargerOpportunity(Handle h, int userid) {
+ int client = GetClientOfUserId(userid);
+ if(client) {
+ int activator = GetClientOfUserId(pdata[client].smartChargeActivator);
+ if(!activator) {
+ pdata[client].smartChargeActivator = 0;
+ }
+ float pos[3], ang[3], endPos[3], spawnPos[3];
+ GetClientAbsOrigin(client, pos);
+ GetClientEyeAngles(client, ang);
+
+ GetHorizontalPositionFromOrigin(pos, ang, -150.0, endPos);
+ TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
+ if(!TR_DidHit()) {
+ spawnPos = endPos;
+ GetHorizontalPositionFromOrigin(pos, ang, 500.0, endPos);
+ TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
+ if(!TR_DidHit()) {
+ SpawnSpecialAtPosition(Special_Charger, spawnPos, ang, client, view_as(Special_AlwaysTarget));
+ if(activator) PrintToChat(activator, "Auto charge %N successfully after %d tries", client, pdata[client].smartChargeAttempts);
+ pdata[client].smartChargeAttempts = 0;
+ pdata[client].smartChargeActivator = 0;
+ return Plugin_Stop;
+ }
+ }
+ if(++pdata[client].smartChargeAttempts > pdata[client].smartChargeMaxAttempts) {
+ if(activator) PrintToChat(activator, "Auto charge timed out after %d attempts", pdata[client].smartChargeAttempts);
+ pdata[client].smartChargeAttempts = 0;
+ pdata[client].smartChargeActivator = 0;
+ DisableTroll(client, "Smart Charge");
+ return Plugin_Stop;
+ }
+ return Plugin_Continue;
+ }
+ return Plugin_Stop;
+}
+
+public bool Filter_CheckChargerValid(int entity, int contentsMask, any data) {
+ return entity <= 0 || entity >= MaxClients || (entity != data && GetClientTeam(entity) == 2);
+}
+
+public Action Timer_UpdateHealTargetPos(Handle h) {
+ int healTarget = GetClientOfUserId(healTargetPlayer);
+ if(healTarget == 0) {
+ PrintToServer("[FTT] Dep Bots: Lost heal target, stopping");
+ return Plugin_Stop;
+ }
+ GetAbsOrigin(healTarget, healTargetPos);
+ int bots = 0;
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsFakeClient(i) && pdata[i].flags & view_as(Flag_IsTargettingHealer)) {
+ bots++;
+ L4D2_RunScript("CommandABot({cmd=1,bot=GetPlayerFromUserID(%d),pos=Vector(%f,%f,%f)})", GetClientUserId(i), healTargetPos[0], healTargetPos[1], healTargetPos[2]);
+ int kit = GetPlayerWeaponSlot(i, 3);
+ if(kit > -1) {
+ SetEntPropEnt(i, Prop_Send, "m_hActiveWeapon", kit);
+ }
+ }
+ }
+ return bots > 0 ? Plugin_Continue : Plugin_Stop;
+}
+
+Action Timer_SpawnHealBots(Handle h, int max) {
+ static int count;
+ if(count < max) {
+ if(!AddSurvivor()) {
+ count = 0;
+ CreateTimer(0.5, Timer_SpawnHealBotsPost);
+ return Plugin_Stop;
+ }
+ count++;
+ return Plugin_Continue;
+ }
+ count = 0;
+ CreateTimer(0.5, Timer_SpawnHealBotsPost);
+ return Plugin_Stop;
+}
+
+Action Timer_SpawnHealBotsPost(Handle h) {
+ PrintToServer("bots post");
+ char classname[32];
+ for(int i = 1; i <= MaxClients; i++) {
+ if(isCustomSurvivor[i]) {
+ int kit = GetPlayerWeaponSlot(i, 3);
+ if(kit > 0) {
+ GetEntityClassname(kit, classname, sizeof(classname));
+ if(StrEqual(classname, "weapon_first_aid_kit")) {
+ continue;
+ }
+ }
+ GiveClientWeapon(i, "weapon_first_aid_kit");
+ pdata[i].flags &= view_as(Flag_IsTargettingHealer);
+ }
+ }
+ return Plugin_Handled;
+}
+Action Timer_StopHealBots(Handle h, DataPack pack) {
+ pack.Reset();
+ int activator = GetClientOfUserId(pack.ReadCell());
+ int victim = GetClientOfUserId(pack.ReadCell());
+ if(activator) {
+ PrintToChat(activator, "Dep bots has expired");
+ }
+ if(victim) {
+ DisableTroll(victim, "Dep Bots");
+ }
+ StopHealingBots();
+ return Plugin_Stop;
+}
+
+
+#define NO_ATTEMPT_MAX_DIST 1000.0
+#define NO_ATTEMPT_MAX_DIST_OPT NO_ATTEMPT_MAX_DIST * NO_ATTEMPT_MAX_DIST
+
+
+Action Timer_WaitForApex(Handle h, int entref) {
+ if(!IsValidEntity(entref)) return Plugin_Stop;
+ int entity = EntRefToEntIndex(entref);
+
+ static float pos[3];
+ GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
+
+ if(entLastHeight[entity] > pos[2]) {
+ char classname[32];
+ GetEntityClassname(entity, classname, sizeof(classname));
+
+ int target;
+ if(StrEqual(classname, "tank_rock") || StrEqual(classname, "spitter_projectile"))
+ target = GetRandomThrowableMagnetTarget(ProjType_Specials);
+ else if(StrEqual(classname, "prop_physics") || StrEqual(classname, "prop_car_alarm"))
+ target = GetRandomThrowableMagnetTarget(ProjType_Cars)
+ else {
+ int entOwner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
+ target = GetRandomThrowableMagnetTarget(ProjType_Survivors, entOwner);
+ }
+
+ if(target > 0) {
+ float targetPos[3], vel[3];
+ GetClientAbsOrigin(target, targetPos);
+ TR_TraceRay(pos, targetPos, MASK_SHOT, RayType_EndPoint);
+ if(TR_DidHit()) {
+ TR_GetEndPosition(pos);
+ if(GetVectorDistance(pos, targetPos, true) > NO_ATTEMPT_MAX_DIST_OPT) {
+ return Plugin_Stop;
+ }
+ }
+
+ // SetEntityMoveType(entity, MOVETYPE_FLY);
+ SetEntityGravity(entity, 0.001);
+ float distance = GetVectorDistance(pos, targetPos);
+ SubtractVectors(targetPos, pos, vel);
+ ScaleVector(vel, 1000.0 / distance);
+ TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, vel);
+
+ CreateTimer(3.0, Timer_ResetGravity, entref);
+ }
+ return Plugin_Stop;
+ }
+ entLastHeight[entity] = pos[2];
+ return Plugin_Continue;
+}
+
+Action Timer_ResetGravity(Handle h, int entref) {
+ if(IsValidEntity(entref)) {
+ int entity = EntRefToEntIndex(entref);
+ SetEntityGravity(entity, 800.0); // could pull from sv_gravity but no ones gonna notice
+ }
+ return Plugin_Handled;
+}
+Action Timer_RestoreHud(Handle h, int userid) {
+ int client = GetClientOfUserId(userid);
+ if(client > 0) {
+ SetEntProp(client, Prop_Send, "m_iHideHUD", 0);
+ }
+ return Plugin_Handled;
+}
\ No newline at end of file
diff --git a/scripting/include/feedthetrolls/trolls.inc b/scripting/include/feedthetrolls/trolls.inc
new file mode 100644
index 0000000..feca0cb
--- /dev/null
+++ b/scripting/include/feedthetrolls/trolls.inc
@@ -0,0 +1,560 @@
+// UP THE VALUE 'MAX_TROLLS' in base.inc before adding new ones!
+
+int t_slipperyShoesIndex = 0;
+int t_stickyGooIndex = 0;
+int t_invertedTrollIndex;
+int t_randomizeAnglesIndex;
+int t_randomizeVelocityIndex;
+int t_vomitPlayerIndex;
+int t_shakeyCameraIndex;
+int t_slotRouletteIndex;
+int t_damageBoostIndex;
+int t_reverseFFIndex;
+int t_throwItAllIndex;
+int t_hideHUDIndex;
+
+void SetupTrolls() {
+ trollKV = new StringMap();
+ categories = new ArrayList(ByteCountToCells(16));
+ gRandomClients = new ArrayList();
+ int index;
+ SetupTroll("Reset User", "Resets the user, removes all troll effects", TrollMod_Instant);
+
+ /// CATEGORY: Magnets
+ SetCategory("Magnets");
+ index = SetupTroll("Special Magnet", "Attracts ALL specials to any alive target with this troll enabled", TrollMod_Constant);
+ AddMagnetFlags(index);
+ index = SetupTroll("Tank Magnet", "Attracts ALL tanks to any alive target with this troll enabled", TrollMod_Constant);
+ AddMagnetFlags(index);
+ #if defined _actions_included
+ index = SetupTroll("Witch Magnet", "All witches when startled will target any player with this troll", TrollMod_Constant);
+ #endif
+ index = SetupTroll("Projectile Magnet", "Makes all projectiles (biles, molotovs, pipes, tank rocks) go to player", TrollMod_Constant);
+ Trolls[index].AddCustomFlagPrompt("Target Sources", true);
+ // Tied to: ProjectileMagnetType
+ Trolls[index].AddFlag("Infected (rocks/goo)", true);
+ Trolls[index].AddFlag("Teammates (grenades)", false);
+ Trolls[index].AddFlag("Thrown Tank Objects", false);
+
+ /// CATEGORY: Infected
+ SetCategory("Infected");
+ SetupTroll("Swarm", "Swarms a player with zombies. Requires swarm plugin", TrollMod_Instant | TrollMod_Constant);
+ t_vomitPlayerIndex = SetupTroll("Vomit Player", "Shortcut to sm_vomitplayer. vomits the player.", TrollMod_Instant | TrollMod_Constant);
+ index = SetupTroll("Insta Special", "Shortcut to sm_insta", TrollMod_Instant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Around them (Director)", true);
+ Trolls[index].AddFlag("On top / in-face", false);
+ SetupTroll("Goo", "Spawns a spitter puddle underneath them", TrollMod_Instant);
+ index = SetupTroll("Sticky Goo", "Slows player down in goo", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("90% Movement Speed", true);
+ Trolls[index].AddFlag("80% Movement Speed", false);
+ Trolls[index].AddFlag("70% Movement Speed", false);
+ Trolls[index].AddFlag("50% Movement Speed", false);
+ Trolls[index].AddFlag("30% Movement Speed", false);
+ Trolls[index].AddFlag("0% Movement Speed", false);
+ t_stickyGooIndex = index;
+ index = SetupTroll("Vocalize Specials", "Spawn commons on special vocals", TrollMod_Constant)
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Mute Vocalization", true);
+ Trolls[index].AddFlag("Do not mute", false);
+ index = SetupTroll("Instant Commons", "Spawns commons behind or infront", TrollMod_Instant | TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("In Back", true);
+ Trolls[index].AddFlag("In Front", false);
+ index = SetupTroll("Smart Charge", "Waits until coast is clear to charge", TrollMod_Constant);
+ Trolls[index].AddCustomFlagPrompt("Attempt Timeout", false);
+ Trolls[index].AddFlag("15 Seconds", true);
+ Trolls[index].AddFlag("30 Seconds", false);
+ Trolls[index].AddFlag("1 minute", false);
+ Trolls[index].AddFlag("5 minutes", false);
+
+ // CATEGORY: Projectiles
+ SetCategory("Projectiles");
+ index = SetupTroll("Rock Dropper", "Drops on a rock. On their head.", TrollMod_Instant);
+ // Trolls[index].AddFlagPrompt(false);
+ // Trolls[index].AddFlag("Drop From Above", true);
+ // Trolls[index].AddFlag("From behind", false);
+ index = SetupTroll("Car Splat", "Car. splats.", TrollMod_Instant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("On Top", true);
+ Trolls[index].AddFlag("Into (Infront)", false);
+ Trolls[index].AddFlag("Into (Behind)", false);
+ index = SetupTroll("Bad Throw", "Player drops throwables on throw, and biles/molotovs themselves", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(true);
+ Trolls[index].AddFlag("Biles", true);
+ Trolls[index].AddFlag("Molotovs", true);
+ Trolls[index].AddFlag("Pipebombs", true);
+ index = SetupTroll("Molotov Bath", "Throws a molotov on their feet", TrollMod_Instant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Normal", true);
+ Trolls[index].AddFlag("Set the town ablaze", false);
+
+ // CATEGORY: Items
+ SetCategory("Items");
+ index = SetupTroll("Throw It All", "Player throws their item(s) periodically to a nearby player", TrollMod_Instant);
+ Trolls[index].SetTimer(THROWITALL_INTERVAL, Timer_ThrowTimer);
+ index = SetupTroll("Spicy Gas", "Gascans player picks up just ignite. Magic.", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Always (100%)", false);
+ Trolls[index].AddFlag("Half Time (50%)", true);
+ Trolls[index].AddFlag("Rare (10%)", false);
+ index = SetupTroll("No Pickup", "Prevents a player from picking up ANY (new) item. Use ThrowItAll to make them drop", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(true);
+ Trolls[index].AddFlag("No Primary", false);
+ Trolls[index].AddFlag("No Melee", false);
+ Trolls[index].AddFlag("No Throwables", true);
+ Trolls[index].AddFlag("No Kits", true);
+ Trolls[index].AddFlag("No Pills / Adr", true);
+ Trolls[index].AddFlag("No GASCANS", true);
+ index = SetupTroll("UziRules / AwpSmells", "Picking up a weapon gives them a UZI or AWP instead", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("UZI Only", true);
+ Trolls[index].AddFlag("AWP Only", false);
+ SetupTroll("Primary Disable", "Player cannot pickup any weapons, only melee/pistols", TrollMod_Constant);
+ index = SetupTroll("Dull Melee", "Player's melee weapon does 0 damage (based on %). Headshots still work", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Always (100%)", false);
+ Trolls[index].AddFlag("Half Time (50%)", true);
+ Trolls[index].AddFlag("Rare (10%)", false);
+ SetupTroll("Nerf Gun", "When they shoot it does no damage.", TrollMod_Constant);
+ SetupTroll("Randomize Clip Ammo", "Randomly changes their clip ammo downwards", TrollMod_Constant | TrollMod_Instant);
+ SetupTroll("CameTooEarly", "When they shoot, random chance they empty whole clip", TrollMod_Constant);
+ index = SetupTroll("Slot Roulette", "Randomize their slots", TrollMod_Constant);
+ Trolls[index].AddCustomFlagPrompt("Activations:", true);
+ Trolls[index].AddFlag("On Vomitted", false); // 1
+ Trolls[index].AddFlag("On Damage", false); // 2
+ Trolls[index].AddFlag("On Vocalize", false); // 4
+ Trolls[index].AddFlag("Periodically", true); //8
+ Trolls[index].AddCustomFlagPrompt("Frequency:", false, 8);
+ Trolls[index].AddFlag("Subtle", false); // 16
+ Trolls[index].AddFlag("Confusing", false); // 32
+ Trolls[index].AddFlag("Annoying", false); // 64
+ Trolls[index].AddFlag("Unusable", false); // 128
+ Trolls[index].SetTimer(0.2, Timer_SlotRoulette, 8);
+ t_slotRouletteIndex = index;
+
+
+ /// CATEGORY: Chat
+ SetCategory("Chat");
+ SetupTroll("Typoos", "", TrollMod_Constant);
+ SetupTroll("iCantSpellNoMore", "Chat messages letter will randomly changed with wrong letters", TrollMod_Constant);
+ index = SetupTroll("No Profanity", "Replaces some words with random phrases", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Only Replace Swears", false);
+ Trolls[index].AddFlag("Replace Full Messages", true);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Show Modified to Them", true);
+ Trolls[index].AddFlag("Show Original to Them", false);
+ index = SetupTroll("Vocalize Gag", "Prevents player from sending any vocalizations (even automatic)", TrollMod_Constant);
+ // Trolls[index].AddFlagPrompt(false);
+ // Trolls[index].AddFlag("Mute for All", true);
+ // Trolls[index].AddFlag("Mute For All But Them", false);
+ index = SetupTroll("Honk / Meow / Woof", "Custom sounds", TrollMod_Constant);
+ Trolls[index].AddCustomFlagPrompt("Choose Sound:");
+ Trolls[index].AddFlag("Honk", true);
+ Trolls[index].AddFlag("Meow", false);
+ Trolls[index].AddFlag("Woof", false);
+ Trolls[index].AddCustomFlagPrompt("Choose Chat modifier:", false, 1);
+ Trolls[index].AddFlag("Show Modified to Them", true);
+ Trolls[index].AddFlag("Show Original to Them", false);
+ Trolls[index].AddFlag("Show Modified Only To Them", false);
+ SetupTroll("Reversed", "Reserves their message", TrollMod_Constant);
+ SetupTroll("Voice Mute", "Mutes from voice", TrollMod_Constant);
+ SetupTroll("No Rushing Us", "Decreases player speed everytime they yell hurry up", TrollMod_Constant);
+
+ /// CATEGORY: Health
+ SetCategory("Health");
+ t_damageBoostIndex = SetupTroll("Damage Boost", "Makes a player take more damage than normal", TrollMod_Constant);
+ SetupTroll("Temp Health Quick Drain", "Makes a player's temporarily health drain very quickly", TrollMod_Constant);
+ SetupTroll("Slow Drain", "Will make the player slowly lose health over time", TrollMod_Constant);
+ SetupTroll("KillMeSoftly", "Make player eat or waste pills whenever possible", TrollMod_Instant | TrollMod_Constant);
+ index = SetupTroll("Reverse FF", "All damage dealt to a player is reversed", TrollMod_Constant);
+ Trolls[index].AddCustomFlagPrompt("Choose Reverse FF", false);
+ Trolls[index].AddFlag("1:1 Ratio", true); //1
+ Trolls[index].AddFlag("2x Ratio", false); //2
+ Trolls[index].AddFlag("0.5x Ratio", false); //4
+ Trolls[index].AddFlag("0.0x Ratio (None)", false); //8
+ Trolls[index].AddFlag("3x Ratio", false); //16
+ Trolls[index].AddCustomFlagPrompt("Modes", true);
+ Trolls[index].AddFlag("Reverse Fire Damage", false); //32
+ Trolls[index].AddFlag("Reverse Explosions", false); //64
+ t_reverseFFIndex = index;
+
+
+ index = SetupTroll("Dep Bots", "Makes bots heal a player. At any cost", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Do not spawn extra", true); // 1
+ Trolls[index].AddFlag("Spawn extra bots (broke)", false); // 2
+ Trolls[index].AddCustomFlagPrompt("# Of Bots", false);
+ Trolls[index].AddFlag("1", false); // 4
+ Trolls[index].AddFlag("2", false); // 8
+ Trolls[index].AddFlag("3", false); // 16
+ Trolls[index].AddFlag("4", true); // 32
+ Trolls[index].AddFlag("5", false); // 64
+ Trolls[index].AddCustomFlagPrompt("Auto Timeout", false, 0);
+ Trolls[index].AddFlag("Until Healed / Map Change", false); // 128
+ Trolls[index].AddFlag("15 seconds", true); // 255
+ Trolls[index].AddFlag("30 seconds", false); // 512
+ Trolls[index].AddFlag("1 minute", false); //1024
+ Trolls[index].AddFlag("5 minutes", false); //2048
+
+ /// CATEGORY: Movement
+ SetCategory("Movement");
+ index = SetupTroll("Slow Speed", "Sets player speed to 0.8x of normal speed", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("90% Movement Speed", true);
+ Trolls[index].AddFlag("80% Movement Speed", false);
+ Trolls[index].AddFlag("70% Movement Speed", false);
+ Trolls[index].AddFlag("50% Movement Speed", false);
+ Trolls[index].AddFlag("30% Movement Speed", false);
+ Trolls[index].AddFlag("0% Movement Speed", false);
+ SetupTroll("Higher Gravity", "Sets player gravity to 1.3x of normal gravity", TrollMod_Constant);
+ t_invertedTrollIndex = SetupTroll("Inverted Controls", "Well, aint it obvious", TrollMod_Constant);
+ SetupTroll("Stagger", "Like a slap, but different", TrollMod_Instant);
+ index = SetupTroll("Slippery Shoes", "Periodically stumbles around.", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(true);
+ Trolls[index].AddFlag("Periodically", true);
+ Trolls[index].AddFlag("When using doors", false);
+ Trolls[index].AddFlag("On throwable use", false);
+ Trolls[index].AddFlag("On pills/adrenaline use", false);
+ Trolls[index].AddFlag("On zombie bite", false);
+ t_slipperyShoesIndex = index;
+ index = SetupTroll("Randomize Angles", "Randomly change their angles", TrollMod_Constant);
+ Trolls[index].AddCustomFlagPrompt("Frequency:", false);
+ Trolls[index].AddFlag("Once in a while", true); //1
+ Trolls[index].AddFlag("Periodically", false); //2
+ Trolls[index].AddFlag("A lot", false); //4
+ Trolls[index].AddFlag("Painful", false); //8
+ Trolls[index].AddFlag("Seizure", false); //16
+ t_randomizeAnglesIndex = index;
+ index = SetupTroll("Randomize Velocity", "Randomly change their velocity", TrollMod_Constant);
+ Trolls[index].SetTimer(0.1, Timer_RandomVelocity);
+ Trolls[index].AddCustomFlagPrompt("Frequency:", false);
+ Trolls[index].AddFlag("Loose", true); //1
+ Trolls[index].AddFlag("Slippery", false); //2
+ Trolls[index].AddFlag("Earthquake", false); //4
+ Trolls[index].AddFlag("Severe Earthquake", false); //8
+ Trolls[index].AddFlag("Bouncy Castle", false); //16
+ t_randomizeVelocityIndex = index;
+
+ /// CATEGORY: MISC
+ SetCategory("Misc");
+ SetupTroll("Gun Jam", "On reload, small chance their gun gets jammed - Can't reload.", TrollMod_Constant);
+ SetupTroll("No Shove", "Prevents a player from shoving", TrollMod_Constant);
+ index = SetupTroll("No Button Touchie", "Stops people from pressing buttons", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(true);
+ Trolls[index].AddFlag("Prevent Use", true);
+ Trolls[index].AddFlag("Vomit On Touch", false);
+ Trolls[index].AddFlag("Incap On Touch", false);
+ Trolls[index].AddFlag("Slay On Touch", false);
+ Trolls[index].AddFlag("0.8x Speed", false);
+ // TODO: setup instant
+ index = SetupTroll("Shakey Camera", "Horrible", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ // add flag: vomit on touch
+ Trolls[index].AddFlag("Annoying but playable", false);
+ Trolls[index].AddFlag("Bad", true);
+ Trolls[index].AddFlag("Sickness", false);
+ Trolls[index].AddFlag("Violent", false);
+ Trolls[index].AddFlag("Violent XX", false);
+ t_shakeyCameraIndex = index;
+ index = SetupTroll("Hide HUD", "Horrible", TrollMod_Constant);
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("Rare & Short", false);
+ Trolls[index].AddFlag("Sometimes & Medium", false);
+ Trolls[index].AddFlag("Constantly", true);
+ t_hideHUDIndex = index;
+ index = SetupTroll("Meta: Random", "Picks a random troll", TrollMod_Instant);
+ index = SetupTroll("Meta: Inverse", "Uhm you are not supposed to see this...", TrollMod_Instant);
+ Trolls[index].hidden = true;
+ Trolls[index].AddFlagPrompt(false);
+ Trolls[index].AddFlag("100%", true);
+ Trolls[index].AddFlag("50%", false);
+ Trolls[index].AddFlag("10%", false);
+
+
+
+
+
+ // Initialize the default flag values to -1
+ for(int i = 0; i <= MAX_TROLLS; i++) {
+ for(int j = 1; j <= MAXPLAYERS; j++) {
+ Trolls[i].timerHandles[j] = null;
+ Trolls[i].activeFlagClients[j] = -1;
+ }
+ }
+
+}
+
+void AddMagnetFlags(int index) {
+ Trolls[index].AddCustomFlagPrompt("Choose Magnet Chance:", false);
+ Trolls[index].AddFlag("Always (100%)", true);
+ Trolls[index].AddFlag("Half Time (50%)", false);
+ Trolls[index].AddFlag("Rare (10%)", false);
+}
+
+TrollEffectResponse ApplyAffect(int victim, const Troll troll, int activator, trollModifier modifier, int flags) {
+ bool toActive = IsTrollActiveByRawID(victim, troll.id);
+ if(StrEqual(troll.name, "Reset User")) {
+ LogAction(activator, victim, "\"%L\" reset all effects for \"%L\"", activator, victim);
+ ShowActivityEx(activator, "[FTT] ", "reset effects for %N. ", victim);
+ // for(int i = 0; i <= MAX_TROLLS; i++) {
+ // Trolls[i].activeFlagClients[victim] = -1;
+ // }
+ // SetEntityGravity(victim, 1.0);
+ // SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
+ ResetClient(victim, true);
+ return TE_Error; // Not an error, but don't want to show activation
+ } else if(StrEqual(troll.name, "Slow Speed")) {
+ if(toActive) {
+ float movement = 0.0;
+ if(flags & 1) movement = 0.9;
+ else if(flags & 2) movement = 0.8;
+ else if(flags & 4) movement = 0.7;
+ else if(flags & 8) movement = 0.5;
+ else if(flags & 16) movement = 0.3;
+ SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", movement);
+ } else
+ SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
+ } else if(StrEqual(troll.name, "Higher Gravity"))
+ SetEntityGravity(victim, toActive ? 1.3 : 1.0);
+ else if(StrEqual(troll.name, "UziRules / AwpSmells")) {
+ DisableTroll(victim, "No Pickup");
+ DisableTroll(victim, "Primary Disable");
+ } else if(StrEqual(troll.name, "Primary Disable")) {
+ DisableTroll(victim, "UziRules / AwpSmells");
+ DisableTroll(victim, "No Pickup");
+ SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
+ } else if(StrEqual(troll.name, "No Pickup")) {
+ DisableTroll(victim, "UziRules / AwpSmells");
+ DisableTroll(victim, "Primary Disable");
+ SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
+ } else if(StrEqual(troll.name, "CameTooEarly")) {
+ ReplyToCommand(activator, "This troll mode is not implemented.");
+ } else if(StrEqual(troll.name, "KillMeSoftly")) {
+ static char wpn[32];
+ GetClientWeaponName(victim, 4, wpn, sizeof(wpn));
+ if(StrEqual(wpn, "weapon_adrenaline") || StrEqual(wpn, "weapon_pain_pills")) {
+ SetSlot(victim, 5);
+ pdata[victim].flags |= view_as(Flag_PendingItemGive);
+ }else{
+ ReplyToCommand(activator, "User does not have pills or adrenaline");
+ return TE_Error;
+ }
+ //TODO: Implement TrollMod_Constant
+ return TE_Error;
+ } else if(StrEqual(troll.name, "Throw It All")) {
+ if(modifier & TrollMod_Instant) {
+ if(flags & 1) { // Hacky, just throw their kit
+ ThrowItemToPlayer(victim, activator, 3);
+ } else ThrowAllItems(victim);
+ }
+ } else if(StrEqual(troll.name, "Swarm")) {
+ if(modifier & TrollMod_Instant) {
+ L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", victim, 15000);
+ }
+ } else if(StrEqual(troll.name, "Gun Jam")) {
+ int wpn = GetClientWeaponEntIndex(victim, 0);
+ if(wpn > -1)
+ SDKHook(wpn, SDKHook_Reload, Event_WeaponReload);
+ else {
+ ReplyToCommand(activator, "Victim does not have a primary weapon.");
+ return TE_Error;
+ }
+ } else if(StrEqual(troll.name, "Vomit Player"))
+ L4D_CTerrorPlayer_OnVomitedUpon(victim, victim);
+ else if(StrEqual(troll.name, "Insta Special")) {
+ int mode = 0;
+ if(flags & 2) mode = 1;
+ ShowInstaSpecialChooser(activator, GetClientUserId(victim), mode);
+ return TE_Menu;
+ } else if(StrEqual(troll.name, "Goo")) {
+ static float pos[3], ang[3];
+ GetClientAbsOrigin(victim, pos);
+ GetClientAbsAngles(victim, ang);
+ L4D2_SpitterPrj(victim, pos, ang);
+ } else if(StrEqual(troll.name, "Stagger")) {
+ L4D_StaggerPlayer(victim, victim, NULL_VECTOR);
+ } else if(StrEqual(troll.name, "Voice Mute")) {
+ BaseComm_SetClientMute(victim, toActive);
+ } else if(StrEqual(troll.name, "Spicy Gas")) {
+ SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
+ } else if(StrEqual(troll.name, "Car Splat")) {
+ if(flags & 1) {
+ if(!SpawnCarOnPlayer(victim)) {
+ ReplyToCommand(activator, "Could not find a suitable area to spawn a car. Requires vertical space above victim.");
+ return TE_Error;
+ }
+ } else if(flags & 2) {
+ if(!SpawnCarToPlayer(victim, 450.0)) {
+ ReplyToCommand(activator, "Could not find a suitable area to spawn a car. Requires space ahead of victim");
+ return TE_Error;
+ }
+ } else if(flags & 4) {
+ if(!SpawnCarToPlayer(victim, -450.0)) {
+ ReplyToCommand(activator, "Could not find a suitable area to spawn a car. Requires space behind victim");
+ return TE_Error;
+ }
+ }
+ } else if(StrEqual(troll.name, "Instant Commons")) {
+ if(modifier & TrollMod_Instant) {
+ float pos[3];
+ GetHorizontalPositionFromClient(victim, flags & 1 ? -40.0 : 40.0, pos);
+ int victimId = GetClientUserId(victim);
+ for(int i = 0; i < 30; i++) {
+ int c = L4D_SpawnCommonInfected(pos);
+ L4D2_RunScript("CommandABot({cmd=0,bot=EntIndexToHScript(%i),target=GetPlayerFromUserID(%i)})", c, victimId);
+ }
+ }
+ } else if(StrEqual(troll.name, "Randomize Clip Ammo")) {
+ if(modifier & TrollMod_Instant) {
+ int primaryWpn = GetPlayerWeaponSlot(victim, 0);
+ if(primaryWpn > 0) {
+ int maxCap = GetEntProp(primaryWpn, Prop_Send, "m_iClip1");
+ SetEntProp(primaryWpn, Prop_Send, "m_iClip1", GetRandomInt(0, maxCap));
+ }
+ }
+ } else if(StrEqual(troll.name, "Rock Dropper")) {
+ float pos[3], dropPos[3];
+ GetClientEyePosition(victim, pos);
+ dropPos = pos;
+ dropPos[2] += 150.0;
+ TR_TraceRayFilter(pos, dropPos, MASK_SOLID, RayType_EndPoint, Filter_IgnorePlayer, victim);
+ if(TR_DidHit()) {
+ ReplyToCommand(activator, "Could not find a suitable area. Requires vertical space.");
+ return TE_Error;
+ }
+ float ang[3];
+ ang[0] = 90.0;
+ L4D_TankRockPrj(0, dropPos, ang);
+ } else if(StrEqual(troll.name, "Molotov Bath")) {
+ int count = 1;
+ if(flags & 2) count = 8;
+ float pos[3], dropPos[3];
+ GetClientEyePosition(victim, pos);
+ dropPos = pos;
+ dropPos[2] += 20.0;
+ TR_TraceRayFilter(pos, dropPos, MASK_SOLID, RayType_EndPoint, Filter_IgnorePlayer, victim);
+ if(TR_DidHit()) {
+ ReplyToCommand(activator, "Could not find a suitable area. Requires vertical space.");
+ return TE_Error;
+ }
+ if(IsAnySurvivorInRange(pos, 55.0, victim)) {
+ ReplyToCommand(activator, "Victim is too close to other players.");
+ return TE_Error;
+ }
+ float vel[3];
+ vel[2] = -90.0;
+ for(int i = 0; i < count; i++) {
+ L4D_MolotovPrj(victim, dropPos, vel);
+ }
+ } else if(StrEqual(troll.name, "Dep Bots")) {
+ if(!toActive) {
+ StopHealingBots();
+ return TE_Success;
+ } else if(healTargetPlayer != 0) {
+ if(stopHealingTimer != null) {
+ TriggerTimer(stopHealingTimer);
+ }
+ return TE_Success;
+ }
+ bool spawnExtra = flags & 2 > 0;
+
+ int numBots = 4;
+ if(flags & 4) numBots = 1;
+ else if(flags & 8) numBots = 2;
+ else if(flags & 16) numBots = 3;
+ else if(flags & 64) numBots = 5;
+
+ float timeout = 0.0;
+ if(flags & 255) timeout = 15.0;
+ else if(flags & 512) timeout = 30.0;
+ else if(flags & 1024) timeout = 60.0;
+ else if(flags & 2048) timeout = 300.0;
+
+ // TODO: Extract this !!
+ healTargetPlayer = GetClientUserId(victim);
+
+ char buffer[32];
+ for(int i = 1; i <= MaxClients; i++) {
+ if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2 && IsFakeClient(i)) {
+ int kit = GetPlayerWeaponSlot(i, 3);
+ if(kit > 0) {
+ GetEntityClassname(kit, buffer, sizeof(buffer));
+ if(StrEqual(buffer, "weapon_first_aid_kit")) {
+ PrintToServer("[FTT] Dep Bots: Found bot %N", i);
+ pdata[i].flags |= view_as(Flag_IsTargettingHealer);
+
+ if(--numBots == 0) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ CreateTimer(2.0, Timer_UpdateHealTargetPos, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ if(timeout > 0.0) {
+ DataPack pack;
+ stopHealingTimer = CreateDataTimer(timeout, Timer_StopHealBots, pack);
+ pack.WriteCell(GetClientUserId(activator));
+ pack.WriteCell(GetClientUserId(victim))
+ }
+
+ if(spawnExtra && numBots > 0) {
+ if(hAbmAutoHard != null) {
+ wasAbmAutoHard = hAbmAutoHard.IntValue;
+ hAbmAutoHard.IntValue = 0;
+ }
+ CreateTimer(0.2, Timer_SpawnHealBots, numBots, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
+ }
+
+ if(hSbFixEnabled != null) {
+ wasSbFixEnabled = hSbFixEnabled.BoolValue;
+ hSbFixEnabled.BoolValue = false;
+ }
+ } else if(StrEqual(troll.name, "Smart Charge")) {
+ if(pdata[victim].smartChargeActivator > 0) {
+ ReplyToCommand(activator, "Target already has smart charge enabled");
+ return TE_Error;
+ }
+ int timeout = 15;
+ if(flags & 2) timeout = 30;
+ else if(flags & 4) timeout = 60;
+ else if(flags & 8) timeout = 300;
+ pdata[victim].smartChargeAttempts = 0;
+ pdata[victim].smartChargeMaxAttempts = timeout;
+ pdata[victim].smartChargeActivator = GetClientUserId(activator);
+ CreateTimer(1.0, Timer_CheckForChargerOpportunity, GetClientUserId(victim), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
+ } else if(StrEqual(troll.name, "No Rushing Us")) {
+ SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
+ } else if(StrEqual(troll.name, "Hide HUD")) {
+ if(toActive)
+ HideHUDRandom(victim);
+ else
+ SetEntProp(victim, Prop_Send, "m_iHideHUD", 0);
+ } else if(StrEqual(troll.name, "Meta: Random")) {
+ int rndTroll = GetRandomInt(0, MAX_TROLLS);
+ int rndFlags = 0;
+ int maxFlags = Trolls[rndTroll].GetFlagCount();
+ int numFlags = GetRandomInt(0, maxFlags);
+ while(numFlags > 0) {
+ // Apply a random flag
+ rndFlags |= GetRandomInt(0, maxFlags)
+ numFlags--;
+ }
+ trollModifier rndMod = Trolls[rndTroll].GetDefaultMod();
+ if(Trolls[rndTroll].HasMod(TrollMod_Constant) && GetURandomFloat() > 0.5) {
+ rndMod = TrollMod_Instant;
+ } else if(Trolls[rndTroll].HasMod(TrollMod_Instant) && GetURandomFloat() > 0.5) {
+ rndMod = TrollMod_Constant;
+ }
+ Trolls[rndTroll].Activate(victim, activator, rndMod, rndFlags);
+ } else if(~modifier & TrollMod_Constant) {
+ PrintToServer("[FTT] Warn: Possibly invalid troll, no apply action defined for \"%s\"", troll.name);
+ #if defined DEBUG
+ ReplyToCommand(activator, "[FTT/Debug] If nothing occurs, this troll possibly was not implemented correctly. ");
+ #endif
+ }
+ return TE_Success;
+}
\ No newline at end of file
diff --git a/scripting/include/ftt.inc b/scripting/include/ftt.inc
new file mode 100644
index 0000000..7242a69
--- /dev/null
+++ b/scripting/include/ftt.inc
@@ -0,0 +1,120 @@
+enum L4D2Infected
+{
+ L4D2Infected_None = 0,
+ L4D2Infected_Smoker = 1,
+ L4D2Infected_Boomer = 2,
+ L4D2Infected_Hunter = 3,
+ L4D2Infected_Spitter = 4,
+ L4D2Infected_Jockey = 5,
+ L4D2Infected_Charger = 6,
+ L4D2Infected_Witch = 7,
+ L4D2Infected_Tank = 8
+};
+
+GlobalForward g_PlayerMarkedForward;
+GlobalForward g_TrollAppliedForward;
+Handle g_hWitchAttack;
+int g_iWitchAttackVictim;
+
+ConVar hAllowEnemyTeam;
+ConVar hAutoPunish;
+ConVar hShoveFailChance;
+ConVar hAutoPunishExpire;
+ConVar hMagnetTargetMode;
+ConVar hBadThrowHitSelf;
+ConVar hBotReverseFFDefend;
+ConVar hSbFriendlyFire;
+ConVar hBotDefendChance;
+ConVar hAntirushBaseFreq;
+ConVar hAntirushIncFreq
+
+ConVar hSbFixEnabled;
+bool wasSbFixEnabled;
+
+int wasAbmAutoHard;
+ConVar hAbmAutoHard;
+
+enum playerDataFlags {
+ Flag_PendingItemGive = 1,
+ Flag_HasSpitTimer = 2,
+ Flag_IsTargettingHealer = 4
+}
+
+enum struct PlayerData {
+ int flags;
+
+ int attackerTargetUid;
+ int specialAttackFlags;
+ int pendingTrollBan; // Includes ent index of activator
+
+ float lastInSpitTime;
+
+ int shootAtTarget;
+ int shootAtLoops;
+ int shootAtTargetHealth;
+
+ int smartChargeAttempts;
+ int smartChargeMaxAttempts;
+ int smartChargeActivator;
+
+ char steamid[32];
+
+ void Reset() {
+ this.flags = 0;
+ this.attackerTargetUid = 0;
+ this.specialAttackFlags = 0;
+ this.pendingTrollBan = 0;
+ this.lastInSpitTime = 0.0;
+ this.shootAtTarget = 0;
+ this.shootAtLoops = 0;
+ this.smartChargeAttempts = 0;
+ this.steamid[0] = '\0';
+ }
+}
+
+PlayerData pdata[MAXPLAYERS+1];
+
+int lastButtonUser;
+int lastCrescendoUser;
+
+bool spIsActive;
+enum SpecialSpawnFlags {
+ Special_Anywhere = 0,
+ Special_OnTarget = 1,
+ Special_SpawnDirectOnFailure = 2,
+ Special_KillOnIncap = 4,
+ Special_AlwaysTarget = 8
+}
+
+enum SpecialInternalFlags {
+ SPI_KillOnSpawn = 1,
+ SPI_AlwaysTarget = 2,
+ SPI_KillOnTargetIncap = 4
+}
+
+int healTargetPlayer;
+float healTargetPos[3];
+Handle stopHealingTimer;
+
+float entLastHeight[2048];
+
+float fLastAntiRushEvent[MAXPLAYERS+1];
+float fAntiRushFrequencyCounter[MAXPLAYERS+1];
+
+float noRushingUsSpeed[MAXPLAYERS+1];
+
+
+
+#define MODEL_CAR "models/props_vehicles/cara_95sedan.mdl"
+
+
+#include