SetAttributeBaseValue()

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
GEEK
New User
Posts: 29
Joined: Sat Jul 22, 2006 8:25 am

SetAttributeBaseValue()

Post 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?
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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.
GEEK
New User
Posts: 29
Joined: Sat Jul 22, 2006 8:25 am

Post 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 ?
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post 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.
Post Reply