It is currently Fri Nov 21, 2008 10:38 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Stat Gain
PostPosted: Wed May 24, 2006 8:20 pm 
Offline

Joined: Wed Apr 19, 2006 12:29 pm
Posts: 42
Location: St. Peters, MO
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.

_________________
Obstacles cannot crush me; every obstacle yields to Stern Resolve.


Top
 Profile  
 
 Post subject: Re: Stat Gain
PostPosted: Fri May 26, 2006 3:45 am 
Offline

Joined: Fri Feb 03, 2006 6:32 am
Posts: 104
Location: Austria
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...

_________________
[url=www.etheria.org]
Etheria - Roleplaying Realism
Image [/url]


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 11:35 am 
Offline

Joined: Wed Apr 19, 2006 12:29 pm
Posts: 42
Location: St. Peters, MO
Right, I have added two props per stat to characters on creation. One prop is the raw value of the stat, the other is the decimal value including the tenths place.

I'm not looking for a test, I think the actual coding is solid until the calculation of the raw stat. I guess I need to add the raw value up, convert it to it's decimal equivalent, then do a check to see if it rouned the corner to the next integer, then set the actual stat to that integer value.

I had to step away from it for a while to re-gain perspective. I was getting tunnel-vision.

_________________
Obstacles cannot crush me; every obstacle yields to Stern Resolve.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl