How To Use ActivateBonus (FAQ)

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
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: How To Use ActivateBonus

Post by [RDH]Zerted »

Took me a while, but I finally figured out how to get those Galactic Conquest bonuses working in mod maps. Ignore the scripting documentation for this, its wrong or outdated. Ignore the other functions with Bonus in them, they seem to have been removed from the game but left in the code.

The function you want to use is:

Code: Select all

ActivateBonus( <team>, "<bonus>" )
where you replace <team> with the number of the team you want to have the bonus and <bonus> with the 'name' of the bonus you want the team to have. Its not very important where you put the ActivateBonus() line in the Lua.

Bonus 'Names':
team_bonus_advanced_blasters
team_bonus_autoturrets
team_bonus_bacta_tanks
team_bonus_combat_shielding
team_bonus_energy_boost
team_bonus_garrison
team_bonus_leader
team_bonus_sabotage
team_bonus_supplies

Here is a code example:

Code: Select all

--give the rebels extra ammo
ActivateBonus( ALL, "team_bonus_supplies" )
Here is another code example:

Code: Select all

--damage the Republic's vehicles
ActivateBonus( CIS, "team_bonus_sabotage" )
Bonus Descriptions:
Advanced Blasters - Increases the damage of all blaster-type weapons
Auto Turrets - Adds defense grid turrets to your CPs
Bacta Tanks - Gives your units a health regen
Combat Shielding - Increases the health of your units
Energy Boost - Gives your units an energy regen
Garrison - Gives you extra reinforcements if your reinforcement count drops too low
Leader - Activates your team's playable hero
Sabotage - Causes enemy vehicles to spawn damaged
Supplies - Increases the amount of ammo and supplies your units can carry

Important Notes:
Each team can only have one bonus at a time. If you try to give a team two bonuses, you will get an error in the error log. However, the second bonus does replace the team's first bonus.

You may be able to clear/remove some bonuses by replacing <bonus> with an invalid bonus 'name'. Example:

Code: Select all

ActivateBonus( IMP, "haha_no_bonus_for_you" )
You will get an error in the error log about an invalid voice over sound. Just ignore it.

All these bonuses work online except team_bonus_autoturrets.

WARNING:
The team_bonus_autoturrets and team_bonus_supplies bonuses may crash others in MP. That is to say, if you use one of those bonuses in a map and that map is played online, everyone who attempts to connect to that server may crash to desktop, even though the admin (if not a dedicated server) will be able to play just fine. The crashes occurs when the bonuses are enabled ingame (like when using the FakeConsole mod). I'm not sure if the crashing still occurs when used in a mod map while the map is being loaded.
User avatar
authraw
1st Lieutenant
1st Lieutenant
Posts: 445
Joined: Mon Jun 26, 2006 3:45 pm

Re: How To Use ActivateBonus

Post by authraw »

Wow, that's great! Correct me if I'm wrong, but these bonuses can be added and removed while the map is playing, correct? So they could be added in the middle of a campaign-style map, right? Or do they have to be used before the map loads?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: How To Use ActivateBonus

Post by Maveritchell »

I'm assuming these have the same effect on any individual unit as SetProperty or SetClassProperty? That is to say giving the Bacta Tanks bonus to a team would override any AddHealth a specific unit had.

@authraw
You can dynamically add and remove these, which means yes, you can do during ScriptPostLoad (the part where your campaign stuff would be written).
User avatar
authraw
1st Lieutenant
1st Lieutenant
Posts: 445
Joined: Mon Jun 26, 2006 3:45 pm

Re: How To Use ActivateBonus

Post by authraw »

Another question: Do we know how to make our own custom bonuses, or is that something that just can't be done?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: How To Use ActivateBonus

Post by Maveritchell »

I don't know that we can necessarily create "bonuses" per se, but you can do whatever you want to whatever unit you want via scripting. If you wanted to, say, give every unit a speed bonus (might not work online; I hear Zerted had some problems with this), you could just use SetClassProperty for each unittype you wanted to have a speed bonus and change their Sprintspeed or whatever.
MandeRek
Sith Master
Sith Master
Posts: 2766
Joined: Tue Oct 02, 2007 10:51 am
Projects :: Battlefront Zer0
Games I'm Playing :: SWTOR
xbox live or psn: No gamertag set
Location: Ghosting around GT
Contact:

Re: How To Use ActivateBonus

Post by MandeRek »

Ok i don't think i get it for a part... This goes let's say just in the ***c_con.lua , and adds a bonus. Does this mean if you add leader bonus to CIS and you play as rep you would be able to come across him ingame? And still this is handy! Nice find :)
ARC_Commander
High General
High General
Posts: 838
Joined: Tue Feb 06, 2007 7:18 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: How To Use ActivateBonus

Post by ARC_Commander »

Hmm... Would these be possible to activate through, say, a weapon?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: How To Use ActivateBonus

Post by Maveritchell »

MandeRek wrote:Ok i don't think i get it for a part... This goes let's say just in the ***c_con.lua , and adds a bonus. Does this mean if you add leader bonus to CIS and you play as rep you would be able to come across him ingame? And still this is handy! Nice find :)
No, you can't use these to make the enemy AI use a hero. Basically, all the hero bonus does is make the hero accessible every time you spawn (or the first time, I can't remember).
ARC_Commander wrote:Hmm... Would these be possible to activate through, say, a weapon?
Yes, using the OnCharacterDispensePowerup or OnCharacterDispenseControllable functions through .lua.
MandeRek
Sith Master
Sith Master
Posts: 2766
Joined: Tue Oct 02, 2007 10:51 am
Projects :: Battlefront Zer0
Games I'm Playing :: SWTOR
xbox live or psn: No gamertag set
Location: Ghosting around GT
Contact:

Re: How To Use ActivateBonus

Post by MandeRek »

Oh ok get it now...Thanks Mav
Caleb1117
2008 Most Original Avatar
Posts: 3096
Joined: Sun Aug 20, 2006 5:55 pm
Projects :: No Mod project currently.
xbox live or psn: No gamertag set
Location: X-Fire: caleb1117 ಠ_ಠ

Re: How To Use ActivateBonus

Post by Caleb1117 »

Confirmation: It seems this bit of data coding is most effective Meat ba... Er Master.

Just tried it with Auto turrets, pure awesome, voice over Announcement and everything.
Adjuntant_Reflex
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 312
Joined: Fri Aug 31, 2007 4:47 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Home... Where else?

Re: How To Use ActivateBonus

Post by Adjuntant_Reflex »

I've always wondered how to add ActivateBonus to a mod map,awesome dude1 :thumbs:
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: How To Use ActivateBonus

Post by [RDH]Zerted »

WARNING:
The team_bonus_autoturrets bonus crashes others in MP. That is to say, if you use the auto-turret bonus in a map and that map is played online, everyone who attempts to connect to that server will crash to desktop, even through the admin (if not a dedicated server) will be able to play just fine.

The other bonuses seem to work fine in MP.
Caleb1117
2008 Most Original Avatar
Posts: 3096
Joined: Sun Aug 20, 2006 5:55 pm
Projects :: No Mod project currently.
xbox live or psn: No gamertag set
Location: X-Fire: caleb1117 ಠ_ಠ

Re: How To Use ActivateBonus

Post by Caleb1117 »

Oooh, thanks for the warning, that was the bonus I was using.

Anyway, does this mean you've added functionality for these into the fake console?
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: How To Use ActivateBonus

Post by [RDH]Zerted »

Yes, they are all in there. I've broken the commands up into sections. You will be able to see which ones crash in MP and which ones are safe to use with other players.

Edit: Sadly, it seems team_bonus_supplies also crashes others when used online.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: How To Use ActivateBonus (FAQ)

Post by Teancum »

Someone asked if you can have more than one bonus at a time, and I accidentally deleted that post (sorry about that).

To answer:
[RDH]Zerted wrote:Important Notes:
Each team can only have one bonus at a time. If you try to give a team two bonuses, you will get an error in the error log. However, the second bonus does replace the team's first bonus.

By the way, I didn't double post... it's that darn forum bug.
Post Reply