Date: 2016/02/18 20:48:55 UTC-08:00
Type: Denizen 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
#############################
# File for Behaviour Module #
#############################
####################################################
# Task script for initalising the behaviour module #
####################################################
Initialise_Module_Behaviour:
type: task
script:
- if <yaml[config].list_keys[framework.modules].contains[npcs].not> || <server.has_file[../dFramework/NPC/yml].not> {
- debug error "Dependency: NPCs module could not be found"
- queue clear
}
- yaml id:config set "framework.modules.behaviour.description:This module requires the npcs module to work. Provides a library of scripts for behaviours."
- yaml id:config set framework.modules.behaviour.enabled:null
- yaml id:config set framework.modules.behaviour.files:->:null
- yaml savefile:../dFramework/config.yml id:config
- yaml id:npcs set behaviour.chat:3
- yaml id:npcs set behaviour.click:5
- yaml id:npcs set behaviour.proximity:3
- yaml id:npcs set behaviour.lookclose:3
- yaml id:npcs set behaviour.pauseVariable:0|20
- yaml id:npcs set behaviour.speed:0.9
- yaml savefile:../dFramework/NPC/yml id:npcs
######################################################################
# Task script for assigning triggers and lookclose states for an NPC #
######################################################################
Assign_Triggers:
type: task
definitions: chat|click|proximity|lookclose
script:
- if <yaml.list.contains[npcs].not> {
- debug error "Module: Behaviour either could not be loaded or could not be found"
- queue clear
}
- trigger name:chat state:true range:<def[chat].as_int||<yaml[npcs].read[behaviour.chat]>>
- trigger name:click state:true range:<def[click].as_int||<yaml[npcs].read[behaviour.click]>>
- trigger name:proximity state:true range:<def[proximity].as_int||<yaml[npcs].read[behaviour.proximity]>>
- lookclose <npc> state:true range:<def[lookclose].as_int||<yaml[npcs].read[behaviour.lookclose]>> realistic
- queue clear
################################################
# Task script for assigning walk related flags #
################################################
Assign_Walk_Flags:
type: task
definitions: min|max|speed
script:
- if <yaml.list.contains[npcs].not> {
- debug error "Module: Behaviour either could not be loaded or could not be found"
- queue clear
}
- flag <npc> walk
- flag <npc> pauseMin:<def[min].as_int||<yaml[npcs].read[behaviour.pauseVariable].get[1]>>
- flag <npc> pauseMax:<def[min].as_int||<yaml[npcs].read[behaviour.pauseVariable].get[2]>>
- flag <npc> speed:<def[min].as_int||<yaml[npcs].read[behaviour.speed]>>
###################################
# Task script to make an NPC Walk #
###################################
Walk:
type: task
debug: false
script:
- flag <npc> walkQueue:<queue>
- while <npc.has_flag[walk]> {
- if <npc.location.chunk.is_loaded.not> {
- queue pause
}
- flag <npc> anchorPoint:<npc.anchor.list.random>
- ~walk <npc> <npc.anchor[<npc.flag[anchorPoint]>]> speed:<npc.flag[speed]> auto_range
- wait <util.random.int[<npc.flag[pauseMin]>].to[<npc.flag[pauseMax]>]>
}
- queue clear
#########################################################
# World script that re-runs walk scripts and hides NPCs #
#########################################################
Behaviour_Manager:
type: world
debug: false
events:
on server start:
- wait 1t
- foreach <server.list_filter[has_flag[walk]]> {
- run Walk npc:<def[Value].as_npc>
}
- queue clear
on chunk loads:
- wait 1t
- foreach <chunk.living_entities.filter[has_flag[walk]]> {
- if <def[value].as_npc.flag[walkQueue].state> == "paused" {
- queue <def[value].as_npc.flag[walkQueue].state> resume
}
}
on player joins:
- if <player.has_flag[debug]
- foreach <server.list_players.filter[has_flag[hidden]]> {
- adjust
}