- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Darkness Warding Items


By Chem
Created: 2015/03/14 13:24:55 UTC-07:00 (9 years and 53 days ago)
Edited: 2016/07/11 20:30:21 UTC-07:00 (7 years and 298 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 script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
12700

Luminescent 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
            - 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
        - 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>
        
        #if didnt move, dont do anything
        - if <def[location]> == <def[last_location]||no_last_location>
          while next
        
        #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>
        
        - define off_hand_light
          <def[script].yaml_key[light_levels.<def[entity].item_in_offhand.simple>]||0>
        
        - 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]>
          <def[light]>
          duration:d@1m
        
        #reset old lighting if last_location exists
        - if <def[last_location].exists||false>
          light
          <def[last_location]>
          reset
        
        #define last_location as this location
        - define last_location
          <def[location]>
        }
    
    - if <def[last_location].exists||false>
      light 
      <def[last_location]>
      reset
    









View History