Main Menu
  • Welcome to The RPG Maker Resource Kit.

help on proper disposal of windows?

Started by shintashi, June 04, 2011, 02:09:09 AM

0 Members and 1 Guest are viewing this topic.

shintashi

So I've got this method called "end_chant_select" and it loads here with the push of the enter key:


    if Input.trigger?(13) #Enter key for casting
        for i in 0..27
          if @fragment_1.term == $data_chants[i].name
            #p $data_chants[i].id
            @chant = $data_chants[i]
          else
            @chant = $data_chants[0]
             $game_system.se_play($data_system.buzzer_se)
          end
        end
      if @chant.scope == 1
        start_enemy_select
      else # elsif @skill.scope == 3 or @skill.scope == 5
        end_chant_select
        start_actor_select
      end   
    end


The problem is when the actor is selected and the action phases kick in to use their action, here:


def make_chant_action_result
     if @fragment_1.term == $data_chants[1].name
        @active_battler.animation_id = 39 #(earth 1)
       
    elsif @fragment_1.term == $data_chants[7].name
      @active_battler.animation_id = 28 #(fire 2)
    else
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
  end



I get "undefined method 'term' for nil:NilClass, because by the time the spell is ready to cast, I've already erased its container here:


  #--------------------------------------------------------------------------
  # * End Chant Selection - added by shintashi
  #--------------------------------------------------------------------------
  def end_chant_select
    if @chant_window != nil       
      @chant_window.dispose
      @chant_window = nil
    end
    @chant_command.dispose #ccom0.2
    @chant_command = nil #ccom0.3
    if @chant_help != nil       
      @chant_help.dispose #chnt1.2
      @chant_help = nil #chnt1.3
    end
    @fragment_1.dispose #frag1.2
    @fragment_1 = nil #frag1.3
    @fragment_2.dispose #frag2.2
    @fragment_2 = nil #frag2.3
    @fragment_3.dispose #frag3.2
    @fragment_3 = nil #frag3.3
    @fragment_4.dispose #frag4.2
    @fragment_4 = nil #frag4.3
    @fragment_5.dispose #frag5.2
    @fragment_5 = nil #frag5.3
    @fragment_6.dispose #frag6.2
    @fragment_6 = nil #frag6.3
    # Hide help window
    @help_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end


but if I don't erase the container, the windows stick around and make a mess of my screen. I was told not to over use globals, but I don't know where to store the "@fragment_1.term" data otherwise. I'm going to need up to 18 different terms stored some place, but the instantiation system of Ruby and programming like it is a bit lost on me.

shintashi

crap

I just realized when doing a global...


    # Set animation ID (castor or target) **LETS START HERE**
      if $matrix[1] == $data_chants[1].id
     #if @fragment_1.term == $data_chants[1].name
        @active_battler.animation_id = 39 #(earth 1)

      elsif $matrix[1] == $data_chants[7].id
    #elsif @fragment_1.term == $data_chants[7].name
      @active_battler.animation_id = 28 #(fire 2)


The 'most recent' logged spell effect becomes the standard effect cast by all mages, because the storage unit isn't specific... Hmnn. I think I've run into this problem before with my "use item". At least I got rid of the nil error.

shintashi

I just realized the battle item resolution can't work because it uses the wielder's equipment for determining who's casting what. So if Jane has a staff of lightning and Bob has a shield of dragon conjuring, Jane will always cast lightning and Bob will always conjure dragons...

But unless I do something with "@active_battler = $game_party.actors[@actor_index]" my global is going to be changed with every caster.

So if I say

Bob Casts lightning
Dave Casts Fireball
Sara casts Cure

Then the current setup is going to do the following:

Bob Casts Cure
Dave casts Cure
Sara casts Cure

Because Cure is the last information to go into the storage container...

this is all happening because RMXP is not only turn based, but waits for all actions to be declared before rearranging them in order from highest agility to lowest agility. During this resorting, my spell info is being lost.

shintashi

so i think i need to create a multidimensional array that assigns a matrix.id to the super or whatever a multidimensional array is called.

so if we know matrix[0] = [a,b,c]
and matrix[3] = [a,d,f]

both represent example matrices, and we know something like the "a" in matrix[a] has to equal
$game_party.actors[@actor_index], then (now im getting lost...) we have something like

matrix[$game_party.actors[@actor_index]] = [a,b,c]

and then we can pull this info by saying something like

active_matrix = matrix[$game_party.actors[@actor_index]]

then pull bits of info out like this

spell_range = active_matrix[0]
spell_duration = active_matrix[1]
spell_damage = active_matrix[2]

Of course, this doesn't fully appreciate the overlap different terms will have, but it gets closer (not that this pseudo code would work, but its getting closer)

shintashi

it's looking a lot like Mr. MO's Hash thing might work.

for example, he does something like this:



RANGE_SKILLS = {}
# RANGE_SKILLS[Skill_ID] = [Range, Speed, Character Set, Mash Time(in seconds), Kick Back(in tiles)]
RANGE_SKILLS[7] = [10, 5, "Magic Balls", 3, 1]
RANGE_SKILLS[13] = [15, 10, "Ammo", 3, 0]
RANGE_SKILLS[69] = [10, 4, "Shuriken", 2, 0]


class MrMo_ABS

  def RANGE_SKILLS
    return RANGE_SKILLS
  end

end



which can be then accessed through stuff like this:


if $ABS.RANGE_SKILLS[my_variable] != nil
p $ABS.RANGE_SKILLS[my_variable][0]
End


What I don't understand is why "class MrMo_ABS" becomes "$ABS" and how the whole hash set up works outside the class, but then has to be defined inside the class. How would this be set up differently from a multidimensional array, i.e.,

a = array[x][y]