Problems with buildings

Problems with buildings

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
cam
Posts: 4
Joined: 28 Jan 2012, 03:17

Problems with buildings

Post 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!
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Problems with buildings

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Problems with buildings

Post 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
cam
Posts: 4
Joined: 28 Jan 2012, 03:17

Re: Problems with buildings

Post by cam »

Thanks very much! Got (1) working. I guess I'll have to come up with another plan for (2).
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Problems with buildings

Post by smoth »

I'd recommend unit swap instead of toggling weapons for upgrades as it will cause issues with info box tooltips.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Problems with buildings

Post 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.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Problems with buildings

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Problems with buildings

Post 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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Problems with buildings

Post 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.
Post Reply

Return to “Game Development”