- 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


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleUntitled Paste
TypeDenizen Script
Date2017/11/12 18:22:39 UTC-08:00
ByGuest
Other
Paste
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
8000
Sneaking_Event:
  type: world
  debug: false
  events:
    on player starts sneaking:
    - run SneakCheck id:SneakCheck_<player.uuid>
    on player stops sneaking:
    - queue 'q@SneakCheck_<player.uuid>' clear
    - actionbar ""
    on player walks: 
    - if !<player.is_sneaking> { 
      - foreach <player.eye_location.find.npcs.within[5]> { 
        - look <def[value]> <player.eye_location> 
        - actionbar target:<player> ""
        }
      } 
SneakCheck: 
  type: task 
  debug: false
  script: 
    - while true {
        - ^define npcs <player.eye_location.find.npcs.within[20]>
        - if <player.has_flag[DetectedBy]> {
          - ^actionbar target:<player> "<bold>Detected"
          - ^look <player.flag[DetectedBy]> <player.eye_location>
          - wait 5t
          - ^while next
          }
        - if <def[npcs].filter[eye_location.facing[<player>].degrees[45]].filter[eye_location.line_of_sight[<player.eye_location>]].size> > 0 {
          - ^flag <player> DetectedBy:->:<def[npcs]> duration:10s
          - wait 5t
          - ^while next
          }
        - foreach <def[npcs]> {
          - if <proc[HiddenSneakChance].context[<player.eye_location.light_level>|<proc[ArmorWeight].context[<player>]>|<def[value].flag[NPCSkill]||50>|<player.flag[SneakSkill]||50>|<proc[SneakBonus]>|<def[value].as_npc.location.distance[<player.eye_location]>]>].mul[0.025]> > <util.random.decimal> {
            - ^narrate "<def[value].name> detected you by algorithm"
            - ^flag <player> DetectedBy:->:<def[npcs]> duration:10s
            - wait 5t
            - ^while next
            }
          }
        - actionbar target:<player> "<italic>Hidden"
        - wait 5t
    }
    
HiddenSneakChance:
  type: procedure
  definitions: light|armor|npcSkill|playerSkill|itemBonus|distance
  debug: false
  script:
    - define exponent <el@-1.566.add[<el@0.3.mul[<def[light].as_decimal>]>].add[<el@3.46.mul[<def[armor].as_decimal>]>].add[<el@0.022.mul[<def[npcSkill].as_decimal>]>].sub[<el@0.022.mul[<def[playerSkill].as_decimal>]>].sub[<el@0.022.mul[<def[itemBonus].as_decimal>]>].sub[<el@0.155.mul[<def[distance].as_decimal>]>]>
    - define algorithm <el@2.71828.power[<def[exponent].as_decimal>]>
    - determine <def[algorithm].div[<def[algorithm].add[1].as_decimal>]>

ArmorWeight:
  type: procedure
  definitions: player
  debug: false
  script:
    - define result 0.0
    - if <def[player].equipment.helmet.material> contains "iron" || <def[player].equipment.helmet.material> contains "diamond" {
        - define result <def[result].add[0.15]>
      }
    - if <def[player].equipment.chestplate.material> contains "iron" || <def[player].equipment.chestplate.material> contains "diamond" {
        - define result <def[result].add[0.25]>
      }
    - if <def[player].equipment.leggings.material> contains "iron" || <def[player].equipment.leggings.material> contains "diamond" {
        - define result <def[result].add[0.25]>
      }
    - if <def[player].equipment.boots.material> contains "iron" || <def[player].equipment.boots.material> contains "diamond" {
        - define result <def[result].add[0.35]>
      }
    - determine <def[result]>
SneakBonus:
  type: procedure
  definitions: player
  debug: false
  script:
    - determine 50



RawRaw



Pastes made: 70296