Jump to content

[Help] Custom command .modify mirror or clone or whatever u like ;)


Guest yimgame

Recommended Posts

Hey every body

Well i am not a specialist of C but i have a little princes of 5 years and she ask me if is possible to have a button to morph the player like the creature she have selected... and i think why not.

I was looking around the code and found usefull material in level2.cpp

//mirror (orignally is ModifyMorph + NpcSetModel
bool ChatHandler::HandleModifyMirrorCommand(const char* args)
{
   if (!*args)
       return false;

   CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo(); //NpcSetModel originally recive a unit32 variable and modifymorph use a unit16 variable can this guive some problem ? Help!!!

   uint16 display_id = cInfo; // this is correct ? i can use the variable as is ? or need locate inside the variable the portion dedicated to displayid ? Help!!!

   Unit *target = getSelectedUnit();
   if (!target)
       target = m_session->GetPlayer();

   // check online security
   else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0))
       return false;

   target->SetDisplayId(display_id);

   return true;
}

I added the proper lines to chat.cpp and chat.h

Now is possible this work ?

I look in forum's about 15 pages returned by the search of modify morph and do not see anything like this.

Any help will be apreciate.

Link to comment
Share on other sites

CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo(); //NpcSetModel originally recive a unit32 variable and modifymorph use a unit16 variable can this guive some problem ? Help!!!

uint16 display_id = cInfo; // this is correct ? i can use the variable as is ? or need locate inside the variable the portion dedicated to displayid ? Help!!!

This will give you the pointer to cinfo.

From Creature.h:

struct CreatureInfo
{
...
   uint32  DisplayID_A[2];
   uint32  DisplayID_H[2];
...
};

You should try:

//mirror
bool ChatHandler::HandleModifyMirrorCommand(const char* args)
{
   Creature *pCreature = getSelectedCreature();

   if (!pCreature)
   {
       SendSysMessage("Please select a creature.");
       SetSentErrorMessage(true);
       return false;
   }
   CreatureInfo const* cInfo = pCreature->GetCreatureInfo();

   m_session->GetPlayer()->SetDisplayId(cInfo->DisplayID_A[0]);
   //To my knowledge in most scenarios DisplayID_A[0..1] and DisplayID_H[0..1] should be the same.

   return true;
}

Edit: this works perfectly on my server. Hope I could help!

Link to comment
Share on other sites

Slurm you rock man this is wonderfull, many thanks really i dont see the problems. 1º i dont think in Null cose i dont ask for the existance of creature target and 2º i change the displayID to the same target i collected the info.

Thanks for the reply i will try to re compile a new core (i am recently new in nix is totally diferent compile in nix than win.)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use