Help with coding my troop tree.

Users who are viewing this thread

Nope.
They have their own faction. Faction 6 is just.... There!
It isn't used by anything. I've made my zombie faction out of them,
and I don't have any complications what so ever.


But if you want to play a safe card, maybe you should try to add your faction and culture into ID_factions.
It might help, and it might not. I'm no coder/ scripter/ mastermind so I can't be 100% sure.
But 95% at least :grin:
 
Actually, faction 6 is for bandits. :razz:
Code:
      (else_try),
        (this_or_next|eq, ":faction_no", "fac_outlaws"),
        (this_or_next|eq, ":faction_no", "fac_peasant_rebels"),
        (this_or_next|eq, ":faction_no", "fac_deserters"),
        (this_or_next|eq, ":faction_no", "fac_mountain_bandits"),
        (eq, ":faction_no", "fac_forest_bandits"),
        (assign, ":result", mtf_culture_6), #culture_6 should be tied to kingdom_6
      (else_try),
 
I think what you posted above only goes for the music cdvader.

If I add my faction into the ID, what number shouls I use? Just any unused number?
 
Code:
fac_no_faction = 0
fac_commoners = 1
fac_outlaws = 2
fac_neutral = 3
fac_innocents = 4
fac_merchants = 5
fac_dark_knights = 6
fac_culture_1 = 7
fac_culture_2 = 8
fac_culture_3 = 9
fac_culture_4 = 10
fac_culture_5 = 11
fac_culture_empire = 12
fac_holy_empire = 13
fac_player_faction = 14
fac_player_supporters_faction = 15
fac_kingdom_1 = 16
fac_kingdom_2 = 17
fac_kingdom_3 = 18
fac_kingdom_4 = 19
fac_kingdom_5 = 20
fac_kingdoms_end = 21
fac_robber_knights = 22
fac_khergits = 23
fac_black_khergits = 24
fac_manhunters = 25
fac_deserters = 26
fac_mountain_bandits = 27
fac_forest_bandits = 28
fac_undeads = 29
fac_slavers = 30
fac_peasant_rebels = 31
fac_noble_refugees = 32

It was added automatically I suppose.
 
Still doesn't work, and no I haven't touched faction_6 or culture_6, was that way. Does it have anything to say?

EDIT: Looked at how SoD handled it, and changed a couple of things. Will see if it works now, wish me luck.  :roll:

EDIT2: Damn, still doesn't work.

EDIT3: Could it work if I used TheMageLord's tweak to make recruitment based on ownership of village?

Code:
 ("update_volunteer_troops_in_village",
    [
       (store_script_param, ":center_no", 1),
       (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
       (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
       (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
       (assign, ":volunteer_troop_tier", 1),
       (store_div, ":tier_upgrades", ":player_relation", 10),
       (try_for_range, ":unused", 0, ":tier_upgrades"),
         (store_random_in_range, ":random_no", 0, 100),
         (lt, ":random_no", 10),
         (store_random_in_range, ":random_no", 0, 2),
         (troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", ":random_no"),
         (try_begin),
           (le, ":upgrade_troop_no", 0),
           (troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", 0),
         (try_end),
         (gt, ":upgrade_troop_no", 0),
         (val_add, ":volunteer_troop_tier", 1),
         (assign, ":volunteer_troop", ":upgrade_troop_no"),
       (try_end),
       
       (assign, ":upper_limit", 7),
       (try_begin),
         (ge, ":player_relation", 5),
         (assign, ":upper_limit", ":player_relation"),
         (val_div, ":upper_limit", 2),
         (val_add, ":upper_limit", 10),
       (else_try),
         (lt, ":player_relation", 0),
         (assign, ":upper_limit", 0),
       (try_end),

       (val_mul, ":upper_limit", 3),   
       (store_add, ":amount_random_divider", 2, ":volunteer_troop_tier"),
       (val_div, ":upper_limit", ":amount_random_divider"),
       
       (store_random_in_range, ":amount", 0, ":upper_limit"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":volunteer_troop"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_amount, ":amount"),
     ]),

What would I have to change here to implement this tweak?

I assume I'd have to change this text in some way? What way?

      (store_script_param, ":center_no", 1),
      (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
      (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
      (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),

Would it work if I changed it to this?

      (store_script_param, ":center_no", 1),
      (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
      (party_get_slot, ":faction_culture", ":center_no", slot_center_culture),
      (faction_get_slot, ":volunteer_troop", ":faction_culture", slot_faction_tier_1_troop),

I'm not good at python scripting, but I think that should reference the faction culture instead?

EDIT4: Dang! That didn't work either...I'm stumped, can anyone tell me what I did wrong above, or show me some other way of doing it? I'm getting really desperate here. Please!
 
Anything in a file prefixed with "ID_" is something that the module system generates automagically when compiling.  You should only have to modify this is if you're doing self-referential trickery (I do some of this, but no one else should ever have to.) 

I've kind of lost track of what the actual question is with all the edits and running dialog, but if all you're trying to do is change the recruits to be of a specific type when the player has their own faction, I'd look to do something like this:
("village_recruit_volunteers_recruit",
[
(party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
(party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
(try_begin),
(eq, "$players_kingdom", "fac_your_faction_here"),
(faction_get_slot, ":volunteer_troop", "fac_your_factions_culture_here", slot_faction_tier_1_troop),
(try_end),

(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(val_min, ":volunteer_amount", ":free_capacity"),
(store_troop_gold, ":gold", "trp_player"),
(store_div, ":gold_capacity", ":gold", 10),#10 denars per man
(val_min, ":volunteer_amount", ":gold_capacity"),
(party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
(party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
(store_mul, ":cost", ":volunteer_amount", 10),#10 denars per man
(troop_remove_gold, "trp_player", ":cost"),
]),

You could do more trickery than that and I'd probably put a few more checks in for correctness.  Also remember that faction slots on cultures are filled out at game_start time so they won't magically appear in save games unless you write code to set them.  If you don't want to hack around with the slot values, you could also do this:
("village_recruit_volunteers_recruit",
[
(party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
(party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
(try_begin),
(eq, "$players_kingdom", "fac_your_faction_here"),
(assign, ":volunteer_troop", "trp_your_new_troop_here"),
(try_end),

(party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
(val_min, ":volunteer_amount", ":free_capacity"),
(store_troop_gold, ":gold", "trp_player"),
(store_div, ":gold_capacity", ":gold", 10),#10 denars per man
(val_min, ":volunteer_amount", ":gold_capacity"),
(party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
(party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
(store_mul, ":cost", ":volunteer_amount", 10),#10 denars per man
(troop_remove_gold, "trp_player", ":cost"),
]),

 
hmmmm, mabye instead of *****ing about the MS in every thread that asked questions about troop editor go back and get troop editor, it really is the way to go.
making / changing factions is easy with notepad, troop editor, and map editor.
 
What would I have to change here to implement this tweak?
Mine is simple, ugly, but works.
Within the code of "#script_update_volunteer_troops_in_village", I insert the below code. The first else_try commented out was there for my future feature. I don't even know if it will work. However, the first part that change the volunteer troop according to the owner faction is working fine. The second esle_try is the Native code.
Code:
("update_volunteer_troops_in_village",
	[
	(store_script_param, ":center_no", 1),
	(party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),

# Spd - Script change volunteer troop to player faction	   
	(try_begin),
	  (party_slot_eq, ":center_no", slot_town_lord, "trp_player"),
	  (eq, "$player_has_homage", 1),
	  (assign, ":center_faction", "$players_kingdom"),
	  (faction_get_slot, ":center_culture", ":center_faction", slot_faction_culture),
	#(else_try),
	  #(party_slot_eq, ":center_no", slot_town_lord, "trp_player"),
	  #(eq, "$players_kingdom", "fac_player_faction"),
	  #(faction_get_slot, ":center_culture", ":center_faction", slot_faction_culture),
	(else_try),
# Spd - Script end (resume Native code below)

	  (party_get_slot, ":center_culture", ":center_no", slot_center_culture),   #Spd - Native Original code
	(try_end),
	(faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
	(assign, ":volunteer_troop_tier", 1),
 
Nice, thanks! skiddledou, making factions isn't that hard, the hard part is code, which would be way harder without the MS.

SPD Phoenix, the (eq, "$player_has_homage", 1), part of your code, wouldn't that require the player to be a vassal?
 
It is. It's supposed to be a 3 parts script. The first part is when player is a vassal of a faction. The second part commented out is when player has own faction (not supporting a claimant).
 
So it would make sense to uncomment the second part?  :mrgreen: BTW, shouldn't the (eq, "$players_kingdom", "fac_player_faction") be player_supporters_faction instead? Especially using Highlanders kingdom management.
 
I don't know.

fac_player_support_faction = claimant?

fac_player_faction = player own faction?

I haven't gone far into creating player own faction yet. That's why I commented out those lines. I'm still busy checking the AI part of my own kingdom management.
 
Back
Top Bottom