Scripting questions

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Scripting questions

Post by fiddler_on_the_roof »

1-How is the filter "config" used?
--what do you enter to get a match for it.

2-Is it possible to make an objective sequence just for one team, so that if you were on the other team, it would skip those objectives?

would it just be If GetObjectTeam(human) == 1 then return end ?

3-for the getobjectteam and stuff, can i use human? (^^)


thanks
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Scripting questions

Post by Frisbeetarian »

1) From the Battlefront2_scripting_system.doc in the documentation
This property is the config (ODF) name of the Object.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Scripting questions

Post by Fiodis »

If you want, say, Conquest objectives for one team and a specialized set for the other, you could do that. I'd have to think about it more, and my brain is not quite in the mood for thinking right now, but I'm not sure you'd even need to check the player's team.

Oh wait...I think you might. Yeah. Like I said, I'm not in thinking mode right now.
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting questions

Post by fiddler_on_the_roof »

Fiodis wrote:If you want, say, Conquest objectives for one team and a specialized set for the other, you could do that. I'd have to think about it more, and my brain is not quite in the mood for thinking right now, but I'm not sure you'd even need to check the player's team.

Oh wait...I think you might. Yeah. Like I said, I'm not in thinking mode right now.
ok, thanks
Frisbeetarian wrote:1) From the Battlefront2_scripting_system.doc in the documentation
This property is the config (ODF) name of the Object.
ok, so i would just type(for example)

Code: Select all

OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
What about question 3?
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Scripting questions

Post by Fiodis »

fiddler_on_the_roof wrote:ok, so i would just type(for example)

Code: Select all

OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
No.

You would type something like:

Code: Select all

OnFlagPickUp(
function(flag, character)
characterodf = GetObjectClass(character)
if characterodf == "rep_inf_ep3_sniper" then
*type code here*
end
)
Also, "human" isn't a recognized team. To check if a player is human and not AI, use

Code: Select all

IsCharacterHuman(variable_of_character)
EDIT - Nice, 1,700th post. Sith Lord rank! :D
Last edited by Fiodis on Mon Aug 10, 2009 2:56 pm, edited 2 times in total.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Scripting questions

Post by [RDH]Zerted »

2) Yes. There are tons of ways to do it.
3) Your question makes no sense. What is human?
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Scripting questions

Post by Frisbeetarian »

Fiodis wrote:
fiddler_on_the_roof wrote:ok, so i would just type(for example)

Code: Select all

OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
No.

You would type something like:

Code: Select all

OnFlagPickUp(
function(flag, character)
characterodf = GetObjectClass(character)
if characterodf == "rep_inf_ep3_sniper" then
*type code here*
end
)
Don't knock what he had, he had the right idea, he just forgot the comma, the quotes, and the "end," and he also called the filter the wrong name. Yours works too, his way is just better. And you forgot an extra "end" for your if statement.

@fiddler_on_the_roof
The filter name is "Class" not config. When the document says "Class: config" it means Class is the filter name and the argument used is the config. You would also put quotes around the config as it is a string. Of course, you also need a comma after the function (which needs an "end" as Fiodis pointed out). It would read something like this:

Code: Select all

OnFlagPickUpClass(
function(flag, character)
*type code here*
end,
"odf_file_name"
)
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Scripting questions

Post by Fiodis »

I'm not sure what you mean by knocking on his code.

What I typed up was a rough outline, so of course it wouldn't be complete. You could do what Frisbeetarian suggested, but you would still need to include an ODF check for the character variable:

Code: Select all

if GetObjectClass(character) == "rep_inf_ep3_sniper" then
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Scripting questions

Post by Frisbeetarian »

No you don't that's the point of filters. You might want to go read up on the scripting document yourself. The whole idea of having the filter is so that the game only uses the code for those specific configs.

Rightly named, the filter filters out unnecessary units so that the game does less work.
I'm not sure what you mean by knocking on his code.
I was just saying that instead of fixing his code, you gave him a totally different way around it. A less efficient way at that.
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting questions

Post by fiddler_on_the_roof »

ok, thanks.

i have 2 more questions.

1--how are the "ends" and the parentheses used to end stuff? I mean when do you put them in and how many.

2--is it possible to add a certain amount of points it takes to unlock a unit each time something happens, but so that you only need one bit of code?

Code: Select all

example:
SetClassProperty("rep_inf_ep3_rifleman", "PointsToUnlock", [b]+12[/b])
(for every time something happens, it adds 12 more points till you unlock a unit instead of writing out each time the new unlock limit)

thanks
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Scripting questions

Post by [RDH]Zerted »

The end ends the function parameter. OnFlagPickUpClass is a function which takes another function and a string as parameters/arguments. The comma after the end separates the two parameters. It is easier to tell where you need ends if you indent each new block/scope level.

I don't think there is any way to get the current unlock point for a unit class, but you could use a variable:

Code: Select all

unlockPoints = 5
OnSomethingHappens...(function(thing,some)
    unlockPoints = unlockPoints + 12
    SetClassProperty("rep_inf_ep3_rifleman", "PointsToUnlock", unlockPoints)
end)
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting questions

Post by fiddler_on_the_roof »

ok, thanks

so if you just put each new function, or If on a new indent, each one needs an end? What about the )?
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Scripting questions

Post by Frisbeetarian »

For every "(" you need a ")".
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting questions

Post by fiddler_on_the_roof »

ok, thanks

so if I had

Code: Select all

                  OnSomething(function(some, thing)
                           --i would need to end it like this
                 )
        end
and if i had

Code: Select all

           OnSomething(function(some, thing)
                    
                     Ifsomething  == something then return end
                     --it would end like this?

                 )
           end
    end
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Scripting questions

Post by [RDH]Zerted »

"so if I had..." you would be wrong. You basically took the code I gave you and made it wrong. This is basic programming stuff. Just like every sentence ends with a period (or colon or question mark, etc...) so must every opening keyword or character: (, {, [, or function end with its corresponding character or keyword: ), }, ], or end. The openings and closing levels cannot be mixed. Meaning that when you 'open' something, everything inside it must be closed before the original thing is closed. In your code exmaples, you put the closing ) before the function's end. Since the starting/opening ( is before the function, it must be closed after the function. Thus the ) must come after the end.

Look at the colors
OnEnterRegionName(function(player)
ShowMessageText("Hello")
end, "startRegion")
or written in a different way (but does the exact same thing)
local sayHello = function(player)
ShowMessageText("Hello")
end

OnEnterRegionName( sayHello, "startRegion" )
An if statement:
if something == something2 then return end
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting questions

Post by fiddler_on_the_roof »

ok, thanks.

two more questions.

for objectives, you can have the "ObjectiveGoTo", how would you make a new one, like
"ObjectiveNew"?

what about rules?(similar as before, how to make a new set)
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Scripting questions

Post by [RDH]Zerted »

Look through the game's campaign script. There are a few campaign missions where you have to go to a certain location. See how they create their Goto objectives.

What do you mean by 'rules'?
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Scripting questions

Post by fiddler_on_the_roof »

[RDH]Zerted wrote:Look through the game's campaign script. There are a few campaign missions where you have to go to a certain location. See how they create their Goto objectives.
What do you mean by 'rules'?
blue, ok.

red-nevermind, i read something wrong.

thanks
Post Reply