-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMap Projectile (ENG).rb
245 lines (202 loc) · 6.66 KB
/
Map Projectile (ENG).rb
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# =============================================================================
# TheoAllen - Map Projectiles
# Version : 1.0
# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
# (English Language)
# -----------------------------------------------------------------------------
# Require : Theo - Basic Modules v1.3 or more
# > Object Core Movement
# =============================================================================
($imported ||= {})[:Theo_MapProjectile] = true
# =============================================================================
# Change Logs:
# -----------------------------------------------------------------------------
# 2014.06.29 - Finished script
# =============================================================================
=begin
-----------------------------------------------------------------------------
Introduction :
-----------------------------------------------------------------------------
This script allow you to show projectile on map. Basically, it just show
projectile from starting character to target character. It doesn't do
anything except only showing projectiles.
The main purpose of this script is for storytelling. Do not expect any Action
Battle System or an event triggered when got hit by the projectile.
-----------------------------------------------------------------------------
How to use :
-----------------------------------------------------------------------------
Put this script below material but above main. Don't forget to put my basic
module as well.
There're two ways to show projectile. By event script call or by move route
script call.
---------------------------
Event script call :
Put this line in script call
show_proj(subject, target, duration, anim_id, hit_anim)
Replace the parameter by this following rules :
*) subject >> event ID for starting projectile. 0 for player. And put "self"
(without quotation) if you want to start projectile from
current event
*) target >> event ID for projectile target. 0 for player. And put "self"
(without quotation) if you want to current event as the
projectile target
*) duration >> Travel duration in frame. 60 frames same as 1 second.
*) anim_id >> Animation ID which will be played in projectile
*) hit_anim >> Animation ID which will be played in character once it got
hit. Can be ommited if isn't necessary
---------------------------
Move route script call :
Note that move route script call always start projectile from self. Put this
line in script call
show_proj(target, duration, anim_id, hit_anim)
Replace the parameter by this following rules :
*) target >> event ID for projectile target. 0 for player.
*) duration >> Travel duration in frame. 60 frames same as 1 second.
*) anim_id >> Animation ID which will be played in projectile
*) hit_anim >> Animation ID which will be played in character once it got
hit. Can be ommited if isn't necessary
=end
# =============================================================================
# No configuration. Do not edit pass this line!
# =============================================================================
class Game_Interpreter
def show_proj(subject, target, duration, anim_id, on_hit_anim = 0)
sub = get_object(subject)
tar = get_object(target)
proj = Map_Projectile.new(sub,tar,anim_id,duration,on_hit_anim)
$game_temp.map_projectiles.push(proj)
end
def get_object(key)
obj = key
obj = $game_map.events[key] if key.is_a?(Numeric)
obj = $game_player if key == 0
obj = $game_map.events[@event_id] if key == self
return obj
end
end
class Game_Character
def show_proj(target, duration, anim_id, on_hit_anim = 0)
tar = get_object(target)
proj = Map_Projectile.new(self,tar,anim_id,duration,on_hit_anim)
$game_temp.map_projectiles.push(proj)
end
def get_object(key)
obj = key
obj = $game_map.events[key] if key.is_a?(Numeric)
obj = $game_player if key == 0
return obj
end
end
class Game_Temp
attr_accessor :map_projectiles
alias theo_mproj_init initialize
def initialize
theo_mproj_init
@map_projectiles = []
end
end
class Map_Projectile
attr_accessor :sub, :target, :anim_id, :duration, :on_hit_anim
def initialize(sub, target, anim_id, duration, on_hit_anim)
@sub = sub
@target = target
@anim_id = anim_id
@duration = duration
@on_hit_anim = on_hit_anim
end
end
class Sprite_MapProj < Sprite_Base
def initialize(vport, proj_data)
super(vport)
@data = proj_data
set_position
goto(@data.target.screen_x, @data.target.screen_y - 16, @data.duration)
start_animation($data_animations[@data.anim_id])
end
def set_position
self.x = @data.sub.screen_x
self.y = @data.sub.screen_y - 16
end
def end_animation
@ani_duration = @animation.frame_max * @ani_rate + 1
end
def move_animation(dx, dy)
if @animation && @animation.position != 3
@ani_ox += dx
@ani_oy += dy
@ani_sprites.each do |sprite|
sprite.x += dx
sprite.y += dy
end
end
end
def update_last_coordinate
@last_x = x
@last_y = y
end
def update
super
process_dispose if need_dispose?
end
def update_move
update_last_coordinate
super
move_animation(diff_x, diff_y)
end
def diff_x
self.x - @last_x
end
def diff_y
self.y - @last_y
end
def need_dispose?
!moving?
end
def process_dispose
@data.target.animation_id = @data.on_hit_anim
# To prevent one frameskip on display hit animation
SceneManager.scene.spriteset.get_character(@data.target).update
dispose
end
end
class Spriteset_Map
alias theo_mproj_init initialize
def initialize
@projectiles = []
theo_mproj_init
end
alias theo_mproj_update update
def update
theo_mproj_update
update_projectiles
end
def update_projectiles
@projectiles.delete_if do |proj|
proj.update
proj.disposed?
end
until $game_temp.map_projectiles.empty?
new_proj = Sprite_MapProj.new(@viewport1, $game_temp.map_projectiles.pop)
@projectiles.push(new_proj)
end
end
alias theo_mproj_dispose dispose
def dispose
theo_mproj_dispose
dispose_projectiles
end
def dispose_projectiles
@projectiles.each do |proj|
proj.dispose
end
end
def get_character(game_char)
@character_sprites.each do |sprite|
return sprite if sprite.character == game_char
end
return nil
end
end
class Scene_Map
attr_reader :spriteset
end