Page 1 of 1

SetAttributeBaseValue()

Posted: Mon Aug 21, 2006 3:19 am
by GEEK
In attributes.inc when the function SetAttributeBaseValue() is used the code check before value:

Code: Select all

  if(intelligence < 10)
    intelligence := 10;
  elseif(intelligence > CORE_SETTINGS_MAX_ATTRIBUTE)
    intelligence := CORE_SETTINGS_MAX_ATTRIBUTE;
  endif
  var ret := SetAttributeBaseValue(who, ATTRIBUTEID_INTELLIGENCE, intelligence);
What can happen if I use directly SetAttributeBaseValue() and I do not check CORE_SETTINGS_MAX_ATTRIBUTE?

Core crashes or only fails the command?

Posted: Mon Aug 21, 2006 9:13 pm
by Yukiko
CORE_SETTINGS_MAX_ATTRIBUTE is a constant used as a reference for the maximum value any attribute can attain. To my knowledge the POL server will suffer no adverse effects if you go above this value. However depending on what format attributes are stored at there may be a maximum hard coded value. For example if attributes are a double-integer the max value will be 65535.

Posted: Tue Aug 22, 2006 1:26 am
by GEEK
I am rewriting all my scripts not using functions in attributes.inc like
GetStamina() or GetHp()

I don't know if it is the case also to substituite also SetBaseIntelligence() for exampe.
The code is:

Code: Select all

function SetBaseIntelligence(who, intelligence)
  intelligence := Cint(intelligence * 10);
  if(intelligence < 10)
    intelligence := 10;
  elseif(intelligence > CORE_SETTINGS_MAX_ATTRIBUTE)
    intelligence := CORE_SETTINGS_MAX_ATTRIBUTE;
  endif
  var ret := SetAttributeBaseValue(who, ATTRIBUTEID_INTELLIGENCE, intelligence);
  if(ret)
    DoRecalcVitals(who);
  endif
  return ret;
endfunction
If I don't' check
if(intelligence < 10)
for exampe
SetAttributeBaseValue(who, ATTRIBUTEID_INTELLIGENCE, intelligence)
do not report error to script if intelligence < 0 ?

Posted: Tue Aug 22, 2006 9:13 am
by CWO
The core shouldnt suffer at all from your changes. Its not the core that checks the max values, its the scripts. Its up to you where you want this all checked if you want it checked at all but also it comes as a warning that if you dont have something checking that somewhere in your scripts, your players can just keep gaining until the core's hardcoded max is reached which I'm sure is far above any cap you want.