User Info
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 02, 2010, 08:06:55 PM

Login with username, password and session length
Search:     Advanced search
News Box
New M&B Version

1.010 is out, and so is the module system. Get modding!

Key Stats
51617 Posts in 2003 Topics by 4425 Members
Latest Member: lovely13
Home Help Search Login Register
M&B Mod Community  |  About Modding  |  Discussion (Moderator: Fisheye)  |  Unit Selector
Pages: [1] Print
Author Topic: Unit Selector  (Read 632 times)
grailknighthero
Craftsman
**
Offline Offline

Posts: 141


View Profile Email
« on: July 01, 2008, 04:49:58 PM »

Ok, on my topic at taleworlds found here on pages 13-16, I am working on a custom battle mod that will feature more than 1 unit.  It is possible as you can tell if you look at the screen shots.  I am having a problem selecting player units though.  The text only shows that the first and last unit is being selected (so any in between are being skipped).  The other problem is that when I tell the unit to hold (the last), the first unit moves, even if the last unit is selected.

Here are my message displays if I hit u twice and then h:
Peasant Bowmen Unit 1 selected
Man-at-arms Unit 3 selected
2
52 (because the 3rd unit slot number is 52, unit 1 50, unit 2 51)
Unit moving to hold position

So even though it shows that the 3rd unit is selected, the first unit moves.  The only thing that I can think of, is that there is a problem with how I am assigning unit leaders, and if so Ill have to post that code, and that will be a pain to look at.  If you need more info tell me...

Code: [Select]
# select unit
      (0, 0, 0,
      [(key_clicked, key_u),        #u for next unit
      ],
      [
      (assign, "$qb_us", 1),
      (val_add, "$qb_unit_tracker", 1),
      (store_add, ":tracker", "$qb_unit_tracker", slot_scene_unit1),
      (try_begin),
           (scene_slot_eq,"$quick_battle_map",":tracker",0),
           (assign, "$qb_unit_tracker", 0),
           (store_add, ":tracker", "$qb_unit_tracker", slot_scene_unit1),
       (try_end),
       (scene_get_slot,":unit","$quick_battle_map",":tracker"),
       (item_get_slot,":troop_id",":unit",slot_item_unit_troop1),
       (item_get_slot,":unit_no",":unit",slot_item_unit_no),
       (assign, reg35, ":unit_no"),
       (str_store_troop_name,s35,":troop_id"),
       (display_message, "@{s35} Unit {reg35}"),
      ]),

# unit hold
(0, 0, 0,
      [(key_clicked, key_h), # h for hold
       (try_begin),
           (neq, "$qb_us", 1),
           (display_message, "@No unit selected"),
       (try_end),
       (eq, "$qb_us", 1),
      ],
      [
      (assign, reg45, "$qb_unit_tracker"),
      (display_message, "@qb tracker: {reg45}"),
      (store_add, ":tracker", "$qb_unit_tracker", slot_scene_unit1),
      (assign, reg45, ":tracker"),
      (display_message, "@qb tracker: {reg45}"),
      (scene_get_slot,":unit","$quick_battle_map", ":tracker"),
      (item_get_slot,":unit_leader",":unit",slot_item_unit_leader),
      (get_player_agent_no,":player_a_no"),
      (agent_get_position,pos36,":player_a_no"),
      (agent_clear_scripted_mode,":unit_leader"),
      (agent_set_scripted_destination,":unit_leader",pos36,1),
      (display_message, "@Unit moving to hold position"),
      (item_set_slot,"$qb_unit_selected",slot_item_unit_order,mordr_hold),
     
      (position_get_x,":x",pos36),
      (position_get_y,":y",pos36),
      (position_get_z,":z",pos36),

      (item_set_slot,"$qb_unit_selected",slot_item_unit_order_position_x,":x"),
      (item_set_slot,"$qb_unit_selected",slot_item_unit_order_position_y,":y"),
      (item_set_slot,"$qb_unit_selected",slot_item_unit_order_position_z,":z"),
      ]),
      # end commands
« Last Edit: July 01, 2008, 06:28:06 PM by grailknighthero » Logged
grailknighthero
Craftsman
**
Offline Offline

Posts: 141


View Profile Email
« Reply #1 on: July 02, 2008, 05:04:31 PM »

I've fixed most of it, except for the problems I describe here.[/here]
Logged
Pages: [1] Print 
Jump to:  

Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Arcane Magic based on BlackDay by TechnoDragon.net | Buttons by Andrea