[HELP] Buff Fairy's for OsRose

Welcome in the osRose emulator Project.

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

[HELP] Buff Fairy's for OsRose

Postby AnimalCrackerz on Thu Sep 07, 2017 5:46 am

Ok well I read most posts here, and realize that Buff Fairy's don't work in Osrose since the server source doesn't handle NPC's buffing properly on evo servers. So I am directing this question mostly to PY. I took a look at the KT rose source..and it is pre-evo but you managed to fix the source for the NPC's. I see where you had changed how it discriminates between CharTypes. But when I transcribed your fix I think I missed something I simply cannot get this fairy to cast a buff. Was wondering if you could lend a hand and help me get this fairy to buff. I am using dev revision II. I also edited the aip cond but didn't edit anything in the Aip action.cpp.
AnimalCrackerz
Pomic
Pomic
 
Posts: 102
Joined: Tue Apr 20, 2010 1:58 pm

Re: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Thu Sep 07, 2017 2:43 pm

It really all depends on how you want to do your buffs.

By far the easiest way is to use AIP. If you do it that way then you already have all the code you need to make buffs work on a player or monster.
The down side is that you can't activate it by talking to the NPC so it's highly indiscriminate.
When you talk to the NPC you go into the QSD system. There is no direct cross talk between QSD and AIP so it's not possible to directly buff a specific player from QSD.

The KTRose solution was a LOOOOONG time ago. I don't even remember how I addressed it at the time.

Ok found it in KT source. It's also present in my 137 server source so there's a good chance it will already be in dev rev 2 since a whole lot of the code that made that up was "borrowed" from KTRose pre-evo
It looks like the solution I opted for was to give a quest reward in QUESTREWD(005)
  1. //Give Reward
  2. QUESTREWD(005)
  3. {
  4.     GETREWDDATA(005);
  5.     //byte btTarget;            // pos 0x00
  6.     //union
  7.     //{
  8.     //  byte btEquation;      // pos 0x02 apparently should be 0x01
  9.     //  word nEquation;
  10.     //};
  11.     //byte btEquation;          // pos 0x01
  12.     //word nEquation;           // pos 0x02
  13.     //int iValue;               // pos 0x04
  14.     //dword iItemSN;            // pos 0x06
  15.     //union
  16.     //{
  17.     //  byte btPartyOpt;      // pos 0x0a
  18.     //  word nPartyOpt;
  19.     //};
  20.     //word nItemOpt;            // pos 0x0c
  21.     //word nSkill. Co-opting nItemOpt as a skill id
  22. word nSkill = data->nItemOpt;
  23.  


normally this quest reward only has two options for reward type.
I added a third and (as noted above) co-opted the nItemOpt reward item as a skill number then later used option 3 to actually start a combat between the NPC (re-cast as a monster) and the player.
  1. case 3://Recieve Buff. start battle so that AIP can actually do the buffing based on RefVar values
  2.         {
  3.             CCharacter* monster = GServer->GetMonsterByID(client->NPCvar,client->Position->Map);
  4.             monster->StartAction( client, SKILL_ATTACK, nSkill );
  5.         }
  6.         break;

So what this does is to use the QSD to initiate a combat scenario and then let AIP handle actually casting the buff
The trick is though, you have to add the necessary QSD and AIP stuff for the NPC.

Is that what you tried to do already?
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 Thu Sep 07, 2017 2:53 pm

In hindsight I'm not sure if that is actually the best approach any more :?
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 Thu Sep 07, 2017 3:56 pm

It now seems a little inefficient to be initiating a complete combat situation between the monster and the play when we can directly call the function that applies the buff.
Try re-writing option 3 as follows (the first part is just the old one commented out for reference and in case this turns out not to work correctly)
  1. //PY: This seems a little overcomplicated. we can just send the request directly to AddBuffs() or UseBuffSkill()
  2.         /*case 3://Recieve Buff. start battle so that AIP can actually do the buffing based on RefVar values
  3.         {
  4.             CCharacter* monster = GServer->GetMonsterByID(client->NPCvar,client->Position->Map);
  5.             monster->StartAction( client, SKILL_ATTACK, nSkill );
  6.            
  7.         }
  8.         break;
  9.         */
  10.         case 3:
  11.         {
  12.             //need a CCharacter object first
  13.             CSkills* thisskill = GServer->GetSkillByID( nSkill );
  14.             client->UseBuffSkill(client, thisskill);
  15.         }
  16.         break;

Doing it this way takes us directly to the UseBuffSkill() function in battle.cpp
This code modification compiles (untested for operation) in KTRose and 137 sources so it should work fine in dev rev 2
However..... There may be an issue or two in the UseBuffSkill() function as a result of there being no active "Battle" involved here.
  1. // use buff skill
  2. void CCharacter::UseBuffSkill( CCharacter* Target, CSkills* skill, bool deBuff )
  3. {
  4.     bool bflag = false;
  5.     bflag = GServer->AddBuffs( skill, Target, GetInt( ) );
  6.     //Log(MSG_INFO,"In UseBuffSkills, 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, clientid );
  12.         ADDWORD    ( pak, Battle->skillid );
  13.         ADDWORD    ( pak, GetInt( )/4 );
  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, clientid);
  21.     ADDWORD    ( pak, Battle->skillid);
  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,"UseBuffSkill: Target HP = %i",Target->Stats->HP);
  26. }

This is the entire function in KTRose. In mainstream osrose there will be a section after this where lmame inserted a patch for reviving dead players. I have no idea if that patch works or not and it's not really relevent here anyway
The issue that we "might" have here is that the packets all contain Battle->this and Battle->that. We have no Battle so they will all be NULL and may or may not have to be dealt with. GetINT() is a little irrelevant too.
It's probably best to just not take the chance and just deal with it anyway.
a few options present themselves.
1) modify this function by adding a boolean bool QSD to the function definition then wrap the existing packets in a conditional with a copy of the packets with zero values in all necessary places in an else condition
2) Copy the whole function and give it a new name so that it is only used when called from QSD
3) Find a way to make dummy values that will include a fake battle and so on.
4) Completely bypass this function and directly call GServer->AddBuffs( skill, Target, GetInt( ) ); directly from the QSD. This will mean that although you get the buffs there will be no packet sent to everyone around you showing you get them. I'm not actually sure what the packets 0x7b5 and 0x7b9 even do without tracing them through the source code. I can certainly do that but I don't really need to yet. I'm just going to assume that they show a player receiving buffs and tell the client(s) to display buff icons above your head and on your own screen. Something has to tell the client o show them right?

So out of these options I'm thinking I would go with 2.
1 is messy
3 is also messy and kind of complicated as well
4 might just fuck up everything :?

Soooooo
first let's add a definition into Character.h
  1. void UseBuffSkill( CCharacter* Target, CSkills* skill, bool deBuff = false );
  2.         void UseBuffSkillQSD( CCharacter* Target, CSkills* skill, bool deBuff = false );

UseBuffSkillQSD has a nice ring to it I think. :D
now we make a copy of the original function in battle.cpp
this should be sufficient. I've replaced alll the battle stuff and sent 1 instead of GetINT() which has no target
  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->skillid );
  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->skillid);
  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. }

Lastly go back into QUESTREWD(005) and set your target function to
  1. client->UseBuffSkillQSD(client, thisskill);
just so that it points to our new function instead of the old one.
That should be nice and tidy and will (hopefully) work just fine. All this code is completely untested but is basically pretty simple so it should work pretty well.

The hard bit is going to be editing your NPC so that he will actually give you the buff. That is going to involve QSD to actually define the skill reward, CON and LTB to actually make the quest options appear in the NPC dialog when you speak to him.
But that is a completely different subject for now....
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 Thu Sep 07, 2017 4:00 pm

Hold on a minute....
Got an error when compiling this stuff. Apparently "skillid" is not a member of CSkills even though it auto-filled it when I wrote the code.
Need to find a different way to extract the skill id from the CSkills structure.
I will post again as soon as I figure it out

Strangely it compiled fine in KTRose but not in osrose. I think there may be some differences in the structure definitions that I hadn't anticipated
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 Thu Sep 07, 2017 4:06 pm

ok here it is.
Just use skill->id instead of skill->skillid
  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. }
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 Thu Sep 07, 2017 10:14 pm

Man your the Tops...I will try to get to these later this evening. Thanks for the response and effort..kind of tied up with the weather this weekend if at all able will get to it this weekend if I can. Thanks PY.
AnimalCrackerz
Pomic
Pomic
 
Posts: 102
Joined: Tue Apr 20, 2010 1:58 pm

Re: [HELP] Buff Fairy's for OsRose

Postby Exordium on Fri Sep 08, 2017 8:17 am

to be honest. it doesnt need to be coded. i have implemented my buff fairy on osrose client side edit..
Exordium
Smoulie
Smoulie
 
Posts: 67
Joined: Tue Sep 25, 2012 11:10 am

Re: [HELP] Buff Fairy's for OsRose

Postby PurpleYouko on Fri Sep 08, 2017 2:52 pm

Exordium wrote:to be honest. it doesnt need to be coded. i have implemented my buff fairy on osrose client side edit..

yes there are ways to do it without coding. particularly if you just use AIP.
It all depends on how you want to implement them.

It's extremely easy to make a buff fairy that just continuously casts AOE buffs or even detects when a player is within range and casts it.
I even wrote a tutorial for it waaaaay back

Using QSD, CON is a little trickier but allows the player to interact with the fairy and select a buff (just for herself) from a list in the dialog window. That's the kind I was aiming for here.
This is the method that gave me headaches in KTRose when I first tried it and found that the basic QSD code gave me no way to actually cast skills on target players.

Another approach (Akram) is to actually set up your buffers as virtual players. This method requires a small number of fake players to be logged into the server. They respond to players near them when they request buffs via a simple AI script. Walk up to one (within distance 5 or so) and type "buff mvspd" to get a move speed buff.
I'm not entirely sure how Akram did it but if i were doing it myself i would use a program that emulates a rose client and just logs in with multiple buff bots then monitors incoming packets and responds to them.
This method could be used on any server type as the buffers are completely independent of the server or client code. They would just have to be able to log in.

What method did you use Exordium? Care to share what you did?
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 Fri Sep 08, 2017 10:08 pm

Yes I had approached you a long time ago and you helped show me where you had put your changes in the code...but as with then and now .. it shows in the server the fairy casting but ingame there is no action happening .. no buff made. I used the NPC 1025 in KT rose the one that casts only one buff for testing purposes..when I manage to get the buff ingame I plan to edit the AIP..I followed all the Tutorials here on how to add a buff fairy..I have it all working except the cast buff doesn't affect any of the player. I am hoping this fix you placed here in this topic will solve the issue..hope to get to it this evening when I get some free moments.
Attachments
Screenshot_1.png
AnimalCrackerz
Pomic
Pomic
 
Posts: 102
Joined: Tue Apr 20, 2010 1:58 pm

Next

Return to Support - OsRose Emulator

Who is online

Users browsing this forum: Google [Bot] and 21 guests

cron