Attack code split adds magic attack

If you want to help us or give some corrections / codes, put it here ;)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Attack code split adds magic attack

Postby Planetary_Myth on Tue Nov 09, 2010 5:08 am

Edit: Added new code to battle.cpp at bottom should balance the base damage out. (Tested)
Highest char I have on official is lvl 83 so i have no data on on chars higher than that.
I was able to base damage up to lvl 130 all lvls past 130 use the formula for lvl 130.
Fixed typo in chartype.h

I ported MagicAttack from osprose base R2 over to the dev rev 2.
Plus I had to in order to split attack into the two types.
These must be added first before the battle.cpp code will work.
The battle code is at the bottom.

All changes are in color.
Lines 1 & 2 are so you know where the code was added under.
The lines above and below the color are so you know where to put it.

chartype.h

  1. struct STATS
  2. {
  3.  
  4.     unsigned long long MaxMP;
  5.  
  6.     unsigned int MagicAttack;
  7.     unsigned int Attack_Power;


character.h

  1.        // stats
  2.         virtual unsigned int GetAttackPower( );
  3.  
  4.         virtual unsigned int GetMagicDefense( );
  5.         virtual unsigned int GetMagicAttack( );
  6.         virtual unsigned int GetCritical( );


charstats.cpp

  1. // virtual [return magic defense]
  2. unsigned int CCharacter::GetMagicDefense( )
  3. {
  4.     return 0;
  5. }
  6.  
  7. // virtual [return magic attack]
  8. unsigned int CCharacter::GetMagicAttack( )
  9. {
  10.     return 0;
  11. }
  12.  
  13. // virtual [return critical]
  14. unsigned int CCharacter::GetCritical( )


WorldMonster.h

  1.        // Stats
  2.         unsigned int GetAttackPower();
  3.  
  4.         unsigned int GetMagicDefense();
  5.         unsigned int GetMagicAttack();
  6.         unsigned int GetCritical();


MonsterStats.cpp

  1.    return mdef;
  2. }
  3.  
  4. // return magic attack
  5. unsigned int CMonster::GetMagicAttack( )
  6. {
  7.     return thisnpc->magicattack;            
  8. }
  9.  
  10. // return max hp
  11. // unsigned int CMonster::GetMaxHP( )
  12. unsigned long long CMonster::GetMaxHP( )


  1.    if (all||Stats->Magic_Defense==0)
  2.     {
  3.         Stats->Magic_Defense = GetMagicDefense();
  4.     }
  5.  
  6.     if (all||Stats->MagicAttack==0)
  7.     {
  8.         Stats->MagicAttack = GetMagicAttack();
  9.     }
  10.  
  11.     if (all||Stats->Critical==0)


player.h

  1.    // Player Stats
  2.     unsigned int GetAttackPower( );
  3.  
  4.     unsigned int GetCartSpeed( );
  5.     unsigned int GetMagicAttack( );
  6.     //unsigned int GetMaxHP( );


playerstats.cpp

  1.    return Critical;
  2. }
  3.  
  4. // Return Magic Attack based on the weapon currently equipped
  5. unsigned int CPlayer::GetMagicAttack( )
  6. {
  7.     if(GServer->EquipList[WEAPON].Index[items[7].itemnum]->magicattack == 1)
  8.         return 1;
  9.     else
  10.         return 0;
  11. }
  12.  
  13. // Return Magic Defense with and without PAT         //A_MRESIST(21) / MAGIC_RESISTENCE_2(98) ok
  14. unsigned int CPlayer::GetMagicDefense( )


  1. // calculate Player Stats
  2. void CPlayer::SetStats( )
  3. {
  4.  
  5.     //end
  6.     Stats->MagicAttack = GetMagicAttack( );
  7.     Stats->Attack_Power = GetAttackPower( );


datatypes.h

  1. // Equip information
  2. struct CEquip
  3. {
  4.  
  5.     UINT magicresistence;
  6.     UINT magicattack;
  7.     UINT attackdistance;


  1. struct CNPCData {
  2.     UINT id;
  3.  
  4.     UINT magicdefense;
  5.     UINT magicattack;
  6.     UINT dodge;


startup.cpp

  1. //LMA: npc_data, STB version.
  2. bool CWorldServer::LoadNPCData( )
  3. {
  4.     //LMA: Mass Exporter.
  5.     if (Config.massexport==1)
  6.  
  7.         newnpc->atkspeed = STB_NPC.rows[i][14];
  8.         newnpc->magicattack = STB_NPC.rows[i][15];
  9.         newnpc->AI = STB_NPC.rows[i][16];


  1. //All files from itemtype 1 to 10 are loaded here, it's a test for weapons I guess.
  2.             if (STB_ITEM[j].fieldcount>35)
  3.             {
  4.                 newequip->attackpower = STB_ITEM[j].rows[i][35];
  5.                 newequip->attackspeed = STB_ITEM[j].rows[i][36];
  6.                 newequip->magicattack = STB_ITEM[j].rows[i][37];      //new. Staffs and wands are designated as magic weapons.
  7.                 if(newequip->magicattack > 1)newequip->magicattack = 0; //all the blue named spears have weird numbers here. Maybe why NA had a massive damage glitch with them.
  8.                
  9.             }
  10.             else
  11.             {
  12.                 newequip->attackpower = 0;
  13.                 newequip->attackspeed = 0;
  14.                 newequip->magicattack = 0;
  15.             }
  16.  
  17.             //job1 to job3
  18.             for(int k=0;k<3;k++)


Damage formula needs testing.
Thanks to PurpleYouko for sharing the code with me.
Changed a few things from PurpleYouko's version.

battle.cpp

  1. // do normal attack
  2. void CCharacter::NormalAttack( CCharacter* Enemy )
  3. {
  4.     //LMA: Sometimes it's fired several times, no need to kill several times ;)
  5.     bool is_already_dead=Enemy->IsDead();
  6.  
  7.     Position->destiny = Position->current;
  8.  
  9.     //LMA: Log
  10.     if(IsPlayer())
  11.         Log(MSG_INFO,"Forcing destiny to current (%.2f,%.2f), (%.2f,%.2f)",Position->current.x,Position->current.y,Position->destiny .x,Position->destiny .y);
  12.  
  13.     reduceItemsLifeSpan( false );
  14.     Enemy->OnBeAttacked( this );
  15.     int attack = 0;
  16.     int LvlDiff = 0;
  17.  
  18.     int LvlBonus = (Stats->Level / 10) - 1;
  19.     Log(MSG_INFO,"Lvl Bonus %i,%i",LvlBonus,Stats->Level);
  20.     if(LvlBonus < 0) {LvlBonus = 0;}
  21.     else if(LvlBonus > 13) {LvlBonus = 13;}
  22.  
  23.     int Lvldiff = (Stats->Level - LvlBonus) - (LvlBonus + Enemy->Stats->Level) + 15;
  24.     Log(MSG_INFO,"Lvl diff %i,%i,%i,%i",Lvldiff,Stats->Level,LvlBonus,Enemy->Stats->Level);
  25.    
  26.     if(Lvldiff > 15)
  27.     {
  28.     Lvldiff = 15;
  29.     Log(MSG_INFO,"Lvl diff max %i",Lvldiff);
  30.     }
  31.     else if(Lvldiff < 2)
  32.     {
  33.     Lvldiff = 2;
  34.     Log(MSG_INFO,"Lvl diff min %i",Lvldiff);
  35.     }
  36.        
  37.     if(Stats->MagicAttack == 1)
  38.     {
  39.     attack = Stats->Attack_Power - (Enemy->Stats->Magic_Defense / Lvldiff);
  40.     Log(MSG_INFO,"MagicAtt %i,%i,%i,%i",attack,Stats->Attack_Power,Enemy->Stats->Magic_Defense,Lvldiff);
  41.     }
  42.     else
  43.     {
  44.     attack = Stats->Attack_Power - (Enemy->Stats->Defense / Lvldiff);
  45.     Log(MSG_INFO,"NormalAtt %i,%i,%i,%i",attack,Stats->Attack_Power,Enemy->Stats->Defense,Lvldiff);
  46.     }
  47.  
  48.     if(attack<0) attack = 5;
  49.     LvlDiff = (Stats->Level - Enemy->Stats->Level) / 4;
  50.     if(LvlDiff<7) LvlDiff = 4;
  51.     attack += GServer->RandNumber( 0, LvlDiff );
  52.     long int hitpower = (long int)floor (attack);
  53.     if(IsPlayer( )) //temp fix to find balance btw monster and player
  54.         hitpower = (long int)floor(attack * (GServer->Config.PlayerDmg/100.00));
  55.     if(IsMonster( )) //temp fix to find balance btw monster and player
  56.         hitpower = (long int)floor(attack * (GServer->Config.MonsterDmg/100.00));
Last edited by Planetary_Myth on Thu Nov 18, 2010 6:41 pm, edited 3 times in total.
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Attack code split adds magic attack

Postby Sethanye on Tue Nov 09, 2010 5:11 am

if(newequip->magicattack > 1)newequip->magicattack = 0; //all the blue named spears have weird numbers here. Maybe why NA had a massive damage glitch with them.


just use the extended item id and there shouldn't be any weird issues with them. instead of 8001 for wooden sword you can use 800001, with that it reads items to 99999 fine. apart from that nice work ^^

my question would however be skills, i see you covered and split the item types to magic and physical and that's fine, but skills don't seem to be designated this way. idk how narose does it to be fair, i don't play narose, but it would seem to be only logical that lets say champ skills do physical damage because they are done with a weapon, however mages and priests should cause magical damage with their skills as they are spells. Also dont remember how stbs handle the armor stats, too lazy to look it up at 4am, but if they handle both physical and mdef then priests and mages would have a lot more chances in pvp cos if their skills are assigned to magic it would create a diversity

Edit: oh yeah and there is also pat weapons that should be handled in the same manner as weapons
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: Attack code split adds magic attack

Postby Planetary_Myth on Tue Nov 09, 2010 5:36 am

Sethanye wrote:
if(newequip->magicattack > 1)newequip->magicattack = 0; //all the blue named spears have weird numbers here. Maybe why NA had a massive damage glitch with them.


just use the extended item id and there shouldn't be any weird issues with them. instead of 8001 for wooden sword you can use 800001, with that it reads items to 99999 fine. apart from that nice work ^^

my question would however be skills, i see you covered and split the item types to magic and physical and that's fine, but skills don't seem to be designated this way. idk how narose does it to be fair, i don't play narose, but it would seem to be only logical that lets say champ skills do physical damage because they are done with a weapon, however mages and priests should cause magical damage with their skills as they are spells. Also dont remember how stbs handle the armor stats, too lazy to look it up at 4am, but if they handle both physical and mdef then priests and mages would have a lot more chances in pvp cos if their skills are assigned to magic it would create a diversity

Edit: oh yeah and there is also pat weapons that should be handled in the same manner as weapons


Top code I left as it was in dev rev 2 so I am not sure what LMame meant by that statement.

As it sits the code should only replace the base damage and well the bonus I put for Lvl difference.
All other bonuses should be handled as they were before as I did not change below the base attack.
Now I would have to look into the rest you pointed out because at this moment I have no clue where or how they are handled.
My main concern was to port it over from osprose to osrose so there was a base to work with and so I could test the battle.cpp code I wanted to try.
Any and all help on this code would be most appreciated.
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Attack code split adds magic attack

Postby Sethanye on Tue Nov 09, 2010 6:15 am

well for skill handling i guess you would need to define them in a similar fashion as you did weapons, pick out which skills are priest/mage and assign the ids to a magic attack instead of physical. i guess in a sense it would be rather similar as the weapons
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: Attack code split adds magic attack

Postby Terr0risT on Tue Nov 09, 2010 12:33 pm

Skills are already split in Magical Attack and Physical in dev Rev II.

  1. }
  2.     switch(skill->formula)//Magical Or Weapon Type Skill?
  3.     {


I'll try whatever i Can to test and give reports to this. I have a totally different custom formula too, but this is worth a try.
User avatar
Terr0risT
Rackie
Rackie
 
Posts: 162
Joined: Sat Aug 11, 2007 10:22 am

Re: Attack code split adds magic attack

Postby PurpleYouko on Tue Nov 09, 2010 3:15 pm

Sethanye wrote:
if(newequip->magicattack > 1)newequip->magicattack = 0; //all the blue named spears have weird numbers here. Maybe why NA had a massive damage glitch with them.


just use the extended item id and there shouldn't be any weird issues with them. instead of 8001 for wooden sword you can use 800001, with that it reads items to 99999 fine. apart from that nice work ^^

This has nothing to do with the id Sethy.
There is a column in the STB (column 37) that defines whether a weapon is a "magic" or "normal" attack.
In 99% of the STB it is boolean. 1 = magic. 0 = normal
With the blue spears (in Pre-evo NOT Evo) though it is some weird number like 3 or 5 so i figure they were getting magic + normal attacks in their calculations. hence the reason that in pre-evo, everybody wanted blue spears cuz they kicked ass.

my question would however be skills, i see you covered and split the item types to magic and physical and that's fine, but skills don't seem to be designated this way. idk how narose does it to be fair, i don't play narose, but it would seem to be only logical that lets say champ skills do physical damage because they are done with a weapon, however mages and priests should cause magical damage with their skills as they are spells. Also dont remember how stbs handle the armor stats, too lazy to look it up at 4am, but if they handle both physical and mdef then priests and mages would have a lot more chances in pvp cos if their skills are assigned to magic it would create a diversity

Edit: oh yeah and there is also pat weapons that should be handled in the same manner as weapons


The skills STB also has a column defining magic or physical attack. In fact there are 17 different skill 'types' that have to be worked into the code. It's all done in osprose already.

And yes the armor STBs have both normal and magical defense defined in them.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Attack code split adds magic attack

Postby Planetary_Myth on Tue Nov 09, 2010 7:03 pm

Thanks PurpleYouko you are saving me time from writing code that already exists.
I will see if I can find the code in question and add it to dev rev 2.

Fixed a mistake in battle.cpp code that would not let it compile.

code before
  1. LvlDiff = ((Stats->Level - Enemy->Stats->Level) * .25);


code now (replaced in first post as well)
  1. LvlDiff = (Stats->Level - Enemy->Stats->Level) / 4;
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Attack code split adds magic attack

Postby Terr0risT on Tue Nov 09, 2010 9:27 pm

Ok, i don't wanna guess.. but any reason for using "4" in the code below?

  1. LvlDiff = (Stats->Level - Enemy->Stats->Level) / 4;
User avatar
Terr0risT
Rackie
Rackie
 
Posts: 162
Joined: Sat Aug 11, 2007 10:22 am

Re: Attack code split adds magic attack

Postby Planetary_Myth on Tue Nov 09, 2010 9:58 pm

Terr0risT wrote:Ok, i don't wanna guess.. but any reason for using "4" in the code below?

  1. LvlDiff = (Stats->Level - Enemy->Stats->Level) / 4;


/4 will give the same result as * .25
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Attack code split adds magic attack

Postby Terr0risT on Wed Nov 10, 2010 4:36 am

Yeah i know that, maybe you misunderstood my question., why not 5, or 6 or 7..

EDIT: Oh well, nevermind. I thought it was something really important. I realized that's only for random damage. Okay thanks..
User avatar
Terr0risT
Rackie
Rackie
 
Posts: 162
Joined: Sat Aug 11, 2007 10:22 am

Next

Return to Submit Code

Who is online

Users browsing this forum: No registered users and 3 guests