Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2008, 06:23 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I would even say to maybe try posting a couple of your major changes first in 1 post and then maybe start a new thread for all of the minor stuff. That should keep it from being too overwhelming and the major stuff would get quick attention.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 10-08-2008, 03:20 PM
James76
Sarnak
 
Join Date: Sep 2008
Location: Canada
Posts: 53
Smile

Alrighty, I've made two lists of changes, one for the combat fixes, and one for the generic type warnings and general use of code. The file link I posted above included all of them, I don't believe I missed anything although I may have, and you will notice them when you compile. That is, you shouldn't get any warnings anymore when you execute 'make' for the zone executable, if all other ".o" files were already made except attack.o. To anyone who doesn't already know, after you "make zone", delete attack.o, and run make again -- that is what I'm talking about. My posted file link also included a uniform formatting scheme, making the file 500% more readable. Some of the code in the original file had skewed blocks which made tracing slightly difficult. One of the companies I worked for had issued to us a uniform coding methodology document which I've been applying ever since, which made all projects readable by everyone so there wasn't ever any confusion. You will also notice that the new variables I create include a type-hint in its name, which was also part of that referred document.

To address Trevius' statement about being a relatively new member, I had been following this project for some time, though I haven't put my mind towards applying changes. It wasn't until I basically quit all MMO's and I remembered this old project, and I came back to see how far it came, and started up my own server for development. I have been coding C++ specifically for about 20 years, and I have a knack for code that allows me to just jump in on any project, because its clearer to me than reading english. This project only uses perhaps 20-30% of the potential of C++, according to Strustrup's own definitive language guide. It can get 1000% more confusing when you see all that is possible, and even then its readable to me with no issues at all. I have always had this gift, if you would like to call it that, ever since I started coding when I was 6 years old on an IBM XT in BASIC. I knew how to code before learning how to read, I don't know how or why, its just always been natural. Maybe I learned how to read by using those "learn to program BASIC" manuals with those type-them-in starter programs. But for certain, I understood math functions like ABS(), exponents, and BEDMAS when they were teaching the other kids Addition. When I was 7 I traced the source code of a learning game called Lemonade Stand, to remove the ABS() from an input line when you buy your components, during a class break on a Commodore PET, so that you could buy & sell like it was a free market. My teacher was most definitely NOT impressed when I showed I could make millions, because she saw it like an act of destroying school property, even though the change was not permanent in any way.... But I digress.

All these changes refer to an unedited attack.cpp from build 1129. I'll give the line number (or range) with a colon, and the required change. Sometimes I'll include an unchanged first line of a multi-line modification.

You may want to work from the bottom-up, so as not to become confused by line-number skewing, and preferably from the very bottom of this entire post.

Ok, the riposte fix, and some combat math fixes are as follows:
Code:
342:
  if (damage >= 0 && CanThisClassRiposte() && !other->BehindMob(this, other->GetX(), other->GetY()))


956-969:
  int nBonus = 0;
  int nLevel = GetLevel();

  if(GetClass() == MONK)
    nBonus += 20;
  if(nLevel > 50)
    nBonus += 15 * ((nLevel - 45)/5);
    
  float fBonus = 1.0f + static_cast<float>(nBonus)/100.0f;
  min_hit = static_cast<int>(static_cast<float>(min_hit) * fBonus);
  max_hit = static_cast<int>(static_cast<float>(max_hit) * fBonus);


978:
    min_hit = static_cast<int>(static_cast<float>(min_hit) * static_cast<float>(100 + itembonuses.MinDamageModifier + spellbonuses.MinDamageModifier) / 100.0f);


995:
  other->AddToHateList(this, 0);
  other->AvoidDamage(this, damage);


1526:
  damage = 0;  //miss
  other->AvoidDamage(this, damage);


OK, now for the type warning fixes, as well as the "++" or "--" modifications. These type fixes are not some sort of psychotic application of static_cast, it was only applied to replace the older "C" type-cast ing of (int) with static_cast(int), or because the math led me to believe (with careful analysis) a cast may or should be required. You will notice I did not type-cast everything, which would be a mark of insanity, because the compiler -will- apply casts when risk of loss of information is nil, without warning. For example, an int to a float is no risk, and no casting required.

Code:
LINE 174 & 175:
  chancetohit += static_cast<int>(145.0f * static_cast<float>(level_difference) / 100.0f);
  chancetohit -= static_cast<int>(static_cast<float>(defender->GetAGI()) * 0.015f);

347:
  bonus += 2.0f + static_cast<float>(skill)/35.0f + static_cast<float>(GetDEX())/200.0f;

364:
  bonus = 2.0f + static_cast<float>(skill)/35.0f + static_cast<float>(GetDEX())/200.0f;

383:
  bonus = static_cast<float>(defender->spellbonuses.ParryChance + defender->itembonuses.ParryChance) / 100.0f;

385:
  bonus += 2.0f + static_cast<float>(skill)/35.0 + static_cast<float>(GetDEX())/200.0f;

405:
  bonus = static_cast<float>(defender->spellbonuses.DodgeChance + defender->itembonuses.DodgeChance) / 100.0f;

407:
  bonus += 2.0f + static_cast<float>(skill)/35.0f + static_cast<float>(GetAGI())/200.0f;

477:
  uint32 intervalsAllowed = 20;

517:
  acfail = static_cast<int>(atof(tmp) * 100.0f);

532:
  acrandom = static_cast<int>((atof(tmp)+1.0f) * 100.0f);

537:
  damage -= static_cast<int>(GetAC() * acreduction/100.0f);

633:
  if(weapon_item->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){

650:
  if(weapon_item->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){

706:
  for(int x = 0; x < 5; ++x){

738:
  for(int x = 0; x < 5; ++x){

767:
  dmg += static_cast<int>(eledmg * against->ResistSpell(weapon_item->GetItem()->ElemDmgType, 0, this) / 100);

771:
  for(int x = 0; x < 5; ++x){

775:
  dmg += static_cast<int>(weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt * against->ResistSpell(weapon_item->GetAugment(x)->GetItem()->ElemDmgType, 0, this) / 100);

783:
  if(weapon_item->GetItem()->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){

801:
  for(int x = 0; x < 5; ++x){

803:
  if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){

822:
  if(weapon_item->GetItem()->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){

840:
  for(int x = 0; x < 5; ++x){

922:
  //int8 otherlevel = other->GetLevel() ? other->GetLevel() : 1; //unused

932:
  weapon_damage = static_cast<int>(static_cast<float>(weapon_damage) * (100.0f+static_cast<float>(bonus) / 100.0f));

1473:
  if(weapon->BaneDmgBody == static_cast<uint32>(other->GetBodyType())){

1482:
  eleBane += static_cast<int16>(weapon->ElemDmgAmt * other->ResistSpell(weapon->ElemDmgType, 0, this) / 100);

1724:
  for (uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i){

1766:
  for(int i=0;i<6;++i) { // Doesnt work right, needs work

2099:
  for (int i = 0; i < MAX_PROCS; ++i)

2495-2498:
  ProcBonus += static_cast<float>(itembonuses.ProcChance + spellbonuses.ProcChance) / 1000.0f;
  ProcChance = 0.05f + static_cast<float>(mydex) / 9000.0f;
  ProcBonus += (ProcChance * static_cast<float>(AABonus)) / 100.0f;

2532:
  for(r = 0; r < MAX_AUGMENT_SLOTS; ++r) {

2542:
  ProcChance *= (100.0f+static_cast<float>(aug->ProcRate))/100.0f;

2568:
  float WPC = ProcChance*(100.0f+static_cast<float>(weapon->ProcRate))/100.0f;

2594:
  //float procmod =  static_cast<float>(GetDEX()) / 100.0f + ProcBonus*100.0f;  //did somebody think about this??? //unused

2607:
  int chance = static_cast<int>(ProcChance + static_cast<float>(SpellProcs[i].chance));

2831:
  for(int bs = 0; bs < BUFF_COUNT; ++bs){

2838:
  --buffs[bs].numhits;
Please don't read into any of my statements as though I'm being snide or crass, I'm not using any emotion, and I did not have any hurt feelings by your remarks. I understand making change can be difficult without proper source control in a fully trusted environment. A project such as this would not exist if it were up to one person alone, so this is expected. But please accept all of my changes, I've given every line in the original attack.cpp great thought.
__________________
Expert developer, I do it for a living.
Don't let the "Junior" tag fool you.

Last edited by trevius; 10-10-2008 at 02:12 PM..
Reply With Quote
  #3  
Old 10-08-2008, 03:31 PM
James76
Sarnak
 
Join Date: Sep 2008
Location: Canada
Posts: 53
Default

I just noticed I use variable nLevel once, when it was intended to replace all further uses of GetLevel(), before I created the math statement to apply bonus damage for increments of 5 levels at 50+. Before it was calling GetLevel() 4 or 5 times. It was too late for me to edit the post, so maybe include that little tweak when implementing. That is, replace all further uses (only one more exists in that method) of GetLevel() with nLevel.
__________________
Expert developer, I do it for a living.
Don't let the "Junior" tag fool you.
Reply With Quote
  #4  
Old 10-09-2008, 04:24 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I am glad you weren't upset with my post

I do think that making the code format uniform and cleaning up any compile warnings is awesome. But, if/when you ever decide to do it again, please only do it without making other changes so we know what to expect and what to look for. Making code changes and format changes at the same time makes it too hard to tell what is happening. Probably waiting until the next official release to reformat any files would be a good idea, so we don't have to try to fit the new code changes since the last update in retro-actively. The quicker we can get a new reformat in after a new release, the better.

And on your note about the GetLevel adjustment, are you saying that this code:

Code:
  int nBonus = 0;
  int nLevel = GetLevel();

  if(GetClass() == MONK)
    nBonus += 20;
  if(GetLevel() > 50)
    nBonus += 15 * ((nLevel - 45)/5);
Should actually be changed to this:

Code:
  int nBonus = 0;
  int nLevel = GetLevel();

  if(GetClass() == MONK)
    nBonus += 20;
  if(nLevel > 50)
    nBonus += 15 * ((nLevel - 45)/5);
and no other changes? Or am I misunderstanding what you are saying?

I can edit that change into your post if I know exactly what you wanted set.

Then we can officially test out the code and get it added
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #5  
Old 10-09-2008, 01:49 PM
James76
Sarnak
 
Join Date: Sep 2008
Location: Canada
Posts: 53
Default

Quote:
Originally Posted by trevius View Post
and no other changes?
Yep, you got it.
__________________
Expert developer, I do it for a living.
Don't let the "Junior" tag fool you.
Reply With Quote
  #6  
Old 10-14-2008, 07:35 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Tried to add some of this code to my source tonight and am unable to tell if I need to add in parts of code, replace part, or remove parts.

If you can post something like:

After this:

Code:
SomeCode
Add this:

Code:
SomeMoreCode
or

Remove this:

Code:
SomeCode
And replace it with this:

Code:
SomeNewCode
That would make it ALOT easier to get this code added and tested. Sorry about all of the extra work to break it down, but it is still hard to add it in without knowing exactly what is needing to be removed, added, or replaced.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 10-14-2008, 12:19 PM
James76
Sarnak
 
Join Date: Sep 2008
Location: Canada
Posts: 53
Default Hrm

Well, I figured if I posted 80 or 100 blocks of one-liner code fields, it would look much more confusing than some simple one-line changes, ... All it takes is to look at the source code, find the line, and change it.

The "riposte and combat math" fixes part, let me eludicate......

342: CHANGE THE LINE

956-969: CHANGE LINES 956-969 WITH THE FOLLOWING

978: CHANGE THE LINE

995: YOU WILL SEE AddToHateList(), insert AvoidDamage() below.

1526: YOU WILL SEE damage=0, insert AvoidDamage() below.

The rest of the changes are simply changes.. I've been holding back any further work until this gets integrated, if this is such a problem maybe I should just wait for CVS access and merge changes myself, if CaveDude EVER gets back to me... This is starting to turn into some kind of joke.
__________________
Expert developer, I do it for a living.
Don't let the "Junior" tag fool you.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:09 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3