Page 1 of 1

Scripted weapon-pickup issue [solved]

Posted: Sat Jul 04, 2009 12:53 pm
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.

Re: Scripted weapon-pickup issue

Posted: Sat Jul 04, 2009 2:12 pm
by MetalcoreRancor
Replace the 2nd pistol with com_weap_null or something else.

Re: Scripted weapon-pickup issue

Posted: Sat Jul 04, 2009 2:39 pm
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.

Re: Scripted weapon-pickup issue

Posted: Sun Jul 05, 2009 12:49 am
by Maveritchell
WeaponName# only goes up to 4. You can add more weapons, but you shouldn't use the number immediately after weaponname.

Re: Scripted weapon-pickup issue

Posted: Sun Jul 05, 2009 9:28 am
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