View Single Post
  #1  
Old 05-20-2003, 06:06 PM
kaldec
Fire Beetle
 
Join Date: May 2003
Posts: 11
Default EXP modifier patch

This is my first attempt at modifying the code, so please go easy on me.

This is just a bit of code to allow admins to modify the amount of EXP earned, AAEXP earned, and the EXP bonus for each additional member of the group. If this is something people want, I'd like to expand it to include Quest EXP vs. Mob EXP, death penalties, mob stats and other balancing issues as well. All of these would be controlled through table entries so that admins could make some balance changes without deciphering the source and recompiling.

The current entries are all controlled through the variables table
  • GroupEXPBonus = EXP modifier for each member of group (default = .1)

    EXPMod = EXP earned multiplier in GetEXP (default = 1.0)

    AAXPMod = AAXP earned multiplier in GetEXP (default = 1.0)
Anyway here's a diff against the zone directory vs 0.4.4-DR1.

I'm not much of a C++ programmer, and do development on Linux so I'm not making any promises. Any feedback or other project ideas are welcome.


Code:
diff -uBb ../Source/zone/client.cpp zone/client.cpp
--- ../Source/zone/client.cpp   2003-05-14 15:28:39.000000000 -0500
+++ zone/client.cpp     2003-05-20 14:27:24.000000000 -0500
@@ -1048,9 +1048,9 @@
 
 void Client::AddEXP(int32 add_exp) {
        int32 add_aaxp = (int32)((float)add_exp * ((float)((float)pp.perAA) / 100
.0f));
-       int32 exp = GetEXP() + (add_exp - add_aaxp);
+       int32 exp = GetEXP() + (int32)(zone->GetEXPMod() * (add_exp - add_aaxp));
 
-       int32 aaexp = GetAAXP() + add_aaxp;
+       int32 aaexp = GetAAXP() + (int32)(zone->GetAAXPMod() * add_aaxp);
        SetEXP(exp, aaexp, false);
        // FIXME!       int32 add_aaxp = (int32)((float)add_exp * ((float)pp.perA
A / 100.0f));
        // FIXME!       SetEXP(GetEXP() + (add_exp - add_aaxp), GetAAXP() + add_a
axp, false);
diff -uBb ../Source/zone/groups.cpp zone/groups.cpp
--- ../Source/zone/groups.cpp   2003-05-14 15:28:38.000000000 -0500
+++ zone/groups.cpp     2003-05-20 20:15:18.000000000 -0500
@@ -201,7 +201,7 @@
         {
                        if(members[i]->GetLevel() > maxlevel)
                                maxlevel = members[i]->GetLevel();
-                       groupexp += exp/10;
+                       groupexp += (uint32)(exp * zone->GetGroupEXPBonus());
                        membercount++;
                }
        }
diff -uBb ../Source/zone/zone.cpp zone/zone.cpp
--- ../Source/zone/zone.cpp     2003-05-14 15:28:38.000000000 -0500
+++ zone/zone.cpp       2003-05-20 20:14:30.000000000 -0500
@@ -93,6 +93,7 @@
        if (!zone->LoadZoneCFG(zone->GetShortName(), true)) // try loading the zo
ne name...
                zone->LoadZoneCFG(zone->GetFileName()); // if that fails, try the
 file name, then load defaults
        char tmp[10];
+       char *tmp2;
        PlayerProfile_Struct* pp;
        int char_num = 0;
        unsigned long* lengths;
@@ -136,6 +137,20 @@
                }
                mysql_free_result(result);
                }
+
+       // Set default value for EXP modifiers
+       zone->EXPMod = (double)1;
+        zone->GroupEXPBonus = 0.1;
+        zone->AAXPMod = (double)1;
+
+       // Look for database entries and use them if they exist
+       if (database.GetVariable("EXPMod", tmp, 9)) 
+               zone->EXPMod = strtod((const char*)tmp, &tmp2);
+       if (database.GetVariable("GroupEXPBonus", tmp, 9)) 
+               zone->GroupEXPBonus = strtod((const char*)tmp, &tmp2);
+       if (database.GetVariable("AAXPMod", tmp, 9)) 
+               zone->AAXPMod = strtod((const char*)tmp, &tmp2);
+
        //g_LogFile.write("AI LEVEL set to %d\n",iAILevel);
        petition_list.ClearPetitions();
        petition_list.ReadDatabase();
diff -uBb ../Source/zone/zone.h zone/zone.h
--- ../Source/zone/zone.h       2003-05-14 15:28:39.000000000 -0500
+++ zone/zone.h 2003-05-20 14:28:01.000000000 -0500
@@ -132,6 +132,11 @@
        bool    IsCityTakeable() { return citytakeable; }
        int16   CityGuardRace(int32 zoneID);
 
+
+       double   GetGroupEXPBonus() { return GroupEXPBonus; }
+       double   GetEXPMod()        { return EXPMod; }
+       double   GetAAXPMod()      { return AAXPMod; } 
+
        void    weatherProc();
        void    weatherSend();
        time_t  weather_timer;
@@ -164,6 +169,10 @@
        float   psafe_x, psafe_y, psafe_z;
        int32   pMaxClients;
 
+       double  GroupEXPBonus;
+       double  EXPMod;
+       double  AAXPMod;
+       
        bool    staticzone;
        bool    gottime;
Kaldec
Reply With Quote