Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: cstb on September 19, 2008, 03:50:25 pm

Title: [XP]Simple RGSS Question
Post by: cstb on September 19, 2008, 03:50:25 pm
How can I Show the name of the actors weapon and shield?cuz i want it so when i go to block it shows block with (insert shield here) and when i go to weapon it shows attack with (insert weapon here).
Title: Re: [XP]Simple RGSS Question
Post by: Aqua on September 19, 2008, 05:17:24 pm
self.battler.armor1_id 
self.battler.weapon_id


I think that should work.
Title: Re: [XP]Simple RGSS Question
Post by: cstb on September 19, 2008, 05:27:00 pm
sry i forgot to put this.i mean in battle how can i show it?And does it go in scene_battle1?
Title: Re: [XP]Simple RGSS Question
Post by: Aqua on September 19, 2008, 06:48:02 pm
Scene_Battle1 Line 26
Change to:

s1 = "#{$data_system.words.attack} with #{$data_weapons[self.battler.weapon_id].name}"


Gimme a sec...

I need to figure out how to get the weapon name into a global variable... (it's probably something easy that I'm missing.
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 01, 2008, 05:40:15 pm
The command window must be dependant on the battler, so this window has to be refreshed every time it's called.
In Scene_Battle 3 you can find the method phase3_setup_command_window with :
    @actor_command_window.active = true
    @actor_command_window.visible = true

The command window becomes visible thanks to those lines, so it has to be refreshed in this method.
Just add before the 2 lines :
@actor_command_window.refresh_weapon_and_shield(@active_battler)


Now you have to create the new method refresh_weapon_and_shield in the class Window_Command. The method must just alter the first and third commands, dependant on the battler, then call a refresh.
So you must add in Window_Command :
  def refresh_weapon_and_shield(battler)
    @commands[0] = "Attack with " + $data_weapons[battler.weapon_id].name
    @commands[2] = "Block with " + $data_armors[battler.armor1_id].name
    refresh
  end


And if the text is too long for the window's width, you can modify this width in Scene_Battle 1 ; in main you can find :
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])

Just replace 160 by a bigger value.
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 02, 2008, 05:57:05 am
Ok, Trying now.
EDIT: i got confused after i got to the Window_Command part :(.Where in window command?
EDIT(again :haha:): I fooled around with the script edit and it WORKS!!!You have full credit for helpin with this!!!
Almost forgot :welcome: :clap:!
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 02, 2008, 06:05:50 am
That is a new method : just add the block before the final "end".
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 02, 2008, 06:10:56 am
Wow...Another error :P.When i attack with basil(im using a new project to test)The game Crashes!!!
EDIT:That happens when i have no shield on :(.I removed the shield part and if u have no weapon on anyways then it crashes again.Is there a way so when you unequip a weapon,you really equip some weapon called"Fists"or something.
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 02, 2008, 06:14:55 am
What is the error message ?
What is the corresponding line in the code ?
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 02, 2008, 06:19:10 am
Window_Command line 51: NoMethodError occured
undefined method `name' for nil:NilClass
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 02, 2008, 07:16:39 am
There is an easy solution : replace the method refresh_weapon_and_shield by :

  def refresh_weapon_and_shield(battler)
    if battler.weapon_id == 0
      @commands[0] = "Attack with fists"
    else
      @commands[0] = "Attack with " + $data_weapons[battler.weapon_id].name
    end
    if battler.armor1_id == 0
      @commands[2] = "Block with fists"
    else
      @commands[2] = "Block with " + $data_armors[battler.armor1_id].name
    end
    refresh
  end
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 02, 2008, 02:16:16 pm
Another Error :O.o:.It happens at the new line u add to Scene_Battle3 (Line 78).
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 03, 2008, 02:35:28 am
What is the error message and your scenario ?
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 03, 2008, 01:52:08 pm
The Error happens when i have no weapon or shield :P.R u even checking if this works urself???
Title: Re: [XP]Simple RGSS Question
Post by: Blizzard on October 03, 2008, 01:59:57 pm
That's kinda weird because these two branches assure that there is no error:

if battler.weapon_id == 0

if battler.armor1_id == 0


Can you post that line and the code section around it?
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 03, 2008, 02:08:45 pm
Heres the code i have
  def refresh_weapon_and_shield(battler)
    if battler.weapon_id == 0
      @commands[0] = "Attack with fists"
    else
      @commands[0] = "Attack with " + $data_weapons[battler.weapon_id].name
    end
    if battler.armor1_id == 0
      @commands[2] = "Block with fists"
    else
      @commands[2] = "Block with " + $data_armors[battler.armor1_id].name
    end
    refresh
  end
I put it at the end of window command like i was told :)
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 04, 2008, 05:45:32 am
QuoteR u even checking if this works urself???


That's weird...
In a new project, I just added :
@actor_command_window.refresh_weapon_and_shield(@active_battler)
in Scene_Battle 3
and 
Quotedef refresh_weapon_and_shield(battler)
    if battler.weapon_id == 0
      @commands[0] = "Attack with fists"
    else
      @commands[0] = "Attack with " + $data_weapons[battler.weapon_id].name
    end
    if battler.armor1_id == 0
      @commands[2] = "Block with fists"
    else
      @commands[2] = "Block with " + $data_armors[battler.armor1_id].name
    end
    refresh
  end
in Window_Command
and it worked...

QuoteIt happens at the new line u add to Scene_Battle3 (Line 78).

What's the message in the pop-up when the error occurs ?
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 05, 2008, 04:40:35 pm
Hmm...I tried it again and it worked :O.o:.How come it never worked last time :???:
EDIT: I Tried it with my RTAB thats in my game im makin.
ERROR:
Script 'Window_Command' line 51: NoMethodError occured.
undefined method `weapon_id' for nil:NilClass
Title: Re: [XP]Simple RGSS Question
Post by: MGC on October 06, 2008, 07:49:54 am
So your active battler is nil...

To avoid the error, you can add immediately after def refresh_weapon_and_shield(battler) :
return if battler.nil?

But in that case (no battler found) the window won't be refreshed.

Can you post your RTAB ?
Title: Re: [XP]Simple RGSS Question
Post by: Blizzard on October 06, 2008, 08:55:45 am
RTAB modifies many of the battle scripts by using an argument called battler which is used instead of @active_battler for the battle process (similar to your method). Specifically during action selection it's @active_actor instead. This piece of code is probably the troublemaker:

@actor_command_window.refresh_weapon_and_shield(@active_battler)


I hope this information helps. :)
Title: Re: [XP]Simple RGSS Question
Post by: cstb on October 06, 2008, 06:38:37 pm
I put both of your lines in and it WORKS :twitch: :clap: :clap: :dance: :dance: :dj: