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
| =begin
Halt / Unhalt All Event Movement v1.1
by PK8
Created: 6/22/2012
Modified: 6/27/2012
──────────────────────────────────────────────────────────────────────────────
■ Author's Notes
This originally started off as an attempt to replicate RPG Maker 2003's
Halt Movement system. When I was trying to look at how it worked (maybe I
applied the event command wrong, or maybe I just misread it), nothing really
halted. Trying to find a few ways didn't result in much so I threw my hands up
and said "forget it."
I hope people enjoy it all the same, even if it doesn't exactly replicate an
event command from an older maker.
──────────────────────────────────────────────────────────────────────────────
■ Introduction
This quickly written script lets users halt, unhalt, and toggle the halted
state of all events (with the exception of any that may have been specified
within the calls) with just a few quick script calls.
──────────────────────────────────────────────────────────────────────────────
■ Features
o Halt all events with the exception of a few IDs specified in an array.
o Unhalt all events with the exception of a few IDs specified in an array.
o Toggle halt state of all events w/ the exception of some IDs set in an array.
──────────────────────────────────────────────────────────────────────────────
■ Changelog
o v1 (06/22/2012): Initial Release
o v1.1 (06/27/2012): Added a toggle halt state call. Users can now specify
exceptions using Ranges (Example: 0..5).
──────────────────────────────────────────────────────────────────────────────
■ Thanks
o Kore, Bird_Eater, SolarGale, and Bravo2Kilo for viewing the stream.
──────────────────────────────────────────────────────────────────────────────
■ Calls
Halt All Movement : halt_all_movement(array, flag)
Unhalt All Movement : unhalt_all_movement(array, flag)
Toggle Halt All Movement : toggle_halt_all_movement(array, flag)
* array: Specify an array of events that would(n't) get (un)halted/get their
halt state toggled. Ranges are allowed. Optional (none).
* flag : Boolean value. Optional (true).
* true: (un)halts/alters halt state of all but specified.
* false: (un)halts/alters halt state of all specified.
=end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Halt All Movement
# array : Specify an array of events that would(n't) get halted.
# Ranges are allowed. Optional.
# flag : Boolean value. Optional.
# * true: halts all but specified
# * false: halts only specified
#--------------------------------------------------------------------------
def halt_all_movement(array = [], flag = true)
array.each { | k |
if k.is_a?(Range); k.each { | i | array.push(i) }; array.delete(k); end
}
$game_map.events.each { |k, v|
# If flag == true, halts all events but those specified
v.lock if !array.include?(k) and flag == true
# If flag == false, halts events not specified
v.lock if array.include?(k) and flag == false
}
end
#--------------------------------------------------------------------------
# * Unhalt All Movement
# array : Specify array of events that would(n't) get unhalted.
# Ranges are allowed. Optional.
# flag : Boolean value. Optional.
# * true: unhalts all but specified
# * false: unhalts only specified
#--------------------------------------------------------------------------
def unhalt_all_movement(array = [], flag = true)
array.each { | k |
if k.is_a?(Range); k.each { | i | array.push(i) }; array.delete(k); end
}
$game_map.events.each { |k, v|
# If flag == true, halts all events but those specified
v.unlock if !array.include?(k) and flag == true
# If flag == false, halts events not specified
v.unlock if array.include?(k) and flag == false
}
end
#--------------------------------------------------------------------------
# * Toggle Halt All Movement
# array : Specify an array of events that would(n't) get their (un)halted
# state toggled. Ranges are allowed. Optional.
# flag : Boolean value. Optional.
# * true: toggles halt state of all but specified
# * false: toggles halt state of only specified
#--------------------------------------------------------------------------
def toggle_halt_all_movement(array = [], flag = true)
array.each { | k |
if k.is_a?(Range); k.each { | i | array.push(i) }; array.delete(k); end
}
$game_map.events.each { |k, v|
# If flag == true, halts all events but those specified
if !array.include?(k) and flag == true
(v.instance_eval("@locked") ? v.unlock : v.lock)
# If flag == false, halts events not specified
elsif array.include?(k) and flag == false
(v.instance_eval("@locked") ? v.unlock : v.lock)
end
}
end
end |