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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
| #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/ ? SBS Tankentai ADD-DON - [Lusitano] Cover ? VX ?
#_/ ? Version 2.1 ?
#_/ ? by Flipsomel ?
#_/-----------------------------------------------------------------------------
#_/ Extra credit:
#_/ - Kal, i used his way of accessing the skill user id
#_/
#_/ Features:
#_/ Defines actors that will take damage in place of an ally via state.
#_/ Does not work for monsters.
#_/
#_/ Mini-faq:
#_/ > The protector stats are used to calculate the damage when covering ally.
#_/ > Items and healing spells affect the target, not the protector
#_/
#_/
#_/----------------------------------------------------------------------------
#_/ Cover Types:
#_/ 1 -> cover target from all physical attacks
#_/ 2 -> cover all physical attacks, with a given chance
#_/ 3 -> cover all physical attacks, if target hp percentage bellow
#_/ 4 -> cover all physical and magic attacks
#_/ 5 -> cover all physical and magic attacks, with a given chance
#_/ 6 -> cover all physical and magic attacks, if target hp percentage bellow
#_/
#_/----------------------------------------------------------------------------
#_/ How to use:
#_/
#_/ > Add to the state notebox: <COVER cover_type cover_param>
#_/
#_/ replace cover_type for the the desired cover type
#_/ replace cover_param for the the desired param
#_/ Setup examples:
#_/
#_/ > cover ally always : <COVER 1 0>
#_/ > 50% chance of physically cover ally: <COVER 2 50>
#_/ > cover phys and mag damage if ally hp is at 20%: <COVER 3 20>
#_/
#_/----------------------------------------------------------------------------
#_/ Where to install:
#_/ Above Main, after the battle system.
#_/----------------------------------------------------------------------------
#_/ Compatible:
#_/ Done and tested for SBS3.4e + ATB 1.2c
#_/-----------------------------------------------------------------------------
#_/
#_/ !ATTENTION! : don't forget to check remove state at end of battle, or
#_/ bad stuff will occur!
#_/-----------------------------------------------------------------------------
#_/
#_/ Version Log:
#_/ 1.0 - Started Script, defender takes damage for protected, pops damage
#_/ 1.1 - Added sprite movement
#_/ 1.2 - Corrected some bugs regarding damage and skill effects
#_/ 2.0 - Added more cover types
#_/ 2.1 - Added protected battler animation
#_/
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#------------------------------------------------------------------------------
# Cover SEQUENCE
# If you know how to use takentai action sequences you can edit this one.
# Please take into account that the script places the defender in the covered
# ally position, no matter what COVER_RESET does.
# COVER_RESET is only used to make the battler stand in place for a time, and
# then return to his original start position.
#
# BUG NOTE:
# Sometimes the defender turn starts before he can execute
# "Start Pos Return", and will stay in the ally being defended spot until
# he is called to defend again. You can add "Start Pos Return" to your
# "COMMAND_INPUT" and this will no longer occur.
# In the next version i will adress this issue, when i have the time z.z
#------------------------------------------------------------------------------
module N01
COVERSCRIPT_SEQUENCE = {
"COVER_RESET" => ["30","Start Pos Return","FLEE_RESET"],
"BE_COVERED" => ["EVADE_JUMP","20","Start Pos Return","FLEE_RESET"]
}
ACTION.merge!(COVERSCRIPT_SEQUENCE)
end
#==============================================================================
# [ State
#==============================================================================
class RPG::State
attr_accessor :skill_user
end
#used by Scene_battle
class Spriteset_Battle
attr_accessor :actor_sprites
#returns the position of the battler in actor_sprites array
def pos_in_sprite_array(battler_id)
for i in 0...actor_sprites.size
if actor_sprites[i].battler.id == battler_id
return i
end
end
return -1
end
end
#access to spriteset
class Scene_Battle < Scene_Base
attr_accessor :spriteset
end
#==============================================================================
# [ Game_Battler
#==============================================================================
class Game_Battler
alias lusitano_cover_old_initialize initialize
def initialize
lusitano_cover_old_initialize #calls old initialize
@covered = nil #flag, true if actor battler os being protected
@protector = 0 # id of battler who is protecting
@protector_spr_id = 0 # id of battler sprite in $scene.spriteset.actor_sprites
@cover_type = 0 # type of cover (physical, magical, both, bellow %hp
@cover_param = 0 # second param for cover ( chance, hp%, etc.)
@is_covering = nil # flag, true if actor is covering another battler
end
alias cover_skill_effect skill_effect
def skill_effect(user, skill)
@skill_user = user
cover_skill_effect(user, skill)
end
#--------------------------------------------------------------------------
# ? check_for_state_extensions
# sees if the added state has extensions defined
# state_id : position of state in the $data_states[] array
#--------------------------------------------------------------------------
def LUS_COVER_check_for_state_extensions(state_id)
return unless @states.include?(state_id)
$data_states[state_id].note.each_line { |line|
case line
when /<(?:cover|COVER)\s*(\d+)\s*(\d+)>/i
@cover_type = $1.to_i
@cover_param = $2.to_i
@covered = true
@protector = $data_states[state_id].skill_user.id
#$game_actors[@protector].set_covering
@protector_spr_id = $scene.spriteset.pos_in_sprite_array(@protector)
return true
end
}
end
#--------------------------------------------------------------------------
# ? alias add_state
# checks for element modifiers
# state_id : position of state in the $data_states[] array
#--------------------------------------------------------------------------
alias add_state_lus_cover add_state
def add_state(state_id)
state = $data_states[state_id]
state.skill_user = @skill_user
add_state_lus_cover(state_id)
LUS_COVER_check_for_state_extensions(state_id)
#checks if self was selected to cover self
remove_state_lus_cover(state_id) if @protector == self.id
end
#--------------------------------------------------------------------------
# ? alias remove_state
# resets affliction type to 1 if state was an afliction
# state_id : position of state in the $data_states[] array
#--------------------------------------------------------------------------
alias remove_state_lus_cover remove_state
def remove_state(state_id)
#checks and reverts to the old weapon_animation_id
if LUS_COVER_check_for_state_extensions(state_id) == true
@cover_type = 0
@covered = false
@protector = nil
@protector_spr_id = 0
@cover_param = 0
end
remove_state_lus_cover(state_id)
end
#--------------------------------------------------------------------------
# * Checks if type of cover allows the battler to be covered
# cover_type : type of cover
# Returns true if battler checks conditions for being covered
#--------------------------------------------------------------------------
def can_be_Covered
# if protector is dead...
if $game_actors[@protector].dead? && @states.size > 0
#check wich state will be removed
for state in @states
if LUS_COVER_check_for_state_extensions(state.id) == true
remove_state(state.id)
end
end
return false
end
#checks type of cover
case @cover_type
when 1,4 #protect physical damage
return true
when 2,5
chance = rand(100) #chance of being covered
return false unless chance >= @cover_param
return true
when 3,6 # if hp is bellow the setting
return false unless ((self.hp.to_f / self.maxhp.to_f) * 100) <= @cover_param
return true
else
return false
end
end
#--------------------------------------------------------------------------
# * Apply State Changes
# obj : Skill, item, or attacker
#--------------------------------------------------------------------------
alias lus_cover_apply_state_changes apply_state_changes
def apply_state_changes(obj)
if @covered == true
#checks if battler can be covered
return if can_be_Covered
end
lus_cover_apply_state_changes(obj)
end
#--------------------------------------------------------------------------
# * Calculation of Damage From Normal Attack
# attacker : Attacker
# The results are substracted added to @hp_damage
# @hp_damage Will be used by execute_damage
#--------------------------------------------------------------------------
alias lusitano_cover_mk_atk_dam make_attack_damage_value
def make_attack_damage_value(attacker)
#calculates de HP_DAMAGE the user would receive
# this is a call to the original make_attack_damage_value
lusitano_cover_mk_atk_dam(attacker)
#checks if user is being covered
return unless @covered == true
#checks if battler can be covered
return unless can_be_Covered
@hp_damage = 0 # takes no hp damage
#calculates the damage value
$game_actors[@protector].make_attack_damage_value(attacker)
#executes hp change
$game_actors[@protector].execute_damage(attacker)
#pops protector damage
#$scene.spriteset.actor_sprites[@protector_spr_id].damage_pop($game_actors[@protector].hp_damage)
cover_sprite_movement
end # end of method
#--------------------------------------------------------------------------
# * Calculation of Damage From OBJ
# user : user (game_battler)
# The results are substracted added to @hp_damage or @mp_damage
# @hp_damage Will be used by execute_damage
#--------------------------------------------------------------------------
alias lusitano_cover_make_obj_damage_value make_obj_damage_value
def make_obj_damage_value(user, obj)
lusitano_cover_make_obj_damage_value(user, obj)
return unless @hp_damage > 0 && obj.is_a?(RPG::Skill)
return unless obj.physical_attack || @cover_type > 3
#checks if user is being covered
return unless @covered == true
#checks if battler can be covered
return unless can_be_Covered
@hp_damage = 0 # takes no hp damage
#calculates the damage value
$game_actors[@protector].make_attack_damage_value(user)
#executes hp change
$game_actors[@protector].execute_damage(user)
#defender sprite animation
cover_sprite_movement
$game_actors[@protector].apply_state_changes(obj)
end
#--------------------------------------------------------------------------
# * Cover Sprite Movement
# Handles the sprite animation for cover event
#--------------------------------------------------------------------------
def cover_sprite_movement
#$scene is Scene_Battle
#actor_sprites is sprite_battler
#makes battler do be_covered_action
self_sprite_id = $scene.spriteset.pos_in_sprite_array(self.id)
action = $game_actors[self.id].be_covered_action
$scene.spriteset.set_action(true, self_sprite_id, action)
#makes defender jump to spot!
$game_actors[@protector].change_base_position(self.position_x, self.position_y)
# $game_actors[@protector].position_y = self.position_y
#sets return sequence
action = $game_actors[@protector].cover_action
$scene.spriteset.set_action(true, @protector_spr_id, action)
#pops defender damage
$scene.spriteset.actor_sprites[@protector_spr_id].damage_pop($game_actors[@protector].hp_damage)
#pop alternative ( i should check this later)
#@spriteset.set_damage_pop(actor, member.index, mp_damage)
# damage_num is from the actors interpreter, it forces and pops the damage
# but takes a while to take place so it is not a good alternative
# $game_actors[@protector].damage_num($game_actors[@protector].hp_damage)
end
#returns the cover_action
def cover_action
return "COVER_RESET"
end
#returns the be covered action
def be_covered_action
return "BE_COVERED"
end
end |