initial revert to 1.00-era code

This commit is contained in:
David Anderson 2006-02-26 06:42:48 +00:00
parent 4db61f243a
commit 8735bf3df3
15 changed files with 827 additions and 1063 deletions

View File

@ -36,8 +36,7 @@
// class CPlayer // class CPlayer
// ***************************************************** // *****************************************************
void CPlayer::Disconnect() void CPlayer::Disconnect(){
{
if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused
return; return;
rank->updatePosition( &life ); rank->updatePosition( &life );

View File

@ -126,9 +126,5 @@ struct CPlayer {
} }
}; };
// *****************************************************
// class Forward
// *****************************************************
#endif // CMISC_H #endif // CMISC_H

View File

@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. 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.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE 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.
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
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision 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, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This 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 Library General
Public License instead of this License.

View File

@ -36,13 +36,11 @@
// ***************************************************** // *****************************************************
// class Stats // class Stats
// ***************************************************** // *****************************************************
Stats::Stats() Stats::Stats(){
{
hits = shots = damage = hs = tks = kills = deaths = 0; hits = shots = damage = hs = tks = kills = deaths = 0;
memset( bodyHits , 0 ,sizeof( bodyHits ) ); memset( bodyHits , 0 ,sizeof( bodyHits ) );
} }
void Stats::commit(Stats* a) void Stats::commit(Stats* a){
{
hits += a->hits; hits += a->hits;
shots += a->shots; shots += a->shots;
damage += a->damage; damage += a->damage;
@ -50,14 +48,14 @@ void Stats::commit(Stats* a)
tks += a->tks; tks += a->tks;
kills += a->kills; kills += a->kills;
deaths += a->deaths; deaths += a->deaths;
for(int i = 1; i < 8; ++i) bodyHits[i] += a->bodyHits[i]; for(int i = 1; i < 8; ++i)
bodyHits[i] += a->bodyHits[i];
} }
// ***************************************************** // *****************************************************
// class RankSystem // class RankSystem
// ***************************************************** // *****************************************************
RankSystem::RankStats::RankStats( const char* uu, const char* nn, RankSystem* pp ) RankSystem::RankStats::RankStats( const char* uu, const char* nn, RankSystem* pp ) {
{
name = 0; name = 0;
namelen = 0; namelen = 0;
unique = 0; unique = 0;
@ -69,92 +67,77 @@ RankSystem::RankStats::RankStats( const char* uu, const char* nn, RankSystem* pp
setName( nn ); setName( nn );
setUnique( uu ); setUnique( uu );
} }
RankSystem::RankStats::~RankStats() RankSystem::RankStats::~RankStats() {
{ delete[] name;
delete name; delete[] unique;
delete unique;
--parent->rankNum; --parent->rankNum;
} }
void RankSystem::RankStats::setName( const char* nn ) void RankSystem::RankStats::setName( const char* nn ) {
{
delete[] name; delete[] name;
namelen = strlen(nn) + 1; namelen = strlen(nn) + 1;
name = new char[namelen]; name = new char[namelen];
if ( name )
if ( name ) strcpy( name , nn ); strcpy( name , nn );
else namelen = 0; else
namelen = 0;
} }
void RankSystem::RankStats::setUnique( const char* nn ) void RankSystem::RankStats::setUnique( const char* nn ) {
{ delete[] unique;
delete unique;
uniquelen = strlen(nn) + 1; uniquelen = strlen(nn) + 1;
unique = new char[uniquelen]; unique = new char[uniquelen];
if ( unique )
if ( unique ) strcpy( unique , nn ); strcpy( unique , nn );
else uniquelen = 0; else
uniquelen = 0;
} }
RankSystem::RankSystem() RankSystem::RankSystem() {
{
head = 0; head = 0;
tail = 0; tail = 0;
rankNum = 0; rankNum = 0;
calc.code = 0; calc.code = 0;
} }
RankSystem::~RankSystem() RankSystem::~RankSystem() {
{
clear(); clear();
} }
void RankSystem::put_before( RankStats* a, RankStats* ptr ) void RankSystem::put_before( RankStats* a, RankStats* ptr ){
{
a->next = ptr; a->next = ptr;
if ( ptr ) if ( ptr ){
{
a->prev = ptr->prev; a->prev = ptr->prev;
ptr->prev = a; ptr->prev = a;
} }
else else{
{
a->prev = head; a->prev = head;
head = a; head = a;
} }
if ( a->prev ) a->prev->next = a; if ( a->prev ) a->prev->next = a;
else tail = a; else tail = a;
} }
void RankSystem::put_after( RankStats* a, RankStats* ptr ) void RankSystem::put_after( RankStats* a, RankStats* ptr ) {
{
a->prev = ptr; a->prev = ptr;
if ( ptr ) if ( ptr ){
{
a->next = ptr->next; a->next = ptr->next;
ptr->next = a; ptr->next = a;
} }
else else{
{
a->next = tail; a->next = tail;
tail = a; tail = a;
} }
if ( a->next ) a->next->prev = a; if ( a->next ) a->next->prev = a;
else head = a; else head = a;
} }
void RankSystem::unlink( RankStats* ptr ) void RankSystem::unlink( RankStats* ptr ){
{
if (ptr->prev) ptr->prev->next = ptr->next; if (ptr->prev) ptr->prev->next = ptr->next;
else tail = ptr->next; else tail = ptr->next;
if (ptr->next) ptr->next->prev = ptr->prev; if (ptr->next) ptr->next->prev = ptr->prev;
else head = ptr->prev; else head = ptr->prev;
} }
void RankSystem::clear() void RankSystem::clear(){
{ while( tail ){
while( tail )
{
head = tail->next; head = tail->next;
delete tail; delete tail;
tail = head; tail = head;
@ -166,8 +149,7 @@ bool RankSystem::loadCalc(const char* filename, char* error)
if ((MF_LoadAmxScript(&calc.amx,&calc.code,filename,error,0)!=AMX_ERR_NONE)|| if ((MF_LoadAmxScript(&calc.amx,&calc.code,filename,error,0)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)|| (MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)|| (MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)||
(MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)) (MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){
{
MF_PrintSrvConsole("Couldn't load plugin (file \"%s\")",filename); MF_PrintSrvConsole("Couldn't load plugin (file \"%s\")",filename);
MF_UnloadAmxScript(&calc.amx, &calc.code); MF_UnloadAmxScript(&calc.amx, &calc.code);
return false; return false;
@ -185,16 +167,14 @@ RankSystem::RankStats* RankSystem::findEntryInRank(const char* unique, const cha
while ( a ) while ( a )
{ {
if ( strcmp( a->getUnique() ,unique ) == 0 ) return a; if ( strcmp( a->getUnique() ,unique ) == 0 )
return a;
a = a->prev; a = a->prev;
} }
a = new RankStats( unique ,name,this ); a = new RankStats( unique ,name,this );
if ( a == 0 ) return 0; if ( a == 0 ) return 0;
put_after( a , 0 ); put_after( a , 0 );
return a; return a;
} }
@ -202,8 +182,7 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
{ {
rr->addStats( s ); rr->addStats( s );
if ( calc.code ) if ( calc.code ) {
{
calc.physAddr1[0] = rr->kills; calc.physAddr1[0] = rr->kills;
calc.physAddr1[1] = rr->deaths; calc.physAddr1[1] = rr->deaths;
calc.physAddr1[2] = rr->hs; calc.physAddr1[2] = rr->hs;
@ -211,25 +190,20 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
calc.physAddr1[4] = rr->shots; calc.physAddr1[4] = rr->shots;
calc.physAddr1[5] = rr->hits; calc.physAddr1[5] = rr->hits;
calc.physAddr1[6] = rr->damage; calc.physAddr1[6] = rr->damage;
for(int i = 1; i < 8; ++i)
for(int i = 1; i < 8; ++i) calc.physAddr2[i] = rr->bodyHits[i]; calc.physAddr2[i] = rr->bodyHits[i];
cell result = 0; cell result = 0;
int err; int err;
MF_AmxPush(&calc.amx, calc.amxAddr2); MF_AmxPush(&calc.amx, calc.amxAddr2);
MF_AmxPush(&calc.amx, calc.amxAddr1); MF_AmxPush(&calc.amx, calc.amxAddr1);
if ((err = MF_AmxExec(&calc.amx, &result, calc.func)) != AMX_ERR_NONE)
if ((err = MF_AmxExec(&calc.amx,&result, calc.func)) != AMX_ERR_NONE) MF_Log("Run time error %d on line (plugin \"%s\")", err, LOCALINFO("csstats_score"));
MF_LogError(&calc.amx, err, "Fatal error calculating stats");
rr->score = result; rr->score = result;
} }
else rr->score = rr->kills - rr->deaths; else rr->score = rr->kills - rr->deaths;
RankStats* aa = rr->next; RankStats* aa = rr->next;
while ( aa && (aa->score <= rr->score) ) { // try to nominate
while ( aa && (aa->score <= rr->score) )
{ // try to nominate
rr->goUp(); rr->goUp();
aa->goDown(); aa->goDown();
aa = aa->next; // go to next rank aa = aa->next; // go to next rank
@ -242,14 +216,12 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
else else
{ {
aa = rr->prev; aa = rr->prev;
while ( aa && (aa->score > rr->score) ) while ( aa && (aa->score > rr->score) ) { // go down
{ // go down
rr->goDown(); rr->goDown();
aa->goUp(); aa->goUp();
aa = aa->prev; // go to prev rank aa = aa->prev; // go to prev rank
} }
if ( aa != rr->prev ) if ( aa != rr->prev ){
{
unlink( rr ); unlink( rr );
put_after( rr, aa ); put_after( rr, aa );
} }

466
dlls/ts/tsx/NBase.cpp Executable file
View File

@ -0,0 +1,466 @@
/*
* Copyright (c) 2003-2004 Lukasz Wlasinski
*
* This file is part of TS XMod.
*
* TS XMod 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.
*
* TS XMod 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 TS XMod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "amxxmodule.h"
#include "tsx.h"
static cell AMX_NATIVE_CALL get_weapon_name(AMX *amx, cell *params)
{ // from id to name 3 params id, name, len
int id = params[1];
if (id<0 || id>=TSMAX_WEAPONS)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Weapon %d is not valid", id);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
}
static cell AMX_NATIVE_CALL wpnlog_to_name(AMX *amx, cell *params)
{ // from log to name
int iLen;
char *log = MF_GetAmxString(amx,params[1],0,&iLen);
int i;
for ( i=1; i<TSMAX_WEAPONS; i++ ){
if ( strcmp(log,weaponData[i].logname ) == 0 )
return MF_SetAmxString(amx,params[2],weaponData[i].name,params[3]);
}
return 0;
}
static cell AMX_NATIVE_CALL wpnlog_to_id(AMX *amx, cell *params)
{ // from log to id
int iLen;
char *log = MF_GetAmxString(amx,params[1],0,&iLen);
int i;
for (i=1; i<TSMAX_WEAPONS; i++ )
{
if ( strcmp(log,weaponData[i].logname) == 0 )
return i;
}
return 0;
}
static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params)
{ // from id to log
int id = params[1];
if (id<0 || id>=TSMAX_WEAPONS)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Weapon %d is not valid", id);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]);
}
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params)
{
int id = params[1];
if (id<1 || id>=TSMAX_WEAPONS)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Weapon %d is not valid", id);
return 0;
}
if ( weaponData[id].melee )
return 1;
return 0;
}
static cell AMX_NATIVE_CALL ts_get_user_weapon(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
int wpn = pPlayer->current;
cell *cpTemp = MF_GetAmxAddr(amx,params[2]);
*cpTemp = pPlayer->weapons[wpn].clip;
cpTemp = MF_GetAmxAddr(amx,params[3]);
*cpTemp = pPlayer->weapons[wpn].ammo;
cpTemp = MF_GetAmxAddr(amx,params[4]);
*cpTemp = pPlayer->weapons[wpn].mode;
cpTemp = MF_GetAmxAddr(amx,params[5]);
*cpTemp = pPlayer->weapons[wpn].attach;
return wpn;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
int wpn = pPlayer->current;
cell *cpTemp = MF_GetAmxAddr(amx,params[2]);
*cpTemp = pPlayer->weapons[wpn].clip;
cpTemp = MF_GetAmxAddr(amx,params[3]);
*cpTemp = pPlayer->weapons[wpn].ammo;
return wpn;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_cash(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
return pPlayer->money;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_space(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
return pPlayer->space;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_pwup(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
cell *cpTemp = MF_GetAmxAddr(amx,params[2]);
*cpTemp = pPlayer->PwUpValue;
return pPlayer->PwUp;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_items(AMX *amx, cell *params)
{
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
return pPlayer->items;
}
return 0;
}
static cell AMX_NATIVE_CALL get_killingStreak(AMX *amx, cell *params)
{
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
return pPlayer->killingSpree;
}
return 0;
}
static cell AMX_NATIVE_CALL get_lastFrag(AMX *amx, cell *params)
{
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (pPlayer->ingame)
{
return pPlayer->lastFrag;
}
return 0;
}
static cell AMX_NATIVE_CALL get_killflags(AMX *amx, cell *params)
{
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if ( pPlayer->ingame ){
return pPlayer->killFlags;
}
return 0;
}
static cell AMX_NATIVE_CALL give_weapon(AMX *amx, cell *params)
{ // index,weapon,clips,extra
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (!pPlayer->ingame || !pPlayer->IsAlive())
{
return 0;
}
// can he carry this weapon check ?
string_t item = MAKE_STRING("ts_groundweapon");
edict_t *pent = CREATE_NAMED_ENTITY( item );
if ( FNullEnt( pent ) ){
return 0;
}
KeyValueData pkvd;
char szTemp[16];
sprintf(szTemp,"%d",(int)params[2]);
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "tsweaponid"; // weapon
pkvd.szValue = szTemp;
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "wduration"; // duration
pkvd.szValue = "180";
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
sprintf(szTemp,"%d",(int)params[3]);
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "wextraclip"; // clips
pkvd.szValue = szTemp;
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
sprintf(szTemp,"%d",(int)params[4]);
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "spawnflags"; // attachements :flashlight,lasersight,scope..
pkvd.szValue = szTemp;
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
/*
pkvd.szClassName = "ts_groundweapon";
pkvd.szKeyName = "message";
pkvd.szValue = "";
pMDLL_KeyValue(pEntity, &pkvd);
*/
MDLL_Spawn(pent);
pent->v.origin = pPlayer->pEdict->v.origin;
MDLL_Use(pent, pPlayer->pEdict);
REMOVE_ENTITY(pent);
return 1;
}
static cell AMX_NATIVE_CALL create_pwup(AMX *amx, cell *params){ // pwup ,origin[3]
string_t item = MAKE_STRING("ts_powerup");
edict_t *pent = CREATE_NAMED_ENTITY( item );
if ( FNullEnt( pent ) ){
return 0;
}
KeyValueData pkvd;
char szTemp[16];
sprintf(szTemp,"%d",(int)params[1]);
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "pwuptype"; // type
pkvd.szValue = szTemp;
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "pwupduration"; // duration
pkvd.szValue = "60";
pkvd.fHandled = false;
MDLL_KeyValue(pent, &pkvd);
/*
pkvd.szClassName = (char *)STRING(pent->v.classname);
pkvd.szKeyName = "message";
pkvd.szValue = "";
pMDLL_KeyValue(pEntity, &pkvd);
*/
cell *vInput = MF_GetAmxAddr(amx,params[2]);
float fNewX = *(float *)((void *)&vInput[0]);
float fNewY = *(float *)((void *)&vInput[1]);
float fNewZ = *(float *)((void *)&vInput[2]);
vec3_t vNewValue = vec3_t(fNewX, fNewY, fNewZ);
MDLL_Spawn(pent);
pent->v.origin = vNewValue;
return ENTINDEX(pent);
}
// create_pwup -> !wait! -> give_pwup
static cell AMX_NATIVE_CALL give_pwup(AMX *amx, cell *params)
{ // index,pwupentindex
edict_t* pent = INDEXENT(params[2]);
if ( FNullEnt( pent ) || strcmp("ts_powerup",STRING(pent->v.classname))!=0 ){
return 0;
}
int id = params[1];
if (id<1 || id>gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", id);
return 0;
}
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (!pPlayer->ingame || !pPlayer->IsAlive())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not ingame.", id);
return 0;
}
pent->v.origin = pPlayer->pEdict->v.origin;
MDLL_Touch(pent, pPlayer->pEdict);
REMOVE_ENTITY(pent);
return 1;
}
static cell AMX_NATIVE_CALL ts_setup(AMX *amx, cell *params){ // index,pwupentindex
gKnifeOffset = params[1];
return 1;
}
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
{ // forward
return 1;
}
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params)
{
return TSMAX_WEAPONS;
}
static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params)
{
return 8;
}
static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params)
{
int weapon = params[1];
if (weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS)
{
return 0;
}
return 1;
}
AMX_NATIVE_INFO base_Natives[] = {
{ "xmod_get_wpnname", get_weapon_name },
{ "xmod_get_wpnlogname", get_weapon_logname },
{ "xmod_is_melee_wpn", is_melee },
{ "xmod_get_maxweapons", get_maxweapons },
{ "xmod_get_stats_size", get_stats_size },
{ "xmod_is_custom_wpn", is_custom },
{ "ts_wpnlogtoname", wpnlog_to_name },
{ "ts_wpnlogtoid", wpnlog_to_id },
{ "ts_getuserwpn", ts_get_user_weapon },
{ "ts_getusercash", get_user_cash },
{ "ts_getuserspace", get_user_space },
{ "ts_getuserpwup",get_user_pwup },
{ "ts_getuseritems",get_user_items },
{ "ts_getkillingstreak",get_killingStreak },
{ "ts_getuserlastfrag",get_lastFrag },
{ "ts_getuserkillflags",get_killflags },
{ "ts_giveweapon",give_weapon },
{ "ts_createpwup",create_pwup },
{ "ts_givepwup",give_pwup },
{ "ts_setpddata",ts_setup },
{ "register_statsfwd",register_forward },
//****************************************
{ "get_weaponname", get_weapon_name },
{ "get_user_weapon", get_user_weapon },
//"*******************"
{ NULL, NULL }
};

98
dlls/ts/tsx/StatsNatives.h → dlls/ts/tsx/NRank.cpp Normal file → Executable file
View File

@ -1,6 +1,6 @@
/* /*
* TSX * TFCX
* Copyright (c) 2005 Twilight Suzuka * Copyright (c) 2004 Lukasz Wlasinski
* *
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -36,9 +36,15 @@
static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int attacker = params[2]; int attacker = params[2];
CHECK_PLAYERRANGE(attacker); if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){ if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]); cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -63,9 +69,15 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int victim = params[2]; int victim = params[2];
CHECK_PLAYERRANGE(victim); if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){ if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]); cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -90,10 +102,13 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end) static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2]; int weapon = params[2];
if (weapon<0||weapon>=TSMAX_WEAPONS){ if (weapon<0||weapon>=TSMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon); MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -118,10 +133,13 @@ static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param
static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */ static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2]; int weapon = params[2];
if (weapon<0||weapon>=TSMAX_WEAPONS){ if (weapon<0||weapon>=TSMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon); MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -146,7 +164,10 @@ static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param *
static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */ static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
GET_PLAYER_POINTER_I(index)->restartStats(); GET_PLAYER_POINTER_I(index)->restartStats();
return 1; return 1;
} }
@ -154,7 +175,10 @@ static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param
static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */ static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){ if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]); cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -178,7 +202,10 @@ static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */ static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */
{ {
int index = params[1]; int index = params[1];
CHECK_PLAYERRANGE(index); if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->rank){ if (pPlayer->rank){
cell *cpStats = MF_GetAmxAddr(amx,params[2]); cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -255,25 +282,31 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logna
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0 static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1]; int weapon = params[1];
if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){ // only for custom weapons if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){ // only for custom weapons
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon); MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
int att = params[2]; int att = params[2];
CHECK_PLAYERRANGE(att); if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int vic = params[3]; int vic = params[3];
CHECK_PLAYERRANGE(vic); if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int dmg = params[4]; int dmg = params[4];
if ( dmg<1 ){ if ( dmg<1 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg); MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
int aim = params[5]; int aim = params[5];
if ( aim < 0 || aim > 7 ){ if ( aim < 0 || aim > 7 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim); MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
@ -287,24 +320,43 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
int TA = 0; int TA = 0;
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) ) if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
TA = 1; TA = 1;
MF_ExecuteForward(g_damage_info, pAtt->index, pVic->index, dmg, weapon, aim, TA );
MF_ExecuteForward(g_damage_info,
(cell)pAtt->index,
(cell)pVic->index,
(cell)dmg,
(cell)weapon,
(cell)aim,
(cell)TA);
if ( pVic->IsAlive() ) if ( pVic->IsAlive() )
return 1; return 1;
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA); pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
MF_ExecuteForward(g_death_info, pAtt->index, pVic->index, weapon, aim, TA );
MF_ExecuteForward(g_death_info,
(cell)pAtt->index,
(cell)pVic->index,
(cell)weapon,
(cell)aim,
(cell)TA);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2]; int index = params[2];
CHECK_PLAYERRANGE(index);
if (!MF_IsPlayerIngame(index))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", index);
return 0;
}
int weapon = params[1]; int weapon = params[1];
if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){ if (weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS)
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon); {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon %d", weapon);
return 0; return 0;
} }

View File

@ -1,335 +0,0 @@
/*
* TSX
* Copyright (c) 2005 Twilight Suzuka
*
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "amxxmodule.h"
#include "tsx.h"
static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
int attacker = params[2];
CHECK_PLAYERRANGE(attacker);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->attackers[attacker];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
if (params[6] && attacker && stats->name )
MF_SetAmxString(amx,params[5],stats->name,params[6]);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
int victim = params[2];
CHECK_PLAYERRANGE(victim);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->victims[victim];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
if (params[6] && victim && stats->name)
MF_SetAmxString(amx,params[5],stats->name,params[6]);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{
int index = params[1];
CHECK_PLAYERRANGE(index);
int weapon = params[2];
if (weapon<0||weapon>=TSMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->weaponsRnd[weapon].shots){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
Stats* stats = &pPlayer->weaponsRnd[weapon];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
int weapon = params[2];
if (weapon<0||weapon>=TSMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->weapons[weapon].shots){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->weapons[weapon];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
GET_PLAYER_POINTER_I(index)->restartStats();
return 1;
}
static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = pPlayer->rank->kills;
cpStats[1] = pPlayer->rank->deaths;
cpStats[2] = pPlayer->rank->hs;
cpStats[3] = pPlayer->rank->tks;
cpStats[4] = pPlayer->rank->shots;
cpStats[5] = pPlayer->rank->hits;
cpStats[6] = pPlayer->rank->damage;
cpStats[7] = pPlayer->rank->getPosition();
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = pPlayer->rank->bodyHits[i];
return pPlayer->rank->getPosition();
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->rank){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = pPlayer->life.kills;
cpStats[1] = pPlayer->life.deaths;
cpStats[2] = pPlayer->life.hs;
cpStats[3] = pPlayer->life.tks;
cpStats[4] = pPlayer->life.shots;
cpStats[5] = pPlayer->life.hits;
cpStats[6] = pPlayer->life.damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = pPlayer->life.bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1] + 1;
for(RankSystem::iterator a = g_rank.front(); a ;--a){
if ((*a).getPosition() == index) {
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = (*a).kills;
cpStats[1] = (*a).deaths;
cpStats[2] = (*a).hs;
cpStats[3] = (*a).tks;
cpStats[4] = (*a).shots;
cpStats[5] = (*a).hits;
cpStats[6] = (*a).damage;
cpStats[7] = (*a).getPosition();
MF_SetAmxString(amx,params[4],(*a).getName(),params[5]);
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = (*a).bodyHits[i];
return --a ? index : 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL get_statsnum(AMX *amx, cell *params)
{
return g_rank.getRankNum();
}
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logname,melee=0
int i;
bool bFree = false;
for ( i=TSMAX_WEAPONS-TSMAX_CUSTOMWPNS;i<TSMAX_WEAPONS;i++){
if ( !weaponData[i].custom ){
bFree = true;
break;
}
}
if ( !bFree )
return 0;
int iLen;
char *szName = MF_GetAmxString(amx, params[1], 0, &iLen);
strcpy(weaponData[i].name,szName);
weaponData[i].custom = true;
weaponData[i].melee = params[2] ? true:false;
return i;
}
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){ // only for custom weapons
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
return 0;
}
int att = params[2];
CHECK_PLAYERRANGE(att);
int vic = params[3];
CHECK_PLAYERRANGE(vic);
int dmg = params[4];
if ( dmg<1 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
return 0;
}
CPlayer* pAtt = GET_PLAYER_POINTER_I(att);
CPlayer* pVic = GET_PLAYER_POINTER_I(vic);
pVic->pEdict->v.dmg_inflictor = NULL;
pAtt->saveHit( pVic , weapon , dmg, aim );
if ( !pAtt ) pAtt = pVic;
int TA = 0;
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
TA = 1;
MF_ExecuteForward(g_damage_info, pAtt->index, pVic->index, dmg, weapon, aim, TA );
if ( pVic->IsAlive() )
return 1;
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
MF_ExecuteForward(g_death_info, pAtt->index, pVic->index, weapon, aim, TA );
return 1;
}
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
CHECK_PLAYERRANGE(index);
int weapon = params[1];
if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
pPlayer->saveShot(weapon);
return 1;
}
AMX_NATIVE_INFO stats_Natives[] = {
{ "get_stats", get_stats},
{ "get_statsnum", get_statsnum},
{ "get_user_astats", get_user_astats },
{ "get_user_rstats", get_user_rstats },
{ "get_user_lstats", get_user_rstats }, // for backward compatibility
{ "get_user_stats", get_user_stats },
{ "get_user_vstats", get_user_vstats },
{ "get_user_wrstats", get_user_wrstats}, // DEC-Weapon(Round) Stats
{ "get_user_wstats", get_user_wstats},
{ "reset_user_wstats", reset_user_wstats },
// Custom Weapon Support
{ "custom_weapon_add", register_cwpn },
{ "custom_weapon_dmg", cwpn_dmg },
{ "custom_weapon_shot", cwpn_shot },
{ NULL, NULL }
};

View File

@ -1,68 +0,0 @@
/*
* Copyright (c) 2003-2005 Twilight Suzuka
*
* This file is part of TSXMod.
*
* TS XMod 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.
*
* TS XMod 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 TS XMod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "amxxmodule.h"
#include "tsx.h"
#include "MsgFunc.h"
int gmsgResetHUD;
int gmsgWeaponInfo;
int gmsgClipInfo;
int gmsgScoreInfo;
int gmsgTSHealth;
int gmsgWStatus;
int gmsgTSCash;
int gmsgTSSpace;
int gmsgPwUp;
struct sUserMsg
{
const char* name;
int* id;
funEventCall func;
bool endmsg;
}
g_user_msg[] =
{
{ "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true },
{ "WeaponInfo",&gmsgWeaponInfo,Client_WeaponInfo,false },
{ "ClipInfo",&gmsgClipInfo,Client_ClipInfo,false },
{ "ScoreInfo",&gmsgScoreInfo,Client_ScoreInfo,false },
{ "TSHealth",&gmsgTSHealth,Client_TSHealth_End,true },
{ "WStatus",&gmsgWStatus,Client_WStatus,false },
{ "TSCash",&gmsgTSCash,Client_TSCash,false },
{ "TSSpace",&gmsgTSSpace,Client_TSSpace,false },
{ "PwUp",&gmsgPwUp,Client_PwUp,false},
{ 0,0,0,false }
};

View File

@ -2502,6 +2502,8 @@ PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction; PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction; PFN_REQ_FNPTR g_fn_RequestFunction;
PFN_AMX_PUSH g_fn_AmxPush; PFN_AMX_PUSH g_fn_AmxPush;
PFN_SET_TEAM_INFO g_fn_SetTeamInfo;
PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2611,6 +2613,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS); REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT); REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH); REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
REQFUNC("SetPlayerTeamInfo", g_fn_SetTeamInfo, PFN_SET_TEAM_INFO);
REQFUNC("PlayerPropAddr", g_fn_PlayerPropAddr, PFN_PLAYER_PROP_ADDR);
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
// Memory // Memory
@ -2733,6 +2737,8 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, ""); MF_RegisterFunction(NULL, "");
MF_SetPlayerTeamInfo(0, 0, "");
MF_PlayerPropAddr(0, 0);
} }
#endif #endif
@ -2912,20 +2918,20 @@ void operator delete[](void *reportedAddress)
#else #else
#if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32 #if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32
void * ::operator new(size_t size) { void * operator new(size_t size) {
return(calloc(1, size)); return(calloc(1, size));
} }
void * ::operator new[](size_t size) { void * operator new[](size_t size) {
return(calloc(1, size)); return(calloc(1, size));
} }
void ::operator delete(void * ptr) { void operator delete(void * ptr) {
if(ptr) if(ptr)
free(ptr); free(ptr);
} }
void ::operator delete[](void * ptr) { void operator delete[](void * ptr) {
if(ptr) if(ptr)
free(ptr); free(ptr);
} }

View File

@ -1927,6 +1927,28 @@ enum ForwardParam
FP_ARRAY, // array; use the return value of prepareArray. FP_ARRAY, // array; use the return value of prepareArray.
}; };
enum PlayerProp
{
Player_Name, //String
Player_Ip, //String
Player_Team, //String
Player_Ingame, //bool
Player_Authorized, //bool
Player_Vgui, //bool
Player_Time, //float
Player_Playtime, //float
Player_MenuExpire, //float
Player_Weapons, //struct{int,int}[32]
Player_CurrentWeapon, //int
Player_TeamID, //int
Player_Deaths, //int
Player_Aiming, //int
Player_Menu, //int
Player_Keys, //int
Player_Flags, //int[32]
Player_Newmenu, //int
Player_NewmenuPage, //int
};
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
@ -1978,6 +2000,7 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else #else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/); typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif #endif
typedef void * (*PFN_PLAYER_PROP_ADDR) (int /*id*/, int /*prop*/);
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -2003,6 +2026,7 @@ typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/); typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/); typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/);
typedef int (*PFN_SET_TEAM_INFO) (int /*player */, int /*teamid */, const char * /*name */);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -2066,6 +2090,8 @@ extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction; extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction; extern PFN_REQ_FNPTR g_fn_RequestFunction;
extern PFN_AMX_PUSH g_fn_AmxPush; extern PFN_AMX_PUSH g_fn_AmxPush;
extern PFN_SET_TEAM_INFO g_fn_SetTeamInfo;
extern PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
@ -2126,6 +2152,8 @@ void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { } void * MF_RequestFunction (const char *description) { }
int MF_AmxPush (AMX *amx, cell *params) { } int MF_AmxPush (AMX *amx, cell *params) { }
int MF_AmxExec (AMX *amx, cell *retval, int idx) { } int MF_AmxExec (AMX *amx, cell *retval, int idx) { }
int MF_SetPlayerTeamInfo (int id, int teamid, const char *teamname) { }
void * MF_PlayerPropAddr (int id, int prop) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
@ -2191,6 +2219,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RegisterFunction g_fn_RegisterFunction #define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction; #define MF_RequestFunction g_fn_RequestFunction;
#define MF_AmxPush g_fn_AmxPush #define MF_AmxPush g_fn_AmxPush
#define MF_SetPlayerTeamInfo g_fn_SetTeamInfo
#define MF_PlayerPropAddr g_fn_PlayerPropAddr
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
/*** Memory ***/ /*** Memory ***/

View File

@ -1,6 +0,0 @@
@echo off
PATH=C:\gcc\bin;%PATH%
make
pause

135
dlls/ts/tsx/tsx.cpp → dlls/ts/tsx/moduleconfig.cpp Normal file → Executable file
View File

@ -30,7 +30,6 @@
*/ */
#include "tsx.h" #include "tsx.h"
#include "UserMsg.h"
funEventCall modMsgsEnd[MAX_REG_MSGS]; funEventCall modMsgsEnd[MAX_REG_MSGS];
funEventCall modMsgs[MAX_REG_MSGS]; funEventCall modMsgs[MAX_REG_MSGS];
@ -44,11 +43,22 @@ CPlayer players[33];
bool is_theonemode; bool is_theonemode;
bool rankBots; bool rankBots;
int g_death_info; int g_death_info = -1;
int g_damage_info; int g_damage_info = -1;
int gKnifeOffset; int gKnifeOffset;
int gmsgResetHUD;
int gmsgWeaponInfo;
int gmsgClipInfo;
int gmsgScoreInfo;
int gmsgTSHealth;
int gmsgWStatus;
int gmsgTSCash;
int gmsgTSSpace;
int gmsgPwUp;
RankSystem g_rank; RankSystem g_rank;
cvar_t init_tsstats_maxsize ={"tsstats_maxsize","3500", 0 , 3500.0 }; cvar_t init_tsstats_maxsize ={"tsstats_maxsize","3500", 0 , 3500.0 };
@ -63,6 +73,27 @@ cvar_t *tsstats_maxsize;
cvar_t *tsstats_reset; cvar_t *tsstats_reset;
cvar_t *tsstats_rank; cvar_t *tsstats_rank;
struct sUserMsg
{
const char* name;
int* id;
funEventCall func;
bool endmsg;
} g_user_msg[] = {
{ "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true },
{ "WeaponInfo",&gmsgWeaponInfo,Client_WeaponInfo,false },
{ "ClipInfo",&gmsgClipInfo,Client_ClipInfo,false },
{ "ScoreInfo",&gmsgScoreInfo,Client_ScoreInfo,false },
{ "TSHealth",&gmsgTSHealth,Client_TSHealth_End,true },
{ "WStatus",&gmsgWStatus,Client_WStatus,false },
{ "TSCash",&gmsgTSCash,Client_TSCash,false },
{ "TSSpace",&gmsgTSSpace,Client_TSSpace,false },
{ "PwUp",&gmsgPwUp,Client_PwUp,false},
{ 0,0,0,false }
};
const char* get_localinfo( const char* name , const char* def = 0 ) const char* get_localinfo( const char* name , const char* def = 0 )
{ {
const char* b = LOCALINFO( (char*)name ); const char* b = LOCALINFO( (char*)name );
@ -73,16 +104,16 @@ const char* get_localinfo( const char* name , const char* def = 0 )
int RegUserMsg_Post(const char *pszName, int iSize) int RegUserMsg_Post(const char *pszName, int iSize)
{ {
for (int i = 0; g_user_msg[ i ].name; ++i ) for (int i = 0; g_user_msg[ i ].name; ++i ){
{ if ( !*g_user_msg[i].id && strcmp( g_user_msg[ i ].name , pszName ) == 0 ){
if ( !*g_user_msg[i].id && strcmp( g_user_msg[ i ].name , pszName ) == 0 )
{
int id = META_RESULT_ORIG_RET( int ); int id = META_RESULT_ORIG_RET( int );
*g_user_msg[ i ].id = id; *g_user_msg[ i ].id = id;
if ( g_user_msg[ i ].endmsg ) modMsgsEnd[ id ] = g_user_msg[ i ].func; if ( g_user_msg[ i ].endmsg )
else modMsgs[ id ] = g_user_msg[ i ].func; modMsgsEnd[ id ] = g_user_msg[ i ].func;
else
modMsgs[ id ] = g_user_msg[ i ].func;
break; break;
} }
@ -106,14 +137,12 @@ void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
void PlayerPreThink_Post( edict_t *pEntity ) void PlayerPreThink_Post( edict_t *pEntity )
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if ( !isModuleActive() ) // stats only if ( !isModuleActive() ) // stats only
return; return;
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame){
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame)
{
pPlayer->clearStats = 0.0f; pPlayer->clearStats = 0.0f;
pPlayer->rank->updatePosition( &pPlayer->life ); pPlayer->rank->updatePosition( &pPlayer->life );
pPlayer->restartStats(false); pPlayer->restartStats(false);
@ -121,17 +150,15 @@ void PlayerPreThink_Post( edict_t *pEntity )
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void ServerDeactivate() void ServerDeactivate()
{ {
int i; int i;
for(i = 1;i<=gpGlobals->maxClients; ++i) for(i = 1;i<=gpGlobals->maxClients; ++i){
{
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->rank) pPlayer->Disconnect(); if (pPlayer->rank) pPlayer->Disconnect();
} }
if ( (g_rank.getRankNum() >= (int)tsstats_maxsize->value) || ((int)tsstats_reset->value == 1) ) if ( (g_rank.getRankNum() >= (int)tsstats_maxsize->value) || ((int)tsstats_reset->value == 1) ) {
{
CVAR_SET_FLOAT("tsstats_reset",0.0); CVAR_SET_FLOAT("tsstats_reset",0.0);
g_rank.clear(); g_rank.clear();
} }
@ -142,19 +169,16 @@ void ServerDeactivate()
for ( i=TSMAX_WEAPONS-TSMAX_CUSTOMWPNS;i<TSMAX_WEAPONS;i++) for ( i=TSMAX_WEAPONS-TSMAX_CUSTOMWPNS;i<TSMAX_WEAPONS;i++)
weaponData[i].custom = false; weaponData[i].custom = false;
g_rank.clear();
g_rank.unloadCalc();
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ])
{ {
GET_PLAYER_POINTER(pEntity)->Connect(pszAddress); GET_PLAYER_POINTER(pEntity)->Connect(pszAddress);
RETURN_META_VALUE(MRES_IGNORED, TRUE); RETURN_META_VALUE(MRES_IGNORED, TRUE);
} }
void ClientDisconnect( edict_t *pEntity ) void ClientDisconnect( edict_t *pEntity )
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (pPlayer->ingame) pPlayer->Disconnect(); if (pPlayer->ingame) pPlayer->Disconnect();
@ -173,76 +197,69 @@ void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer )
const char* name = INFOKEY_VALUE(infobuffer,"name"); const char* name = INFOKEY_VALUE(infobuffer,"name");
const char* oldname = STRING(pEntity->v.netname); const char* oldname = STRING(pEntity->v.netname);
if ( pPlayer->ingame ) if ( pPlayer->ingame ){
{ if ( strcmp(oldname,name) ) {
if ( strcmp(oldname,name) )
{
if (!tsstats_rank->value) if (!tsstats_rank->value)
pPlayer->rank = g_rank.findEntryInRank( name, name ); pPlayer->rank = g_rank.findEntryInRank( name, name );
else else
pPlayer->rank->setName( name ); pPlayer->rank->setName( name );
} }
} }
else if ( pPlayer->IsBot() ) else if ( pPlayer->IsBot() ) {
{
pPlayer->PutInServer(); pPlayer->PutInServer();
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{ {
if (ed) if (ed){
{
mPlayerIndex = ENTINDEX(ed); mPlayerIndex = ENTINDEX(ed);
mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex); mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex);
} } else {
else
{
mPlayerIndex = 0; mPlayerIndex = 0;
mPlayer = NULL; mPlayer = NULL;
} }
mState = 0; mState = 0;
if ( msg_type < 0 || msg_type >= MAX_REG_MSGS )
if ( msg_type < 0 || msg_type >= MAX_REG_MSGS ) msg_type = 0; msg_type = 0;
function=modMsgs[msg_type]; function=modMsgs[msg_type];
endfunction=modMsgsEnd[msg_type]; endfunction=modMsgsEnd[msg_type];
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void MessageEnd_Post(void) void MessageEnd_Post(void)
{ {
if (endfunction) (*endfunction)(NULL); if (endfunction) (*endfunction)(NULL);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteByte_Post(int iValue) void WriteByte_Post(int iValue)
{ {
if (function) (*function)((void *)&iValue); if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteChar_Post(int iValue) void WriteChar_Post(int iValue)
{ {
if (function) (*function)((void *)&iValue); if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteShort_Post(int iValue) void WriteShort_Post(int iValue)
{ {
if (function) (*function)((void *)&iValue); if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteLong_Post(int iValue) void WriteLong_Post(int iValue)
{ {
if (function) (*function)((void *)&iValue); if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteAngle_Post(float flValue) void WriteAngle_Post(float flValue)
{ {
if (function) (*function)((void *)&flValue); if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
@ -254,29 +271,29 @@ void WriteCoord_Post(float flValue)
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteString_Post(const char *sz) void WriteString_Post(const char *sz)
{ {
if (function) (*function)((void *)sz); if (function) (*function)((void *)sz);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void WriteEntity_Post(int iValue) void WriteEntity_Post(int iValue)
{ {
if (function) (*function)((void *)&iValue); if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr)
{ {
if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&& if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&
e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )) e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )){
{
GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup; GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup;
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void OnMetaAttach() { void OnMetaAttach()
{
CVAR_REGISTER (&init_tsstats_maxsize); CVAR_REGISTER (&init_tsstats_maxsize);
CVAR_REGISTER (&init_tsstats_reset); CVAR_REGISTER (&init_tsstats_reset);
@ -292,15 +309,19 @@ void OnMetaAttach() {
} }
void OnPluginsLoaded()
{
g_damage_info = MF_RegisterForward("client_damage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_death_info = MF_RegisterForward("client_death", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
void OnAmxxAttach()
void OnAmxxAttach() { {
gKnifeOffset = TSKNIFE_OFFSET; gKnifeOffset = TSKNIFE_OFFSET;
MF_AddNatives( stats_Natives ); MF_AddNatives( stats_Natives );
//TSFun does these now MF_AddNatives( base_Natives );
//MF_AddNatives( base_Natives );
const char* path = get_localinfo("tsstats_score","addons/amxmodx/data/tsstats.amxx"); const char* path = get_localinfo("tsstats_score","addons/amxmodx/data/tsstats.amxx");
if ( path && *path ) if ( path && *path )
@ -314,8 +335,8 @@ void OnAmxxAttach() {
} }
} }
void OnPluginsLoaded() void OnAmxxDetach()
{ {
g_damage_info = MF_RegisterForward("client_damage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); g_rank.clear();
g_death_info = MF_RegisterForward("client_death", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); g_rank.unloadCalc();
} }

View File

@ -6,8 +6,8 @@
// Module info // Module info
#define MODULE_NAME "TSX" #define MODULE_NAME "TSX"
#define MODULE_VERSION "1.65" #define MODULE_VERSION "1.65"
#define MODULE_AUTHOR "Twilight Suzuka" #define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org" #define MODULE_URL "http://www.amxmodx.org/"
#define MODULE_LOGTAG "TSX" #define MODULE_LOGTAG "TSX"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line // If you want the module not to be reloaded on mapchange, remove / comment out the next line
#define MODULE_RELOAD_ON_MAPCHANGE #define MODULE_RELOAD_ON_MAPCHANGE
@ -21,6 +21,16 @@
// metamod plugin? // metamod plugin?
#define USE_METAMOD #define USE_METAMOD
// use memory manager/tester?
// note that if you use this, you cannot construct/allocate
// anything before the module attached (OnAmxxAttach).
// be careful of default constructors using new/malloc!
// #define MEMORY_TEST
// Unless you use STL or exceptions, keep this commented.
// It allows you to compile without libstdc++.so as a dependency
// #define NO_ALLOC_OVERRIDES
// - AMXX Init functions // - AMXX Init functions
// Also consider using FN_META_* // Also consider using FN_META_*
// AMXX query // AMXX query
@ -28,8 +38,8 @@
// AMXX attach // AMXX attach
// Do native functions init here (MF_AddNatives) // Do native functions init here (MF_AddNatives)
#define FN_AMXX_ATTACH OnAmxxAttach #define FN_AMXX_ATTACH OnAmxxAttach
// AMXX dettach // AMXX detach
// #define FN_AMXX_DETACH OnAmxxDetach #define FN_AMXX_DETACH OnAmxxDetach
// All plugins loaded // All plugins loaded
// Do forward functions init here (MF_RegisterForward) // Do forward functions init here (MF_RegisterForward)
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
@ -48,7 +58,7 @@
//#define FN_META_QUERY OnMetaQuery //#define FN_META_QUERY OnMetaQuery
// Meta attach // Meta attach
#define FN_META_ATTACH OnMetaAttach #define FN_META_ATTACH OnMetaAttach
// Meta dettach // Meta detach
//#define FN_META_DETACH OnMetaDetach //#define FN_META_DETACH OnMetaDetach
// (wd) are Will Day's notes // (wd) are Will Day's notes
@ -460,4 +470,3 @@
#endif // USE_METAMOD #endif // USE_METAMOD
#endif // __MODULECONFIG_H__ #endif // __MODULECONFIG_H__

View File

@ -46,7 +46,29 @@
#endif #endif
extern AMX_NATIVE_INFO stats_Natives[]; extern AMX_NATIVE_INFO stats_Natives[];
//extern AMX_NATIVE_INFO base_Natives[]; extern AMX_NATIVE_INFO base_Natives[];
extern int gmsgResetHUD;
extern int gmsgWeaponInfo;
extern int gmsgClipInfo;
extern int gmsgScoreInfo;
extern int gmsgTSHealth;
extern int gmsgWStatus;
extern int gmsgTSCash;
extern int gmsgTSSpace;
extern int gmsgPwUp;
void Client_ResetHUD_End(void*);
void Client_WeaponInfo(void*);
void Client_ClipInfo(void*);
void Client_ScoreInfo(void*);
void Client_TSHealth_End(void*);
void Client_WStatus(void* mValue);
void Client_TSCash(void* mValue);
void Client_TSSpace(void* mValue);
void Client_PwUp(void* mValue);
typedef void (*funEventCall)(void*); typedef void (*funEventCall)(void*);
extern funEventCall modMsgsEnd[MAX_REG_MSGS]; extern funEventCall modMsgsEnd[MAX_REG_MSGS];
@ -83,67 +105,8 @@ extern int gKnifeOffset;
extern weapon_t weaponData[TSMAX_WEAPONS]; extern weapon_t weaponData[TSMAX_WEAPONS];
inline bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL) bool isModuleActive();
{ bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL);
if ( !rankBots && ( pEnt->v.flags & FL_FAKECLIENT || ( pOther && pOther->v.flags & FL_FAKECLIENT ) ) ) return true;
return false;
}
inline bool isModuleActive()
{
if ( !(int)CVAR_GET_FLOAT("tsstats_pause") ) return true;
return false;
}
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define CHECK_PLAYERRANGE(x) \
if (x > gpGlobals->maxClients || x < 0) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif //TSX_H #endif //TSX_H

173
dlls/ts/tsx/MsgFunc.h → dlls/ts/tsx/usermsg.cpp Normal file → Executable file
View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2003-2005 Twilight Suzuka * Copyright (c) 2003-2004 Lukasz Wlasinski
* *
* This file is part of TSXMod. * This file is part of TS XMod.
* *
* TS XMod is free software; you can redistribute it and/or modify it * TS XMod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -32,44 +32,41 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include "tsx.h" #include "tsx.h"
void Client_ResetHUD_End(void* mValue)
{ void Client_ResetHUD_End(void* mValue){
if ( mPlayer->IsAlive() ) if ( mPlayer->IsAlive() ){ // ostatni przed spawn'em
{ mPlayer->clearStats = gpGlobals->time + 0.25f; // teraz czysc statystyki
mPlayer->clearStats = gpGlobals->time + 0.25f;
} }
else else { // dalej "dead" nie czysc statystyk!
{
mPlayer->items = 0; mPlayer->items = 0;
mPlayer->is_specialist = 0; mPlayer->is_specialist = 0;
mPlayer->killingSpree = 0; mPlayer->killingSpree = 0;
mPlayer->killFlags = 0; mPlayer->killFlags = 0;
mPlayer->frags = (int)mPlayer->pEdict->v.frags; mPlayer->frags = (int)mPlayer->pEdict->v.frags;
/*
fix dla user_kill() z addfrag
oraz self kills
*/
} }
} }
void Client_ScoreInfo(void* mValue) void Client_ScoreInfo(void* mValue){
{
static int iId; static int iId;
switch(mState++) switch(mState++){
{
case 0: case 0:
iId = *(int*)mValue; iId = *(int*)mValue;
break; break;
case 4: case 4:
if ( iId && (iId < 33) ) if ( iId && (iId < 33) ){
{
GET_PLAYER_POINTER_I(iId)->teamId = *(int*)mValue; GET_PLAYER_POINTER_I(iId)->teamId = *(int*)mValue;
} }
break; break;
} }
} }
void Client_WeaponInfo(void* mValue) void Client_WeaponInfo(void* mValue){
{
static int wpn; static int wpn;
switch(mState++) switch(mState++){
{
case 0: case 0:
wpn = *(int*)mValue; wpn = *(int*)mValue;
if ( !wpn ) wpn = 36; // kung fu if ( !wpn ) wpn = 36; // kung fu
@ -90,58 +87,51 @@ void Client_WeaponInfo(void* mValue)
} }
} }
void Client_ClipInfo(void* mValue) void Client_ClipInfo(void* mValue){
{
int iValue = *(int*)mValue; int iValue = *(int*)mValue;
if ( iValue < mPlayer->weapons[mPlayer->current].clip ) if ( iValue < mPlayer->weapons[mPlayer->current].clip ) {
{
mPlayer->saveShot(mPlayer->current); mPlayer->saveShot(mPlayer->current);
} }
mPlayer->weapons[mPlayer->current].clip = iValue; mPlayer->weapons[mPlayer->current].clip = iValue;
} }
void Client_TSHealth_End(void* mValue) void Client_TSHealth_End(void* mValue){
{
edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor; edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor;
int damage = (int)mPlayer->pEdict->v.dmg_take; int damage = (int)mPlayer->pEdict->v.dmg_take;
if ( !damage || !enemy )
if ( !damage || !enemy ) return; return;
int aim = 0; int aim = 0;
int weapon = 0; int weapon = 0;
mPlayer->pEdict->v.dmg_take = 0.0; mPlayer->pEdict->v.dmg_take = 0.0;
CPlayer* pAttacker = NULL; CPlayer* pAttacker = NULL;
if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){
{
pAttacker = GET_PLAYER_POINTER(enemy); pAttacker = GET_PLAYER_POINTER(enemy);
weapon = pAttacker->current; weapon = pAttacker->current;
aim = pAttacker->aiming; aim = pAttacker->aiming;
pAttacker->saveHit( mPlayer , weapon , damage, aim ); pAttacker->saveHit( mPlayer , weapon , damage, aim );
} }
else else {
{
char szCName[16]; char szCName[16];
strcpy( szCName,STRING(enemy->v.classname) ); strcpy( szCName,STRING(enemy->v.classname) );
if ( szCName[0] == 'g' ) if ( szCName[0] == 'g' ) {
{ if ( enemy->v.owner && enemy->v.owner->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){
if ( enemy->v.owner && enemy->v.owner->v.flags & (FL_CLIENT | FL_FAKECLIENT) )
{
pAttacker = GET_PLAYER_POINTER(enemy->v.owner); pAttacker = GET_PLAYER_POINTER(enemy->v.owner);
weapon = 24; // grenade weapon = 24; // grenade
if ( pAttacker != mPlayer ) pAttacker->saveHit( mPlayer , weapon , damage, 0 ); if ( pAttacker != mPlayer )
pAttacker->saveHit( mPlayer , weapon , damage, 0 );
} }
} }
else if ( szCName[0] == 'k' ) else if ( szCName[0] == 'k' ) {
{
int pOwner = *( (int*)enemy->pvPrivateData + gKnifeOffset ); int pOwner = *( (int*)enemy->pvPrivateData + gKnifeOffset );
if ( FNullEnt( (edict_t*)pOwner) ) return; if ( FNullEnt( (edict_t*)pOwner) )
return;
pAttacker = GET_PLAYER_POINTER( (edict_t*)pOwner ); pAttacker = GET_PLAYER_POINTER( (edict_t*)pOwner );
//weapon = 37; // throwing knife weapon = 37; // throwing knife
aim = pAttacker->aiming; aim = pAttacker->aiming;
pAttacker->saveHit( mPlayer , weapon , damage, aim ); pAttacker->saveHit( mPlayer , weapon , damage, aim );
} }
@ -149,74 +139,86 @@ void Client_TSHealth_End(void* mValue)
if ( !pAttacker ) pAttacker = mPlayer; if ( !pAttacker ) pAttacker = mPlayer;
int TA = 0; int TA = 0;
if ( mPlayer->teamId || is_theonemode ){
if ( mPlayer->teamId || is_theonemode ) if ( (mPlayer->teamId == pAttacker->teamId ) && (mPlayer != pAttacker) )
{ TA = 1;
if ( (mPlayer->teamId == pAttacker->teamId ) && (mPlayer != pAttacker) ) TA = 1;
} }
if ( weaponData[weapon].melee ) pAttacker->saveShot(weapon); if ( weaponData[weapon].melee )
pAttacker->saveShot(weapon);
MF_ExecuteForward(g_damage_info, pAttacker->index, mPlayer->index, damage, weapon, aim, TA ); MF_ExecuteForward(g_damage_info,
(cell)pAttacker->index,
if ( mPlayer->IsAlive() ) return; (cell)mPlayer->index,
(cell)damage,
(cell)weapon,
(cell)aim,
(cell)TA
);
if ( mPlayer->IsAlive() )
return;
// death // death
if ( (int)pAttacker->pEdict->v.frags - pAttacker->frags == 0 ) pAttacker = mPlayer; if ( (int)pAttacker->pEdict->v.frags - pAttacker->frags == 0 ) // nie bylo fraga ? jest tak dla bledu z granatem ..
pAttacker = mPlayer;
int killFlags = 0; int killFlags = 0;
if ( !TA && mPlayer!=pAttacker ) if ( !TA && mPlayer!=pAttacker ) {
{
int sflags = pAttacker->pEdict->v.iuser4; int sflags = pAttacker->pEdict->v.iuser4;
int stuntKill = 0; int stuntKill = 0;
int slpos = 0; int slpos = 0;
if ( weapon == 24 ); if ( weapon == 24 ) // dla granata nie liczy sie sflags
; // nic nie rob..
else if ( sflags == 20 || sflags == 1028 || sflags == 2052 ) stuntKill = 1; else if ( sflags == 20 || sflags == 1028 || sflags == 2052 )
else if ( sflags == 36) slpos = 1; stuntKill = 1;
else if ( sflags == 36)
slpos = 1;
int doubleKill = 0; int doubleKill = 0;
if ( gpGlobals->time - pAttacker->lastKill < 1.0 ) doubleKill = 1; if ( gpGlobals->time - pAttacker->lastKill < 1.0 )
doubleKill = 1;
if ( stuntKill ) killFlags |= TSKF_STUNTKILL; if ( stuntKill )
killFlags |= TSKF_STUNTKILL;
pAttacker->lastKill = gpGlobals->time; pAttacker->lastKill = gpGlobals->time;
pAttacker->killingSpree++; pAttacker->killingSpree++;
if ( pAttacker->killingSpree == 10 ) pAttacker->is_specialist = 1; if ( pAttacker->killingSpree == 10 )
pAttacker->is_specialist = 1;
pAttacker->lastFrag = weaponData[weapon].bonus + 2*stuntKill; pAttacker->lastFrag = weaponData[weapon].bonus + 2*stuntKill;
if ( doubleKill ) if ( doubleKill ){
{
pAttacker->lastFrag *= 2; pAttacker->lastFrag *= 2;
killFlags |= TSKF_DOUBLEKILL; killFlags |= TSKF_DOUBLEKILL;
} }
if ( pAttacker->is_specialist ) if ( pAttacker->is_specialist ){
{
pAttacker->lastFrag *= 2; pAttacker->lastFrag *= 2;
killFlags |= TSKF_ISSPEC; killFlags |= TSKF_ISSPEC;
} }
if ( mPlayer->is_specialist ) if ( mPlayer->is_specialist ){
{
pAttacker->lastFrag += 5; pAttacker->lastFrag += 5;
killFlags |= TSKF_KILLEDSPEC; killFlags |= TSKF_KILLEDSPEC;
} }
pAttacker->frags += pAttacker->lastFrag; pAttacker->frags += pAttacker->lastFrag;
if ( pAttacker->frags != pAttacker->pEdict->v.frags ) if ( pAttacker->frags != pAttacker->pEdict->v.frags ){
{ // moze to sliding kill ?
if ( slpos ) killFlags |= TSKF_SLIDINGKILL; if ( slpos )
else weapon = 36; killFlags |= TSKF_SLIDINGKILL;
else // moze to kung fu z bronia ?
weapon = 36;
pAttacker->lastFrag += (int)pAttacker->pEdict->v.frags - pAttacker->frags; pAttacker->lastFrag += (int)pAttacker->pEdict->v.frags - pAttacker->frags;
pAttacker->frags = (int)pAttacker->pEdict->v.frags; pAttacker->frags = (int)pAttacker->pEdict->v.frags;
} }
@ -224,42 +226,38 @@ void Client_TSHealth_End(void* mValue)
pAttacker->killFlags = killFlags; pAttacker->killFlags = killFlags;
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA); pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
MF_ExecuteForward(g_death_info, pAttacker->index, mPlayer->index, weapon, aim, TA ); MF_ExecuteForward(g_death_info,
(cell)pAttacker->index,
(cell)mPlayer->index,
(cell)weapon,
(cell)aim,
(cell)TA);
} }
void Client_WStatus(void* mValue) void Client_WStatus(void* mValue){
{ switch(mState++){
switch(mState++)
{
case 1: case 1:
if ( !*(int*)mValue ) if ( !*(int*)mValue ){
{
mPlayer->current = 36; // fix dla wytraconej broni mPlayer->current = 36; // fix dla wytraconej broni
} }
break; break;
} }
} }
void Client_TSCash(void* mValue) void Client_TSCash(void* mValue){
{
mPlayer->money = *(int*)mValue; mPlayer->money = *(int*)mValue;
} }
void Client_TSSpace(void* mValue) void Client_TSSpace(void* mValue){
{
mPlayer->space = *(int*)mValue; mPlayer->space = *(int*)mValue;
} }
void Client_PwUp(void* mValue) void Client_PwUp(void* mValue){
{
static int iPwType; static int iPwType;
switch(mState++){ switch(mState++){
case 0: case 0:
iPwType = *(int*)mValue; iPwType = *(int*)mValue;
switch(iPwType){
switch(iPwType)
{
case TSPWUP_KUNGFU : case TSPWUP_KUNGFU :
mPlayer->items |= TSITEM_KUNGFU; mPlayer->items |= TSITEM_KUNGFU;
break; break;
@ -270,7 +268,8 @@ void Client_PwUp(void* mValue)
} }
break; break;
case 1: case 1:
if ( iPwType != TSPWUP_KUNGFU && iPwType != TSPWUP_SJUMP ) mPlayer->PwUpValue = *(int*)mValue; if ( iPwType != TSPWUP_KUNGFU && iPwType != TSPWUP_SJUMP )
mPlayer->PwUpValue = *(int*)mValue;
break; break;
} }
} }