Tuesday, April 17, 2012

[FA] Limit ammo on each unit can carry. Is it posible?

As far as I know, we only can limit the on-air time of an airplane, but now I want to limit the ammunition of an unit. In addition to, you have to purchase mass to reload at the factories.
In sum, is it posible? How can I do that?
Thanks for all replies|||I tried once. It was very hacky and didn't work because the Attack Manager code in the engine crashed when you tried to access it (which you need to do to tell things to stop trying to attack).
I think it'd work better in Sup2, assuming that the bug has been fixed.|||Possible, but like bullet says, it would never work quite right- units wouldn't know when or how to reload, and would not know to stop attacking. It would also probably be quite a bit of work, as you'd have to re-write the majority of the weapon.lua and defaultweapons.lua code.|||It's possible to give each unit in play a "silo" and have them build ammo to fill this silo. (Just like what is done with TML's)
However we get into the sticky situation where some units that have more then one weapon will each draw from the same silo. (basicly using the same ammo)
Worse yet, weapons that fire multible shots per salvo can draw the silo counter negative! This is due to the way the weapon handler checks if ammo is avalible before allowing a weapon to fire. If just "1" round is avalible the weapon will be allowed to fire even if there are 10 shots to a salvo. Such a salvo will draw the silo to a count of -9..... :evil:
As for the overall game it could be possible to give each unit a fixed number of shots via Blueprint.lua as the units inital load... Then later create functions that fork off to add the silos, ammo and build costs to each unit. After that it's just a question of altering Unit.lua / Weapon.lua to handle the mechanics of each units silo.
Resin_Smoker|||I think this is partly possible.. maybe a problem with getting the ammo back once depleted..
i just looked at defaultwepaons.lua..
you could make a new weapon class just for this weapon, in this new class your going to override some DefaultProjectileWeapon functions to check the ammo amount, this would be easier than trying to hook DefaultProjectileWeapon its self..
just make a new wep class and add what is needed..
in the unit blueprint specify the intitial ammo amount
on stopbeing built set this ammo amount to a unit var. self.WepA.Amount = 6 or w/e
in the units script call defaultweapons(myNewWeaponClass) which will contain the check to see if our self.unit.WepA.Amount > w/e if it isnt .. self.unit:SetFireState(0)
which will disable all weapons and release the unit from any attack orders.. OR just disable the weapon itsself.. if it has other weapons that can attack.. you will have to have some code in the units script to tell it when and where to go get some more ammo.. not entirely sure how this could implimented.. however this would be called if the ammo amount == 0 or w/e
for the "re-arming" from a factory? hmmm.. you would have to use aibrain to get a filtered list of unit "factory" get its distance and or position.. issue a move order to the unit and move it to an offset of any factories found.. prolly closest..
then create another function.. which triggers when the unit is within a certain range of the fac.. if it is and the fac is idle.. create a beam to a build arm of the factory
(custom effects) and start a timer or w/e to begin re-arming, increasing self.WepA.Amount at an interval (re-arming)
there are other little things that will need to be done but this is mostly the gist of it.. how i would go about doing such a thing :)|||It sound complicated. I'm a newbie and it's too difficult for me

No comments:

Post a Comment