EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Feature Requests (https://www.eqemulator.org/forums/forumdisplay.php?f=612)
-   -   PvP stats (https://www.eqemulator.org/forums/showthread.php?t=16979)

Magoth78 11-12-2004 11:27 PM

PvP stats
 
Hello,

I'm sorry to bother you with the PvP but is it possible to add some stats when a Player kills an other Player?

How I would see that:
- New table in the DB called: PvPstats
- Fields: Pwinner (the killer's name) Pwinguild (the killer's guild) Pwinlevel (level of the winner) Plooser (the looser) Ploosguild (the looser's guild) Plooslvl(level of the looser) Nkills (number of kills).

-> When player1(guild: Goodies) kills player2(guild: Shorties), it adds an entrie in the PvPstats table:
- players1|goodies|51|players2|shorties|51|1

This way, it would become possible to make some pvp stats :)

Thx,
Mag

Muuss 11-14-2004 10:04 PM

This kind of implements would be nice to add for any PvP server. I m not sure of how much work it requires, but it seems than adding a simple query adding a row in a table when a player dies from another one might not be that hard. Exploiting that table from an external website, to make PvP rosters will be really valuable !
Tho, i would suggest a different table from Mag's one, instead of cumulating kills on the same record, i would just add 1 row per kill, with the date, so it could allow to make periodic stats instead of global ones!

Magoth78 08-19-2005 12:02 AM

Hello there,

I'm sorry to bump my old post but I would like to know if it would be possible to add this feature?

Thx by advance,
Mag

fathernitwit 08-19-2005 02:18 AM

anything is possible, but its not gunna get written by the core developers right now, we have a lot of higher priorities.

Magoth78 08-19-2005 05:59 PM

Ok fnw, no probs.
I'll just wait then.

Mag

Magoth78 09-15-2005 12:15 PM

I've learned c++ and coded it, so I don't need it anymore.

It's working well even if the code might be crappy :D

If anyone is interested by the code changes, I can give them np.

Mag

Dr Zauis 09-15-2005 12:27 PM

"I've learned c++ and coded it, so I don't need it anymore."

Well Hello Albert Einstein! That was quick learning!

vRandom 09-15-2005 12:28 PM

I would be interested in seeing the code. I'm curious if maybe it could be modified to count all kills a player does that way we could make a site similar to eq2's player profiling... number kills each player did, and what not...

just an idea...

vRandom

Magoth78 09-15-2005 08:29 PM

Quote:

Originally Posted by Dr Zauis
"I've learned c++ and coded it, so I don't need it anymore."

Well Hello Albert Einstein! That was quick learning!


Quick yeah, but i dunno about how good is the code :D

Vrandom, once a player kills an other player , it add an entrie in the pvpstats table, in that way:
killID|Killername|killerlevel|killerguild|Looserna me|Looserlevel|Looserguild|PvPpoints|Timestamp

So you can see (using php by example):
- Daily, Weekly, Monthly: who is the best killer, which's the best guild, how many kills does have a player, who is the best target of a player, etc...
Also pvppoints are calculated depending of the levels and it also works for group kills.


Once I'll get to home, I'll show the code i've made.

Mag

Magoth78 09-15-2005 11:06 PM

Last line of database.cpp
Code:

bool Database::UpdatePVPPoints(const char* killername, int klevel, int kguildid, const char* loosername, int llevel, int lguildid, int pvppoints)
{
        // debug
        printf("Starting the update...\n");
        // end debug
        char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
        int32        affected_rows = 0;
        //printf("Variables ok...\n");
        if (!RunQuery(query, MakeAnyLenString(&query,
                "INSERT INTO pvpstats (killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints) VALUES ('%s','%i','%i','%s','%i','%i','%i')",killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints),
                errbuf, 0, &affected_rows)); {
                        //printf("Error Updating the points......\n");
                safe_delete_array(query);
                return false;
                }
        //printf("UpdatePVPPoints: %s,%i,%i,%s,%i,%i,%i\n",killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints);
        safe_delete_array(query);
        return true;
}


add this in database.h:
Code:

bool UpdatePVPPoints(const char* killername, int klevel, int kguildid, const char* loosername, int llevel, int lguildid, int pvppoints);
and in attack.cpp just after the lines:
Code:

//                if(!IsLD())//Todo: make it so an LDed client leaves corpse if its enabled
//                        MakeCorpse(exploss);

add this:
Code:

if(GetGM() || !IsBecomeNPC() && other != NULL && other->IsClient())
 // added GetGM() for debug purposes
        {
                        const char* killername = other->GetName();
                        int klevel = other->GetLevel();
                        int kguildid = other->CastToClient()->GuildDBID();
                        const char* loosername = this->GetName();
                        int llevel = this->GetLevel();
                        int lguildid = this->CastToClient()->GuildDBID();
                        int pvppoints;
                        int diflevel = klevel - llevel;
                       
                        if(diflevel >= 10)
                                pvppoints = 10;

                        if(diflevel < 10 && diflevel >= 7)
                                pvppoints = 25;

                        if(diflevel < 7 && diflevel >= 4)
                                pvppoints = 40;

                        if(diflevel < 4 && diflevel >= 1)
                                pvppoints = 50;
                               
                        if(diflevel == 0)
                                pvppoints = 60;

                        if(diflevel <= -1 && diflevel > -4 )
                                pvppoints = 80;

                        if(diflevel <= -4 && diflevel > -7)
                                pvppoints = 100;

                        if(diflevel < -7)
                                pvppoints = 120;

                        if(kguildid == NULL){
                                kguildid = 0;
                        }
                        if(lguildid == NULL){
                                lguildid = 0;
                        }
                        //// let's calcul points of the group

                                if(other->CastToClient()->IsGrouped()) {
                                        Group* group = entity_list.GetGroupByClient(other->CastToClient());
                                                for(int i=0;i<MAX_GROUP_MEMBERS;i++) {
                                                                if(group->members[i] != NULL) {
                                                                        Client* c = group->members[i]->CastToClient();
                                                                        pvppoints = llevel / 4;
                                                                        c->Message(0,"You have gained %i points in this fight!",pvppoints);
                                                                        database.UpdatePVPPoints(c->GetName(),c->GetLevel(),c->GuildDBID(),loosername,llevel,lguildid,pvppoints);
                                                                }
                                                        }
                                                }
               
                                else{
                                                printf("Variables: killername = %s, klevel = %i, kguildid = %i, loosername = %s, llevel = %i, lguildid = %i, pvppoints = %i\n",
                                                killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints);

                                                database.UpdatePVPPoints(killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints);
                                                //LogFile->write(EQEMuLog::Error, "%i,%i,%i,%s,%i,%i,%i"), killerid,klevel,kguildid,looserid,llevel,lguildid,pvppoints;
                                                other->CastToClient()->Message(0,"You have gained %i points in this fight!",pvppoints);
                                                printf("PVP: %s has been killed by %s\n",loosername,killername);
                                                //this->CastToClient()->Message(0,"You have been killed by an enemy. Xp lost!");
                                    }
                       

                       
        }

yes I know that the code is ugly, but my skills in c++ are still low :D


You will can notice that all pvppoints are previously declared. (it's what i wanted to do on empire). You can change them, or add a formula for the points check.

You will have to create a new table in your db called "pvpstats" with the columns: id(int(11)auto_increment), killername(varchar(64)),klevel(int(11)),kguilid(in t(11)),loosername(varchar(64)),llevel(int(11)),lgu ildid(int(11)),pvppoints(int(11)),date(timestamp(C URRENT_TIMESTAMP on update CURRENT_TIMESTAMP)).


Mag

vRandom 09-16-2005 04:00 AM

Quote:

Originally Posted by Magoth78
Last line of database.cpp

yes I know that the code is ugly, but my skills in c++ are still low :D

Mag

np, my c++ skills are, humm, below that low you used, i just have a nack in figuring things out

Thanks for sharing, I'll see what I come up with later, got called to the office :( I hate the office....

Good job on the code Mag.
vRandom

cavedude 09-16-2005 05:31 AM

OT but I bet my office is worse than yours :P One of my users somehow removed the root user from their Linux server. I told them not use root. I told them they would break it.... LOL

vRandom 09-16-2005 05:43 AM

Quote:

Originally Posted by cavedude
OT but I bet my office is worse than yours :P One of my users somehow removed the root user from their Linux server. I told them not use root. I told them they would break it.... LOL

LMAO, I totaly understand that one... my user did rm -fr in the root dir because it had to much stuff in it..... /sigh

vRandom


All times are GMT -4. The time now is 08:57 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.