Oni Central Forum

A forum for the Oni community

You are not logged in.

#1 09/05/10 02:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

BSL AI scripting help

I started to make my own script.
The level is power (07), I have an initialization script: loadgame forks the first codes in the spawning script, fog, lock doors.
And a spawn script that is the level logic (spawning enemies at a location). The exact location i'm talking about is 1131 900 921 (the bridge below you when standing on the narrow bridge). I don't know where the flags are, or how to make one so i use chr_location to teleport enemies in.

My problem is when I teleport them they don't attack unless I stand 1-2 meters in their perimeter. I use ai2_makeaware and  ai2_attack char_0 or 0 (are both ok?). I know that pathfinding is a hard to do thing now, but can't I increase the range they're aware of me? The game is playable unless you run away from them (they do follow you if you hit and run). Is there a path for ai2_dopath on that bridge?

Offline

#2 09/05/10 04:09

s10k
Member
Registered: 01/14/07
Website

Re: BSL AI scripting help

For finding flags use flag map of zdlo:
http://mods.oni2.net/node/146

Don't know how to find path nodes without looking at original bsl files, but i think you can use ai2_movetoflag as alternative for them to move.

ai2_movetoflag [ai_name:string | script_id:int] flag_id:int [setfacing:string{"setfacing"}] - tells an AI to move to a flag - ai2_movetoflag 0 1091

Offline

#3 09/05/10 08:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

Well it's really confusing, though i did see some. None on that bridge in any case.
If I put him to go to flag 0 for example, will he move to that direction and stop and engage me (attack) when i'm nearby? Or will he jump-suicide? I'm still trying now.

Edit: no, it didn't work. It's just the illusion that he follows you once you get near him.
Please help, I've played some levels scripted in such a way (far places, no flags i think) and the AI noticed you.
And why when I give a dead npc full health, tell it ai2_attack x y, it won't attack me?

Last edited by Tudorge (09/05/10 08:09)

Offline

#4 09/05/10 10:09

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: BSL AI scripting help

The issue of AIs ignoring you when you are a distance away is due to a lack of pathfinding grids at your location.
Currently, there is no way to increase the range awareness or combat range of the AI, believe me, I've tried.

To see the pathfinding grids use this command: ai2_showgrids = 1
To see the combat range use this command: ai2_showcombatranges = 1

Offline

#5 09/05/10 12:09

s10k
Member
Registered: 01/14/07
Website

Re: BSL AI scripting help

And why when I give a dead npc full health, tell it ai2_attack x y, it won't attack me?

That's a limitation of the engine. When someone dies and you set his health > 0 they just turns up and don't do nothing like a non-moving zombie. Don't know if you can fix this with any script command although.

If you want to re-utilize a character, set him to be unkillable and when he reaches 0 healh restore his health, you can look at the example of ota script.

Offline

#6 09/05/10 12:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

Thank you, that worked.

Offline

#7 09/05/10 19:09

Mukade
Member
From: Ottawa, Ontario - Canada
Registered: 05/29/07

Re: BSL AI scripting help

Yeah, once theyre dead, theyre dead... doesn't matter if you necromance em  big_smile


"He looks mean enough to tear my arm off and beat me to death with it. In fact, he looks mean enough to tear his OWN arm off and beat me to death with it."

Offline

#8 09/08/10 14:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

My script won't act as it's supposed to.
:

func void round1(void)
{
    ai2_spawn new_4
    chr_location 2 1124 1140 460
    ai2_attack new_4 0
    chr_wait_health new_4 0
    sleep 60
    fork round2    
}
func void round2(void)
{
    sleep 60
    sound_impulse_play objective_prompt
    dmsg "[g. Round 2]"
    sleep 80
    sound_impulse_play objective_new
    dmsg "[r. FIGHT!]"
    ai2_spawn new_7
    ai2_spawn A2_s_blue13
    chr_location 3 1124 1140 460
    chr_location 4 1124 1140 470
    ai2_attack A2_s_blue13 0
    ai2_attack new_7 0
    chr_wait health A2_s_blue13 0
    chr_wait_health new_7 0
                fork round3
                sleep 60
}
func void round3(void)
{
    sleep 60
    sound_impulse_play objective_prompt
    dmsg "[g. Round 3]"
    sleep 80
    sound_impulse_play objective_new
    dmsg "[r. FIGHT!]"
    ai2_spawn D3_tank65
    chr_location 5 1124 1140 460
    ai2_attack D3_tank65 0
    chr_wait_health D3_tank65 0
    sleep 60
}

On this type i'm going for a while until I finish the problems.
First sub works properly, seconds works too except that when I kill both foes, func round3 won't start even though I call it
in previous func. When I turn dev mode on and fork round3 ingame, it starts but it tells me I put bad parameters in chr_location, when they're the same as for other foes.
Did I mess with the IDs when using chr_location? I know that the only starting chars are char_0 and the blue striker(spawned from game), so the first real enemy starts at #2. Anyway, why didn't the sub round3 not start at all?

Offline

#9 09/08/10 15:09

Mukade
Member
From: Ottawa, Ontario - Canada
Registered: 05/29/07

Re: BSL AI scripting help

Alright, I'm gonna suggest that instead of using chr_location, use chr_teleport, however this will involve you starting to mess with flags, which is probably a good thing to know anyways.

chr_teleport works on the same code as chr_location, however, I don't know EXACTLY what chr_location does, according to you, it teleports, but I think you're right that it messes with the character itself and not just it's location.

The "template" for chr_teleport is:

chr_teleport <chr number> <Flag Number>

For chr_number, you don't have to change anything, you got the idea already, however, for Flag Number, unless you know there's already a flag in the location you want, you'll have to create new ones, here's a crash course how to do it (from memory, so bear with me)

Okay, so go to the level folder you want under GameDataFolder>level<number>_final

You want the file called BINACJBOFlags.oni

Use Onisplit to turn this into XML

Go into oni and use the command: chr_debug_characters = 1
This will open a window, amond the info it shows will be your coordinates, go to the location you want the flag to be at and record those coordinates (in your case, you want 1124 1140 460)
And don't worry too much about all the decimals afterward, just worry mostly about whole numbers (watch for the negative/postive symbol though smile )

Open the BINAFlags XML file, and copy one of the flag entries, (I don't have the window up right now, so I can't tell you what the tag is called that begins a flag and ends it, but hopefully you can figure that out)

Paste the flag at the top or bottom of the document (somewhere you will find it, if you need to play with it later, the middle of the document just makes things difficult) Then change the coordinates of your flag, and the ID number I believe.

Save the XML and use Onisplit to change it back to .oni

Either make a new package, or simply stick it in a random package for testing purposes (keep in mind, if you want to release this, you'll need your own package, so putting in another package should only be temporary)BEAR IN MIND most mods are applied to level0_final, so be sure to stick the BINACJBOFlags.oni in the RIGHT LOCATION, otherwise it won't work!

Run AEI

Change your BSL scripts (for example)

chr_location 3 1124 1140 460

to:

chr_teleport 3 <Flag ID>

Now instead of having to repeat the same coordinates every time, you can just use your new flag. Keep in mind, if you want different locations, you need to create a flag for each. Hopefully, this will help in the present or future. It's a good thing to know, and quite simple once you've done it successfully

If this is a bit messy, try looking on the wiki or on the forum itself, people have explained to me successfully, so I'm sure there are entries elsewhere on how to do it smile

Good luck with your mod!

Last edited by Mukade (09/08/10 15:09)


"He looks mean enough to tear my arm off and beat me to death with it. In fact, he looks mean enough to tear his OWN arm off and beat me to death with it."

Offline

#10 09/08/10 16:09

s10k
Member
Registered: 01/14/07
Website

Re: BSL AI scripting help

ai2_attack new_7 0
    chr_wait health A2_s_blue13 0
    chr_wait_health new_7 0

The error is in the first chr_wait_health you are missing the underscore ( _ ) after 'wait'.

I recommend you to use notepad++ with bsl syntax highlight, its easier to check the errors.

Offline

#11 09/08/10 17:09

Mukade
Member
From: Ottawa, Ontario - Canada
Registered: 05/29/07

Re: BSL AI scripting help

arghh! Can't believe I didn't notice that.... you should still take my advice Tudorage, even if you're not going to use it at least give it a try smile


"He looks mean enough to tear my arm off and beat me to death with it. In fact, he looks mean enough to tear his OWN arm off and beat me to death with it."

Offline

#12 09/09/10 02:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

Me too hmm
Thanks!

chr_debug_characters 1 gives you the expected "got 1 expected ;" message. What do I do?

Last edited by Tudorge (09/09/10 02:09)

Offline

#13 09/09/10 05:09

s10k
Member
Registered: 01/14/07
Website

Re: BSL AI scripting help

Go into oni and use the command: chr_debug_characters = 1

it's a variable.

Last edited by s10k (09/09/10 05:09)

Offline

#14 09/09/10 13:09

Mukade
Member
From: Ottawa, Ontario - Canada
Registered: 05/29/07

Re: BSL AI scripting help

yeah, you gotta put the "=" in there


"He looks mean enough to tear my arm off and beat me to death with it. In fact, he looks mean enough to tear his OWN arm off and beat me to death with it."

Offline

#15 09/10/10 09:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

I have followed both your advice and the wiki tutorial, and it says those flags don't exist. I'm sure I used valid locations and the same flag id in script. And also export/edit/import in level9_final and scripts in power.

Offline

#16 09/10/10 15:09

Mukade
Member
From: Ottawa, Ontario - Canada
Registered: 05/29/07

Re: BSL AI scripting help

I dunno, maybe I missed a step... are you sure you put the BINA back where it was supposed to be? it should be (i think)

Package>oni>level(number)_final>level(number)_final(again), and then in there you put the BINA


"He looks mean enough to tear my arm off and beat me to death with it. In fact, he looks mean enough to tear his OWN arm off and beat me to death with it."

Offline

#17 09/11/10 11:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

I thought that I edited the wrong things. I've checked the wiki, it's good.
I thought the file didn't replace, it actually did because you can see the code there if you open it again in xml. I tried to convert it into .oni in a folder and then in gamdatafolder(lvl9). The script seems to be fine, i mean it should at least execute chr_teleport 0 *. Odd thing.

Offline

#18 09/11/10 14:09

paradox-01
Member
From: Germany
Registered: 01/14/07

Re: BSL AI scripting help

There might be some pre-spawned foes which make player character not "0".
Try "chr_teleport konokos_ai_name your_new_flag".

Offline

#19 09/11/10 14:09

s10k
Member
Registered: 01/14/07
Website

Re: BSL AI scripting help

nop konoko char is always 0. smile

Offline

#20 09/11/10 15:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

The problem is that if you use any character to teleport (VALID) they don't and the game says that the flag does not exist. If you convert BINACJBOFlags.oni back to .xml, you can clearly see at the end my added flags with no errors. I followed the exact instructions, but when I use chr_teleport someone to that flag, it won't work  hmm

Offline

#21 09/11/10 15:09

paradox-01
Member
From: Germany
Registered: 01/14/07

Re: BSL AI scripting help

Hm, you are right, script.
Edit: Note to self: chr_location has a pre-spawn issue, not chr_teleport.

Tudorge, when you convert your oni file from a package to xml it's not a guarantee that AEI had backed it into the level archive. You would need to split the level archive into oni files and then make the one file a xml...
However, if you can't figure out the error you might consider uploading your stuff so someone from the community can help debugging.

Last edited by paradox-01 (09/12/10 05:09)

Offline

#22 09/11/10 15:09

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: BSL AI scripting help

It sounds like your .oni file isn't being installed...


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#23 09/11/10 16:09

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: BSL AI scripting help

Here they are. I used OniSplit with GUI. I didn't edit anything but flag position and id.
Please have a look and see if it's right.
Thanks

Offline

#24 09/11/10 17:09

paradox-01
Member
From: Germany
Registered: 01/14/07

Re: BSL AI scripting help

I converted xml to oni and put it into an existing package:
Oni\Edition\install\packages\23000ShinatamaToo\oni\level9_Final\level9_Final

Then tested ingame the script.
The 7030-7032 flags works fine.
But:
It seems that spawnID for chr_teleport is invalid, except for 0.
I checked the original scripts: they all use the ai_name or 0.

Here's the script with the corrected lines.
ps: And think of the underscores.  smile

Offline

#25 09/11/10 17:09

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: BSL AI scripting help

Yeah, BSL is kind of notorious for using spawnID in some places and names in other places.


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

Board footer

Powered by FluxBB