[Dev V Rev 12] GM command AllSkills

If you want to help us or give some corrections / codes, put it here ;)

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

[Dev V Rev 12] GM command AllSkills

Postby WiseGuy on Mon May 26, 2014 7:54 pm

file: datatypes.h
find:
  1. struct CSkills {
  2.     UINT id;
  3.  

Add after:


File: startup.cpp
Find:
  1.        newskill->id=i;
  2.  

Add after:
  1.         newskill->skillid = STB_SKILL.rows[i][1];  // Skills id
  2.  


File: playerdata.cpp
find and replace similar function with these:
  1. //LMA: Find a skill offset for cskills...
  2. int CPlayer::FindSkillOffset(int family)
  3. {
  4.     if (family>4)
  5.     {
  6.         Log(MSG_WARNING,"Bad family in FindSkillOffset (%i)",family);
  7.         return -1;
  8.     }
  9.  
  10.     int begin[5];
  11.     int end[5];
  12.  
  13.     begin[0]=0;
  14.     begin[1]=168;
  15.     begin[2]=504;
  16.     begin[3]=252;
  17.     begin[4]=420;
  18.     end[0]=168;
  19.     end[1]=252;
  20.     end[2]=546;
  21.     end[3]=420;
  22.     end[4]=504;
  23.  
  24.     int res=cur_max_skills[family];
  25.  
  26.     if (res<end[family])
  27.     {
  28.         cur_max_skills[family]++;
  29.         return res;
  30.     }
  31.  
  32.  
  33.     return -1;
  34. }
  35.  


  1. //LMA: Find a skill in cskills...
  2. bool CPlayer::FindSkill(int family,UINT skill)
  3. {
  4.     if (family>4)
  5.     {
  6.         Log(MSG_WARNING,"Bad family in FindSkill (%i) for skill %i",family, skill);
  7.         return true;
  8.     }
  9.  
  10.     int begin[5];
  11.     int end[5];
  12.  
  13.     begin[0]=0;
  14.     begin[1]=168;
  15.     begin[2]=504;
  16.     begin[3]=252;
  17.     begin[4]=420;
  18.     end[0]=168;
  19.     end[1]=252;
  20.     end[2]=546;
  21.     end[3]=420;
  22.     end[4]=504;
  23.  
  24.     for (int k=begin[family];k<end[family];k++)
  25.     {
  26.         if (cskills[k].thisskill==NULL)
  27.         {
  28.             continue;
  29.         }
  30.  
  31.         if(cskills[k].id==skill)
  32.         {
  33.             return true;
  34.         }
  35.  
  36.     }
  37.  
  38.  
  39.     return false;
  40. }
  41.  


  1. //LMA: reset skill offsets.
  2. void CPlayer::ResetSkillOffset()
  3. {
  4.     int begin[5];
  5.  
  6.  
  7.     begin[0]=0;
  8.     begin[1]=168;
  9.     begin[2]=504;
  10.     begin[3]=252;
  11.     begin[4]=420;
  12.  
  13.     for (int k=0;k<4;k++)
  14.     {
  15.         //We don't reset the basic skills.
  16.         if(k==2)
  17.             continue;
  18.         cur_max_skills[k]=begin[k];
  19.     }
  20.  
  21.  
  22.     return;
  23. }
  24.  


File: gmcmds.cpp
find & replace this function:
  1. /GM: All Skills {By CrAshInSiDe} - Skills and levels updated by rl2171 & Devilking
  2. //LMA: Mysql now.
  3. //PY: Rewritten to use SkillList so we don't need the SQL table. UNTESTED
  4. bool CWorldServer::pakGMAllSkill(CPlayer* thisclient, char* name)
  5. {
  6.     bool is_ok=false;
  7.     int nb_skills=0;
  8.     CPlayer* otherclient = GetClientByCharName( name );
  9.     if(otherclient==NULL)
  10.         return true;
  11.  
  12.     int classid = otherclient->CharInfo->Job;
  13.  
  14.     //PY Let's do it from the existing SkillList that we already loaded from STB
  15.     //Borrowed some of this code from lmame. see original code.
  16.     for (int k = 0;k < MAX_ALL_SKILL;k++)
  17.     {
  18.         //if(otherclient->GoodSkill(otherclient->cskills[k].id)==2) continue;
  19.         otherclient->cskills[k].id = 0;
  20.         otherclient->cskills[k].level = 0;
  21.         otherclient->cskills[k].thisskill=NULL;
  22.     }
  23.     int cur_cskills[5];
  24.     int end[5];
  25.     cur_cskills[0]=0;
  26.     cur_cskills[1]=168;
  27.     cur_cskills[2]=504;
  28.     cur_cskills[3]=252;
  29.     cur_cskills[4]=420;
  30.     end[0]=168;
  31.     end[1]=252;
  32.     end[2]=546;
  33.     end[3]=420;
  34.     end[4]=504;
  35.     for (int i=0;i<5;i++)
  36.     {
  37.         //if(i==2) continue;
  38.         otherclient->cur_max_skills[i]=cur_cskills[i];
  39.     }
  40.     int jobid;
  41.     bool skill_ok;
  42.     UINT oldSkill=0;
  43.     int oldOffset=-1;
  44.     for(int i = 0;i < SkillList.size();i++)
  45.     {
  46.         if(SkillList.at(i)->skillid==0) continue;
  47.         if (oldSkill==SkillList.at(i)->skillid){
  48.             otherclient->cskills[oldOffset].level = SkillList.at(i)->level;
  49.             skill_ok = false;
  50.         }else{
  51.             jobid = SkillList.at(i)->c_class[0];
  52.             skill_ok = false;    //start out false as default
  53.             if (jobid == 0) {skill_ok = true;}  //always true if no job is specified
  54.             else
  55.             {
  56.                 if (jobid == 41 && (classid == 111 || classid == 121 || classid == 122)) skill_ok = true;
  57.                 if (classid == 121 && jobid == 61) skill_ok = true;
  58.                 if (classid == 122 && jobid == 62) skill_ok = true;
  59.                 if (jobid == 42 && (classid == 211 || classid == 221 || classid == 222)) skill_ok = true;
  60.                 if (classid == 221 && jobid == 63) skill_ok = true;
  61.                 if (classid == 222 && jobid == 64) skill_ok = true;
  62.                 if (jobid = 43 && (classid == 311 || classid == 321 || classid == 322)) skill_ok = true;
  63.                 if (classid == 321 && jobid == 65) skill_ok = true;
  64.                 if (classid == 322 && jobid == 66) skill_ok = true;
  65.                 if (jobid = 44 && (classid == 411 || classid == 421 || classid == 422)) skill_ok = true;
  66.                 if (classid == 421 && jobid == 67) skill_ok = true;
  67.                 if (classid == 422 && jobid == 68) skill_ok = true;
  68.             }
  69.         }
  70.  
  71.         if (skill_ok == false) continue;  //don't give them the skill
  72.         int family=otherclient->GoodSkill(SkillList.at(i)->skillid);
  73.         if (family == -1) continue;
  74.         int offset = otherclient->FindSkillOffset(family);
  75.         if (offset == -1) continue;
  76.         if (otherclient->FindSkill(family,SkillList.at(i)->skillid)==true) continue;
  77.         otherclient->cskills[offset].id = SkillList.at(i)->skillid;
  78.         otherclient->cskills[offset].level = SkillList.at(i)->level;
  79.         oldSkill=SkillList.at(i)->skillid;
  80.         oldOffset=offset;
  81.         nb_skills++;
  82.         if(nb_skills>=MAX_ALL_SKILL)
  83.         {
  84.             Log(MSG_WARNING,"Too many skills, aborting Row: %i SkillID: %i", SkillList.at(i)->id, SkillList.at(i)->skillid);
  85.             SendPM(thisclient,"Too many skills, aborting");
  86.             break;
  87.         }
  88.     }
  89.     // PY End
  90.     SendPM (otherclient, "Relogin to get all skills");
  91.     otherclient->AttrAllSkills();
  92.     otherclient->saveskills();
  93.     otherclient->ResetSkillOffset();
  94.  
  95.     return true;
  96. }
  97.  
Last edited by WiseGuy on Tue May 27, 2014 1:53 pm, edited 4 times in total.
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] GM command AllSkills

Postby WiseGuy on Tue May 27, 2014 12:30 pm

updates in order to reach max skill level
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] GM command AllSkills

Postby rl2171 on Tue May 27, 2014 1:18 pm

I copied the info and replaced it all, but got this error below, what did I miss??

  1. ||=== Build: release in World Server (compiler: GNU GCC Compiler) ===|
  2. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp||In member function 'bool CWorldServer::pakGMAllSkill(CPlayer*, char*)':|
  3. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6441|error: 'struct CSkills' has no member named 'skillid'|
  4. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6442|error: 'struct CSkills' has no member named 'skillid'|
  5. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6462|error: 'struct CSkills' has no member named 'skillid'|
  6. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6466|error: 'struct CSkills' has no member named 'skillid'|
  7. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6467|error: 'struct CSkills' has no member named 'skillid'|
  8. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6469|error: 'struct CSkills' has no member named 'skillid'|
  9. C:\Users\Rob\Documents\0-Rose\osRose\Dev5\osRose\World Server\gmcmds.cpp|6473|error: 'struct CSkills' has no member named 'skillid'|
  10. ||=== Build failed: 7 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
  11.  
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] GM command AllSkills

Postby WiseGuy on Tue May 27, 2014 1:26 pm

wuaaaa
forgot to mention:

1. add to struct cskills
UINT skillid;
2. add to LoadSkillData
newskill->skillid = STB_SKILL.rows[i][1]; // Skills id
3. edit all part range of Skill offset on playerdata:
ResetSkillOffset
FindSkill
FindSkillOffset
Attachments
screen002.jpg
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] GM command AllSkills

Postby rl2171 on Tue May 27, 2014 1:34 pm

WiseGuy wrote:wuaaaa
forgot to mention:

1. add to struct cskills
UINT skillid;
2. add to LoadSkillData
newskill->skillid = STB_SKILL.rows[i][1]; // Skills id
3. edit all part range of Skill offset on playerdata:
ResetSkillOffset
FindSkill
FindSkillOffset



Looks great, but where do I add and edit these? I am not a programmer :) Thanks
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] GM command AllSkills

Postby WiseGuy on Tue May 27, 2014 1:44 pm

rl2171 wrote:Looks great, but where do I add and edit these? I am not a programmer :) Thanks


first post update with the full instruction
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] GM command AllSkills

Postby rl2171 on Tue May 27, 2014 2:03 pm

Works great, thank you so much!
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] GM command AllSkills

Postby WiseGuy on Tue May 27, 2014 2:16 pm

you're welcome
please report for the other class, if you don't mind
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] GM command AllSkills

Postby rl2171 on Tue May 27, 2014 2:20 pm

Too bad you can't upload all your updates to the SVN too.

Will report any issues with the classes as well
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] GM command AllSkills

Postby WiseGuy on Tue May 27, 2014 2:52 pm

No problem :)

Thank's
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta


Return to Submit Code

Who is online

Users browsing this forum: No registered users and 3 guests