 |
 |
 |
 |
| Author |
Message |
Exar Kun
Joined: 19 Apr 2006 Posts: 42 Location: St. Peters, MO
|
Posted: Thu May 25, 2006 12:20 am Post subject: Stat Gain |
|
|
I got a hold of a server where Stat Gain was not tied to skill gain. I'm trying to tie it back in. I'd appreciate any help I can get.
Right now, when my CheckSkill runs, a succesful skill check earns a Raw Stat Point.
| Code: | if ( rawMaxSkill > possibleNewRawSkill )
AwardRawSkill ( character, attribute, 1 );
StatIncrease ( character, attribute );
endif |
Here's the StatIncrease function (yes, I understand I should put in a function to handle the repetitive code, but I'm just trying to get the whole thing working right now):
| Code: | function StatIncrease ( character, attribute )
case ( attribute )
"Alchemy":
"Anatomy":
"Detecthidden":
"Leadership":
"Invocation":
"Magery":
"Magicresistance":
"Meditation":
"Necromancy":
"Tactics":
"Tracking":
"Veterinary":
var currentInt := GetObjProperty ( character, "int" );
var rawCurrentInt := BaseToRaw ( currentInt * 10 );
rawCurrentInt := ( rawCurrentInt + 1 );
var newCurrentInt := RawToBase ( rawCurrentInt );
newCurrentInt := ( newCurrentInt / 10 );
SetObjProperty ( character, "int", newCurrentInt );
var unmod_Int := CInt ( GetAttributeBaseValue ( character, "Intelligence" ) / 10 );
if ( ( CInt ( newCurrentInt ) ) > unmod_Int )
var charMaxStat := GetObjProperty ( character, "maxint" );
var rawMaxStat := BaseToRaw ( charMaxStat );
rawMaxStat := ( rawMaxStat + 1 );
var currentRawStat := BaseToRaw ( currentInt * 10 );
var possibleNewRawStat := ( currentRawStat + 1);
if ( rawMaxStat > possibleNewRawStat )
SetAttributeBaseValue ( character, "Intelligence", unmod_Int * 10 + 10 );
RecalcVitals ( character );
endif
endif
"Archery":
"Fencing":
"Lockpicking":
"Stealing":
"Stealth":
"Parry":
"Tinkering":
"Tailoring":
"Cartography":
"Hiding":
"Musicianship":
"Poisoning":
"Inscription":
var currentDex := GetObjProperty ( character, "dex" );
var rawCurrentDex := BaseToRaw ( currentDex * 10 );
rawCurrentDex := ( rawCurrentDex + 1 );
var newCurrentDex := RawToBase ( rawCurrentDex );
newCurrentDex := ( newCurrentDex / 10 );
SetObjProperty ( character, "dex", newCurrentDex );
var unmod_Dex := CInt ( GetAttributeBaseValue ( character, "Dexterity" ) / 10 );
if ( ( CInt ( newCurrentDex ) ) > unmod_Dex )
var charMaxStat := GetObjProperty ( character, "maxdex" );
var rawMaxStat := BaseToRaw ( charMaxStat );
rawMaxStat := ( rawMaxStat + 1 );
var currentRawStat := BaseToRaw ( currentDex * 10 );
var possibleNewRawStat := ( currentRawStat + 1);
if ( rawMaxStat > possibleNewRawStat )
SetAttributeBaseValue ( character, "Dexterity", unmod_Dex * 10 + 10 );
RecalcVitals ( character );
endif
endif
"Lumberjacking":
"Mining":
"Wrestling":
"Blacksmithy":
"Carpentry":
"Fishing":
"Macefighting":
"Swordsmanship":
"Camping":
"Druidry":
var currentStr := GetObjProperty ( character, "str" );
var rawCurrentStr := BaseToRaw ( currentStr * 10 );
rawCurrentStr := ( rawCurrentStr + 1 );
var newCurrentStr := RawToBase ( rawCurrentStr );
newCurrentStr := ( newCurrentStr / 10 );
SetObjProperty ( character, "str", newCurrentStr );
var unmod_Str := CInt ( GetAttributeBaseValue ( character, "Strength" ) / 10 );
if ( ( CInt ( newCurrentStr ) ) > unmod_Str )
var charMaxStat := GetObjProperty ( character, "maxstr" );
var rawMaxStat := BaseToRaw ( charMaxStat );
rawMaxStat := ( rawMaxStat + 1 );
var currentRawStat := BaseToRaw ( currentStr * 10 );
var possibleNewRawStat := ( currentRawStat + 1);
if ( rawMaxStat > possibleNewRawStat )
AwardRawStat ( character, "str", 1 )
SetAttributeBaseValue ( character, "Strength", unmod_Str * 10 + 10 );
RecalcVitals ( character );
endif
endif
"Cooking":
"Healing":
"Peacemaking":
"Provocation":
"Taming":
return;
default:
DohEth ( character );
endcase
endfunction |
So now AwardRawStat:
| Code: | function AwardRawStat ( character, statID, rawStatPoints )
var calcRawStat, rawElem;
if ( !rawStatPoints )
return;
endif
if ( character.npctemplate )
rawElem := npcRawSkill.FindElement ( character.serial );
if ( !rawElem )
rawElem := npcRawSkill.CreateElement ( character.serial );
endif
calcRawStat := rawElem.GetProp ( "raw" + statID ) + rawStatPoints;
if ( !calcRawStat )
calcRawStat := rawStatPoints;
endif
rawElem.SetProp ( "raw" + statID, calcRawStat );
SetBaseStatFromRaw ( character, statID, calcRawStat );
else
calcRawStat := GetObjProperty ( character, "raw" + statID ) + rawStatPoints;
if ( !calcRawStat )
calcRawStat := rawStatPoints;
endif
SetBaseStatFromRaw ( character, statID, calcRawStat );
SetObjProperty ( character, "raw" + statID, calcRawStat );
endif
endfunction |
SetBaseStatFromRaw:
| Code: | function SetBaseStatFromRaw ( character, statID, rawStat )
var calc_Base_Stat := RawToBase ( rawStat );
if ( calc_Base_Stat == GetAttributeBaseValue ( character, statID ) )
return;
else
SetAttributeBaseValue ( character, statID, calc_Base_Stat );
endif
endfunction |
GetRawStat:
| Code: | function GetRawStat ( character, statID )
var rawStat, rawElem;
if ( character.npctemplate )
rawElem := npcRawSkill.FindElement ( character.serial );
rawStat := rawElem.GetProp ( "raw" + statID );
else
rawStat := GetObjProperty ( character, "raw" + statID );
endif
if ( !rawStat )
return 0;
else
return rawStat;
endif
endfunction |
SetRawStat:
| Code: | function SetRawStat ( character, statID, rawStatPoints )
var rawElem;
if ( rawStatPoints )
if ( character.npctemplate )
rawElem := npcRawSkill.FindElement ( character.serial );
if ( !rawElem )
npcRawSkill.CreateElement ( character.serial );
endif
rawElem.SetProp ( "raw" + statID, rawStatPoints );
else
SetObjProperty ( character, "raw" + statID, rawStatPoints );
endif
SetBaseStatFromRaw ( character, statID, rawStatPoints );
endif
endfunction |
Basically, I ripped off the old AwardRawSkill functions and changed the variable names. I don't think I can display a 0.1 gain for a Stat (STR, DEX, INT), so am I handling this correctly? I think I'm stretched to my coding limits on this one.
I'd appreciate any help. Thanks. |
|
 |
|
|
 |
 |
| Author |
Message |
Firedancer
Joined: 03 Feb 2006 Posts: 104 Location: Austria
|
Posted: Fri May 26, 2006 7:45 am Post subject: Re: Stat Gain |
|
|
As to your question: You asume correctly, stats are integer values, you can't set them to e.g. 0.1 - but of course you could keep an internal value, e.g. in a cprop, which could hold a more accurate value.
(And you can then take that value for your maths and maybe even for display)
Ps: As to the topic as a whole, I'm a bit lazy to read all that code, not knowing what to look for. What exactly is it doing now? Finding a problem is one thing, but I doubt you'll find someone willing to test your scripts for you. I bet if you could tell us, as to what it's doing differently than you expect, then you'd find people more willing to look up the issue for you... |
|
 |
|
|