Make workers reclaim and assist with Shard
Moderators: hoijui, Moderators
Make workers reclaim and assist with Shard
Hi,
I have managed to make a pack of units and Shard throwed then into battle
but I cant figure how to assign workers ( reclaim and assists only )
the queue starts building infinite workers that doesn't receive any order
my game is quite "strange" compared to A, only metal as resource and can only be adquired by reclaiming or killing enemyes
but for the moment i want to make a pack of workers and sen them to search the map for features
and at some point make another pack of workers to assist the factory
thx
I have managed to make a pack of units and Shard throwed then into battle
but I cant figure how to assign workers ( reclaim and assists only )
the queue starts building infinite workers that doesn't receive any order
my game is quite "strange" compared to A, only metal as resource and can only be adquired by reclaiming or killing enemyes
but for the moment i want to make a pack of workers and sen them to search the map for features
and at some point make another pack of workers to assist the factory
thx
Re: Make workers reclaim and assist with Shard
Those workers will need behaviours assigned to them. It's likely they got assigned the taskqueue behaviour, but without defining task queues that behaviour won't do anything useful. It doesn't sound like your game has base construction though so that behaviour is of no use to you.
Here's an area reclaiming behaviour from Evolution RTS https://github.com/EvolutionRTS/Evoluti ... aviour.lua a little modification should get it doing what you want. Similarly some modification of a copy could give you a repair behaviour
Here's one that builds a turret when the unit is under attack https://github.com/EvolutionRTS/Evoluti ... aviour.lua
For repairing, I'd suggest you grab all friendly units, and search for the closest unit where HP != Max HP and issue a repair command, the repair command takes another unit as a parameter
You'll need to assign these behaviours to your worker unit, this post should explain how to do that:
http://shard.tomjn.com/2010/07/29/adding-new-behaviors/
Here's some information regarding behaviours that may be useful:
http://shard.tomjn.com/2015/11/17/recla ... ehaviours/
Here's some information on how to reclaim things:
http://shard.tomjn.com/2011/09/27/searc ... -features/
Here's an area reclaiming behaviour from Evolution RTS https://github.com/EvolutionRTS/Evoluti ... aviour.lua a little modification should get it doing what you want. Similarly some modification of a copy could give you a repair behaviour
Here's one that builds a turret when the unit is under attack https://github.com/EvolutionRTS/Evoluti ... aviour.lua
For repairing, I'd suggest you grab all friendly units, and search for the closest unit where HP != Max HP and issue a repair command, the repair command takes another unit as a parameter
You'll need to assign these behaviours to your worker unit, this post should explain how to do that:
http://shard.tomjn.com/2010/07/29/adding-new-behaviors/
Here's some information regarding behaviours that may be useful:
http://shard.tomjn.com/2015/11/17/recla ... ehaviours/
Here's some information on how to reclaim things:
http://shard.tomjn.com/2011/09/27/searc ... -features/
Re: Make workers reclaim and assist with Shard
One thought, you could add a behaviour that's assigned to whatever is building your workers, that makes it build workers, and counts workers. When it counts the workers and sees a certain threshold is reached, it can yield control.
This way your taskqueues can focus on stuff that aren't workers, and your worker count is as you desire. Just make sure you tell the behaviour to have a priority of 0 when you have enough workers, and a priority of 1000 or something silly high when you need to make workers. Make it trigger the behaviour election on unit Idle if it needs to take control so that it doesn't interrupt any existing orders
This way your taskqueues can focus on stuff that aren't workers, and your worker count is as you desire. Just make sure you tell the behaviour to have a priority of 0 when you have enough workers, and a priority of 1000 or something silly high when you need to make workers. Make it trigger the behaviour election on unit Idle if it needs to take control so that it doesn't interrupt any existing orders
Re: Make workers reclaim and assist with Shard
thx for the detailed info
I'm investigating :)
PS: when i compile Spring the compile proccess fails to get the evo config and also the spring buildbot seems to not grab it too
Mantised this
I'm investigating :)
PS: when i compile Spring the compile proccess fails to get the evo config and also the spring buildbot seems to not grab it too
Mantised this
Re: Make workers reclaim and assist with Shard
I managed to made workers reclaim the features i want but when they end reclaiming they don't search for more features
how I can do this?
thx
how I can do this?
thx
Re: Make workers reclaim and assist with Shard
here is what I done
https://github.com/JauriaStudios/Shard/ ... /ai/jauria
https://github.com/JauriaStudios/Shard/ ... /ai/jauria
Last edited by TurBoss on 09 Dec 2015, 00:26, edited 1 time in total.
Re: Make workers reclaim and assist with Shard
Your behaviour issues an area reclaim command when it's activated, but once that command has been performed, the unit becomes idle
Perhaps, there are no more features left within the radius of 200 you specified to find? I would move the area reclaim command into the update routine, and have UnitIdle and Activate turn on a flag indicating that the reclaiming needs to occur, then set the flag to false when the command is given.
Currently, an active behaviour that's chosen a second time has it's Activate function called the second time it's chosen. I'd prefer Shard didn't activate active behaviours as it seems counter intuitive, I will think about this
Perhaps, there are no more features left within the radius of 200 you specified to find? I would move the area reclaim command into the update routine, and have UnitIdle and Activate turn on a flag indicating that the reclaiming needs to occur, then set the flag to false when the command is given.
Currently, an active behaviour that's chosen a second time has it's Activate function called the second time it's chosen. I'd prefer Shard didn't activate active behaviours as it seems counter intuitive, I will think about this
Re: Make workers reclaim and assist with Shard
Ok I did it that way an worked thank you so much
Re: Make workers reclaim and assist with Shard
How i can do this? :)AF wrote:you could add a behaviour that's assigned to whatever is building your workers
thx
Re: Make workers reclaim and assist with Shard
ok i think i got it
I added it like I do whit workers :)
I added it like I do whit workers :)
Re: Make workers reclaim and assist with Shard
I hit a strange problem
i made a file called utils.lua with a simple function that checks is a unit is on a table like attackers
seems to work on behaviours.lua but not in my unitcounterbehaviour.lua
https://github.com/JauriaStudios/Shard/ ... /utils.lua
http://paste.springfiles.com/view/8e82bf76
:\
i made a file called utils.lua with a simple function that checks is a unit is on a table like attackers
seems to work on behaviours.lua but not in my unitcounterbehaviour.lua
https://github.com/JauriaStudios/Shard/ ... /utils.lua
http://paste.springfiles.com/view/8e82bf76
:\
Re: Make workers reclaim and assist with Shard
I see it's iterating over a list of workers, which is a list of unit names, strings, you should check if unit is nil, is that the case?
Re: Make workers reclaim and assist with Shard
I have checked for unit is nil here but i', getting the same error
https://github.com/JauriaStudios/Shard/ ... ur.lua#L31
https://github.com/JauriaStudios/Shard/ ... ur.lua#L31
Re: Make workers reclaim and assist with Shard
Can you print out as much information you can? Including the team, ally team of both the unit, and of the player
Re: Make workers reclaim and assist with Shard
Ok i figured it
I was calling UnitCreated instead of UnitBuilt
hehe thank you
I was calling UnitCreated instead of UnitBuilt
hehe thank you
Re: Make workers reclaim and assist with Shard
Do you still have the information from the echos? I see you were outputting Shards team and ally team, did you get the unit team and ally team for a comparison?
Re: Make workers reclaim and assist with Shard
If I understand correctly
is this what you need?
http://paste.springfiles.com/view/ffbc92cd
is this what you need?
Code: Select all
function UnitCounterBehaviour:UnitBuilt(unit)
EchoDebug("Team ID: " .. game:GetTeamID())
EchoDebug("Unit Team ID: " .. unit:Team())
end
http://paste.springfiles.com/view/ffbc92cd