KarmaSystem
welcome this will discuss the contents of the globals\helpers\conflict.lua this documentation is correct as of version 6.0 PRECB1 Release
Contents
- 1 Conflict Functions
- 1.1 AdjustKarma
- 1.2 AlterKarmaAction
- 1.3 CheckKarmaBeneficialAction
- 1.4 CheckKarmaLoot
- 1.5 ColorizeMobileName
- 1.6 ColorizePlayerName
- 1.7 DailyLogin
- 1.8 ExectueKarmaAction
- 1.9 GetKarma
- 1.10 GetKarmaLevel
- 1.11 GetKarmaStringAmount
- 1.12 KarmaPunishAllAggressorsForMurder
- 1.13 SetKarma
- 1.14 WithinKarmaArea
Conflict 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