Page 1 of 1
Problems with buildings
Posted: 18 Mar 2012, 23:10
by cam
I want to have buildings that have researchable upgrades. I've been able to do this fine for the most part, but I am having trouble with two of them:
1. I want to be able to build a "turret" in the building (i.e. allow it to fire at enemies). In order to do this, my plan was to give the building a weapon in the unitdef and set
Code: Select all
canAttack = false,
fireState = 0,
noAutoFire = true,
so that the unit could not attack unless I changed the fire state manually (which I would do when the building was upgraded). However, it seems as though noAutoFire = true locks the firestate on "Fire at Will". Is there a way to get around this? Or a better way to do what I want to do?
2. I want the buildings to be able to repair units when a certain upgrade is researched. However, apparently I can't set canRepair = true if I have a yardmap in the unitdef. What gives?
Thanks!
Re: Problems with buildings
Posted: 18 Mar 2012, 23:14
by PicassoCT
Why not just allow the weapon to exist normally and then set a boolean on aiming, so that the hidden, not yet upgraded weapon cant fire?
Setting it in the unitdef could (unless changed) permanently label it as a peacefull constructor unit.
Sorry, but it seems a bit overcomplicated.
edit: Sorry, re-reading my post i sound arrogant as SomeWhat. Guess i should keep my lips sealed, using 1200 overcomplicated lines for one freaking train. So disregard my post.
Re: Problems with buildings
Posted: 18 Mar 2012, 23:24
by knorke
in the unitscript in function script.AimWeapon1: return false and the weapon will not fire.
you probally also want this:
http://answers.springlobby.info/questio ... munication
can also set the weapon reload time to block it, like this map:
http://springrts.com/phpbb/viewtopic.ph ... =downcount
apparently I can't set canRepair = true if I have a yardmap in the unitdef. What gives?
iirc only "mobile" units can spray nanostuff. That is why nanoturrets in BA etc are actually mobile units with maxVelocity=0
Re: Problems with buildings
Posted: 19 Mar 2012, 00:42
by cam
Thanks very much! Got (1) working. I guess I'll have to come up with another plan for (2).
Re: Problems with buildings
Posted: 19 Mar 2012, 17:04
by smoth
I'd recommend unit swap instead of toggling weapons for upgrades as it will cause issues with info box tooltips.
Re: Problems with buildings
Posted: 19 Mar 2012, 18:41
by knorke
smoth wrote:I'd recommend unit swap instead of toggling weapons for upgrades as it will cause issues with info box tooltips.
Would rather fix w/e info tooltip wupget then. Weapon upgrades is something that should work without unit swapping simply by (un)blocking weapons or editing them.
Spring.SetUnitWeaponState can also be used to "upgrade" weapons, at least "reloadTime" works as expected.
"aimReady" is maybe even better for blocking but I have not tested.
Re: Problems with buildings
Posted: 19 Mar 2012, 18:45
by smoth
cannot re-designate primary weapon, what if he needs to be able to choose weapons? the unit still primarily aims with the weapon 1. Unless they changed that.
Re: Problems with buildings
Posted: 19 Mar 2012, 18:56
by knorke
yea, i think its still like that. Though it only matters when you change what stuff the weapon can target. (like swap a cannon vs torpedo or different weapon range)
For a stationary building primary weapon does not matter so much (at all?) because it can not move into range anyway.
Re: Problems with buildings
Posted: 20 Mar 2012, 21:48
by KDR_11k
May need some additional information.
Is the building in question a factory? If it is then it cannot do things like repairing. I'm not sure what the restrictions on non-factory buildings are but there are plenty of those with build capability in the form of nanotowers in various mods.