ENEMY AI [ACE]

Posts

Pages: 1
Hello. I just want to ask you guys, if it possible to have a better enemy ai? i my case, i have for example an actor with 20 p.defense and 40 m.defense. the enemy has one skill with 40 p.attack and another with 30 magic attack. so my damage-formulas are these ones (p.atk - p.def = damage) and (m.atk - m.def = damage).

So my enemy does 40 p.damage - 20 defense = 20 damage taken to the actor. All Good!
But now the problem with the magic attack:
Enemy does 30 m.damage - 40 m.defense = 0 damage taken to the actor. Not Good, stupid enemy!

So as you see i need a script or something other that makes that the enemy (in this case) choose the p.attack do deal damage and not choose a skill who dont make any damage.

I hope you guys understand me. Any Ideas? I have the VXace maker. :)
well it's normal since you know 30-40 = -10 which is 0 since RM works with integer numbers. So your formula doesn't make much sense? :o
Craze
why would i heal when i could equip a morningstar
15170
I'm not going to write it for you, but I'll help point you in the right direction - this is the code I'm currently using in Edifice:

#------------------------------------------------------------------------------
# ■ Game_Unit
#------------------------------------------------------------------------------

class Game_Unit

def random_target
item = SceneManager.scene.subject.current_action.item
ele = item.damage.element_id
atkr = SceneManager.scene.subject

pool = []
for member in alive_members
odds = member.tgr
# Provoke
odds *= 5 if atkr.state?(13) and member == atkr.state_origin?(13)
# Elements
odds *= 1 + 2*(member.element_rate(ele)-1)
if ele == 2 # SOL Buffs/Debuffs
odds *= 1.4 if member.get_buff_level(4) < 0
odds *= 0.6 if member.get_buff_level(4) > 0
elsif ele == 2 # LUN Buffs/Debuffs
odds *= 1.4 if member.get_buff_level(5) < 0
odds *= 0.6 if member.get_buff_level(5) > 0
end

# Slightly more likely to be targeted at low HP (1.5x at 1% HP)
odds *= ((1 - 1.00 * member.hp / member.mhp) + 2) / 2

for i in 0..odds
pool.push(member)
end
end

return pool[rand(pool.size)]
#~ tgr_rand = rand * tgr_sum
#~ alive_members.each do |member|
#~ tgr_rand -= member.tgr
#~ return member if tgr_rand < 0
#~ end
alive_members[0]
end

end

The commented-out bit is the original code for random_target; as you can see, I've completely hijacked and rewritten it. It doesn't remove the TGR stat, so states like Firefly/Shadow (2.5x TGR, 0.3x TGR) still work perfectly. Feel free to take and edit this, just delete the buff-based section since it'd only work for my game (which overrides all of the buffs for my own effects).

It should be pretty easy to figure out what the lines are doing, and to add in your own conditions. To get aspects of the skill being used, ask stuff like "item.magical?".

odds *= 1.5 if item.magical? and (atkr.mat > member.mdf)
odds *= 0.65 if item.magical? and (atkr.mat < member.mdf)

atkr.mat > member.mdf ? odds *= 1.5 : odds *= 0.65 if item.magical?

(Both do the same thing, the latter is simply cleaner.)
Pages: 1