Author Topic: [Code] Dynamic Kingdom Troop Tree Presentation  (Read 4290 times)

0 Members and 1 Guest are viewing this topic.

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #30 on: May 04, 2012, 07:10:17 PM »
Looks unrelated. That's all mission template schtuff...



Patta

  • Sergeant Knight at Arms
  • *
    • View Profile
  • Faction: Sarranid
  • MP nick: IT_Patta_Kaiser
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #31 on: May 04, 2012, 07:32:30 PM »
Humm, I did not change anything in the mission templates since the last time I compiled. I will check what happens when I start the mod.

edit: UNexpected end of file, mission_templates.txt, yes. OK, now I just need to find out what I did wrong -.-

eswallie

  • Veteran
  • *
    • View Profile
  • Faction: Swadian
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #32 on: May 04, 2012, 07:34:29 PM »
Simply looks like you didn't add the scripts to the module_scripts file. (Or, if you did, you added them outside of the scripts = [] list)


here is an snip of my module_scripts.py

have I misinterpreted the instructions on what this file should look like?



(click to show/hide)


On a side note, when rearrangimg the mesh file...

do we insert that block of txt marked with the # # pair where it shows in that sopiler, then comment out the lines below where they normally would be?  or have i misunderstoood this section?
like so...


Snip form module_meshes.py

(click to show/hide)



EDIT:

ok I have found solutions to these problems.  The "updated" script section by Caba'drin is only a partial replacement for the original one.  You still need to add in the last sections from the OP

First the script     ("prsnt_lines_to",...
and second the section designated as  # Rubik CC's     

 These are not duplicated in Caba's post, it only covers the one script.   Amazing what debugging at some time other than 1AM can do for you.


Still a question on if I did the meshes file correctly?   or will I run into some problems down the road by doing it the way I have posted above.
« Last Edit: May 04, 2012, 08:58:26 PM by eswallie »

Patta

  • Sergeant Knight at Arms
  • *
    • View Profile
  • Faction: Sarranid
  • MP nick: IT_Patta_Kaiser
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #33 on: May 04, 2012, 07:56:32 PM »
Got it to work, the error was not related. It works fine and looks sweet, thanks.

eswallie

  • Veteran
  • *
    • View Profile
  • Faction: Swadian
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #34 on: May 06, 2012, 04:13:12 AM »
There is no "done" button on the troop tree main page

Here is how I fixed this.  If you have a better way please let me know.



(click to show/hide)

FALX

  • Sergeant Knight at Arms
  • *
  • Wyrd bið ful aræd
    • View Profile
  • Faction: Bandit
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #35 on: May 06, 2012, 10:21:34 PM »
There is no "done" button on the troop tree main page

Here is how I fixed this.  If you have a better way please let me know.



(click to show/hide)

Thank you,  eswallie .  This is what I wanted to ask. :D

eswallie

  • Veteran
  • *
    • View Profile
  • Faction: Swadian
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #36 on: May 08, 2012, 05:42:49 AM »
OK new question...  i would like this to show the mercenary tree, the sword sister tree, and the various bandits.  taiga bandits mountain bandits etc. that can be upgraded into a new unit.


i have been poking around in the code but every change i try to make to get this to work just breaks it entirely.   any help on this would be greatly appreciated.


i am sure it is an easy fix for someone  more familiar with the mod system than i.  i am more of fix it with a hammer type of  warband coder.  i need a scalpel user for this.






Looking at this again...


  #try-else block here to get 'troop-no' (or above) for non-kingdom trees
  (faction_get_slot, ":troop_no", ":culture", slot_faction_tier_1_troop),
  # lowest troop tiers initialization BEGIN
  (troop_set_slot, "trp_temp_array_a", 0, 1),           # Number of Lowest Tier Troop
  (troop_set_slot, "trp_temp_array_a", 1, 1),           # 1 for 1st troop
  (troop_set_slot, "trp_temp_array_b", 1, ":troop_no"), # 1st troop id
  # lowest troop tiers initialization END


this section of code seems to me that it is suggesting i use a try try block to get troop_no which will be the starting point for a faction...   what exactly would this try block look like?  what is it looking for?



It would seem to me that basically it is finding the id number of the troop that is the beginning troop for a faction so we have a start point to step through the tree and fill out the faction array.   but where is the starting troop for a faction defined?
« Last Edit: May 10, 2012, 07:15:10 AM by eswallie »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #37 on: May 10, 2012, 07:29:18 AM »
Quote
where is the starting troop for a faction defined?
In the game_start script, where all of the basics get set up.

For this code you want to do, you'll need to write an else block for all of the non-Faction troop trees. 

But I don't even think that's needed.  I don't think troop_get_upgrade_troop existed when this was written and probably it can be greatly shortened by simply checking to see if it returns any value other than -1, instead of manually winding through the Faction troop slot definitions.

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #38 on: May 10, 2012, 05:54:57 PM »
But I don't even think that's needed.  I don't think troop_get_upgrade_troop existed when this was written and probably it can be greatly shortened by simply checking to see if it returns any value other than -1, instead of manually winding through the Faction troop slot definitions.
?
The only faction slot definition that dunde's code uses is the first one to get the recruit troop. It then loops through uses of troop_get_upgrade_troop (an operation that has long, long been present) to generate a list of troops, by tier, in the trp_temp_array_x slots.

There are a number of places you'll need to make changes to get the non-kingdom factions in
  • "prsnt_faction_troop_tree" - need to (overlay_add_item,  "$g_presentation_obj_1" ) with the extra factions to make it an option and
  • re-work the code that goes from that overlay's value to (call_script, "script_prsnt_culture_troop_tree", ":culture"),  since the non-kingdom factions don't have a culture set, so you'll want to simply pass the faction ID
  • "script_prsnt_culture_troop_tree" - the top needs to be reworked if you want an appropriate mesh set
  • then the else-try to set up where the script should start the troop_get_upgrade_troop loops; you'll essentially want the follow:
Code: [Select]
(try_begin),
  (eq, ":culture", "fac_manhunters"),
  (troop_set_slot, "trp_temp_array_a", 0, 1),           # Number of Lowest Tier Troop
  (troop_set_slot, "trp_temp_array_a", 1, 1),           # 1 for 1st troop
  (troop_set_slot, "trp_temp_array_b", 1, "trp_FIRST_MANHUNTER_TROOP_HERE"), # 1st troop id
(else_try),
   (eq, ":culture", "fac_<whoever>"),
   #again
(else_try),
  (faction_get_slot, ":troop_no", ":culture", slot_faction_tier_1_troop),
  (troop_set_slot, "trp_temp_array_a", 0, 1),           # Number of Lowest Tier Troop
  (troop_set_slot, "trp_temp_array_a", 1, 1),           # 1 for 1st troop
  (troop_set_slot, "trp_temp_array_b", 1, ":troop_no"), # 1st troop id
(try_end),

I'm not sure how well the system will do for the mercenary tree, given that you'll need to make 2 starting troop definitions (farmer and whatever the other merc is) that then merge. To get the merging to work at all, you'd need to use my additions...but I never toyed with giving it 2 tier 1 troops, so not sure.



eswallie

  • Veteran
  • *
    • View Profile
  • Faction: Swadian
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #39 on: May 11, 2012, 12:47:06 AM »
Well in the merc tree there is "farmer" as the beginning for the normal mercs, and then "peasant woman" as the beginning for the female side.  the female troop tree also can begin with "refugee" but i an nor sure what these are, or where you find them.  to my knowledge i have never seen them in the game.  There are also some townsmen etc that jump to the mercenary tree as well.  but just getitng it to start at "farmer" is fine by me.  I would like to get the female side of the mercenary tree in as well, however they are in faction commoners as well, so that may be a bit more difficult.




another thing i had been trying is to do something like this...


in constants

(click to show/hide)



and then in scripts under ("game_start",
(click to show/hide)

and again under ("prsnt_culture_troop_tree",

(click to show/hide)

but this does not seem to work...  I have either missed something or this idea or tier_0_troop just does not work out.  I was hoping to get the bandit that leads into each faction on the presentation as well.  I am in no way an expert on warband coding, more like a total noob.  so any help on this aspect would be great as well.








Ok got it working.... mostly.

the display is a bit scrambled.  I just posted a hyperlink to he img so you can look at it full size to see what is going on.

http://dl.dropbox.com/u/75023494/mb_warband%202012-05-10%2021-40-51-22.jpg

here is the upgrade section of troops.py

(click to show/hide)
« Last Edit: May 11, 2012, 05:43:32 AM by eswallie »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #40 on: May 11, 2012, 05:30:23 AM »
Sorry Caba, you're right, it does use that operation, it just uses it in a funky way.

What I was thinking was that you'd just write out a script that iterates through every troop and for any of them that tree out, builds the rest of the data and checks for connectivity.

So, you'd go through all of the troops, looking for troop_get_upgrade_troop results other than -1; then you'd check for chaining and find the roots of all the trees.  So instead of a Swadia, you'd have a progression for trp_swadian_peasant --> trp_swadian_knight / trp_swadian_supercrossbowguy or whatever, built on the fly. 

In theory you'd just build that data one time in game_start, since that wouldn't change, but I'm fairly certain that by some straightforward optimizations such as cutting out everybody with -1, -1 results from the chaining analysis it could be made fairly fast and then it'd be nice to keep it live instead of static, so that modders could change data and then see it reflected in testing immediately.  Anyhow, I'll see if I can find some time to look at this when I'm done working on the mod instead of just jabbering about it; I think it'd be a useful piece of utility code :-)

FALX

  • Sergeant Knight at Arms
  • *
  • Wyrd bið ful aræd
    • View Profile
  • Faction: Bandit
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #41 on: May 20, 2012, 04:11:27 PM »
Is it possible to get the code under which the tree of the troops will not recruit from the same village, and according to the three types of settlements in a way that would recruit from the village a line of troop tree , from a recruit from the castle - another recruit from the city and the third line of troop  tree ?

1 recruit  village --   swordsman -....
                                            \
2 recruit castle --  mounted  varrior  -.....
                                             /
3 recruit city   --  varrior  -.....
                              \
                             guard 
                           
« Last Edit: May 20, 2012, 05:31:36 PM by FALX »

Windyplains

  • Master Knight
  • *
  • Silverstag Dev Team
    • View Profile
  • Faction: Bandit
  • WB
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #42 on: May 29, 2012, 10:53:57 AM »
With Dunde's permission I repackaged this mod into a modmerger kit and hosted it on the M&B nexus site.

This copy of it includes Caba'drin's modifications as well.

Computica

  • Master Knight
  • *
  • "Cosmic Kalypso!"
    • View Profile
  • Faction: Swadian
  • MP nick: Computica
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #43 on: June 01, 2012, 05:43:02 AM »
Woah, this is very cool, I'll see how this fairs in SoD, thanks everyone.


"The God you don't believe in does not exist"
"No need for bombs, when hate will do."

eswallie

  • Veteran
  • *
    • View Profile
  • Faction: Swadian
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #44 on: June 02, 2012, 04:40:21 AM »
Anybody ever get a chance to take  a look at the screen shot, and my upgrade path, to see if they can see what is causing the display to be scrambled like it is?