Author Topic: Unit capturing  (Read 2226 times)

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Unit capturing
« on: 5 October 2016, 22:23:49 »
This is a feature I want to use in one of my techtrees, so it would be appreciated if it could please be considered for inclusion. I remembered I made a thread about it long ago, but it seems I never actually have.

I'd like to suggest a simple way of implementing unit capturing: A system to allow specific units to be converted by their attacker instead of being destroyed. This would allow enemy troops to surrender to their attackers and join them when killed, or for enemy buildings of interest to be conquered instead of getting leveled to the ground.

Example: Suppose I want to make the worker from Tech an unit that can be captured. I define an xml block in the following form:

Code: [Select]
<captures>
<capture>
<faction type="tech"/>
<unit type="worker"/>
<health-threshold value="10%"/>
<health value="25%"/>
<probability value="50%"/>
</capture>

<capture>
<faction type="magic"/>
<unit type="acolyte"/>
<health-threshold value="0%"/>
<health value="50%"/>
<probability value="25%"/>
</capture>
</captures>

This says the following: If the unit is hit by an enemy that's part of the Tech faction while its health is below 10%, there's a 50% probability that it will become an unit of type worker (same unit in this case) for the attacker, with 25% of the unit's normal health. Whereas if the unit is damaged by an enemy from the Magic faction while its health is 0% (the unit died), there's a 25% possibility that it becomes an acolyte for the attacker, with 50% of the acolyte's normal health.

The feature would make it possible to create strategic techs in which players can capture each others units, grabbing them for themselves (if part of the same tech) or turning them into compatible versions of an own unit (if part of another tech). I can't imagine much difficulty in implementing this... since all the code would need to do is check the conditions and the attacker's identity when an unit is damaged, then erase the unit and spawn one for the attacker at the same position.

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #1 on: 20 November 2016, 15:44:05 »
Any thoughts on this from the developers? I'm curious if it's something everyone agrees to, and that could be done in a simple way.

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: Unit capturing
« Reply #2 on: 21 November 2016, 01:41:26 »
I can't imagine who wouldn't like seeing this. It would be helpful for possible campaign missions in the future as well.  ;)
Egypt Remastered!

Proof: Owner of glest@mail.com

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Re: Unit capturing
« Reply #3 on: 21 November 2016, 10:46:56 »
This is quite complicated to do and in my eyes a too special feature. It would mean you need a transition map of which unit is mapped on which unit while capturing and so on.
I  don't think I want to add something like this and I think these kind of things should be done with scenario code.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #4 on: 21 November 2016, 12:59:41 »
This is quite complicated to do and in my eyes a too special feature. It would mean you need a transition map of which unit is mapped on which unit while capturing and so on.
I  don't think I want to add something like this and I think these kind of things should be done with scenario code.

Why would that be needed though, compared to my initial idea: When an unit dies or is under a certain HP, check who the attacker is, and if a capture definition exists then delete the unit and simply spawn an unit for the attacker? In a sense this should be similar to how a summoner spawns other units... though more like a summoner from one faction spawning an unit for another faction.

I imagine this can be easily done in scenario nodes for now. But then it would only work for scenarios, not for random matches... which would be very limited, and not make it possible to have this as a real feature of the tech tree.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Re: Unit capturing
« Reply #5 on: 21 November 2016, 14:40:45 »
I understand it, but as I said too complicated to do for the benefit you get. Saying: I will not do this at this point  ;)
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #6 on: 21 November 2016, 18:17:23 »
I understand it, but as I said too complicated to do for the benefit you get. Saying: I will not do this at this point  ;)

Ok. You're a core developer so you know best how it would work! Hopefully either another dev could look into it, or you could put it on your list for later on when you believe possibilities might change :)

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: Unit capturing
« Reply #7 on: 24 November 2016, 17:43:14 »
Wouldn't you just define the unit conversion in the XML and then kill the one unit and spawn the proper replacement in the same location? In what way is this complicated?

In fact wouldn't this just be a copy of the spawn at death feature which you did in fact implement? You don't literally have to modify a given unit to another type.

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #8 on: 25 November 2016, 01:25:34 »
Wouldn't you just define the unit conversion in the XML and then kill the one unit and spawn the proper replacement in the same location? In what way is this complicated?

In fact wouldn't this just be a copy of the spawn at death feature which you did in fact implement? You don't literally have to modify a given unit to another type.

I was wondering the exact same things, to be fair.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Re: Unit capturing
« Reply #9 on: 25 November 2016, 13:07:42 »
You would need a mapping which unit to spawn for which unit. By this you get a dependency of one faction to another. Up to now there is no such dependency and you can move factions around.
I dont really want to introduce this dependency, but if it would exists it is possible to implement somehting like you suggested.

( completly offtopic but please test this and give feedback: https://forum.megaglest.org/index.php?topic=9837.0 )
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #10 on: 25 November 2016, 18:17:00 »
You would need a mapping which unit to spawn for which unit. By this you get a dependency of one faction to another. Up to now there is no such dependency and you can move factions around.
I dont really want to introduce this dependency, but if it would exists it is possible to implement somehting like you suggested.

( completly offtopic but please test this and give feedback: https://forum.megaglest.org/index.php?topic=9837.0 )

What I'm still confused about is: Code to spawn any unit for any faction at any time exists... summoners and builders use it after all! So why can't the defeated unit simply be erased, and a completely new and independent unit added separately... only creating the illusion that it's the same unit having transformed? Why would there be a dependency in between the two, even in an approach where they're two completely separate entities? I just see it as using the following steps:

1 - Unit X for faction A is simply erased out of existence.
2 - The code remembers what the location and orientation of unit X was, storing them as a vector and a float somewhere.
3 - A completely new unit Y for faction B is spawned, just as if a summoner from that faction would have spawned it.
4 - Unit Y is instantly given the stored position and orientation that unit X had.

filux

  • MegaGlest Team
  • Draco Rider
  • ********
  • Posts: 310
  • was OpenSuse x64, is Debian testing x64
    • View Profile
Re: Unit capturing
« Reply #11 on: 25 November 2016, 18:24:00 »
same type of unit? not from own faction? then you have high chance for unexpected problems like
e.g. instant dying > because no food > because your faction doesn't use food etc.

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #12 on: 25 November 2016, 18:27:05 »
Sorry for having to correct myself so early! I kept thinking you're referring to a dependency issue in the code, caused by trying to convert an existing unit to a different faction, hence why I kept suggesting a "delete old / spawn new" approach. I just realized you were in fact referring to the dependency in the definitions... since indeed, every unit that used this would have to name a unit from every other faction in the techtree that it can be turned into within its xml.

Personally I don't see that as a problem. Unless as you mentioned, someone decides to move techs in and out of tech trees, and forgets to also update this definition. That would however be a developer error, the same as say moving a common asset and forgetting to replace it in an unit's definition. It's also not something I believe people should do normally, as techs are balanced against one another and would have to be thoroughly re-checked in case of such a move anyway.

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #13 on: 25 November 2016, 18:30:36 »
same type of unit? not from own faction? then you have high chance for unexpected problems like
e.g. instant dying > because no food > because your faction doesn't use food etc.

No... I was understanding incorrectly. He's referring to the dependency of specifying a unit of one tech in the definition of a unit in another tech, which is indeed the case with my idea. Like I said I don't see a problem with it myself... it does add the extra responsibility of fixing this definition in case you ever move a tech out of the same techtree, but I think tech developers who decide to use this can definitely learn to keep an eye out for such.

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: Unit capturing
« Reply #14 on: 27 November 2016, 03:14:20 »
You would need a mapping which unit to spawn for which unit. By this you get a dependency of one faction to another. Up to now there is no such dependency and you can move factions around.
I dont really want to introduce this dependency, but if it would exists it is possible to implement somehting like you suggested.


I don't see how. You kill a unit and spawn your own faction's version. If you kill a unit that you don't indicate in the XML, you don't spawn a unit. So the unit would just die instead of being captured. So yeah it wouldn't work right but it wouldn't break the game somehow. If you were going to the level of modding that involves swapping factions around you should be able to handle this. You could even just bump and error if capture failed to the error log. If people are moving around factions but can't read error logs that's not really your fault.

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Unit capturing
« Reply #15 on: 27 November 2016, 13:36:49 »
I don't see how. You kill a unit and spawn your own faction's version. If you kill a unit that you don't indicate in the XML, you don't spawn a unit. So the unit would just die instead of being captured. So yeah it wouldn't work right but it wouldn't break the game somehow. If you were going to the level of modding that involves swapping factions around you should be able to handle this. You could even just bump and error if capture failed to the error log. If people are moving around factions but can't read error logs that's not really your fault.

Yeah... like that. My idea was this, to exemplify: Suppose that in your tech tree you have 3 factions, A B and C. In faction A, you define an unit that you want to make possible to capture. You want the unit to only be captured by: The same tech it's from (A), and tech B. So you simply say the following in the unit's definition: "If killed by an unit from tech A then: Become the same type of unit from tech A" and "if killed by an unit from tech B then: Become this here tech-B unit". However if you leave the tech C definition out, the unit just dies normally and doesn't become anything for its captor.

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 474
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Unit capturing
« Reply #16 on: 13 March 2017, 03:43:29 »
This is a feature I want to use in one of my techtrees, so it would be appreciated if it could please be considered for inclusion. I remembered I made a thread about it long ago, but it seems I never actually have.

I'd like to suggest a simple way of implementing unit capturing: A system to allow specific units to be converted by their attacker instead of being destroyed. This would allow enemy troops to surrender to their attackers and join them when killed, or for enemy buildings of interest to be conquered instead of getting leveled to the ground.

What you describe sounds a lot like what Earth Breach did in the possession obsession scenario.
https://forum.megaglest.org/index.php?topic=9842.0

I tried playing it as a stand-alone tech tree, but the AI gets a bit confused. As titi mentioned, it's not a feature he'll be working on. But the scenario runs fine.

I modified it a bit so the "captured" units appear at the player's start location. I would have preferred they appear near the battle but wasn't quite sure how to do it. I could get their unit position and add or subtract for pos x,y, but there isn't really a way I know of to say how far away to place them, or in which direction, afaik.

https://forum.megaglest.org/index.php?topic=9917.0

Anyways, after reading your post, I thought you may be interested to see how Earth Breach did it.


 

anything