- dieniferMembro
- Mensagens : 393
Reputação : 41
Script de nadar
Qua Out 06, 2010 10:24 pm
Estou disponilizando aqui na RMB. Na verdade foi o Ranran Hangai quem fez
Nessesario:
Dois chars que estou disponilizando para o próprio nadar:
Char nadando:
no fundo do mar ou lagos e etc :
COLOCAR SCRIPT ACIMA DO MAIN (NA CAIXA DE SCRIPTS)
Script:
Nessesario:
Dois chars que estou disponilizando para o próprio nadar:
Char nadando:
no fundo do mar ou lagos e etc :
COLOCAR SCRIPT ACIMA DO MAIN (NA CAIXA DE SCRIPTS)
Script:
- Código:
################################################################################
################################################################################
########################### Modulo RTH #########################################
################################################################################
################################################################################
#===============================================================================
# Criado por Renan Tsuneo Hangai Junior
#===============================================================================
# Script de Protect Element
#===============================================================================
module RTH
# Grafico de um char submerso
GRAPHIC_CHAR_SUBMERSO = "CharSub"
# Inicialização da invariavel GRAPHIC_CHAR_NADANDO
GRAPHIC_CHAR_NADANDO = []
# Defina o grafico de cada char como o exemplo
# GRAPHIC_CHAR_NADANDO[id] = [1, 2, 3] onde:
# 1 = Nome da imagem do char na agua rasa
# 2 = Nome da imagem do char na agua média
# 3 = Nome da imagem do char na agua funda
GRAPHIC_CHAR_NADANDO[1] = ["CharNada", "CharNada", "CharNada"]
# Batalha permitida enquanto nada?
NADANDO_BATTLE_PERMITIDA = true
# Nome do fundo enquanto estiver nadando
NADANDO_BATTLEBACK_NAME = ""
# Nome do fundo de batalha caso esteja mergulhando
MERGULHANDO_BATTLEBACK_NAME = ""
# Agua rasa, permite apenas nadar, mas não mergulhar
AGUA_RASA_TERRENO_ID = 1
# Agua normal, nada e mergulha
AGUA_NORMAL_TERRENO_ID = 2
# Agua Funda, nada e mergulha, mas somente se possuir um item
AGUA_FUNDA_TERRENO_ID = 3
# Não passa por baixo Terreno
NAO_MERGULHA_TERRENO_ID = 4
# Tipo do item para nadar em agua funda
# 0 - Item
# 1 - Armas
# 2 - Armaduras
ITEM_NADAR_AGUA_FUNDA_TIPO = 2
# Item para nadar em agua funda
ITEM_NADAR_AGUA_FUNDA = 33
# Botão que faz mergulhar
MERGULHAR_BUTTON = Input::X
# A barra aparecerá?
OXIGENIO_MERGULHADO_GAUGE = true
# Texto que aparecerá em cima da barra
OXIGENIO_BARRA_TEXTO = "Oxigenio"
# Opacidade da barra
OXIGENIO_BARRA_OPACIDADE = 160
# Tempo máximo da barra
OXIGENIO_MERGULHADO_MAX_TIME = 500
# Velocidade em que ela se gasta
OXIGENIO_MERGULHADO_TIME_SPEED = 1
# Tempo de recuperação de ar enquanto nada
OXIGENIO_MERGULHADO_RECOVER_TIME_WATER = 1
# Tempo de recuperação de ar enquanto na terra
OXIGENIO_MERGULHADO_RECOVER_TIME_TERRA = 2
# Quantidade de HP perdida quando estiver se afogando
SEM_OXIGENIO_DANO = 10
# Tempo para perder HP enquanto estiver se afogando
SEM_OXIGENIO_TIME_DANO = 10
# Som que se reproduzirá ao perder HP por afogamento, deixe nil
# caso não queira som
SEM_OXIGENIO_DANO_SE = RPG::AudioFile.new("092-Attack04", 100, 100)
end
$RTHScript["Nadar"] = true
class Game_System
attr_accessor :graphic_char_sub, :oxigen_max_time
attr_accessor :oxigen_time_speed, :ox_recover_time_water, :ox_recover_time_terra
attr_accessor :no_oxigen_dano, :no_oxigen_time
alias rth_mergulha_game_system_initialize initialize
def initialize
oxigen_stats_normal
rth_mergulha_game_system_initialize
end
def oxigen_stats_normal
@graphic_char_sub = RTH::GRAPHIC_CHAR_SUBMERSO
@oxigen_max_time = RTH::OXIGENIO_MERGULHADO_MAX_TIME
@oxigen_time_speed = RTH::OXIGENIO_MERGULHADO_TIME_SPEED
@ox_recover_time_water = RTH::OXIGENIO_MERGULHADO_RECOVER_TIME_WATER
@ox_recover_time_terra = RTH::OXIGENIO_MERGULHADO_RECOVER_TIME_TERRA
@no_oxigen_dano = RTH::SEM_OXIGENIO_DANO
@no_oxigen_time = RTH::SEM_OXIGENIO_TIME_DANO
end
end
class Game_Map
def terrain_tag_layer(x, y, layer)
if @map_id != 0
tile_id = data[x, y, layer]
if tile_id == nil
return 0
elsif @terrain_tags[tile_id] > 0
return @terrain_tags[tile_id]
end
end
return 0
end
def set_battleback_nada
@bbntipo = 0 if @bbntipo == nil
return if @bbntipo == 1
@bbntipo = 1
@pre_battleback = @battleback_name.dup if @bbntipo == 0
@battleback_name = RTH::NADANDO_BATTLEBACK_NAME.dup
end
def set_battleback_mergulha
@bbntipo = 0 if @bbntipo == nil
return if @bbntipo == 2
@bbntipo = 2
@pre_battleback = @battleback_name.dup if @bbntipo == 0
@battleback_name = RTH::MERGULHANDO_BATTLEBACK_NAME.dup
end
def set_battleback_normal
@bbntipo = 0 if @bbntipo == nil
return if @bbntipo == 0
@bbntipo = 0
@battleback_name = @pre_battleback.dup
@pre_battleback = nil
end
end
class Game_Player < Game_Character
attr_reader :watered, :mergulhed, :mergulhed_time
alias rth_water_game_player_update update
alias rth_water_game_player_passable? passable?
alias rth_water_game_player_screen_z screen_z
def terrain_tag_layer(layer)
return $game_map.terrain_tag_layer(self.x, self.y, layer)
end
def mergulhed?
@watered = false if @watered == nil
@mergulhed = false if @mergulhed == nil
return @mergulhed
end
def invisible_oxi_barra
@oxigenio_barra = Sprite_Mergulhed.new if @oxigenio_barra == nil
@oxigenio_barra.visible = false
end
def update
if Input.trigger?(Input::L)
p screen_z
elsif Input.trigger?(Input::R)
p rth_water_game_player_screen_z
end
@mergulhed_time = $game_system.oxigen_max_time if @mergulhed_time == nil
@watered = false if @watered == nil
@oxigenio_barra = Sprite_Mergulhed.new if @oxigenio_barra == nil
@no_oxigenio_time = $game_system.no_oxigen_time if @no_oxigenio_time == nil
unless $game_system.map_interpreter.running?
now_m = @mergulhed_time
terrenos = [RTH::AGUA_RASA_TERRENO_ID, RTH::AGUA_NORMAL_TERRENO_ID, RTH::AGUA_FUNDA_TERRENO_ID]
if terrenos.include?(self.terrain_tag_layer(0)) and @watered == false
@watered = true
a_tipo = terrenos.index(self.terrain_tag_layer(0))
@character_name = RTH::GRAPHIC_CHAR_NADANDO[$game_party.actors[0].id][a_tipo]
for i in 1..2
tile_id = $game_map.data[self.x, self.y, i]
if tile_id != nil and tile_id > 0 and not terrenos.include?(self.terrain_tag_layer(i))
@watered = false
refresh
break
end
end
end
if @watered
if terrenos.include?(self.terrain_tag_layer(0))
@watered = true
a_tipo = terrenos.index(self.terrain_tag_layer(0))
@character_name = RTH::GRAPHIC_CHAR_NADANDO[$game_party.actors[0].id][a_tipo]
else
@watered = false
refresh
end
end
pre_mergulhed = @mergulhed
@oxigenio_barra.visible = false
@mergulhed = false
if Input.press?(RTH::MERGULHAR_BUTTON) and @watered and self.terrain_tag_layer(0) != terrenos[0]
@mergulhed = true
@character_name = $game_system.graphic_char_sub
@mergulhed_time -= $game_system.oxigen_time_speed
if Input.trigger?(RTH::MERGULHAR_BUTTON)
check_event_trigger_here([1,2])
end
elsif pre_mergulhed and @mergulhed == false
for i in 1..2
tile_id = $game_map.data[self.x, self.y, i]
if tile_id != nil and tile_id > 0 and not terrenos.include?(self.terrain_tag_layer(i))
@mergulhed = true
@character_name = $game_system.graphic_char_sub
@mergulhed_time -= $game_system.oxigen_time_speed
break
end
end
elsif @watered
@mergulhed_time += $game_system.ox_recover_time_water
else
@mergulhed_time += $game_system.ox_recover_time_terra
end
if @mergulhed_time >= $game_system.oxigen_max_time
@mergulhed_time = $game_system.oxigen_max_time
end
if @mergulhed_time < $game_system.oxigen_max_time
@oxigenio_barra.update
@oxigenio_barra.visible = true
end
if @mergulhed_time <= 0
@mergulhed_time = 0
if @no_oxigenio_time <= 0
$game_system.se_play(RTH::SEM_OXIGENIO_DANO_SE) if RTH::SEM_OXIGENIO_DANO_SE != nil
for actor in $game_party.actors
actor.hp -= $game_system.no_oxigen_dano
end
if $game_party.all_dead?
$scene = Scene_Gameover.new
end
@no_oxigenio_time = $game_system.no_oxigen_time
else
@no_oxigenio_time -= 1
end
else
@no_oxigenio_time = $game_system.no_oxigen_time
end
end
if @watered
$game_map.set_battleback_nada
end
if @mergulhed
$game_map.set_battleback_mergulha
end
if @watered or @mergulhed
$game_system.encounter_disabled = (not RTH::NADANDO_BATTLE_PERMITIDA)
end
if RTH::OXIGENIO_MERGULHADO_GAUGE == false
@oxigenio_barra.visible = false
end
rth_water_game_player_update
end
def passable?(x, y, d)
@watered = false if @watered == nil
@mergulhed = false if @mergulhed == nil
terrenos = [RTH::AGUA_RASA_TERRENO_ID, RTH::AGUA_NORMAL_TERRENO_ID, RTH::AGUA_FUNDA_TERRENO_ID]
if @watered
# Selecionar as novas coordenadas
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
if @mergulhed
unless terrenos.include?($game_map.terrain_tag_layer(new_x, new_y, 0))
return false
end
if $game_map.terrain_tag_layer(new_x, new_y, 0) == RTH::AGUA_RASA_TERRENO_ID
return false
end
end
item_tipo = RTH::ITEM_NADAR_AGUA_FUNDA_TIPO
item_id = RTH::ITEM_NADAR_AGUA_FUNDA
if $game_map.terrain_tag_layer(new_x, new_y, 0) == terrenos[2]
if item_tipo == 0 and $game_party.item_number(id) <= 0
return false
elsif item_tipo >= 1 and not $game_party.actors[0].equiped?(item_id, item_tipo-1)
return false
end
end
for i in 1..2
if $game_map.terrain_tag_layer(new_x, new_y, i) == RTH::NAO_MERGULHA_TERRENO_ID
return false
end
end
return true if @mergulhed
end
return rth_water_game_player_passable?(x, y, d)
end
def screen_z(height = 0)
@mergulhed = false if @mergulhed == nil
terrenos = [RTH::AGUA_RASA_TERRENO_ID, RTH::AGUA_NORMAL_TERRENO_ID, RTH::AGUA_FUNDA_TERRENO_ID]
z = (@real_y - $game_map.display_y + 3) / 4 + 32
if @mergulhed
for i in 1..2
tile_id = $game_map.data[self.x, self.y, i]
if tile_id != nil and tile_id > 0 and not terrenos.include?(self.terrain_tag_layer(i))
return -100
end
end
end
return rth_water_game_player_screen_z
end
end
class Scene_Map
alias rth_mergulha_scene_map_main main
def main
rth_mergulha_scene_map_main
$game_player.invisible_oxi_barra
end
end
class Sprite_Mergulhed < Sprite
def initialize
v = Viewport.new(16, 410, 120, 64)
v.z = 9999
super(v)
self.visible = false
self.bitmap = Bitmap.new(120, 64)
filled = ($game_player.mergulhed_time.to_f * 120.0 / $game_system.oxigen_max_time.to_f)
self.bitmap.draw_gauge("Oxigenio_Bar", 0, 32, 120, 32, filled, Color.new(68, 102, 255), Color.new(68, 250, 255), RTH::OXIGENIO_BARRA_OPACIDADE)
self.bitmap.clear
update
end
def update
self.bitmap.fill_rect(0, 0, 120, 32, Color.new(0, 0, 0, 0))
self.bitmap.draw_text(0, 0, 120, 32, RTH::OXIGENIO_BARRA_TEXTO.dup, 1)
h = self.bitmap.text_size(RTH::OXIGENIO_BARRA_TEXTO.dup).height
filled = ($game_player.mergulhed_time.to_f * 120.0 / $game_system.oxigen_max_time.to_f)
self.bitmap.draw_gauge("Oxigenio_Bar", 0, h, 120, 32, filled, Color.new(68, 102, 255), Color.new(68, 250, 255))
self.opacity = RTH::OXIGENIO_BARRA_OPACIDADE
self.z = 9999
end
end
- RafaelSOPAMembro
- Mensagens : 339
Reputação : 53
Re: Script de nadar
Qua Out 06, 2010 11:12 pm
Bela postagem dienifer \o/, acho que vai ser util em meu projeto...
- dieniferMembro
- Mensagens : 393
Reputação : 41
Re: Script de nadar
Qui Out 07, 2010 2:29 am
que bom que pude te ajudar
- cranem258Membro
- Mensagens : 245
Reputação : 37
Re: Script de nadar
Qua Dez 08, 2010 1:48 pm
Muito bom cara, já vou testar, achei muito criativo esse script, confesso que eu li quase todo ele...
Acho que é bem útil, só não sei quanto hp ele perde quando afoga...
Valeu!
Acho que é bem útil, só não sei quanto hp ele perde quando afoga...
Valeu!
- dieniferMembro
- Mensagens : 393
Reputação : 41
Re: Script de nadar
Sex Dez 24, 2010 3:09 am
Denada ,bom é bom ser util de vez em quando
Permissões neste sub-fórum
Não podes responder a tópicos
|
|