New Skills

For questions relating to POL scripting (not necessarily related to WoD)

Moderators: Siobhan, Sebastian, Drocket

New Skills

Postby Atlina on Sun Jan 25, 2004 8:29 am

I am trying to add several new skills, such as Sorcery, but I do not know how to make them show up on the skill book. What will I need to change in the scripts to make the skill show up. It is already added in skillmaster.cfg under skill # 49. Here is the script for the book:

Code: Select all
use uo;
use os;
use cfgfile;

include "include/client";
include "include/string";
include "include/skills";

var specs := array {};
var gump_data := array {""};
var gump_layout := array {
   "nodispose",
   "page 0",
   "gumppic 0 50 500"
};

var skillmastercfg := ReadConfigFile(":skills:skillmaster");
var skills := {};
const LASTPAGE := 3;

program SkillWindow (me, text)
   if (GetObjProperty (me, "#logon_noskillwin"))
      EraseObjProperty (me, "#logon_noskillwin");
      return;
   endif

   LoadSpecs (me);
   LoadSkillArrayByValue (me);
   
   foreach skill in skills
      gump_data.append (GetSkillValDisplay (me, skill));
      gump_data.append (getskillname (skill));
   endforeach

   //finish loading gump_layout
   for pagenum := 1 to LASTPAGE
      LoadPageArray (pagenum);
      for i := 1 to 7
         var button := ( (pagenum - 1) * 14 ) + i;
         LoadLeftPageArray (button, i, skills[button]);
      endfor
      for i := 8 to 14
         var button := ( (pagenum - 1) * 14 ) + i;
         LoadRightPageArray (button, i-7, skills[button]);
      endfor
   endfor

   var sreturn := SendDialogGump( me, gump_layout, gump_data );
   if (sreturn[0])
      LaunchSkillScript(me, skills[sreturn[0]]);
   endif
endprogram


function LoadPageArray ( pagenum )

   if ( pagenum == 1 )
      gump_layout.append ("page 1");
      gump_layout.append ("button 356 50 502 502 0 2");//next page
   elseif ( pagenum == LASTPAGE )
      gump_layout.append ("page " + cstr(LASTPAGE));
      gump_layout.append ("button 0 50 501 501 0 "+ cstr(LASTPAGE-1));//previous page
   else
      gump_layout.append ("page " + cstr(pagenum));
      gump_layout.append ("button 0 50 501 501 0 " + cstr(pagenum - 1));//next
      gump_layout.append ("button 356 50 502 502 0 "+ cstr(pagenum + 1));//previous
   endif

endfunction

function LoadLeftPageArray (button, i, skillid)

   var skillvaltext := cstr((button*2)-1);
   var skillnametext := cstr(button*2);
   if ( GetSkillName(skillid) == "None" )
      skillvaltext := " 0";
      skillnametext := " 0";
   endif

   gump_layout.append ("text 50 " + cstr(70 + (22*i)) + " 2400 " + skillvaltext);
   gump_layout.append ("text 100 " + cstr(70 + (22*i)) + " 0 " + skillnametext);
   if (IsAction(skillid))
      gump_layout.append ("button 35 " + cstr(75 + (22*i)) + " 2104 2103 1 0 " + cstr( button ));
   endif

endfunction

function LoadRightPageArray(button, i, skillid)

   var skillvaltext := cstr((button*2)-1);
   var skillnametext := cstr(button*2);
   if ( GetSkillName(skillid) == "None" )
      skillvaltext := " 0";
      skillnametext := " 0";
   endif

   gump_layout.append ("text 240 " + cstr(70 + (22*i)) + " 2400 " + skillvaltext);
   gump_layout.append ("text 290 " + cstr(70 + (22*i)) + " 0 " + skillnametext);
   if (IsAction(skillid))
      gump_layout.append ("button 225 " + cstr(75 + (22*i)) + " 2104 2103 1 0 " + cstr( button ));
   endif

endfunction

function IsAction(skillid)

   var skillmastercfg := ReadConfigFile(":skills:skillmaster");
   var skillelem := FindConfigElem(skillmastercfg, skillid);
   if (len(skillelem.script))
      return 1;
   else
      return 0;
   endif

endfunction

function SortValue (byref me, skillid)

   var adjustval := 1;//make sure real skills sort ahead of disabled ones
   if ( GetSkillName(skillid) = "None" )
      return 0;//sort disabled skills to the end
   else
      //sort the specs in order:
      if (skillid == specs[1])
         adjustval := 10000;
      elseif (skillid == specs[2])
         adjustval := 9000;
      elseif (skillid == specs[2])
         adjustval := 8000;
      elseif (skillid == specs[3])
         adjustval := 7000;
      elseif (skillid == specs[4])
         adjustval := 6000;
      elseif (skillid == specs[5])
         adjustval := 5000;
      elseif (skillid == specs[6])
         adjustval := 4000;
      elseif (skillid == specs[7])
         adjustval := 3000;
      endif
   endif

   var attribute := GetAttributeIDBySkillID (skillid);
   var value := GetAttributeBaseValue (me, attribute) + GetAttributeTemporaryMod (me, attribute);
   return value;
endfunction

function LoadSkillArrayByValue (me)
   var skillvals := {};
   for i := 0 to 48
      skillvals[i+1] := GetSortValue (me, i);
   endfor
   skillvals[50] := -1;      //dummy for comparisons


   var chosenskill := 50;
   for i := 1 to 49
      chosenskill := 50;
      for j := 1 to 49
         if (skillvals[j] > skillvals[chosenskill])
            chosenskill := j;
         endif
      endfor
      if (skillvals[chosenskill] >= 0)
         skillvals[chosenskill] := -1;
         skills[i] := chosenskill - 1;
      endif
   endfor
endfunction

function GetSortValue (byref me, skillid)
   if ( GetSkillName(skillid) == "None" )
      return -1;//sort disabled skills to the end
   else
      //sort the specs in order:
      if (skillid == specs[1])
         return 10000;
      elseif (skillid == specs[2])
         return 9000;
      elseif (skillid == specs[2])
         return 8000;
      elseif (skillid == specs[3])
         return 7000;
      elseif (skillid == specs[4])
         return 6000;
      elseif (skillid == specs[5])
         return 5000;
      elseif (skillid == specs[6])
         return 4000;
      elseif (skillid == specs[7])
         return 3000;
      endif
   endif
   
   var attributeid := GetAttributeIDBySkillID (skillid);

   return (GetAttributeBaseValue (me, attributeid) + GetAttributeTemporaryMod (me, attributeid));
endfunction

function LoadSpecs (byref character)

   specs[1] := GetObjProperty (character, "primary1");
   specs[2] := GetObjProperty (character, "primary2");
   specs[3] := GetObjProperty (character, "primary3");
   specs[4] := GetObjProperty (character, "secondary1");
   specs[5] := GetObjProperty (character, "secondary2");
   specs[6] := GetObjProperty (character, "secondary3");
   specs[7] := GetObjProperty (character, "tradeskill");

endfunction
Atlina
Newbie
 
Posts: 5
Joined: Mon Dec 29, 2003 6:50 pm

Postby Drocket on Sun Jan 25, 2004 9:04 am

Just taking a look at it, I think there's only one area of that code that you would need to change, and that's in the LoadSkillArrayByValue function:

for i := 0 to 48
to
for i := 0 to 49

and then:

var chosenskill := 50;
for i := 1 to 49
chosenskill := 50;
for j := 1 to 49
to
var chosenskill := 51;
for i := 1 to 50
chosenskill := 51;
for j := 1 to 50

One other file that I know you'll also need to change is attributes.inc, in /scripts/include - basically just adding stuff. Near the top, you'll see a bunch of CONST statements - you'd want to add:
Const ATTRIBUTEID_SORCERY := "Sorcery";

In client.inc, then you'd need to add:
Const SKILLID_SORCERY := 49;

Then back to Attributes.inc, you'd need to add the new skill in some assorted function (GetAttributeIDBySkillID, GetSkillIDByAttributeID, and ListSkillAttributes.) I think they're pretty self-expanitory, though.
Drocket
Site Admin
 
Posts: 820
Joined: Mon Oct 07, 2002 2:54 am

Postby Atlina on Sun Jan 25, 2004 3:08 pm

Thank you... I changed all of this, but the skill is still not showing up.
Atlina
Newbie
 
Posts: 5
Joined: Mon Dec 29, 2003 6:50 pm


Return to Scripting Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron