New account registration is temporarily disabled.

[RM2K3] QUESTION/REQUEST : TIPS TO CREATE A CUSTOM ENEMY AI IN DBS?

Posts

Pages: 1
Greetings, making a modified DBS enemy AI has been my goals for a while now. However, I can't seem to pull it off...efficiently. Thus I wonder if any of you have some insight on how to make:

(Note: It doesn't have to be the working code, just idea on which function to use (and actually can be pulled off) would be great)

1. Scripting enemy attack
I find it quite easy to make a custom skill (calculation and execution and whatnot) because there is the "If enemy x is targetted" trigger. However, there is no such thing for the heroes themselves (I think..?) so it's a bit tougher to try and emulate enemy attacks...

I thought of assigning it to random value (if 1 then attack hero 1) or "HAAAATE VALUE" - which should be kind of easy, but then, if I am to allow multiple party members (switchings) this method hits the wall again.

Simply put, it'd be a piece of cake if you have a static party, person A to C. But if the party ranges from A-Z (no), it's.. going to be tedious I think.

So the main question is :
A. what do you think of this method and
B. Is there an easy method to assigning target (enemy to heroes) that basically is (depending on the roll) "if party member 1 is attacked" instead of "if A is attacked" ? I can think of using storing variables but I'd like to hear any alternatives

2. Skills duplicates and execution?
Right, now the problem on the heroes' side. AGAIN, it shouldn't be easy if you have a static party, OR like in Alter Aila where it's always the same MP value used in the attack ("Variables" "checks MP" -- "if reduce by 2 then hero A is using skill A" and "if reduce by 4, then Hero A use skill B" so on).

It's pretty hard to pull off, but at least there isn't tons of trigger.

Now, if the heroes can learn skill from the same pool, this one starts to get really tedious as well. I.e duplicating the whole skill for each hero (ex. HERO A skill A switch and so on). Not to mention that there will be tons of trigger as the result in the monster group....

So the main issue is : Is there a way to organize skill for ease of scripting apart from using the variable method above (assuming you want minimize triggers and using custom calculation. Man, I am not even sure if you can assign target to SWITCH type skill so this might be a moot method)

----

Thanks for the read, any tips?

Aside from abandon Rm2k3, use VX, or wait for Rm2Million (the latter sounds pretty nice, though I dunno when it's gonna be finished).

ADD:
If it's any help my goal was to allow:
1. Changing Resistance in battle (so it has to be custom)
2. Easier Defense stat calculation
3. Multiple hit skill (random??)
4. Alas, benefits of using skill or action (see Etrian Odyssey III) such as countering, healing and provoking
I think the way I did targeting was to store the IDs of the hero's currently in the party, and then using a random number between 1 and 4, and then do IF checks,

If random = 1
Set target = value of variable storing the hero ID in position 1
If random = 2
Set target = value of variable storing the hero ID in position 2
etc...

And then when reducing HP (or whatever) the target is "Character with ID stored in: target variable"

If you also have variable party sizes, you'd have to account for that using the random number and the size of the party. (random number between 1 and 3, 1 and 2, etc...)

You would also have to track who is in the party in these variables, OR run a common event before every battle that figures it out dynamically.
I can't seem to visualize that Kentona, do you have a coding screenshot mayhaps? Thanks! :D
@Kentona
Yeah, that's pretty much what I am thinking. I just thought whether there is an alternate way to do this.

However, if I want to say, create a provoke or counter skill (which alter the random roll and null attack for example) I think Storing ID won't work very well then? Since I have to personalize the check for each character (i.e. check whether that person have Counter skill)? Is it possible to implement this using hero ID?

@DarkFlameWolf
I think it'd be something like:
1. Assign "Party size" variable. This will be 1-4 depending on how much people is in the current party

2. check and store party member's position (hero id - I haven't test much with this function, but I am pretty sure this is how it works - check later). I.e who is in position A and who is in Position B etc

3. Simulate enemy using their "attack" skill (there are many ways, so I will skip this). Then use random 1-4 number to determine which target he will pick.

4. Reduce HP of the attacked member using the stored variable in 2. I.e. if the monster attack the 1st position, check which of the hero is there, then assign damage accordingly.

-----

Also any takers on question 2?
Nvm, it's pretty much impossible annoyingly tedious if you have inter-changeable party (especially with large roster of heroes).

There is no easy way to "Show battle animation" to assigned party member slot (ex. the 1st one in the party) - only show battle animation to Hero A, B, C etc is available!

So yeah, :(

*sigh*
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
I have a common event that determines which four party members are on the team, and assigns their IDs to four variables named "1st party member", "2nd party member", etc. The common event itself is fairly long and tedious, but worth the effort. It makes so many things so much easier.

In this case, it would make your events about 100x less tedious. Mind you, you'd still need a case for each character. But all you'd need to do is:

Run Common Event: IdentifyPartyMembers
Variable Operation: TargetVar1 = random (1-4)

Conditional Branch: If TargetVar1 is equal to 1:
- Variable Operation: TargetVar2 = Value of Variable 1stPartyMember
end branch
Conditional Branch: If TargetVar1 is equal to 2:
- Variable Operation: TargetVar2 = Value of Variable 2ndPartyMember
end branch
Conditional Branch: If TargetVar1 is equal to 3:
- Variable Operation: TargetVar3 = Value of Variable 3rdPartyMember
end branch
Conditional Branch: If TargetVar1 is equal to 4:
- Variable Operation: TargetVar2 = Value of Variable 4thPartyMember
end branch

Conditional Branch: If TargetVar2 is equal to 1:
- Deal damage to Character 1
- Show animation on Character 1
end branch
Conditional Branch: If TargetVar2 is equal to 2:
- Deal damage to Character 2
- Show animation on Character 2
end branch
...and then continue to make more branches, like these two, for every possible party member.
K-hos
whoa You guys are hi-chaining without me? That's just not right. :<
721
author=kentona
I think the way I did targeting was to store the IDs of the hero's currently in the party, and then using a random number between 1 and 4, and then do IF checks,

If random = 1
Set target = value of variable storing the hero ID in position 1
If random = 2
Set target = value of variable storing the hero ID in position 2
etc...

And then when reducing HP (or whatever) the target is "Character with ID stored in: target variable"

If you also have variable party sizes, you'd have to account for that using the random number and the size of the party. (random number between 1 and 3, 1 and 2, etc...)

You would also have to track who is in the party in these variables, OR run a common event before every battle that figures it out dynamically.


In addition to or instead of random, you could actually make them choose.

Pseudocode;

i is 0
heaviest is 0
heaviest_id is 0
weight_list is empty

while i is less than heros in party then
add ( ( hero_hp + hero_mp ) * ( hero_atk/1.05 ) ) to a new index in weight_list
// That formula is totally dumb, but you get the idea, you pretty much want to grade your
// heroes on what their currant condition is.
increment i
end

set i to 0

// This loop will figure out who is the weakest in the group.
while i is less than or equal to length of weight_list then

if wight at index i in weight_list is more than heaviest then
heaviest now equals wight at index i in weight_list
heaviest_id now equals i
end

increment i
end

attack hero with heaviest_id id

Obviously you would need to make it more complex, otherwise the enemy would just attack the weakest (and end up being the same) character each turn.
You could do this in several ways, such as giving the enemy a different preference for what it wants to attack each turn, this preference could be based on different stats.

For instance lets say that the enemy has a preference for attacking a hero who has mid rage attack this turn. Then instead of basing the weights in the list above on hp and such
you could base them on physical and magical attack and then to get the id you would check if the weight of a hero is around the middle of the average of the list of weights.


How that enemy comes up with that preference could either be just random, or what the heroes did last turn, the enemies current condition and maybe a little random for the slightly
insane enemies.


I hope that was relevant/understandable.
@locke
Here's what I have so far (simpl.):

*1+2 is common event function to reduce clutter
1. Check if party size is 1-4
2. Random value 1-4, depending on (1) - this choose the target
3. Realized that show animation is HERO based - stops

So to emulate one (show animation) enemy attack I will have to use a somewhat...tedious (long) codes (I don't think I can use common event here to simplify it further) in monster group.

I think your suggestion would work (I think I get what you are trying to say) but can you give an example? I..uh, can't seem to grasp it fully (sorry, fatiqued)

EDIT
I feel dumb already
So what you are saying is Instead of the old code above, we use this:

Now:
-Random No. 1-4
-If VarTarget = VarPSlot2
-If VarPSlot2 = (For example, hero 3)
-Show Battle animation at Hero 3
-Repeat
-Headache at the huge code clutter

Something like this right? And yes, this is pretty doable I think!

@K-HOS
Hmm... I wonder if the Rm2k3 programming also take this account when they decide which hero the enemy would attack...

Any clue? Cause yeah, randomness ain't too good.

---

Hmm, I am still having issues with the 2nd question - It seems the only way is to use (MP) calculation to determine what attack is used (i.e. there is no way to implement the feature "If hero use X command" to the skill subset i.e. if hero use skill A or something)?

I hope there is some other way around this cause some skills have similar MP costs :(

But thanks for the input guys!
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Look at my post again, there are no embedded conditional statements! It is actually even simpler than you think. In my post, I use the dash to represent an indentation, since rpgmaker.net's forums strip extra spaces out from posts. Does knowing that make it easier to read?

It looks like your new version still would have four copies of the damage/animation per hero - one for each spot he can be in. My version only has one copy of the damage/animation per hero.

By the way, it occurs to me that if you sometimes have less than four characters in the party, then you can't actually use random 1-4. You'll need to use random 1-12, and then take that random number and modulus it by the number of party members. I am sure there is a modulus operation in RM2K3's variable operations. It might be called "mod" or "%".
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
In regards to your second question, I think an alternate method that allows targeting and doesn't rely on MP is to make the skill apply a status effect, and then have battle events that do your special effect when that status effect is afflicted on a target? It's been a while, and I don't have RM2K3 in front of me, so I'm not 100% sure that conditional branches can depend on status effects being afflicted, but I think they can.
If you want a custom party targeting system, you were on the right track. But it needs a little more.

In a common event have a variable randomly choose between a random number. Each number corresponds to a party member. 1 = Hero 1, 2 = Hero2, 3 = Hero 3, etc

Once a number is chosen, have a conditional branch check if the chosen member based on their number is actually in the party, if they are, do nothing. If they aren't, then jump back to label one, and have the random number selection begin again. This will go on indefinitely till a member that is in the party has been chosen.

Now in the battle event, have a conditional branch check what number the targeting variable is. If it's 1 then play battle animation and damage code on hero 1, if it's 2 then then play battle animation and damage code on hero 2, etc

Code Breakdown:

Common Event
Label: 1
Variable Operation: Set to random number between *max amount of party members*
Conditional branch: If Targeting Variable is 1/2/3/4/etc
Conditional Branch: *party member* is in the party
If they are: Do nothing
If they aren't: Jump to Label 1

Battle Event
Call Targeting Common Event
Conditional Branch: If Targeting variable is 1
If it is: Play battle animation and code on hero 1.
Conditional Branch: If Targeting variable is 2
If it is: Play battle animation and code on hero 2.
A conditional branch for each number case.
Turn off the switch that activates the battle event page
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Skie, your method of choosing a party member is way laggier than mine and has the potential to infinitely loop and crash the game if it continues to get unlucky rolls.

That said, making a "choose a target" common event isn't a bad idea at all.
Well, I have a small number of party members, and I have never run into any sort of lag thus far. The choosing has actually been instantaneous. I found it more efficient than the previous method I used, which was to have a skill inflict a party member with a 'targeted' status effect, check who had that status effect, and then set a variable to their number and play the skill code on them.
@LockeZ
Hmm... now I don't get what you mean. I thought that to make this work, we will need 2 variables.

1st is the random number 1-4 (which correspond to the Party slot - the 2nd Var)

2nd is the Party Slot variable (correspond to the 3rd variable - the actual hero in the spot)

So you are adding, uh another variable at the bottom of these two - basically a number that is the result of (2) above. Using this then you can just write four lines of codes (if (VarResult =1, Show anim at 1, If VarResult =2, Show anim at 2, etc).

Well, if this is what you mean, then yes, this does cut down repetition by quite a bit.

----------------

Regarding Modulus, I have no clue what you mean by 1-12. How I use it is that by having 4 separate code, if VarPartysize=1(Always=1), If Var Partysize=2 (RND 1-2)...If VarPartySize=4 (Rnd1-4).
Common event can do this, so it's pretty easy to set up.

-----------------

Yeah, you can check status effect all right. But as far as I remember it only works for hero methinks. That is, the function to check (IF A HAS STATUS EFFECT) is only available for the heroes.

I guess there is no easy way to do this. Well... using custom enemy attack but default hero attack means I only get to work half the fun, so I might just use the DBS all the way or the MP thing. Ah well, decisions decisions..

Thanks for the help though!

--------------------

@Skie
Small party size/Static party - both are easy to set up. It's when you get ambitious and want to let full custom it becomes really troublesome :]
Pages: 1