Oni Central Forum

A forum for the Oni community

You are not logged in.

#1 06/01/09 15:06

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

Scripting Help

Okay, this is gonna be my thread for getting help for my scripting. I just started yesterday, but it isnt hard so far, and ive gotten some done, so things i ask shouldnt be hard to answer smile

First Problem: How do i spawn AI from different maps? I can get them from the map I'm making the script on, but otherwise.. i cant. There's probly a simple solution to this roll


"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

#2 06/01/09 16:06

Dr.Karluzz
Member
From: Milan, Italy
Registered: 05/22/09

Re: Scripting Help

i have same problem, probably beacuse we can spawn AI only if them are naturally in this level. for example we can't spawn Muro in first mission or i don't know how to do it smile

Last edited by Dr.Karluzz (06/01/09 16:06)


Press here >>http://www.myPlugoo.com/5PFFKSWC00BKE0D<< for chat with me

Offline

#3 06/01/09 16:06

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

Re: Scripting Help

my idea would be transfer some of the model animations and files and such from IGDM in their respective lvls, to the EnvWarehouse level, so he can b accessed, but i dunno sad


"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

#4 06/01/09 17:06

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

Re: Scripting Help

This is already done in the AE. Btw, IGMD is only level scripting, no actual data.
What you need to mod is the BINACJBOCharacter of the level. (in AE).

You can use

chr_set_class ai_number class_name

But then you have to keep track of every character spawned. smile

Getting a BINACJBOCHAR it to and from XML is the same as the other tutorial I made. It is pretty self explanitory. I don't have time tonight to write up a tutorial for it. If you need help, probably tomorrow. smile


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

#5 06/01/09 18:06

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

Re: Scripting Help

Here's a little more info.
Convert the file BINACJBOCHAR.oni into XML, then you will see all the characters for that level.  You will need to copy all the information for the character and paste it to the BINACJBOCHAR.oni of the level you want to add the new character.
For example Muro's data from level 19:

<Object Id="8733" Type="CHAR">
            <Header>
                <Flags>0</Flags>
                <Position>-112.0837 1486 -2619.775</Position>
                <Rotation>0 171.3265 0</Rotation>
            </Header>
            <OSD>
                <Flags>NotInitiallySpawned Boss NoAutoDrop</Flags>
                <Class>muro_generic</Class>
                <Name>Muro</Name>
                <Weapon />
                <Scripts>
                    <Spawn />
                    <Die>check_death2</Die>
                    <Combat />
                    <Alarm />
                    <Hurt />
                    <Defeated />
                    <OutOfAmmo />
                    <NoPath />
                </Scripts>
                <AdditionalHealth>0</AdditionalHealth>
                <Job>
                    <Type />
                    <PatrolPathId>0</PatrolPathId>
                </Job>
                <Behaviors>
                    <CombatId>0</CombatId>
                    <MeleeId>30</MeleeId>
                    <NeutralId>0</NeutralId>
                </Behaviors>
                <Inventory>
                    <Ammo>
                        <Use>1</Use>
                        <Drop>0</Drop>
                    </Ammo>
                    <EnergyCell>
                        <Use>1</Use>
                        <Drop>0</Drop>
                    </EnergyCell>
                    <Hypo>
                        <Use>0</Use>
                        <Drop>0</Drop>
                    </Hypo>
                    <Shield>
                        <Use>0</Use>
                        <Drop>0</Drop>
                    </Shield>
                    <Invisibility>
                        <Use>0</Use>
                        <Drop>0</Drop>
                    </Invisibility>
                </Inventory>
                <Team>Syndicate</Team>
                <InitialAmmo>100</InitialAmmo>
                <Alert>
                    <Initial>Low</Initial>
                    <Minimal>Low</Minimal>
                    <JobStarting>Low</JobStarting>
                    <Investigating>Low</Investigating>
                </Alert>
                <AlarmGroups>0</AlarmGroups>
                <Pursuit>
                    <Strong>4</Strong>
                    <Weak>1</Weak>
                    <StrongSeen>4</StrongSeen>
                    <WeakSeen>4</WeakSeen>
                    <Lost>0</Lost>
                </Pursuit>
            </OSD>
        </Object>

Offline

#6 06/02/09 14:06

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

Re: Scripting Help

okay, i see what u mean smile

lol, i was poking around the folder and man.... there are some stuff i could really mess around with >:)
teams, ammo, drops etc... i wouldnt even have to rewrite anything, just change a few things


"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

#7 06/03/09 14:06

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

Re: Scripting Help

kay, next question...

fork logic, i need some explaining on this, its not completely clea in the tut.

I have sumthin like

func main (void)
{
chr_teleport 0 7010
chr_giveweapon 0 w8_mbo
sleep 300

ai2_spawn Top_Striker1 7009
chr_wait_health Top_Striker1 0
sleep 300

ai2_spawn secret2 7009
chr_wait_health secret2 0
etc. etc. etc....
fork logic
}

func logic
{etc. etc. etc.
fork logic2
}

func logic2
{........
}

now, is forking logic like this just to spilt different events up to make things easier to manage in while scripting?
like, could it all be written in one big list?


"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 06/03/09 17:06

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

Re: Scripting Help

In that case (forking at the end), yes.


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

#9 06/03/09 17:06

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

Re: Scripting Help

In that case (forking at the end), yes.


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

#10 06/03/09 18:06

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Scripting Help

But "fork" was created for multithreading tasks, so in that sample code you might as well use just the function name without fork in front.  Normally you'd use "fork" to split off new tasks and get them running while the rest of the original function continues to execute.


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#11 06/03/09 20:06

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

Re: Scripting Help

ahh, i think i see what you mean... what ive discovered, is if one line in the coding is incorrect, the rest after wont run. Which means that theyre played in order of appearence, but if i forked logic n the middle of a script, it would run new the logic and the rest of the lines after the fork at the same time yes?

Last edited by Mukade (06/03/09 20:06)


"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 06/03/09 20:06

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

Re: Scripting Help

okay here's sumthing that requires a little more then a simple answer:

in my script, i have a tctf female cop fighting two bots (identicle to karen v. the two bots at the training)  Now i wanted to make it so that if she died, then the bots would gain their health and more. But if the bots died, karen turns on me. The problem with this: i forked the logic, but i kill the bots, then karen after she turns, but then it still runs the fork. I figure i need to set conditions. Along the lines of

if (chr_health demo1 >0)
{*run script*
}

also i need an "and/or" statement, because i need to say
if (chr_health demo1 >0)
AND/OR if (chr_health demo2 >0)
{*run script*
}

I'm trying to make as much sense as I can...
If you know what i mean good

If not, just say so, and ill copy my coding that i have and show you what i mean there.

Note: Even easier would be: just tell me if i can change a character to another one, that would solve this problem. I see what u mean by chr_set_class ai_number class_name but what goes where? is it:
chr_set_class (The number in <Object Id="8733" Type="CHAR"> ) (name of the character, or class? ex: Muro or muro_generic)

Last edited by Mukade (06/03/09 22:06)


"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

#13 06/04/09 02:06

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

Re: Scripting Help

Well, for one, you can't detect specific healths like that, you have to do it in a roundabout way...

int droid1_died = 0;
int droid2_died = 0;

func void main(void) {
fork health1
fork health2
#stuff goes here
if( !(droid1_died and droid2_died) ) { 
#! means NOT. So it returns false only if both droids are dead. Otherwise it returns true.
#
#do whatever
}

}


func void health1(void) {
chr_wait_health demo1 0
droid1_died = 1
}


func void health2(void) {
chr_wait_health demo2 0
droid2_died = 2
}

The ai_number is given by the spawn order. You have to keep very close track of who is alive and such. Konoko gets 0, the next AI spawned gets 1, the next 2, and so on.
muro_generic is indeed correct.


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

#14 06/04/09 06:06

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Scripting Help

I think you mean for the last line of code there to say "droid2_died = 1".


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#15 06/04/09 13:06

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

Re: Scripting Help

oh okay, they both make sense smile

itll be nice to have that tut to track deaths, but it'll take alot less work to just change the character itself, but i may have need of the rest of that in the near future.

I'll test to make sure it works, then i'll see about uploading my script so far so you can check my progress
(keep in mind, i've never scripted before in my life, i just started a week ago wink )

EDIT: ROFL!!! Thats mean!!! I did the character switch, since the female cop is the 4th spawn, i did:
chr_change_class 4 CopFemA2
and changed all the other stuff to work for ai number 4, but as soon as it got to the part where
chr_change_class was supposed to exexute, it gave me: Blam, Oni Crashd D:

EDIT2: Okay.... now when i put the two int statement before func void main (void) it just loads me in the first room with an invisble wall...

Last edited by Mukade (06/04/09 14:06)


"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

#16 06/04/09 17:06

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

Re: Scripting Help

Don't put the int statements inside main. That would make them local variables. (I'm not sure if Oni even supports that).

Remember, the spawning starts with 0, Konoko.


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

#17 06/04/09 18:06

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

Re: Scripting Help

i know tongue

im not putting them inside, im putting them before, the first and second lines of the page, but it blams me sad


"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

#18 06/05/09 14:06

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

Re: Scripting Help

OK, here's what I have:

func void main (void) {
chr_teleport 0 7010
sleep 300
ai2_spawn Top_Striker_1
chr_teleport Top_Striker_1 7009
chr_wait_health Top_Striker_1 0
sleep 300

ai2_spawn secret2
chr_teleport secret2 7009
chr_wait_health secret2 0

sleep 300
fork logic
}

#So basically, two strikers spawn one after the others, no problems there, 

#Here is where it crashes, whereever i put the int statements, it crashes at...
int demo1_died = 0;
int demo2_died = 0;
func logic
{
ai2_spawn demo3
ai2_spawn demo2
ai2_spawn demo1
chr_teleport demo2 7009
chr_teleport demo1 7008
chr_teleport demo3 7007
chr_changeteam demo1 Syndicate
chr_changeteam demo2 Syndicate
chr_set_health demo1 150
chr_set_health demo2 150
sleep 100

fork health1
fork health2
fork karendies
sleep 50
dmsg "[r. Help me!]
chr_wait_health demo1 0
chr_wait_health demo2 0
sleep 100
dmsg "[b. Thanks for helping, if you hadn't shown up, I don't know if I would have][r. survived]"
sleep 100
dmsg "[r. Unfourtunately, it'll be the last thing you ever do...]"
sleep 100
dmsg "[o. *Karen turns on you*]"
chr_changeteam demo3 Syndicate
chr_set_health 250
chr_wait_health demo3 0
sleep 300
fork round2
}
 # for that logic, there were 3 forks, 2 were for bot healths, which may work except int doesnt accept the 
#int demo1_died = 0; or the other one, and func kareendies, which is what happens if you do not help karen
#out and she dies. The problem is whether If i help her, she turns on me, and I kill her, but it still runs func
#karendies which is why i requested a tut on how to do conditons, which is what i'm having trouble with in this
#script
func round2
{
dmsg "[r. That was the][b. EASY][r. part, now it gets harder.]"
sleep 100
dmsg "[o. Here's a hypo for you]"
powerup_spawn hypo 7010
sleep 300
dmsg "[r. Get][b. ready]"
sleep 300
ai2_spawn OutroTCTF01
ai2_spawn OutroTCTF02
ai2_spawn griffin
chr_teleport OutroTCTF01 7007
chr_teleport OutroTCTF02 7008
chr_teleport griffin 7009
dmsg "[r. There!][b.That's the one who killed Karen!]
chr_set_health griffin 200
chr_changeteam griffin Syndicate
chr_changeteam OutroTCTF01 Syndicate
chr_changeteam OutroTCTF02 Syndicate
}
#The stuff above is what happens after karen and the 2 bots die
func karendies
{
if ( !(demo1_died and demo2_died) ) 
chr_wait_health demo3 0
dmsg "[r. Why][b. didn't you....help........me........]"
sleep 100
dmsg "[r. Evil Bot:][b.MUAHAHAHAHAHAHA]"
chr_givehealth demo1 150
chr_givehealth demo2 150
}
#Stuf that happens when karen dies

func health1
{chr_wait_health demo1 0
demo1_died = 1
}
#bot 1 health
func health2
{chr_wait_health demo2 0
demo2_died = 1
}
#bot 2 health

so i dunno... copy/paste this script into your Env and test it out, see if it crashes for you too... if it does, try to fix it. If you fix it, show me how, for future reference and If you do sumthin different from what i've tried, tell me plz smile

thx
It'll probly be easier for you to do it yourself

Other then that, it's a good script so far :3

Last edited by Mukade (06/05/09 14:06)


"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

#19 07/14/09 15:07

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

Re: Scripting Help

Oh, another script that needs attention... neutral


Leus wrote:

Hmm...  I'm doing something wrong.  Here's what I have.  It's not my ultimate goal, I'm just trying to test and get it to work:

func void main(void)
{
chr_teleport 0 9515
ai2_spawn B_SuperNinja
ai2_spawn D_SuperNinja
ai2_spawn E_SuperNinja
ai2_spawn OutroNinja
chr_teleport B_SuperNinja 9500
chr_teleport D_SuperNinja 9541
chr_teleport E_SuperNinja 9507
chr_teleport OutroNinja 9529
chr_set_class 1 generic_male_6
}

So I assumed that 1 meant the character spawned after me; in this case B_SuperNinja.  But they all still look like Mukade.


It might be that another BSL file contains a function of a trigger volume which spawns characters when you stand in that TV.
Make sure there's nobody around. Try  "chr_kill_all_ai" after "chr_teleport 0 9515"
BTW, what level are you modding?

Edit: IIRC, first AAC level has a prespawned character which mess up the spawn order.

Last edited by paradox-01 (07/14/09 15:07)

Offline

#20 07/14/09 15:07

Leus
Member
From: Boone, NC
Registered: 05/28/09
Website

Re: Scripting Help

Rooftops, and I only have this one bsl file in the entire folder so there shouldn't be any other characters in the level before I spawn them in my script, right?


If we don't change the direction we're going, we'll likely end up where we're headed.

Offline

#21 07/14/09 16:07

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

Re: Scripting Help

Looks like there are 3 three prespanwed characters. the kill commands didn't worked for me here. ok try using id 4 up to 7.

func void main(void)
{
ai2_shownames = 1
chr_teleport 0 9515
ai2_spawn B_SuperNinja
ai2_spawn D_SuperNinja
ai2_spawn E_SuperNinja
ai2_spawn OutroNinja
chr_teleport B_SuperNinja 9500
chr_teleport D_SuperNinja 9541
chr_teleport E_SuperNinja 9507
chr_teleport OutroNinja 9529
chr_set_class 4 generic_male_6
chr_set_class 5 generic_male_6
chr_set_class 6 generic_male_6
chr_set_class 7 generic_male_6
}


BINACJBOCharacter says that IntroNinja, A_N1, and A_Sr9 misses the flag "NotInitiallyPresent". If you add this flag to them then ID 1 up to 4 works again.

Last edited by paradox-01 (07/14/09 16:07)

Offline

Board footer

Powered by FluxBB