friendly mercenary tribes
friendly mercenary tribes
Hello,
Again working on my ruleset.
This time it's about huts.
Both Legion and Horsemen have the "Hut" flag set.
However when going into huts I only get legions, never horsemen...
Did i miss something somewhere ?
Is random choice between all available units for huts implemented and working ?
Besides, how to setup the ruleset so these have no home city when recruited ?
Again working on my ruleset.
This time it's about huts.
Both Legion and Horsemen have the "Hut" flag set.
However when going into huts I only get legions, never horsemen...
Did i miss something somewhere ?
Is random choice between all available units for huts implemented and working ?
Besides, how to setup the ruleset so these have no home city when recruited ?
Re: friendly mercenary tribes
According to data/default/default.lua(_deflua_hut_get_mercenaries), we search unit which have role 'HutTech', with player information.
According to common/scriptcore/api_game_find.c(api_find_role_unit_type) and common/unittype.c(best_role_unit_for_player), last defined unit in units.ruleset is selected which you can build.
If you cannot build any 'HutTech' role unit, then we backed to default.lua, and search unit which have role 'Hut', without any player information.
According to api_game_find.c and unittype.c(get_role_unit), first defined unit selected.
e.g. in classic ruleset:
We obtain Knights if we have technology Chivalry (but must not have Leadership).
If we have not Chivalry or Knights is obsoleted, then we obtain Musketeers if we have technology Gunpowder (but must not have Conscription).
If we have not Gunpowder or Musketeers is obsoleted, then we obtain Legion.
We cannot obtain Horsemen and Chariot by hut.
This behavior is implemented from Freeciv 2.2, it seems.
In Freeciv 1.14 to 2.1, it seems chosen at random from 'HutTech' units and 'Hut' units if no eligible unit.
To set no homecity in unit which spawned from hut, you need copy data/default/default.lua to your ruleset, and change unit:get_homecity() to nil in function _deflua_hut_get_mercenaries.
According to common/scriptcore/api_game_find.c(api_find_role_unit_type) and common/unittype.c(best_role_unit_for_player), last defined unit in units.ruleset is selected which you can build.
If you cannot build any 'HutTech' role unit, then we backed to default.lua, and search unit which have role 'Hut', without any player information.
According to api_game_find.c and unittype.c(get_role_unit), first defined unit selected.
e.g. in classic ruleset:
We obtain Knights if we have technology Chivalry (but must not have Leadership).
If we have not Chivalry or Knights is obsoleted, then we obtain Musketeers if we have technology Gunpowder (but must not have Conscription).
If we have not Gunpowder or Musketeers is obsoleted, then we obtain Legion.
We cannot obtain Horsemen and Chariot by hut.
This behavior is implemented from Freeciv 2.2, it seems.
In Freeciv 1.14 to 2.1, it seems chosen at random from 'HutTech' units and 'Hut' units if no eligible unit.
To set no homecity in unit which spawned from hut, you need copy data/default/default.lua to your ruleset, and change unit:get_homecity() to nil in function _deflua_hut_get_mercenaries.
- GriffonSpade
- Elite
- Posts: 578
- Joined: Mon Apr 29, 2013 4:41 pm
Re: friendly mercenary tribes
Oh, hmm, that's not good, now is it? Not only does using more than one Hut unit not work, units aren't even in order of tech level by default (They're ordered by 'group' first). It means that Knights are preferred over Musketeers. And if you have Leadership, even that is Broken!?Akechi wrote:We obtain Knights if we have technology Chivalry (but must not have Leadership).
If we have not Chivalry or Knights is obsoleted, then we obtain Musketeers if we have technology Gunpowder (but must not have Conscription).
If we have not Gunpowder or Musketeers is obsoleted, then we obtain Legion.
We cannot obtain Horsemen and Chariot by hut.
Seems like there should be a priority level instead or something...
Re: friendly mercenary tribes
Below code is not smart, but if you prefer 1.14 to 2.1 hut mercenaries behavior in Classic ruleset, try this code to default.lua in your own ruleset:GriffonSpade wrote:Oh, hmm, that's not good, now is it? Not only does using more than one Hut unit not work, units aren't even in order of tech level by default (They're ordered by 'group' first). It means that Knights are preferred over Musketeers. And if you have Leadership, even that is Broken!?
Seems like there should be a priority level instead or something...
Code: Select all
-- Get a mercenary unit from entering a hut.
function _deflua_hut_get_mercenaries(unit)
local owner = unit.owner
-- Comment out.
--[[
local type = find.role_unit_type('HutTech', owner)
if not type or not type:can_exist_at_tile(unit.tile) then
type = find.role_unit_type('Hut', nil)
if not type or not type:can_exist_at_tile(unit.tile) then
type = nil
end
end
--]]
local type = nil
local chivalry = owner:knows_tech(find.tech_type("Chivalry"))
local gunpowder = owner:knows_tech(find.tech_type("Gunpowder"))
local chance = random(0, 5)
if chivalry == true and gunpowder == true then
if chance == 0 or chance == 1 or chance == 2 then
type = find.unit_type("Knights")
else
type = find.unit_type("Musketeers")
end
elseif gunpowder == true then
type = find.unit_type("Musketeers")
elseif chivalry == true then
type = find.unit_type("Knights")
end
if not type or not type:can_exist_at_tile(unit.tile) then
if chance == 0 or chance == 1 then
type = find.unit_type("Legion")
elseif chance == 2 or chance == 3 then
type = find.unit_type("Horsemen")
else
type = find.unit_type("Chariot")
end
if not type or not type:can_exist_at_tile(unit.tile) then
type = nil
end
end
if type then
notify.event(owner, unit.tile, E.HUT_MERC,
_("A band of friendly mercenaries joins your cause."))
owner:create_unit(unit.tile, type, 0, unit:get_homecity(), -1)
return true
else
return false
end
end
Re: friendly mercenary tribes
If simple lua script can fix this i'll gladly apply !
However you say default.lua and in the ruleset there is only script.lua.
Did the name simply change since 2.5 ? Or is this another file ? I don't want to touch any global file...
However you say default.lua and in the ruleset there is only script.lua.
Did the name simply change since 2.5 ? Or is this another file ? I don't want to touch any global file...
Re: friendly mercenary tribes
default.lua is placed on data/default/.meynaf wrote:If simple lua script can fix this i'll gladly apply !
However you say default.lua and in the ruleset there is only script.lua.
Did the name simply change since 2.5 ? Or is this another file ? I don't want to touch any global file...
https://github.com/freeciv/freeciv/blob ... efault.lua
If you copy this file to your own ruleset, Freeciv may load your default.lua instead of data/default/default.lua.
So ruleset modder can change hut behavior and partisan behavior in own ruleset.
- Alien Valkyrie
- Elite
- Posts: 513
- Joined: Sun Feb 10, 2013 10:21 pm
- Location: Stuttgart, Germany
Re: friendly mercenary tribes
A better alternative to overwriting default.lua in your ruleset is to define everything necessary in script.lua, but returning false from the function. This should (in principle) tell the engine not to stop processing that event, so it won't execute the default code. I haven't actually tried it though.
~ AVL
Re: friendly mercenary tribes
Ok, I will try. Thanks for your help
Btw. Are there other files that can be overridden this way ?
Btw. Are there other files that can be overridden this way ?
- Alien Valkyrie
- Elite
- Posts: 513
- Joined: Sun Feb 10, 2013 10:21 pm
- Location: Stuttgart, Germany
Re: friendly mercenary tribes
All .ruleset files have to be supplied/overridden if I'm not mistaken. I'm not sure if adding an empty script.lua file is necessary or if that is assumed blank if not supplied. Only default.lua is imported from /data/default/ if it isn't supplied (and it is recommended to not override it). So really, that's the only case where you have the choice whether to use the existing one or not.
~ AVL
Re: friendly mercenary tribes
It seems default.lua isn't big and having to make a diff when upgrading shouldn't be too much of a hassle.
Therefore I duplicated it in my dir and did the patch given here.
It works !
Another problem solved.
But the further I go, the hotter it gets...
Therefore I duplicated it in my dir and did the patch given here.
It works !
Another problem solved.
But the further I go, the hotter it gets...