Page 1 of 1

home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 12:16 am
by Wahazar
Currently you can't set home city for homeless unit - it usually make sense, to avoid accidentally making upkeep of free units,
but is completely counterproductive, if killunhomed option is set.
In such case units others than settlers are dying after at least 10 turns and you can't do anything (besides disbanding them to collect few shields).

Therefore I propose small patch in function can_unit_change_homecity_to in common/unit.c

Code: Select all

  return (punit && pcity
	  && ((punit->homecity > 0) || (game.server.killunhomed >0))
	  && acity
	  && city_owner(acity) == unit_owner(punit)
	  && punit->homecity != acity->id);
Not sure if brackets are needed, added them to enhance code.

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 8:20 am
by Alien Valkyrie
In the current master (3.1+), the "change home city" action is already controlled by an action enabler; I believe the requirement that a unit must already have a home has been un-hardcoded. However, I don't believe there is currently a means of requiring a server setting to have (or not have) some value, so it is only possible to either always allow it, or never allow it (or some more fine-grained conditions based on other things in the game), regardless of the killunhomed server setting.

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 4:51 pm
by Ignatus
Caedo wrote:However, I don't believe there is currently a means of requiring a server setting to have (or not have) some value, so it is only possible to either always allow it, or never allow it (or some more fine-grained conditions based on other things in the game), regardless of the killunhomed server setting.
"ServerSetting" requirement in 3.0 supports boolean-type options.

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 8:27 pm
by Alien Valkyrie
Ignatus wrote:
Caedo wrote:However, I don't believe there is currently a means of requiring a server setting to have (or not have) some value, so it is only possible to either always allow it, or never allow it (or some more fine-grained conditions based on other things in the game), regardless of the killunhomed server setting.
"ServerSetting" requirement in 3.0 supports boolean-type options.
Do you happen to know if this includes testing whether a numeric setting is non-zero?

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 9:37 pm
by Ignatus
Caedo wrote: Do you happen to know if this includes testing whether a numeric setting is non-zero?
For non-boolean options, it yet either does not load or returns always false. The development obstacle seems to me like just it would require some a bit more sophisticated coding to fit universals with non-boolean value into 32 bytes, a bigger structure for requiremens will slow down too many things.

Re: home city for homeless when killunhomed>0

Posted: Thu Feb 06, 2020 2:29 pm
by Wahazar
By the way, this patch (for 2.6) doesn't work - seems it is hardcoded also elsewhere - gui client?

Re: home city for homeless when killunhomed>0

Posted: Fri Mar 06, 2020 4:40 pm
by Lachu
I propose add new action, which consumes and requires 100% MP, but disable killunhomed effect for actor, but also disables HP regen. But.. I don't know, what name should be use for make it reality (made possible not degrade reality of gameplay, when introduce this action). Maybe add this action also for normal units, so we could introduce additional effect for units with home, but uses this action.

Ah... For reality, also makes this action possible only on certain tile/terrain, like with food, farm, irrigation, etc

Re: home city for homeless when killunhomed>0

Posted: Mon Jul 20, 2020 8:53 am
by ilkkachu
Wahazar wrote:By the way, this patch (for 2.6) doesn't work - seems it is hardcoded also elsewhere - gui client?
It seems to me it's hardcoded in that the client appears to use that very same function to determine if rehoming is possible. But even if I recompiled the client with that patch, it didn't have the correct value of game.server.killunhomed -- it doesn't get sent to the client. It would require adding some other setting that actually does get sent. Creating a new boolean, e.g. `allow_rehome_unhomed` instead of relying on `killunhomed` would also allow having the current behaviour in case someone wants just that. (You could have a ruleset with the initial units having some advantage the buildable ones don't have, with the downside that they have a limited lifetime.)

Same for 3.x, if the action enabler only supports booleans, it can be solved by adding a new boolean setting.