Friday, April 13, 2012

[FA] Need help with a pesky unit upgrade.

[:1]So, i'm working on a costum unit for FA. Pretty unique, T3 unit (should almost call it T3.5 heh) it's a pretty cheap and useless unit at first, then you upgrade it with either 2 utility upgrades, 2 base upgrades, and 2 offensive upgrades. Did most of them already. Aynway, i'd need help with 2 upgrades. One would be a classic weapon swap but this, for some reason, isn't working properly even though i followed the tutorial. The other upgrade i'd need help with is an upgrade that makes the unit's MaxSpeed higher (to whatever value i set it).
bp: http://pastebin.com/1xpvPMRH
script: http://pastebin.com/28BTXr1U
Anyone who can make my unit work gets a free cookie and a glass of milk (optional)|||Blueprint problems:
- The real weapons need PrefersPrimaryWeaponTarget = true
- The dummy weapon needs a damage value (as far as I'm aware)
- You shouldn't be firing 5 projectiles at once from the same muzzle (use salvos if you really feel it needs that many projectiles)
- The laser should not be RULEUBA_LowArc (use RULEUBA_None)
- All three weapons need Seabed in the source and destination of their FireTargetLayerCapsTable. All three will need AboveWaterTargetsOnly = true as well. This lets them fire to and from the shoreline, and at targets emerging from the water - otherwise their weapons will all be disabled when they approach the shoreline.
- Beam delay values should be multiples of 0.1, also remembering that BeamCollisionDelay has 0.1 added to it by the engine. This means BeamLifeTime needs to be at least BeamCollisionDelay + 0.1.
Script problems:
- CreateEnhancement should not be having to call RemoveUnitEnhancement on anything so long as you're using the blueprint RemoveEnhancements tables properly (which you appear to be doing)
- Your weapon switch enhancement isn't syncing up the two weapons' aim manipulators upon switchover, although that's non-critical (it should just result in a snap-back of the turret)

That said, I'm not sure why the weapon switch wouldn't work at all, assuming you've confirmed that the laser works when enabled alone in OnCreate. Without knowing specifically what problem you're having, I can't really give any more specific help.
For speed increases, use self:SetSpeedMult(mult) in CreateEnhancement. Set that to 1 to return the unit to default speed. You may also want to call SetTurnMult and SetAccMult with the same values, if you want to increase turn and acceleration rates accordingly.|||Alright, did everything you said (the weapons part anyway, will do the speed thing later.), except the multiple projectiles out of 1 muzzle, thats kind of a workaround because there wasnt a big enough gauss projectile so i made it fire 6 (hence the damage 500/5) so the resulting projectile looks bigger.
Anyway, now the error log thing reports this error in the script:
WARNING: ...supreme destruction\units\reu1337\reu1337_script.lua(15): access to nonexistent global variable "WeaponFile"
WARNING: stack traceback:
WARNING: [C]: in function `error'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\config.lua(53): in function <...alliance\gamedata\mohodata.scd\lua\system\config.lua:52>
WARNING: ...supreme destruction\units\reu1337\reu1337_script.lua(15): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: in function `pcall'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(48): in function `import'
WARNING: Error importing /mods/supreme destruction/units/reu1337/reu1337_script.lua:
Error importing '/mods/supreme destruction/units/reu1337/reu1337_script.lua'
stack traceback:
[C]: in function `error'
...alliance\gamedata\mohodata.scd\lua\system\import.lua(52): in function `import'
INFO: Problems loading module '/mods/supreme destruction/units/reu1337/reu1337_script.lua'. Falling back to 'Unit' in '/lua/sim/unit.lua'.

Odd. :?
Oh btw, neither weapon fires before or after the upgrade.
new bp: http://pastebin.com/DxPXkhkq
new script: http://pastebin.com/JPduaBds|||That's because your script is failing due to a typo. I'm surprised the unit works at all. Your barebones weapon class is looking in 'WeaponFile', which doesn't exist - you only defined 'WeaponsFile'.
Edit: You're also referring to 'WeaponsFile' before it's even defined. You can't do that.|||And... umm... how would i fix that? Sorry but my knowlege of these scripts is pretty much 0... i only copied some stuff from other units' scripts and tweaked them just a bit.|||Did some random stuff and copy pasting, and now the unit is firing the upgrade weapon... i just can't seem to get this working, and i've been trying for like 2 hours... D:|||Well, you might want to learn some really basic programming concepts before doing things like combining scripts, or you'll be running into a lot of problems. Scripting is a lot more complex than blueprint editing, and there's a lot more that can go catastrophically wrong. 'Random stuff' is usually not going to solve any problems, and if you don't know why you're doing what you're doing, there's about a 99% chance it'll just make things worse.
Again, you need to at least list the exact problem you're having, and post an updated version of the script/bp - you just said the unit is firing the upgrade weapon, but that 'this isn't working' - we have no way of knowing what 'this' is, or in what way it isn't working.
I'm not trying to be harsh. It's just really, really difficult to troubleshoot someone else's work even when they show everything and describe the problems they're having in detail. Without any of that, there's no way for us to know what's wrong.|||Edit:

Got everything on the unit working (apart from the textures haha) only one more thing is wrong. The unit won't switch from the Autocannon upgrade to the Laser Gun upgrade, for some reason.
bp: http://pastebin.com/6vQsH64Q
script: http://pastebin.com/m3mi9Ppu|||You mean the laser upgrade doesn't work at all, or only when you already have the main gun upgrade installed?
You're still doing an extraneous RemoveUnitEnhancement in a bunch of the removal enhancements - at the very least, you do not need that, and it may even cause problems depending on the order in which things run. If your enhancements aren't being removed without that, then you're doing something else wrong that I'm just not seeing right now.|||Both upgrades work, i'm just saying that i can't switch from the autocannon upgrade to the laser upgrade.|||Oh. Your MainGun remove has the slot set to 'Back', rather than 'LCH'. It probably isn't being found by the UI code.

No comments:

Post a Comment