OSP Code QoL Randomly unisex troops

Users who are viewing this thread

random_mixed_gender = (ti_on_agent_spawn, 0, 0, [],
  [
  (store_trigger_param_1, ":agent_no"),
  (agent_get_troop_id, ":troop_no", ":agent_no"),
  (neg|troop_is_hero, ":troop_no"),
  (store_random_in_range, ":gender", 0, 2),
    (try_begin),
    (eq, ":gender", 0),
    (troop_set_type, ":troop_no", 0),
    (else_try),
    (eq, ":gender", 1),
    (troop_set_type, ":troop_no", 1),
    (try_end),
  ])

  #script_add_troop_to_cur_tableau_for_party
  # INPUT: troop_no
  # OUTPUT: none
  ("add_troop_to_cur_tableau_for_party",
    [
    ...
      (try_begin),
        (troop_is_hero, ":troop_no"),
        (cur_tableau_add_troop, ":troop_no", pos2, ":animation", -1),
      (else_try),
#################################################
  (store_random_in_range, ":gender", 0, 2),
    (try_begin),
    (eq, ":gender", 0),
    (troop_set_type, ":troop_no", 0),
    (else_try),
    (eq, ":gender", 1),
    (troop_set_type, ":troop_no", 1),
    (try_end),
#################################################

        (store_mul, ":random_seed", ":troop_no", 126233),
        (val_mod, ":random_seed", 1000),
        (val_add, ":random_seed", 1),
        (cur_tableau_add_troop, ":troop_no", pos2, ":animation", ":random_seed"),
      (try_end),
      (cur_tableau_set_camera_position, pos5),

      (copy_position, pos8, pos5),
      (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up
      (position_rotate_z, pos8, 30),
      (position_rotate_x, pos8, -60),
      (cur_tableau_add_sun_light, pos8, 175,150,125),
    ]),
 
What happens to the agents of the same troop that are already spawned when you use troop_set_type for the next spawning agent? Do they retain their gender?
 
Do they retain their gender?
Yup, I tested it in a battle with looters and in the party window. All non-hero agents were mixed in both as it was supposed to be. To sum it up works much like giving troops, not agents, an item or something.

PS: coulda fought a villager party.
 
MadVader said:
What happens to the agents of the same troop that are already spawned when you use troop_set_type for the next spawning agent? Do they retain their gendertype?

Yes, that how I randomize troops with variated phenotype. It even works for heroes and trp_player. That's why I put troop_set_type at the first start dialog state, and set it back on every frame map free simple trigger. Player agent already spawned on conversation mission 's not affected, but then {maskulin/feminim} strings on dialogs for custom race PC can be fixed.
 
dunde said:
MadVader said:
What happens to the agents of the same troop that are already spawned when you use troop_set_type for the next spawning agent? Do they retain their gendertype?

Yes, that how I randomize troops with variated phenotype. It even works for heroes and trp_player. That's why I put troop_set_type at the first start dialog state, and set it back on every frame map free simple trigger. Player agent already spawned on conversation mission 's not affected, but then {maskulin/feminim} strings on dialogs for custom race PC can be fixed.
Just curious why would you need to set back the type?
Do you use this only for the {m/f} syntax to work in dialogs?

EDIT:
I did this the pedestrian way for TLD, changing all {m/f} syntax to {reg11?f:m} syntax, and inserting this snippet:
      (troop_get_type, reg11, ":someone"),
      (try_begin),
        (gt, reg11, 1), #non-humans are male
        (assign, reg11, 0),
      (try_end)],
 
Well crap.  :roll:
Already have a configurable launcher with gender and item swap and everything on the internal POP forums.

I was spending weeks wading through the internal assembler code of the game engine because
someone said what you just have done with the module system is impossible.

Of course your solution is superior and we will implement that for our Falcon Knights. Thanks.

But I don't regret the time I learned about writing a launcher.
Do you have something worthwhile that is really impossible with the module system to suggest?
 
MadVader said:
Just curious why would you need to set back the type?
Do you use this only for the {m/f} syntax to work in dialogs?

Because on my mods, different type mean different phenotype. Like, I start as large man (type = 6). If I don't switch my type to 0, then my companions will call me 'my lady'. 1st start checking block alway called by any normal dialogs, I put it too on "event_triggered" too to handle map conversation. I should set it back so in the next scenes I won't be changed to normal man (type=0).
 
Calen said:
Well crap.  :roll:
Already have a configurable launcher with gender and item swap and everything on the internal POP forums.

I was spending weeks wading through the internal assembler code of the game engine because
someone said what you just have done with the module system is impossible.

Of course your solution is superior and we will implement that for our Falcon Knights. Thanks.

But I don't regret the time I learned about writing a launcher.
Do you have something worthwile that is really impossible with the module system to suggest?
I didn't try to one-up you or make your stuff look bad. It just caught my attention being a fan of PoP. Also, people don't always make something completely different everytime and don't have to either. For example, Calradia: Modern Warfare had an autofire code before Ithilienranger developed another. I fail to see what is vain or disrespectful about it.
 
I guess the self irony didn't translate properly through this written medium despite my smiley.

There is nothing vain or disrespectful about your post at all.
I'm really glad there is a better way than through a launcher
and I also thanked you for it in my post already.

So does someone have a suggestion what I could do with my skills that is impossible with the module system?
 
Multiplayer campaign.  :wink:
Maybe you could do things that are possible with the module system? Just a wild thought. :smile:

EDIT: Better open a new topic in the Forge asking just that, so we'll stop spamming this one.
 
I hate to bring this up, but this script also affects gender-specific units. Is there a way to avoid this?

I'll go into more detail. Like I said this doesn't go very well with some gender-exclusive troops or use gender-exclusive armor, like the sword sisters troop tree. The result is transgender/transvesty troops with male faces and women's dress and such :smile:

Maybe we could make this affect only male troops. However, there are some mods out there that also have exclusive male troops, which would complicate things up a bit...

Unfortunately, I suck at scripting... As a coder my skills are very poor and limited, but I'll still contribute the best way I can. I think that the best bet could be using the male/female flags on these specific troops to somehow prevent this from happening or maybe make checks on especific troops to avoid the script. Perhaps a more "generic flag" could be unisex factions, excluding non-unisex factions like the outlaws.

Another issue was having a lot of bald women somehow. I guess it's related to the face generator...

So, in short: conflicts with exclusive women/male troops, conflict with male armor and bald women :p

Last (but not least), I can't leave without saying this. I never thought that I'd see the day of someone implementing a script such as this. Everybody thought it was hardcoded. Yet, here it is and it looks so simple! Kudos!

Now, my 2 cents for perfection...

 
Re: "transvestites": It's relatively easy to fix. You can exclude the troops supposed to be strictly male or female and give the rest gender-specific equipment depending on the randomized gender.
cucas said:
Another issue was having a lot of bald women somehow. I guess it's related to the face generator...
Yup, that's the tricky part. I've read this bug report on a mod forum too. But in my experience, it worked perfectly in a test battle with a bunch of looters for some reason.
Last (but not least), I can't leave without saying this. I never thought that I'd see the day of someone implementing a script such as this. Everybody thought it was hardcoded. Yet, here it is and it looks so simple! Kudos!
Thanks.
 
The facegen issue has to do with the facecodes from agents on both sides being mixed up - normally in Native this is expressed by soldiers from one faction having the facecode of another and vice versa.
 
Dusk Voyager said:
Re: "transvestites": It's relatively easy to fix. You can exclude the troops supposed to be strictly male or female and give the rest gender-specific equipment depending on the randomized gender.
Like this?  :oops:

(store_trigger_param_1, ":agent_no"),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(neg|troop_is_hero, ":troop_no"),
# begin check to avoid changing troops with gender already defined
(troop_get_type, ":gender", ":troop_no"),
(try_begin),
(neq, ":gender", 0),
(neq, ":gender", 1),
# end check to avoid changing troops with gender already defined
# your code to set troops with still undefined gender begins here
(store_random_in_range, ":gender", 0, 2),
(try_begin),
(eq, ":gender", 0),
(troop_set_type, ":troop_no", 0),
(else_try),
(eq, ":gender", 1),
(troop_set_type, ":troop_no", 1),
(try_end),
(try_end),

Or maybe something this?
(this_or_next|eq, ":gender", 0),
(eq, ":gender", 1),
Dusk Voyager said:
cucas said:
Another issue was having a lot of bald women somehow. I guess it's related to the face generator...
Yup, that's the tricky part. I've read this bug report on a mod forum too. But in my experience, it worked perfectly in a test battle with a bunch of looters for some reason.
Erm.. That's weird. Is it the same code?

Somebody said:
The facegen issue has to do with the facecodes from agents on both sides being mixed up - normally in Native this is expressed by soldiers from one faction having the facecode of another and vice versa.
I think I've noticed this before. Can we un-mix this?
 
Make sure all the unisex troops are in one place/tidy them up as much as possible in module_troops or copy one of the genders to give them that gender there. Don't make them undead (2), because otherwise the first troop/agent to spawn will become one before its gender can be randomized! The latter doesn't require a change, but if you choose the former, it's this:

  (store_trigger_param_1, ":agent_no"),
  (agent_get_troop_id, ":troop_no", ":agent_no"),
  (neg|troop_is_hero, ":troop_no"),
 
  (is_between, ":troop", [first UT], [the one following the last UT]), # if they really are in one place

  (store_random_in_range, ":gender", 0, 2),
    (try_begin),
    (eq, ":gender", 0),
    (troop_set_type, ":troop_no", 0),
    (else_try),
    (eq, ":gender", 1),
    (troop_set_type, ":troop_no", 1),
    (try_end),

Re: faces: No, I didn't change the code.
 
I think the game is trolling with our heads :razz:

It would be so simple if what I posted above worked... I still don't understand why. don't they have a gender defined already, before spawning? :/

In theory it's so simple. If they already have a defined gender (0 or 1), then don't run the script xD
 
cucas said:
It would be so simple if what I posted above worked... I still don't understand why. don't they have a gender defined already, before spawning? :/
Yes, but you're excluding both of the defined genders with your first code and none with the second one. Only some troops are supposed to be unisex and even they don't have to be of only one gender. Any troop whose name is ambiguous enough is potentially mixed.
 
Back
Top Bottom