How can I make dplmc_random_mixed_gender play nice with new tf_etc options?

Users who are viewing this thread

I'm tinkering with a mod that I'm using the latest Diplomacy base for, which has a feature (if enabled) that randomises the gender of troops on the battlefield by assigning tf_male and tf_female to the troops.

I've added a new skin, tf_skeleton, using Barf's beautiful skeleton models. Works great, when I can see them. Unfortunately, the script (dplmc_random_mixed_gender) does this to them:
OU6UwT.png

Which makes sense, the script is doing exactly what it's supposed to. Unfortunately, the flesh-skeletons are extremely upsetting to me.

Here's the script in question, and my failed attempts to fix the problem:
Code:
dplmc_random_mixed_gender = (ti_on_agent_spawn, 0, 0, [
  (ge, "$g_disable_condescending_comments", 4),
],
  [
  (store_trigger_param_1, ":agent_no"),
  (agent_is_human, ":agent_no"),
  (agent_get_troop_id, ":troop_no", ":agent_no"),
  (neg|troop_is_hero, ":troop_no"),
  # (neg|troop_get_type, ":troop_no", tf_skeleton), ## Morgana - this breaks the whole code, apparently. - 24/05/23
  (is_between, ":troop_no", soldiers_begin, "trp_follower_woman", "trp_caravan_master"), #skip refugee line, town walkers
  #SB : check non-native troop genders

  #get individual faction chances
  (store_faction_of_troop, ":faction_no", ":troop_no"),
  (try_begin), #TODO: this affects the next agent to spawn as well if custom ratio skewed too high
    (agent_get_party_id, ":party_no", ":agent_no"),
    (party_is_active, ":party_no"),
    (store_faction_of_party, ":party_faction", ":party_no"),
    # (eq, ":party_faction", "$players_kingdom"),
    (call_script, "script_dplmc_get_troop_standing_in_faction", "trp_player", ":party_faction"),
    (ge, reg0, DPLMC_FACTION_STANDING_LEADER),
    (assign, ":faction_no", "fac_player_supporters_faction"),
  (try_end),
  (faction_get_slot, ":ratio", ":faction_no", slot_faction_gender_ratio),
  (store_random_in_range, ":gender", -100, ":ratio"),
  (try_begin),
    # (troop_get_type, ":troop_no", tf_skeleton), ## This ALSO breaks it
    # (troop_set_type, ":troop_no", tf_skeleton), ##
  # (else_try), ##
    (le, ":gender", 0),
    (troop_set_type, ":troop_no", tf_male),
  (else_try),
    (troop_set_type, ":troop_no", tf_female),
  (try_end),
 
  ])

I'm convinced that I'm in the right area for putting a fix, but clearly I'm not doing it right. I also really want to avoid having to fold this into the is_between, since I don't know where this skeletons are going to end up in the troop list.

Can anybody give me some guidance on what to do?
 
The neg operation does only work at operations which have true-false conditions. You need to fetch first the the troop type of the current agent and then sort out the ones which you don't want to have:
Code:
troop_get_type                           = 1506  # (troop_get_type, <destination>, <troop_id>),
                                                 # Returns troop current skin (i.e. gender).

(troop_get_type, ":troop_type", tf_skeleton),  # fetch troop type and store at local variable :troop_type
(lt, ":troop_type", tf_skeleton),              # only continue if variable is less than tf_skeleton (which should be 2)
 
I've tried putting that under the is_between, inside the two trys, above the try loop, in a new try/else above the one setting it to tf_male, and in a try_begin that wraps around the existing ones.

I've tried changing the variable around, changing it to 2 (tf_skeleton = 2 in the header file), changing to eq, then neq. Nothing works.

I don't know where this needs to go for the code to understand what I'm asking it to do, or if some part of it needs to be rewritten.

Sidebar: I don't know why the is_between has four items when the header_operations implies it should only have three.
 
I just took a more detailed look at your script and you are right that this cannot work. Here is the original script, you might have accidentally added something:

Compare it with yours and edit yours accordingly.
 
Last edited:
Ah, I see what happened.

The current version of Diplomacy has this script in it:
Code:
dplmc_random_mixed_gender = (ti_on_agent_spawn, 0, 0, [
  (ge, "$g_disable_condescending_comments", 4),
],
  [
  (store_trigger_param_1, ":agent_no"),
  (agent_is_human, ":agent_no"),
  (agent_get_troop_id, ":troop_no", ":agent_no"),
  (neg|troop_is_hero, ":troop_no"),
  (is_between, ":troop_no", soldiers_begin, "trp_follower_woman", "trp_caravan_master"), #skip refugee line, town walkers
  #SB : check non-native troop genders

  #get individual faction chances
  (store_faction_of_troop, ":faction_no", ":troop_no"),
  (try_begin), #TODO: this affects the next agent to spawn as well if custom ratio skewed too high
    (agent_get_party_id, ":party_no", ":agent_no"),
    (party_is_active, ":party_no"),
    (store_faction_of_party, ":party_faction", ":party_no"),
    # (eq, ":party_faction", "$players_kingdom"),
    (call_script, "script_dplmc_get_troop_standing_in_faction", "trp_player", ":party_faction"),
    (ge, reg0, DPLMC_FACTION_STANDING_LEADER),
    (assign, ":faction_no", "fac_player_supporters_faction"),
  (try_end),
  (faction_get_slot, ":ratio", ":faction_no", slot_faction_gender_ratio),
  (store_random_in_range, ":gender", -100, ":ratio"),
  (try_begin),
    (le, ":gender", 0),
    (troop_set_type, ":troop_no", tf_male),
  (else_try),
    (troop_set_type, ":troop_no", tf_female),
  (try_end),
 
  ])
Which is what I was working from. The mission_template file was updated in December '19, so presumably in the ~6 months since Somebody wrote the VC code, Somebody decided to change it up.

Plugged in the June '19 code, which still worked just fine. And did a bunch of stuff to it, none of which worked.
What did work, was chucking
Code:
  (neg|is_between, ":troop_no", "trp_skeglington", "trp_black_khergit_horseman"), #always skeleton   ##
under the first is_between.

Not happy with it as a solution, but it IS a solution that seems to work, so I'll take it.
 
Right, yes
The piece of code looks like this now:

Code:
dplmc_random_mixed_gender = (ti_on_agent_spawn, 0, 0, [
  (ge, "$g_disable_condescending_comments", 4),
],
[
  (store_trigger_param_1, ":agent_no"),
  (agent_is_human, ":agent_no"),
  (agent_get_troop_id, ":troop_no", ":agent_no"),
  (neg|troop_is_hero, ":troop_no"),
  (neg|is_between, ":troop_no", "trp_follower_woman", "trp_caravan_master"), #always female
  (neg|is_between, ":troop_no", "trp_skeglington", "trp_black_khergit_horseman"), #always skeleton   ## 
  #SB : check non-native troop genders

  #get individual faction chances
  (store_faction_of_troop, ":faction_no", ":troop_no"),
  (try_begin), #TODO: this affects the next agent to spawn as well if custom ratio skewed too high
    (agent_get_party_id, ":party_no", ":agent_no"),
    (party_is_active, ":party_no"),
    (store_faction_of_party, ":party_faction", ":party_no"),
    # (eq, ":party_faction", "$players_kingdom"),
    (call_script, "script_dplmc_get_troop_standing_in_faction", "trp_player", ":party_faction"),
    (ge, reg0, DPLMC_FACTION_STANDING_LEADER),
    (assign, ":faction_no", "fac_player_supporters_faction"),
  (try_end),
  (faction_get_slot, ":ratio", ":faction_no", slot_faction_gender_ratio),
  (store_random_in_range, ":gender", -100, ":ratio"),
  (try_begin),
    (le, ":gender", 0),
    (troop_set_type, ":troop_no", tf_male),
  (else_try),
    (troop_set_type, ":troop_no", tf_female),
  (try_end),
])

Seems to work great.

What are you even trying to do here? Do you want everyone to be a skeleton?

What a world that would be
 
Back
Top Bottom