Jump to content
Rpg²S Forum

Mon

Utenti
  • Posts

    12
  • Joined

  • Last visited

Posts posted by Mon

  1. Grazie tante per l'impegno, ho preferito non dir nulla per tutto questo tempo per impegnarmi anch'io, XD... ebbene dopo vari cervellamenti credo di aver raggiunto il mio obbiettivo, lo spiegherò qui di seguito se mai qualcun'altro voglia fare una cosa simile.

     

    Prima di tutto, ecco come si è evoluto il primo script, chiaramente richiamandolo con "New_Event.new(x, y)"; ho in seguito "disattivato" character name/hue per provare se funzionava anche con tile_id.

    class New_Event
      def initialize(x, y)
        # id event
        map_ev = $game_map.events
        for i in 1...map_ev.size+2
          if not map_ev.keys.include?(i)
            id = i
            break
          end
        end
        ev = RPG::Event.new(x, y)
        ev.id = id
        ev.name = "CreatoScript"
        ev.pages = [RPG::Event::Page.new]
        # pages
        ev.pages[0].move_type = 0
        ev.pages[0].move_speed = 3
        ev.pages[0].move_frequency = 3       
        ev.pages[0].move_route = RPG::MoveRoute.new
        ev.pages[0].walk_anime = true
        ev.pages[0].step_anime = false
        ev.pages[0].direction_fix = false
        ev.pages[0].through = false
        ev.pages[0].always_on_top = false
        ev.pages[0].trigger = 0
        # condition
        ev.pages[0].condition = RPG::Event::Page::Condition.new
        ev.pages[0].condition.switch1_valid = false
        ev.pages[0].condition.switch2_valid = false
        ev.pages[0].condition.variable_valid = false
        ev.pages[0].condition.self_switch_valid = false
        # graphic
        ev.pages[0].graphic = RPG::Event::Page::Graphic.new
        ev.pages[0].graphic.tile_id = 398
        #ev.pages[0].graphic.character_name = "183-Rock02"
        #ev.pages[0].graphic.character_hue = 0
        ev.pages[0].graphic.direction = 2
        ev.pages[0].graphic.pattern = 0
        ev.pages[0].graphic.opacity = 255
        ev.pages[0].graphic.blend_type = 0
        # command
        ev.pages[0].list = Array.new(2, RPG::EventCommand.new)
        ev.pages[0].list[0].code = 250
        ev.pages[0].list[0].indent = 0
        audio = RPG::AudioFile.new("157-Skill01", 80, 100)
        ev.pages[0].list[0].parameters = [audio]
        # game map
        $game_map.event_new(id, ev)
      # end initialize
      end
    # end New_Event
    end
    

    Ho poi creato un "def" in Game_Map...

      #--------------------------------------------------------------------------
      # * Event New
      #--------------------------------------------------------------------------
      def event_new(id, ev)
        @map.events[id] = ev
        @events[id] = Game_Event.new(@map_id, @map.events[id])
        refresh
      end
    

    Arrivato a questo punto non dava errori, l'evento era tangibile e ci si potevo interagire, creato il comando del suono apposita per constatare ciò... però risultava invisibile, così ho pensato di dover pasticciare con "Spriteset_Map", infatti...

     

    Ho aggiunto questo prima dell'update degli sprite.

        if not $game_map.events.size+1 == @character_sprites.size
          refresh
        end
    

    Ecco invece il comando per aggiornare gli sprite.

      #--------------------------------------------------------------------------
      # * refresh
      #--------------------------------------------------------------------------
      def refresh
        @character_sprites = [@character_sprites[@character_sprites.size-1]]
        s = 0
        for i in $game_map.events.keys.sort
          sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
          @character_sprites.insert(s, sprite)
          s += 1
        end
      end
    

    Inoltre va precisato che l'evento creato sparirà una volta cambiato mappa, quindi bisognerà ricrearlo se serve più volte, questa è solo una prova, per capire come crearlo... ci tengo a precisare che sono tutte cose che ho imparato per esperienza, spulciando su internet si trova poco o niente, quindi se si potesse fare la stessa cosa ma meglio, beh, basta che funzioni, o no?

     

    Se qualcuno provandolo trova dei bug o simili, mi avvisi, grazie, lo stesso farò anch'io.

  2. class CreaEve
      def initialize(x, y)
        # event
        me = $game_map.events
        for i in 1...me.size
          if not me.keys.include?(i)
            id = i
            break
          end
        end
        print("#{id}\n#{$game_map.events.keys.include?(id)}")
        ev = RPG::Event.new(x, y)
        ev.id = id
        ev.name = "CreatoScript"
        ev.pages = [RPG::Event::Page.new]
        # pages
        ev.pages[0].condition = RPG::Event::Page::Condition.new
        ev.pages[0].graphic = RPG::Event::Page::Graphic.new
        ev.pages[0].move_type = 0
        ev.pages[0].move_speed = 3
        ev.pages[0].move_frequency = 3       
        ev.pages[0].move_route = RPG::MoveRoute.new
        ev.pages[0].walk_anime = true
        ev.pages[0].step_anime = false
        ev.pages[0].direction_fix = false
        ev.pages[0].through = false
        ev.pages[0].always_on_top = false
        ev.pages[0].trigger = 3
        ev.pages[0].list = [RPG::EventCommand.new]
        # condition
        ev.pages[0].condition.switch1_valid = false
        ev.pages[0].condition.switch2_valid = false
        ev.pages[0].condition.variable_valid = false
        ev.pages[0].condition.self_switch_valid = false
        # graphic
        ev.pages[0].graphic.tile_id = 0
        ev.pages[0].graphic.character_name = "Graphics/Characters/183-Rock02"
        ev.pages[0].graphic.character_hue = 0
        ev.pages[0].graphic.direction = 2
        ev.pages[0].graphic.pattern = 0
        ev.pages[0].graphic.opacity = 255
        ev.pages[0].graphic.blend_type = 0
        # game map
        me[id] = ev
        print("#{id}\n#{me.keys.include?(id)}")
        #$game_map.refresh
      end
    end
    

    Uhm... tranquillo, grazie comunque per avermi fatto capire di più il funzionamento, infatti non avevo preso in cosiderazione che eliminando alcuni eventi l'ID massimo disponibile non è pari al numero di eventi presenti (o magari +1), ecco perchè quel for all'inizio.

     

    Effettivamente nel primo print, il codice suggerito da te, prima mi da false poi true, segno che l'evento non c'era poi c'è... eppure non cambia, mi da comunque l'errore dello starting, provando lo stesso vale con update e refresh, ma se risulta che esiste, perchè accade ciò? Mah.

  3. class CreaEve
      def initialize(x, y)
        # event
        id = $game_map.events.size
        ev = RPG::Event.new(x, y)
        ev.id = id
        ev.name = "CreatoScript"
        ev.pages = [RPG::Event::Page.new]
        # pages
        ev.pages[0].condition = RPG::Event::Page::Condition.new
        ev.pages[0].graphic = RPG::Event::Page::Graphic.new
        ev.pages[0].move_type = 0
        ev.pages[0].move_speed = 3
        ev.pages[0].move_frequency = 3       
        ev.pages[0].move_route = RPG::MoveRoute.new
        ev.pages[0].walk_anime = true
        ev.pages[0].step_anime = false
        ev.pages[0].direction_fix = false
        ev.pages[0].through = false
        ev.pages[0].always_on_top = false
        ev.pages[0].trigger = 0
        ev.pages[0].list = [RPG::EventCommand.new]
        # condition
        ev.pages[0].condition.switch1_valid = false
        ev.pages[0].condition.switch2_valid = false
        ev.pages[0].condition.variable_valid = false
        ev.pages[0].condition.self_switch_valid = false
        # graphic
        ev.pages[0].graphic.tile_id = 0
        ev.pages[0].graphic.character_name = "Graphics/Characters/183-Rock02"
        ev.pages[0].graphic.character_hue = 0
        ev.pages[0].graphic.direction = 2
        ev.pages[0].graphic.pattern = 0
        ev.pages[0].graphic.opacity = 255
        ev.pages[0].graphic.blend_type = 0
        # game map
        $game_map.events[id] = ev
        #$game_map.refresh
      end
    end
    

    Salve, mi sarebbe molto comodo poter creare un evento da script, ho utilizzato il codice mostrato sopra ma... mi dice che il valore "starting" dell'evento non è valido, ho anche provato ad aggiungere "ev.strarting = " sia con false che con true ma niente, lo stesso con "ev.clear_starting"... ho momentaneamente disattivato "$game_map.refresh" per risolvere un problema alla volta.

     

    Sapreste aiutarmi? Grazie.

  4. Scusate necroposting ma tra i vari script che promettevano la stessa cosa, questo è stato l'unico che mi ha funzionato come si deve, però aveva alcuni difettucci che poi ho sistemato quindi mi sembra giusto condividere il mio perfezionamento... poi magari, continuando ad utilizzarlo mi rendo conto di altri errori, ma per ora pensiamo all'uso base; inoltre aggiungo che in passato l'avevo già provato ma commisi l'errore di aggiungere gli script in cima, mentre invece vanno subito sopra "main".

     

    Va modificato solamente MOUSE3_2

     

     

     

    #==============================================================================
    # ** Window_MenuStatus
    #==============================================================================
    class Window_MenuStatus < Window_Selectable
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 116
    end
    end
    #==============================================================================
    # ** Window_Target
    #==============================================================================
    class Window_Target < Window_Selectable
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 105
    end
    end
    #==============================================================================
    # ** Window_BattleReserve
    #==============================================================================
    class Window_BattleReserve < Window_Selectable
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 105
    end
    end
    #==============================================================================
    # ** Window_EquipRight
    #==============================================================================
    class Window_EquipRight < Window_Selectable
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 32
    end
    #--------------------------------------------------------------------------
    # * Mouse Oh
    #--------------------------------------------------------------------------
    def mouse_oh
    return 0
    end
    end
    #==============================================================================
    # ** Window_Message
    #==============================================================================
    class Window_Message < Window_Selectable
    #--------------------------------------------------------------------------
    # * Mouse Oh
    #--------------------------------------------------------------------------
    def mouse_oh
    return $game_temp.choice_start * 32
    end
    end
    #==============================================================================
    # ** Window_Party
    #==============================================================================
    class Window_Party < Window_Selectable
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 52
    end
    end
    #==============================================================================
    # ** Window_Menu
    #==============================================================================
    class Window_Menu < Window_Selectable
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 32
    end
    end
    #==============================================================================
    # ** Window_ActorCommand
    #==============================================================================
    class Window_ActorCommand < Window_Selectable
    #--------------------------------------------------------------------------
    # * Update
    #--------------------------------------------------------------------------
    def update
    if $mouse_sprite.visible
    # if Mouse sleectable, active, at least 1 item and non-negative index
    if self.mouse_selectable && self.active && @item_max > 0 && @index >= 0
    # Get / check mouse position
    mouse_x, mouse_y = *Mouse.position
    if mouse_x.between?(self.x, self.x + self.width) &&
    mouse_y.between?(self.y, self.y + self.height)
    # Calculates mouse position within window
    mouse_x -= self.x
    mouse_y -= self.y
    # Subtracts widnow padding and overhead
    mouse_x -= @window_padding
    mouse_y -= @window_padding - self.mouse_oh
    # Look through all items
    for i in 0...@item_max
    ix,iy = @positions
    if mouse_x.between?(ix, ix + 32) && mouse_y.between?(iy, iy + self.oh)
    if i != @index
    $game_system.se_play($data_system.cursor_se)
    end
    @index = i
    break
    end
    end
    end
    end
    end
    super
    end
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 32
    end
    end
    #==============================================================================
    # ** Window_NameInput
    #==============================================================================
    class Window_NameInput < Window_Base
    #--------------------------------------------------------------------------
    # * Default Settings
    #--------------------------------------------------------------------------
    Default_Mouse_Selectable = true
    Default_Window_Padding = 16
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :mouse_selectable
    attr_accessor :window_padding
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias_method :shaz_mouseselectable_wndslct_init, :initialize
    alias_method :shaz_mouseselectable_wndslct_update, :update
    #--------------------------------------------------------------------------
    # ● Initialize the Name Input window
    #--------------------------------------------------------------------------
    def initialize
    # Original Initialization
    shaz_mouseselectable_wndslct_init
    # Set Mouse Selectable Flag
    @mouse_selectable = Default_Mouse_Selectable
    @window_padding = Default_Window_Padding
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
    # if mouse selectable, visible, active, and non-negative index
    if $mouse_sprite.visible && self.mouse_selectable && self.active &&
    @index >= 0
    # Get mouse position
    mouse_x, mouse_y = *Mouse.position
    # If mouse within window
    if mouse_x.between? (self.x, self.x + self.width) &&
    mouse_y.between? (self.y, self.y + self.height)
    # Calculates mouse X and Y positions within window
    mouse_x -= self.x; mouse_y -= self.y
    # Subtracts window padding
    mouse_x -= @window_padding; mouse_y -= @window_padding
    # Subtracts mouse oh
    mouse_y -= self.mouse_oh
    # Gets cursor width
    cursor_width = 28
    # If not Submit button, pass through all items
    if mouse_x.between?(428, 428+48) && mouse_y.between?(9*32, 9*32+32)
    $game_system.se_play($data_system.cursor_se) if @index != 180
    @index = 180
    else
    for i in 0..90
    # Calculate index position
    x = 140 + i / 5 / 9 * 180 + i % 5 * 32
    y = i / 5 % 9 * 32
    # If mouse between rect
    if mouse_x.between?(x, x + cursor_width) &&
    mouse_y.between?(y, y + self.oh)
    # set index
    prev_index = @index
    @index = i
    if prev_index != @index
    $game_system.se_play($data_system.cursor_se)
    end
    break
    end
    end
    end
    end
    end
    # Original update
    shaz_mouseselectable_wndslct_update
    end
    #--------------------------------------------------------------------------
    # * Oh
    #--------------------------------------------------------------------------
    def oh
    return 32
    end
    #--------------------------------------------------------------------------
    # * Mouse Oh
    #--------------------------------------------------------------------------
    def mouse_oh
    return 0
    end
    end
    #==============================================================================
    # ** Scene_File
    #==============================================================================
    class Scene_File
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias_method :sephlamchop_mousesys_scnfl_update, :update
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
    # agf = hide mouse
    if $mouse_sprite.visible == true
    # If Mouse Position isn't Nil
    if Mouse.pos != nil
    # Gets Mouse Position
    x, y = Mouse.pos
    y = y + 32
    # Pass Through Savefile Windows
    for i in 0...@savefile_windows.size
    # Gets Window
    w = @savefile_windows
    # Don't allow user to select autosave slot in Load Menu
    if @autosave_slot == false
    i = 1 if i == 0
    end
    # If Within Window Range
    if x.between?(w.x, w.x + w.width) &&
    y.between?(w.y, w.y + w.height) && w.active
    prev_index = @file_index
    # Set File Index
    @file_index = i
    # Turns Window On
    w.selected = true
    # Play SE
    if prev_index != @file_index
    $game_system.se_play($data_system.cursor_se)
    end
    # Unhighlight remaining windows
    for j in 0...@savefile_windows.size
    if j != i
    @savefile_windows[j].selected = false
    end
    end
    # Don't select autosave slot in Load Menu
    if @autosave_slot == false
    @savefile_windows[0].selected = false if i == 1
    end
    # Break Main Loop
    break
    end
    end
    end
    end
    # Original Update
    sephlamchop_mousesys_scnfl_update
    end
    end
    #==============================================================================
    # ** Game_Battler
    #==============================================================================
    class Game_Battler
    #--------------------------------------------------------------------------
    # * Battler Width
    #--------------------------------------------------------------------------
    def battler_width
    return RPG::Cache.battler(@battler_name, @battler_hue).width
    end
    #--------------------------------------------------------------------------
    # * Battler Height
    #--------------------------------------------------------------------------
    def battler_height
    return RPG::Cache.battler(@battler_name, @battler_hue).height
    end
    end
    #==============================================================================
    # ** Arrow_Enemy
    #==============================================================================
    class Arrow_Enemy < Arrow_Base
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias_method :seph_mouseselectablewindows_arrenmy_update, :update
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
    # Original Update
    seph_mouseselectablewindows_arrenmy_update
    if $mouse_sprite.visible == true
    # Return if Nil Mouse Position
    return if Mouse.position.nil?
    # Gets Mouse Position
    mx, my = *Mouse.position
    # Pass Through Enemies
    $game_troop.enemies.each do |enemy|
    # Skip if Non-Existing Enemy
    next unless enemy.exist?
    # Gets Paddings
    w, h = enemy.battler_width / 2, enemy.battler_height
    # If Within Mouse Padding Range
    if mx.between?(enemy.screen_x - w, enemy.screen_x + w) &&
    my.between?(enemy.screen_y - h, enemy.screen_y + 10)
    # Set Index
    @index = $game_troop.enemies.index(enemy)
    # Set mouse cursor to bitmap
    $mouse_sprite.set_bitmap(MouseCursor::Enemy_Cursor)
    return
    # break
    end
    end
    # Set Mouse to Default Cursor
    $mouse_sprite.set_bitmap(MouseCursor::Default_Cursor)
    end
    end
    end
    #==============================================================================
    # ** Arrow_Actor
    #==============================================================================
    class Arrow_Actor < Arrow_Base
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias_method :seph_mouseselectablewindows_arractr_update, :update
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
    # Original Update
    seph_mouseselectablewindows_arractr_update
    # Return if Nil Mouse Position
    return if Mouse.position.nil?
    # Gets Mouse Position
    mx, my = *Mouse.position
    # Pass Through Actors
    $game_party.actors.each do |actor|
    # Gets Paddings
    w, h = actor.battler_width / 2, actor.battler_height
    # If Within Mouse Padding Range
    if mx.between?(actor.screen_x - w, actor.screen_x + w) &&
    my.between?(actor.screen_y - h, actor.screen_y + 10)
    # Set Index
    @index = $game_party.actors.index(actor)
    end
    end
    end
    end
    #==============================================================================
    # ** Scene_Map
    #==============================================================================
    class Scene_Map
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias_method :sephlamchop_mousesys_scnmap_update, :update
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
    # Unless Message Showing
    unless $game_temp.message_text
    # Update Event Cursors
    $mouse_sprite.update_event_cursors
    end
    # Original Update
    sephlamchop_mousesys_scnmap_update
    end
    end
    #==============================================================================
    # ** Interpreter
    #==============================================================================
    class Interpreter
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias_method :shaz_mousesys_intrprtr_command_101, :command_101
    #--------------------------------------------------------------------------
    # * Show Text
    #--------------------------------------------------------------------------
    def command_101
    # return mouse sprite to default cursor
    $mouse_sprite.set_bitmap(MouseCursor::Default_Cursor)
    # original command_101
    shaz_mousesys_intrprtr_command_101
    end
    end
    $mouse_sprite = Sprite_Mouse.new
    # game mouse is visible, system mouse is hidden
    $mouse_sprite.visible = true

     

     

     

    La finestra dell'equipaggiamento non mi funzionava proprio, il cursore non mi selezionava le armature rimanendo fermo sul primo equipaggiamento, mi è bastato modificare 2 numeri e va benissimo.

     

    Un'altra cosa strana era che nel menù, quando si selezionavano i PG, il cursore andava al PG successivo con un minimo movimento, mentre adesso ho sistemato in modo che deve trovarsi sopra al PG per selezionarlo.

     

    Ah, un'ultima cosa, oltre ad un icona "Arrow", ne serve un'altra chiamata "Arrow4" per le battaglie... mentre le precedenti, 2 e 3, non ho idea se servono.

     

    Mi scuso ancora se vado contro regolamento ma mi sembrava comunque giusto condividere la cosa, spero quindi di essere stato utile a qualcuno.

  5. Grazie davvero tanto Giver... specifico in caso altri abbiamo il mio stesso problema: ridando uno sguardo agli script da te menzionati (specifico che sono stati i primi a cui ho dato uno sguardo) non ci ho guadagnato nulla, XD, ho voluto crearmi un battle system da 0 invece che modificare quello attuale (infatti ho in mente di richiamarlo manualmente, attraverso evento) è perchè ci capisco ancora troppo poco; ciò che mi ha aperto gli occhi è stato quando hai detto che probabilmente c'è un problema sul come viene richiamato troop_update.

     

    Praticamente ho creato l'array "@enemies" in "def initialize", invece che ricrearla di continuo (andando ad aggiornare la grafica), a quanto pare facendo così mi azzerava anche lo stato dei nemici, per massima chiarezza posto le parti dello script interessate (anche perchè per intero è davvero lungo).

     

    def initialize
    
        # troop->enemies
        @enemies = []
        @troop = $data_troops[$troop]
        
        for i in 0...@troop.members.size
          
          if $data_enemies[@troop.members[i].enemy_id] != nil
            @enemies.push(Game_Enemy.new($troop, i))
          end
          
        end
    
    
    end

    Do il valore desiderato a "$troop" prima di richiamare lo script.

     

    Mentre lo script inizialmente mostrato è diventato:

    def troop_update(troop_id)
        
        i = 4
        
        while i < 8
          @dx[i].contents.clear
          i += 1
        end
        
        # troop->enemies; spazio disponibile 148x114
        
        for i in 0...@troop.members.size
          
          img = RPG::Cache.battler(@enemies[i].battler_name, @enemies[i].battler_hue)
          
          # grafic
          @rect = Rect.new(0, 0, @dx[i+4].width, @dx[i+4].height)
          @dx[i+4].contents.blt(0, 0, img, @rect)
          
          hp = (@enemies[i].hp.to_f*100/@enemies[i].maxhp.to_f).ceil
          
          if hp >= 51 && hp <= 100
            clrhp = Color.new(0, 255, 0, 255)
          elsif hp >= 21 && hp <= 50
            clrhp = Color.new(255, 125, 0, 255)
          else
            clrhp = Color.new(255, 0, 0, 255)
          end
          
          sp = (@enemies[i].sp.to_f*100/@enemies[i].maxsp.to_f).ceil
          
          if sp >= 51 && sp <= 100
            clrsp = Color.new(0, 0, 255, 255)
          elsif sp >= 21 && sp <= 50
            clrsp = Color.new(255, 0, 255, 255)
          else
            clrsp = Color.new(125, 0, 125, 255)
          end
          
          # name
          @dx[i+4].contents.draw_text(0, 0, @dx[i+4].width - 32, 20, @enemies[i].name, 2)
          
          @dx[i+4].contents.font.size = 15
          @dx[i+4].contents.font.color = @clrbs
          
          # hp
          @dx[i+4].contents.fill_rect(0, 95, 70, 15, Color.new(0, 125, 0, 255))
          @dx[i+4].contents.fill_rect(0, 95, (0.7*hp).ceil, 15, clrhp)
          @dx[i+4].contents.draw_text(0, 95, 70, 15, @enemies[i].hp.to_s+"/"+@enemies[i].maxhp.to_s, 1)
          
          # sp
          @dx[i+4].contents.fill_rect(72, 95, 70, 15, Color.new(0, 0, 125, 255))
          @dx[i+4].contents.fill_rect(72, 95, (0.7*sp).ceil, 15, clrsp)
          @dx[i+4].contents.draw_text(72, 95, 70, 15, @enemies[i].sp.to_s+"/"+@enemies[i].maxsp.to_s, 1)
          
          # color e size standart
          @dx[i+4].contents.font.color = @clrbs
          @dx[i+4].contents.font.size = @szbs
          
        end
        
      # end troop_update
      end

    Ho fatto varie prove e così funziona, i danni, o comunque i cali, agli hp restano memorizzati; speriamo di non incappare in altri problemi simili.

  6. Va bene, ecco:

     

      #--------------------------------------------------------------------------
      # * Change Enemy HP
      #--------------------------------------------------------------------------
      def command_331
        # Get operate value
        value = operate_value(@parameters[1], @parameters[2], @parameters[3])
        # Process with iterator
        iterate_enemy(@parameters[0]) do |enemy|
          # If HP is not 0
          if enemy.hp > 0
            # Change HP (if death is not permitted then change HP to 1)
            if @parameters[4] == false and enemy.hp + value <= 0
              enemy.hp = 1
            else
              enemy.hp += value
            end
          end
        end
        # Continue
        return true
      end
  7. Sto impazzendo da giorni, mi sono studiato rigo per rigo OGNI script inserito di base nel programma e non sono riuscito a capire come risolvere; dal mio ultimo topic ho imparato tantissimo, infatti sto portando avanti un progettino carino, con un battle system semplice senza grosse pretese ma... non riesco a fargli memorizzare i danni ai singoli nemici, sono riuscito a capire come far apparire gli "Troop" specifici ed utilizzo questo script, creato da me prendendo spunto spulciando gli script base:

     


    def troop_update(troop_id)
        
        i = 4
        
        while i < 8
          @dx[i].contents.clear
          i += 1
        end
        
        # troop->enemies; spazio disponibile 148x114
        @enemies = []
        troop = $data_troops[troop_id]
        
        for i in 0...troop.members.size
          
          if $data_enemies[troop.members[i].enemy_id] != nil
            @enemies.push(Game_Enemy.new(troop_id, i))
          end
          
          img = RPG::Cache.battler(@enemies[i].battler_name, @enemies[i].battler_hue)
          
          # grafic
          @rect = Rect.new(0, 0, @dx[i+4].width, @dx[i+4].height)
          @dx[i+4].contents.blt(0, 0, img, @rect)
          
          hp = (@enemies[i].hp.to_f*100/@enemies[i].maxhp.to_f).ceil
          
          if hp >= 51 && hp <= 100
            clrhp = Color.new(0, 255, 0, 255)
          elsif hp >= 21 && hp <= 50
            clrhp = Color.new(255, 125, 0, 255)
          else
            clrhp = Color.new(255, 0, 0, 255)
          end
          
          sp = (@enemies[i].sp.to_f*100/@enemies[i].maxsp.to_f).ceil
          
          if sp >= 51 && sp <= 100
            clrsp = Color.new(0, 0, 255, 255)
          elsif sp >= 21 && sp <= 50
            clrsp = Color.new(255, 0, 255, 255)
          else
            clrsp = Color.new(125, 0, 125, 255)
          end
          
          # name
          @dx[i+4].contents.draw_text(0, 0, @dx[i+4].width - 32, 20, @enemies[i].name, 2)
          
          @dx[i+4].contents.font.size = 15
          @dx[i+4].contents.font.color = @clrbs
          
          # hp
          @dx[i+4].contents.fill_rect(0, 95, 70, 15, Color.new(0, 125, 0, 255))
          @dx[i+4].contents.fill_rect(0, 95, (0.7*hp).ceil, 15, clrhp)
          @dx[i+4].contents.draw_text(0, 95, 70, 15, @enemies[i].hp.to_s+"/"+@enemies[i].maxhp.to_s, 1)
          
          # sp
          @dx[i+4].contents.fill_rect(72, 95, 70, 15, Color.new(0, 0, 125, 255))
          @dx[i+4].contents.fill_rect(72, 95, (0.7*sp).ceil, 15, clrsp)
          @dx[i+4].contents.draw_text(72, 95, 70, 15, @enemies[i].sp.to_s+"/"+@enemies[i].maxsp.to_s, 1)
          
          # color e size standart
          @dx[i+4].contents.font.color = @clrbs
          @dx[i+4].contents.font.size = @szbs
          
        end
        
      # end troop_update
      end

    Graficamente è ancora da studiare quindi non fateci caso, come dicevo ciò che mi sta bloccando è come danneggiare gli hp dei nemici, con "@enemies.hp" mi visualizza gli hp attuali del nemico, se provo a fare, per esempio:

     

    @enemies.hp -= 100

     

    La variabile "@enemies.hp" cambia solo in primo momento ma poi torna ad essere pari a "@enemies.maxhp", quindi come è possibile rendere il calcolo definitivo? A dirla tutta avrei decine di idee alternative ma sarebbe mille volte più comodo sfruttare/mutare ciò che il programma già ti presenta, avendo visto varie cose carine, mi manca solo capire questa cosa... spero si sia capito, grazie!

     

  8. Assolutamente non la prendo a male, anzi, più cose imparo meglio è; è proprio questo il mio scopo, lo script fatto è solo una prova per simulare un script vero e proprio che potrebbe servirmi in futuro... infatti l'HUD mi intriga parecchio, me lo studio un pò in questi giorni, ora ho mal di testa (non centra nulla lo script) e non mi sembra il caso scervellarmi, XD

  9. Dopo tante visual finalmente una risposta! XD Grazie.

     

    Comunque si, con "eliminare la bitmap" intendevo utilizzare "content.clear".

     

    Ho visto nella guida presente nel programma ed è "fill_rect" ma la situazione non cambia, si aggiunge un comodo sfondo alla scritta ma si comporta comunque allo stesso modo.

    Studiando gli altri script del programma ho provato anche con le immagini invece del testo, sempre inserendole in una window ma si ripete il fastidio ma anzi ho capito una cosa in più per nulla positiva, dopo un pò sparisce anche l'ultima cosa mostrata, quindi da come ho capito le window hanno una scadenza, spariscono da sole dopo un pò se lo script si ferma.

     

    Quindi alla fine sono arrivato alla conclusione che è meglio utilizzare il classico "show picture" presente tra i comandi base ma la comodità degli script è incredibile, esiste quindi un codice per richiamare quel comando da script? Per ora ho trovato solamente il comando per impostare switch e variabili, intendo proprio quelle standart del progetto.

  10. Specifico che ho fatto ricerche in ogni luogo, universo, molecolare e via dicendo, senza risultati ovviamente; intanto copio ed incollo il mio script per intero, tanto è corto, sto facendo varie prove per capire come scriptare.

     



    class Variabili_Testo
    def main
    if not defined? $a
    $a = 5
    end
    @window1 = Window_Base.new(3, 3, 70, 55)
    @window1.opacity = 0
    @window1.contents = Bitmap.new(35, 20)
    text1 = $a.to_s
    if $a < 10
    text1 = "0"+text1
    end
    if $a < 100
    text1 = "0"+text1
    end
    @window1.contents.draw_text(0, 0, 35, 20, text1, 1)
    mio_file = File.new("Txt/testlettura.txt", "r+")
    txt = []
    i = 0
    while riga = mio_file.gets
    txt = riga
    i += 1
    end
    txt2 = txt[0].split("")
    print (txt2[1]+txt2.length.to_s)
    File.open "Txt/testscrittura.txt", "w" do |mio_file|
    mio_file.puts "Scrivo"
    end
    # Restore BGM and BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
    end
    end

     

     

    L'ho messo tutto per sicurezza ma ciò su cui dovete porre maggior attenzione è @window1.contents.draw_text(0, 0, 35, 20, text1, 1) .

     

    Praticamente la mia intenzione è mettere a schermo un valore che viene modificato da un evento per click (ora per provare), visto che ci sono vi riporto anche questo; metterò in grassetto ciò che viene "creato" attraverso comandi standart e non script.

     


    $scene = Variabili_Testo.new

    Wait: 1 frame(s)

    $a += 1

    $game_variables[1] = $a
    Text: \v[1]

     

     

    Praticamente aumento la variale di 1, poi alcuni passaggi per farmelo mostrare su testo; questa è una prova per vedere come interagiscono script ed eventi.

     

    Tutto questo ma il problema è alla fonte, ogni volta che il valore della variabile viene aggiornato, i numeri a schermo inizialmente vengono scritti uno sopra l'altro, solo dopo un pò resta solamente l'ultimo, quindi immagino che sia semplice da risolvere per chi se ne intende, per farla breve: com'è possibile evitare che si scrivono uno su l'altro e che quindi viene mostrato subito solamente l'ultimo valore? Ho provato ad eliminare prima la finestra, poi il bitmap e dopo avviare il comando ma non cambia nulla. Grazie mille a chi almeno proverà ad aiutarmi.

×
×
  • Create New...