Jump to content
Rpg²S Forum
  • 0

[Aiuto] Modifica, correzione e integrazione di uno script


TheVillAngel
 Share

Question

Ragazzi mi servirebbe una mano, avrei intenzione di utilizzare lo script Advanced Dash and Jump System ma avrei bisogno, se possibile, di un paio di (credo) semplici modifiche, oltre che di una correzione di un errore che si verifica.

 

Partiamo dall'errore: quando il pg è rivolto verso il basso, il primo salto viene eseguito senza problemi mentre dal secondo si verifica un errore poichè è richiesto un doppio suffisso al nome dell'immagine da utilizzare per il salto (praticamente quando il pg salta la sua grafica cambia passando da es. Hero1.png a Hero1_salta.png, SOLO SE rivolto verso il basso, al secondo salto viene richiesta l'immagine Hero1_salta_salta.png e credo così via, dato che non ho la possibilità di verificare)

 

Per quanto riguarda la modifica, si tratterebbe di eliminare la parte della corsa, visto che quello di cui ho bisogno è solo la funzone salto.

 

Per quanto riguarda l'integrazione, mi chiedevo se fosse possibile integrare il Complete Keyboard Input con lo script in questione, in modo da poter assegnare al salto un tasto qualunque e non solo quelli standard di rpg maker.

 

Qualcuno saprebbe aiutarmi?

Edited by TheVillAngel

premi(o XD)http://rpg2s.net/gif/SCContest1Oct.gif

Progetto in corso:

Light and Decay

 

 

My hysterical dog is watching you

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0
Guest clyde

Rimuovendo la corsa, rimuovi anche l'errore. La grafica aggiuntiva serviva per il personaggio in corsa e non per il salto.

Lo script con la corsa rimossa è il seguente:

 

 

#==============================================================================
# ATTENZIONE! QUESTO NON E' LO SCRIPT ORIGINALE!
#==============================================================================
# Corsa e Salto avanzati
# Autore : kingartur2
# Versione : 1.04
# Data :24 / 03 / 2010
#==============================================================================
module New_Player
#==============================================================================
# TABELLA DEI TASTI
#------------------------------------------------------------------------------
# Nome Tasto Corrispondente sul computer
# C Invio - C
# X A
# A Z - SHIFT
# R W
# L Q
# Z D
# Y S
# B - ESC B - ESC - X - 0(tastierino numerico)
#==============================================================================
# INIZIO PARTE EDITABILE
#==============================================================================
#==============================================================================
# Tasto per saltare
# : indica quale sarà il tasto usato per effetuare il salto
# per scegliere il tasto usa la tabellina che si trova in cima
#------------------------------------------------------------------------------
# Sintassi ::
# JUMP_KEY = Input::(Tasto scelto da te)
# - senza le parentesi
#------------------------------------------------------------------------------
JUMP_KEY = Input::X
#==============================================================================
# Distanza Salto normale
# : Distanza che coprirà un Salto effetuato mentre NON si corre
#------------------------------------------------------------------------------
# Sintassi ::
# JUMP_DISTANCE = integer
# - al posto di integer mettere un numero
#------------------------------------------------------------------------------
JUMP_DISTANCE = 2
end
$K2SCRIPT = {} if $K2SCRIPT == nil
$K2SCRIPT["Dash and Jump"] = true
class Game_Map
def priority(x, y)
 val = -100
 record = []
 for i in [0, 1, 2]
  if valid?(x,y)
record[i] = priorities[data[x, y, i]]
  else
record[i] = 1
  end
  if valid?(x,y) and priorities[data[x, y, i]] > val and
priorities[data[x, y, i]] < 5
val = priorities[data[x, y, i]]
  end
 end
 if val == -100
  val = 0
 end
 if record[1] == 5 and record[2] == 5
  return 0
 end
 return val
end
end

class Game_Player

alias initialize_running_king initialize
def initialize
 initialize_running_king
end

alias update_running_king update
def update
 update_running_king
 continuo_update
end

def continuo_update
 if $game_system.map_interpreter.running? or @move_route_forcing or
  $game_temp.message_window_showing
  return
 end
 if Input.trigger?(New_Player::JUMP_KEY)
  case Input.dir4
  when 2
turn_down
  when 4
turn_left
  when 6
turn_right
  when 8
turn_up
  end
  jump_passable(New_Player::JUMP_DISTANCE, true)
 end
end

def jump_passable(n, jumping = false)
 if n == 0
  if jumping
return
  else
return false
  end
 end
 if self.jumping?
  if jumping
return
  else
return false
  end
 end
 case self.direction
 when 2
  if not passable?(x, y + n, 0)
if jumping
 jump_passable(n - 1, true)
 return
else
 return false
end
  end
  for i in y...y + n
if $game_map.priority(x, i) > 0 and $game_map.priority(x, i) < 5
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
  end
  if jumping
jump(0, +n)
return
  end
  when 4
if not passable?(x - n, y, 0)
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
for i in x - n...x
 if $game_map.priority(i, y - 1) > 0 and $game_map.priority(i, y - 1) < 5
  if jumping
   jump_passable(n - 1, true)
   return
  else
   return false
  end
 end
end
if jumping
 jump(-n, 0)
 return
end
  when 6
if not passable?(x + n, y, 0)
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
for i in x...x + n
 if $game_map.priority(i, y - 1) > 0 and $game_map.priority(i, y - 1) < 5
  if jumping
   jump_passable(n - 1, true)
   return
  else
   return false
  end
 end
end
if jumping
 jump(+n, 0)
 return
end
  when 8
if not passable?(x, y - n, 0)
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
for i in y - n...y
 if $game_map.priority(x, i) > 0 and $game_map.priority(x, i) < 5
  if jumping
   jump_passable(n - 1, true)
   return
  else
   return false
  end
 end
end
if jumping
 jump(0, -n)
return
  end
 end
 return true
end

end
#==============================================================================
# FINE SCRIPT
#==============================================================================

 

 

Edited by clyde
Link to comment
Share on other sites

  • 0

Naturalmente:

dove vedi:

if Input.trigger(tasto)

sostituisci con:

if keyboard(tasto)

quindi guarda nel Complete Keyboard Input, ci sono elencati i tasti e come inserirli. :smile:

Link to comment
Share on other sites

  • 0
Guest clyde

Il Keyboard Input è una classe, e questa cosa a clyde non piace.

Game_Character < Input_keyboard restituisce errore.

Clyde ha trasformato la classe in modulo, e ha cambiato il metodo per ottenere se il tasto è premuto o no.

 

ATTENZIONE: Se utilizzi lo script per l'input da altre parti, inserendo la versione di clyde smetteranno di funzionare.

Correggi gli eventuali:

class nome < Input_keyboard

in:

class nome
include Input_keyboard

 

Keyboard Input Script:

 

 

# WARNING: THIS IS NOT THE ORIGINAL SCRIPT!
#====================================================
#
# Keyboard script v1																	   created by: cybersam
#
#====================================================
#
# hi guys.... it me again... ^-^
#
# now... this script is for more keys to press...
# anyone you like...
#
# i'll list here some of the buttons...
# on you're keyboard....
# not all of them of course...
# it would take to much time... ^-^
#
# you'll see that i prepared a mouse button handle already....
# but it only the buttons are recognized...
# after this i'll work on the mouse itself... so it can be displayed... ^-^
#
# i marked the change in the script
#
#====================================================
#=begin
module Input_keyboard

RMouse_BUTTON_L = 0x01		 # left mouse button
RMouse_BUTTON_R = 0x02		 # right mouse button
RMouse_BUTTON_M = 0x04		 # middle mouse button
RMouse_BUTTON_5 = 0x05		 # 4th mouse button # only tested with win2k with a logitech mouse (MX900)
RMouse_BUTTON_6 = 0x06		 # 5th mouse button # only tested with win2k with a logitech mouse (MX900)
R_Key_BACK	   = 0x08				# BACKSPACE key
R_Key_TAB		 = 0x09			   # TAB key
R_Key_RETURN   = 0x0D		  # ENTER key
R_Key_SHIFT	 = 0x10		 # SHIFT key
R_Key_PAUSE	 = 0x13		 # PAUSE key
R_Key_CAPITAL   = 0x14		 # CAPS LOCK key
R_Key_ESCAPE   = 0x1B		  # ESC key
R_Key_SPACE	 = 0x20		 # SPACEBAR
R_Key_PRIOR	 = 0x21		 # PAGE UP key
R_Key_NEXT	   = 0x22				# PAGE DOWN key
R_Key_END		 = 0x23			   # END key
R_Key_HOME	   = 0x24				# HOME key
R_Key_LEFT	   = 0x25				# LEFT ARROW key
R_Key_UP			   = 0x26		  # UP ARROW key
R_Key_RIGHT	 = 0x27		 # RIGHT ARROW key
R_Key_DOWN	   = 0x28				# DOWN ARROW key
R_Key_SELECT   = 0x29		  # SELECT key
R_Key_PRINT	 = 0x2A		 # PRINT key
R_Key_SNAPSHOT  = 0x2C		 # PRINT SCREEN key
R_Key_INSERT   = 0x2D		  # INS key
R_Key_DELETE   = 0x2E		  # DEL key

R_Key_0				 = 0x30		 # 0 key
R_Key_1				 = 0x31		 # 1 key
R_Key_2				 = 0x32		 # 2 key
R_Key_3				 = 0x33		 # 3 key
R_Key_4				 = 0x34		 # 4 key
R_Key_5				 = 0x35		 # 5 key
R_Key_6				 = 0x36		 # 6 key
R_Key_7				 = 0x37		 # 7 key
R_Key_8				 = 0x38		 # 8 key
R_Key_9				 = 0x39		 # 9 key
R_Key_A				 = 0x41		 # A key
R_Key_B				 = 0x42		 # B key
R_Key_C				 = 0x43		 # C key
R_Key_D				 = 0x44		 # D key
R_Key_E				 = 0x45		 # E key
R_Key_F				 = 0x46		 # F key
R_Key_G				 = 0x47		 # G key
R_Key_H				 = 0x48		 # H key
R_Key_I				 = 0x49		 # I key
R_Key_J				 = 0x4A		 # J key
R_Key_K				 = 0x4B		 # K key
R_Key_L				 = 0x4C		 # L key
R_Key_M				 = 0x4D		 # M key
R_Key_N				 = 0x4E		 # N key
R_Key_O				 = 0x4F		 # O key
R_Key_P				 = 0x50		 # P key
R_Key_Q				 = 0x51		 # Q key
R_Key_R				 = 0x52		 # R key
R_Key_S				 = 0x53		 # S key
R_Key_T				 = 0x54		 # T key
R_Key_U				 = 0x55		 # U key
R_Key_V				 = 0x56		 # V key
R_Key_W				 = 0x57		 # W key
R_Key_X				 = 0x58		 # X key
R_Key_Y				 = 0x59		 # Y key
R_Key_Z				 = 0x5A		 # Z key
R_Key_LWIN	  = 0x5B		  # Left Windows key (Microsoft Natural keyboard)
R_Key_RWIN	   = 0x5C				# Right Windows key (Natural keyboard)
R_Key_APPS	   = 0x5D				# Applications key (Natural keyboard)
R_Key_NUMPAD0  = 0x60		   # Numeric keypad 0 key
R_Key_NUMPAD1   = 0x61		 # Numeric keypad 1 key
R_Key_NUMPAD2   = 0x62		 # Numeric keypad 2 key
R_Key_NUMPAD3   = 0x63		 # Numeric keypad 3 key
R_Key_NUMPAD4   = 0x64		 # Numeric keypad 4 key
R_Key_NUMPAD5   = 0x65		 # Numeric keypad 5 key
R_Key_NUMPAD6   = 0x66		 # Numeric keypad 6 key
R_Key_NUMPAD7   = 0x67		 # Numeric keypad 7 key
R_Key_NUMPAD8   = 0x68		 # Numeric keypad 8 key
R_Key_NUMPAD9   = 0x69		 # Numeric keypad 9 key
R_Key_MULTIPLY  = 0x6A		 # Multiply key (*)
R_Key_ADD		 = 0x6B			   # Add key (+)
R_Key_SEPARATOR = 0x6C		 # Separator key
R_Key_SUBTRACT  = 0x6D		 # Subtract key (-)
R_Key_DECIMAL   = 0x6E		 # Decimal key
R_Key_DIVIDE   = 0x6F		  # Divide key (/)
R_Key_F1			   = 0x70		  # F1 key
R_Key_F2			   = 0x71		  # F2 key
R_Key_F3			   = 0x72		  # F3 key
R_Key_F4			   = 0x73		  # F4 key
R_Key_F5			   = 0x74		  # F5 key
R_Key_F6			   = 0x75		  # F6 key
R_Key_F7			   = 0x76		  # F7 key
R_Key_F8			   = 0x77		  # F8 key
R_Key_F9			   = 0x78		  # F9 key
R_Key_F10		 = 0x79			   # F10 key
R_Key_F11		 = 0x7A			   # F11 key
R_Key_F12		 = 0x7B			   # F12 key
R_Key_NUMLOCK   = 0x90		 # NUM LOCK key
R_Key_SCROLL   = 0x91		  # SCROLL LOCK key
R_Key_LSHIFT   = 0xA0		  # Left SHIFT key
R_Key_RSHIFT   = 0xA1		  # Right SHIFT key
R_Key_LCONTROL  = 0xA2		 # Left CONTROL key
R_Key_RCONTROL  = 0xA3		 # Right CONTROL key
R_Key_L_ALT	 = 0xA4		 # Left ALT key
R_Key_R_ALT	 = 0xA5		 # Right ALT key




GetAsyncKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
def keyboard(rkey)
 GetAsyncKeyState.call(rkey) < 0  # key 0
end

end

 

 

 

Jump Script:

 

 

#==============================================================================
# ATTENZIONE! QUESTO NON E' LO SCRIPT ORIGINALE!
#==============================================================================
# Corsa e Salto avanzati
# Autore : kingartur2
# Versione : 1.04
# Data :24 / 03 / 2010
#==============================================================================
module New_Player
#==============================================================================
# TABELLA DEI TASTI
#------------------------------------------------------------------------------
# Nome Tasto Corrispondente sul computer
# C Invio - C
# X A
# A Z - SHIFT
# R W
# L Q
# Z D
# Y S
# B - ESC B - ESC - X - 0(tastierino numerico)
#==============================================================================
# INIZIO PARTE EDITABILE
#==============================================================================
#==============================================================================
# Tasto per saltare
# : indica quale sarà il tasto usato per effetuare il salto
# per scegliere il tasto usa la tabellina che si trova in cima
#------------------------------------------------------------------------------
# Sintassi ::
# JUMP_KEY = Input::(Tasto scelto da te)
# - senza le parentesi
#------------------------------------------------------------------------------
JUMP_KEY = Input::X
#==============================================================================
# Distanza Salto normale
# : Distanza che coprirà un Salto effetuato mentre NON si corre
#------------------------------------------------------------------------------
# Sintassi ::
# JUMP_DISTANCE = integer
# - al posto di integer mettere un numero
#------------------------------------------------------------------------------
JUMP_DISTANCE = 2
end
$K2SCRIPT = {} if $K2SCRIPT == nil
$K2SCRIPT["Dash and Jump"] = true
class Game_Map
def priority(x, y)
 val = -100
 record = []
 for i in [0, 1, 2]
  if valid?(x,y)
record[i] = priorities[data[x, y, i]]
  else
record[i] = 1
  end
  if valid?(x,y) and priorities[data[x, y, i]] > val and
priorities[data[x, y, i]] < 5
val = priorities[data[x, y, i]]
  end
 end
 if val == -100
  val = 0
 end
 if record[1] == 5 and record[2] == 5
  return 0
 end
 return val
end
end

class Game_Player
 include Input_keyboard

alias initialize_running_king initialize
def initialize
 initialize_running_king
end

alias update_running_king update
def update
 update_running_king
 continuo_update
end

def continuo_update
 if $game_system.map_interpreter.running? or @move_route_forcing or
  $game_temp.message_window_showing
  return
 end
 if keyboard(R_Key_SPACE)
  case Input.dir4
  when 2
turn_down
  when 4
turn_left
  when 6
turn_right
  when 8
turn_up
  end
  jump_passable(New_Player::JUMP_DISTANCE, true)
 end
end

def jump_passable(n, jumping = false)
 if n == 0
  if jumping
return
  else
return false
  end
 end
 if self.jumping?
  if jumping
return
  else
return false
  end
 end
 case self.direction
 when 2
  if not passable?(x, y + n, 0)
if jumping
 jump_passable(n - 1, true)
 return
else
 return false
end
  end
  for i in y...y + n
if $game_map.priority(x, i) > 0 and $game_map.priority(x, i) < 5
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
  end
  if jumping
jump(0, +n)
return
  end
  when 4
if not passable?(x - n, y, 0)
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
for i in x - n...x
 if $game_map.priority(i, y - 1) > 0 and $game_map.priority(i, y - 1) < 5
  if jumping
   jump_passable(n - 1, true)
   return
  else
   return false
  end
 end
end
if jumping
 jump(-n, 0)
 return
end
  when 6
if not passable?(x + n, y, 0)
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
for i in x...x + n
 if $game_map.priority(i, y - 1) > 0 and $game_map.priority(i, y - 1) < 5
  if jumping
   jump_passable(n - 1, true)
   return
  else
   return false
  end
 end
end
if jumping
 jump(+n, 0)
 return
end
  when 8
if not passable?(x, y - n, 0)
 if jumping
  jump_passable(n - 1, true)
  return
 else
  return false
 end
end
for i in y - n...y
 if $game_map.priority(x, i) > 0 and $game_map.priority(x, i) < 5
  if jumping
   jump_passable(n - 1, true)
   return
  else
   return false
  end
 end
end
if jumping
 jump(0, -n)
return
  end
 end
 return true
end

end
#==============================================================================
# FINE SCRIPT
#==============================================================================

 

 

Edited by clyde
Link to comment
Share on other sites

  • 0

Grazie a entrambi, effettivamente avevo già provato il metodo postato da dilos ma avevo un errore di variabile non inizializzata.

Ma quindi in pratica se io lo utilizzo anche nello scene_map devo fare la stessa modifica e va tutto bene?

premi(o XD)http://rpg2s.net/gif/SCContest1Oct.gif

Progetto in corso:

Light and Decay

 

 

My hysterical dog is watching you

Link to comment
Share on other sites

  • 0
Guest clyde

Se lo usi nello scene map devi scrivere:

[altro]
...
class Scene_Map
include Input_keyboard
...
[altro]

 

Fai comunque una copia di backup per non correre rischi!

Edited by clyde
Link to comment
Share on other sites

  • 0
Si si non le provo mai direttamente sul progetto queste cose :-) ultima domanda, dal momento che l'input keyboard andava posizionato direttamente sotto gli interpreter, pena il non funzionamento, mantenendo la stessa posizione non dovrei avere problemi giusto? Comunque poi provo io al massimo, al momento non ho la possibilità.

premi(o XD)http://rpg2s.net/gif/SCContest1Oct.gif

Progetto in corso:

Light and Decay

 

 

My hysterical dog is watching you

Link to comment
Share on other sites

  • 0
Guest clyde
Così com'è non credo ci siano problemi di posizionamento, ma nel dubbio clyde ti consiglia di tenerlo dov'è. ^_^
Link to comment
Share on other sites

  • 0
Ok criceto, ringrazia clyde da parte mia, anche se ancora non ho capito come fa a lavorare con il cigolio della tua rotellina XD

premi(o XD)http://rpg2s.net/gif/SCContest1Oct.gif

Progetto in corso:

Light and Decay

 

 

My hysterical dog is watching you

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...