[devRev4] MP drops to zero when casting AOE

Welcome in the osRose emulator Project.

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

[devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Tue May 07, 2013 8:08 pm

Hello OsRose. :D

We have a problem again - and hopefully someone here could help us out.

Whenever a player casts' an AOE skill, disregarded whether its targeted AOE(Icy Hailstorm) or staystill (Tornado, Windstorm) the players MP drops to zero.

But this happens only when MANY mobs are attacking.

See here, I used a windstorm in one enemy:
-seems fine.
1.jpg


And here, when mobs are attacking:
-there it goes.
2.jpg


When mobs are still far out tho,
-it does not mess the MP
3.jpg


And again this happens when mobs started attacking:
4.jpg


I don't think this is any packet issue, seems to be that when mobs attack during the time the player is CASTING an AOE skill, the MP is DAMAGED in return. (I'm assuming here.)
See screenshot number three, a few mobs are already attacking, and as I was casting ICY HAILSTORM, my MP drops to half. So I think, the damage of the mobs is what messing with the MP.

I've also thought that the MP required to use a certain AOE skill is CALCULATED as damage to a single mob - meaning if AOE-ing, the server calculates an MP minus to each mob a player is attacking.

Okay, enough assumptions for today. :D

I've looked into charfunctions and battle cpp - but, dnt know where to look .

Hopefully someone can point me somewhere. :) Thank you.
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] MP drops to zero when casting AOE

Postby PurpleYouko on Wed May 08, 2013 3:19 pm

It sounds like the MP cost is being applied per monster rather than per attack.

I have checked through the code that i have here and that is not happening.
Then again we have seen differences between your code base and mine before so you should probably check your code.

What you need to do is look through battle.cpp
find function bool CCharacter::AoeSkill( CSkills* skill, CCharacter* Enemy )
scan through it till you find a call to an actual damage function
You will find it in a bit of code that looks like this
  1. if(IsPlayer() || IsSummon())
  2.     {
  3.         //monsters.
  4.         for(UINT i=0;i<map->MonsterList.size();i++)
  5.         {
  6.             CMonster* monster = map->MonsterList.at(i);
  7.             if(monster->clientid == clientid) continue;
  8.             if(monster->IsSummon( ) && (map->allowpvp == 0 || monster->owner == clientid)) continue;
  9.             if(GServer->IsMonInCircle( goodtarget,monster->Position->current,(float)skill->aoeradius+1))
  10.             {
  11.                 if(GServer->ServerDebug)
  12.                 Log(MSG_INFO,"AOE Attack (1) player attacks monster %i (clientID %u) radius %.2f",monster->montype,monster->clientid,(float)skill->aoeradius+1);
  13.  
  14.                 //LMA: we have to since AOE doesn't have a specific target and atkskil resets some values.
  15.                 Battle->skilltarget=monster->clientid;
  16.                 Battle->skillid=skill->id;
  17.                 Battle->atktype = save_atktype;
  18.                 UseAtkSkill( (CCharacter*) monster, skill );

The very last line in that code snippet calls function UseAtkSkill from within the loop of all monsters in range of the attack.
If your code is calling a different function such as SkillAttack then you have a problem since SkillAttack charges an MP cost each time it is called.

Try looking through the UseAtkSkill function to see if you can find any place where code like this Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100)); is applied
In fact you can search the whole of battle.cpp by using the find function (Ctrl-F) and typing in Stats->MP then search. Do not use find in files. just find so that it stays in the present cpp file.
You can cycle through all the instances of the code by pressing F3
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: [devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Wed May 08, 2013 6:24 pm

I printed out all the places I've found Stat->MP (with calculations) just to be sure.

Altho I think, we should be more concern of LINE 1362 and 1384. Those are what handles the AOE skills



Line 1003 under bool CCharacter::SkillAttack( CCharacter* Enemy, CSkills* skill )
  1.    Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));



Line 1025 under bool CCharacter::SkillAttack( CCharacter* Enemy, CSkills* skill )
  1. Stats->MP -= (skill->costamount[1] - (skill->mp * Stats->MPReduction / 100));



Line 1088 under bool CCharacter::BuffSkill( CCharacter* Target, CSkills* skill )
  1.   Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));



Line 1110 under bool CCharacter::BuffSkill( CCharacter* Target, CSkills* skill )
  1. Stats->MP -= (skill->costamount[1] - (skill->mp * Stats->MPReduction / 100));



Line 1166 under bool CCharacter::DebuffSkill( CCharacter* Enemy, CSkills* skill )
  1. Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));





Line 1362 under bool CCharacter::AoeSkill( CSkills* skill, CCharacter* Enemy )
  1.    Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));
  2.  



Line 1384 under bool CCharacter::AoeSkill( CSkills* skill, CCharacter* Enemy )
  1. Stats->MP -= (skill->costamount[1] - (skill->mp * Stats->MPReduction / 100));




Line 1416 under bool CCharacter::AoeBuff( CSkills* skill )
  1. Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));



Line 1515 underbool CCharacter::AoeBuff( CSkills* skill )
  1.    Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));



Line 1600 under bool CCharacter::AoeDebuff( CSkills* skill, CCharacter* Enemy )
  1. Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] MP drops to zero when casting AOE

Postby PurpleYouko on Wed May 08, 2013 6:56 pm

they all look fine. At least you didn't find any MP adjustments being made in UseAtkSkill

However there is something in your code that must be drastically different to mine because the two lines of code that you have at positions 1362 and 1384 are at 1186 and 1208 in my source :shock:

still, as long as the cost is not being applied inside the monster loop then that isn't the cause of it.

It may be possible that after an AOE attack, it isn't being set back to a normal attack properly in which case it could potentially loop through some unexpected code many times.
It's kind of tricky to debug this stuff over a forum.

Try running in debug mode ( gm command /serverdebug ) and see what prints out
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: [devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Wed May 08, 2013 7:03 pm

Here is the whole bool for AOESKILL:

  1.  
  2.  
  3. // do AoE skill
  4. bool CCharacter::AoeSkill( CSkills* skill, CCharacter* Enemy )
  5. {
  6.     //LMA: not here since AOE can have NULL Enemy, will be catched later by the call to the skill.
  7.     //bool is_already_dead=Enemy->IsDead();
  8.     if(GServer->ServerDebug)
  9.         Log(MSG_INFO,"In AOE Skill");
  10.     Position->destiny = Position->current;
  11.     //Log(MSG_INFO,"Position in AOE: %.2f,%.2f",Position->current.x,Position->current.y);
  12.  
  13.     //LMA: handling case of AOE_SKILLS and AOE_TARGET (the target point is not the same).
  14.     fPoint goodtarget;
  15.     goodtarget=Position->current;
  16.     if (Battle->atktype==AOE_TARGET)
  17.     {
  18.        goodtarget=Position->aoedestiny;
  19.     }
  20.  
  21.     if(Battle->castTime==0)
  22.     {
  23.         BEGINPACKET( pak, 0x7bb );
  24.         ADDWORD    ( pak, clientid );
  25.         GServer->SendToVisible( &pak, (CCharacter*)this );
  26.         Battle->castTime = clock();
  27.         return true;
  28.     }
  29.     else
  30.     {
  31.         //LMA: No delay for AOE_TARGET skill (zone)
  32.         if (Battle->atktype!=AOE_TARGET)
  33.         {
  34.             clock_t etime = clock() - Battle->castTime;
  35.             if(etime<SKILL_DELAY)
  36.                 return true;
  37.         }
  38.  
  39.     }
  40.  
  41.     Battle->castTime = 0;
  42.     CMap* map = GServer->MapList.Index[Position->Map];
  43.  
  44.     //osprose
  45.     //LMA: pvp ?
  46.     UINT save_atktype=Battle->atktype;
  47.  
  48.     if(IsPlayer() || IsSummon())
  49.     {
  50.         //monsters.
  51.         for(UINT i=0;i<map->MonsterList.size();i++)
  52.         {
  53.             CMonster* monster = map->MonsterList.at(i);
  54.             if(monster->clientid == clientid) continue;
  55.             if(monster->IsSummon( ) && (map->allowpvp == 0 || monster->owner == clientid)) continue;
  56.             if(GServer->IsMonInCircle( goodtarget,monster->Position->current,(float)skill->aoeradius+1))
  57.             {
  58.                 if(GServer->ServerDebug)
  59.                     Log(MSG_INFO,"AOE Attack (1) player attacks monster %i (clientID %u) radius %.2f",monster->montype,monster->clientid,(float)skill->aoeradius+1);
  60.  
  61.                 //LMA: we have to since AOE doesn't have a specific target and atkskil resets some values.
  62.                 Battle->skilltarget=monster->clientid;
  63.                 Battle->skillid=skill->id;
  64.                 Battle->atktype = save_atktype;
  65.                 UseAtkSkill( (CCharacter*) monster, skill, true, true );
  66.  
  67.                 //LMA: TEST is there a "buff/debuff" skill with it too?
  68.                 /*
  69.                 if (skill->status[0]!=0&&skill->buff[0]!=0&&monster->Stats->HP>0)
  70.                 {
  71.                     UseBuffSkill( (CCharacter*)monster, skill );
  72.                     Log(MSG_INFO,"AOE Attack (1) player buffs monster %i",monster->montype);
  73.                 }
  74.                 */
  75.  
  76.                 //LMA: AIP time.
  77.                 monster->DoAi(monster->thisnpc->AI, 3);
  78.                 //END OF TEST.
  79.  
  80.             }
  81.  
  82.         }
  83.  
  84.         //Pvp, group Vs group, here all.
  85.         if(map->allowpvp!=0&&IsPlayer())
  86.         {
  87.             CPlayer* plattacker=(CPlayer*) this;
  88.             for (UINT i=0;i<map->PlayerList.size();i++)
  89.             {
  90.                 CPlayer* thisplayer=map->PlayerList.at(i);
  91.                 if(thisplayer==NULL)
  92.                 {
  93.                     continue;
  94.                 }
  95.  
  96.                 //not attacking allies.
  97.                 if(thisplayer->pvp_id==plattacker->pvp_id)
  98.                 {
  99.                     continue;
  100.                 }
  101.  
  102.                 if(GServer->IsMonInCircle( goodtarget,thisplayer->Position->current,(float)skill->aoeradius+1))
  103.                 {
  104.                     //LMA: we have to since AOE doesn't have a specific target and atkskil resets some values.
  105.                     Battle->skilltarget=thisplayer->clientid;
  106.                     Battle->skillid=skill->id;
  107.                     Battle->atktype = save_atktype;
  108.                     UseAtkSkill( (CCharacter*) thisplayer, skill, false, true );
  109.                     if(GServer->ServerDebug)
  110.                         Log(MSG_WARNING,"AOE Skill pvp player %s",thisplayer->CharInfo->charname);
  111.                 }
  112.  
  113.             }
  114.  
  115.         }
  116.  
  117.     }
  118.  
  119.     if(IsMonster() && !IsSummon())
  120.     {
  121.         for(UINT i=0;i<map->PlayerList.size();i++)
  122.         {
  123.             CPlayer* player = map->PlayerList.at(i);
  124.             if(player->clientid == clientid) continue;
  125.             if(GServer->IsMonInCircle( goodtarget,player->Position->current,(float)skill->aoeradius+1))
  126.             {
  127.                 if(GServer->ServerDebug)
  128.                     Log(MSG_INFO,"AOE Attack (2) monster attacks player %s radius %.2f",player->CharInfo->charname,(float)skill->aoeradius+1);
  129.                 UseAtkSkill( (CCharacter*) player, skill, false, true );
  130.             }
  131.  
  132.         }
  133.     }
  134.     //osprose end
  135.  
  136.     if(Enemy!=NULL)
  137.     {
  138.         if(!Enemy->IsDead( ))
  139.         {
  140.             Battle->atktarget = Battle->target;
  141.             Battle->atktype = NORMAL_ATTACK;
  142.             Battle->skilltarget = 0;
  143.             Battle->skillid = 0;
  144.         }
  145.         else
  146.         {
  147.             ClearBattle( Battle );
  148.         }
  149.  
  150.     }
  151.     else
  152.     {
  153.         ResumeNormalAttack(NULL,true);
  154.         //ClearBattle( Battle );
  155.     }
  156.  
  157.     if(skill->costtype[0] == 17)
  158.     Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));
  159.     //Some skills uses zulie
  160.     if(skill->costtype[0] == 40)
  161.     {
  162.         CPlayer* thisclient = GServer->GetClientByID(clientid,Position->Map);
  163.         thisclient->CharInfo->Zulies -= skill->costamount[0];
  164.         if(thisclient->CharInfo->Zulies < 0) thisclient->CharInfo->Zulies = 0;
  165.         BEGINPACKET( pak, 0x71d );
  166.         ADDQWORD( pak, thisclient->CharInfo->Zulies );
  167.         thisclient->client->SendPacket( &pak );
  168.     }
  169.     if(skill->costtype[1] == 40)
  170.     {
  171.         CPlayer* thisclient = GServer->GetClientByID(clientid,Position->Map);
  172.         thisclient->CharInfo->Zulies -= skill->costamount[1];
  173.         if(thisclient->CharInfo->Zulies < 0) thisclient->CharInfo->Zulies = 0;
  174.         BEGINPACKET( pak, 0x71d );
  175.         ADDQWORD( pak, thisclient->CharInfo->Zulies );
  176.         thisclient->client->SendPacket( &pak );
  177.  
  178.     }else if(skill->costtype[1] == 17)
  179.     {
  180.         Stats->MP -= (skill->costamount[1] - (skill->mp * Stats->MPReduction / 100));
  181.     }
  182.     if(Stats->MP<0) Stats->MP=0;
  183.     Battle->lastAtkTime = clock( );
  184.     return true;
  185. }
  186.  
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Wed May 08, 2013 7:05 pm

Altho, I would just like to ask PY, about the changes i did in charfunctions to make the AOE targetted skills work, which is here:
http://forum.dev-osrose.com/viewtopic.php?f=18&t=5377

I changed the Battle->target = 0; to Battle->target = Battle->atktarget;
because targetting a zone doesn't seem to work with targeted AOE.
Stay still AOE (Tornado, Windstorm) works with or without this fix tho.


And also I changed:
  1. case AOE_TARGET:
  2.         {
  3.             if(Battle->skilltarget!=0 && Battle->skillid!=0) return true;
  4.         }


then moved it below:
  1. case AOE_TARGET:
  2.         {
  3.             if(Battle->skillid!=0) return true;
  4.         }


To be clearer, if you have time you can check the changes I did from that post. Thank you. :)
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Wed May 08, 2013 7:14 pm

This is the structure of your code in that last line right?
UseAtkSkill( (CCharacter*) monster, skill );

Well, this is ours:
UseAtkSkill( (CCharacter*) monster, skill, false, true );

I tried setting, the FALSE to true:
Mana don't decrease anymore. :lol:
Altho that is very tempting, no one will agree on that.

I hope that helps tho.
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] MP drops to zero when casting AOE

Postby PurpleYouko on Wed May 08, 2013 7:36 pm

Where exactly did your code come from?
or did you add some stuff yourself.

I just checked the roseZA source that was released as dev rev 4 and the structure of that function call matches mine
  1. UseAtkSkill( (CCharacter*) monster, skill );

Where did that boolean come from?

Just checked dev rev 3 too and that also matches my code.

FYI I'm still the owner of both those SVN repositories ;)
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: [devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Wed May 08, 2013 7:45 pm

RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Re: [devRev4] MP drops to zero when casting AOE

Postby kismetbecomes on Wed May 08, 2013 9:58 pm

PurpleYouko wrote:Try running in debug mode ( gm command /serverdebug ) and see what prints out


The worldserver prints out packet 0x783 [13]
RoseZa v437 - HueRose Test Project -- http://hueroseonline.no-ip.biz
kismetbecomes
Rackie
Rackie
 
Posts: 299
Joined: Mon Feb 06, 2012 12:41 am

Next

Return to Support - OsRose Emulator

Who is online

Users browsing this forum: No registered users and 8 guests