Date: 2024/04/20 00:45:26 UTC-07:00
Type: Denizen Script
on player damages entity:
- define damager <context.damager>
- define item <[damager].item_in_hand>
- define inv <[damager].inventory>
- define slot hand
- define stat_name <[item].flag[oil.name].if_null[null]>
- define stat_damage <[item].flag[oil.damage].if_null[null]>
- define stat_duration <[item].flag[oil.duration].if_null[null]>
- define max_hits <[item].flag[oil.max_hits].if_null[null]>
- define curr_hits <[item].flag[oil.hits].if_null[null]>
- if !<[item].has_flag[oil_applied]>:
- narrate "no oil"
- stop
- if <[max_hits]> == null or <[curr_hits]> == null:
- narrate "max_hits or curr_hits == null"
- stop
- if <[curr_hits]> == 0:
- inventory flag destination:<[inv]> slot:<[slot]> oil_applied:!
- inventory flag destination:<[inv]> slot:<[slot]> oil:!
- define i_lore <[item].lore>
- define lore_loc <[i_lore].find_partial[Oil]>
- define update_oil <[i_lore].remove[<[lore_loc]>]>
- inventory adjust destination:<[inv]> slot:<[slot]> lore:<[update_oil]>
- narrate "current hits == 0"
- stop
- inventory flag destination:<[inv]> slot:<[slot]> oil.hits:--
- define curr_hits <[item].flag[oil.hits].if_null[null]>
- define i_lore <[item].lore>
- define lore_loc <[i_lore].find_partial[Oil]>
- define update_oil <[i_lore].set[<&f> ꀅ <&f>Oil:<[stat_name]> - <[curr_hits]>/<[max_hits]>].at[<[lore_loc]>]>
- inventory adjust destination:<[inv]> slot:<[slot]> lore:<[update_oil]>
- narrate "curr hits = <[curr_hits]>"
- stop