Skip to content
Permalink
Browse files

Merge pull request #86 from polserver/attributemod-precision

Add parameter to get an attribute value in tenths
  • Loading branch information...
turleypol committed Mar 20, 2019
2 parents 251cf45 + b2c15f9 commit fd9ae82a560e258a1de4e7c4d1bfc1500019d043
@@ -5,10 +5,12 @@
<fileheader fname="Attributes.em">
<filedesc>Functions for working with mobile's attributes/skills.</filedesc>
<datemodified>03/19/2009</datemodified>
<constant>const ATTRIBUTE_LOCK_UP := 0;</constant>
<constant>const ATTRIBUTE_LOCK_DOWN := 1;</constant>
<constant>const ATTRIBUTE_LOCK_LOCKED := 2;</constant>
<constant>const ATTRIBUTE_MAX_BASE := 60000;</constant>
<constant>const ATTRIBUTE_LOCK_UP := 0;</constant>
<constant>const ATTRIBUTE_LOCK_DOWN := 1;</constant>
<constant>const ATTRIBUTE_LOCK_LOCKED := 2;</constant>
<constant>const ATTRIBUTE_MAX_BASE := 60000;</constant>
<constant>const ATTRIBUTE_PRECISION_NORMAL := 0;</constant>
<constant>const ATTRIBUTE_PRECISION_TENTHS := 1;</constant>
</fileheader>

<function name="CheckSkill">
@@ -48,12 +50,13 @@
</function>

<function name="GetAttribute">
<prototype>GetAttribute( character, attrname )</prototype>
<prototype>GetAttribute( character, attrname, precision := ATTRIBUTE_PRECISION_NORMAL )</prototype>
<parameter name="character" value="Character Reference" />
<parameter name="attrname" value="String (attribute name)" />
<parameter name="precision" value="Integer" />
<explain>Returns the current effective value for the specified attribute on character.</explain>
<return>Integer "Effective" attribute value on success (base + temporary mod + intrinsic mod) or
Error</return>
Error. Will return the precision in tenths if ATTRIBUTE_PRECISION_TENTHS is specified. </return>
<error>"Invalid parameter type" including if attrname was not found as an attribute</error>
<related>Character</related>
<relatedcfg>attributes.cfg</relatedcfg>
@@ -2,9 +2,17 @@
<ESCRIPT>
<header>
<topic>Latest Core Changes</topic>
<datemodified>03-09-2019</datemodified>
<datemodified>03-19-2019</datemodified>
</header>
<version name="POL100">
<entry>
<date>03-19-2019</date>
<author>Kevin:</author>
<change type="Changed">attributes::GetAttribute now accepts an optional parameter to specify the precision of the attribute<br/>
value returned. Use ATTRIBUTE_PRECISION_NORMAL (default) to use the existing precision, or<br/>
ATTRIBUTE_PRECISION_TENTHS to get the value in tenths.<br/>
Since this is a change to the module function's number of arguments, you MUST recompile your scripts.</change>
</entry>
<entry>
<date>03-08-2019</date>
<author>Yukiko:</author>
@@ -1,4 +1,10 @@
-- POL100 --
03-19-2019 Kevin:
Changed: attributes::GetAttribute now accepts an optional parameter to specify the precision of the attribute
value returned. Use ATTRIBUTE_PRECISION_NORMAL (default) to use the existing precision, or
ATTRIBUTE_PRECISION_TENTHS to get the value in tenths.

Since this is a change to the module function's number of arguments, you MUST recompile your scripts.
03-08-2019 Yukiko:
Changed: pol.cfg settings HideWarningGump and HideWarningItem to ShowWarningGump and ShowWarningItem.
This positive logic is consistent with all other console output settings.
@@ -95,15 +95,17 @@ Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeDefaultCap( /* alia
return new Bscript::BLong( attr->default_cap );
}

Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttribute( /* mob, attrname */ )
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttribute( /* mob, attrname, precision */ )
{
Character* chr;
const Attribute* attr;
short precision;

if ( getCharacterParam( exec, 0, chr ) && Core::getAttributeParam( exec, 1, attr ) )
if ( getCharacterParam( exec, 0, chr ) && Core::getAttributeParam( exec, 1, attr ) &&
getParam( 2, precision ) )
{
const AttributeValue& av = chr->attribute( attr->attrid );
return new Bscript::BLong( av.effective() );
return new Bscript::BLong( precision == 1 ? av.effective_tenths() : av.effective() );
}
else
{
@@ -6,6 +6,9 @@ const ATTRIBUTE_LOCK_UP := 0;
const ATTRIBUTE_LOCK_DOWN := 1;
const ATTRIBUTE_LOCK_LOCKED := 2;

const ATTRIBUTE_PRECISION_NORMAL := 0;
const ATTRIBUTE_PRECISION_TENTHS := 1;

const ATTRIBUTE_MAX_BASE := 60000;

// To-Fix: Uses a skillid - should take in an attribute name.
@@ -15,7 +18,7 @@ AlterAttributeTemporaryMod( character, attrname, delta_tenths );

GetAttributeName( alias_name );

GetAttribute( character, attrname );
GetAttribute( character, attrname, precision := ATTRIBUTE_PRECISION_NORMAL );
GetAttributeBaseValue( character, attrname );
GetAttributeIntrinsicMod( character, attrname );
GetAttributeTemporaryMod( character, attrname );

0 comments on commit fd9ae82

Please sign in to comment.
You can’t perform that action at this time.