- Joined
- Jul 31, 2013
- Messages
- 21
- Reaction score
- 1
- First Language
- English
- Primarily Uses
Hello, all. I'm currently attempting to write up my own script that will detect if there are multiple enemies of the same type in a troop and if so, account for that in the "<x> emerged!" message at the start of combat. Currently I'm trying to do this through modification of the enemy_names method under the Game_Troop class. As a test case, my enemy name is "Varg". What this should be doing is making it so that it says "Vargs emerged!" if I have more than one in a troop. But instead, it's still spitting out "Varg emerged!" even though there are four in the pack.
#-------------------------------------------------------------------------- # * Get Enemy Name Array # For display at start of battle. Overlapping names are pluralized. #-------------------------------------------------------------------------- def enemy_names names = [] #Array of names returned checkedTwice = [] #Array of names pluralized members.each do |enemy| #Loops through each member of the troop next unless enemy.alive? #Skips to next enemy if the current one is dead next if checkedTwice.include?(enemy.original_name)#Skips if already plural if names.include?(enemy.original_name) #If already checked once... checkedTwice.push(enemy.original_name)#Moves to pluralized list names.each do |name| #Checks each name in names[] if (name == enemy.original_name) #If it matches the current enemy...# name = pluralize(name) name = name + "s" #Changes name to pluralized version end #Ends if branch end #Ends pluralizer loop else #If the name hasn't been checked yet... names.push(enemy.original_name) #Adds it to names[] end #Ends checked-or-unchecked if/else end #Ends troop member-checking loop names #Returns names[] end #Ends definitionFrom what I can tell, I feel like the logic should be working fine, but for some reason, the pluralization is not being done, or it's being done wrong or...I don't know. I have no idea how to follow the path of what this method's doing to see what's going wrong. Anyone have any insight? Something obvious I've overlooked? The latter is entirely possible since I'm still rather new both Ruby and this whole scripting thing...
Thanks in advance for any help and advice.
#-------------------------------------------------------------------------- # * Get Enemy Name Array # For display at start of battle. Overlapping names are pluralized. #-------------------------------------------------------------------------- def enemy_names names = [] #Array of names returned checkedTwice = [] #Array of names pluralized members.each do |enemy| #Loops through each member of the troop next unless enemy.alive? #Skips to next enemy if the current one is dead next if checkedTwice.include?(enemy.original_name)#Skips if already plural if names.include?(enemy.original_name) #If already checked once... checkedTwice.push(enemy.original_name)#Moves to pluralized list names.each do |name| #Checks each name in names[] if (name == enemy.original_name) #If it matches the current enemy...# name = pluralize(name) name = name + "s" #Changes name to pluralized version end #Ends if branch end #Ends pluralizer loop else #If the name hasn't been checked yet... names.push(enemy.original_name) #Adds it to names[] end #Ends checked-or-unchecked if/else end #Ends troop member-checking loop names #Returns names[] end #Ends definitionFrom what I can tell, I feel like the logic should be working fine, but for some reason, the pluralization is not being done, or it's being done wrong or...I don't know. I have no idea how to follow the path of what this method's doing to see what's going wrong. Anyone have any insight? Something obvious I've overlooked? The latter is entirely possible since I'm still rather new both Ruby and this whole scripting thing...
Thanks in advance for any help and advice.


