- // this function runs from the /buffme command via gmcmds.cpp
- void CCharacter::GiveBuffsFromBot( CCharacter* Target, UINT skillid, UINT skillpower )
- {
- Log(MSG_DEBUG,"buffme called. giving skill id %i",skillid);
- CSkills* thisskill = GServer->GetSkillByID( skillid );
- GServer->AddBuffs( thisskill, Target, skillpower ); //apply the buffs
- BEGINPACKET( pak, 0x7b5 );
- ADDWORD ( pak, Target->clientid );
- ADDWORD ( pak, Target->clientid );
- ADDWORD ( pak, thisskill->id );
- ADDWORD ( pak, 1 );
- ADDBYTE ( pak, thisskill->nbuffs );
- GServer->SendToVisible( &pak, Target );
- //need a CPlayer object to set the stats so we go and find it
- CPlayer* thisclient = GServer->GetClientByID(Target->clientid,Target->Position->Map);
- thisclient->SetStats(); //this actually sends the updated stats to the client
- }
here is the function
See how simplified that is now?
We also need the prototype which we put in character.h. here it is in situ.
- void UseBuffSkillQSD( CCharacter* Target, CSkills* skill, bool deBuff = false );
- void GiveBuffsFromBot( CCharacter* Target, UINT skillid, UINT skillpower ); //new buffme code added by PY
- void UseAtkSkill( CCharacter* Enemy, CSkills* skill, bool deBuff= false );
Then i went back to startup.cpp and added a couple of lines of code to the normal NPC load function bool CWorldServer::LoadNPCs( ) just to make sure that all the other (normal) NPCs have their buffbot and buffpower values set to zero. I kept getting false positives for my bot check.
These two lines will do it.
- thisnpc->buffbot = false;
- thisnpc->buffpower = 0;
just stick them at the bottom of the actual loading code so that it looks something like this
- thisnpc->pos.x = WarpGate.IfoPosition.x;
- thisnpc->pos.y = WarpGate.IfoPosition.y;
- thisnpc->dialog=0;
- thisnpc->event=0;
- thisnpc->thisnpc = GetNPCDataByID( thisnpc->npctype );
- thisnpc->thisnpc->eventid=0;
- thisnpc->buffbot = false;
- thisnpc->buffpower = 0;
- //LMA: check if out of memory.
- if (thisnpc->posMap>=MapList.max)
- {
- Log(MSG_WARNING,"NPC, index overflow trapped %i>%i (should not happen) WarpGate",thisnpc->posMap,MapList.max);
- delete thisnpc;
- }
And very last (I think), set that stupid database default value for buffpower back to zero and change all the non-buffbot NPCs in that table back to zero also.
As you will notice in my gm commands code I used the 4 GM buff skills for this test run.
- { //Got buff bot so do de buffs
- Target->GiveBuffsFromBot( Target, 3202, buffpower );
- Target->GiveBuffsFromBot( Target, 3203, buffpower );
- Target->GiveBuffsFromBot( Target, 3204, buffpower );
- Target->GiveBuffsFromBot( Target, 3205, buffpower );
- SendPM(Target,"Congratulations! You received buffs from the buff fairy with buffpower %i", buffpower);
- }
Feel free to use whatever skills you like in place of these. Even make some of your own if you like.
And absolutely finally.........
Here it is all working brilliantly
the only thing I didn't do here was to put my buff fairy onto the mini-map
If you want to do that you will just have to edit the IFO files for the maps in which you add your buff bots.
If you want to get really smart with it you could also add some simple CON files so that you can at least select a buff bot and talk to it enough to maybe get instructions. But right now I'm not planning on going there because i have much grander plans than using crappy old CON and LTB stuff.
Have fun and give me feedback, modification ideas and stuff. Or just let me know if it simply didn't work for you and I will attempt to figure out why. Bye for now