eronoobos / BABAR-The-Shardifant

Balanced Annihilation & Balanced Annilhation Reloaded configuration for Shard
2 stars 1 forks source link

generic quick questions #78

Open pandaro opened 8 years ago

pandaro commented 8 years ago

why we need this lines for example in taskBuild? if tskqbhvr.unit == nil then return DummyUnitName end

why tskqbhvr will get nil unit?

eronoobos commented 8 years ago

I'm not sure why it would get a nil unit. There is a lot of this kind of paranoia in the code, in some cases justified, in some cases not. It was a long time ago, I have forgotten what was happening to make me add such checks.

I can't now think of any reason a behaviour would have a nil unit. The real danger I can think of is a nil engineUnit (aka, in a behaviour, self.unit:Internal()). When our own units die, their engineUnit becomes nil. I have written some modules that store behaviours in tables, so it is possible for those stored behaviours to become zombies with no engineUnit.

pandaro commented 7 years ago

there is a reason because advanced construction submarine are not in advconlist?

eronoobos commented 7 years ago

I can't think of any reason that would cause a behaviour to have a nil unit. Would be good to add it to the list though

eronoobos commented 7 years ago

ohh, now i get it

pandaro commented 7 years ago

if i have only a ID of a unit, where can i take a unit(self)? in other word, we have a function: GetunitFromID(id)

eronoobos commented 7 years ago

yup, game:GetUnitByID( unit_id )

When I was first writing the BA config, I didn't trust Shard's API so I stored a lot of unitIDs instead of Shard unit objects. I'm assuming your question is a result of my bad habit. :-[