James76, you are 100% right that most people that can currently do code updates are by no means professional coders. The only ones that I would consider professionals are KLS and Derision. But one thing we do all have in common is that we know the emulator very well and have been involved with it for a while and hand selected to be allowed to update the source code. We have to understand that updates to the SVN effect everyone that uses it, so not only do we have to make sure that any code that gets added works, we also have to be sure that it is an improvement and that it follows the direction that the emulator is going for.
I am probably the least code savvy of all of the people with SVN access lol. I only started looking at the source a few months back and have been learning code purely by examples in the source. So, please don't judge the team by my replies  I was only asking more of you because no one else was running with the code and getting it put in.
I realize that your current submission has been hanging around much longer than it should have been, and I apologize for that. As it was mentioned by So_1337, the new SVN was added which opens up the possibility for constant updates. Since it has been added, there have been multiple updates every day, which is just awesome! It also shows that everyone on the team has been very busy getting code updates from other people or themselves added in. But, it also means that just posting line numbers and not replace with or add below or some kind of diff makes adding any code submissions more work than they should be. Even I could probably read through your code and eventually figure out what is going on and what needs to go where, but my time is limited. I am running the latest SVN code and that is what I am adding code into, so line numbers are not as useful to me. It would probably have been much easier to figure out what goes where if I was also using 1129 code to reference where it was supposed to be added, but that is just 1 more extra step.
For me, adding in code is like playing Suduko. Sure, I can figure out where everything goes on my own by looking at what is around it, but it is SO much quicker/easier if I have all of the answers right in front of me :P
KLS has asked that code submissions are made in 1 of 2 formats to make it easier/quicker on her, which also means easier/quicker on the rest of us now. Anything not done in this format will almost always take considerably longer to be looked at and added to the source.
http://www.eqemulator.net/forums/showthread.php?t=26351
I will go through this diff that erde posted and try to get it added on my server and tested most likely tonight:
Code:
Index: attack.cpp
===================================================================
--- attack.cpp (Revision 95)
+++ attack.cpp (Arbeitskopie)
@@ -171,8 +171,8 @@
sint32 level_difference = attacker_level - defender_level;
if(level_difference < -20) level_difference = -20;
if(level_difference > 20) level_difference = 20;
- chancetohit += (145 * level_difference / 100);
- chancetohit -= ((float)defender->GetAGI() * 0.015);
+ chancetohit += static_cast<int>(145.0f * static_cast<float>(level_difference) / 100.0f);
+ chancetohit -= static_cast<int>(static_cast<float>(defender->GetAGI()) * 0.015f);
#ifdef EQBOTS
@@ -417,7 +417,7 @@
/////////////////////////////////////////////////////////
// riposte
/////////////////////////////////////////////////////////
- if (damage > 0 && CanThisClassRiposte() && !other->BehindMob(this, other->GetX(), other->GetY()))
+ if (damage >= 0 && CanThisClassRiposte() && !other->BehindMob(this, other->GetX(), other->GetY()))
{
skill = GetSkill(RIPOSTE);
if (IsClient()) {
@@ -427,7 +427,7 @@
if (!ghit) { //if they are not using a garunteed hit discipline
bonus = (defender->spellbonuses.RiposteChance + defender->itembonuses.RiposteChance);
- bonus += 2.0 + skill/35.0 + (GetDEX()/200);
+ bonus += 2.0f + static_cast<float>(skill)/35.0f + static_cast<float>(GetDEX())/200.0f;
RollTable[0] = bonus;
}
}
@@ -444,7 +444,7 @@
}
if (!ghit) { //if they are not using a garunteed hit discipline
- bonus = 2.0 + skill/35.0 + (GetDEX()/200);
+ bonus = 2.0f + static_cast<float>(skill)/35.0f + static_cast<float>(GetDEX())/200.0f;
RollTable[1] = RollTable[0] + bonus;
}
}
@@ -463,9 +463,9 @@
this->CastToClient()->CheckIncreaseSkill(PARRY, -10);
}
- bonus = (defender->spellbonuses.ParryChance + defender->itembonuses.ParryChance) / 100.0f;
+ bonus = static_cast<float>(defender->spellbonuses.ParryChance + defender->itembonuses.ParryChance) / 100.0f;
if (!ghit) { //if they are not using a garunteed hit discipline
- bonus += 2.0 + skill/35.0 + (GetDEX()/200);
+ bonus += 2.0f + static_cast<float>(skill)/35.0 + static_cast<float>(GetDEX())/200.0f;
RollTable[2] = RollTable[1] + bonus;
}
}
@@ -485,9 +485,9 @@
this->CastToClient()->CheckIncreaseSkill(DODGE, -10);
}
- bonus = (defender->spellbonuses.DodgeChance + defender->itembonuses.DodgeChance) / 100.0f;
+ bonus = static_cast<float>(defender->spellbonuses.DodgeChance + defender->itembonuses.DodgeChance) / 100.0f;
if (!ghit) { //if they are not using a garunteed hit discipline
- bonus += 2.0 + skill/35.0 + (GetAGI()/200);
+ bonus += 2.0f + static_cast<float>(skill)/35.0f + static_cast<float>(GetAGI())/200.0f;
RollTable[3] = RollTable[2] + bonus;
}
}
@@ -602,7 +602,7 @@
//Add these to rules eventually
//double the clients intervals to make their damage output look right, move to rule eventually too
- int intervalsAllowed = 20;
+ uint32 intervalsAllowed = 20;
if(defender->IsClient())
intervalsAllowed *= 2;
@@ -642,7 +642,7 @@
char tmp[10];
if (database.GetVariable("ACfail", tmp, 9)) {
- acfail = (int) (atof(tmp) * 100);
+ acfail = static_cast<int>(atof(tmp) * 100.0f);
if (acfail>100) acfail=100;
}
@@ -657,12 +657,12 @@
if (database.GetVariable("ACrandom", tmp, 9))
{
- acrandom = (int) ((atof(tmp)+1) * 100);
+ acrandom = static_cast<int>((atof(tmp)+1.0f) * 100.0f);
if (acrandom>10100) acrandom=10100;
}
if (acreduction>0) {
- damage -= (int) (GetAC() * acreduction/100.0f);
+ damage -= static_cast<int>(GetAC() * acreduction/100.0f);
}
if (acrandom>0) {
damage -= (myac * MakeRandomInt(0, acrandom) / 10000);
@@ -758,7 +758,7 @@
if(against->SpecAttacks[IMMUNE_MELEE_EXCEPT_BANE]){
if(weapon_item){
- if(weapon_item->BaneDmgBody == against->GetBodyType()){
+ if(weapon_item->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){
banedmg += weapon_item->BaneDmgAmt;
}
@@ -775,7 +775,7 @@
}
else{
if(weapon_item){
- if(weapon_item->BaneDmgBody == against->GetBodyType()){
+ if(weapon_item->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){
banedmg += weapon_item->BaneDmgAmt;
}
@@ -831,7 +831,7 @@
dmg = weapon_item->GetItem()->Damage;
}
- for(int x = 0; x < 5; x++){
+ for(int x = 0; x < 5; ++x){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
dmg += weapon_item->GetAugment(x)->GetItem()->Damage;
}
@@ -863,7 +863,7 @@
dmg = weapon_item->GetItem()->Damage;
}
- for(int x = 0; x < 5; x++){
+ for(int x = 0; x < 5; ++x){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
dmg += weapon_item->GetAugment(x)->GetItem()->Damage;
}
@@ -892,15 +892,15 @@
}
if(eledmg)
- dmg += (eledmg * against->ResistSpell(weapon_item->GetItem()->ElemDmgType, 0, this) / 100);
+ dmg += static_cast<int>(eledmg * against->ResistSpell(weapon_item->GetItem()->ElemDmgType, 0, this) / 100);
}
if(weapon_item){
- for(int x = 0; x < 5; x++){
+ for(int x = 0; x < 5; ++x){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
eledmg += weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt;
if(weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt)
- dmg += (weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt * against->ResistSpell(weapon_item->GetAugment(x)->GetItem()->ElemDmgType, 0, this) / 100);
+ dmg += static_cast<int>(weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt * against->ResistSpell(weapon_item->GetAugment(x)->GetItem()->ElemDmgType, 0, this) / 100);
}
}
}
@@ -908,7 +908,7 @@
if(against->SpecAttacks[IMMUNE_MELEE_EXCEPT_BANE]){
if(weapon_item && weapon_item->GetItem()){
- if(weapon_item->GetItem()->BaneDmgBody == against->GetBodyType()){
+ if(weapon_item->GetItem()->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){
if(IsClient() && GetLevel() < weapon_item->GetItem()->RecLevel){
banedmg += CastToClient()->CalcRecommendedLevelBonus(GetLevel(), weapon_item->GetItem()->RecLevel, weapon_item->GetItem()->BaneDmgAmt);
}
@@ -926,9 +926,9 @@
}
}
- for(int x = 0; x < 5; x++){
+ for(int x = 0; x < 5; ++x){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
- if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){
+ if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){
banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt;
}
@@ -947,7 +947,7 @@
}
else{
if(weapon_item && weapon_item->GetItem()){
- if(weapon_item->GetItem()->BaneDmgBody == against->GetBodyType()){
+ if(weapon_item->GetItem()->BaneDmgBody == static_cast<uint32>(against->GetBodyType())){
if(IsClient() && GetLevel() < weapon_item->GetItem()->RecLevel){
banedmg += CastToClient()->CalcRecommendedLevelBonus(GetLevel(), weapon_item->GetItem()->RecLevel, weapon_item->GetItem()->BaneDmgAmt);
}
@@ -965,7 +965,7 @@
}
}
- for(int x = 0; x < 5; x++){
+ for(int x = 0; x < 5; ++x){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){
banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt;
@@ -1047,7 +1047,7 @@
/// Now figure out damage
int damage = 0;
int8 mylevel = GetLevel() ? GetLevel() : 1;
- int8 otherlevel = other->GetLevel() ? other->GetLevel() : 1;
+ //int8 otherlevel = other->GetLevel() ? other->GetLevel() : 1; //unused
int weapon_damage = GetWeaponDamage(other, weapon);
//if weapon damage > 0 then we know we can hit the target with this weapon
@@ -1057,7 +1057,7 @@
//Berserker Berserk damage bonus
if(berserk && GetClass() == BERSERKER){
int bonus = 3 + GetLevel()/10; //unverified
- weapon_damage = weapon_damage * (100+bonus) / 100;
+ weapon_damage = static_cast<int>(static_cast<float>(weapon_damage) * (100.0f+static_cast<float>(bonus) / 100.0f));
mlog(COMBAT__DAMAGE, "Berserker damage bonus increases DMG to %d", weapon_damage);
}
@@ -1081,21 +1081,18 @@
//monks are supposed to be a step ahead of other classes in
//toe to toe combat, small bonuses for hitting key levels too
- int bonus = 0;
+ int nBonus = 0;
+ int nLevel = GetLevel();
+
if(GetClass() == MONK)
- bonus += 20;
- if(GetLevel() > 50)
- bonus += 15;
- if(GetLevel() >= 55)
- bonus += 15;
- if(GetLevel() >= 60)
- bonus += 15;
- if(GetLevel() >= 65)
- bonus += 15;
-
- min_hit += (min_hit * bonus / 100);
- max_hit += (max_hit * bonus / 100);
+ 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);
+
// ***************************************************************
// *** Calculate the damage bonus, if applicable, for this hit ***
// ***************************************************************
@@ -1120,7 +1117,7 @@
}
#endif
- min_hit = min_hit * (100 + itembonuses.MinDamageModifier + spellbonuses.MinDamageModifier) / 100;
+ min_hit = static_cast<int>(static_cast<float>(min_hit) * static_cast<float>(100 + itembonuses.MinDamageModifier + spellbonuses.MinDamageModifier) / 100.0f);
if (Hand==14) {
if(GetAA(aaSinisterStrikes)) {
@@ -1146,6 +1143,7 @@
mlog(COMBAT__ATTACKS, "Attack missed. Damage set to 0.");
damage = 0;
other->AddToHateList(this, 0);
+ other->AvoidDamage(this, damage);
} else { //we hit, try to avoid it
other->AvoidDamage(this, damage);
other->MeleeMitigation(this, damage, min_hit);
@@ -1932,7 +1930,7 @@
//if NPCs can't inheriently hit the target we don't add bane/magic dmg which isn't exactly the same as PCs
int16 eleBane = 0;
if(weapon){
- if(weapon->BaneDmgBody == other->GetBodyType()){
+ if(weapon->BaneDmgBody == static_cast<uint32>(other->GetBodyType())){
eleBane += weapon->BaneDmgAmt;
}
@@ -1941,7 +1939,7 @@
}
if(weapon->ElemDmgAmt){
- eleBane += (weapon->ElemDmgAmt * other->ResistSpell(weapon->ElemDmgType, 0, this) / 100);
+ eleBane += static_cast<int16>(weapon->ElemDmgAmt * other->ResistSpell(weapon->ElemDmgType, 0, this) / 100);
}
}
@@ -1985,7 +1983,8 @@
other->AddToHateList(this, hate);
} else {
if(!other->CheckHitChance(this, skillinuse, Hand)) {
- damage = 0; //miss
+ damage = 0; //miss
+ other->AvoidDamage(this, damage);
} else { //hit, check for damage avoidance
other->AvoidDamage(this, damage);
other->MeleeMitigation(this, damage, min_dmg+eleBane);
@@ -2240,7 +2239,7 @@
/* Send the EVENT_KILLED_MERIT event and update kill tasks
* for all group members */
- for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
+ for (int i = 0; i < MAX_GROUP_MEMBERS; ++i) {
if (kg->members[i] != NULL && kg->members[i]->IsClient()) { // If Group Member is Client
Client *c = kg->members[i]->CastToClient();
parse->Event(EVENT_KILLED_MERIT, GetNPCTypeID(), "killed", this, c);
@@ -2306,7 +2305,7 @@
if(killer->IsGrouped()) {
Group* group = entity_list.GetGroupByClient(killer->CastToClient());
if(group != 0) {
- for(int i=0;i<6;i++) { // Doesnt work right, needs work
+ for(int i=0;i<6;++i) { // Doesnt work right, needs work
if(group->members[i] != NULL) {
corpse->AllowMobLoot(group->members[i],i);
}
@@ -3195,7 +3194,7 @@
bool Mob::HasProcs() const
{
- for (int i = 0; i < MAX_PROCS; i++)
+ for (int i = 0; i < MAX_PROCS; ++i)
if (PermaProcs[i].spellID != SPELL_UNKNOWN || SpellProcs[i].spellID != SPELL_UNKNOWN)
return true;
return false;
@@ -3685,7 +3684,6 @@
break;
}
}
-
#ifdef EQBOTS
// Bot AA WeaponAffinity
@@ -3709,12 +3707,10 @@
#endif //EQBOTS
+ 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; ProcChance += ProcBonus;
- ProcBonus += float(itembonuses.ProcChance + spellbonuses.ProcChance) / 1000.0f;
-
- ProcChance = 0.05f + float(mydex) / 9000.0f;
- ProcBonus += (ProcChance * AABonus) / 100;
- ProcChance += ProcBonus;
mlog(COMBAT__PROCS, "Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus);
return ProcChance;
}
@@ -3747,7 +3743,7 @@
//do augment procs
int r;
- for(r = 0; r < MAX_AUGMENT_SLOTS; r++) {
+ for(r = 0; r < MAX_AUGMENT_SLOTS; ++r) {
const ItemInst* aug_i = weapon_g->GetAugment(r);
if(!aug_i)
continue;
@@ -3757,7 +3753,7 @@
if (IsValidSpell(aug->Proc.Effect)
&& (aug->Proc.Type == ET_CombatProc)) {
- ProcChance = ProcChance*(100+aug->ProcRate)/100;
+ ProcChance *= (100.0f+static_cast<float>(aug->ProcRate))/100.0f;
if (MakeRandomFloat(0, 1) < ProcChance) { // 255 dex = 0.084 chance of proc. No idea what this number should be really.
if(aug->Proc.Level > ourlevel) {
Mob * own = GetOwner();
@@ -3783,7 +3779,7 @@
//give weapon a chance to proc first.
if(weapon != NULL) {
if (IsValidSpell(weapon->Proc.Effect) && (weapon->Proc.Type == ET_CombatProc)) {
- float WPC = ProcChance*(100+weapon->ProcRate)/100;
+ float WPC = ProcChance*(100.0f+static_cast<float>(weapon->ProcRate))/100.0f;
if (MakeRandomFloat(0, 1) <= WPC) { // 255 dex = 0.084 chance of proc. No idea what this number should be really.
if(weapon->Proc.Level > ourlevel) {
mlog(COMBAT__PROCS, "Tried to proc (%s), but our level (%d) is lower than required (%d)", weapon->Name, ourlevel, weapon->Proc.Level);
@@ -3809,7 +3805,7 @@
}
//now try our proc arrays
- float procmod = float(GetDEX()) / 100.0f + ProcBonus*100.0; //did somebody think about this???
+// float procmod = float(GetDEX()) / 100.0f + ProcBonus*100.0; //did somebody think about this???
//AndMetal: aren't we doing this in GetProcChances?
uint32 i;
@@ -3823,7 +3819,7 @@
}
}
if (SpellProcs[i].spellID != SPELL_UNKNOWN) {
- int chance = ProcChance + SpellProcs[i].chance;
+ int chance = static_cast<int>(ProcChance + static_cast<float>(SpellProcs[i].chance));
if(MakeRandomInt(0, 100) < chance) {
mlog(COMBAT__PROCS, "Spell proc %d procing spell %d (%d percent chance)", i, SpellProcs[i].spellID, chance);
ExecWeaponProc(SpellProcs[i].spellID, on);
@@ -4269,14 +4265,14 @@
}
//Rogue sneak attack disciplines make use of this, they are active for one hit
- for(int bs = 0; bs < BUFF_COUNT; bs++){
+ for(int bs = 0; bs < BUFF_COUNT; ++bs){
if(buffs[bs].numhits > 0 && IsDiscipline(buffs[bs].spellid)){
if(skill == spells[buffs[bs].spellid].skill){
if(buffs[bs].numhits == 1){
BuffFadeBySlot(bs, true);
}
else{
- buffs[bs].numhits--;
+ --buffs[bs].numhits;
}
}
}
I know that doing code submissions in forums isn't really the best possible way to do it, but we can't just allow SVN update access for everyone. And, at least it still allows anyone who wants to share their work with the community for the benefit of all. It takes lots of patience and consistency to be considered for the emulator team. I am sure that with your skill, if you were able to remain patient and consistent with code submissions or helping around the forums in other ways, you would eventually be able to get SVN access. There are other factors as well, like attitude, trustworthiness, and other key factors, but the emu team does recognize deserving members. Sometimes things move slower than they should, but we are working on that!
Remember that everyone here is here voluntarily and we do our best with the time that is allowed. All in all, I think this community is by far better than any other I have seen. And, even though things may have gotten a little slower over the past year or 2 due to a large portion of the team leaving and not being replaced, we have made leaps and bounds in recent months. Many new team members have been added and some older team members have had their access upgraded to increase the rate of progress. And, the new SVN is just awesome and should make a huge impact on the project overall.
If you really do plan to give up so early, then that is your decision. But, I do think we can clear up any issues you may have with the current system.
Last edited by trevius; 10-16-2008 at 03:56 PM..
|