Scripted weapon-pickup issue [solved]

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
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Scripted weapon-pickup issue [solved]

Post by Eggman »

I've scripted an event where the player enters a region and, upon re-spawning, has access to a new weapon (same basic concept as in Maveritchell's Spira: Besaid). It works near-flawlessly, with one exception: the player can't switch secondary weapons.

I find it strange that this is the problem, as the new weapon takes the place of a primary weapon slot. I would have expected any interference to happen in the primary weapon channel, not the secondary weapon channel.

Here's the script:

Code: Select all

launcher_pickup = OnEnterRegion(
   function(region, player)
			KillObject("launcher")
			DeactivateRegion("launcher_pickup")
			SetClassProperty("rep_inf_trooper_story2", "WeaponName3", "rep_weap_inf_rocket_launcher")
			SetClassProperty("rep_inf_trooper_story2", "WeaponAmmo3", 7)
   end,
"launcher_pickup"
)
And the unit's .odf:

Code: Select all

[GameObjectClass]
ClassParent         = "rep_inf_default"

[Properties]

MaxHealth           	= 1400.0

WEAPONSECTION = 1
WeaponName1         = "rep_weap_inf_carbine"
WeaponAmmo1         = 2

WEAPONSECTION = 2
WeaponName2         = "rep_weap_inf_pistol"
WeaponAmmo2         = 0

WEAPONSECTION 	= 3
WeaponName3         	= "rep_weap_inf_pistol"
WeaponAmmo3         	= 0

WEAPONSECTION = 4
WeaponName4         = "rep_weap_inf_thermaldetonator"
WeaponAmmo4         = 1
WeaponChannel4      = 1

WEAPONSECTION 	= 5
WeaponName5         	= "rep_weap_inf_bacta"
WeaponAmmo5         	= 1
WeaponChannel5      	= 1

VOUnitType        	= 121
I read somewhere that the order in which the weapons are set up in the .odf affects scripted weapon-changes, so I think my problem lies in how I set that up, but I'm not quite sure what I need to change.
Last edited by Eggman on Sun Jul 05, 2009 10:05 am, edited 1 time in total.
MetalcoreRancor
Brigadier General
Brigadier General
Posts: 628
Joined: Thu Jun 07, 2007 11:13 am
Projects :: No Mod project currently.
Games I'm Playing :: swbf origin
xbox live or psn: No gamertag set

Re: Scripted weapon-pickup issue

Post by MetalcoreRancor »

Replace the 2nd pistol with com_weap_null or something else.
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Scripted weapon-pickup issue

Post by Eggman »

Replacing the second pistol with a different weapon didn't change anything. I'll try changing the order and see if that yields any results.

Edit: switching the .odf to this:

Code: Select all

[GameObjectClass]
ClassParent         = "rep_inf_default"

[Properties]

MaxHealth           	= 1400.0

WEAPONSECTION = 1
WeaponName1         = "rep_weap_inf_carbine"
WeaponAmmo1         = 2

WEAPONSECTION = 2
WeaponName2         = "rep_weap_inf_pistol"
WeaponAmmo2         = 0

WEAPONSECTION 	= 3
WeaponName3         	= "rep_weap_inf_bacta"
WeaponAmmo3         	= 1
WeaponChannel3      	= 1

WEAPONSECTION = 4
WeaponName4         = "rep_weap_inf_thermaldetonator"
WeaponAmmo4         = 1
WeaponChannel4      = 1

WEAPONSECTION 	= 5
WeaponName5        	= "rep_weap_inf_pistol_dummy"
WeaponAmmo5         	= 0

VOUnitType        	= 121
Allows the player to access both secondary weapons, but not "rep_weap_inf_pistol_dummy" (which switches for "rep_weap_inf_rocket_launcher").

Edit2: So it seems like the problem is that the player can't access the fifth weaponsection, no matter what it is.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Scripted weapon-pickup issue

Post by Maveritchell »

WeaponName# only goes up to 4. You can add more weapons, but you shouldn't use the number immediately after weaponname.
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Scripted weapon-pickup issue

Post by Eggman »

Maveritchell wrote:WeaponName# only goes up to 4. You can add more weapons, but you shouldn't use the number immediately after weaponname.
Alright, that should make the problem easy enough to fix. Thanks.

Edit: Works like a charm.

New .odf for anyone who's curious:

Code: Select all

[GameObjectClass]
ClassParent         = "rep_inf_default"

[Properties]

MaxHealth           	= 1400.0

WEAPONSECTION = 1
WeaponName1         = "rep_weap_inf_carbine"
WeaponAmmo1         = 2

WEAPONSECTION = 2
WeaponName2         = "rep_weap_inf_pistol"
WeaponAmmo2         = 0

WEAPONSECTION 	= 3
WeaponName3        	= "rep_weap_inf_pistol_dummy"
WeaponAmmo3         	= 0

WEAPONSECTION = 4
WeaponName4         = "rep_weap_inf_thermaldetonator"
WeaponAmmo4         = 1
WeaponChannel4      = 1

WEAPONSECTION 	= 5
WeaponName         	= "rep_weap_inf_bacta"
WeaponAmmo         	= 1
WeaponChannel      	= 1

VOUnitType        	= 121
Post Reply