Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A question about Enemy Elemental Defense

First, what is the syntax for checking the elemental affiliation of an enemy?

I've made a common event that is called when you cast a certain spell. I would like the effects to be affected by the elemental affiliation of the enemy it's targetted. There a way to do that using scripts? Is it possible from a common event [since common events don't have enemy placement information]? Is it possible at all?

Is there a way to check the number of enemies in a troop from a common event? Then use that number to check the element effectiveness for each member of the troop? And finally, what if I wanted to find the element affinity for "Earth"?

Actually you know what.... Is there way a way to just check for a certain element affinity without checking all the enemies in a troop? Like if I use a conditional Branch saying;

Code:
If "Element affinity = B" then
   damage 50%
end
Or something to the like? Something that automatically checks the enemies in the troop for this affinity and acts accordingly?

Is that possible?

Thanks in advance,
Firestalker
 
Just a quick update:

I was able to finally get Local Movement Script to work. Apparently I'm an idiot and forgot to add the wait 1 in the loop. So Second question done.

But I still need the first question answered.
 

khmp

Sponsor

Sorry for the late reply:

$game_troop.enemies[0].element_ranks[0]

That will get you elemental rank for whatever the first element is of the first enemy in a troop selection. Assuming you were in a new project and fought the first troop it would be the elemental effectiveness of a Ghost against fire which would be 1 for B. Hope this helps you.

(0: A, 1: B, 2: C, 3: D, 4: E, 5: F)

Good luck with it Firestalker5! :thumb:
 
Thank you very much for the code Khmp. You are by far the most helpful person I have met on this site.

If I may ask a few more questions about this though. just so I understand exactly how this works.

Is there a way to check the number of enemies in a troop from a common event? Then use that number to check the element effectiveness for each member of the troop? And finally, what if I wanted to find the element affinity for "Earth"?

Actually you know what.... Is there way a way to just check for a certain element affinity without checking all the enemies in a troop? Like if I use a conditional Branch saying;

Code:
If "Element affinity = B" then
   damage 50%
end
Or something to the like? Something that automatically checks the enemies in the troop for this affinity and acts accordingly?

Is that possible?

Thanks in advance,
Firestalker
 

khmp

Sponsor

Well to start. How to check the number of enemies? You could use "Script..."
Code:
x = $game_troop.enemies.size # The amount of enemies.
Or if you wanted to save it in a game variable because you use it over and over.
Code:
$game_variables[x] = $game_troop.enemies.size
Where x is the index of the variable you want to store the number of enemies currently fighting. I don't believe there is an event command to do it. :-/

I'm not sure about the rest though Firestalker. Personally I would just edit some scripts so its done automatically when a game_switch or some other condition is active. I've looked through the code and I've debated about how to go about it. I think you'll need the help of someone more knowledgeable than me, but I think it will involve how the element_rate method in Game_Enemy is handled.
 
Is there a way to do a blanket check of all the enemies in the troop? Then use conditional branches to make the skill act automatically to that affinity?

You want to check the enemy that is targeted by the spell or all of the enemies in the group? I'm kinda confuse. But it's possible, either way

How about how do you do it for both?
 
Ok I've created a method to make it easy for you to check. However, I think it's still not that efficient to use it through common event during the battle. Thus I want to change a script into, "a skill that result into other skill, depending on target's elemental defense." Would that work too?

For example, there are three skills, "A" is a skill that deal 20 dmg and "B" is a skill that kill enemy instantly. "C" is a special skill that if an enemy has elemental defense of "Water" at rate A, the skill will call skill "B" instead. Otherwise it calls "A".

And about checking all the enemies elemental defense..how would say that the result is true or false? All enemies have to have the same elemental rate you check or just some?
 
Actually it's more like this:

troop one;
mon has 'A' rank to fire
mon has 'D' rank to fire

can there be common event that checks both mon's and have it do something different for each rank?

like:

If "Element affinity = A" then
damage 50%
end
If "Element affinity = D" then
damage 125%
end
Deal damage to Monster

Mon recieves 50 dam
monster recieves 125 dam

You kinda get it? Is that possible?
 
That's possible, but it'll be really inefficient if used in common event. Since you have to have fork condition for every single monster in the troop and for all possible affinities :S

Also, the damage calculation cannot be change during the process of common event, because common event occur "after" the skill is used. So I would have to ask whether you want to change the damage recieved by enemies only or you want some other effects too?

In any case, here's the script

http://community.thaiware.com/index.php?act=attach&type=post&id=62956

To use this, you can check the enemies' affirnity by typing this into the condition.
Code:
($scene.target_battlers[0].element_rank_check(1,"A"))

This would check the first enemy in the target array (hence 0 position) for its affinity of "Fire" (number 1 is for element id.) whether the rating is A or not.

And then inside the if condition, you can put anything you want :)

As you can see...this mean you have to create a cycle that loop and check this for all the enemies in the target array, and since when dealing damage through event, you have to be specific which monster you want to deal damage to. This makes it more inefficient as you need more and more if condition :(
 
Thank you for the script I'll try it out if all else fails.

It occurs to me that I might not have explained myself all that well. So this time I'll use pictures.

This is the Skill that calls the event:
http://i38.photobucket.com/albums/e134/ ... /Skill.png[/IMG]

As you can see it does nothing but call the common event. It's mostly just a way to call the event.

This is the Common Event it calls:
http://i38.photobucket.com/albums/e134/ ... nEvent.png[/IMG]

As you can see the Common Event does all the work. Using variables and Deal Damage event commands I have made the damage random. I only want the event to check all the monster in the troop for the "Earth" element and it's affinity to it. I can then change the damage variable accordingly.

Is that a little more clear? I realize that I probably wasn't entirely clear on my wording.

I literally mean using a Conditional Branch, like so:

If "Call Script: Enemy Element Affinity[Earth] = B" then
Damage Variable: 50%
end

I can copy and paste that and just change the Letter for the desired affect.

I hope this helps a little better.
 
class Scene_Battle
attr_accessor :target_battlers
end

class Game_Battler
#--------------------------------------------------------------------------
# - Element Rank Check -
# element_id - The id of the element you want to check, according to the
# database
# rank - The rank of element you want to check. Range from A - E
#
# return true or false
#--------------------------------------------------------------------------
def element_rank_check(element_id,rank)
result_compare = {"A"=>1,"B"=>2,"C"=>3,"D"=>4,"E"=>5}
if self.is_a?(Game_Actor)
result = $data_classes[self.class_id].element_ranks[element_id]
else
result = $data_enemies[self.enemy_id].element_ranks[element_id]
end
# Method end
return (result==result_compare[rank])
end #method
end

class Game_Enemy < Game_Battler
attr_accessor :enemy_id
end

Above main would be the best place to put this script :)
 

khmp

Sponsor

You need to edit it so the lighting on the carpet is constant :P Then I wouldn't stop looking at it. Shaolin Soccer and Kung Fu Hustle are the only ones I saw and they were pretty good.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top