male and female troops?

Users who are viewing this thread

Tricket

Veteran
i am trying to make it so that when you go to recruit troops for the khergit faction, you get both male and female troops,  as two different troop types, in this case, male and female peasants.  is this possible? or am i going to have to take a different approach?

regards,
tricket
 
Ruthven tried this once, couldn't come up with anything.  I don't think you can do it.
 
Well, one solution would be to use the troop_set_type operation. The only problem with that is that if say, you recruited a "peasant" and set its type to 1 (female), if the peasant is upgradeable, the gender change wouldn't transfer to the upgraded troop.
 
Easiest solution without needing scripting and what not, is to make another troop line with the troop editor (this is how i did it) . I believe there is only one possible upgrade from peasent, leaving a free branch slot, where female can be added. This means that females must upgrade one further time, but it's hardly difficult to get those extra XP so low down the troop tree.

Not the ultimate solution, but it works.
 
This code should do it's job. Stick it in script_village_recruit_volunteers_recruit. After party_get_free_companions_capacity would be great.

PS: Untested, sorry. But it seemed to compile fine (disregarding other errors in my Testing MS. :razz:)
  (try_begin), #~ CD - Male/Female Begin ~#
    (store_random_in_range, ":random", 1,10),
    (assign, ":khergit_faction", "fac_kingdom_3"),
  (is_between, ":villages", villages_begin,villages_end),
  (store_faction_of_party, ":villages"),
  (eq, ":villages", ":khergit_faction"),
  (try_begin),
      (ge, ":random", 5),
  (assign, ":volunteer_troop", "trp_khergit_tribe_male"),
      (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
  (else_try),
      (lt, ":random", 5),
  (assign, ":volunteer_troop", "trp_khergit_tribe_female"),
  (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
  (try_end),
  (try_end), #~ CD - Male/Female End ~#

[quote author= Dudro]I don't think you can do it.[/quote]
Almost anything is possible with the ModuleSystem. Belfry system, battering ram, artillery! (also, most of the game mechanics) And to say, this is a pretty simple script. Just because one guy can't do it, doesn't mean it's not possible.

cdvader
 
troop_set_type works for me. What is the operation to get troop's gender?

I use a similar script as cdvader above. Mine will assign gender randomly for each troop. I have to randomly reassign gender after upgrade. This works fine for me now because the the real gender is the same (male or female), just use a difference body mesh (bigger/smaller, taller/shorter).

If I can get troop gender, then I can use some modified code to keep the gender when upgrade. Another is to assign proper equipment and may be using mix gender (male-female) troop tree.
 
This should do it. Untested, but it compiled fine. What it does, is first get a random number between 1,10. If the number is higher or equal to 5, then put the volunteer troop as male gender, else set it as female and also the upgrade troop of it to female.

cdvader
Code:
	 (assign, ":villages", -1),
	 (assign, ":female", tf_female),
	 (assign, ":male", tf_male),
     (try_begin), #~ CD - Male/Female Begin ~#
        (store_random_in_range, ":random", 1,10),
        (assign, ":khergit_faction", "fac_kingdom_3"),
        (is_between, ":villages", villages_begin,villages_end),
        (store_faction_of_party, ":villages"),
        (eq, ":villages", ":khergit_faction"),
        (try_begin),
            (ge, ":random", 5),
            (assign, ":volunteer_troop", "trp_khergit_tribesman"),
            (troop_set_slot, ":volunteer_troop", ":male"),
        (else_try),
            (lt, ":random", 5),
            (assign, ":volunteer_troop", "trp_khergit_tribesman"),
            (troop_set_slot, ":volunteer_troop", ":female"),
        (try_end),
		(try_begin),
		    (troop_get_upgrade_troop, ":upgrade_troop", "trp_khergit_tribesman", 0),
			(troop_get_type, ":volunteer_troop_type", ":volunteer_troop"),
			(eq, ":volunteer_troop_type", ":female"),
			(troop_set_type, ":upgrade_troop", ":female"),
		(else_try),
		    (troop_set_type, ":upgrade_troop", ":male"),
		(try_end),
     (try_end), #~ CD - Male/Female End ~#
 
There's a troop_get_type command that would work, but I'm not a huge fan of the troop_set_type concept just because we can't set face codes in the game, so I've seen some of the face's look pretty bad after switching them...  But I'm testing with aliens, so maybe its fine for humans.  :wink:    If I was going to do something like this I'd probably use something similar to what cdvader first posted, and have it randomly pick some females and some male recruits that were added to your party every time you went to a village, etc.

edit:  just saw cdvader's example, and I think you guys are making this too difficult?  why don't you just have a trp_khergit_tribesman and trp_khergit_tribeswoman ?  That way they are separate troops, with separate face codes, equipment, upgrade paths, etc....
 
I was thinking about that, at first, but doing my way (if it works) would probably be more time-saving. But doing Hokie's way would be more secure and less buggy, just some more leg-work.

cdvader
 
i'll give cdvader's script a try and see what happens, the only reason i wanted male and female recruits was because i wasn't sure if you could get more than one type of recruit if that makes sense.  and i needed male and female, because i didn't think it would make sense to go from a male troop to a female troop.

thanks for your help going to test it now
tricket

EDIT: I popped the script in the right place, got no errors building it, tried it in game on about 20 tribesman and nothing, so i'm not sure what's going on, would appreciate someone else to test this when they have time to confirm or refute my findings.
 
Will troop_get_type give me troops' gender? I know that function, but in the header file, it seems to get the troop ID instead. I have never used that function.

troop_set_type works for my current system because I just use different body mesh for each gender. Face code doesn't matter much.

If I can get the troop gender, then I can do it differently.

@Tricket,
May be you need to wait until the recruit is refreshed a few times. Based one the script, you will have equal chance of getting either all female or all male.

Also, make sure you have defined female peasant/tribewoman and male peasant/tribeman as seperate troop ID
 
Alright, here's the updated code SPD_Phoenix. This should work.
      (try_begin),
          (troop_get_upgrade_troop, ":upgrade_troop", "trp_khergit_tribesman", 0),
          (troop_get_type, ":volunteer_troop_type", ":volunteer_troop"),
          (eq, ":volunteer_troop_type", 1),
          (troop_set_type, ":upgrade_troop", 1),
          (assign, ":upgrade_troop", tf_female),
      (else_try),
          (troop_set_type, ":upgrade_troop", 0),
          (assign, ":upgrade_troop", tf_male),
      (try_end),

And to Tricket, try using this code instead. Should work better.
  (try_for_range, ":villages", villages_begin,villages_end), #~ CD - Male/Female Begin ~#
    (store_random_in_range, ":random", 1,10),
    (assign, ":khergit_faction", "fac_kingdom_3"),
  (store_faction_of_party, ":villages"),
  (eq, ":villages", ":khergit_faction"),
  (try_begin),
      (ge, ":random", 5),
  (assign, ":volunteer_troop", "trp_khergit_tribe_male"),
      (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
  (else_try),
      (lt, ":random", 5),
  (assign, ":volunteer_troop", "trp_khergit_tribe_female"),
  (party_set_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
  (try_end),
  (try_end), #~ CD - Male/Female End ~#
 
alright i managed to implement it, but i get a compile error regarding mt_bandits_at_night, it's in the scripts file, it says it can't find the object and that mt_bandits_at_night is a illegal identifier.

i had a few other errors but i fixed them, this one i'm not sure how to fix.

 
Err... you added this to mission templates?

[quote author= cdvader]Stick it in script_village_recruit_volunteers_recruit. After party_get_free_companions_capacity would be great.[/quote]
 
nope, i put it into scripts, i had to add two new troops to the troop file khergit_tribe_(male/female)\

now it just goes on about bandits at night.  the errors come under the "exporting scripts"
 
figured it out, i was missing a chunk in mission templates, apparently i pasted over it during my other modifications, now to test to see if this script works
 
Back
Top Bottom