Add award difficulty multipler

This commit is contained in:
rubenwardy 2018-04-17 22:25:53 +01:00
parent 08f654cf94
commit f0052386c8
2 changed files with 26 additions and 2 deletions

View File

@ -17,24 +17,44 @@ awards.register_award("mymod:myaward", {
-- Optional:
difficulty = 1.0, -- Difficulty multipler
requires = { "amod:an_award" }, -- don't show this award or allow it to be unlocked
-- until required awards are unlocked
sound = {}, -- SimpleSoundSpec or false to play no sound
-- if not provided, uses default sound
image = "icon_image.png", -- uses default icon otherwise
background = "background_image.png", -- uses default background otherwise
trigger = { -- is only unlocked by direct calls to awards.unlock() otherwise
type = "trigger_type",
-- see specific docs on the trigger to see what else goes here
},
-- Callback. award_def is this table (plus some additional methods/members added by register_award)
on_unlock = function(name, award_def) end,
})
```
If the award is counted, ie: there's a trigger.target property, then the difficulty
multipler is timesd by target to get the overal difficulty. If the award isn't a
counted type then the difficulty multiplier is used as the overal difficulty.
Award difficulty affects how awards are sorted in a list - more difficult awards
are further down the list.
Actual code used to calculate award difficulty:
```lua
local difficulty = def.difficulty or 1
if def.trigger and def.trigger.target then
difficulty = difficulty * def.trigger.target
end
```
## Registering Trigger Types
```lua

View File

@ -13,9 +13,13 @@ local function order_awards(name)
if def then
hash_is_unlocked[awardname] = true
local score = -100000
local difficulty = def.difficulty or 1
if def.trigger and def.trigger.target then
score = score + def.trigger.target
difficulty = difficulty * def.trigger.target
end
score = score + difficulty
retval[#retval + 1] = {
name = awardname,
def = def,