[XP]Simple RGSS Question

Started by cstb, September 19, 2008, 03:50:25 pm

Previous topic - Next topic

cstb

September 19, 2008, 03:50:25 pm Last Edit: September 19, 2008, 03:52:10 pm by cstb
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).
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

Aqua

self.battler.armor1_id 
self.battler.weapon_id


I think that should work.

cstb

September 19, 2008, 05:27:00 pm #2 Last Edit: September 19, 2008, 05:27:34 pm by cstb
sry i forgot to put this.i mean in battle how can i show it?And does it go in scene_battle1?
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

Aqua

September 19, 2008, 06:48:02 pm #3 Last Edit: September 20, 2008, 12:24:24 am by Aqua
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.

MGC

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.

cstb

October 02, 2008, 05:57:05 am #5 Last Edit: October 02, 2008, 06:08:41 am by cstb
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:!
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

MGC

That is a new method : just add the block before the final "end".

cstb

October 02, 2008, 06:10:56 am #7 Last Edit: October 02, 2008, 06:17:15 am by cstb
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.
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

MGC

What is the error message ?
What is the corresponding line in the code ?

cstb

Window_Command line 51: NoMethodError occured
undefined method `name' for nil:NilClass
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

MGC

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

cstb

Another Error :O.o:.It happens at the new line u add to Scene_Battle3 (Line 78).
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

MGC

What is the error message and your scenario ?

cstb

The Error happens when i have no weapon or shield :P.R u even checking if this works urself???
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

Blizzard

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?
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

cstb

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 :)
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

MGC

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 ?

cstb

October 05, 2008, 04:40:35 pm #17 Last Edit: October 05, 2008, 04:55:10 pm by cstb
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
Chronos: Failed project due to loss of data.
Maybe I could try again...


Which Final Fantasy Character Are You?
Final Fantasy 7

MGC

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 ?

Blizzard

October 06, 2008, 08:55:45 am #19 Last Edit: October 06, 2008, 09:04:38 am by Blizzard
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. :)
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.