I am making an ABS first off. The battles take place on the actual map, not in a zoomed screen. I wanted to add status effects (States) to my weapons. After many attempts, I realized you cannot equip a weapon and it automatically inflict you outside of a battle. Even still, within a battle the affliction only works on enemies, not on a character.
I wrote a script (Probably the crappiest script anyone has ever seen) to fix my issue. It is as follows...
$game_party.actors[0].remove_state(30)
$game_party.actors[0].remove_state(31)
$game_party.actors[0].remove_state(32)
$game_party.actors[0].remove_state(33)
# Below is for Spear
if $game_party.actors[0].weapon_id == 1
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 2
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 3
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 4
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 5
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 6
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 7
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 8
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 9
$game_party.actors[0].add_state(30)
end
# Below is for knife
if $game_party.actors[0].weapon_id == 11
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 12
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 13
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 14
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 15
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 16
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 17
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 18
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 19
$game_party.actors[0].add_state(31)
end
# Below is for club
if $game_party.actors[0].weapon_id == 21
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 22
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 23
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 24
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 25
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 26
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 27
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 28
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 29
$game_party.actors[0].add_state(32)
end
# Below is for Creator
if $game_party.actors[0].weapon_id == 31
$game_party.actors[0].add_state(33)
end
A quick explanation... There are 3 weapon types. Spears, Knives and Clubs. There are nine of each type (Meaning 9 spears, 9 knives and 9 clubs). The one at the very end of the code called "Creator" is just something extra I threw in for testing purposes.
I tagged this code into Scene_Equip here...
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @item_window.item
# Change equipment
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
----------> HERE!!!!!!!!!!!!!! <----------
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
return
end
end
end
The final product is as follows...
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @item_window.item
# Change equipment
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
$game_party.actors[0].remove_state(30)
$game_party.actors[0].remove_state(31)
$game_party.actors[0].remove_state(32)
$game_party.actors[0].remove_state(33)
# Below is for Spear
if $game_party.actors[0].weapon_id == 1
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 2
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 3
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 4
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 5
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 6
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 7
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 8
$game_party.actors[0].add_state(30)
end
if $game_party.actors[0].weapon_id == 9
$game_party.actors[0].add_state(30)
end
# Below is for knife
if $game_party.actors[0].weapon_id == 11
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 12
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 13
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 14
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 15
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 16
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 17
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 18
$game_party.actors[0].add_state(31)
end
if $game_party.actors[0].weapon_id == 19
$game_party.actors[0].add_state(31)
end
# Below is for club
if $game_party.actors[0].weapon_id == 21
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 22
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 23
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 24
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 25
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 26
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 27
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 28
$game_party.actors[0].add_state(32)
end
if $game_party.actors[0].weapon_id == 29
$game_party.actors[0].add_state(32)
end
# Below is for Creator
if $game_party.actors[0].weapon_id == 31
$game_party.actors[0].add_state(33)
end
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
return
end
end
end
When I enter my game now, I can equip any weapon and become afflicted with whatever I want. I control what the status effect does from a common event.
My problem is that I originally wanted this script in its own window above MAIN, so that it can be called upon from Scene_Equip instead of a huge amount of crappy code tagged in there lol. I have no clue how to go about that as I am a complete newb to scripting. Making even what I have was a miracle enough. If anyone can write it better that would be much appreciated and perhaps find a way for me to call upon it from within Scene_Equip so that it can run from its own script page.
Side note : There is only one character in the game. So I never needed to add multiple character IDs. That is why it only applies to if $game_party.actors[0]
Thanks for looking into my newb script troubles.
I totally don't know if I did this right, but I tried haha.
EDITED:
Okay I tested it out, and this works!
class Scene_Equip
alias abs_update update_item
def update_item
# Original Code
abs_update
# If C button was pressed
if Input.trigger?(Input::C)
for s in (30..33)
$game_party.actors[0].remove_state(s)
end
# Below is for Spear
state_id = case $game_party.actors[0].weapon_id
when 0..9 then 30
# Below is for Knife
when 11..19 then 31
# Below is for Club
when 21..29 then 32
# Below is for Creator
when 31 then 33
end
# Apply State
$game_party.actors[0].add_state(state_id)
return
end
end
end
You can replace the if-else's with a case
state_id = case $game_party.actors[0].weapon_id
when 1..9 then 30
when 11..19 then 31
when 31 then 33
# and so on...
end
$game_party.actors[0].add_state(state_id)
Fixed. Omg, I'm learning o.o
Quote from: Zexion on February 12, 2014, 01:47:34 am
Fixed. Omg, I'm learning o.o
So I got rid of my crappy script and added yours into its own thingy above MAIN and it works lol. Pretty sure I implemented it right or else I wouldn't even be able to attack enemies so thank you! I will give you credit in my game :P
EDIT : I don't need to call upon this from scene_equip like I asked right? It seems to be working without being called on. Like I said, I am unfamiliar with a lot of scripting stuff.
No basically that little snip is just adding code to the end of "def update_item" in Scene_Equip.
Quote from: Zexion on February 13, 2014, 02:06:15 am
No basically that little snip is just adding code to the end of "def update_item" in Scene_Equip.
You know, just yesterday I took every weapon off of me and to my surprise I stayed inflicted with "Spear". I implemented my own fix and things are all good now but I just wanted to let you know.
:P
Oh yeah, my bad. I can see now why it would do that haha. Well at least you fixed it :P