All bowcasters, no pistols

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:

All bowcasters, no pistols

Post by [RDH]Zerted »

If I change in the lua, all of the units' weapons to pistols, the game crashes. If I use bowcasters instead, it runs smooth. Any ideas on why whenever I give even a single pistol to an unlockable unit the game crashes, but everything is fine if I give them bowcasters instead?
-_-
Gametoast Staff
Gametoast Staff
Posts: 2678
Joined: Sat May 07, 2005 1:22 pm

Post by -_- »

Okay, first, slow down. Post more details of what you did, and we can help ya.
User avatar
Epena
Old School Staff
Posts: 1176
Joined: Fri Oct 21, 2005 2:33 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Epena »

And don't forget to tell us exactly what odf you're using for the pistols. :)
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:

Post by [RDH]Zerted »

I don't think its solvable without developer support, I was more pointing it out because I though it was really wierd and I don't have a clue why it happens, but here is what I did:

I'm working on letting players change their weapon and loadouts ingame. For example, if you killed an enemy, the enemy may drop its weapon instead of the normal health/ammo/awards. This can't be done in an odf, it has to be in the lua. SetClassProperty() (read the scripting documentation) can be used to change a property in classes (haven't got it working on weapon classes yet, but it works on unit classes). As an example, SetClassProperty( "all_inf_sniper", "EnergyBar", 240 ) would double the sniper's energy which is normally at 120. You can expand this and change any value of a unit's class based on some ingame condition.

The level I'm working on starts everyone as some low level basic unit. For this to happen correctly all the units need to have the same loadout (weapons, speed, armor, skin, etc...). Everything was working fine until I tried to change the weapons. I attempt fill up all the unit's weapon slots with all_weap_inf_pistol. This worked fine with one, then two units so I expanded it to all units. The map now crashed when you spawned. Through much further testing, I discovered if you give any of the unlockable units a pistol, the game crashes on your first spawn or shortly after (I haven't tested out the other weapons except pistol and bowcaster). I got a crash log, and nothing important showed up. I discovered if I change the pistol to a all_weap_inf_bowcaster, the game stopped crashing. I'm wondering if any one could think of a reason of why the game crashes when say a wookiee has a pistol.

Here is the important part of the lua code that changes the weapons. You can see I'm just using normal units. SetupTeams is normal too. The unitRemake and two For loops are the important parts. If you swap which weapon is commented out, the game will go from crashing to not crashing or from not crashing to crashing.
ReadDataFile("sound\\tat.lvl;tat2gcw")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman",
"all_inf_rocketeer",
"all_inf_sniper",
"all_inf_engineer",
"all_inf_officer",
"all_inf_wookiee",
"all_hero_hansolo_tat")

ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_bobafett",
"imp_fly_destroyer_dome" )

ReadDataFile("SIDE\\tur.lvl", "tur_bldg_tat_barge", "tur_bldg_laser")

unitRemake = { "all_inf_rifleman", "all_inf_rocketeer", "all_inf_engineer", "all_inf_sniper", "all_inf_wookiee", "all_inf_officer" }

for number = 1,6 do --for each of the units in unitRemake
for slot = 1,4 do --for the first 4 weapons of each unit
--set the weapon
--SetClassProperty( unitRemake[number], "WeaponName" .. slot, "all_weap_inf_pistol" ) --this will cause the game to crash
SetClassProperty( unitRemake[number], "WeaponName" .. slot, "all_weap_inf_bowcaster" ) --this works fine
--set the weapon's ammo
SetClassProperty( unitRemake[number], "WeaponAmmo" .. slot, 0 )
end
end
Erathoniel

Post by Erathoniel »

I'll admit, I tried this too, and I failed. What I do is I just make an ultra-long range ammo droid and use that. Works like a charm, and you never run out of ammo, or grenades (or detpacks and buffs). If you don't mind doing that, you can also have some great battles. I can hold for about fifteen minutes behind a kashyyyk barrier with just a rifle and grenades. Great for long hero assaults.
Post Reply