Qhimm.com Forums

Miscellaneous Forums => Archive => Topic started by: secondadvent on 2009-06-05 21:47:48

Title: [Release]scene.bin ai size reduction project, v0.1
Post by: secondadvent on 2009-06-05 21:47:48
this mod will attempt to keep the enemies acting as close to the originals as possible (with some small additions as necessary), while rewriting the ai to be as small as possible, to shrink the overall size of the scene.bin, and to make the code as optimized as possible, all while fixing ai bugs :-P. This is not a hard/balance mod, but rather something that can be used as a base for other mods and such, or for those who just want a bugfixed version of the original.

the size is being made smaller so that other mods will be able to safely add to it without having the space issue the psx version has, allowing for more people to use these mods. the size should become small enough over time so that you should not be able to make it become too large for the psx iso unless you were to add a massive amount to the ai, and i mean a LOT.

Current Release: v0.1, with changes to enemies up to air buster (game order, so the first two reactors :P). here is the link: http://files.filefront.com/13875177

Current Size: 256kb, but quickly approaching 248kb

each release will also have an updated kernel.bin (only for if you are not using a modded one), a list with the original/current ai sizes of the enemies, and a file to help people test the ai (if they wanna help me out  :wink:), showing every possible outcome the enemy will have, as in what it will do in one turn, on who, etc.

as of right now, 21 scene files are now empty (as in filled with nothing) that had no enemies used in-game, such as dummy enemies used during testing, as well as an enemy from a scene that has enemies that are used in-game. it is likely there are more to remove, but i haven't checked too far into this yet.
Title: Re: scene.bin ai reduction project
Post by: warbaque on 2009-06-05 22:11:15
Continuing arguing about removing 2x multiplier from enemies.

Quote
That is after all the original intention of GS's AI.
= Halve all non-piercing damage during counter stance

If you wanted numbers
1st Form
      Guard Scorpion's Def = D (Min-Max 0-510) (Example 40)
      Guard Scorpion's MDf = M (Min-Max 0-510) (Example 256)
2nd Form
      Guard Scorpion's Def = D+((512-D)/2) (Min-Max 256-511) (Example 276)
      Guard Scorpion's MDf = M+((512-D)/2) (Min-Max 256-511) (Example 384)

This way there was no need for halving while keeping full controll over stats (0-510)

All incoming damage is halved during counter stance and regardless of original Def/Mdef values won't skyrocket absurdly high.
Title: Re: scene.bin ai reduction project
Post by: secondadvent on 2009-06-05 22:42:10
ok, the initial stats are 40/300 when doubled, and without reducing the 300 mdef to 256, it is already different from the original version. now, adding the barriers, if i allowed it (still makes it different, since the barriers are visible, and normally it has no barriers), the mdef (if reduced to 256 first) would basically act the same as 384 mdef, but the 40 def would act much higher than the normal 255 it is given during the 2nd stage (276 != 255 :-P), and if the initial 300 mdef were not reduced, then it would act like 406 mdef.

yes, that would be a shorter way to do it, but it is still not the same as the normal game unless you alter the initial stats of the GS (i am not altering any enemy stats, only moves when needed, stats are staying the same), or reduce the stats in battle. as i said, i am trying to make this mod as close to the original as possible, no stat changing (only moves if needed), and keeping the ai as true to the original as possible, and adding a status to the GS would defeat the purpose, even if it did something similar. now, when i finish this and get to my hard mod, then i will definitely be doing whatever i can to make the ai as compact as i can while doing what i want, but even then i probably would make the barriers a last resort, especially since i plan on implementing a way to make the enemies level as you do (not all will level every time you do, and stat gains will be from a random amount to give variation... a big pre-battle for every enemy, that is different every time... have to set all enemies' base stats to level 1 as well, so that enemies do not get too pumped up if they are already souped up a ton. this will be a while from now though, and i plan to make it as evil as i possibly can :-P), and giving certain statuses/resistances to enemies, as well as certain new moves as they become higher level is a priority >:D.

ok, current progress (will eventually add a text file listing changes as it gets farther along):
name:               original ai size:     new ai size:
MP                    861                  227
Guard Hound      256                  114
Mono Drive        418                  190
Grunt                861                  234
1st Ray              42                    42
Sweeper           161                  131 (main) (added darkness giving ability to it's smoke attack, since the ai is based
                                               9 (pre-battle)  around you being blinded from it, 100% inflict with 75% atk accuracy)
Guard Scorpion   62 (pre-battle)           90 (pre-battle) (relative defense boost added, halved defenses first*)
                        701 (main)                 645 (main)
                        23 (general counter)   23 (general counter)
                        45 (death counter)     33 (death counter) (removed hurt anim. setting)

*both versions apparently double defense before the battle begins, halving it is so that the defenses can be made to be exactly the same as the original, but with added support for those who wish to edit the enemy stats, since normaly GS would have set defenses no matter what you changed his defenses to. guard scorpion will add 106 to the base defense now (it's base 150 mdef will become 256, the normal stage 1 mdef for it), and in the second stage, it will add 235 to def, and another 128 to mdef (becoming 255def/384mdef at normal stats). the min/max for these values at each stage is 255d/361m in stage one, 490d/489m in stage two.
Title: Re: scene.bin ai reduction project
Post by: warbaque on 2009-06-05 22:57:36
My last post wasn't about barriers.

And there's about 8% difference in damage between 255 and 276.

1st Form
      Guard Scorpion's Def = D (Min-Max 0-510) (Example 40)
      Guard Scorpion's MDf = M (Min-Max 0-510) (Example 256)
2nd Form
      Guard Scorpion's Def = D+((512-D)/2) (Min-Max 256-511) (Example 276)
      Guard Scorpion's MDf = M+((512-D)/2) (Min-Max 256-511) (Example 384)

I think this works better with all values between 0-512
Title: Re: scene.bin ai reduction project
Post by: secondadvent on 2009-06-05 23:14:35
i thought i read about barriers in the one post on the proud cloud thread... i dunno what i was thinking about then :-P.

and i know the difference isn't much, but i want it to be exactly the same initially as the original in performance and stats, with only things added to fit into the original ai, like adding cure to adamantaimai, and giving smoke shot from the sweepers the ability to add darkness, since their ai checks for enemies with the darkness stat when selecting a target for smoke shot, that means it was originally supposed to add darkness, and they just forgot about putting the status change on the move :-P.

i know i am being picky, but i want everything to be as close to the original ai as possible. if it was supposed to set defense to 333, and an easy way would set it to 350, i wouldn't accept it, even if it took half the space to do. i'd have to check to see if doing it your way would even save much if any space to begin with...

ok, if i were to use yours, it would be much smaller, but if i could remove the auto def doubling, then i would only be a small bit bigger, and produce much more accurate results compared to the original. you could consider removing the auto double as going against what i am trying to do, but every other normal stat caps off at 255, and yet the defenses are automatically sent past their cap at or over 128 defense, and this feature is what will cause me issues throughout every enemy that has a def change in battle, and will plague me through any future mod i do. to me, removing it is like removing a bug, since your character's defense does not get doubled initially, and there is the move dragon force, which is used by an enemy, meaning defense was not initially doubled for enemies, else this move would not be an enemy skill (it raises the defense mod, essentially increasing your battle defense). i think that the def doubling was a last minute addition to try to increase the difficulty, wich didnt work too well (the game was rushed too much).

only problem... i have no idea where to go to turn off the auto doubling <_<.
Title: Re: scene.bin ai reduction project
Post by: warbaque on 2009-06-05 23:54:41
Quote
My last post wasn't about barriers.
I mentioned about barriers in PrC thread.

I'm just against removing natural 0-510 Def stat range since it allows things like cool new features like real-time weapon change enemy with 25% physical defence and 75% magical
Title: Re: scene.bin ai reduction project
Post by: secondadvent on 2009-06-06 00:07:45
i dont need it to be gone for this mod, since my GS already works by halving it initially, i just really want it for my future mod :-P. any other enemy can have it too, but it just takes up more room this way.
Title: Re: scene.bin ai reduction project
Post by: warbaque on 2009-06-06 17:53:36
I must have misread at some point since I thought you wrote at some point that you were adding Def/2 to every single enemy's AI to get rid of Def doubling.
Title: Re: scene.bin ai reduction project
Post by: secondadvent on 2009-06-06 18:35:53
no, no, i meant that i would like to turn it off through the core of the game (probably in the exe or something, just dont know where atm), only GS has that for now, as well as any other def setting enemy i stumble across, so it shouldn't happen to too many other enemies. i am just adding it to make the ai work more accurately for me, thats all.

i have finished checking all of the enemy ai (actually finished last night) up to and including GS, so if you or anybody wants to test it out, just tell me. i know the first instance of each in the scene.bin "should" work, since i already directly tested them, but any that i had to copy the ai to may not work, since it was all manually retyped back in for each one.

sides... it'd take 36 bytes to halve both defenses (18 apiece), and per enemy would quickly build up... if i were to change it in the core, if it were, say def x 2, then i just make it def x 1, and not have to remove anything ^^.

wow... ok, grashtrikes ai is set up to check for any non-slowed enemy and use silk on them, if they have enough mp to use it, however their silk attack does not cost any mp at all, since they have 0 mp. if you follow through their logic, they will ALWAYS use silk until the enemy is slowed, even if they cannot be slowed, causing a potential loop there. also, their next step checks to see if an enemy is slowed, and chose a random slowed target if they are slowed, and if not, then chose a random target. now, if all people do become slowed, they will begin to attack (no sooner), and will always target a slowed person (all are slowed anyway), so i have a predicament.

either i give their silk move mp cost, and give the grashtrikes mp as well, going against my normal rules to fix an issue (to make it as close to intended as possible), and be able to barely reduce the total ai, or i keep the potential loop and get a bigger ai reduction. i think it is time i have to break my rules a bit :-P. actually, i DID say that i was trying to make it as close to what was intended as possible while fixing bugs, and this can be seen as an ai bug (more of an oversight actually), so i guess its time to fix it up >:D.

ok now, how much mp to make it cost, and how much mp to give them? their base chance to hit is 90% (with guaranteed infliction on hit), so with no magic evade, it will usually hit, and if you are immune, they would use it however many times each to try and slow you. my guess is that allowing each to be used twice max is pretty good, any higher would make them take too long before attacking. also, mp cost should be at, or a little lower than normal slow spell, probably lower since it is kind of a "natural" ability for them, though it could be 255 mp cost for all i care, and i could give them 510 mp, but that is kind of pointless. meh... normal is 20 mp, but i think 8 is good :-P.

hmm... i made GS so that he is hacker friendly when changing stats, but so far with enemies using mp (those that check their remaining mp), i have not made it friendly there... people will have to manually change the check in the ai (only need to change one value, but still) if they change the mp cost of the abilities used... an auto check is possible easily, but takes more room to do, only about 2 bytes more though :P. i will have to make sure all mp using enemies have the check for the move's ability, but if the move is removed, then problems may occur, so it is kinda lose/lose either way.

it also seems that they were originally supposed to cause damage with their silk attack since they have magic power (enemies that don't have magic attacks have no magic), and their silk attack is set to do magical damage, but with no attack power for the move (unlike normally where it is set to "no damage calculation"), but i will not be adding that in, at least not right now, and if i did it would do very little damage.
Title: Re: scene.bin ai reduction project
Post by: warbaque on 2009-06-06 20:01:42
When you fight agaist them it's not possible to be immune agaist slow. And afterall they ARE stupid insects so I wouldn't find it weird if they tried to continuously slow you even when they have already failed on it multiple times.

But for MP amount, I would say about 2-4 castings (or more if you have items to heal that status at that point)
Title: Re: scene.bin ai reduction project
Post by: secondadvent on 2009-06-06 20:16:45
i know they are stupid, but i have a "no fool left out" policy, so even crappy enemies are given what they were meant to have :-P. an infinite loop is not really good anywhere, and giving them two castings is nice, since they appear in groups of 2-4, is plenty. now, you can have magic evade to lower the chances (not by much, but still) of being hit, and this is (hopefully) going to be a base for other mods, so it is possible that they will have other types of equipment available, as well as the possibility for different materia, so it is possible that slow could be prevented, then no matter how powerful they were made, they would NEVER attack, this is just a bug fix.

also, i updated the mono drive to check fire's mp cost (actually, people will have to change the ai for new moves anyway, so that it checks for the new move's mp instead), so if fire were to be upped in price, there would never be a "out of skill points" message appearing, they'd just physically attack the rest of the fight. only cost me one (not two ^^) byte to add, so no big deal, more friendly than the other way. going to work my way to corneo's mansion before any testing, to speed up the process, and test in one fell swoop.

ok, another predicament... the blugu enemy's ai is set up around checking for paralysis in combination with it's hell bubbles move (to see who is attacked with it), but hell bubbles causes sleep... so either i change the ai to check for sleep, or else i change hell bubbles to cause paralysis instead (easier actually). since i am basing things off of the ai, hell bubbles will now cause paralysis instead of sleep, and paralysis is worse because physical hits will not cure it.
Title: Re: scene.bin ai reduction project
Post by: warbaque on 2009-06-06 21:09:48
I'm not sure about paralysis. You can't heal it without esuna, angel whisper or white wind, spells that you most likely do not have at that point and 2 blugus can paralyse your entire party quite fast if you're unlucky.
Title: Re: scene.bin ai reduction project
Post by: secondadvent on 2009-06-06 21:29:49
but, that is where the ai is pointing to. if sleep and paralysis were right next to each other bitwise, then i would probably assume it was a mistake for the ai to use paralysis (even though it is used multiple times in the ai). also, you do not have access to anything to remove sleep for that matter, though it is removed by being hit, so no big difference there. also, they can only use it about a third of the time IF the ai takes a few turns beforehand.

basically, the first turn it is possible (a 1/4 chance then), then after that it has to take up to two more turns until the 1/3 chance activates, and if the chance fails, then they have to wait another two turns for another 1/3 chance, so it isn't like they will be using it very commonly on you either way. they do come in groups of 2-3, so if all do get it on the first turn (a 1/64 chance), they have a 80% chance on contact of paralysis landing (essentially an overall 1/125 chance of all three getting paralyzed), so not very likely, and if all three do somehow use it, there is about a 50% chance that all three will be affected... not too good of odds of it happening.

also, another oddity is that hell bubbles has an attack power of 12, but does no damage, while silk has no atk power, but calculates damage... maybe a mixup, and these guys were supposed to damage and paralyze you (kind of like a magical cross-slash?). so many unknown things going on...

ok, about your post in the PrC thread, it is possible to set whatever in-battle flags, since many enemies do that normally (an example is the mono drive, which prints a warning/enemy sighted dialogue box at the start and attacks after that, never displaying the message after that. also, the programming logic for the enemy ai is much different from most programming languages you may be used to. the best way to learn it is to look at other people's coding, though the ffvii ai used initially is usually lain out in a very unusual and inefficient way for many of the enemies, but mine is also hard to follow because i program weird, but in an efficient way :-P.

ok, the blugu enemy is a mess of an ai... i should get a good bit of shrinkage here, but it will take some time, unlike the previous three enemies that were actually half decently done. i also noticed that some enemies actually share ai, showing how rushed ffvii was, since the ai was barely even made to be efficient, much of which isn't even properly working, something that only hackers and those who made the game (sans adamantaimai bug) would notice, since things work normally otherwise.

paralysis only lasts 8 units of time, while sleep lasts 26, so being unable to smack yourself out of it is a fair trade.
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-07 01:06:31
I repost this here in case you missed it eventhought it was mostly directed at Crysalis.

What can and what can't be done with current AI scripting?

So the solution could be to make enemies give way less exp so levelling up is slower and the time you meet bosses you are much lower level but this would then mean getting to the magical level 99 and level 60 points much harder and less likely in a normal game, I do agree enemy AI's need to be improved especially on bosses and of course stronger attacks ones that hurt enough so that you do actually have to heal in battles and even consider fighting on the back row/use sadness, but doing this alone is useless if the enemy gets no attacks in, and the best way to ensure they get attacks in is to boost their hp/dexterity and defenses.

I started my balance/hard mod from completely different perspective. Average EXP/AP is multiplied by 2 and boss EXP/AP by 5. This way player is about lvl 90 when they reach The Northern Crater and difficulty isn't completely ruined for those who wish to max their levels.
Damage multipliers removed from UWs. I haven't yet decided should I replace it with some other effect or leave them as "normal" weapons.
If Shield protected against non-elemental magical damage I would make KotR hit everyone on the screen (your own party included). So if you wanted to cast it and survive you would need some preparations or final attack+restore/phoenix. In any case the effect can't be made a lot weaker since the animation takes forever so it has to dish some damage. It's the MP cost that is the problem. If it killed you everytime you summoned it requiring you to use final attack+restore for example that would make miming it a lot harder. Or alternatively (1-3)xShield 180-540MP for preparations but if I remember correctly Shield protected only against physical and elemental magic damage. Items excluded.

If you wanted harder battles enemies need to have a lot stronger attacks than they do in vanilla/unmodified game. AI needs to be smart and it needs to react players actions, for example use spells like dispel and debarrier.
What I personally find annoying are the enemies that have 1 basic attack and 1 stronger attack and they choose their attacks completely by change. After that difficulty of the battle becomes dependant on players luck. Does it use it's stronger attack or do I get lucky and it uses it's weaker attack multiple times in a row without using the stronger one. Of course if the attacks had a different Att% with stronger attack having smaller change hitting I could understand why it chooses weaker attack over stronger one.

By the way is it possible to make enemies not use certain spell afer certain events during fight.

Example
start.flag=0

if flag=0
  select all cast Fire3
  if damage > 0
    set flag 0
  else set flag 1
  endif
else chew bubblegum
endif

I haven't touched the actual AI-data yet so I don't know how it looks like or what commands it uses. That's way my crude example
Title: Re: scene.bin ai size reduction project
Post by: Chrysalis on 2009-06-07 02:43:18
I initially tried to add the following changes to kotr.

increase cost over 250 (sucked when realised max is 255)
make max level 3 so 3x per battle, and to even level up to level 2 would be same as current level 4 and level3 same as current level 5.

I then tried to take the ignore defense flag off so its significantly weaker against bosses (since all boss's in my game especially late game have good magic defense) but this in some cases made it too weak, it went from doing 9k or so damage per hit to sometimes only 100 per hit.  So for now I have kept the ignore defense flag on and took down the base damage so it does around 2k-3k per hit, so total damage is more than zero bahamut but not insane.

Of course late game kotr isnt that powerful when you compare to other things eg. 4x cut with 9999 limit break removed will do similiar damage to kotr and omnislash also similiar.  This is why I consider many hp's far too low, to me a boss battle has to last a long time thats the #1 rule, even if its just the same AI but the battle lasting longer its an improvement.  Once thats fixed then the battle can be made genuinly harder with AI improvements and stronger attacks.

By the way your idea for kotr to harm everyone is very good, to get round the shield not protecting issue you can decrease the accuracy down to something that will miss as often as normal attacks and then ways for players to survive could be having a very high defense %.  So wearing mystile for example.

If I understand you correctly you will be balancing the game so the player is expected to be around level 90 at the end? and to compensate for the higher level requirements you will make it easier to level up so less training.  If so I like the idea of this.

What I did in my game, (since I lack the skills to edit AI.)

1 - I set most normal enemies with a attack, magic and dexterity boost meaning most enemies you meet will get their turn first and get an attack in, the idea was for the attack too hurt, the dexterity defenitly worked as I rarely go first in fights but most attacks are still far too weak. Also luck boost to every enemy so critical hits more frequent.
2 - I set a few random encounters to signficantly more diffilcult, large hp boost, larger boosts than normal on the attack and dexterity stats, as well as some defensive boosts.  These fights I tend to make more rewarding like extra exp and small chance of good item.
3 - all enemies get level boosts, trying to keep enemies that are inside 4x and 5x levels still inside them, so enemy skills remain effective on same enemies.
4 - all boss's large boosts especially on hp and mp, early boss's have lower boosts and all boss's after midgar larger boosts.  Typical boosts to HP are early boss's triple HP, mid game bosses 4x HP and late game bosses 10-20x HP.  In addition large level boosts as well as large stats boosts, initially I went too far on some boosts and had to tone it down a bit, but I still have many bosses way too easy.  Some are genuine tough battles tho.
5 - safer sephiroph, in addition has couple changes to attacks. super nova ignores status defense, heartless angel adds chance of poison and ignores status defense, of course slow+poison on someone with 1hp will kill them, so basically heartless angel becomes a 1hp attack with a chance of death.  He has massive defense boosts since his hp cant be effectively boosted.
6 - all enemies are much easier to steal from, this is something that makes game easier but it was just silly before on the default settings, most items 83% chance of success, but special items like weapons and elixir reduced to 51%.

To me obvious AI boosts are.

1 - a counter attack that either heals or drains, so the enemy will be able to attack+heal (since the heal is a counter).
2 - more status affects in attacks such as confusion and petrify.
3 - ability to use peerless.
4 - to react to current state of battle, eg. casting haste onself after slow in affect.
5 - ability to cast summons including kotr.
6 - have stocks of elixir, especially some boss's.
7 - to be able to revive other enemies.
8 - have a random chance of breaking players equipped accessory. once broken it is lost.
Title: Re: scene.bin ai size reduction project
Post by: nfitc1 on 2009-06-07 03:04:35
I'd love to see more peerless in the game. I considered removing one/all of the sources and replacing them with some rare-status inducing attacks. Peerless would be one such effect, as would dual and darkness.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 04:24:11
@nfitc1: yeah, many of the stats are underused, but i think that is because the game was massively rushed. i was planning on making my balancing/hard mod after finishing the compressed ai mod, but it seems that you guys are more interested in the hard mod right now :-P. i will probably start going back and forth between the two then, after either getting to air buster, or the end of the shinra building (boss galore), and working my way up to that point in my hard mod. i do plan on balancing out the game a lot, and the rarer statuses are definitely making the cut.

peerless will likely be item only (sans aerith of course), or on a late game materia, since it has too much cheapness for an early game ability. darkness will likely be placed onto a separate materia (kind of make separate materia for each specific status type, element type, etc, and it is possible that i will remove the X pluses, since they can definitely break the difficulty), making use of all the room i possibly can in the materia section. dual drain (sap) is likely to be added to the bio materia as bleed/sap, and mixed together with one of the bio spells (likely bioga, making a poison/sap combo which could be deadly, especially if an enemy has it).


@chrysalis: most mods make you start weaker, and make the enemies as strong as they can, but something that isn't usually done is lowering the character growth, thereby limiting the maximum stats you are able to obtain. mix this with limited/no sources, and you have much more room to make enemies grow, since the overall enemy stat average will need to be reduced as well. if you capped lv 99 strength at 70 or so, and removed ultimate weapon abilities, combined with reduced weapon power, then the enemies will not have to be made too much stronger to give you trouble. the lower you place your characters, the more room enemies have to grow without altering the game engine. if you were to make your people have the stats used in paper mario, without editing the base enemies at all, then it is likely that you wouldn't make it past the first fight, though if you did (possible), you are almost certainly not making it past the guard scorpion. if you take the normal character growth in ffvii, and pumped up the enemies even really high, an experienced person will still have little trouble beating it. if you slash your own people (not just abilities' power, but those as well as stat growths), that is a bigger boost than raising the enemies.

if all weapon power was halved (giving ultima weapon 50 atk and making it do normal damage), with a lv 99, 70 strength cloud, you would do ~2350 damage to a 0 defense enemy. as you can see, that is much less than the normal lv 99 9999+ damage, and if 4xcut were weakened as well, then it is likely that without critical hits, you wouldn't even hit the cap. this game has a lot of potential, and i plan on tapping into as much of it as i can, making enemies much stronger than you makes you need to use a strategy other than final atk+phoenix/raise, kotr, 4xcut (and 4xcut counter). darkness will be something that will be greatly helping you out, as will silence, though i will be making enemies change their patterns when afflicted with certain statuses. you can also increase the amount needed to fill your limit bar, making limits much more difficult to get, making things even more difficult.

also, since the ai can do pretty much anything (including change your immunities), it is possible to give you death sentence, possibly with other ailments, and give you immunity to death and immunity to restorative spells, making you a guaranteed dead man with no way of resurrecting yourself, since immunity would be preventing it. if anybody gets that, it'd likely be like a tonberry (knife attack XD), or northern crater enemy/side boss.

the only ai problem (not actually an ai problem, but something related to it) right now is the fact that animations need to be added to enemies to use other types of attacks. for example, the MP (guard at the start of the game) cannot directly use magical attacks, unless it uses it with either it's tonfa attack animation, or machine gun animation, since it wasn't made to use magic, and the actual magic attack animation will not be used, but rather it will show the normal attack done by the MP, but with the magic's effects. I do not know anything about adding animations, and is something that i would likely need help with, and even enemies that can use magic have camera oddities (camera doesn't act right... too slow or fast for the spell depending on the enemy's magic casting animation), but will display the correct magical attack animation. that issue will probably be the biggest obstacle to overcome once you know the ai language pretty well, but if you know how to edit their animations as well (their actual animations in the battle.lgp file, not the animations in the scene.bin, in case i confused you), then you are set, and can make anybody use any move.

when i do begin my hard/balanced mod, i will be testing it every step of the way to make sure everything is balanced nicely (especially since ai is in the mix, though i still always test my work for a while), and if it doesn't suit my needs/others' needs, i will raise the difficulty accordingly >:D.


@warbaque: basically anything is possible with ai if you are creative, though you have limited space (not that any enemy even reached the limit in the normal game, but with mass modifications to power bosses, it *may* be reached, though i still doubt it :-P). increasing the exp/ap is fine, but only if the enemies are getting a nice boost as well, and if you can still easily take everything down, then it isn't good enough >:D. you can easily set the enemy ai to use flags, create custom stats, give auto statuses, bring them back to life automatically when killed the first time (still working out the bugs for multiple times, and i do not know how to fix invisibility, but i know how to avoid it :-P), attack multiple times a turn, and other things as well.

some things that may be possible via ai is to make other enemy battles appear after finishing the fight (i know it can be done by editing the scene file, never looked into doing it via ai), allowing for multiple item steals, such as making it allow you to steal again, and possibly adding different items to be stolen depending on certain conditions (i would love this, and it is likely possible since exp/ap can be set in ai), as well as changing dropped items (again would love this, many different possible uses, such as different drops based on level, or based on your actions in battle). like i said, there is much possible through ai, i would need specific examples to know if it could be (currently) done or not... i am also going to try to figure out as many unknown variables as posible, for even more flexibility with the ai, i already know the invisibility flag (it may just disable the idle animation... possibly resetting the idle animation would bring it back?), the flag to keep the enemy from using the normal death animation, and the magic counter (it counts the amount of times you are hit with magical attacks) variable, though i sadly didn't find any physical/general version of that... they may be with the magical one, and i just set it up wrong, but i am not too sure on that...

but yeah... if you have an idea that you would like to know if it could be added into the ai, just post it here and i will see what i can say about it (still learning myself, but i think i am doing ok :-P).

whew... a long post, but i think i covered everything (hopefully...).
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-07 05:18:15
I can't figure out how Sephiroth's main AI works

Quote
LocalVar:0000 <- 2
TargetMask <-  (TargetMask.GreatestElementalDamage >= 5) <- what does this do for example
If (TargetMask)
{
   Debug.Print: "RESIST EARTH MONSTER" ; 0
   LocalVar:0040 <- 1
}
TargetMask <-  (ActiveMask.FormationNumber == 25) <- same question
If ( ( (TargetMask And  (TargetMask.Status:Death == 1) )  And  (Random MOD 3 == 0) ) )
{
   LocalVar:0020 <- 8

}

ElseIf ( (BitCount(AllActiveOpponentMask) == 1) ) <- BitCount and AllActiveOpponentMask?
{
   TargetMask <- RandomBit(AllActiveOpponentMask)
   If ( (TargetMask.BattleRow >= 16) )
   {
      LocalVar:0020 <- 29

   }
   
Else
   {
      LocalVar:0000 <- 1
   }

}

Else
{
   TargetMask <- AllActiveOpponentMask
   If (Random MOD 3 + LocalVar:0040 == 0)
   {
      LocalVar:0020 <- 38
      LocalVar:0040 <- 1

   }
   
ElseIf (Random MOD 3 + LocalVar:0040 == 1)
   {
      LocalVar:0020 <- 32

   }
   
Else
   {
      LocalVar:0020 <- 35

   }
   
Else
   {
      POP(Random MOD 3 + LocalVar:0040)
   }
   Perform(LocalVar:0020, LocalVar:0000)
SCRIPT END

How does script functions use if function
is for example
If (something) equivalent of If (something==1)
Title: Re: scene.bin ai size reduction project
Post by: nfitc1 on 2009-06-07 06:54:59
Quote
(TargetMask.GreatestElementalDamage >= 5) <- what does this do for example

I had a discussion with Akari about the function of code 96. Apparently, it takes two arguments: character mask and an element. What it does is goes through all the characters in the character mask and set their GreatestElementalDamage value (within their unit data 4058h) to the elemental damage modifier of that element. So when this is checking the "GreatestElementalDamage" it's checking the status of the Earth Elemental. This will prevent him from using Quake3 further on down.

Quote
TargetMask <-  (ActiveMask.FormationNumber == 25) <- same question

This is targeting any character with a formation number of 25. I'm not really sure what this means, but I believe that it's checking to see if Young Cloud is alive.

Quote
ElseIf ( (BitCount(AllActiveOpponentMask) == 1) ) <- BitCount and AllActiveOpponentMask?

BitCount is a count of the number of bits that are active in that value. AllActiveOpponentMask is a mask (of bits) that indicate which opponents are still alive.

Let me attempt to simplify his code for you.

Quote
AttackType = Command.Magic
Target <- TargetMask.ElementalDamage(Earth) >= 5

If (Target) Then  ' If Target is non-zero
   Debug.Print "RESIST EARTH MONSTER"
   ResistEarthMonster = 1
End If

Target <- ActiveMask.FormationNumber == 25

If (Target and (Target.Status.Death) and Random MOD 3 == 0) Then

   Attack <- Life2

Else

   If BitCount(AllActiveOpponentMask) == 1 Then

      Target <- Random.Opponent

      If Target.BattleRow >= 16 Then ' in back row probably
         Attack <- Fire3
      Else
         AttackType <- Command.Attack
      End If

   Else

      Target <- AllActiveOpponents

      If (Random MOD 3 + ResistEarthMonster == 0) Then
         Attack <- Quake3
         ResistEarthMonster <- 1   ' This line is pointless
      ElseIf (Random MOD 3 + ResistEarthMonster == 1) Then
         Attack <- Ice3
      Else
         Attack <- Bolt3
      End If

   End If

End If

Perform(Attack, AttackType)

Since everything is init'ed to 0 then Attack will be 0 if AttackType is Command.Attack (1h). Otherwise it'll be Command.Magic (0h). So the odds of Sephiroth casting Quake3 are 1:3 IF there's not a monster that nullifies or absorbs Earth Elemental. Even though he has a Restore Materia, he will never use it in battle. You could get him to use it out of battle, I suppose. I never tried it. He'll also never use Fire3 on all enemies like this.
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-07 08:36:42
Quote
Quote
Since everything is init'ed to 0 then Attack will be 0 if AttackType is Command.Attack (1h). Otherwise it'll be Command.Magic (0h). So the odds of Sephiroth casting Quake3 are 1:3 IF there's not a monster that nullifies or absorbs Earth Elemental. Even though he has a Restore Materia, he will never use it in battle. You could get him to use it out of battle, I suppose. I never tried it. He'll also never use Fire3 on all enemies like this.
I always found it weird all other Sephiroths elemental spells had all materia linked to them except fire. Instead there was an empty slot. I always thought that this was a mistake on developers part but now I see AI tells different story.
Fire3 intentionally casted only on single enemies when normal attack would do ½ damage because of back row modifier. And because of that I think that casting Fire3 at all is impossible with this AI since if I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" correctly Sephiroth will only use normal attack and Fire3 against single targets. In vanilla scene.bin all enemies in flashback come in groups and Sephiroths kills them all in once either with Ice3 or Bolt3 and if for some reason 1 enemy was left alive it would always be in front row -> so no Fire3
Have I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" part correctly? Is this what actually happens?
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 13:25:08
@nfit1c: i believe that row 16 is the "can't reach" row, since zemzelet sets its row to row 16 when it flies up. oh, and imagine a fully ai controlled party... that would actually be pretty fun to do for boss battles (big ones)... see how long your ai lives against... your ai :-P.

@warbaque:  that is essentially right, but a way to make your second statement right (since putting just one nonzero value, say 23 for instance, could be wrong, even though it is still non-zero) would be to make if (something >= 1), because it will always be a (positive) non-zero value, though just if (something is much easier to write, and saves space :-P.
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-07 13:55:51
@warbaque:  that is essentially right, but a way to make your second statement right (since putting just one nonzero value, say 23 for instance, could be wrong, even though it is still non-zero) would be to make if (something >= 1), because it will always be a (positive) non-zero value, though just if (something is much easier to write, and saves space :-P.

My 1st statement was
Quote
If (something) is equivalent of If (something==1)
what would if statement return when using following value for example
something=0 If (something) returns 0
something=1 If (something) returns 1
something=23 If (something) returns 0
something=-23 If (something) returns 0

And second
Quote
If (something) is equivalent of If (something=/=0)
something=0 If (something) returns 0
something=1 If (something) returns 1
something=23 If (something) returns 1
something=-23 If (something) returns 1


Because in scripting languages I've been more recently working with
If Variable has been just shorter and more efficient way of using If Variable==1
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 14:26:28
actually, you have them reversed... if (something) returns true whenever the number isn't 0, so 346456456 would be true, 0 would be false. if (something == 1) would only return true when something is equal to one, so only 1 will ever return true, nothing else.

well, if (something=/=0) would work as if (something), but takes an extra three bytes in the ai to do, opposed to the if(something) method. if you use if (not(something)) in the ai (essentially an if(something == 0) statement), it does the exact opposite, and is good for whenever you ned to check something against the value 0, since it takes less room in the ai to do.

yay... blugu lost 99 of it's 262 byte size >:D. heh... and it looks like smogger isn't too much different ai-wise from the blugu, just an extra check, and a few modifications to add to make it work. just like with the MP and grunt enemies, since their ai was exactly the same originally (except moves used and random chances... exact same size)... i love it when enemy ai is the same (at least for this mod... overall that isn't a good thing >_>).
Title: Re: scene.bin ai size reduction project
Post by: nfitc1 on 2009-06-07 14:56:46
actually, you have them reversed... if (something) returns true whenever the number isn't 0, so 346456456 would be true, 0 would be false. if (something == 1) would only return true when something is equal to one, so only 1 will ever return true, nothing else.

well, if (something=/=0) would work as if (something), but takes an extra three bytes in the ai to do, opposed to the if(something) method. if you use if (not(something)) in the ai (essentially an if(something == 0) statement), it does the exact opposite, and is good for whenever you ned to check something against the value 0, since it takes less room in the ai to do.

If (something) works just as well as if (something <> 0). This includes negative values. The reason is the jump 70 which jumps if the popped value is 0. If the previous value is 0 then it jumps over all the next few statements. Also remember that just because things are compiled one way doesn't mean it's the only way to do it. Optimizing Assembler code is a huge task that requires you to know more than just the language it was written in.

And second
Quote
If (something) is equivalent of If (something=/=0)
something=0 If (something) returns 0
something=1 If (something) returns 1
something=23 If (something) returns 1
something=-23 If (something) returns 1

This is correct.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 15:10:56
yeah... and i wouldn't recommend doing what i am doing, even to myself :-P. with programming the ai, there are many ways to do things, some are better than others, but none "have" to be done a certain way. you could intentionally make the ai do 10x the work to do something, but it could still get the same answer as something 1/10 the size.

the ai does a normal sized script in one frame of the game, so unless you loop things massively, or program really bad, and when i say this, i mean REALLY bad... like using 1kb for a common enemy that only has two attacks :-P, it shouldn't seem any different in-game.
Title: Re: scene.bin ai size reduction project
Post by: nfitc1 on 2009-06-07 15:22:11
yeah... and i wouldn't recommend doing what i am doing, even to myself :-P. with programming the ai, there are many ways to do things, some are better than others, but none "have" to be done a certain way. you could intentionally make the ai do 10x the work to do something, but it could still get the same answer as something 1/10 the size.

the ai does a normal sized script in one frame of the game, so unless you loop things massively, or program really bad, and when i say this, i mean REALLY bad... like using 1kb for a common enemy that only has two attacks :-P, it shouldn't seem any different in-game.

No kidding. Remember what I said about Eligor having the longest script? Pointless. Granted he's almost as hard as a boss at that point, but he's no WEAPON.
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-07 15:24:48
Quote
Quote
Since everything is init'ed to 0 then Attack will be 0 if AttackType is Command.Attack (1h). Otherwise it'll be Command.Magic (0h). So the odds of Sephiroth casting Quake3 are 1:3 IF there's not a monster that nullifies or absorbs Earth Elemental. Even though he has a Restore Materia, he will never use it in battle. You could get him to use it out of battle, I suppose. I never tried it. He'll also never use Fire3 on all enemies like this.
I always found it weird all other Sephiroths elemental spells had all materia linked to them except fire. Instead there was an empty slot. I always thought that this was a mistake on developers part but now I see AI tells different story.
Fire3 intentionally casted only on single enemies when normal attack would do ½ damage because of back row modifier. And because of that I think that casting Fire3 at all is impossible with this AI since if I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" correctly Sephiroth will only use normal attack and Fire3 against single targets. In vanilla scene.bin all enemies in flashback come in groups and Sephiroths kills them all in once either with Ice3 or Bolt3 and if for some reason 1 enemy was left alive it would always be in front row -> so no Fire3
Have I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" part correctly? Is this what actually happens?
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 15:40:09
im slowly approaching eligor as well... he is where i am at in my hard mod (old one, pre-ai scripting knowledge), and inever found him to be difficult even in a normal game... his ai is really long for any enemy in the game (at the current ai level in vii), and i plan on shortening that :-P. MP and grunt had 861 bytes each... more than even GS did total, and they shrunk down to ~250 apiece, while GS is still around the same original size (about 30-50 lower, but still  :-)).

i think that the row being 16 is the "can't reach" row, but since there isn't any enemies that can fly out of range in the flashback, i dont think it is ever used. otherwise, he should always use fire3/firaga on an out of range enemy. either way, the only way to know is to have his ai active on someone in an out of range enemy battle, or set your row to 16 with ai and have the enemy use it on you (same thing, just reversed). i am almost 100% sure that 16 is out of range row, so i am guessing that putting sephy against a zemzelet or heli gunner for instance (zem would have to be flying), he would always use fire3 until they died.

warbaque... i think you should learn the way to program it with opcodes rather than just in the normal code form, since even if you know how it should look in written form, it won't help you if you can't code it. a good place to fool around with learning ai is the MP fight at the start of the game, just skip the movie (gypt instant yamp) with ctrl+s, run forward when able to, and test your enemy guaranteed, no need to worry about any other enemies possibly showing up. then, when you are done, or it craps out, just quit out and change/try again, taking little time between modifications :-P. and even if your logic is right, there could be little errors (such as using wrong sizes for variables) that would still show correctly in the disassembled view... the more you know about the coding itself, the better off you are. not that learning how it should look is bad, it is just useless without learning the coding along side it.

almost ready to put a beta up for testing, since air buster is a few enemies away. the kernel update issue in PrC happened again, but no biggie. air buster is going to be a fun one though...

wow... i just looked ahead to eligor's ai, and it has 2693 bytes used for it's ai... that is REALLY bad... and i will probably make the scene.bin shrink a size by editing it's ai alone... what were they thinking?

taking a quick look at the scene files again to remove enemies that aren't used in-game (grunt at shinra building for example). should give some more room. at 256 kb currently, it's last scene lookup is now 246, so it is getting pretty close to shrinking yet again. checked the cactuar battle, and it wasn't affected by my scene file hex editing (removed the grunts in it's scene, as well as in scenes 63/64 (erased completely/all FF file), since they were not used), so things got a little boost in shrinkage safely :-P.
Title: Re: scene.bin ai size reduction project
Post by: Chrysalis on 2009-06-07 18:05:11
my game style must be odd I find eligor very easy, easy to the point I can just have 2 characters waiting whilst the 3rd one keeps attempting to steal the striking staff, he is not hard enough in that I need to heal and finish the battle.

in regards to peerless I meant adding the ability to enemies so they can use it, I wouldnt object to the player been able to use it ( I considered adding great gospel to cait sith as level 3 break or as a reward on his fruit machine) but it can be considered a cheap move.  I am not massively against cheap moves I think they are less of a problem than the overall too weak enemies.  Its one thing having cheap movies it is another thing when the cheap moves arent needed to easily win a battle.

secondadvent I think you have touched on the problem I noticed, when I was looking at the growth curve in wallmarket I wanted to see if I could make early growth much slower (like in oblivion) and it accelerates towards the end so higher levels are more rewarding and you not overpowered early in the game, some times when attack power increases there is very large boosts in attack been dealt as well.  In addition I would like to see different characters more variable in their stats.

So if barret is a tough guy we boost his max hp and max defense but we make his magical and dexterity abilities signifacantly worse.
Tife we boost her dexterity but we reduce her toughness and hitting power.
Cait sith we can make someone whos lucky and is good at magic but very weak physical abilities.
I would have vincent the 2nd best at magic in the game (behind aerith and ahead of cait sith), but weak at physical defense and dexterity.
Cid can be all round like cloud but weaker.
nanaki dexterity same as tifa but not so fast and of course not as weak.

So these are ideas to add variety which makes the player be more strategic in the use of characters.

There is one thing I wonder a lot in RPG's which squaresoft made an effort to fix in crysis core and that is why dont they add diffilculty levels, they have a problem in satisfying players new to the genre so dont want the game to be too hard and dont want to make it so the players have to train and level up their characters to get pass a boss, but this then makes the game too easy for experienced players, the solution is a diffilculty option, personally I think its better if a player needs to level up to get passed a point in the game then be in a position where the level is too high for that point of the game and things are too easy.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 18:25:51
i know eligor is easy... it just has a massively high amount of ai it uses (basically repeating the same thing a million times). if you pump up it's stats it can be deadly though, as can any other enemy be if the game is balanced right.

peerless would be something i would give to enemies (stronger ones) as something similar to ffxii's paling, but for both phys  magical, and status resistance in one, and wears off quickly. however, manually setting enemies to be immune tho things with ai editing (setting phys/mag immunity on, dunno if status immunity is there/works or not yet) allows for a longer counter, which is dependent on their attack speed rather than in-game units of time.

i am not going to be adding anything yet, but after i finish up to and including air buster, i will be putting my mod up for testing (hopefully it shrinks to 248kb... it is close ^^), and starting my hard/balance mod up to air buster as well (kinda alternate between the two, compressing then making use of the compression. i hope you guys will help me out with the testing as well :-P.

the beta should be up either later today, or early tomorrow (3:30 pm here), since i will have to do school work here soon, which is very easy... my current class is an intro to programming course, teaching about pseudocode (not any actual language, just pseudo), and is my third full intro class, i have had a intro to java, C++, and half a COBOL class before this, all teaching pseudo as well, but i have to take this class to continue on... guess i will get another A then XD.

ok, the blood taste enemy's tentacle drain is physical based, and costs 0 mp, even though it seems as if it should be a magic attack in the ai (checks for mp as well). unlike it's previous palette swap, the guard hound, it cannot use the regular tentacle move. what i am thinking, is that it was normally supposed to have three attacks (bite, tentacle, and tentacle drain), and that the draining version was to be magical based with mp cost attached. if the ai supports this fully, it will be gaining an attack, and it's ai will be slightly altered from normal.

i think i will add the normal tentacle attack, and make it the attack used if it runs out of mp, essentially making it still use it's tentacle attack, just without draining capability, since the tenacle attack is stronger than the normal bite attack anyway. it will also replace the bite attack in another spot, where the possible double attack happens, making the second attack the more powerful tentacle attack, though it would only use this at lower life (commonly at least), so it is essentially a balancing attempt, but with weak enemies :-P. tentacle drain will be switched to magical damage, and the blood tastes given enough mp to use it a good bit, but i will not change their magical power, though i may have to reduce the atk power of the move to accommodate the type switch.

yeah... i checked, and if it were to just do a plain switch, it'd do ~78 damage a hit... if i reduce the power of the drain attack to 1 instead of 10, it'd do the same damage it does now, but in magical form. a really weak attack, but it would still be true to the original damage amount. then again i could keep it physical and just give it mp cost, but then it's magic power goes to waste... though at a 1/16 base power, at 255 magic and at lv 99, it'd only do ~130 damage, hardly anything. i think it will stay physical for now, but with an mp cost, since that works out the best overall.

also, i will be reversing all dropped/stolen items (not making steals drops, and vice versa, but the order in which they are gotten, making the rarer items drop first), since there was obviously a mixup in the layout, since some items are made extremely rare, some items completely missable after a certain point (vagrysk claw anyone?), when the rare item was supposed to be checked for first (giving the rare drops priority if the random number succeeded, instead of going through all common items first). this should help balance the normal drop/steal chances without actually changing the item or drop rates, making the common drops less common, and the rare drops more common.
Title: Re: scene.bin ai size reduction project
Post by: nfitc1 on 2009-06-07 20:39:38
Quote
Quote
Since everything is init'ed to 0 then Attack will be 0 if AttackType is Command.Attack (1h). Otherwise it'll be Command.Magic (0h). So the odds of Sephiroth casting Quake3 are 1:3 IF there's not a monster that nullifies or absorbs Earth Elemental. Even though he has a Restore Materia, he will never use it in battle. You could get him to use it out of battle, I suppose. I never tried it. He'll also never use Fire3 on all enemies like this.
I always found it weird all other Sephiroths elemental spells had all materia linked to them except fire. Instead there was an empty slot. I always thought that this was a mistake on developers part but now I see AI tells different story.
Fire3 intentionally casted only on single enemies when normal attack would do ½ damage because of back row modifier. And because of that I think that casting Fire3 at all is impossible with this AI since if I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" correctly Sephiroth will only use normal attack and Fire3 against single targets. In vanilla scene.bin all enemies in flashback come in groups and Sephiroths kills them all in once either with Ice3 or Bolt3 and if for some reason 1 enemy was left alive it would always be in front row -> so no Fire3
Have I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" part correctly? Is this what actually happens?

Not really. Like I have said, the disassemble is just an approximation and isn't always 100% accurate. This is one of those times. That particular piece isn't an ElseIf block, but an If block nested inside an Else block. Confusing, I know. Conditions are one of the harder things to decompile because jumps can go all over the place and there are frequently jumps that never get called that are throwing off the disassembly.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-07 22:59:37
ok, blood tastes are done and able to use tentacle drain up to four times due to mp cost (still physical attack equation used),so only air buster is left before the beta arrives, but i have to finish school work first, so it could still be a few hours until then, plus i still have to do the initial testing of all the ai i recently edited (everyone between guard scorpion and air buster). i do not think it will reach 248 kb this release, but the next one will most certainly become that small :-P.

my goal is to try and reach ~200kb in size, but whether or not it can be shrunk that far is still unknown to me right now.

ok, now with a weeks worth of programming class homework done in two hours (a test included :P), i am now back in action >:D. sadly, it took me longer to finish that homework, which was easy, than it does to shrink a moderate sized enemy's ai... too used to ai editing right now i guess  :|

heh... by the looks of it, air buster will be a nice little challenge to optimize, and since i know what 402c is, i know the only unknown in it's ai :P. yay for the no death animation flag, which stops the normal death animation, usually for using custom death animations (in this case, he uses a different version depending on his facing), but can also be used to prevent the enemy from becoming invisible when killed and revived via ai (insta revive, non-invisible style, and without using a move to do it >:D). hmm... if there is a flag to enable the main script, maybe there is one to enable/disable others, more specifically the death counter, so multiple auto rezzes can happen in one fight.

i think i am going to test up until i reach him, just so i can get a better understanding of what all is possible to be removed without any changes to his performance. and this way all i have to do is test one fight before the beta is out :P.
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-08 02:14:16
Quote
Quote
Since everything is init'ed to 0 then Attack will be 0 if AttackType is Command.Attack (1h). Otherwise it'll be Command.Magic (0h). So the odds of Sephiroth casting Quake3 are 1:3 IF there's not a monster that nullifies or absorbs Earth Elemental. Even though he has a Restore Materia, he will never use it in battle. You could get him to use it out of battle, I suppose. I never tried it. He'll also never use Fire3 on all enemies like this.
I always found it weird all other Sephiroths elemental spells had all materia linked to them except fire. Instead there was an empty slot. I always thought that this was a mistake on developers part but now I see AI tells different story.
Fire3 intentionally casted only on single enemies when normal attack would do ½ damage because of back row modifier. And because of that I think that casting Fire3 at all is impossible with this AI since if I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" correctly Sephiroth will only use normal attack and Fire3 against single targets. In vanilla scene.bin all enemies in flashback come in groups and Sephiroths kills them all in once either with Ice3 or Bolt3 and if for some reason 1 enemy was left alive it would always be in front row -> so no Fire3
Have I understood "ElseIf ( (BitCount(AllActiveOpponentMask) == 1) )" part correctly? Is this what actually happens?

Not really. Like I have said, the disassemble is just an approximation and isn't always 100% accurate. This is one of those times. That particular piece isn't an ElseIf block, but an If block nested inside an Else block. Confusing, I know. Conditions are one of the harder things to decompile because jumps can go all over the place and there are frequently jumps that never get called that are throwing off the disassembly.
Not that confusing now that you explained. Seems like, as secondadvent said, I should use mainly opcodes while editing AI, not that hard after a bit of learning.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-08 02:18:33
i advise you to start with a simple ai (like 1st ray) and work your way up to bigger, more complex ai. i am at air buster right now and i have to actually test the fight normally to know what is able to be removed, since it's ai is a big mess (not as bad as eligor's, but pretty bad). they made things complicated beyond what was needed, and i plan on fixing that :P.

try out some ai on the mp enemy (just use a fresh scene.bin and completely erase the main ai and start from scratch, it makes learning much easier. also, use the WM help file, and look into the ai section for a good many examples, and what the opcodes do. that is how i learned to do this, and i am putting it to good use >:D

at least now is a good time for me to compile a list of how the ai should react, lain out in an easy to follow way, so that i and other people will be able to test out my ai to make sure it is all working properly. i already have a list of changes to both size, and enemy moves/stats (only a few moves/stats altered so far, to better fit the ai), so that is one thing down.
Title: Re: scene.bin ai size reduction project
Post by: warbaque on 2009-06-08 02:22:33
I just checked and Eligor's AI is definately a mess.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-08 02:26:22
oh yeah, but i know what is going on there, and could easily take it pretty damn low. if you notice, the same damn checks are performed over and over, rather than jumping to the very first time it is checked and working from there. writing something once and jumping back to it is more efficient and much easier to follow than writing it 100 times, but you have to model the program around it so that when other parts jump to it, everything flows right.

AB is my biggest enemy so far, having around 1150 bytes worth of code (shrunk ~20 so far in the death/pre-battle ai, and they were small to begin with), so it will take some time.

here is an example from my test file, showing what the enemies should do in a fight, like who is targeted, and the chances of using certain moves, but with better spacing obviously... it doesn't like to copy tabbing over >_>:

Grunt:   it's row   party's row      target      attack probability
           front      all in front      random      1/8 Beam Gun, 7/8 Handclaw
                       all in back      random      5/6 Beam Gun, 1/6 Handclaw
                       mixed rows   *              1/2 Beam Gun, 1/2 Handclaw
           back      all in front      random      7/8 Beam Gun, 1/8 Handcalw
                       all in back      random      15/16 Beam Gun, 1/16 Handclaw
                       mixed rows      *              11/12 Beam Gun, 1/12 Handclaw
*if the attack will be Beam Gun, it will always hit a back row ally, if Handclaw, always front row ally
Title: Re: scene.bin ai size reduction project
Post by: obesebear on 2009-06-08 04:48:00
I have no clue what it is exactly that you're doing... but once you're done, will the enemy's act more intelligently?  Not necessarily more difficult, but perform moves normally at their disposal at more appropriate times?
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-08 05:22:03
for this part of my mod, no. all that is being done is bugfixing the original ai (and adding things as needed when i think it fits into the original ai's layout, i.e. what i think was going to be there originally), and rewriting the ai to be much smaller while doing the same thing. this is essentially for those psx modders out there to have a nice base scene.bin to use that shouldn't ever go above the size limit unless you massively add things to the ai, and i mean a LOT.

however, after i release my current version (will be up to air buster), i plan on starting my hard/balance mod, which will be doing as much ais i can do to make them much more capable of kicking your ass. believe me, i have plenty planned, and the sad thing is, is that i will likely NEED the base ai compressed as far as possible to fit it all in to still easily fit into a psx iso. i will be compressing/bigfixing, then balancing/increasing difficulty, and going like that back and forth as i progress on, and when i make significant progress with the balance mod, it will gain it's own thread.

this part is just to make my, and other people's, life easier. i think people would be happy to have a mod they can easily use as a base for their projects, or for any who just wants to play a bugfixed version of the original, or as much as i have knowledge to do (i will try as hard as i can to find out the unknown variables, for better understanding of certain ai's and for future use).

i am currently at air buster, so when i complete his ai and do initial testing, a beta will be out for people to use, and my balance mod will start to take shape as well. i will have to completely remodel each enemy twice, once for this mod, and again for the balancing one, but it will be worth it in the long run. beta will be up sometime tomorrow, since school took some time away, and i am pretty damn tired XD.

i updated the first page into something hopefully more readable, especially since i will soon be releasing the first vesion (actually about version 0.05-0.1, but it is still a release :-P

ok, all enemies tested up to, but not including air buster (still need to see exactly how its ai works), an fixed the bugs i initially had (mainly just trying to put a value into another value instead of in an address... i hate when i do that >_>). at least my fixes didn't require any additions/rearranging, my program was right, but my little address errors stopped it from working right (actually all but one worked almost right, even with the errors for some reason :-P). now to work on air buster, test him, and then put my release up >:D.

his ai is currently giving me issues, i am still figuring out the facings and stuff for the battle (learning about special formations at the same time), but i should be making progress soon.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-08 18:37:51
ok to bump up my thread some, and to add some ai info that i have been messing around with (air buster testing).

going to make an example of what happens during back/side attacks:  

party 1        party 2            party 3
facing= 1     facing = 1/0     facing = 0

ok, party one is the left side of the screen, and party three the right. when someone of one party attacks another party, and their facings are the same, the back attack damage occurs (same party would be guaranteed back attack, even though they are in the same row, which is why it doesn't work that way. it must be two different parties). so if cloud attacked air buster when it was facing barret (cloud's facing is 0, barret's facing is 1, and it is facing the same way as cloud, so AB's facing is 0), the back attack damage would kick in since they both have the same facing, and are in different parties.

back attack (enemy's back is facing you) keeps your facing at 0 like a normal fight (you get facing 0 as a base, and the enemy gets a base facing of 1), but the enemy's facing is also 0. in an ambush, your facing becomes one, like the enemy's base facing. a pincer attack would have the same layout as a side attack battle (not completely sure, haven't got to test one yet), the right side being facing 0, the left facing 1, and your party facing mixed ways.

the sideAttack flag is likely just to check which party someone is in during a back attack, used similarly to the facing flag, but likely to attack specific parties rather than a specific person (like when using an attack all move, it can only hit one party, probably unless the move hits everybody on the field). doing some testing on this flag now, will update about it soon.

ok, barret's backAttack flag is 1, and clouds' 0, just like the facings, so it is like a party facing a certain direction, and that direction is the flag for that party.

ok, finally getting it's ai slimmed down, but i am having to test as i edit, since i am not 100% sure on everything. the original ai has so many flaws it is unreal. they set the idle animation in places where it is not needed to be set, and the final hit has the wrong animation as well (acts as if cloud hit it when killed by barret/tifa, and vice versa). working on the counter ai first, since it is smaller and is easier to test (in a shorter time frame anyway). bodyblow is unusable when at under 20% hp (turn broken), since it cannot move.

if i cannot get AB done anytime soon, i will release the scene.bin as it is, which has everybody up to him finished and (hopefully) working. AB has a lot to optimize, and there are things i am thinking of adding (not sure yet though), so he will still be a while.

i dont think that it can use bodyblow unless it is attacked from behind (and if it's turn isnt broken) and at a 2/3 chance. the move itself turns AB around (and sets it to a new idle animation) like it does in the main ai. this is what was causing me trouble, as i couldnt figure out how the hell it was turning without the special attack added before it. should be pretty fast from here on out then ^^.

air buster's counter ai is now working properly (i hope), so all that is left is the main, and then it will be released.

update: ok, just some tweaking and then the mod will have it's first release! the ai is finished now, but there are still two bugs that were in the original ai (the wrong hurt animation on killing blow, meaning if facing barret and hit by cloud, it looks like he is facing cloud when the hurt animation plays, and if attacked in the back and then attacked in the front (if it doesn't use bodyblow as a counter, or turn using main ai), the back attack damage will still happen to an attack on it's front, probably because the game automatically reverses the flag when back attack damage is done). other than those two bugs, it should be working like normal.
Title: Re: scene.bin ai size reduction project
Post by: secondadvent on 2009-06-09 03:24:41
ok the first release is out... let me know how things go ;).
Title: Re: [Release]scene.bin ai size reduction project, v0.1
Post by: gjoerulv on 2009-06-09 16:13:05
Nice to see someone removing all the AI bugs. However, if someone urgently needs a scene.bin with all the AI bugs fixed you can download the scene from my "hardcore" mod. Though they're heavily moded so I could hardly recommend it (unless you want to use my battle.lpg as well). I based my bug hunt on TFergusson Enemy Mechanics. I didn't Include those bugs from Bizarro though 'cause it wouldn't change anything concerning the battle itself.

But I wanted to ask: Do you go through every bit of the AI or do you follow some kind of lead. The former seems too tedious for a lazy person like me lol. Now that I think 'bout it if I actually had read some of the post here I would prob get my answer.  :-D
Title: Re: [Release]scene.bin ai size reduction project, v0.1
Post by: secondadvent on 2009-06-09 16:54:58
yeah... i go through every ai manually. getting to know how they work allows you to find bugs easier, and helps you learn quicker ;). im making this mainly for people who just want something close to the original ai, and at a much smaller size, with bugfixes, that can easily be modded without having to worry about size at all (big for psx users), unless they were to add some ai, and even then they'd have plenty of room to do it. it's something i am going to be using for my main mod (a hard balance mod... which we have plenty of, but variety is nice :P), which i am working on now (going back and forth between them, that way i don't forget what i have planned  :-D).

if you were to look into every enemy's ai the way it was originally, you will notice many things that are either bugged to not work (unnoticed by regular users, sans a few bugs), or coded extremely repetitively (eligor >_<), so much of the ai is unneeded anyway. this is kind of an optimization project, and im hoping people will actually like and use this as it grows, otherwise i'll just have to use it fo myself :P.

hmm... doesn't seem like it is gathering too much attention... i guess i will be putting more work into my main mod then >_<.
Title: Re: [Release]scene.bin ai size reduction project, v0.1
Post by: secondadvent on 2009-06-10 14:59:27
ok, on my mod that is using this mod as a base (a hard/balance mod), i have successfully added a feature to allow enemies to level up as you do, though it takes up a good bit of room to do. i plan on editing the enemy ai even further to make the battles themselves more balanced/difficult, so the ai will be possibly increased more, or for some enemies, decreased.

enemies will be given new moves (if i can,with the limited animations, and my limited animation creation knowledge :P) as they get high enough in level, their moves may gain statuses as well, possible elemental resistances given, auto-statuses (possible auto life as well ^^), and much higher stats. their current level will always be at or higher than your current level, some higher than others, and their stats will go up accordingly, by a possible set amount, and/or a random amount (random amount for luck/speed/evade most of the time (1 or none) with no set amount, while things like hp will have both a set amount and random amount, to make enemies more unique).

i may possibly change battle formations as well (not the first release more than likely), to make more difficult random encounters, as well as change the battle square fights, since the difficulty will be way up in there, to only be one-on-one for the most part, except with overall weaker enemies, because making the battle square too hard would make finishing it next to impossible, even with extreme luck on the slots.

i would be adding more drops/steals to the enemies (and making it possible to steal more than once from some enemies if i wanted to), but i cant find the damn place it is located if there is one, so that is out for now. i also wanted to add status immunities to them (and cause some attacks to make you immune to good statuses), but that is out for now as well.

gonna take a temporary break to create the rest of my ffxii earliest possible bazaar package list (including enemies needed, and quantities as well, and packages that are linked with each other at that time), since my friend is coming over tomorrow, and he has been following it so far (busy chaining the rare bat in golmore >:D).