Announcement

Collapse
No announcement yet.

Qestion about Enemy Behavior

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Qestion about Enemy Behavior

    For some odd reason my monsters always attack my main hero. Is this normal? Is the only way i can get monsters to attack other party members to write them all individual traits? Because that would take far too much memory if that's the case.

    #2
    Re: Qestion about Enemy Behavior

    I never had that happen to me. Go back and look at the character and enemy traits, and the enemy actions. Also, take a look at the battle scripts, there might be a part where you can set attack ratios.

    Comment


      #3
      Re: Qestion about Enemy Behavior

      Originally posted by rpgfanatic View Post
      I never had that happen to me. Go back and look at the character and enemy traits, and the enemy actions. Also, take a look at the battle scripts, there might be a part where you can set attack ratios.

      The monsters have no traits on them. I just used the default enemy behavior setting and set the attacks and spells i wanted them to use by random percents in the behavior window. I assumed they would attack targets by random, but that's not the case. They always attack the character on the far left of the screen, and never mess with the other party member unless it's an attack or ability that affects the entire party.

      My chatacter's ally does have a trait though, so i'll take that off and see if that could be some of the problem, though i don't really see why it would.

      Comment


        #4
        Re: Qestion about Enemy Behavior

        Well you could make a general trait script for all enemies which would not take up that much memory. So I think this may be the default behavior for the action tab. Not sure though as it's been quite a while since I've messed around with RPGM2.

        But it should be easy to make a generic enemy trait script that will always hit the character with the lowest MP, or some similar AI tactic, instead of just randomly attacking. This will also make your game more challenging (though of course you should add some randomness to it).

        Well I don't remember hearing any remedies for this, so just make up a generic trait script for enemy attacks. One thing you could do is use a couple of battle variables (or even some regular variables) to setup specific spells the enemy will use and then use that in the trait script instead of making a separate script for each enemy. If you go really fancy you could use a bitfield to turn on and off what abilities the enemy will use, and then compact together some 7 bit numbers in one variable for the percentages for each one. So this is entirely possible to write using one script and maybe a few helper scripts (like for bitmasking and such).
        はじめまして。真(しん)の冷静(れいせい)です。どうぞよろしく。
        http://www.thetruecoolness.com/

        5198-2124-7210 Smash

        Comment


          #5
          Re: Qestion about Enemy Behavior

          Originally posted by thetruecoolness View Post
          Well you could make a general trait script for all enemies which would not take up that much memory. So I think this may be the default behavior for the action tab. Not sure though as it's been quite a while since I've messed around with RPGM2.

          But it should be easy to make a generic enemy trait script that will always hit the character with the lowest MP, or some similar AI tactic, instead of just randomly attacking. This will also make your game more challenging (though of course you should add some randomness to it).

          Well I don't remember hearing any remedies for this, so just make up a generic trait script for enemy attacks. One thing you could do is use a couple of battle variables (or even some regular variables) to setup specific spells the enemy will use and then use that in the trait script instead of making a separate script for each enemy. If you go really fancy you could use a bitfield to turn on and off what abilities the enemy will use, and then compact together some 7 bit numbers in one variable for the percentages for each one. So this is entirely possible to write using one script and maybe a few helper scripts (like for bitmasking and such).
          It would be easy to make a generic enemy trait script if that's all my monsters did was a normal attack, but they have a lot more to them. Some have as many as 6 different abilities they use on the party, with a total of 96 different spells and 72 different monsters, so i would have to make a lot of different conditions for each monster depending on when it would be most intelligent to use that specific ability the monster has. So it would end up being a very massive script i'm not sure i could handle, but if it's the only way i'll give it a try and, if you're willing - keep you up to date on my progress so you can help me when i undoubtedly get confused.

          I do like some of the side effects of doing it this way, as monsters will no longer use spells when they run low on mp and what not - and seeing i have been writing enemy scripts for my boss monsters I do at least have a good idea how to do it, though i've never attempted a trait script so huge for multilple monsters or characters before.

          Your ideas about assigning spells to different variables and doing it that way kind of confuses me. I might try assigning each monster a battle variable and use that as my starting condition. Not sure if that's what you mean by making variables to avoid having to make a seperate script for each monster or not, because i'm not really sure how assigning spells to variables would help me any. So if you could explain that a little more might help.
          Last edited by Jeremy; 02-26-2007, 11:59 PM.

          Comment


            #6
            Re: Qestion about Enemy Behavior

            Well I guess it would be rather hard to make it that way without making the logic overly simple. Essentially to pull it off you would have to have a ranking system for each ability the monster will use. Of course you would also want to have some a different ranking for some common situations, like if a fellow enemy is weakened it might raise the rank of a cure ability more than an attack ability.

            So you would have to figure out the best way to find a generic way to make your monsters attack and only make specific scripts for bosses and the like. Shouldn't be too difficult to do with some sort of ranking system or a percentage system like the game uses.

            Now on to the number packing thing I was talking about, what you can do is take the 6 abilities he has, and then take the max amount of abilities there are, lets say 100. So you know each number must be 100 or less, then you can use binary to pack them like numbers are stored on a computer. So in this case each number will use 7 bits (since 2^7 = 128 > 100, but 2^8 = 256 which would be too big and waste some bits), and since each variable can hold 26 bits you can fit 3 abilities in one variable (7 * 3 = 21 < 26).

            So lets say you have ability 50, 99, and 3. To compact them you take 50 + 99 * 2^7 + 3 * 2^7 * 2^7 = 50 + 99 * 128 + 3 * 16384. You needed to multiple by 2^7 to 'shift' the numbers in the right spot so they can be later retrieved. Then to get them back for the 50 just do
            (% is modulus function, and is the same as it is in RPGM2)
            Var1 % 128 = ability1
            (Var1 / 128) % 128 = ability2
            (Var1 / (128 * 128)) % 128 = ability2

            You can do the same for the percentages for each one and store those in a similar way (or if you just used percentages with multiples of 5 you could store 5 of them in one variable [2^5 = 32 > 25, and 5 * 5 = 25 bits < 26 bits per variable]). Then you can just use the percentages to choose what ability to do. If you have only 63 or less abilities you would be able to fit 4 in one variable (2^6 = 64 so 6 bits per number, then 6 * 4 = 24 < 26 bits in one variable). Then to get each one

            Var1 % 64 = ability1
            (Var1 / 64) % 64 = ability2
            (Var1 / (64 * 64)) % 64 = ability2
            (Var1 / (64 * 64 * 64)) % 64 = ability2

            You can also use this to store 26 flags in one variable, since a flag is just 1 bit (1 or 0).

            This way you can use one pretty small common enemy script.
            So if that all flew over your head, read it again and let me know what specific parts you don't get.
            はじめまして。真(しん)の冷静(れいせい)です。どうぞよろしく。
            http://www.thetruecoolness.com/

            5198-2124-7210 Smash

            Comment


              #7
              Re: Qestion about Enemy Behavior

              Well it didn't fly over my head, it left it in the dust

              But don't worry about explaining it to me just yet. Think i'll go ahead and try to work something out with my regular method and see how it goes, instead of trying to incorporate some new alien design for my traits - especially considering it took me months just to understand the one i know.

              When I get stuck and can't figure it out i'll post the details of the script and see if you can't figure out where the snag is. I've actually been having a lot of success with my trait scripts lately so i might do a little better at it then i'm expecting.
              Last edited by Jeremy; 02-27-2007, 05:57 AM.

              Comment


                #8
                Re: Qestion about Enemy Behavior

                deleted this post
                Last edited by Jeremy; 03-22-2007, 09:00 AM.

                Comment


                  #9
                  Re: Qestion about Enemy Behavior

                  Thought i'd update you on my progress just in case you are thinking i wasted your time with a question i wasn't really that interested in. I'm actually glad i attempted this, as it's turning out not to be as difficult as i thought and has actually evolved into a lot more than i was expecting, and is benefiting my game's gameplay a lot.

                  This is method i'm using thus far:

                  First i assign each monster a specific battle variable. Then i created a new variable i call [Enemy Number] which is my own version of the game's Member Number variable, since unfortunately the game doesn't already have one.

                  At the beginning of my trait script i check for each specific battle variable by using a script condition. Then, if the condition is met i assign the appropriate number to my [Enemy Number] variable. This allows me to check for specific enemies later on in the script so as to use the right abilities. For example:

                  Let's say Imp has [Battle Variable9] = 5 and Familiar has [Battle Variable9] = 9

                  So at the start of my script I do this...

                  Script Branch: Condition: Variable [Battle Variable9] = 5
                  Data: Variable: [Enemy Number] = 5
                  Script: Condition End

                  Script Branch: Condition: Variable [Battle Variable9] = 9
                  Data: Variable: [Enemy Number] = 9
                  Script: Condition End

                  Battle Variable9 always corresponds to the actual data base number of the enemy so as to avoid confusion. This means a rather lengthy check at the beginning of my trait script (since i'll have to make an individual condition for each enemy), but it's way shorter than writing an individual script for each enemy.

                  After assigning the right number to the [Enemy Number] Variable that corresponds to the data base number of the enemy who is currently taking action i go on to set up specific conditions to determine what the enemy actually does. However i ran into some problems on this part, since in order to save memory and effort i would need to generalize the conditions so it can apply to as many different monsters as possible, since spells and Mp costs...Hp levels will vary dramatically during the course of the game. This is what i ended up doing...

                  I made three new variables and called them this, [Mp 25%], [HP 25%], [HP 50%]. These i use to set up more general conditions that can change during the game, rather using specific hp and mp values.

                  Battle: Substitute Target Attribute for Variable
                  Data: Variable: [MP 25%] = [Max Magic Points / 4] <-- here i divide the target's max MP by 4 so as to get a rough estimate of what would be 25% of the target's overall MP value. There is probably a more specific and accurate way of doing this, but i couldn't figure it out. Would like to know it if there is.

                  Battle: Substitute Target Attribute for Variable
                  Script Branch: Condition: Variable: [Magic Points] >= [Mp 25%] <-- this way the enemy does not cast a spell unless his MP is greater than or equal to 25% of his Max Mp. It's not perfect, but at least it creates a balance as to how much a monster can cast relative to his MP reserves.

                  Now i want the monster to check the opposing side if his MP is greater than 25%, because he's going to use a spell on someone.

                  Battle: Check who Goes First
                  Script Branch: Repeat: Flag [Member Check] = Off
                  Script Branch: Condition; Flag [Instigator Side] = Off
                  Target Data: Action Status: Confirm [Death]
                  Script Branch: Condition: Flag [Indirect Effect] = Off

                  Now i have the monster checking who goes first on the opposing side when it's MP is >= 25% of it's Max Mp. Here i can put specific target conditions to determine when the monster will act - and since i already know what monster is acting because i loaded it's database number earlier i can control what actions are done based on the content of variable [Enemy Number]. For example:

                  Script Branch: Condition: [Enemy Number] = 5 <--- by setting this condition the actions in this specific branch are only done when the acting monster is number 5 on the data base list. I can set all the target conditions i wish after this condition, and and they will still only apply to that specific monster.
                  Script: Condition End
                  Script Branch: Condition: [Enemy Number] = 9 <--- only if the acting monster is enemy number 9 will the actions in this branch take place..
                  Script: Condition End

                  This is how i've been able to make a single enemy trait dictate what different monsters do so far. If you have any ideas on how to improve on this basic method feel free to share them

                  Script Branch: Condition: Variable [Battle Variable9] = 5
                  Data: Variable: [Enemy Number] = 5
                  Script: Condition End
                  Script Branch: Condition: Variable [Battle Variable9] = 9
                  Data: Variable: [Enemy Number] = 9
                  Script: Condition End
                  Battle: Substitute Target Attribute for Variable
                  Data: Variable: [MP 25%] = [Max Magic Points / 4]
                  Battle: Substitute Target Attribute for Variable
                  Script Branch: Condition: Variable: [Magic Points] >= [Mp 25%]
                  Battle: Check who Goes First
                  Script Branch: Repeat: Flag [Member Check] = Off
                  Script Branch: Condition; Flag [Instigator Side] = Off
                  Target Data: Action Status: Confirm [Death]
                  Script Branch: Condition: Flag [Indirect Effect] = Off
                  Script Branch: Condition: [Enemy Number] = 5
                  Script: Condition End
                  Script Branch: Condition: [Enemy Number] = 9
                  Script: Condition End
                  Script: Condition End
                  Script: Condition End
                  Battle: Check Who Goes Next
                  Script: Branch End
                  Script: Condition End
                  Battle: Change Back Active Character

                  Ignore the double post. This site has some bug to where if you make a reply then are asked to log in it double prints your last reply after you log in.
                  Last edited by Jeremy; 03-22-2007, 08:56 AM.

                  Comment

                  Working...
                  X