TRIHAN'S "MAKE ME A SCRIPT" TOPIC!

Posts

author=Trihan
class Game_Enemy < Game_Battler
  attr_accessor :scanned
  alias tri_scan_initialize initialize
  def initialize(index, enemy_id)
    tri_scan_initialize(index, enemy_id)
    @scanned = false
  end
  def scanned?
    @scanned
  end
end
  
class Window_BattleEnemy < Window_Selectable
  def draw_item(index)
    change_color(normal_color)
    enemy = $game_troop.alive_members[index]
    name = enemy.name
    if enemy.scanned?
      draw_text(item_rect_for_text(index), "#{name} (#{enemy.hp}/#{enemy.mhp})")
    else
      draw_text(item_rect_for_text(index), name)
    end
  end
end
There you go UPRC. You need to make the skill in question set the scanned property of the target to true. I did this by doing "b.scanned = true" in the formula window, but then it displays a message saying no damage was done so this obviously isn't the best way. I'd probably recommend implementing a notetag for it or something.


Hey, awesome! I'm a dummy though... put b.scanned = true in the notes area or call script via event? If I DO make it damage the enemy as well, what happens? It will just show the damage as usual and then their HP will be visible when they're selected next time?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
You put it in the damage calculation. If you make it damage the enemy as well, it will work exactly like you said.
Isn't the Damage Calculation a single line? how do you do multiple commands on a single line in Ruby?

EDIT:
oh yeah, I think I am going to try to see if YF's Follow Up skill will work for the 10 damage + 2 cold damage idea.


Did I ask about whether or not I could make two separate "death" conditions? Or somehow make it so that I could have a Revive skill for humans, and a Reboot for robots, and Reboot not work on humans and Revive not work on robots, for the purpose of removing the "death" condition.

Also, I've been told that the engine assumes that the first condition in the list is a "death" condition.
Adon237
if i had an allowance, i would give it to rmn
1743
If you are talking about like in the formula box, then you just use the ; to represent a line break. That might be the same thing in the editor~
Got it, now I understand. Many thanks Trihan, looking forward to trying it out!

I just thought of one other thing, though. Is it possible to have a tag to prevent certain monsters from having their HP revealed? That would be useful on major bosses and, eventually, the final boss.
probably easiest to do it in a battle event by assigning a variable IS_BOSS = True, and then modifying the draw_item method to check to make sure that the variable in question is not true

I don't know Ruby syntax, but it'd be like:
// if the enemy has been scanned and variable 1000 is false
if enemy.scanned? & !gamevariables.index(1000)
draw_text(item_rect_for_text(index), "#{name} (#{enemy.hp}/#{enemy.mhp})")
else
.....
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Just a quick checkin to say I haven't died and I haven't forgotten about this, I just have limited free time right now. I'll try to get to the unfulfilled requests soon.
author=Trihan
Just a quick checkin to say I haven't died and I haven't forgotten about this, I just have limited free time right now. I'll try to get to the unfulfilled requests soon.


do you still take request? me and a friend o'mine need a particular script for a custom save/load menu for a game we are making together. i don't know ho to script because i normally don't use vxAce so if you could help me out i'd appreciate it :)
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
I wasn't around for a while but I have a bit more free time now so hopefully I'll be able to start taking requests again. What kind of custom menu were you and your friend looking for?
Hi Trihan,

I was wondering...

Is it possible to have the ESC button open a menu that only has the options of Save, Load, Exit to Title, and Exit Game? No status, no list of party members, no inventory or anything like that.

Just, hitting ESC would bring up a menu in the middle of the screen that has
SAVE
LOAD
TO TITLE
EXIT

?

Thanks
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Yep!

Go to Window_MenuCommand and remove the following lines from make_command_list:
"add_main_comands"
"add_formation_command"

Then to go Scene_Menu and remove the following from the "start" method:
"create_gold_window"
"create_status_window"

Finally, in the "create_command_window" method, add the following lines underneath everything else:
"@command_window.x = (Graphics.width / 2) - (@command_window.width / 2)"
"@command_window.y = (Graphics.height / 2) - (@command_window.height / 2)"

If you want you can also remove those methods entirely and also delete the relevant handler settings in the create_command_window method of Scene_Menu, but that won't actually be necessary to make the thing work.

If you want to expand that to the actual options you listed (so rather than having an "end game" option that then gives you the "to title" and "exit" options you have the options in the menu), and an explicit "load" option from the menu rather than choosing continue at the title screen, let me know.
This works great, thanks!

EDIT:
In the load menu, can I show a value of a variable from the saved game, above the Time Elapsed?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Like this?
Imageshack is blocked at work, so I have no idea. I can't see the image.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
...oh. Well!

STEP THE FIRST

Add a new line to the "self.make_save_header" method of DataManager, just above the line that just says "header":
header[:variable] = $game_variables[id of variable you want on the load screen]

STEP THE SECOND

Add a new method to Window_SaveFile called draw_variable:

def draw_variable(x, y, width, height)
header = DataManager.load_header(@file_index)
return unless header
draw_text(x, y, width, line_height, header[:variable], 2)
end

STEP THE THIRD

Then in the "refresh" method, add this line to the bottom:
draw_variable(0, contents.height - (line_height * 2), contents.width - 4, 2)

can you explain the header[:variable] code? I don't understand the syntax or what that is supposed to mean.
I am considering adding a second variable to the savefile display, but I don't get what header[:variable] means.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
When the engine creates a save file header, it's really just storing a hashmap of the values (an array of key-value pairs where the key is a symbol, which is basically just a fancy variable beginning with a colon) that need to be available to the code for display in the load game scene.

To be honest, I just called the symbol for your thing :variable because that's what you wanted to store. I could just as easily have called it :kentona or :chocolatebar or :giraffe and it would have done exactly the same thing.

If you want to show a new value in the loading screen, you need to add it to the save file header so you can reference it later (you could reference the value directly, but this would show its actual value currently as opposed to the value it had when you saved the game), then add a method to Window_SaveFile that draws that value to the window wherever you want to show it, and add a call to that method in refresh.

Edit: I'll attempt to explain the header thing a bit better.

You know how arrays work: to access an array element you say the name of the array and the number of the element you want i.e. $game_variables[1] will return the first variable.

Hashmaps work with keys rather than values, but the idea is the same. If you set hashmapname[:symbol] to $game_variables[1] and then later on you have a draw_text call that uses hashmapname[:symbol] as the text to be drawn, it'll draw whatever value the variable was at when you added it to the hashmap. It's pretty much the same as an array only you can give your elements meaningful names.
thanks! I didn't know what significance :variable had. I couldn't tell if it was a key name, or a class name or a namespace or something else.

EDIT:

and here it is in action!
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Any time you see something in Ruby beginning with a colon it's a symbol. They're more complex than my explanation implies, but that's all you really need to know about them to effectively use them.
author=Trihan
I wasn't around for a while but I have a bit more free time now so hopefully I'll be able to start taking requests again. What kind of custom menu were you and your friend looking for?


hey, first off thanks for at least considering my request :P

well the the thing is, in this game you select one hero and you keep it for the rest of the game, there is no party, it's basically and action/adventure game. now overall the menu should look like the standard one (maybe the save boexs a little bit bigger) but instead of loading the actor sprites it should load a background immage which i will make and put somewhere in the graphic folder, maybe in a custom folder named save menu bitmap or stuff like that) if hero is actor number 1 or if it's actor 2, or the standard window skin if the save slot is empty, and then it should display the following info: Hero Name, Playtime, Date and Time of the last save, and if possible, the map name.