RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RESOLVED] Alignment Bar With scripting?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 87
...I'M HUNGRY! Food plawks
I would like to add a gradient bar to the character menu to graphically display the players alignment. With my limited scripting knowledge, I'm assuming this could be done as an add-on to the basic menu-screen script. Ideally, it would be   red on one side and fade to blue on the other (like KoTOR) but I'd be satisfied with any graphical representation (say, a line with a dot on it) rather than having it simply display the value of the variable.

I Use XP. I have no idea how much work it would be to put this modification together, or whether I'm even looking at the solution the right way. If anyone knows how to do this, would like to slap it together for me  ;D, or knows of a pre-existing mod, please post.
« Last Edit: May 14, 2007, 04:38:07 AM by Zeriab »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I did something similar for Black Shadow. Where do you want the bar to show up in your menu?

***
Rep:
Level 87
...I'M HUNGRY! Food plawks
I guess ideally it would appear over equipped items (to the right of hp) under character status...at this point, I think the alignment will only affect the main hero, though.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Okay, here it is. Just replace your Window_Status script with this:

Code: [Select]
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  def draw_alignment(id, x, y)
     src_rect = Rect.new(0, 0, 185, 40)
     self.contents.blt(x, y, RPG::Cache.picture("Good-Bad"), src_rect, 255)
     a = $game_variables[id]
     if a > 80
       a = 80
     end
     if a < -80
       a = -80
     end
     src_rect = Rect.new(0, 0, 30, 30)
     self.contents.blt(78 + x + a,y + 4, RPG::Cache.picture("Good-Bad Icon"), src_rect, 255)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 4 + 144, 0)
    draw_actor_level(@actor, 96, 32)
    draw_actor_state(@actor, 96, 64)
    draw_actor_hp(@actor, 96, 112, 172)
    draw_actor_sp(@actor, 96, 144, 172)
    draw_actor_parameter(@actor, 96, 192, 0)
    draw_actor_parameter(@actor, 96, 224, 1)
    draw_actor_parameter(@actor, 96, 256, 2)
    draw_actor_parameter(@actor, 96, 304, 3)
    draw_actor_parameter(@actor, 96, 336, 4)
    draw_actor_parameter(@actor, 96, 368, 5)
    draw_actor_parameter(@actor, 96, 400, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(320, 48, 80, 32, "EXP")
    self.contents.draw_text(320, 80, 80, 32, "NEXT")
    self.contents.font.color = normal_color
    self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
    self.contents.font.color = system_color
    if (@actor.id == 1)
       draw_alignment(4, 320, 120)
    end
    self.contents.draw_text(320, 160, 96, 32, "Equipment")
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
  end
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400)
  end
end

The only things I added were this:


  def draw_alignment(id, x, y)
     src_rect = Rect.new(0, 0, 185, 40)
     self.contents.blt(x, y, RPG::Cache.picture("Good-Bad"), src_rect, 255)
     a = $game_variables[id]
     if a > 80
       a = 80
     end
     if a < -80
       a = -80
     end
     src_rect = Rect.new(0, 0, 30, 30)
     self.contents.blt(78 + x + a,y + 4, RPG::Cache.picture("Good-Bad Icon"), src_rect, 255)
  end


and this:


    if (@actor.id == 1)
       draw_alignment(4, 320, 120)
    end


This second part, you have to edit. The way I did it (most scripters hate doing this, but I think it makes it easier for the user), is I have the alignment meter controlled by an in-game variable. I.E., one of the variables you control with the event command Control Variables. The things you have to edit are the numbers in that second segment I just posted.

The 1 in if (@actor.id == 1) is the ID of your main hero. The 4 in draw_alignment(4, 320, 120) is the ID of the variable you want to use to control alignment. The 320 is the x-coordinate and the 120 is the y-coordinate. Once the hero hits 80 or -80, the meter will stop advancing if he gets more good or more evil.

So, basically, if you add 1 to the variable, the meter will move 1 pixel to the right, and if you subtract 1, it will move one pixel to the left.

You can edit the look of the bar, that was just something I made quickly in paint. Try to keep it the same width and height. If you want any edits and don't know how to script them in, just post back and I will make the necessary adjustments. (For example, if you wanted a larger bar, or if you want a wider range then 160... etc...). Also, if you don't understand something, post back.

***
Rep:
Level 87
...I'M HUNGRY! Food plawks
Wow, thanks so much Algebra, I really appreciate this! It looks like exactly what I was hoping for, and you put it together fast! I'll probably start playing with it tomorrow, and if I have any problems, I'll let you know.
Thanks again!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Oh, and you need these:


Lol, I'm terrible at life sometimes  ;8

Here's what it looks like:



And, as I said, if you want a different graphic, just try and keep the same size as the original picture, or, if you need it to be wider, then just post with the specifications and I will make the necessary adjustments.
« Last Edit: May 13, 2007, 05:12:20 AM by modern algebra »

***
Rep:
Level 87
...I'M HUNGRY! Food plawks
Ooooh, purty  ;D I was just working on my own, but that makes things easier. Thanks!

***
Rep:
Level 87
...I'M HUNGRY! Food plawks
Quick Question: How can I fix this? And yes, the variable is at zero...modding the icons x and y?
http://img150.imageshack.us/my.php?image=untitledqa4.png

ffs...why dont images I post ever show up...it works for my sig   :(

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Did you copy the bar after clicking on the image to enlarge it? I think that may be the problem. You saved the smaller image into your game.


Otherwise, that's a strange little problem, but easy to fix. Go into that bigger portion of my addition:
Spoiler for:
  def draw_alignment(id, x, y)
     src_rect = Rect.new(0, 0, 185, 40)
     self.contents.blt(x, y, RPG::Cache.picture("Good-Bad"), src_rect, 255)
     a = $game_variables[id]
     if a > 80
       a = 80
     end
     if a < -80
       a = -80
     end
     src_rect = Rect.new(0, 0, 30, 30)
     self.contents.blt(78 + x + a,y + 4, RPG::Cache.picture("Good-Bad Icon"), src_rect, 255)
  end


self.contents.blt(78 + x + a,y + 4, RPG::Cache.picture("Good-Bad Icon"), src_rect, 255)

See that 78+x+a? a is the value of the variable you are using, x is the x-coordinate of the bar, and 78 is the number you want to change. You'll want to reduce the number a little bit. I can't say for sure exactly how much... maybe to 74?
« Last Edit: May 13, 2007, 01:53:04 PM by modern algebra »

***
Rep:
Level 87
...I'M HUNGRY! Food plawks
That fixed it! I think I'm starting to get an idea how it works, so I should be able to troubleshoot anything myself  ;D Thanks again, algebra, you rock out loud  ^-^