Author Topic: Troop Ratio Bar  (Read 3594 times)

0 Members and 1 Guest are viewing this topic.

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Troop Ratio Bar
« on: December 18, 2008, 03:52:29 PM »
Hello, everyone. I have created a Troop Ratio Bar.  In battle, the Troop Ratio Bar displays the amount of troops remaining for each participating side in battle (green for your troops, blue for allied troops, and red for enemy troops.), you can remove the bar by pressing "O" and call up the minimap by pressing "O" again.

Source code:

Paste the following into module_presentations.py:
Code: [Select]
##################################################
##### troop_ratio_bar
##################################################
  ("troop_ratio_bar",prsntf_read_only,0,[
      (ti_on_presentation_load,
       [
        (assign, "$presentation_troop_ratio_bar_active", 1),
        (set_fixed_point_multiplier, 1000),
       
        (create_mesh_overlay, "$g_presentation_obj_1", "mesh_status_troop_ratio_bar"),
        (position_set_x, pos1, 30),
        (position_set_y, pos1, 700),
        (overlay_set_position, "$g_presentation_obj_1", pos1),
       
        (position_set_x, pos1, 35),
        (position_set_y, pos1, 713),
       
        (create_mesh_overlay, "$g_presentation_obj_2", "mesh_white_plane"),
        (overlay_set_color, "$g_presentation_obj_2", 0xAA1F1F),
        (overlay_set_position, "$g_presentation_obj_2", pos1),
       
        (create_mesh_overlay, "$g_presentation_obj_3", "mesh_white_plane"),
        (overlay_set_color, "$g_presentation_obj_3", 0x1F1FAA),
        (overlay_set_position, "$g_presentation_obj_3", pos1),
     
        (create_mesh_overlay, "$g_presentation_obj_4", "mesh_white_plane"),
        (overlay_set_color, "$g_presentation_obj_4", 0x1FAA1F),
        (overlay_set_position, "$g_presentation_obj_4", pos1),
       
        (create_mesh_overlay, "$g_presentation_obj_5", "mesh_status_troop_ratio_bar_button"),
        (position_set_x, pos1, 35),
        (position_set_y, pos1, 700),
        (overlay_set_position, "$g_presentation_obj_5", pos1),
       
        (create_mesh_overlay, "$g_presentation_obj_6", "mesh_status_troop_ratio_bar_button"),
        (position_set_x, pos1, 275),
        (position_set_y, pos1, 700),
        (overlay_set_position, "$g_presentation_obj_6", pos1),

        (create_mesh_overlay, "$g_presentation_obj_7", "mesh_status_troop_ratio_bar_button"),
        (create_mesh_overlay, "$g_presentation_obj_8", "mesh_status_troop_ratio_bar_button"),
       
        (presentation_set_duration, 999999),
       ]),
      (ti_on_presentation_run,
       [
        (store_trigger_param_1, ":cur_time"),
       
        (set_fixed_point_multiplier, 1000),
        (assign, ":player_count", 0),
        (assign, ":ally_count", 0),
        (assign, ":enemy_count", 0),
        (assign, ":total_count", 0),
       
        (try_for_agents, ":cur_agent"),
          (agent_is_human, ":cur_agent"),
          (agent_is_alive, ":cur_agent"),
          (agent_get_party_id, ":agent_party", ":cur_agent"),
          (try_begin),
            (eq, ":agent_party", "p_main_party"),
            (val_add, ":player_count", 1),
          (else_try),
            (agent_is_ally, ":cur_agent"),
            (val_add, ":ally_count", 1),
          (else_try),
            (val_add, ":enemy_count", 1),
          (try_end),
        (try_end),
        (val_add, ":total_count", ":player_count"),
        (val_add, ":total_count", ":ally_count"),
        (val_add, ":total_count", ":enemy_count"),

        (position_set_x, pos1, 12000),
        (position_set_y, pos1, 300),
        (overlay_set_size, "$g_presentation_obj_2", pos1),
     
        (store_add, ":ally_percent", ":player_count", ":ally_count"),
        (val_mul, ":ally_percent", 12000),
        (val_div, ":ally_percent", ":total_count"),
        (position_set_x, pos1, ":ally_percent"),
        (position_set_y, pos1, 300),
        (overlay_set_size, "$g_presentation_obj_3", pos1),
     
        (store_mul, ":player_percent", ":player_count", 12000),
        (val_div, ":player_percent", ":total_count"),
        (position_set_x, pos1, ":player_percent"),
        (position_set_y, pos1, 300),
        (overlay_set_size, "$g_presentation_obj_4", pos1),
       
        (store_add, ":ally_percent_2", ":player_count", ":ally_count"),
        (val_mul, ":ally_percent_2", 240),
        (val_div, ":ally_percent_2", ":total_count"),
        (val_add, ":ally_percent_2", 35),
        (position_set_x, pos1, ":ally_percent_2"),
        (position_set_y, pos1, 700),
        (overlay_set_position, "$g_presentation_obj_7", pos1),
       
        (store_mul, ":player_percent_2", ":player_count", 240),
        (val_div, ":player_percent_2", ":total_count"),
        (val_add, ":player_percent_2", 35),
        (position_set_x, pos1, ":player_percent_2"),
        (position_set_y, pos1, 700),
        (overlay_set_position, "$g_presentation_obj_8", pos1),
       
        (try_begin),
          (eq, "$presentation_troop_ratio_bar_active", 1),
          (gt, ":cur_time", 200),
          (game_key_clicked, gk_view_orders),
          (assign, "$presentation_troop_ratio_bar_active", 0),
          (presentation_set_duration, 0),
          (start_presentation, "prsnt_battle"),
        (try_end),
       ]),
       
     ]),
##################################################
##### troop_ratio_bar
##################################################

Search "(assign, "$g_presentation_battle_active", 0)," in module_presentations.py, then insert the line as following:

Code: [Select]
       (try_begin),
          (gt, ":cur_time", 200),
          (game_key_clicked, gk_view_orders),
          (assign, "$g_presentation_battle_active", 0),
          (try_for_agents, ":cur_agent"),
            (agent_set_slot, ":cur_agent", slot_agent_map_overlay_id, 0),
          (try_end),
          (presentation_set_duration, 0),
##################################################
##### troop_ratio_bar
##################################################
          (start_presentation, "prsnt_troop_ratio_bar"),
##################################################
##### troop_ratio_bar
##################################################
        (try_end),

Paste the following into module_meshes.py:
Code: [Select]
##################################################
##### troop_ratio_bar
##################################################
  ("status_troop_ratio_bar", 0, "slider_hor", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("status_troop_ratio_bar_button", 0, "handle_hor", 0, 0, 0, 0, 0, 0, 1, 1, 1),
##################################################
##### troop_ratio_bar
##################################################

The following into any applicable mission template, usually the troop ratio bar need to be add into any mission template which you can call up the command interface by pressing "O". So search "common_battle_order_panel," in module_mission_templates.py, then add the following near it.
Code: [Select]
##################################################
##### troop_ratio_bar
##################################################
      (0, 0, ti_once, [], [(start_presentation, "prsnt_troop_ratio_bar")]),
##################################################
##### troop_ratio_bar
##################################################

Screenshot:


« Last Edit: December 18, 2008, 05:19:32 PM by rubik »

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
Re: Troop Ratio Bar
« Reply #1 on: December 18, 2008, 04:49:14 PM »
wow, that is very cool, nice work.   Could you post an example of a screenshot at the start of battle and then after several minutes of fighting?   I'm curious to see how the bars change during battle (bars get smaller, bar stays the same size but color goes away, etc)

EDIT:  thanks, very cool!
« Last Edit: December 18, 2008, 11:37:12 PM by HokieBT »
 

Ruthven

  • Revs lil' helper
  • Grandmaster Knight
  • *
  • crushie crushie crushie
    • View Profile
  • Faction: Neutral
  • MP nick: irc://Ruthven
Re: Troop Ratio Bar
« Reply #2 on: December 18, 2008, 10:13:23 PM »
Looks cool. I may use it.

Keedo420

  • Knight at Arms
  • *
  • All glory to the Hypnotoad!!
    • View Profile
    • All glory to the Hypnotoad!
  • Faction: Bandit
Re: Troop Ratio Bar
« Reply #3 on: December 18, 2008, 10:19:47 PM »
Definitely nice work.  :D How do reinforcements affect the bar? Do they show up on it before or after they spawn?

Kleidophoros

  • Administrator
  • *
    • View Profile
  • Faction: Rhodok
  • MP nick: CoR_Kleid_of_Veluca
  • M&BWB
Re: Troop Ratio Bar
« Reply #4 on: December 18, 2008, 10:34:54 PM »

wow, that is very cool, nice work.   Could you post an example of a screenshot at the start of battle and then after several minutes of fighting?   I'm curious to see how the bars change during battle (bars get smaller, bar stays the same size but color goes away, etc)
seeing its a ratio bar i suppose sliders move left right to represent the uhm..ratio..?
I have been away for some 6 months and will be for another 6 months or maybe a year. Don't pm me if you need an urgent reply.
I might see your email though if you are that desperate.

"Al esfuerzo y al heroísmo de una revolución. ¡No los queremos! ¡No los necesitamos!"


rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: Troop Ratio Bar
« Reply #5 on: December 19, 2008, 05:43:35 PM »
Definitely nice work.  :D How do reinforcements affect the bar? Do they show up on it before or after they spawn?

It will be Rendered in real-time.

Kiado

  • Regular
  • *
    • View Profile
  • Faction: Swadian
Re: Troop Ratio Bar
« Reply #6 on: December 19, 2008, 05:45:06 PM »
Very nice work.  I like that. 
Team Lead- Castle Black Mod Team - A Song of Ice and Fire Mod for M&B 1.011
Work is under way on a new version, redone from the ground up, for M&B 1.x.  Come visit the boards!

Kolba

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Kolba
Re: Troop Ratio Bar
« Reply #7 on: December 19, 2008, 05:53:46 PM »
I like it.  :)

wwwyyy12350

  • Recruit
  • *
    • View Profile
  • Faction: Neutral
Re: Troop Ratio Bar
« Reply #8 on: December 27, 2008, 01:07:21 PM »
Nice work!master~

aronccs

  • Squire
  • *
  • I came, I saw, I conquer
    • View Profile
    • Facebook of mine
  • Faction: Neutral
  • MP nick: aronccs
Re: Troop Ratio Bar
« Reply #9 on: October 27, 2011, 04:14:09 AM »
can't  find "(assign, "$g_presentation_battle_active", 0)," in module_presentations.py

Belendor Torheal Artendor

  • Master Knight
  • *
  • "World is same only less in it..."
    • View Profile
    • Olympus Studios
  • Faction: Nord
  • MP nick: CoR _Belendor
  • WBWF&S
Re: Troop Ratio Bar
« Reply #10 on: November 24, 2011, 03:58:33 PM »
Well, it is pretty much outdated. Should be easy to port, though.

dia151

  • Squire
  • *
    • View Profile
  • Faction: Bandit
  • MP nick: Bandit_Gazda_the_Swine
  • WB
Re: Troop Ratio Bar
« Reply #11 on: December 01, 2011, 04:28:52 PM »
Does this work in multiplayer too?