Jump to content
Rpg²S Forum

makgyver

Utenti
  • Posts

    175
  • Joined

  • Last visited

Posts posted by makgyver

  1. Mi da un errore con il file table

    Mmmm ke errore ti da?? strano xke se è nella cartella giusta al posto giusto dovrebbe andare...

     

    EDIT: eh si ovvio.. beh crea un evento ke ti da dei soldi e sei a posto per provare!!

  2. ho provato a convertirlo guardando qua e la codici del VX spero funzioni o ti dia errori facilmente risolvibili:

     

     

    class Game_Interpreter
     attr_accessor :weapon
     attr_accessor :armor
     def take_armors
    @weapon = {}
    @armor = {}
    @weapon.default = nil
    @armor.default = nil
    for actor in $game_party.members
      actor.equip(0, 0)
      actor.equip(1, 0)
    end
    for weapon in 1...$data_weapons.size
      if $game_party.item_number($data_weapons[weapon]) > 0
    	@weapon[weapon] = n = $game_party.item_number($data_weapons[weapon])
    	$game_party.lose_item($data_weapons[weapon], n)
      end
    end
    for armor in 1...$data_armors.size
      if $game_party.item_number($data_armors[armor]) > 0
    	@armor[armor] = n = $game_party.item_number($data_armors[armor])
    	$game_party.lose_item($data_armors[armor], n)
      end
    end
     end
     
     def give_armors
    for i in 1..$data_weapons.size
      if @weapon[i] != nil
    	$game_party.gain_item($data_weapons[i], @weapon[i])
      end
    end
    for i in 1..$data_armors.size
      if @armor[i] != nil
    	$game_party.gain_item($data_weapons[i], @armor[i])
      end
    end
    @weapon = nil
    @armor = nil
     end
    end

     

     

     

  3. Descrizione:

    Questo script, correlato di immagini, vi permetterà di inserire nel vostro RPG uno dei giochi più famosi del mondo, il Blackjack con tanto di regole ufficiali.

     

    Autore:

    IO (makgyver)

     

    Screen:

    Ecco come si presenta graficamente(non è perfetto ma sono uno scripter non un grafico!!):

    Versione 1.1 :

    http://i35.tinypic.com/2hp29ds.jpg

     

    Versione 2.1

    http://i34.tinypic.com/f00qz4.jpg

     

    Allegati:

    Questa cartella ke si chiama Cards deve essere messa nella cartella Pictures:

    Versione 1.1 (Il file da 3 MB):

    http://www.mediafire.com/?sharekey=f7d49b1...2db6fb9a8902bda

     

    Versione 2.0 (Il file con data 29/09):

    http://www.mediafire.com/?sharekey=f7d49b1...2db6fb9a8902bda

     

    Script:

    Versione 1.1:

     

     

    class Card < Sprite
     attr_accessor :face_up
     def initialize(sign, num, fup)
    super(Viewport.new(0,0,640,480))
    @value = num
    @sign = sign
    @name = sign+num.to_s 
    @face_up = (fup)? false : true
    turn
    move(0,0)
    self.z = 100000
    self.opacity = 255
     end
     
     def turn
    @face_up = (@face_up)? false : true
    self.bitmap = RPG::Cache.picture("Cards/"+((@face_up)? @name : "retro"))
     end
     
     def real_value
    return @value
     end
     
     def value
    return @value if @value <= 10
    return 10
     end
     
     def move(x, y)
    self.x = x
    self.y = y
     end
     
     def clone
    card = Card.new(@sign, @value, @face_up)
    card.x = self.x
    card.y = self.y
    return card
     end
    end
    
    class BJ_Table < Sprite
     def initialize(bet = 0)
    super(Viewport.new(0,0,640,480))
    self.bitmap = RPG::Cache.picture("Cards/table")
    self.x = 0
    self.y = 0
    self.z = 1
     end
    end
    
    class BJ_Table_text < Window_Base
     attr_accessor :bet
     attr_accessor :done
     def initialize(bet = 0)
    super(0,0,640,480)
    self.contents = Bitmap.new(640,480)
    self.windowskin = nil
    self.z = 1
    @bet = bet
     end
     
     def fiches
    x = 73
    y = 364
    bitmap = RPG::Cache.picture("Cards/fiches")
    cw = bitmap.width 
    ch = bitmap.height 
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x -cw/2 , y -ch/2 , bitmap, src_rect)
    self.contents.font.color = Color.new(255,255,255)
    self.contents.draw_text(50, 390, 100, 32, @bet.to_s+" "+$data_system.words.gold)
     end
     
     def update(tv, pv1, pv2 = -1)
    self.contents.clear
    self.contents.font.color = Color.new(0,0,255)
    self.contents.draw_text(128, 300, 50, 32, pv1.to_s)
    self.contents.draw_text(440, 256, 50, 32, pv2.to_s) if pv2 != -1
    self.contents.font.color = Color.new(255,0,0)
    self.contents.draw_text(263, 12, 50, 32, tv.to_s)
    fiches if @done
     end
    end
    
    class Window_Bet < Window_Base
     attr_accessor :done
     attr_accessor :bet
     def initialize(min, max = 0, inc_min = 10, inc_max = 100)
    super(-250,155,250,140)
    self.contents = Bitmap.new(width-32, height-32)
    @min_bet = min
    @max_bet = max
    @can_play = can_play
    @inc_min = inc_min
    @inc_max = inc_max
    @bet = @min_bet
    @done = false
    #enter
    refresh
     end
     
     def can_play
    return $game_party.gold >= @min_bet
     end 
     
     def new_game
    @done = false
    @bet = @min_bet
    @can_play = can_play
    enter
    refresh
     end
     
     def refresh
    self.contents.clear
    if (@can_play)
      self.contents.draw_text(20, 10, 220, 32, "Quanto punti?")
      self.contents.draw_text(80, 50, 200, 32, @bet.to_s+" "+$data_system.words.gold)
    else
      self.contents.draw_text(20, 10, 220, 32, "Non hai abbastanza soldi!!")
    end
     end
     
     def exit
    div = 10
    for i in 0...div
      self.x -= 250 / div
      Graphics.update
    end
     end
     
     def enter
    div = 10
    for i in 0...div
      self.x += 250 / div
      Graphics.update
    end
     end
     
     def update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      if @can_play
    	$game_party.lose_gold(@bet)
    	@done = true
    	exit
      else
    	$scene = Scene_Map.new
      end
    end
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      if ($game_party.gold - @inc_min - @bet >= 0)
    	if @bet + @inc_min <= @max_bet or @max_bet == 0
    	  @bet += @inc_min
    	else
    	  @bet = @max_bet
    	end
      end
    end
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      if (@bet - @inc_min > @min_bet)
    	@bet -= @inc_min
      else
    	@bet = @min_bet
      end
    end
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      if ($game_party.gold - @inc_max - @bet >= 0)
    	if @bet + @inc_max <= @max_bet or @max_bet == 0
    	  @bet += @inc_max
    	else
    	  @bet = @max_bet
    	end
      end
    end
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      if (@bet - @inc_max > @min_bet)
    	@bet -= @inc_max
      else
    	@bet = @min_bet
      end
    end
    refresh
     end
    end
    
    class Window_Player < Window_Selectable
     attr_accessor :entered
     def initialize
    super(-170, 155, 170, 160)
    @commands = ["Carta!", "Mi fermo!", "Sdoppio", "Raddoppio."]
    @item_max = @commands.size
    self.contents = Bitmap.new(width - 32, @item_max * 32 )
    refresh
    self.index = 0
     end
     
     def enter
    div = 10
    for i in 0...div
      self.x += 170/div
      Graphics.update
    end
     end
     
     def exit
    div = 10
    for i in 0...div
      self.x -= 170 / div
      Graphics.update
    end
     end
     
     def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
     end
     
     def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(18, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
     end
     
     def disabled_option(index)
    draw_item(index, disabled_color)
     end
    end
    
    class Window_Result < Window_Base
     attr_accessor :blackjack
     attr_accessor :winner
     def initialize
    super(150,150,300,130)
    self.contents = Bitmap.new(width-32, height-32)
    self.visible = false
    @blackjack = false
    @winner = -1
    self.y = 100
     end
     
     def refresh
    self.contents.clear
    if @winner == 0
      text = "Il banco vince!!"
    elsif @winner == 2
      text = "Pareggio!!"
    else
      text = "Hai vinto!!"
    end
    if @blackjack == false
      self.contents.draw_text(20, 30, 150, 32, text)
    else
      text1 = (@winner == 0)? "Il banco fa BlackJack!!" : "Hai fatto BlackJack!!"
      self.contents.draw_text(20, 20, 200, 32, text1)
      self.contents.draw_text(20, 60, 200, 32, text)
    end
     end
    end
    
    class BlackJack
     def initialize(min = 10, max = 1000, inc_min = 10, inc_max = 100, bmax = 16)
    @min_bet = min
    @max_bet = max
    @inc_min = inc_min
    @inc_max = inc_max
    @bank_max = bmax
     end
     
     def init_deck
    @cards = {}
    @cards.default = nil
    x = 20
    count = 0
    for s in ["c","f","p","q"]
      for i in 1..13
    	index = s.to_s+i.to_s
    	@cards[index] = Card.new(s, i, false)
    	@cards[index].move(20+count*3, 18)
    	count += 1
      end
    end
     end
     
     def new_game(bool = true)
    Graphics.transition
    discard_deck if bool
    init_deck
    @player_window.exit
    @player_window.dispose
    @window_bet.new_game if bool
    @result_window.visible = false
    @player_window = Window_Player.new
    @player_cards1 = []
    @player_cards2 = []
    @table_cards = []
    @player_value1 = 0
    @player_value2 = -1
    @table_value = 0
    @double = 0
    @entered = false
    @split = false
    @hands = 1
    @BJ = false
    @winner = -1
     end
     
     def main
    @table = BJ_Table.new
    @table_text = BJ_Table_text.new
    @window_bet = Window_Bet.new(@min_bet, @max_bet, @inc_min, @inc_max)
    @player_window = Window_Player.new
    @result_window = Window_Result.new
    new_game(false)
    Graphics.transition
    @window_bet.enter
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
    	break
      end
    end
    @window_bet.dispose
    @player_window.dispose
    @result_window.dispose
    @table_text.dispose
    @table.dispose
     end
     
     def control_value
    @table_value = 0
    @player_value1 = 0
    @player_value2 = 0 if @split
    for c in @table_cards
      @table_value += c.value if c.face_up
    end
    for c in @player_cards1
      @player_value1 += c.value
    end
    if (@split)
      for c in @player_cards2
    	@player_value2 += c.value
      end
    end
    #
    for c in @table_cards
      if c.value == 1 and @table_value + 10 <= 21
    	@table_value += 10 if c.face_up
      end
    end
    for c in @player_cards1
      if c.value == 1 and @player_value1 + 10 <= 21
    	@player_value1 += 10
      end
    end
    if (@split)
      for c in @player_cards2
    	if c.value == 1 and @player_value2 + 10 <= 21
    	@player_value2 += 10
      end
      end
    end
     end
     
     def update
    control_value
    @table_text.bet = ((@split)? 2 : 1)*@window_bet.bet + @double*@window_bet.bet
    @table_text.done = @window_bet.done
    @table_text.update(@table_value, @player_value1, @player_value2)
    if @result_window.visible
      result_update
    elsif @window_bet.done
      if @entered == false
    	give_card(1, true)
    	put_card(1)
    	refresh
    	Graphics.transition
    	give_card(0, true)
    	put_card(0)
    	refresh
    	Graphics.transition
    	give_card(1, true)
    	put_card(1)
    	refresh
    	Graphics.transition
    	give_card(0, false)
    	put_card(0)
    	refresh
    	Graphics.transition
    	@player_window.enter 
    	@entered = true
      else
      player_update
    end
    else
    @window_bet.update
    end
     end
     
     def give_card(who, face_up)
    if who == 0
      bool = false
      while not bool
    	sign = ""
    	case random(4)
    	  when 1
    	sign = "c"
    	  when 2
    	sign = "f"
    	  when 3
    	sign = "p"
    	  when 4
    	sign = "q"
    	end
    	index = sign+random(13).to_s
    	bool = @cards[index] != nil
    	card = @cards[index].clone if bool
      end
      @cards[index] = nil
      card.turn if face_up
      @table_cards[@table_cards.size] = card
      @table_value += card.value if face_up
    else
      bool = false
      while not bool
    	case random(4)
    	  when 1
    	sign = "c"
    	  when 2
    	sign = "f"
    	  when 3
    	sign = "p"
    	  when 4
    	sign = "q"
    	end
    	index = sign+random(13).to_s
    	bool = @cards[index] != nil
    	card = @cards[index].clone if bool
      end
      @cards[index].dispose
      @cards[index] = nil
      card.turn if face_up
      if @hands == 1
    	@player_cards1[@player_cards1.size] = card
    	@player_value1 += card.value
      else
    	@player_cards2[@player_cards2.size] = card
    	@player_value2 += card.value
      end
    end
    refresh
    put_card(who)
     end
    
     def discard_deck
    for i in 0...@player_cards1.size
      @player_cards1[i].dispose
    end
    for i in 0...@player_cards2.size
      @player_cards2[i].dispose
    end
    for i in 0...@table_cards.size
      @table_cards[i].dispose
    end
    for s in ["c","f","p","q"]
      for i in 1..13
    	index = s.to_s+i.to_s
    	@cards[index].dispose if @cards[index] != nil
      end
    end
     end
     
     def refresh
    count = 0
    for s in ["c","f","p","q"]
      for i in 1..13
    	if @cards[s.to_s+i.to_s] != nil
    	  @cards[s.to_s+i.to_s].move(20+count*3, 18)
    	  count += 1
    	end
      end
    end
     end
     
     def put_card(who)
    if who == 0
      @table_cards[@table_cards.size-1].move(318 + (@table_cards.size-1)*30, 22)
    else
      if @hands == 1
    	@player_cards1[@player_cards1.size-1].move(182 + (@player_cards1.size-1)*30, 309)
      else
    	@player_cards2[@player_cards2.size-1].move(422 + (@player_cards2.size-1)*30, 309)
      end
    end
     end
     
     def random(n)
    times = rand(10)
    result = 0
    for i in 0...times
      result = rand(n)
    end
    return result + 1
     end
     
     def player_update
    @player_window.disabled_option(2) if not can_split?
    @player_window.disabled_option(3) if not can_double?
    if (@player_value1 == 21 and @player_cards1.size == 2) or (@hands == 2 and @player_value2 == 21 and @player_cards2.size == 2)
      @BJ = true
    end
    if ((@hands == 1) and (@split == false) and (@player_value1 >= 21)) or ((@hands == 2) and (@player_value2 >= 21))
      table_turn
    end
    @player_window.update
    if Input.trigger?(Input::B)
    end
    if Input.trigger?(Input::C)
      case @player_window.index
    	when 0
    	  give_card(1, true)
    	  put_card(1)
    	  refresh
    	  Graphics.update
    	  Graphics.transition
    	when 1
    	  if (@hands == 2 and @split or @split == false)
    		table_turn
    	  else
    		@hands = 2
    	  end
    	when 2
    	  do_split if can_split?
    	when 3
    	  do_double if can_double?
      end
    end
     end
     
     def do_double
    @double += 1
    give_card(1, true)
    put_card(1)
    $game_party.lose_gold(@window_bet.bet)
    refresh
    Graphics.update
    Graphics.transition
    if (@hands == 2 or (@hands == 1 and @split == false))
      table_turn
    else 
      @hands = 2
    end
     end
     
     def table_turn
    if (@hands == 1 and @player_value1 > 21) or (@hands == 2 and @player_value1 > 21 and @player_value2 > 21)
      @player_window.exit
      @result_window.blackjack = false
      @result_window.winner = 0
      @result_window.refresh
      @result_window.visible = true
      return
    end
    @table_cards[1].turn
    refresh
    Graphics.transition
    control_value
    stop = @table_value >= @bank_max
    while not stop
      give_card(0, true)
      put_card(0)
      refresh
      Graphics.transition
      control_value
      stop = @table_value >= @bank_max
    end
    if @table_value > 21
      @winner = 1
      $game_party.gain_gold((@window_bet.bet*1.5).floor) 
      $game_party.gain_gold((@window_bet.bet*1.5).floor) if (@hands == 2 and @player_value2 < 21)
    else
      if (@hands == 1 and @player_value1 < @table_value)
    	@winner = 0
      elsif (@hands == 2 and @player_value1 < @table_value and @player_value2 < @table_value)
    	@winner = 0
      elsif (@hands == 1 and @player_value1 == @table_value)
    	@winner = 2
      elsif (@hands == 2 and @player_value1 == @table_value and @player_value2 == @table_value)
    	@winner = 2
      else
    	@winner = 1
      end
      $game_party.gain_gold((@window_bet.bet*(1.5+((@BJ and @winner==1)? 0.5 : 0))).floor) if (@player_value1 > @table_value)
      $game_party.gain_gold((@window_bet.bet*(1.5+((@BJ and @winner==1)? 0.5 : 0))).floor) if (@hands == 2 and @player_value2 > @table_value)
      $game_party.gain_gold(@window_bet.bet) if (@player_value1 == @table_value)
      $game_party.gain_gold(@window_bet.bet) if (@hands == 2 and @player_value2 == @table_value)
    end
    if @winner == 0
      @BJ = ((@table_cards.size == 2)and(@table_value == 21))
    end
    @player_window.exit
    @result_window.blackjack = @BJ
    @result_window.winner = @winner
    @result_window.refresh
    @result_window.visible = true
     end
     
     def do_split
    @player_cards2[0] = @player_cards1.pop
    @player_cards2[0].move(420, 309)
    @player_value2 = @player_cards2[0].value
    @player_value1 -= @player_cards2[0].value
    $game_party.lose_gold(@window_bet.bet)
    @split = true
     end
     
     def can_split?
    if ((has_money?) and (@split == false) and (@player_cards1.size == 2) and (@player_cards1[0].real_value == @player_cards1[1].real_value))
      return true
    end
    return false
     end
     
     def has_money?
    return $game_party.gold - @window_bet.bet >= 0
     end
     
     def can_double?
    return ($game_party.gold - @window_bet.bet) >= 0
     end
     
     def result_update
    if Input.trigger?(Input::C) or Input.trigger?(Input::B)
      $game_system.se_play($data_system.decision_se)
      @result_window.visible = false
      new_game
    end
     end
    end

     

     

     

    Versione 2.1

     

    module BJ_MODULE
     NO_MONEY = ["Non hai abbastanza soldi.","Non puoi più giocare.","Arrivederci!"]
     DRAW = ["Pareggio.","Nessuno la spunta.","Facciamone un altra!?","Per un pelo..."]
     LOSE = ["Il banco vince.","Hai perso.","Ti è andata male.","Riprova, sarai più fortunato."]
     WIN = ["Hai vinto!", "Complimenti!", "Oggi si festeggia!","E' il tuo giorno fortunato!"]
     BJ_LOSE = ["Il banco fa BlackJack.","Oggi non è giornata."]
     BJ_WIN = ["Hai fatto BlackJack!","21 vittoria grande baldoria!", "21, 21 e ancora 21!!","La fortuna?Me la sono portata da casa!"]
    end
    
    class Card < Sprite
     attr_accessor :face_up
     def initialize(sign, num, fup)
    super(Viewport.new(0,0,640,480))
    @height = 95
    @width = 72
    @value = num
    @sign = sign
    @name = sign+num.to_s 
    @face_up = (fup)? false : true
    turn
    move(0,0)
    self.z = 100000
    self.opacity = 255
     end
    
     def turn
    @face_up = (@face_up)? false : true
    if @face_up == true
      self.bitmap = RPG::Cache.picture("Cards/"+@sign+"littlecards")
      start = (@value % 2 == 1)? 0 : @width+1
      self.src_rect.set(start, (((@value-1)/2).floor)*@height, @width, @height)
    else
      self.bitmap = RPG::Cache.picture("Cards/"+"littleretro")
    end
     end
     
     def real_value
    return @value
     end
     
     def value
    return @value if @value <= 10
    return 10
     end
     
     def move(x, y, bool = false)
    if bool
      div = 5
      incx = (x-self.x)/div
      incy = (y-self.y)/div
      for i in 0...div
    	self.x += incx
    	self.y += incy
    	Graphics.update
      end
    end
    self.x = x
    self.y = y
     end
     
     def clone
    card = Card.new(@sign, @value, @face_up)
    card.x = self.x
    card.y = self.y
    return card
     end
    end
    
    class BJ_Table < Sprite
     def initialize(s = "")
    super(Viewport.new(0,0,640,480))
    self.bitmap = RPG::Cache.picture("Cards/table"+s)
    self.x = 0
    self.y = 0
    self.z = 1
     end
    end
    
    class BJ_Help < Window_Base
     def initialize
    super(-200,36,200, 64)
    self.contents = Bitmap.new(width-32, height-32)
    #refresh
     end
     
     def refresh(bool = true)
    if bool == false
      self.width = 400
      self.contents = Bitmap.new(width-32, height-32)
      self.contents.draw_text(18, 0, 400, 32, random_choise(BJ_MODULE::NO_MONEY))
    else
      self.width = 200
      self.contents = Bitmap.new(width-32, height-32)
      self.contents.draw_text(18, 0, 200, 32, "Quanto punti?")
    end
     end
     
     def random_choise(vett)
    return vett[random(vett.size)]
     end
     
     def random(n)
    times = rand(10)
    result = 0
    for i in 0...times
      result = rand(n)
    end
    return result
     end
     
     def exit
    div = 10
    for i in 0...div
      self.x -= 200 / div
      Graphics.update
    end
    self.x = -200
     end
     
     def enter
    div = 10
    for i in 0...div
      self.x += 200 / div
      Graphics.update
    end
    self.x = 0
     end
    end
    
    class BJ_Table_text < Window_Base
     attr_accessor :gold_start
     attr_accessor :bet
     attr_accessor :done
     attr_accessor :fiches_num
     attr_accessor :arrow_pos
     def initialize(bet = 0)
    super(0,0,640,480)
    self.contents = Bitmap.new(640,480)
    self.windowskin = nil
    self.z = 1
    @bet = bet
    @fiches_num = {}
    @fiches_num.default = 0
    @arrow_pos = -1
    @gold_start = -1
     end
     
     def fiches
    x = 63
    y = 346
    count = 0
    bitmap = RPG::Cache.picture("Cards/fiches")
    cwh = 40 
    for index in [10, 25, 50, 100, 500]
      if fiches_num[index] != 0
      for i in 0...fiches_num[index]
    	src_rect = Rect.new(count*40, 0, cwh, cwh)
    	incx = (count <= 1)? 40*count : 40*(count-2)-20
    	incy = (count >= 2)? 50 : 0
    	self.contents.blt(x -cwh/2+incx, y -cwh/2 -i*2 + incy, bitmap, src_rect)
      end
      end
      count += 1
    end
    self.contents.font.color = Color.new(255,255,255)
    self.contents.draw_text(52, 413, 100, 32, @bet.to_s+" "+$data_system.words.gold)
     end
     
     def arrow
    return if (arrow_pos == -1)
    bitmap = RPG::Cache.picture("Cards/arrow")
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    y = 234
    if (arrow_pos == 1)
      x = 205
      self.contents.blt(x -cw/2, y -ch/2, bitmap, src_rect)
    else
      x = 409
      self.contents.blt(x -cw/2, y -ch/2, bitmap, src_rect)
    end
     end
     
     def gold_bar
    bitmap = RPG::Cache.picture("Cards/goldbar_empty")
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    x = 155
    y = 378
    self.contents.blt(x -cw/2, y -ch/2, bitmap, src_rect)
    if (@gold_start < $game_party.gold)
      bitmap = RPG::Cache.picture("Cards/goldbar_full")
      cw = bitmap.width
      ch = bitmap.height
    else	
      bitmap = RPG::Cache.picture("Cards/goldbar")
      cw = bitmap.width
      ch = bitmap.height*$game_party.gold/@gold_start
    end
    src_rect = Rect.new(0, 88-ch, cw, ch)
    self.contents.blt(x -cw/2, y+44-ch, bitmap, src_rect)
    self.contents.font.color = Color.new(255,255,0)
    self.contents.draw_text(148, 420, 30, 32, $data_system.words.gold)
     end
     
     def update(tv, pv1, pv2 = -1)
    self.contents.clear
    self.contents.font.color = Color.new(0,0,255)
    self.contents.draw_text(253, 248, 50, 32, pv1.to_s)
    self.contents.draw_text(460, 248, 50, 32, pv2.to_s)  if pv2 != -1
    self.contents.font.color = Color.new(255,0,0)
    self.contents.draw_text(320, -10, 50, 32, tv.to_s)
    arrow 
    gold_bar
    fiches 
     end
    end
    
    class Window_Bet < Window_Selectable
     attr_accessor :done
     attr_accessor :bet
     attr_accessor :fiches_num
     def initialize(min, max = 0)
    super(-140,100,140,260)
    self.contents = Bitmap.new(width-32, height-32)
    s = " "+$data_system.words.gold 
    @commands = ["10"+s, "25"+s, "50"+s, "100"+s, "500"+s, "Azzera", "Punta"]
    @item_max = @commands.size
    @min_bet = min
    @max_bet = max
    @can_play = can_play
    @fiches_num = {}
    @fiches_num.default = 0
    @bet = 0
    @done = false
    self.index = 0
    #enter
    refresh
     end
     
     def can_play
    return $game_party.gold >= @min_bet
     end 
     
     def new_game
    @fiches_num = {}
    @fiches_num.default = 0
    @done = false
    @bet = 0
    @can_play = can_play
    enter
    refresh
     end
     
     def refresh
    self.contents.clear
    gold = $game_party.gold - @bet
    if (@can_play)
      for i in 0...@item_max
    	draw_item(i, normal_color)
      end
    else
      exit
    end
    draw_item(0, disabled_color) if ((gold - 10) < 0)
    draw_item(1, disabled_color) if ((gold - 25) < 0)
    draw_item(2, disabled_color) if ((gold - 50) < 0)
    draw_item(3, disabled_color) if ((gold - 100) < 0)
    draw_item(4, disabled_color) if ((gold - 500) < 0)
    draw_item(6, disabled_color) if (@bet < @min_bet)
     end
     
     def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(18, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
     end
     
     def disabled_option(index)
    draw_item(index, disabled_color)
     end
     
     def exit
    div = 10
    for i in 0...div
      self.x -= 140 / div
      Graphics.update
    end
     end
     
     def enter
    div = 10
    for i in 0...div
      self.x += 140 / div
      Graphics.update
    end
     end
     
     def fiches_x2
    for i in [10, 25, 50, 100, 500]
      @fiches_num[i] *= 2
    end
     end
     
     alias update_old update
     def update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::C)
      gold = $game_party.gold - @bet
      if @can_play
    	case @index
    	  when 0
    		if gold - 10 < 0
    		  $game_system.se_play($data_system.buzzer_se)
    		  return
    		end
    		$game_system.se_play($data_system.decision_se)
    		@fiches_num[10] += 1
    		@bet += 10
    	  when 1
    		if gold - 25 < 0
    		  $game_system.se_play($data_system.buzzer_se)
    		  return
    		end
    		$game_system.se_play($data_system.decision_se)
    		@fiches_num[25] += 1
    		@bet += 25
    	  when 2
    		if gold - 50 < 0
    		  $game_system.se_play($data_system.buzzer_se)
    		  return
    		end
    		$game_system.se_play($data_system.decision_se)
    		@fiches_num[50] += 1
    		@bet += 50
    	  when 3
    		if gold - 100 < 0
    		  $game_system.se_play($data_system.buzzer_se)
    		  return
    		end
    		$game_system.se_play($data_system.decision_se)
    		@fiches_num[100] += 1
    		@bet += 100
    	  when 4
    		if gold - 500 < 0
    		  $game_system.se_play($data_system.buzzer_se)
    		  return
    		end
    		$game_system.se_play($data_system.decision_se)
    		@fiches_num[500] += 1
    		@bet += 500
    	  when 5
    		$game_system.se_play($data_system.decision_se)
    		@fiches_num = {}
    		@fiches_num.default = 0
    		@bet = 0
    	  when 6
    		$game_system.se_play($data_system.decision_se)
    		$game_party.lose_gold(@bet)
    		@done = true
    		exit
    	  end
      else
    	$scene = Scene_Map.new
      end
    end
    update_old
    refresh
     end
    end
    
    class Window_Player < Window_Selectable
     attr_accessor :entered
     def initialize
    super(-170, 155, 170, 160)
    @commands = ["Carta!", "Mi fermo!", "Sdoppio", "Raddoppio"]
    @item_max = @commands.size
    self.contents = Bitmap.new(width - 32, @item_max * 32 )
    refresh
    self.index = 0
     end
     
     def enter
    div = 10
    for i in 0...div
      self.x += 170/div
      Graphics.update
    end
     end
     
     def exit
    div = 10
    for i in 0...div
      self.x -= 170 / div
      Graphics.update
    end
     end
     
     def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
     end
     
     def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(18, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
     end
     
     def disabled_option(index)
    draw_item(index, disabled_color)
     end
    end
    
    class Window_Result < Window_Base
     attr_accessor :blackjack
     attr_accessor :winner
     def initialize
    super(150,150,300,130)
    self.contents = Bitmap.new(width-32, height-32)
    self.visible = false
    @blackjack = false
    @winner = -1
    self.y = 100
     end
     
     def refresh
    self.contents.clear
    if @winner == 0
      text = random_choise(BJ_MODULE::LOSE)
    elsif @winner == 2
      text = random_choise(BJ_MODULE::DRAW)
    else
      text = random_choise(BJ_MODULE::WIN)
    end
    if @blackjack == false
      self.contents.draw_text(18, 30, 250, 32, text)
    else
      text1 = (@winner == 0)? random_choise(BJ_MODULE::BJ_LOSE) : random_choise(BJ_MODULE::BJ_WIN)
      self.contents.draw_text(18, 16, 250, 32, text1)
      self.contents.draw_text(18, 60, 250, 32, text)
    end
     end
     
     def random_choise(vett)
    return vett[random(vett.size)]
     end
     
     def random(n)
    times = rand(10)
    result = 0
    for i in 0...times
      result = rand(n)
    end
    return result
     end
    end
    
    class BlackJack
     def initialize(min = 10, max = 1000, bmax = 16, green = true)
    @min_bet = min
    @max_bet = max
    @bank_max = bmax
    @green = green
     end
     
     def init_deck
    @cards = {}
    @cards.default = nil
    x = 20
    count = 0
    for s in ["c","f","p","q"]
      for i in 1..13
    	index = s.to_s+i.to_s
    	@cards[index] = Card.new(s, i, false)
    	@cards[index].move(20+count*2, 18)
    	count += 1
      end
    end
     end
     
     def new_game(bool = true)
    Graphics.transition
    discard_deck if bool
    init_deck
    @player_window.exit
    @player_window.dispose
    @help.enter
    @help.refresh(@window_bet.can_play)
    @window_bet.new_game if bool
    #@window_bet.active = true
    @result_window.visible = false
    @player_window = Window_Player.new
    @table_text.fiches_num = @window_bet.fiches_num
    @player_cards1 = []
    @player_cards2 = []
    @table_cards = []
    @player_value1 = 0
    @player_value2 = -1
    @table_value = 0
    @double = 0
    @entered = false
    @split = false
    @hands = 1
    @BJ = false
    @winner = -1
     end
     
     def main
    @table = BJ_Table.new((@green)? "" : "1")
    @table_text = BJ_Table_text.new
    @table_text.gold_start = $game_party.gold
    @window_bet = Window_Bet.new(@min_bet, @max_bet)
    @player_window = Window_Player.new
    @result_window = Window_Result.new
    @help = BJ_Help.new
    new_game(false)
    Graphics.transition
    @window_bet.enter
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
    	break
      end
    end
    @help.exit
    @window_bet.exit if @window_bet.can_play 
    @help.dispose
    @window_bet.dispose
    @player_window.dispose
    @result_window.dispose
    @table_text.dispose
    @table.dispose
     end
     
     def control_value
    @table_value = 0
    @player_value1 = 0
    @player_value2 = 0 if @split
    for c in @table_cards
      @table_value += c.value if c.face_up
    end
    for c in @player_cards1
      @player_value1 += c.value
    end
    if (@split)
      for c in @player_cards2
    	@player_value2 += c.value
      end
    end
    #
    for c in @table_cards
      if c.value == 1 and ((@table_value + 10) <= 21)
    	@table_value += 10 if c.face_up
      end
    end
    for c in @player_cards1
      if c.value == 1 and @player_value1 + 10 <= 21
    	@player_value1 += 10
      end
    end
    if (@split)
      for c in @player_cards2
    	if c.value == 1 and @player_value2 + 10 <= 21
    	@player_value2 += 10
      end
      end
    end
     end
     
     def update
    @table_text.fiches_num = @window_bet.fiches_num
    control_value
    @table_text.bet = ((@split)? 2 : 1)*@window_bet.bet + @double*@window_bet.bet
    @table_text.done = @window_bet.done
    @table_text.update(@table_value, @player_value1, @player_value2)
    if @result_window.visible
      @table_text.arrow_pos = -1
      result_update
    elsif @window_bet.done
      @table_text.arrow_pos = @hands
      if @entered == false
    	@help.exit
    	give_card(1, true)
    	put_card(1)
    	refresh
    	Graphics.transition
    	give_card(0, true)
    	put_card(0)
    	refresh
    	Graphics.transition
    	give_card(1, true)
    	put_card(1)
    	refresh
    	Graphics.transition
    	give_card(0, false)
    	put_card(0)
    	refresh
    	Graphics.transition
    	@player_window.enter 
    	@entered = true
      else
      player_update
    end
     else
    @table_text.arrow_pos = -1
      @window_bet.update
    end
     end
     
     def give_card(who, face_up)
    if who == 0
      bool = false
      while not bool
    	sign = ""
    	case random(4)
    	  when 1
    	sign = "c"
    	  when 2
    	sign = "f"
    	  when 3
    	sign = "p"
    	  when 4
    	sign = "q"
    	end
    	index = sign+random(13).to_s
    	bool = @cards[index] != nil
    	card = @cards[index].clone if bool
      end
      @cards[index] = nil
      card.turn if face_up
      @table_cards[@table_cards.size] = card
      @table_value += card.value if face_up
    else
      bool = false
      while not bool
    	case random(4)
    	  when 1
    	sign = "c"
    	  when 2
    	sign = "f"
    	  when 3
    	sign = "p"
    	  when 4
    	sign = "q"
    	end
    	index = sign+random(13).to_s
    	bool = @cards[index] != nil
    	card = @cards[index].clone if bool
      end
      @cards[index].dispose
      @cards[index] = nil
      card.turn if face_up
      if @hands == 1
    	@player_cards1[@player_cards1.size] = card
    	@player_value1 += card.value
      else
    	@player_cards2[@player_cards2.size] = card
    	@player_value2 += card.value
      end
    end
    refresh
    put_card(who)
     end
    
     def discard_deck
    for i in 0...@player_cards1.size
      @player_cards1[i].dispose
    end
    for i in 0...@player_cards2.size
      @player_cards2[i].dispose
    end
    for i in 0...@table_cards.size
      @table_cards[i].dispose
    end
    for s in ["c","f","p","q"]
      for i in 1..13
    	index = s.to_s+i.to_s
    	@cards[index].dispose if @cards[index] != nil
      end
    end
     end
     
     def refresh
    count = 0
    for s in ["c","f","p","q"]
      for i in 1..13
    	if @cards[s.to_s+i.to_s] != nil
    	  @cards[s.to_s+i.to_s].move(20+count*2, 18)
    	  count += 1
    	end
      end
    end
     end
     
     def put_card(who)
    if who == 0
      @table_cards[@table_cards.size-1].move(251 + (@table_cards.size-1)*17, 15+ (@table_cards.size-1)*17, true)
    else
      if @hands == 1
    	@player_cards1[@player_cards1.size-1].move(185 + (@player_cards1.size-1)*17, 272+ (@player_cards1.size-1)*17, true)
      else
    	@player_cards2[@player_cards2.size-1].move(389 + (@player_cards2.size-1)*17, 272+ (@player_cards2.size-1)*17, true)
      end
    end
     end
     
     def random(n)
    times = rand(10)
    result = 0
    for i in 0...times
      result = rand(n)
    end
    return result + 1
     end
     
     def player_update
    @player_window.disabled_option(2) if not can_split?
    @player_window.disabled_option(3) if not can_double?
    if (@player_value1 == 21 and @player_cards1.size == 2) or (@hands == 2 and @player_value2 == 21 and @player_cards2.size == 2)
      @BJ = true
    end
    if ((@hands == 1) and (@split == false) and (@player_value1 >= 21)) or ((@hands == 2) and (@player_value2 >= 21))
      table_turn
    end
    @player_window.update
    if Input.trigger?(Input::B)
    end
    if Input.trigger?(Input::C)
      case @player_window.index
    	when 0
    	  give_card(1, true)
    	  put_card(1)
    	  refresh
    	  Graphics.update
    	  Graphics.transition
    	when 1
    	  if (@hands == 2 and @split or @split == false)
    		table_turn
    	  else
    		@hands = 2
    	  end
    	when 2
    	  do_split if can_split?
    	when 3
    	  do_double if can_double?
      end
    end
     end
     
     def do_double
    @double += 1
    give_card(1, true)
    put_card(1)
    @window_bet.fiches_x2
    $game_party.lose_gold(@window_bet.bet)
    refresh
    Graphics.update
    if (@hands == 2 or (@hands == 1 and @split == false))
      table_turn
    else 
      @hands = 2
    end
     end
     
     def table_turn
    if (@hands == 1 and @player_value1 > 21) or (@hands == 2 and @player_value1 > 21 and @player_value2 > 21)
      @player_window.exit
      @result_window.blackjack = false
      @result_window.winner = 0
      @result_window.refresh
      @result_window.visible = true
      return
    end
    @table_cards[1].turn
    control_value
    refresh
    Graphics.transition
    stop = @table_value >= @bank_max
    while (stop == false)
      give_card(0, true)
      put_card(0)
      refresh
      Graphics.transition
      control_value
      stop = (@table_value >= @bank_max)
    end
    refresh
    Graphics.transition
    if @table_value > 21
      @winner = 1
      $game_party.gain_gold((@window_bet.bet*1.5).floor) 
      $game_party.gain_gold((@window_bet.bet*1.5).floor) if (@hands == 2 and @player_value2 < 21)
    else
      if (@hands == 1 and @player_value1 < @table_value)
    	@winner = 0
      elsif (@hands == 2 and @player_value1 < @table_value and @player_value2 < @table_value)
    	@winner = 0
      elsif (@hands == 1 and @player_value1 == @table_value)
    	@winner = 2
      elsif (@hands == 2 and @player_value1 == @table_value and @player_value2 == @table_value)
    	@winner = 2
      else
    	@winner = 1
      end
      $game_party.gain_gold((@window_bet.bet*(1.5+((@BJ and @winner==1)? 0.5 : 0))).floor) if (@player_value1 > @table_value)
      $game_party.gain_gold((@window_bet.bet*(1.5+((@BJ and @winner==1)? 0.5 : 0))).floor) if (@hands == 2 and @player_value2 > @table_value)
      $game_party.gain_gold(@window_bet.bet) if (@player_value1 == @table_value)
      $game_party.gain_gold(@window_bet.bet) if (@hands == 2 and @player_value2 == @table_value)
    end
    if @winner == 0
      @BJ = ((@table_cards.size == 2)and(@table_value == 21))
    end
    @player_window.exit
    @result_window.blackjack = @BJ
    @result_window.winner = @winner
    @result_window.refresh
    @result_window.visible = true
     end
     
     def do_split
    @player_cards2[0] = @player_cards1.pop
    @player_cards2[0].move(389, 272)
    @player_value2 = @player_cards2[0].value
    @player_value1 -= @player_cards2[0].value
    @window_bet.fiches_x2
    $game_party.lose_gold(@window_bet.bet)
    @split = true
     end
     
     def can_split?
    if ((has_money?) and (@split == false) and (@player_cards1.size == 2) and (@player_cards1[0].real_value == @player_cards1[1].real_value))
      return true
    end
    return false
     end
     
     def has_money?
    return $game_party.gold - @window_bet.bet >= 0
     end
     
     def can_double?
    return ($game_party.gold - @window_bet.bet) >= 0
     end
     
     def result_update
    if Input.trigger?(Input::C) or Input.trigger?(Input::B)
      $game_system.se_play($data_system.decision_se)
      @result_window.visible = false
      new_game
    end
     end
    end

     

     

    Istruzioni:

    Inserite lo script in una nuova classe sopra il main. Per richiamarlo basta scrivere in un evento nel call script: $scene = BlackJack.new

     

    Aggiornamenti:

    Aggiornata la versione. Ora disponibile la 1.1. Sono stati sistemati alcuni bug anke se ininfluenti nel gioco e aggiunta flessibilità alla classe. Per gestire il banco del BlackJack in modo differente in differenti chiamate dello script basta settare le variabili ke ora dirò:

    $scene = BlackJack.new(bmin, bmax, imin, imax, bstop)

    #bmin : puntata minima di default è 10

    #bmax : puntata massima di default è 1000

    #imin : è di quanto aumenta/diminuisce la puntata premendo sinistra o destra

    #imax : è di quanto aumenta/diminuisce la puntata premendo su o giù

    #bstop : è il valore ke deve superare il banco per potersi fermare di default è 16 (il minimo

    # consentito dalle regole e anke il più usato)

     

    Aggiornamento 2.1. In questa versione è possibile rendere le frasi "finali" randomizzate e personalizzate basta modificare le varie liste di frasi presenti in BJ_MODULE all'inizio dello script.

    L'aggiornamento inoltre fa visualizzare le carte ke dal mazzo si posizionano nel loro posto.

    Il costruttore della classe è diverso ovvero:

    $scene = BlackJack.new(bmin, bmax, bstop, green)

    le prime 3 variabili hanno lo stesso significato di quello del 1.1 mentre green può essere o true o false, true per il tappeto verde e false per quello rosso.

     

    Conflitti:

    E' uno script autonomo quindi non dovrebbe avere conflitti di nessun tipo.

     

    Altro:

    Questo script vorrei inserirlo in una serie di script ke faranno parte di un ipotetico progetto chiamato "Progetto Casinò" ricco di script di giochi che si trovano appunto nei casinò però per alcune cose avrei bisogno di qualche volontario sia in grafica che in script. Beh per chi volesse sapete dove trovarmi. Vi darò dettagli più approfonditi prossimamente!!

  4. allora ho cambiato quello ho cambiato anche la variabile @armor = {} con @armor = []

    però non va da lo stesso errore, il resto mi sembra corretto e poi ho visto che tra gli script c'è ne già uno che si chiama proprio

    Game_intepreter mi sa che va aggiunto la .... cmq ho segnalato lo script nel supporto rgss vx del forum ovviamente ho citato te per lo script, se mi fanno saxe qualcosa per la modifica magari ti avviso non so se sei interessato al vx però magari potrebbe tornarti utile

     

    tnx

    Si è ovvio ke esista già il mio script è un aggiunta a quella classe e puoi lasciarla a parte.. le parentesi grafe mq devi tenerle xke la variabile non è un array ma un hash e quindi vuole le grafe... cmq se qualke anima pia ti aiuta non avrai problemi anke xke credo ke le modifiche da fare sono poke e semplici..

  5. grazie cmq mak, e che alcune cose io non le conosco tipo non so se intepreter in xp equivale a game_intepreter in vx o se anche nella versione xp era una cosa a parte...

     

    :rovatfl:

    In teoria mi sa ke è proprio il game_interpreter del VX poi xò gli altri dubbi ke ho riguardano anke le variabili di sistema ke forse hanno nomi diversi... magari al posto di class Interpreter prova a mettere Game_Interpreter e vedi se va o se cmq cambia errore... xke il name error te lo da se non interpreta in modo giusto il nome della funzione...

  6. ... ho provato lo script... va tradotto da errore

    ???????name error????????

    undefible variable take_armors in game e poi mette una scritta in esadecimale (sicuramente l'indirizzo fisico della memoria)

     

    ho provato a convertirlo ma la guida di ruby del vx è in japp...

     

    qualcuno può tradurlo in ruby vx, o passarmi la guida del ruby per il vx????

     

    forse l'interpreter del VX è leggermente diverso da quello dell'XP x quello ti da quell'errore... se sapessi come tradurtelo lo farei ma nn ho mai visto l'rgss2...

  7. ti ringrazio va bene anche se poi il pg se le deve ri equipaggiare addosso, lo provo e poi ti dico se va bene :)

    Volendo si può fare ke si equipaggiano automaticamente xò ho preferito lasciare così. Cmq come ho messo nell'edit del mess precedente lo script funziona sicuramente col XP con il VX non so se cambi qualcosa. Spero di no... altrimenti prova a vedere di tradurlo...

  8. Ecco il codice:

    crea una classe sopra main e chiamala come vuoi:

    class Interpreter
     attr_accessor :weapon
     attr_accessor :armor
     def take_armors
    @weapon = {}
    @armor = {}
    @weapon.default = nil
    @armor.default = nil
    for actor in $game_party.actors
      actor.equip(0, 0)
      actor.equip(1, 0)
    end
    for weapon in 1...$data_weapons.size
      if $game_party.weapon_number(weapon) > 0
    	@weapon[weapon] = n = $game_party.weapon_number(weapon)
    	$game_party.lose_weapon(weapon, n)
      end
    end
    for armor in 1...$data_armors.size
      if $game_party.armor_number(armor) > 0
    	@armor[armor] = n = $game_party.armor_number(armor)
    	$game_party.lose_armor(armor, n)
      end
    end
     end
     
     def give_armors
    for i in 1..$data_weapons.size
      if @weapon[i] != nil
    	$game_party.gain_weapon(i, @weapon[i])
      end
    end
    for i in 1..$data_armors.size
      if @armor[i] != nil
    	$game_party.gain_armor(i, @armor[i])
      end
    end
    @weapon = nil
    @armor = nil
     end
    end

     

    poi crei un evento e nello sript scrivi take_armors se vuoi togliere armi e scudi, oppure give_armors per dargliele indietro.

    Occhio ke quando restituisce le armi quelle ke erano in equip devi rimetterle manualmente non è ke si equipaggiano automaticamente. Se ti da problemi dimmi pure...

     

    EDIT: mi sono accorto solo ora ke è lo sportello del VX. non so se a livello di codice cambi qualcosa.. prova a vedere se funziona altrimenti prova a vedere se qualcuno sa tradurlo per il VX in teoria non dovrebbe essere difficile xò io non so...

  9. esatto potrebbero cambiare le armi la città dove si effettua questo disarmo è una città di passaggio, ci vogliono le variabili vero se l'arma non è la stessa?

    Beh io però farei notare una cosa: se l'arma ke ha in equip l'eroe è posseduta in più unità anke se viene disarmato può cmq riprendersela avendone un altra uguale!?

    Cmq il tuo problema è facilmente risolvibile con poke righe di script...

  10. Sleeping se vuoi una mano per la CPU avversaria posso aiutarti se riesco. Tempo fa realizzai un gioco di dama con una buona AI basata su algoritmi ke ho studiato x un anno al posto di studiare per l'esame di 5^ :sisi:, il quale mi batteva in continuazione quindi volendo potrei aiutarti. O cmq se hai dubbi o problemi basta ke mi dici provo a vedere se posso darti qualke consiglio... Cmq ottimo lavoro. Sei un mito!!
  11. Mmmm ke strano errore... in teoria mettendo $scene = Scene_Diary.new(true) nel call script degli eventi (non importa se lo richiami da evento comune o meno) dovrebbe funzionare perfettamente... Sei sicuro di non aver scritto male qualcosa?!?!?! al massimo adesso provo ank'io in un progetto vuoto e ti dico..
  12. D: Tra gli script che uso c'è quello del diario che si richiama dalla schermata principale del menù, ora vorrei anche creare un oggetto "diario" da poter usare nel menù oggetti, credo che dovrei usare il comando "call script" ma cosa ci devo scrivere? il nome dello script?

    Guarda si può fare in 2 modi a mio parere in base a dove è questo oggetto diario:

    se lo trovi nella mappa e non lo hai con te basta ke metti un evento e andando sull'ultima opzione "Script" scrivi $scene = Diary.new (scrivo diary xke non so il nome della classe) altrimenti se l'oggetto l'hai sempre con te e devi consultarlo allora crei un evento comune uguale identico all'evento ke ti ho appena scritto e lo richiami utilizzando l'oggetto. Sper di essere stato chiaro e ke il tutto fuzioni!!

  13. ah, niente niente.

    uso un bs non di default che modifica una funzione in cui c'è l'enemy_arrow e mi ero dimenticato di sistemarlo.

    mò funziona tutto.

    immagino che per avere 4 quadratini diversi, devo creare 4 arrow_base. certo che da vedere, è davvero brutto! :D (lo script intendo). ma almeno funziona.

    grazie! :D

     

    lo posto quindi? la prima parte è ammirevole, poi si risolve in un copia-incolla :D

    comunque va bene lo stesso! bon, posto allora?

     

    Si si posta. Eh in effetti avrei voluto renderlo più stiloso ma sarebbe stato un lavoraccio ke poi nemmeno ero sicuro funzionasse :)...

  14. stavo facendo la stessa cosa anche io. è un obbrobrio da vedere...

    comunque ha un problema. non capisco perchè, ma mi si blocca quando appare il cursore. non si chiude la finestra, nè mi appare errore, è come se non ricevesse più gli input da tastiera

     

    ??? Strano a me va... anke se non mi si vede un grankè bene... xò da come dici è come se si bloccasse in qualke update o compagnia sonante..

  15. Crea 4 classi nuove e chiamale:

    Arrow_Enemy_AD

     

     

    class Arrow_Enemy_AD < Arrow_Base
     #--------------------------------------------------------------------------
     # * Get Enemy Indicated by Cursor
     #--------------------------------------------------------------------------
     def enemy
    return $game_troop.enemies[@index]
     end
     #--------------------------------------------------------------------------
     # * Frame Update
     #--------------------------------------------------------------------------
     def update
    super
    # Skip if indicating a nonexistant enemy
    $game_troop.enemies.size.times do
      break if self.enemy.exist?
      @index += 1
      @index %= $game_troop.enemies.size
    end
    # Cursor right
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Cursor left
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += $game_troop.enemies.size - 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Set sprite coordinates
    if self.enemy != nil
      self.x = self.enemy.screen_x + @enemy_sprites[@index].width - 16
      self.y = self.enemy.screen_y + @enemy_sprites[@index].height - 16
    end
     end
     #--------------------------------------------------------------------------
     # * Help Text Update
     #--------------------------------------------------------------------------
     def update_help
    # Display enemy name and state in the help window
    @help_window.set_enemy(self.enemy)
     end
    end

     

     

     

    Arrow_Enemy_AS

     

    class Arrow_Enemy_AS < Arrow_Base
     #--------------------------------------------------------------------------
     # * Get Enemy Indicated by Cursor
     #--------------------------------------------------------------------------
     def enemy
    return $game_troop.enemies[@index]
     end
     #--------------------------------------------------------------------------
     # * Frame Update
     #--------------------------------------------------------------------------
     def update
    super
    # Skip if indicating a nonexistant enemy
    $game_troop.enemies.size.times do
      break if self.enemy.exist?
      @index += 1
      @index %= $game_troop.enemies.size
    end
    # Cursor right
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Cursor left
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += $game_troop.enemies.size - 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Set sprite coordinates
    if self.enemy != nil
      self.x = self.enemy.screen_x
      self.y = self.enemy.screen_y + @enemy_sprites[@index].height - 16
    end
     end
     #--------------------------------------------------------------------------
     # * Help Text Update
     #--------------------------------------------------------------------------
     def update_help
    # Display enemy name and state in the help window
    @help_window.set_enemy(self.enemy)
     end
    end

     

     

    Arrow_Enemy_BD

     

    class Arrow_Enemy_BD < Arrow_Base
     #--------------------------------------------------------------------------
     # * Get Enemy Indicated by Cursor
     #--------------------------------------------------------------------------
     def enemy
    return $game_troop.enemies[@index]
     end
     #--------------------------------------------------------------------------
     # * Frame Update
     #--------------------------------------------------------------------------
     def update
    super
    # Skip if indicating a nonexistant enemy
    $game_troop.enemies.size.times do
      break if self.enemy.exist?
      @index += 1
      @index %= $game_troop.enemies.size
    end
    # Cursor right
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Cursor left
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += $game_troop.enemies.size - 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Set sprite coordinates
    if self.enemy != nil
      self.x = self.enemy.screen_x + @enemy_sprites[@index].width - 16
      self.y = self.enemy.screen_y
    end
     end
     #--------------------------------------------------------------------------
     # * Help Text Update
     #--------------------------------------------------------------------------
     def update_help
    # Display enemy name and state in the help window
    @help_window.set_enemy(self.enemy)
     end
    end

     

     

    Arrow_Enemy_BS

     

    class Arrow_Enemy_BS < Arrow_Base
     #--------------------------------------------------------------------------
     # * Get Enemy Indicated by Cursor
     #--------------------------------------------------------------------------
     def enemy
    return $game_troop.enemies[@index]
     end
     #--------------------------------------------------------------------------
     # * Frame Update
     #--------------------------------------------------------------------------
     def update
    super
    # Skip if indicating a nonexistant enemy
    $game_troop.enemies.size.times do
      break if self.enemy.exist?
      @index += 1
      @index %= $game_troop.enemies.size
    end
    # Cursor right
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Cursor left
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
    	@index += $game_troop.enemies.size - 1
    	@index %= $game_troop.enemies.size
    	break if self.enemy.exist?
      end
    end
    # Set sprite coordinates
    if self.enemy != nil
      self.x = self.enemy.screen_x
      self.y = self.enemy.screen_y
    end
     end
     #--------------------------------------------------------------------------
     # * Help Text Update
     #--------------------------------------------------------------------------
     def update_help
    # Display enemy name and state in the help window
    @help_window.set_enemy(self.enemy)
     end
    end

     

     

    Cambia o modifica Scene_Battle3 con questo codice se devi solo modificarlo guarda le parti in cui richiamo le variabili enemy_arrow:

     

    class Scene_Battle
     #--------------------------------------------------------------------------
     # * Start Actor Command Phase
     #--------------------------------------------------------------------------
     def start_phase3
    # Shift to phase 3
    @phase = 3
    # Set actor as unselectable
    @actor_index = -1
    @active_battler = nil
    # Go to command input for next actor
    phase3_next_actor
     end
     #--------------------------------------------------------------------------
     # * Go to Command Input for Next Actor
     #--------------------------------------------------------------------------
     def phase3_next_actor
    # Loop
    begin
      # Actor blink effect OFF
      if @active_battler != nil
    	@active_battler.blink = false
      end
      # If last actor
      if @actor_index == $game_party.actors.size-1
    	# Start main phase
    	start_phase4
    	return
      end
      # Advance actor index
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # Once more if actor refuses command input
    end until @active_battler.inputable?
    # Set up actor command window
    phase3_setup_command_window
     end
     #--------------------------------------------------------------------------
     # * Go to Command Input of Previous Actor
     #--------------------------------------------------------------------------
     def phase3_prior_actor
    # Loop
    begin
      # Actor blink effect OFF
      if @active_battler != nil
    	@active_battler.blink = false
      end
      # If first actor
      if @actor_index == 0
    	# Start party command phase
    	start_phase2
    	return
      end
      # Return to actor index
      @actor_index -= 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # Once more if actor refuses command input
    end until @active_battler.inputable?
    # Set up actor command window
    phase3_setup_command_window
     end
     #--------------------------------------------------------------------------
     # * Actor Command Window Setup
     #--------------------------------------------------------------------------
     def phase3_setup_command_window
    # Disable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # Set actor command window position
    @actor_command_window.x = @actor_index * 160
    # Set index to 0
    @actor_command_window.index = 0
     end
     #--------------------------------------------------------------------------
     # * Frame Update (actor command phase)
     #--------------------------------------------------------------------------
     def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow_as != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
     end
     #--------------------------------------------------------------------------
     # * Frame Update (actor command phase : basic command)
     #--------------------------------------------------------------------------
     def update_phase3_basic_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Go to command input for previous actor
      phase3_prior_actor
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by actor command window cursor position
      case @actor_command_window.index
      when 0  # attack
    	# Play decision SE
    	$game_system.se_play($data_system.decision_se)
    	# Set action
    	@active_battler.current_action.kind = 0
    	@active_battler.current_action.basic = 0
    	# Start enemy selection
    	start_enemy_select
      when 1  # skill
    	# Play decision SE
    	$game_system.se_play($data_system.decision_se)
    	# Set action
    	@active_battler.current_action.kind = 1
    	# Start skill selection
    	start_skill_select
      when 2  # guard
    	# Play decision SE
    	$game_system.se_play($data_system.decision_se)
    	# Set action
    	@active_battler.current_action.kind = 0
    	@active_battler.current_action.basic = 1
    	# Go to command input for next actor
    	phase3_next_actor
      when 3  # item
    	# Play decision SE
    	$game_system.se_play($data_system.decision_se)
    	# Set action
    	@active_battler.current_action.kind = 2
    	# Start item selection
    	start_item_select
      end
      return
    end
     end
     #--------------------------------------------------------------------------
     # * Frame Update (actor command phase : skill selection)
     #--------------------------------------------------------------------------
     def update_phase3_skill_select
    # Make skill window visible
    @skill_window.visible = true
    # Update skill window
    @skill_window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End skill selection
      end_skill_select
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the skill window
      @skill = @skill_window.skill
      # If it can't be used
      if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
    	# Play buzzer SE
    	$game_system.se_play($data_system.buzzer_se)
    	return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Set action
      @active_battler.current_action.skill_id = @skill.id
      # Make skill window invisible
      @skill_window.visible = false
      # If effect scope is single enemy
      if @skill.scope == 1
    	# Start enemy selection
    	start_enemy_select
      # If effect scope is single ally
      elsif @skill.scope == 3 or @skill.scope == 5
    	# Start actor selection
    	start_actor_select
      # If effect scope is not single
      else
    	# End skill selection
    	end_skill_select
    	# Go to command input for next actor
    	phase3_next_actor
      end
      return
    end
     end
     #--------------------------------------------------------------------------
     # * Frame Update (actor command phase : item selection)
     #--------------------------------------------------------------------------
     def update_phase3_item_select
    # Make item window visible
    @item_window.visible = true
    # Update item window
    @item_window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End item selection
      end_item_select
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @item_window.item
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
    	# Play buzzer SE
    	$game_system.se_play($data_system.buzzer_se)
    	return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Set action
      @active_battler.current_action.item_id = @item.id
      # Make item window invisible
      @item_window.visible = false
      # If effect scope is single enemy
      if @item.scope == 1
    	# Start enemy selection
    	start_enemy_select
      # If effect scope is single ally
      elsif @item.scope == 3 or @item.scope == 5
    	# Start actor selection
    	start_actor_select
      # If effect scope is not single
      else
    	# End item selection
    	end_item_select
    	# Go to command input for next actor
    	phase3_next_actor
      end
      return
    end
     end
     #--------------------------------------------------------------------------
     # * Frame Updat (actor command phase : enemy selection)
     #--------------------------------------------------------------------------
     def update_phase3_enemy_select
    # Update enemy arrow
    @enemy_arrow_ad.update
    @enemy_arrow_as.update
    @enemy_arrow_bd.update
    @enemy_arrow_bs.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End enemy selection
      end_enemy_select
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Set action
      @active_battler.current_action.target_index = @enemy_arrow.index
      # End enemy selection
      end_enemy_select
      # If skill window is showing
      if @skill_window != nil
    	# End skill selection
    	end_skill_select
      end
      # If item window is showing
      if @item_window != nil
    	# End item selection
    	end_item_select
      end
      # Go to command input for next actor
      phase3_next_actor
    end
     end
     #--------------------------------------------------------------------------
     # * Frame Update (actor command phase : actor selection)
     #--------------------------------------------------------------------------
     def update_phase3_actor_select
    # Update actor arrow
    @actor_arrow.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End actor selection
      end_actor_select
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Set action
      @active_battler.current_action.target_index = @actor_arrow.index
      # End actor selection
      end_actor_select
      # If skill window is showing
      if @skill_window != nil
    	# End skill selection
    	end_skill_select
      end
      # If item window is showing
      if @item_window != nil
    	# End item selection
    	end_item_select
      end
      # Go to command input for next actor
      phase3_next_actor
    end
     end
     #--------------------------------------------------------------------------
     # * Start Enemy Selection
     #--------------------------------------------------------------------------
     def start_enemy_select
    # Make enemy arrow
    @enemy_arrow_as = Arrow_Enemy_AS.new(@spriteset.viewport1, @spriteset.enemy_sprites)
    @enemy_arrow_ad = Arrow_Enemy_AD.new(@spriteset.viewport1, @spriteset.enemy_sprites)
    @enemy_arrow_bs = Arrow_Enemy_BS.new(@spriteset.viewport1, @spriteset.enemy_sprites)
    @enemy_arrow_bd = Arrow_Enemy_BD.new(@spriteset.viewport1, @spriteset.enemy_sprites)
    # Associate help window
    @enemy_arrow_as.help_window = @help_window
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
     end
     #--------------------------------------------------------------------------
     # * End Enemy Selection
     #--------------------------------------------------------------------------
     def end_enemy_select
    # Dispose of enemy arrow
    @enemy_arrow_as.dispose
    @enemy_arrow_bs.dispose
    @enemy_arrow_bd.dispose
    @enemy_arrow_ad.dispose
    @enemy_arrow_as = nil
    @enemy_arrow_ad = nil
    @enemy_arrow_bs = nil
    @enemy_arrow_bd = nil
    # If command is [fight]
    if @actor_command_window.index == 0
      # Enable actor command window
      @actor_command_window.active = true
      @actor_command_window.visible = true
      # Hide help window
      @help_window.visible = false
    end
     end
     #--------------------------------------------------------------------------
     # * Start Actor Selection
     #--------------------------------------------------------------------------
     def start_actor_select
    # Make actor arrow
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
    @actor_arrow.index = @actor_index
    # Associate help window
    @actor_arrow.help_window = @help_window
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
     end
     #--------------------------------------------------------------------------
     # * End Actor Selection
     #--------------------------------------------------------------------------
     def end_actor_select
    # Dispose of actor arrow
    @actor_arrow.dispose
    @actor_arrow = nil
     end
     #--------------------------------------------------------------------------
     # * Start Skill Selection
     #--------------------------------------------------------------------------
     def start_skill_select
    # Make skill window
    @skill_window = Window_Skill.new(@active_battler)
    # Associate help window
    @skill_window.help_window = @help_window
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
     end
     #--------------------------------------------------------------------------
     # * End Skill Selection
     #--------------------------------------------------------------------------
     def end_skill_select
    # Dispose of skill window
    @skill_window.dispose
    @skill_window = nil
    # Hide help window
    @help_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
     end
     #--------------------------------------------------------------------------
     # * Start Item Selection
     #--------------------------------------------------------------------------
     def start_item_select
    # Make item window
    @item_window = Window_Item.new
    # Associate help window
    @item_window.help_window = @help_window
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
     end
     #--------------------------------------------------------------------------
     # * End Item Selection
     #--------------------------------------------------------------------------
     def end_item_select
    # Dispose of item window
    @item_window.dispose
    @item_window = nil
    # Hide help window
    @help_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
     end
    end

     

     

    Poi per far si ke vengano presi i 4 angoli del cursore della wskin devi modificare Arrow_Base.

  16. Ci ho pensato su un pò e siccome Arrow_Base eredita da Sprite l'idea di fare delle modifiche mi viene difficile quindi opto per le 4 arrow. Ora penso al codice e poi te lo posto appena finito...
  17. non so, mak, per me non cambia nulla. fa quello che ti viene più facile.

    (comunque, siete entrambi, mik & mak, nell'olimpo dei miei crediti. penso di postare tutto quanto nella sezione script per rendere usufruibile da tutti queste modifiche. ditemi se siete d'accordo)

     

    Grazie mi commuovi così.. :nana: Cmq per me si si puoi mettere tutto sugli script, sono per la condivisione assoluta, per il metodo ti posso dire ke il più semplice (anke se makkinoso) è forse quello con le 4 arrow anke xke non vorrei venisse fuori un casino con la grafica. Mentre l'altro sarebbe più stiloso xò devo pensarci un attimino sul come fare...

  18. era per mik quella risposta. a te ho risposto nell'edit:

    si si infatti mi sono accorto tardi sorry. Cmq volendo, il come devo ancora pensarlo, al posto di fare 4 arrow si può lo stesso facendone una con qualke modifica. Se vuoi lo facciamo...

  19. ti ho risposto. so che valori dare alle coordinate di ogni quadratino, ma mi servono 8 coordinate, 2 per ogni quadratino. io ne ho solo 2 (self.x e self.y). capì?

    lo so x quello ti ho detto ke potresti creare 4 arrow x ogni nemico così hai 2 coordinate x 4 ke fa 8 capito??

    EDIT: sorry non mi ero accorto ke avevi editato...

×
×
  • Create New...