Class: Game_ActionResult

Inherits:
Object
  • Object
show all
Defined in:
Game_ActionResult.rb

Overview

** Game_ActionResult


This class handles the results of battle actions. It is used internally for

the Game_Battler class.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Game_ActionResult) initialize(battler)


  • Object Initialization




30
31
32
33
# File 'Game_ActionResult.rb', line 30

def initialize(battler)
  @battler = battler
  clear
end

Instance Attribute Details

- (Object) added_buffs

added buffs



24
25
26
# File 'Game_ActionResult.rb', line 24

def added_buffs
  @added_buffs
end

- (Object) added_debuffs

added debuffs



25
26
27
# File 'Game_ActionResult.rb', line 25

def added_debuffs
  @added_debuffs
end

- (Object) added_states

added states



22
23
24
# File 'Game_ActionResult.rb', line 22

def added_states
  @added_states
end

- (Object) critical

critical flag



15
16
17
# File 'Game_ActionResult.rb', line 15

def critical
  @critical
end

- (Object) evaded

evaded flag



14
15
16
# File 'Game_ActionResult.rb', line 14

def evaded
  @evaded
end

- (Object) hp_damage

HP damage



17
18
19
# File 'Game_ActionResult.rb', line 17

def hp_damage
  @hp_damage
end

- (Object) hp_drain

HP drain



20
21
22
# File 'Game_ActionResult.rb', line 20

def hp_drain
  @hp_drain
end

- (Object) missed

missed flag



13
14
15
# File 'Game_ActionResult.rb', line 13

def missed
  @missed
end

- (Object) mp_damage

MP damage



18
19
20
# File 'Game_ActionResult.rb', line 18

def mp_damage
  @mp_damage
end

- (Object) mp_drain

MP drain



21
22
23
# File 'Game_ActionResult.rb', line 21

def mp_drain
  @mp_drain
end

- (Object) removed_buffs

removed buffs/debuffs



26
27
28
# File 'Game_ActionResult.rb', line 26

def removed_buffs
  @removed_buffs
end

- (Object) removed_states

removed states



23
24
25
# File 'Game_ActionResult.rb', line 23

def removed_states
  @removed_states
end

- (Object) success

success flag



16
17
18
# File 'Game_ActionResult.rb', line 16

def success
  @success
end

- (Object) tp_damage

TP damage



19
20
21
# File 'Game_ActionResult.rb', line 19

def tp_damage
  @tp_damage
end

- (Object) used


  • Public Instance Variables




12
13
14
# File 'Game_ActionResult.rb', line 12

def used
  @used
end

Instance Method Details

- (Object) added_state_objects


  • Get Added States as an Object Array




88
89
90
# File 'Game_ActionResult.rb', line 88

def added_state_objects
  @added_states.collect {|id| $data_states[id] }
end

- (Object) clear


  • Clear




37
38
39
40
41
# File 'Game_ActionResult.rb', line 37

def clear
  clear_hit_flags
  clear_damage_values
  clear_status_effects
end

- (Object) clear_damage_values


  • Clear Damage Values




55
56
57
58
59
60
61
# File 'Game_ActionResult.rb', line 55

def clear_damage_values
  @hp_damage = 0
  @mp_damage = 0
  @tp_damage = 0
  @hp_drain = 0
  @mp_drain = 0
end

- (Object) clear_hit_flags


  • Clear Hit Flags




45
46
47
48
49
50
51
# File 'Game_ActionResult.rb', line 45

def clear_hit_flags
  @used = false
  @missed = false
  @evaded = false
  @critical = false
  @success = false
end

- (Object) clear_status_effects


  • Clear Status Effects




78
79
80
81
82
83
84
# File 'Game_ActionResult.rb', line 78

def clear_status_effects
  @added_states = []
  @removed_states = []
  @added_buffs = []
  @added_debuffs = []
  @removed_buffs = []
end

- (Boolean) hit?


  • Determine Final Hit


Returns:

  • (Boolean)


107
108
109
# File 'Game_ActionResult.rb', line 107

def hit?
  @used && !@missed && !@evaded
end

- (Object) hp_damage_text


  • Get Text for HP Damage




113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'Game_ActionResult.rb', line 113

def hp_damage_text
  if @hp_drain > 0
    fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
    sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
  elsif @hp_damage > 0
    fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
    sprintf(fmt, @battler.name, @hp_damage)
  elsif @hp_damage < 0
    fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
    sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
  else
    fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
    sprintf(fmt, @battler.name)
  end
end

- (Object) make_damage(value, item)


  • Create Damage




65
66
67
68
69
70
71
72
73
74
# File 'Game_ActionResult.rb', line 65

def make_damage(value, item)
  @critical = false if value == 0
  @hp_damage = value if item.damage.to_hp?
  @mp_damage = value if item.damage.to_mp?
  @mp_damage = [@battler.mp, @mp_damage].min
  @hp_drain = @hp_damage if item.damage.drain?
  @mp_drain = @mp_damage if item.damage.drain?
  @hp_drain = [@battler.hp, @hp_drain].min
  @success = true if item.damage.to_hp? || @mp_damage != 0
end

- (Object) mp_damage_text


  • Get Text for MP Damage




131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'Game_ActionResult.rb', line 131

def mp_damage_text
  if @mp_drain > 0
    fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
    sprintf(fmt, @battler.name, Vocab::mp, @mp_drain)
  elsif @mp_damage > 0
    fmt = @battler.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
    sprintf(fmt, @battler.name, Vocab::mp, @mp_damage)
  elsif @mp_damage < 0
    fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
    sprintf(fmt, @battler.name, Vocab::mp, -@mp_damage)
  else
    ""
  end
end

- (Object) removed_state_objects


  • Get Removed States as an Object Array




94
95
96
# File 'Game_ActionResult.rb', line 94

def removed_state_objects
  @removed_states.collect {|id| $data_states[id] }
end

- (Boolean) status_affected?


  • Determine Whether Some Sort of Status (Parameter or State) Was Affected


Returns:

  • (Boolean)


100
101
102
103
# File 'Game_ActionResult.rb', line 100

def status_affected?
  !(@added_states.empty? && @removed_states.empty? &&
    @added_buffs.empty? && @added_debuffs.empty? && @removed_buffs.empty?)
end

- (Object) tp_damage_text


  • Get Text for TP Damage




148
149
150
151
152
153
154
155
156
157
158
# File 'Game_ActionResult.rb', line 148

def tp_damage_text
  if @tp_damage > 0
    fmt = @battler.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
    sprintf(fmt, @battler.name, Vocab::tp, @tp_damage)
  elsif @tp_damage < 0
    fmt = @battler.actor? ? Vocab::ActorGain : Vocab::EnemyGain
    sprintf(fmt, @battler.name, Vocab::tp, -@tp_damage)
  else
    ""
  end
end