differentiate mobile units and buildings
Moderator: Moderators
differentiate mobile units and buildings
so how to in a simple way?
isBuildings=true/false is not enough, its false for mex.
For factories too I think.
So there is isFactory but then you would probally have to check a million other tags as well, thats stupid.
Speed would be good but the mod might have a speed=100 tag wrongly assigned to a building so thats not working either.
isBuildings=true/false is not enough, its false for mex.
For factories too I think.
So there is isFactory but then you would probally have to check a million other tags as well, thats stupid.
Speed would be good but the mod might have a speed=100 tag wrongly assigned to a building so thats not working either.
Re: differentiate mobile units and buildings
(isBuilding or isFactory) and not canMove
Works nicely for BA. The only oddities are the dragon claw and dragon maw, which actually CAN move.
Works nicely for BA. The only oddities are the dragon claw and dragon maw, which actually CAN move.
Re: differentiate mobile units and buildings
are those the pop up turrets that look like dragon teeth when not poped up?Works nicely for BA. The only oddities are the dragon claw and dragon maw, which actually CAN move.
how are those able to move and why does it contradict canmove=false? oO
but yea, i want to avoid such oddities...isnt there a way to figure out how "spring sees the unit" instead of how it is defined in its file?
Re: differentiate mobile units and buildings
acceleration=1e-13;
canMove=1;
canMove=1;
Re: differentiate mobile units and buildings
huh? more input please 

Re: differentiate mobile units and buildings
Code: Select all
local udef = UnitDefs[udid]
if (udef.type == "Building") then
...
end
Re: differentiate mobile units and buildings
looks good.
but from
http://springrts.com/wiki/Lua_UnitDefs
and looking at some mods it seems "type" is a part of the
"moveData" and "Building" is just one possible name for a certain movement type? What if other names are used.
Like couldnt a mod have buildings with type="Building_1" and another with type="Building_2" for example if buildings are suppossed to have different maxSlope?
(like turrets can be build on mountains but factories only on flat)
but from
http://springrts.com/wiki/Lua_UnitDefs
and looking at some mods it seems "type" is a part of the
"moveData" and "Building" is just one possible name for a certain movement type? What if other names are used.
Like couldnt a mod have buildings with type="Building_1" and another with type="Building_2" for example if buildings are suppossed to have different maxSlope?
(like turrets can be build on mountains but factories only on flat)
Re: differentiate mobile units and buildings
You mean the MoveType name, which you can find under moveData.
The `type` is an engine internal tag, mods can't define it, it's the result of some other tags (canmove etc.).
It defines what CommandAI gets loaded for the unit and limits the possible MoveTypes of an unit (buildings can't load an air movetype etc.).
To check the possible values for it, either write a small for-loop and iterate all UnitDefs or check the engine code.
The `type` is an engine internal tag, mods can't define it, it's the result of some other tags (canmove etc.).
It defines what CommandAI gets loaded for the unit and limits the possible MoveTypes of an unit (buildings can't load an air movetype etc.).
To check the possible values for it, either write a small for-loop and iterate all UnitDefs or check the engine code.
Re: differentiate mobile units and buildings
thats what i was looking for :)The `type` is an engine internal tag, mods can't define it, it's the result of some other tags (canmove etc.).
thanks!
Re: differentiate mobile units and buildings
hm, again that tag alone isnt enough.
for example nano turrets and construction vehicles are both type="Builder"
for example nano turrets and construction vehicles are both type="Builder"
Re: differentiate mobile units and buildings
That's because they are! Nanotowers are not buildings! If they were buildings, they would be factories, and factories can't help other factories. Despite their deceptive apparence, Nanotowers are truely mobile cons! Just their speed is slow you can't see them moving.
Re: differentiate mobile units and buildings
i think in spring rocks would be animals, but just really slow ones 

Re: differentiate mobile units and buildings
I believe Spring actually allows a building to be a constructor but it doesn't remember that a building con is actually a building.zwzsg wrote:That's because they are! Nanotowers are not buildings! If they were buildings, they would be factories, and factories can't help other factories. Despite their deceptive apparence, Nanotowers are truely mobile cons! Just their speed is slow you can't see them moving.
Re: differentiate mobile units and buildings
Incorrect.zwzsg wrote:That's because they are! Nanotowers are not buildings! If they were buildings, they would be factories, and factories can't help other factories. Despite their deceptive apparence, Nanotowers are truely mobile cons! Just their speed is slow you can't see them moving.
Units in Spring have 3 interfaces: UnitType, MoveTypeAI & CommandAI.
- UnitType defines which C-Class is used for the unit, it's what you get via `UnitDef.type`. It limits which MoveTypeAI & CommandAIs can be used by the unit (still there are multiple options for the same UnitType).
- MoveTypeAI is obvious.
- CommandAI defines which commands an unit can process (factories, builders, airfighters, fighters, transporters).
So you want to know the MoveTypeAI which is CStaticMoveType for NanoTowers. Now the bad news, Spring doesn't export this information to Lua AFAIK, so you have to check all the tags the engine does :x
PS: I know that all this stuff is very messy and it really needs a cleanup (as the weapon handling already had).
Re: differentiate mobile units and buildings
The semantics of canMove (like most of the can$Verb$ tags) are only "this unit can be given move commands", but they say nothing about a unit's ability to actually execute them (think factories).knorke wrote: how are those able to move and why does it contradict canmove=false?
In Lua you can just check if unitDef.moveData is an empty table (a unit that is assigned CStaticMoveType has a null MoveData instance) and !unitDef.canFly.jK wrote: So you want to know the MoveTypeAI which is CStaticMoveType for NanoTowers. Now the bad news, Spring doesn't export this information to Lua AFAIK, so you have to check all the tags the engine does.
Re: differentiate mobile units and buildings
I hate it when dragon claws go mobile, and a raiding party invades my base.