#DDA AI-Script small question thread
309 messages ยท Page 1 of 1 (latest)
First things first however, is it possible for me to return an ai target from a function and it work?
so if I call it like
useskill(2818)
function()
it will use that targeting?
like this would be crazy good
So I dont have to return a value then check again
I can just return what the targeting is in the function to use
so I choose to use phys and there is no one with ailments
so just target randomly
why would you have to do that
Because I want to make it use a targeting choice like rnd by calling a function that checks
so I can ask it to choose 1 target if they have an ailment or just everyone if 2 have them
by calling a function like (target_ailment)
or can I just use the targeting without the return
Basically can I call a target for a skill within a function?
that is seperate to the skill
I mean maybe? but I don't really see the purpose behind making it that complicated as opposed to just doing a simple if else statement
I have reasons...
Mainly because I want to condense it down into a function I can call any time but
I can live
probally
I mean idk if the whole return thing would work
I've never tried it or seen anyone else try it
but I don't think there's really anything stopping you from making a bunch of different procedures to call if you don't feel like writing stuff like that over and over
I'd just recommend writing them in like a separate flow file and importing it into your scripts
just to make it easier to look at
also so you don't have to keep writing those procedures
I do not
I can keep it simple
that is an option
or super jank even not like anyone but me is gonna use it 
well as the saying goes
if it works, it works
I just never bothered trying too much outside of the basic stuff with flowscript because trying some of the more advanced stuff never seemed to work for me
granted that could easily just be a skill issue on my part

same here probally
oh I will also need a battle file are those lain out similar to the ai flowscript here or do they have some wildly different format? The documentations doesnt really give much detail
Yes
All I need it to do Is to count party members with ailments for my targeting
after each turn
but they have procedures that run at specified times in the battle that I'm assuming is determined by exe stuff
the guide should tell you which is which
It did
why not do that with the AI script? I'm not sure how something like that would work in the encounter script
actually it might work because i think Yaldabaoth does something similar for some of the dialogue
From my limited understanding I need an id to check the members individually
so I cant to that without the party members ids
unless I check them all
but I have no idea if checking a member that isnt in the battle crashes the game or causes some unforseen error
I'm not sure why you'd have to check them individually
but no it wouldn't crash or anything
if they aren't in the battle then it just wouldn't run that code
and party member IDs are pretty simple
they should already be documented in the script compiler enums
but if not then this is what I have
wait does that give them as a int
so the other 3?
ok I wamted the id because I wanted to use this
so my idea as to see who is there after all 4 party turns have passed then use that for targeting
I think so? but you don't need to pad them out or anything
you can just do it like
AI_TAR_ID( 1 )
and that'll mean whatever is specified will only target Joker
why not just use AI_CHK_ENBAD for this though
for single and aoe targeting I can just use the builtins but for me to differentiate if 2 or more have them I need to check individually
because there is no function that gives the NUMBER of them inflicted in the documentation
I might be wrong, but I'm pretty sure that's what AI_GET_ENBAD_ON does
hojoON is there for buffs
it takes the same status flags as ENBAD does, it just returns the number of party members afflicted with the specified ailment
you can see a list of all the functions here https://github.com/tge-was-taken/Atlus-Script-Tools/blob/master/Source/AtlusScriptLibrary/Libraries/Persona5Royal/Modules/AI/Functions.json
there aren't descriptions for them or anything, but the names are all here at least
ok then
I think I downloaded that file actually
yes I did I just couldnt wrap my head around it 
huh
I think I will give descri[ptions to the ones I use in future in my own copy of the file
so this just checks enemy weaknesses?
oh yeah I forgot to note down the turn checker
does it just check turn 0? The AI_CHK_TURN_0
it checks if anyone is weak to the specified affinity. when used from enemy AI script, it's checking for those weaknesses on the player side
AI_CHK_TURN_O checks the total amount of turns that have passed in the fight
it's a bit confusing because both player and enemy turns count towards it
so for example; AI_CHK_TURN_O( 50 ) would return true after 25 turns, not 50
maybe?
there's a good amount of those functions that are unused so it's hard to tell what they do
or if they even do anything at all
I believe some of them are just leftovers from P4G that are probably just empty in the exe
Did I get the flags correct here?
I think?
do these ones do anything in royal?
I have no idea, but I know the ATTR functions usually have to do with checking if a unit has previously used a skill from a specified affinity
I've never seen that specific one in any scripts I've looked at though, so I'm leaning towards unused
I see
it's in player AI
bit hard to tell what exactly it does because the player AI is kinda convoluted
there's quite a few AI functions that as far as I can tell, were made literally just for player AI
and it's not exactly obvious what they're doing because nothing gets plugged into them, so you'd have to go digging through the exe to look
and yeah, the player AI bf doesn't help much either lol
I see...
oh and does AI_TAR_HPMAX target the highest hp on the field?
highest max hp that it
yes but it goes off percentage, not their actual HP value
I see
Got something like this right now, some thingsd will likely come up later but
seems like an alright baseline
Oh I put end
Not rnd
changes their affinities to the affinities of the specified enemy ID
oh

oh yeah also in my own copy of the functions json I am going to be documenting what I see, mostly based on guesses and inferences but it will help me find the ones I want later on
oh and one more small thing before I go to bed
what does the st mean here?
is it like an inclusive thing?
so they dont drain or
repel or drain
or
nul, repel or drain
depending on which you call
I think it's supposed to be for "Standing"
meaning it'll target whoever repels the specified affinity and isn't knocked down
but idk, they're kinda weird
funny thing is that I think Lavenza is the only one who uses any of those targetting functions with _ST in it
player AI uses AI_GET_UNIWEAK_ST as well
but that's it
Sorry for any confusion! I didn't document all the functions because I was trying more to explain the patterns in function names rather than go over every single one and make the guide much bigger. But there are definitely some useful ones listed in the JSON file that I didn't go over expicitly.
I see
I think I have found one actually
I wonder if the nullify extends to drain and repell
as they dont have entries aswell
ok they dont have target variants nevermind 
these might just check if the caller is weak or resistant to the affinity given
You can get a wider range of targeting options if you can check who is in the battle tbh
that might be something I do in a battle script
is there logical "and" with these scripts?
&&
I see
and can we also have lists/arrays or are those way beyond the scope of what we have lol
I believe there's some machinery for arrays, but it's pretty limited and brittle.
rip
Very simple arrays can do what you want, but as soon as you need to do something like nested arrays or accessing both i and i+1... it's known to be finicky.
It's very much designed to be a subset of C syntax. So it's really only got the basics, but if you're coming from Python and not familiar with C's conventions, it would be worth finding a basic C reference.
I tried doing a switch statement once and even that didn't work
wtf
I swear I've heard of folks who used switch statements effectively, but yeah, the simpler you can keep things, the better ๐ฅฒ
In the end, flowscript is just an approachable formalism to keep modders from having to edit bytecode, but... it's still written atop very simple bytecode, so it's hard to get fancy.
oh yeah something I wanted to put past you is if I can select targeting from a different functioin like this
if I call for targeting like target(), can it use it from inside this separate function?
(I'll defer to Fayande and co. for that, because I don't work with the battle functions enough to know specifics.)
Lol, sorry, I bring more general programming knowledge.
Thats good enought for me
never dived into any of the C derivatives but the one time I did I had 0 idea what to do
Python shaped me 
Not many other Python users around here, but fortunately I can translate, there ๐

man I need to make a check to see which of my few values is the largest 
actually maybe not
I just see which one is 2 first or something
hmmm idk
I want to think of a simpler way to do this that isnt a really long line of ifs
like man I am planning ahead and thinking with my brain and dont even know how to check for a highest value
I know modmenu does, but I have no earthly idea why it wouldn't work for me
then again, with how many things are still kinda broken with modmenu maybe it just doesn't work anymore for whatever reason
from my debugging though, it's like the switch cases were working the way they were supposed to but the game just wasn't executing anything inside the cases
Is there any easy way for me to check the max from a group of variables...
what do you mean
ok so I want to check what ailemnts the party has and want to target them based on which has the highest
I could cheese this by checking if 3 of them are present and just sending nuke damage to technical
since nuke technicals with 3 of them
But it could also just be moreso for seeing if I should aoe or not
you could script some kind of ailment priority thing if you really wanted to
I just mean like, if you want the AI to prioritize targetting Dizzy over Sleep or something (just using that as an example)
you could probably script something to prioritize targets with multiple ailments if you really wanted to, but that sounds like making things a lot more complicated than they really need to be in practice
yeah this would work
I could jusy have it single target all the time but I feel thats would be painful to watch
although that is seperate to the targeting here
hard to say really. when making custom AI for this game, you kinda just have to get used to trying shit just to see if it works lol

I was thinking of having a turn limit thing but I dont think I will
if you can recover from sleep + rays of control I think you deserve to keep going
with how primitive and basic the AI in the base game is, I'd say there's a lot of the potential scripting that just doesn't even get used so there's a lot of things you can do that don't have any precedent to compare to
so what I needed for this is to see how many their are with that ailment to use in my skill use, no point using nuke damage if I can use almighty intsead and actualy tech
I will set up the prio as shown
or maybe a bit differently as vanity is a special case
I know switch statements essentially get compiled to a series of ifs, and whatever is inside the parentheses gets evaluated multiple times. This threw me off when I put a SEL() inside the parentheses (which causes dialogue options to appear) and it got called multiple times, causing the options to appear multiple times in the game's attempt to match one of the cases.
like I said, from when I tried it's like the cases were being determined properly but it wasn't executing anything inside the cases so it would just skip over them entirely
This is my never used AI utility script, maybe it will be helpful
Here's an example of usage
ok 
Omg is that a
Smart check for Weaknesses and effects?

OK I get what its trying to do
Mine is more complicated 
Lol
However I will take that enum code 
Makes remembering stuff easier
Hold on new question
Is enum in this case purely for variable values or can it be used to call functions?
So if make a an enum act()
Can I call it like act.phys to trigger a physical attack function?
Um, no. That's not how enums work. You can make an Act function that accepts damage type as a parameter, for Act(phys)
Maun
Oh yeah something I wanted to sdk before I went back home is if their is documentation on the dialogue files, so for thr battle script to trigger voice lines and pop up boxes
Or will I have to go grab one and look
I'm a bit confused as to what you're asking
IDK if it's documented, but we did briefly touch on some in-battle dialogue mechanics here: https://discord.com/channels/746211612981198989/1255796360209371187
...if that's the sort of thing you mean?
Yes
I just want to make the dialogue box appear with text as you would see in other boss battles
Does anyone have any idea why my if statements get skipped? The conditions are being met
this is first few lines after the beggining of declaring AI_MAIN
is it not all I have
its just those if statements
The counter ones work just fine
does all the skill one after the other
the if ( AI_CHK_MYHP( 20 ) == 1 )
and the if ( AI_CHK_MORE() == 1 )
Everything contained within those does not get triggered even if the conditions are met
well whatever is in the first one isn't going to get triggered unless the enemy is at or below 20% health
I got it to like 10% and it kept doing the skill loop 
and I gave it 1 mores
nothing
what's in the 20% thing?
well if you're sure you're triggering those conditions properly then I don't see a reason why it wouldn't be working
kinda hard to tell for sure without seeing the whole thing
thats pretty much the entire script without the one enumeration
either my compiler cuts it out or I've done something wrong?
idk, I don't really see anything wrong with it

you're absolutely sure you saved and compiled that into the bf that the game is loading?
Yes
if it's not that or some weird compiler error, then idk
Ann was knocked down by diamonds dust but still used maziodyne, the next skill in the 11 counter
try re-decompiling the bf in the game files and see if it matches what's in your original flow
this changed slightly but idk if thats relevant
the decleration was moved to above the cutin setup
it adds newlines in places also but I dint think thats the issue
well I think its bed time for me 
ok I fixed the script by making it messy?
its skipping the ifs because they dont have an else attatched to them???
uncompiled and compiled ones
I will have to try again some other way
I hope I dont need to add an else for every if 
...Damn, really? That seems like a major oversight in the flowscript compiler....
I feel like it has to be something else because I've never noticed that being a problem
and I've used if statements like that a lot
Are there any logical issues with this?
Before I go down the rabbit hole of trying to put this in the right place for imports to work
oh god can I not use string variables??
Uhhh, there's a constant string table that seems to be mostly for logging, but string variables? No, that's not a thing here, to my knowledge.
FlowScript barely has arrays, it seems like a lot to expect ๐
yeah I changed it
i did however run into this
There is another where it just refuses to recognise an else
You're missing an open brace after line 178.
