Difference between revisions of "KarmaSystem"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
(AlterKarmaAction)
(Conflict Functions)
Line 4: Line 4:
 
''
 
''
  
== Conflict Functions ==
+
== Karma Functions ==
 
=== AdjustKarma ===
 
=== AdjustKarma ===
 
''
 
''

Revision as of 09:12, 27 January 2018

 welcome this will discuss the contents of the globals\helpers\conflict.lua
 this documentation is correct as of version 6.0 PRECB1 Release 

Karma Functions

AdjustKarma

 -- Adjust the karma for a mobile, a system message pertaining to the change is sent.
 -- @param mobile(mobileObj)
 -- @param amount(number) The amount to adjust by.
 -- @return none
 function AdjustKarma(mobile, amount)
   if ( amount == 0 or amount == nil ) then return end
   local karma = GetKarma(mobile)
   -- cache the karma level so we can check if it changed.
   local karmaLevel = GetKarmaLevel(karma)
   karma = math.floor(karma + amount + 0.5)
   SetKarma(mobile, karma)
   if ( amount > 0 ) then
       mobile:SystemMessage("You have gained"..GetKarmaStringAmount(amount).."karma.", "info")
   else
       mobile:SystemMessage("You have lost"..GetKarmaStringAmount(math.abs(amount)).."karma.", "info")
   end
   if ( karmaLevel.Name ~= GetKarmaLevel(karma).Name ) then
       -- Karma was changed, update the name and whatever else, maybe a message?
       mobile:SendMessage("UpdateName")
   end
 end

AlterKarmaAction

 -- convenience function to alter a karma action's amount before applying it
 -- @param karmaAction Lua table karma action
 -- @param newAmount(number)
 -- @return the altered karma action
 function AlterKarmaAction(karmaAction, newAmount)
   karmaAction = deepcopy(karmaAction)
   karmaAction.Adjust = newAmount
   return karmaAction
 end

CheckKarmaBeneficialAction

CheckKarmaLoot

ColorizeMobileName

ColorizePlayerName

DailyLogin

ExectueKarmaAction

GetKarma

GetKarmaLevel

GetKarmaStringAmount

KarmaPunishAllAggressorsForMurder

SetKarma

WithinKarmaArea