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

0 Members and 1 Guest are viewing this topic.

dunde

  • Count
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
[Code] Dynamic Kingdom Troop Tree Presentation
« on: January 21, 2012, 04:43:32 PM »
Presentation to display Troop Tree like Rubik made for Custom Commander 's proved very useful for players.
The problem is for mods that have different factions or different troop trees from Native, we must make the troop trees for them one by one and to adjust the diagram positions is a boring and time consuming activity.
The solution is a generic presentation that read the troop upgrade from 1st tier of every faction and draw the diagram automatically.
Here's my trial to make it.
(click to show/hide)
(click to show/hide)

Issues :
- The code has not been optimized, even I am not interested in doing it because of this presentation will be called from the report menu where performance is not an issue.
- It has no support yet for troops that can be upgraded from more than 1 troop. (Caba's improved version on page 2 has support for this case).
- Limited Support to max 6 tiers and max 4 branches (visually)
- Limited Support to max 10 tiers and max 10 branches (data structure)


Credits :
- rubik, for the original idea and the script execute the drawing.

Windyplains' modmerger kit (with Caba's modification included) :
http://mountandblade.nexusmods.com/mods/3682

EDIT :
- Adding missing get_troop_max_hp and copy_inventory script and import declaration. Thanks to Dawg of War and Lav for pointing those.
- Diplomacy  has CC included, so  scripts from CC 's already on the it's Module System, but some of them have dplmc_ prefix.
« Last Edit: May 30, 2012, 01:53:01 AM by dunde »

Caba`drin

  • Dovie'andi se tovya sagain
  • Forum Legend
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • WBM&BWF&SNWVC
Re: [OSP] Dynamic Kingdom Troop Tree Presentation
« Reply #1 on: January 21, 2012, 04:47:22 PM »
Awesome, thanks as always dunde.



NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #2 on: January 21, 2012, 06:14:57 PM »
I don't know where to add this:Code: (rearrage mesh, so we can iterate them by faction)

dunde

  • Count
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #3 on: January 21, 2012, 06:40:11 PM »
I don't know where to add this:Code: (rearrage mesh, so we can iterate them by faction)

Edit module_meshes.py. You must rearrange these meshes :
  ("pic_swad", 0, "pic_swad", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_vaegir", 0, "pic_vaegir", 0, 0, 0, 0, 0, 0, 1, 1, 1), 
  ("pic_khergit", 0, "pic_khergit", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_nord", 0, "pic_nord", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_rhodock", 0, "pic_rhodock", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_sarranid_encounter", 0, "pic_sarranid_encounter", 0, 0, 0, 0, 0, 0, 1, 1, 1),

At native Module System, they are not ordered properly. I don't like long try_else checks so I decided to rearrange the meshes.

Lav

  • Sergeant Knight at Arms
  • *
    • Skype - Eleyvie
    • Steam - eleyvie
    • View Profile
    • Lav's Warband Workshop
  • Faction: Vaegir
  • MP nick: Lav
  • M&BWB
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #4 on: January 21, 2012, 06:59:21 PM »
That's a great work!

A pity it doesn't support trees with merging upgrade lines, but when I think about this, it seems there's no way to automate the layout of such a troop tree (and it can even be impossible in some cases).

Either way, a great contribution!

NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #5 on: January 21, 2012, 08:33:04 PM »
I don't know where to add this:Code: (rearrage mesh, so we can iterate them by faction)

Edit module_meshes.py. You must rearrange these meshes :
  ("pic_swad", 0, "pic_swad", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_vaegir", 0, "pic_vaegir", 0, 0, 0, 0, 0, 0, 1, 1, 1), 
  ("pic_khergit", 0, "pic_khergit", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_nord", 0, "pic_nord", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_rhodock", 0, "pic_rhodock", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_sarranid_encounter", 0, "pic_sarranid_encounter", 0, 0, 0, 0, 0, 0, 1, 1, 1),

At native Module System, they are not ordered properly. I don't like long try_else checks so I decided to rearrange the meshes.
Thanks, and hope it work  :D

NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #6 on: January 21, 2012, 08:42:02 PM »
I don't know where to add this:Code: (rearrage mesh, so we can iterate them by faction)

Edit module_meshes.py. You must rearrange these meshes :
  ("pic_swad", 0, "pic_swad", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_vaegir", 0, "pic_vaegir", 0, 0, 0, 0, 0, 0, 1, 1, 1), 
  ("pic_khergit", 0, "pic_khergit", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_nord", 0, "pic_nord", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_rhodock", 0, "pic_rhodock", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("pic_sarranid_encounter", 0, "pic_sarranid_encounter", 0, 0, 0, 0, 0, 0, 1, 1, 1),

At native Module System, they are not ordered properly. I don't like long try_else checks so I decided to rearrange the meshes.
Thanks, and hope it work  :D
Some problem:
(click to show/hide)

Lav

  • Sergeant Knight at Arms
  • *
    • Skype - Eleyvie
    • Steam - eleyvie
    • View Profile
    • Lav's Warband Workshop
  • Faction: Vaegir
  • MP nick: Lav
  • M&BWB
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #7 on: January 21, 2012, 08:51:27 PM »
Add the line
Code: [Select]
from header_presentations import *At the beginning of the module_scripts.py file.

The Real Slate

  • Master Knight
  • *
  • When you conquer fear of death, you start to live.
    • Steam - therealslate
    • View Profile
    • Insanity's Finest Discord
  • Faction: Neutral
  • MP nick: Sir Slate
  • M&BWBWF&S
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #8 on: January 21, 2012, 10:43:29 PM »
Plus if you happen to have Diplomacy implemented in your source you may need to change, (call_script, "script_get_troop_max_hp", "$temp"), to (call_script, "script_dplmc_get_troop_max_hp", "$temp"),

and..(call_script, "script_copy_inventory", "$temp", "trp_temp_array_a"), to (call_script, "script_dplmc_copy_inventory", "$temp", "trp_temp_array_a"),

In the module_presentations code he provided.

NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #9 on: January 22, 2012, 01:11:13 PM »
Still not work  :(

dunde

  • Count
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #10 on: January 22, 2012, 01:38:42 PM »
Still not work  :(

Put this at the top of module_constants.py :
Code: [Select]
from ID_troops import *
from ID_parties import *
from ID_animations import *
from header_skills import *
from header_troops import *
from header_triggers import *

NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #11 on: January 22, 2012, 02:10:36 PM »
Yahoo!!!! IT WORK!!!

NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #12 on: January 22, 2012, 02:17:30 PM »
Yahoo!!!! IT WORK!!!

One more thing. how can i edit the red word "Faction's Troop Tree"

dunde

  • Count
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #13 on: January 22, 2012, 02:33:08 PM »
Great. I'm glad you made it.

("faction_troop_tree", "Faction's Troop Tree"),

Change the right string as you want. If you want to use another color,
change the constants :
title_red     = 0xFF0000 ## FF0000 is red

Wait. How can your troop tree has 3 braches from tier 3 to tier 4?

Would you like to send me your upgrading declaration from your module_troops.py please?
You might just found  a bug of this presentation.
« Last Edit: January 22, 2012, 02:44:39 PM by dunde »

NewBie-BR

  • Veteran
  • *
  • L12SQ
    • View Profile
  • Faction: Swadian
Re: [Code] Dynamic Kingdom Troop Tree Presentation
« Reply #14 on: January 22, 2012, 03:29:27 PM »
Great. I'm glad you made it.

("faction_troop_tree", "Faction's Troop Tree"),

Change the right string as you want. If you want to use another color,
change the constants :
title_red     = 0xFF0000 ## FF0000 is red

Wait. How can your troop tree has 3 braches from tier 3 to tier 4?

Would you like to send me your upgrading declaration from your module_troops.py please?
You might just found  a bug of this presentation.
I use Morgh to edit my troop tree.