Sorry, just a combination of laziness and busyness
Let me see, the last thing I posted about the level system stuff was an AwardExperience function that makes points available to spend. Quick copy-n-paste here so we're all on the same page:
- Code: Select all
function AwardExperience (character, newxp)
newxp := CINT (newxp);
if (!character or !newxp)
return;
endif
set_critical (1);
var oldxp := GetObjProperty (character, "experience");
if (!oldxp)
oldxp := 0;
endif
var totalxp := oldxp + newxp;
var xpneeded := GetExperienceForNextLevel (character);
if (totalxp >= xpneeded)
//We're going to level up
var currentlevel := GetObjProperty (character, "experiencelevel");
currentlevel := currentlevel + 1;
SetObjProperty (character, "experiencelevel), currentlevel);
totalxp := totalxp - xpneeded;
SendSysMessage (character, "Welcome to level " + currentlevel + "!");
var pointsavailable := GetObjProperty (character, "pointsavailable");
if (!pointsavailable)
pointsavailable := 0;
endif
pointsavailable := pointsavailable + 10;
SetObjProperty (character, "pointsavailable", pointsavailable);
endif
SetObjProperty (character, "experience", totalxp);
set_critical (0);
endfunction
(nothing new yet, that's just the old code)
Just to make it a bit easier to work on, I'm going to split out the level up stuff from the award experience function and just make that its own level:
- Code: Select all
function AwardExperience (character, newxp)
newxp := CINT (newxp);
if (!character or !newxp)
return;
endif
set_critical (1);
var oldxp := GetObjProperty (character, "experience");
if (!oldxp)
oldxp := 0;
endif
var totalxp := oldxp + newxp;
var xpneeded := GetExperienceForNextLevel (character);
if (totalxp >= xpneeded)
//We're going to level up
var currentlevel := GetObjProperty (character, "experiencelevel");
currentlevel := currentlevel + 1;
SetObjProperty (character, "experiencelevel), currentlevel);
totalxp := totalxp - xpneeded;
SendSysMessage (character, "Welcome to level " + currentlevel + "!");
//Replaced this section here with the new code
AwardPointsForLevelUp (character);
endif
endif
SetObjProperty (character, "experience", totalxp);
set_critical (0);
endfunction
Ok, so now we make a new AwardPointsForLevelUp (character) function, which will add one point to your skills and stats. That would look something like this:
- Code: Select all
function AwardPointsForLevelUp (character)
var basestr := CINT (GetAttributeBaseValue (character, "Strenth")/10);
var maxstr := GetObjProperty (character, "maxstr");
if (!maxstr)
maxstr := 75;
endif
basestr := basestr + 1;
if (basestr > maxstr)
basestr := maxstr;
endif
SetAttributeBaseValue (character, "Strength", basestr*10);
//Do the exact same thing for int and dex
//now for skills
//be sure you include skills.inc and attributes.inc
var specs := LoadSpecializations (character);
for i := 1 to 3
var skillid := specs[i];
if (skillid or skillid == 0)
var skillval := CINT (GetAttributeBaseValue (character, GetAttributeIDBySkillid (skillid))/10);
skillval := skillval + 1;
if (skillval > 100)
skillval := 100;
endif
SetAttributeBaseValue (character, GetAttributeIDBySkillID (skillid), skillval * 10);
endif
endfor
//secondaries
for i := 4 to 6
var skillid := specs[i];
if (skillid or skillid == 0)
var skillval := CINT (GetAttributeBaseValue (character, GetAttributeIDBySkillid (skillid))/10);
skillval := skillval + 1;
if (skillval > 80)
skillval := 80;
endif
SetAttributeBaseValue (character, GetAttributeIDBySkillID (skillid), skillval * 10);
endif
endfor
//the tradeskill
var skillid := specs[7];
if (skillid or skillid == 0)
var skillval := CINT (GetAttributeBaseValue (character, GetAttributeIDBySkillid (skillid))/10);
skillval := skillval + 1;
if (skillval > 100)
skillval := 100;
endif
SetAttributeBaseValue (character, GetAttributeIDBySkillID (skillid), skillval * 10);
endif
endfunction
As normal, none of this is tested in any way