Jump to content

Custom Graveyards


Guest elmaster

Recommended Posts

mangos v0.13-dev2+ScriptDev2 v928.

No test in another version.

/***********************By ElMaStEr*************************************
*    
*    Modify file    : dbcfile.cpp
*     Function    : DBCFile::Load
*    add a line with  #include cgraveyard.h in the start of file 
*    create a file cgraveyard.h in src\\shared\\Database
*    example of CGraveyard.h
*    VERY IMPORTANT ALWAYS MAKE A COPY OF YOUR SOURCES =P
************************************************************************
*    struct GVlocal
*    {
*            uint32        ID;
*            uint32        map_id;
*           float         x;
*            float         y;
*            float        z;
*        uint32    code[16];
*        uint32    lang;
*    };
*    int CGraves=2;     //Number of Custom Graveyard
*    GVlocal* localgrave=new GVlocal[CGraves];
*
*    void LoadGraves() // Charge all custom graveyards
*    {
*        localgrave[0].ID=1500; //ID of graveyard
*        localgrave[0].map_id =0; //map
*        localgrave[0].x=-4162.279785f; 
*        localgrave[0].y=-1000.280029f;
*        localgrave[0].z=167.403000f;
*
*        localgrave[1].ID=1501;
*        localgrave[1].map_id =1;
*        localgrave[1].x=-10603.679688f;
*        localgrave[1].y=2525.08402f;
*        localgrave[1].z=6.445616f;
*    }
************************************************************************
*    replace your function DBCFile::Load with this
************************************************************************/

bool DBCFile::Load(const char *filename, const char *fmt)
{

   uint32 header;
   if(data)
   {
       delete [] data;
       data=NULL;
   }

   FILE * f=fopen(filename,"rb");
   if(!f)return false;

   if(fread(&header,4,1,f)!=1)                             // Number of records
       return false;

   EndianConvert(header);
   if(header!=0x43424457)
       return false;                                       //'WDBC'

   if(fread(&recordCount,4,1,f)!=1)                        // Number of records
       return false;

   EndianConvert(recordCount);

   if(fread(&fieldCount,4,1,f)!=1)                         // Number of fields
       return false;

   EndianConvert(fieldCount);

   if(fread(&recordSize,4,1,f)!=1)                         // Size of a record
       return false;

   EndianConvert(recordSize);

   if(fread(&stringSize,4,1,f)!=1)                         // String size
       return false;

   EndianConvert(stringSize);

/*----------------------------------------------- Start Custom GraveYards ---------------------------------------------- */
char fn1[MAX_PATH];  
char *filenn;
char *res;
strcpy(&fn1[0],filename);
char sep[]   = "/";
  filenn = strtok((char *)fn1, sep);
  while( filenn != NULL )
  {
       res=filenn;
       filenn= strtok(NULL, sep );
  }
// Test if have custom graveyard and more
if(!stricmp(res,"WorldSafeLocs.dbc") && CGraves!=0)
   {
       // ----------- Set Graves
       fieldsOffset = new uint32[fieldCount];
       fieldsOffset[0] = 0;
       for(uint32 i = 1; i < fieldCount; i++)
       {
           fieldsOffset[i] = fieldsOffset[i - 1];
           if (fmt[i - 1] == 'b' || fmt[i - 1] == 'X')         // byte fields
               fieldsOffset[i] += 1;
           else                                                // 4 byte fields (int32/float/strings)
               fieldsOffset[i] += 4;
       }
   LoadGraves(); // charge grave datas
   data = new unsigned char[recordSize*(recordCount+CGraves) + stringSize];
       if(fread(data,(recordSize*recordCount),1,f)!=1)
           return false;

       for(int i = 0; i < CGraves; i++)
           {
               localgrave[i].code[0]=1;//here your code lang, this is enEN?
               localgrave[i].lang =0x00ff01fe;//here your code lang, this is enEN?
               memcpy(data+(recordSize*recordCount)+(recordSize*i),&localgrave[i],recordSize);
           }
       if(fread(data+(recordSize*(recordCount+CGraves)),stringSize,1,f)!=1)
               return false;

       recordCount=recordCount+CGraves;
       stringTable = data + (recordSize*recordCount);
   }
   else
   {
       fieldsOffset = new uint32[fieldCount];
       fieldsOffset[0] = 0;
       for(uint32 i = 1; i < fieldCount; i++)
       {
           fieldsOffset[i] = fieldsOffset[i - 1];
           if (fmt[i - 1] == 'b' || fmt[i - 1] == 'X')         // byte fields
               fieldsOffset[i] += 1;
           else                                                // 4 byte fields (int32/float/strings)
               fieldsOffset[i] += 4;
       }
       data = new unsigned char[recordSize*recordCount+stringSize];
       stringTable = data + recordSize*recordCount;

       if(fread(data,recordSize*(recordCount)+stringSize,1,f)!=1)
           return false;
   }
/*----------------------------------------------- end  Custom GraveYards ---------------------------------------------- */

   fclose(f);
   return true;
}

add your new graveyard to the database, compile and run ^_^

example of query of your graveyards

insert into `game_graveyard_zone` (`id`, `ghost_zone`, `faction`) values('1500','11','0');
insert into `game_graveyard_zone` (`id`, `ghost_zone`, `faction`) values('1501','1377','0');

Link to comment
Share on other sites

  • 3 months later...

This is rather interesting for me aswell.

I see that the thread is getting some wrinkles but I'll dig it up again though as far as I can see it, hard coding it into the dbc is currently the only opt. Loading from the DB would require some clever tweaks.

Anyone got more input?

I found a work-around from the Scriptdev forums. Simply delete the wanted zone or graveyard link in grave_yard_zone. People releasing in the zone will release and stand upon their corpse, adding a spirit healer is a easy matter.

Not the most convenient solution, but better than hardcoding in the core.

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