Darkness Warding Items
By
ChemCreated: 2015/03/14 13:24:55 UTC-07:00 (9 years and 285 days ago)
Edited: 2016/07/11 20:30:21 UTC-07:00 (8 years and 165 days ago)
Likes: 2
Denizen Version: 0.9.8
Script Version: 1.1
Description:
Some simple scripts designed for players to ward off evil and darkness on your server.
Features:
1: Luminescent aversion: When an entity targets an another entity, its canceled if the entity is holding a luminescent item. Useful for npcs that are in battle with mobs or players that are afraid of spiders / witches / wolves. Works for offhand items too.
2: Torch Enflaming: When an entity damages another entity with a torch in their hand theres a 60% chance (configurable) to set that entity on fire.
3: Luminescent Items: When holding those in a hand, there will be a light level according to the settings in the config. Works for offhand items too.
Tested as of build: 607 Core: 1.10 (142)
Download script |
View raw scriptLuminescent Items:
affected_mobs:
- wolf
- spider
- cavespider
- witch
luminescent_items:
- i@torch
- i@glowstone
- i@sea_lantern
- i@redstone_torch_on
- i@lava_bucket
- i@jack_o_lantern
- i@glowstone_dust
- i@beacon
success max: 10
success min: 6
duration: d@2s-15s
light_time_update: d@12t
light_levels:
i@torch: 12
i@glowstone: 15
i@sea_lantern: 15
i@redstone_torch_on: 4
i@lava_bucket: 6
i@jack_o_lantern: 8
i@glowstone_dust: 5
i@beacon: 15
type: world
events:
on entity damages entity:
- async:
- if <context.damager.item_in_hand.simple||none> != i@torch
queue clear
Line with no clear purpose - missing a -dash- or :colon:?
- define max "<script.yaml_key[success max]>"
- define min "<script.yaml_key[success min]>"
- define roll <util.random.int[0].to[<def[max]>]>
- if !<def[roll].is[or_more].than[<def[min]>]> queue clear
- narrate "<gray>You set your enemies on <red>fire<yellow>!"
- define duration <script.yaml_key[duration]>
- burn <context.entity> duration:%duration%
on entity targets:
- if !<script.yaml_key[affected_mobs].contains[<context.entity.name>]> queue clear
- if !<context.reason.contains[closest_player]> queue clear
- if !<script.yaml_key[luminescent_items].contains[<context.target.item_in_hand>]>
&& !<script.yaml_key[luminescent_items].contains[<context.target.item_in_offhand>]> queue clear
Line with no clear purpose - missing a -dash- or :colon:?
- determine cancelled
on player holds item:
- async:
- define name <player.name>_light_update_queue
- if <queue.exists[<def[name]>]> queue clear
- run "Hand Item Light Update" def:<script>|<player> id:<def[name]>
Hand Item Light Update:
type: task
definitions: script|entity
speed: 0t
default_script: "s@Luminescent Items"
type_script: as_script
type_entity: as_entity
script:
- inject typecheck
- if !<def[entity].is_spawned> queue clear
- define items <def[script].yaml_key[luminescent_items]>
- while <def[items].contains[<def[entity].item_in_hand.simple>].or[<def[items].contains[<def[entity].item_in_offhand.simple>]>]> {
- wait <def[script].yaml_key[light_time_update]>
- if !<def[entity].is_spawned> while stop
- define location
<def[entity].location.simple.as_location>
Line with no clear purpose - missing a -dash- or :colon:?
#if didnt move, dont do anything
- if <def[location]> == <def[last_location]||no_last_location>
while next
Line with no clear purpose - missing a -dash- or :colon:?
#hand light values even if the item isnt a luminessent item
- define hand_light
<def[script].yaml_key[light_levels.<def[entity].item_in_hand.simple>]||0>
Line with no clear purpose - missing a -dash- or :colon:?
- define off_hand_light
<def[script].yaml_key[light_levels.<def[entity].item_in_offhand.simple>]||0>
Line with no clear purpose - missing a -dash- or :colon:?
- if <def[hand_light].is[or_more].than[<def[off_hand_light]>]> {
- define light <def[hand_light]>
} else {
- define light <def[off_hand_light]>
}
#change lighting according to scripted values
- light
<def[location]>
Line with no clear purpose - missing a -dash- or :colon:?
<def[light]>
Line with no clear purpose - missing a -dash- or :colon:?
duration:d@1m
#reset old lighting if last_location exists
- if <def[last_location].exists||false>
light
Line with no clear purpose - missing a -dash- or :colon:?
<def[last_location]>
Line with no clear purpose - missing a -dash- or :colon:?
reset
Line with no clear purpose - missing a -dash- or :colon:?
#define last_location as this location
- define last_location
<def[location]>
Line with no clear purpose - missing a -dash- or :colon:?
}
- if <def[last_location].exists||false>
light
Line with no clear purpose - missing a -dash- or :colon:?
<def[last_location]>
Line with no clear purpose - missing a -dash- or :colon:?
reset
Line with no clear purpose - missing a -dash- or :colon:?
View History