#DDA AI-Script small question thread

309 messages ยท Page 1 of 1 (latest)

thin saffron
#

Just a thread where I put small questions to be answered and discussed as they really dont warrant their own thread

#

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?

thin saffron
#

like this would be crazy good

gloomy hamlet
#

I don't really get what the point of this would be

#

but my hunch says no

thin saffron
#

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

gloomy hamlet
thin saffron
#

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

gloomy hamlet
#

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

thin saffron
#

I have reasons...

#

Mainly because I want to condense it down into a function I can call any time but

#

I can live

#

probally

gloomy hamlet
#

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

thin saffron
#

oooo

#

ok

gloomy hamlet
#

also so you don't have to keep writing those procedures

thin saffron
#

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 ICANT

gloomy hamlet
#

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

thin saffron
#

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

gloomy hamlet
#

I'm assuming you mean the encounter script

#

it's similar

thin saffron
#

Yes

#

All I need it to do Is to count party members with ailments for my targeting

#

after each turn

gloomy hamlet
#

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

thin saffron
#

It did

gloomy hamlet
#

actually it might work because i think Yaldabaoth does something similar for some of the dialogue

thin saffron
#

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

gloomy hamlet
#

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

thin saffron
#

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

gloomy hamlet
#

you can just do it like

AI_TAR_ID( 1 )

#

and that'll mean whatever is specified will only target Joker

gloomy hamlet
thin saffron
#

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

gloomy hamlet
#

I might be wrong, but I'm pretty sure that's what AI_GET_ENBAD_ON does

thin saffron
#

Thats not documented SkadiDaijoubu

#

ok then I'll use that

gloomy hamlet
#

weird

#

I thought it was

thin saffron
#

hojoON is there for buffs

gloomy hamlet
#

huh

#

well the idea is basically the same

thin saffron
#

Ok I will keep that in mind

#

I appreciate it

gloomy hamlet
#

it takes the same status flags as ENBAD does, it just returns the number of party members afflicted with the specified ailment

#

there aren't descriptions for them or anything, but the names are all here at least

thin saffron
#

ok then

#

I think I downloaded that file actually

#

yes I did I just couldnt wrap my head around it ICANT

gloomy hamlet
#

it's part of the script compiler

#

so you should have it, yeah

thin saffron
#

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

gloomy hamlet
gloomy hamlet
#

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

thin saffron
#

very well

#

does this just check if the enemy has been scanned before?

gloomy hamlet
#

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

thin saffron
#

very well

gloomy hamlet
#

I believe some of them are just leftovers from P4G that are probably just empty in the exe

thin saffron
#

Did I get the flags correct here?

gloomy hamlet
#

I think?

thin saffron
#

do these ones do anything in royal?

gloomy hamlet
#

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

thin saffron
#

I see

thin saffron
#

ok this has to do something

#

is this legit just a free technical action?

gloomy hamlet
#

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

thin saffron
#

I see...

#

oh and does AI_TAR_HPMAX target the highest hp on the field?

#

highest max hp that it

gloomy hamlet
#

yes but it goes off percentage, not their actual HP value

thin saffron
#

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

thin saffron
#

oh hwo does this one work?

#

with only one input

gloomy hamlet
#

changes their affinities to the affinities of the specified enemy ID

thin saffron
#

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

gloomy hamlet
#

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

thin saffron
#

wdf

#

ok

gloomy hamlet
#

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

green mist
# thin saffron Thats not documented <:SkadiDaijoubu:839269199964798997>

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.

thin saffron
#

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 ICANT

#

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

thin saffron
#

is there logical "and" with these scripts?

fringe pier
#

&&

thin saffron
#

I see

#

and can we also have lists/arrays or are those way beyond the scope of what we have lol

fringe pier
#

I believe there's some machinery for arrays, but it's pretty limited and brittle.

thin saffron
#

rip

fringe pier
#

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.

thin saffron
#

I see

#

I will keep that in mind

gloomy hamlet
#

I tried doing a switch statement once and even that didn't work

thin saffron
#

wtf

fringe pier
#

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.

thin saffron
#

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?

fringe pier
#

(I'll defer to Fayande and co. for that, because I don't work with the battle functions enough to know specifics.)

thin saffron
#

very well

fringe pier
#

Lol, sorry, I bring more general programming knowledge.

thin saffron
#

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 AdinMad_PartingGift

fringe pier
#

Not many other Python users around here, but fortunately I can translate, there ๐Ÿ˜„

thin saffron
#

man I need to make a check to see which of my few values is the largest AdinMad_PartingGift

#

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

gloomy hamlet
#

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

thin saffron
#

Is there any easy way for me to check the max from a group of variables...

gloomy hamlet
#

what do you mean

thin saffron
#

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

gloomy hamlet
#

you could script some kind of ailment priority thing if you really wanted to

thin saffron
#

I see

#

ok then

#

I mean I can check if its lower than 2 at the time and such

gloomy hamlet
#

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

thin saffron
#

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

gloomy hamlet
#

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

thin saffron
#

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

gloomy hamlet
#

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

thin saffron
#

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

green mist
# gloomy hamlet I tried doing a switch statement once and even that didn't work

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.

gloomy hamlet
#

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

open lance
thin saffron
#

ok LaiaHeart

thin saffron
#

Omg is that a

#

Smart check for Weaknesses and effects?

#

OK I get what its trying to do

#

Mine is more complicated DestinaDerp_Fruity

#

Lol

#

However I will take that enum code MaximaAwoo

#

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?

open lance
#

Um, no. That's not how enums work. You can make an Act function that accepts damage type as a parameter, for Act(phys)

thin saffron
#

Maun

thin saffron
#

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

gloomy hamlet
#

I'm a bit confused as to what you're asking

fringe pier
thin saffron
#

Yes

#

I just want to make the dialogue box appear with text as you would see in other boss battles

thin saffron
#

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

gloomy hamlet
#

is that all you have?

#

what is being skipped

thin saffron
#

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

gloomy hamlet
#

I'm confused

#

what's being skipped then

thin saffron
#

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

gloomy hamlet
#

well whatever is in the first one isn't going to get triggered unless the enemy is at or below 20% health

thin saffron
#

I got it to like 10% and it kept doing the skill loop shrugs

#

and I gave it 1 mores

#

nothing

gloomy hamlet
#

what's in the 20% thing?

thin saffron
gloomy hamlet
#

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

thin saffron
#

thats pretty much the entire script without the one enumeration

#

either my compiler cuts it out or I've done something wrong?

gloomy hamlet
#

idk, I don't really see anything wrong with it

thin saffron
gloomy hamlet
#

you're absolutely sure you saved and compiled that into the bf that the game is loading?

thin saffron
#

Yes

gloomy hamlet
#

if it's not that or some weird compiler error, then idk

thin saffron
#

Ann was knocked down by diamonds dust but still used maziodyne, the next skill in the 11 counter

gloomy hamlet
#

try re-decompiling the bf in the game files and see if it matches what's in your original flow

thin saffron
#

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 SkadiDaijoubu

thin saffron
#

ok I fixed the script by making it messy?

#

its skipping the ifs because they dont have an else attatched to them???

#

I will have to try again some other way

#

I hope I dont need to add an else for every if SkadiDaijoubu

thin saffron
#

wait yeah I think it is

#

wow ok this changes things

thin saffron
#

yeah...

#

wow that sucks SkadiDaijoubu

fringe pier
#

...Damn, really? That seems like a major oversight in the flowscript compiler....

gloomy hamlet
#

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

thin saffron
#

idk then SkadiDaijoubu

#

Can you guys try and compile the original?

thin saffron
#

Before I go down the rabbit hole of trying to put this in the right place for imports to work

thin saffron
#

oh god can I not use string variables??

fringe pier
#

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 ๐Ÿ˜…

thin saffron
#

yeah I changed it

#

i did however run into this

#

There is another where it just refuses to recognise an else

fringe pier
#

You're missing an open brace after line 178.

thin saffron
#

I just saw that

#

:ICANTR

#

lmao

#

ok it compiled steve_thumbsup