[HELP] Buff Fairy's for OsRose

Welcome in the osRose emulator Project.

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

Re: [HELP] Buff Fairy's for OsRose

Postby AnimalCrackerz on Mon Sep 11, 2017 5:25 pm

Idosel would be fine...I can add her to the database her dialog id is in the list_event still I dont think that they removed entry's.
But I use this con editor...it takes a hecka long time to load.for me but my pc get wierd with some of these tools. but works very well .lua wise Don't remember who made it..
you probably don't need it..but as far as con editors go it's very nice and reliable.
But for whoever else is following this topic might want it.
Attachments
Npc Studio.rar
(2.68 MiB) Downloaded 549 times
AnimalCrackerz
Pomic
Pomic
 
Posts: 102
Joined: Tue Apr 20, 2010 1:58 pm

Re: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Mon Sep 11, 2017 6:46 pm

Yeah that thing won't even run for me. It crashes as soon as I attempt to open the LTB from vs 137
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: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Mon Sep 11, 2017 8:16 pm

so I tested my buff code and it works... partly. The buff icons appear and the buff animations also appear on my character.
What doesn't happen is actually getting any change to my move speed or dodge rate. they both stay the same.
So this means I'm on the right track with the code that I added last week but it's just not completely doing what it should.

tested by adding a little player command to gmcmds.cpp
  1. if (strcmp(command, "buffme")==0)
  2.     {
  3.         CSkills* ThisSkill = GetSkillByID( 3205 );
  4.         thisclient->UseBuffSkillQSD(thisclient, ThisSkill);
  5.     }


This is set to just apply skill 3205 to the player. It's a GM skill that buffs move speed and dodge rate.

If you would like to add this code put it directly after the broadcast command like this
  1. if (strcmp(command, "b")==0)
  2.     {
  3.         if(Config.Command_Broadcast > thisclient->Session->accesslevel)
  4.             return true;
  5.         time_t seconds;
  6.         seconds = time (NULL);
  7.         if((thisclient->CharInfo->LastGlobal+Config.Command_GlobalTime) <= seconds || thisclient->Session->accesslevel > 100)
  8.         {
  9.             thisclient->CharInfo->LastGlobal = time (NULL);
  10.             char outputmsg[200];
  11.             sprintf( outputmsg, "%s %s", Config.Command_GlobalPrefix, &P->Buffer[3] );
  12.             Log( MSG_INFO, "%s> %s %s", thisclient->CharInfo->charname, Config.Command_GlobalPrefix, &P->Buffer[3]);
  13.             SendGlobalMSG(thisclient, outputmsg);
  14.         }
  15.         else
  16.         {
  17.             long int remaining = (Config.Command_GlobalTime-(seconds-thisclient->CharInfo->LastGlobal));
  18.             char buffer2[200];
  19.             sprintf ( buffer2, "Please wait %i seconds before sending another global message.", remaining );
  20.             SendPM(thisclient, buffer2);
  21.         }
  22.         return true;
  23.     }
  24.     if (strcmp(command, "buffme")==0)
  25.     {
  26.         CSkills* ThisSkill = GetSkillByID( 3205 );
  27.         thisclient->UseBuffSkillQSD(thisclient, ThisSkill);
  28.     }


Additionally it will be really easy to just do it this way and use an area check to make sure it only works when standing near the specified NPC. Then we don't need to worry about CON, LTB or QSD editing :D

I will be back with the other half of the puzzle later

OK so it IS applying the correct buff in the server. It's just not getting to the client to display it.
Also I've discovered that it's probably not such a hot idea to call the AddBuff() function with an INT of 1 like we were doing
  1. // use buff skill from QSD
  2. void CCharacter::UseBuffSkillQSD( CCharacter* Target, CSkills* skill, bool deBuff )
  3. {
  4.     bool bflag = false;
  5.     bflag = GServer->AddBuffs( skill, Target, 1 );
  6.     //Log(MSG_INFO,"In UseBuffSkillsQSD, skill %i, nbuffs %i, bflag %i to %u",skill->id,skill->nbuffs,bflag,Target->clientid);
  7.     if(skill->nbuffs > 0 && bflag == true)
  8.     {
  9.         BEGINPACKET( pak, 0x7b5 );
  10.         ADDWORD    ( pak, Target->clientid );
  11.         ADDWORD    ( pak, Target->clientid );
  12.         ADDWORD    ( pak, skill->id );
  13.         ADDWORD    ( pak, 1 );
  14.         ADDBYTE    ( pak, skill->nbuffs );
  15.         GServer->SendToVisible( &pak, Target );
  16.         //Log(MSG_DEBUG,"Buff Skill. buffs applied 1");
  17.     }
  18.     if (deBuff) return;
  19.     BEGINPACKET( pak, 0x7b9);
  20.     ADDWORD    ( pak, Target->clientid);
  21.     ADDWORD    ( pak, skill->id);
  22.     ADDWORD    ( pak, 1);
  23.     GServer->SendToVisible( &pak, this );
  24.     //Log(MSG_DEBUG,"Buff Skill. buffs applied 2 nbuffs = %i",skill->nbuffs);
  25.     //Log(MSG_INFO,"UseBuffSkillQSD: Target HP = %i",Target->Stats->HP);
  26. }

try this instead
  1. bflag = GServer->AddBuffs( skill, Target, 5000 );


So that gets a nice big buff applied (in the server) now we need to let the client know that it has happened. More in a bit as soon as I track the code through
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: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Mon Sep 11, 2017 9:04 pm

Building out on the earlier function. Replace the earlier "buffme" command with this

  1. if (strcmp(command, "buffme")==0)
  2.     {
  3.         if ((tmp = strtok(NULL, " "))==NULL)return true;
  4.         CSkills* ThisSkill = NULL;
  5.         if(strcmp(tmp, "atk")==0)
  6.         {   
  7.             ThisSkill = GetSkillByID( 3202 );
  8.         }
  9.         if(strcmp(tmp, "def")==0)
  10.         {   
  11.             ThisSkill = GetSkillByID( 3203 );
  12.         }
  13.         if(strcmp(tmp, "aspd")==0)
  14.         {   
  15.             ThisSkill = GetSkillByID( 3204 );
  16.         }
  17.         if(strcmp(tmp, "mspd")==0)
  18.         {   
  19.             ThisSkill = GetSkillByID( 3205 );
  20.         }
  21.         if (!ThisSkill == NULL)
  22.             thisclient->UseBuffSkillQSD(thisclient, ThisSkill);
  23.     }

So now you would type /buffme mspd to get a move speed buff

and modifying the function we made earlier in battle.cpp will fix teh buffs not showing up in the client
now it should look like this
  1. // use buff skill from QSD or from the "buffme" command
  2. void CCharacter::UseBuffSkillQSD( CCharacter* Target, CSkills* skill, bool deBuff )
  3. {
  4.     //how about a proximity check to a specified NPC?
  5.     // To be added a little later
  6.     bool bflag = false;
  7.     bflag = GServer->AddBuffs( skill, Target, 5000 );
  8.     if(skill->nbuffs > 0 && bflag == true)
  9.     {
  10.         BEGINPACKET( pak, 0x7b5 );
  11.         ADDWORD    ( pak, Target->clientid );
  12.         ADDWORD    ( pak, Target->clientid );
  13.         ADDWORD    ( pak, skill->id );
  14.         ADDWORD    ( pak, 1 );
  15.         ADDBYTE    ( pak, skill->nbuffs );
  16.         GServer->SendToVisible( &pak, Target );
  17.         //Log(MSG_DEBUG,"Buff Skill. buffs applied 1");
  18.     }
  19.     if (deBuff) return;
  20.     BEGINPACKET( pak, 0x7b9);
  21.     ADDWORD    ( pak, Target->clientid);
  22.     ADDWORD    ( pak, skill->id);
  23.     ADDWORD    ( pak, 1);
  24.     GServer->SendToVisible( &pak, this );
  25.     //buffs applied. Now we need to recalculate all the stats and we need a CPlayer object for that
  26.     CPlayer* thisclient = GServer->GetClientByID(Target->clientid,Target->Position->Map);
  27.     thisclient->SetStats();
  28. }
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: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Mon Sep 11, 2017 9:35 pm

So now we add a proximity check to Idiosel and teh function looks like this
  1. // use buff skill from QSD or from the "buffme" command
  2. void CCharacter::UseBuffSkillQSD( CCharacter* Target, CSkills* skill, bool deBuff )
  3. {
  4.     //how about a proximity check to a specified NPC?
  5.     POSITION NPCPosition;  //set NPC as Idiosel the teleporter in Zant
  6.     NPCPosition.current.x = 5244.93;
  7.     NPCPosition.current.y = 5220.95;
  8.     float dx = Target->Position->current.x - (float)(NPCPosition.current.x);
  9.     float dy = Target->Position->current.y - (float)(NPCPosition.current.y);
  10.     float distance = sqrt((dx*dx) + (dy*dy));
  11.     if (distance > 50)
  12.     {
  13.         Log(MSG_DEBUG,"buffme called but too far from Idiosel");
  14.         return; //don't apply the buff
  15.     }
  16.     bool bflag = false;
  17.     bflag = GServer->AddBuffs( skill, Target, 5000 );
  18.     if(skill->nbuffs > 0 && bflag == true)
  19.     {
  20.         BEGINPACKET( pak, 0x7b5 );
  21.         ADDWORD    ( pak, Target->clientid );
  22.         ADDWORD    ( pak, Target->clientid );
  23.         ADDWORD    ( pak, skill->id );
  24.         ADDWORD    ( pak, 1 );
  25.         ADDBYTE    ( pak, skill->nbuffs );
  26.         GServer->SendToVisible( &pak, Target );
  27.         //Log(MSG_DEBUG,"Buff Skill. buffs applied 1");
  28.     }
  29.     if (deBuff) return;
  30.     BEGINPACKET( pak, 0x7b9);
  31.     ADDWORD    ( pak, Target->clientid);
  32.     ADDWORD    ( pak, skill->id);
  33.     ADDWORD    ( pak, 1);
  34.     GServer->SendToVisible( &pak, this );
  35.     //buffs applied. Now we need to recalculate all the stats and we need a CPlayer object for that
  36.     CPlayer* thisclient = GServer->GetClientByID(Target->clientid,Target->Position->Map);
  37.     thisclient->SetStats();
  38. }
  39.  

Tested and working
It will only grant your buff if you are standing pretty close (within 50) of Idiosel
And the buff ONLY affects the player using the command. It's not an AOE

NO AIP, QSD, CON or LTB required. Just a little bit of code in the server.
It could be expanded to load in a list of locations at which it can work. You would need to add a DB table and some loading code. Pretty basic stuff.
It could even be tied into my good old PYEvents code since that already loads in some locations for teleports.

I think I will still mess around with some buff bots though since I find that idea pretty fascinating :D

Just let me know if you need or want any other features on this code.
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: [HELP] Buff Fairy's for OsRose

Postby AnimalCrackerz on Tue Sep 12, 2017 3:01 am

:roll: working
Attachments
Screenshot_1.png
AnimalCrackerz
Pomic
Pomic
 
Posts: 102
Joined: Tue Apr 20, 2010 1:58 pm

Re: [HELP] Buff Fairy's for OsRose

Postby Exordium on Tue Sep 12, 2017 1:30 pm

AnimalCrackerz wrote::roll: working

Good job to you guys! :D
Exordium
Smoulie
Smoulie
 
Posts: 67
Joined: Tue Sep 25, 2012 11:10 am

Re: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Tue Sep 12, 2017 2:13 pm

Nice

I see you have customized it a little as well.
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: [HELP] Buff Fairy's for OsRose

Postby AnimalCrackerz on Tue Sep 12, 2017 9:25 pm

Yes I did! All your suggestions were Great! I have it were if your in Adventure Plains it gives less buffs than in Junon at a lesser strength..Awesome Idea! the best part is I can edit the strength values easily and the World Server isn't constantly firing off buffs every 30 seconds on all the different maps. It buffs only the player ..great. Ty PY. I edited it alot removed the buffqsd..and cobbled together this modeled off of the buffone command. Don't know how to simplify it so not to redeclare everything. Ingame it would spawn the npc on a map that didn't have the command when I tried to shorten it. Since I am new to Programming I am sure you could do a much better job.

  1.  else if (strcmp(command, "buffme")==0)    // buff - debuff by Drakia -buff commented out for now
  2.   {
  3.     UINT strength;
  4.     UINT zone;
  5.     if ((tmp = strtok(NULL, " " )) == NULL) strength = 0, zone = 0; else strength = 3000;
  6.     {
  7.      Log( MSG_GMACTION, "buffed : character [ %s ] Strength [ %d ] Zone [ %d ]", thisclient->CharInfo->charname, strength, zone);
  8.     }
  9.     //how about a proximity check to a specified NPC
  10.     if (thisclient->Position->Map == 1)//this map Zant
  11.     {
  12.       POSITION NPCPosition;  //set NPC as Idiosel the teleporter in Zant
  13.       NPCPosition.current.x = 5270.93;
  14.       NPCPosition.current.y = 5228.95;
  15.       float dx = thisclient->Position->current.x - (float)(NPCPosition.current.x);
  16.       float dy = thisclient->Position->current.y - (float)(NPCPosition.current.y);
  17.       float distance = sqrt((dx*dx) + (dy*dy));
  18.     if (distance > 10 & thisclient->Position->Map == 1)
  19.         {
  20.         SendPM(thisclient, "You are too far from Buff Fairy!! Find the Buff Fairy to recieve buff!!!");//don't apply the buff
  21.         return true;
  22.         }
  23.     pakGMBuffme(thisclient, strength, 1 );//now send buffs distance check good.
  24.     if (distance < 10 & thisclient->Position->Map == 1)
  25.        {
  26.         SendPM(thisclient, "Buff Fairy Minnie has answered your call and strengthened you!!!");
  27.         return true;
  28.         }
  29.  
  30.     }
  31.     if (thisclient->Position->Map == 22)//this map Adv Plains.
  32.     {
  33.       POSITION NPCPosition;  //set NPC Position coordinates to where you want NPC.
  34.       NPCPosition.current.x = 5202.93;
  35.       NPCPosition.current.y = 5211.95;
  36.       float dx = thisclient->Position->current.x - (float)(NPCPosition.current.x);
  37.       float dy = thisclient->Position->current.y - (float)(NPCPosition.current.y);
  38.       float distance = sqrt((dx*dx) + (dy*dy));
  39.     if (distance > 10 & thisclient->Position->Map == 22)
  40.         {
  41.         SendPM(thisclient, "You are too far from Buff Fairy!! Find the Buff Fairy to recieve buff!!!");//don't apply the buff
  42.         return true;
  43.         }
  44.  
  45.     pakGMBuffme(thisclient, strength, 0 );//now send buffs.
  46.     if (distance < 10 & thisclient->Position->Map == 22)
  47.        {
  48.         SendPM(thisclient, "Buff Fairy Minnie has answered your call and strengthened you!!!");
  49.         return true;
  50.         }
  51.  
  52.     }
  53.     if (thisclient->Position->Map == 2)//this map Junon.
  54.     {
  55.       POSITION NPCPosition;  //set NPC Position coordinates to where you want NPC.
  56.       NPCPosition.current.x = 5184.93;
  57.       NPCPosition.current.y = 5226.95;
  58.       float dx = thisclient->Position->current.x - (float)(NPCPosition.current.x);
  59.       float dy = thisclient->Position->current.y - (float)(NPCPosition.current.y);
  60.       float distance = sqrt((dx*dx) + (dy*dy));
  61.     if (distance > 10 & thisclient->Position->Map == 2)
  62.         {
  63.         SendPM(thisclient, "You are too far from Buff Fairy!! Find the Buff Fairy to recieve buff!!!");//don't apply the buff
  64.         return true;
  65.         }
  66.  
  67.     pakGMBuffme(thisclient, strength, 2 );//now send buffs.
  68.     if (distance < 10 & thisclient->Position->Map == 2)
  69.        {
  70.         SendPM(thisclient, "Buff Fairy Minnie has answered your call and strengthened you!!!");
  71.         return true;
  72.         }
  73.  
  74.     }
  75.      else
  76.        {
  77.         SendPM(thisclient, "You must find the Buff Fairy if you want a Buff or ask another Player they are usually in a Town!");//find a buffme stone;
  78.        }
  79. }

  1. bool CWorldServer::pakGMBuffme( CPlayer* thisClient, int strength, int zone )
  2. {
  3.     pakGMDebuff(thisClient);
  4.        {
  5.            switch ( zone )
  6.            {
  7.             case 0:
  8.                pakGMGiveBuff( thisClient, thisClient, 994, 2000); // wallop   3906(300s) (18)
  9.                //pakGMGiveBuff( thisClient, thisClient, 1004, 1000); // resilience  3905(300s) (19)
  10.                pakGMGiveBuff( thisClient, thisClient, 1019, 2000); // Precision (420s) (20)
  11.                pakGMGiveBuff( thisClient, thisClient, 930, 2000); // Hustle  (420s) (21)
  12.                pakGMGiveBuff( thisClient, thisClient, 1254, 2000); // Battle    (420s) (22)
  13.                //pakGMGiveBuff( thisClient, thisClient, 1270, 1000); // Clobber     (300s) (23)
  14.                //pakGMGiveBuff( thisClient, thisClient, 1275, 1000); // Evasive    (420s) (24)
  15.                pakGMGiveBuff( thisClient, thisClient, 1284, 2000); // Critical (420s) (26)
  16.                //pakGMGiveBuff( thisClient, thisClient, 1294, 1000);  // Valkyrie   (420s) (38)
  17.                pakGMGiveBuff( thisClient, thisClient, 1039, 2000); // Blessed-M   (420s) (38)
  18.                break;
  19.             case 1:
  20.                pakGMGiveBuff( thisClient, thisClient, 994, 3000); // wallop   3906(300s) (18)
  21.                pakGMGiveBuff( thisClient, thisClient, 1004, 3000); // resilience  3905(300s) (19)
  22.                pakGMGiveBuff( thisClient, thisClient, 1019, 3000); // Precision (420s) (20)
  23.                pakGMGiveBuff( thisClient, thisClient, 930, 3000); // Hustle  (420s) (21)
  24.                pakGMGiveBuff( thisClient, thisClient, 1254, 3000); // Battle    (420s) (22)
  25.                pakGMGiveBuff( thisClient, thisClient, 1270, 3000); // Clobber     (300s) (23)
  26.                pakGMGiveBuff( thisClient, thisClient, 1275, 3000); // Evasive    (420s) (24)
  27.                pakGMGiveBuff( thisClient, thisClient, 1284, 3000); // Critical (420s) (26)
  28.                pakGMGiveBuff( thisClient, thisClient, 1294, 3000);  // Valkyrie   (420s) (38)
  29.                pakGMGiveBuff( thisClient, thisClient, 1039, 3000); // Blessed-M   (420s) (38)
  30.                break;
  31.             case 2:
  32.                pakGMGiveBuff( thisClient, thisClient, 994, 5000); // wallop   3906(300s) (18)
  33.                pakGMGiveBuff( thisClient, thisClient, 1004, 5000); // resilience  3905(300s) (19)
  34.                pakGMGiveBuff( thisClient, thisClient, 1019, 5000); // Precision (420s) (20)
  35.                pakGMGiveBuff( thisClient, thisClient, 930, 5000); // Hustle  (420s) (21)
  36.                pakGMGiveBuff( thisClient, thisClient, 1254, 5000); // Battle    (420s) (22)
  37.                pakGMGiveBuff( thisClient, thisClient, 1270, 5000); // Clobber     (300s) (23)
  38.                pakGMGiveBuff( thisClient, thisClient, 1275, 5000); // Evasive    (420s) (24)
  39.                pakGMGiveBuff( thisClient, thisClient, 1284, 5000); // Critical (420s) (26)
  40.                pakGMGiveBuff( thisClient, thisClient, 1294, 5000);  // Valkyrie   (420s) (38)
  41.                pakGMGiveBuff( thisClient, thisClient, 1039, 5000); // Blessed-M   (420s) (38)
  42.                break;
  43.         }
  44.     return true;}
  45. }


PY was wondering if you could help clean this up?
oh here it is in action
https://youtu.be/h_v-J1ii6tc
AnimalCrackerz
Pomic
Pomic
 
Posts: 102
Joined: Tue Apr 20, 2010 1:58 pm

Re: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Tue Sep 12, 2017 9:37 pm

one thing you could do to simplify it is to use the GM skills rather than the massive list of 10 that you have now.
They are all condensed into 4, each of which gives you 2 different buffs. Skills 3202 through 3205
  1. 3202    ATK & Accuracy Up
  2. 3203    DEF & M-DEF Up
  3. 3204    A-SPD & CRI Up
  4. 3205    M-SPD & Dodge Up
  5.  

You would still need to add the valkyrie skill though so that makes 5

You could also edit your STB a little to make a few custom skills. I've been messing around with that today in fact. I've started investigating the best way to add a virtual player server, starting with BuffBots and later maybe replacing ALL the NPCs with a much more interactive AI driven system.

I will take a look at your code and let you know if i can find any good ways to streamline it. :D

How about loading in a list of positions from a database table? that way you don't need to hard code all the NPC locations.
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

PreviousNext

Return to Support - OsRose Emulator

Who is online

Users browsing this forum: No registered users and 13 guests