Check If Shield Equipped.

Status
Not open for further replies.

Puck

Warper
Member
Joined
Aug 31, 2013
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Sorry for such an unusual request but. Is there any way to check via the "Script" feature in the eventing option "Conditional Branch" or some simpler manner to see if the actor DOES or DOES NOT have any form of shield equipped?

I am using battlers that are a bit cosmetic where if the player has a shield equipped or not it changes it via "call script", but I noticed there is no option to see if the player has a shield equipped or not. Only a specific shield. It would cut me a ton of slack, not having to conditional branch every single shield that way if there was a scriptable way to do this to save a lot of time and monotonous eventing and testing.

Basically 

Check if player has shield or not.

If so it will call script to change his battler or if not keep it as is.

The battler portion I have fixed using Galv's battlers so that's just explaining WHY I needed this. If anyone could help me I would greatly appreciate it and credit them in my project.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
try this

$game_actor[id].armors.select {|item| [list1, list2, list3...].include?(item.atype_id) }.size > 0where id is the actor's id who you're checking, and [list1, list2, list3 ...] is an array of all the armor types (from the Terms tab) that are shields.
If you only have ONE armor type that's a shield, you can do this instead to make it shorter:

Code:
$game_actor[id].armors.select {|item| item.atype_id == shield_id }.size > 0
where shield_id is the armor type (from the Terms tab) of the shields.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I prefer do it in simple way

insert this script

class Game_Actor < Game_Battler def has_shield? armors.compact.any? {|armor| armor.etype_id == 1} endendAnd you may use it in conditional branch using this following script calls

$game_actors[id].has_shield?Not tested yet. But I'm sure it will works
 

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Yes it does, That's actually how I'm writing the script I was writing for this. I am adding in a lot more checks that you can not normally do too.

With this set up you can also do the different variations or actor, i.e. $game_party.members[0].has_sheild? || $game_party.battle_members[0].has_sheild? and it will also work the same.

There will be many more in the script, I will try to finish it soon.
 

Puck

Warper
Member
Joined
Aug 31, 2013
Messages
4
Reaction score
0
First Language
English
Primarily Uses
I prefer do it in simple way

insert this script

class Game_Actor < Game_Battler
def has_shield?
armors.compact.any? {|armor| armor.etype_id == 1}
end
end
And you may use it in conditional branch using this following script calls

$game_actors[id].has_shield?
Not tested yet. But I'm sure it will works

 
 I'll give it a shot and see if it works. I know little to nothing about scripting but we'll throw it to the wall and see what sticks. :3

Yes it does, That's actually how I'm writing the script I was writing for this. I am adding in a lot more checks that you can not normally do too.

With this set up you can also do the different variations or actor, i.e. $game_party.members[0].has_sheild? || $game_party.battle_members[0].has_sheild? and it will also work the same.

There will be many more in the script, I will try to finish it soon.
Thank you so much. I can wait for that then. It's not needed right away but would fix some odd graphical kinks and put some battlers I paid for to good use. I'll keep tabs on this and follow until then. It's greatly appreciated.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Just keep in mind that because they are defined in the Terms tab, what is a "shield" in one project may not be a "shield" in someone else's project. So you cannot default it to 1.

Also, etype_id tells you whether it's a weapon or armor. It does not tell you it's a shield. That's atype_id.
 
Last edited by a moderator:

Puck

Warper
Member
Joined
Aug 31, 2013
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Just keep in mind that because they are defined in the Terms tab, what is a "shield" in one project may not be a "shield" in someone else's project. So you cannot default it to 1.

Also, etype_id tells you whether it's a weapon or armor. It does not tell you it's a shield. That's atype_id.
Theodric's snippit of code worked. But if vincada has one or similar to contribute I am sure it will be a help to others.

Thank you Theodric. I tested it and it works.
 

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Here is v0.1. I'll be adding more checks tomorrow.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top