Author Topic: export/import NPCs - source code released  (Read 17119 times)

0 Members and 1 Guest are viewing this topic.

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
export/import NPCs - source code released
« on: April 08, 2009, 01:13:53 AM »
Incidentally I found that when a NPC do as the commander in battles, you can export/import him/her just like the player in my MOD Custom Commander.

There is some code below to implement it in a menu, no need to enter a scene any more.

I just insert the menu option in the menu "camp_action", in fact you can insert it in any menu you like.
Quote
........................
........................

      ("action_read_book",[],"Select a book to read.",
       [(jump_to_menu,
"mnu_camp_action_read_book"),
        ]
       ),
#### export/import NPCs begin ####
     
("action_export_import",[],"Export/import NPCs.",
        [
          (jump_to_menu,
"mnu_export_import_npcs"),
        ]
      ),
#### export/import NPCs end ####
     
("action_modify_banner",[(eq, "$cheat_mode", 1)],"Cheat: Modify your banner.",
       [
           (start_presentation, "prsnt_banner_selection"),
           
#(start_presentation, "prsnt_custom_banner"),
       
]
       ),

........................
........................


These two menus below can be added anywhere.
Quote
#### export/import NPCs begin ####
 
("export_import_npcs", mnf_enable_hot_keys,
   
"Please choose an NPC, then press key C to view and export/import this character.^^You choose {reg0?{s0}:none}.",
   
"none",
    [
      (assign, reg0,
"$g_player_troop"),
      (str_store_troop_name, s0,
"$g_player_troop"),
    ],
    [
      (
"export_import_back",[],"Go back",
        [
          (assign,
"$g_player_troop", "trp_player"),
          (set_player_troop,
"$g_player_troop"),
          (jump_to_menu,
"mnu_camp_action"),
        ]
      ),
    ]+[(
"export_import_npc"+str(x+1),
        [
          (store_add,
":dest_npc", "trp_npc1", x),
          (str_store_troop_name, s0,
":dest_npc"),
        ],
"{s0}",
        [
          (store_add,
":dest_npc", "trp_npc1", x),
          (assign,
"$g_player_troop", ":dest_npc"),
          (set_player_troop,
"$g_player_troop"),
        ])
for x in range(0, 8)]+[
      (
"export_import_next",[],"Next page", [(jump_to_menu, "mnu_export_import_npcs_2")]),
    ]
  ),
 
  (
"export_import_npcs_2", mnf_enable_hot_keys,
   
"Please choose an NPC, then press key C to view and export/import this character.^^You choose {reg0?{s0}:none}.",
   
"none",
     [
       (assign, reg0,
"$g_player_troop"),
       (str_store_troop_name, s0,
"$g_player_troop"),
     ],
    [
      (
"export_import_prev",[],"Previous page", [(jump_to_menu, "mnu_export_import_npcs")]),
    ]+[(
"export_import_npc"+str(x+1),
      [
        (store_add,
":dest_npc", "trp_npc1", x),
        (str_store_troop_name, s0,
":dest_npc"),
      ],
"{s0}",
      [
        (store_add,
":dest_npc", "trp_npc1", x),
        (assign,
"$g_player_troop", ":dest_npc"),
        (set_player_troop,
"$g_player_troop"),
      ])
for x in range(8, 16)]
  ),
#### export/import NPCs end ####
« Last Edit: December 29, 2009, 11:56:06 AM by rubik »

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: export/import NPC
« Reply #1 on: April 08, 2009, 01:21:53 AM »
What's the filename that it goes out to?

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: export/import NPC
« Reply #2 on: April 08, 2009, 01:26:53 AM »
just like Borcha.txt, Rolf.txt...

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: export/import NPC
« Reply #3 on: April 08, 2009, 01:29:06 AM »
Awesome.... looks like you can import your whole party! Does this work in menu or do you have to be in a scene?

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: export/import NPC
« Reply #4 on: April 08, 2009, 01:35:28 AM »
No need in a scene, it can be also done in a menu with the following key function:
(set_player_troop,<troop_id>),

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&BWB
Re: export/import NPC
« Reply #5 on: April 08, 2009, 04:58:33 AM »

well damn, that is cool.  here we were looking into hex editing saved game files so we could edit companions (and other stuff) and you figure out a way to just export/import them with a new menu system....   :)    this is very interesting, thx.
 
PC Gamer - "Uninstall KOTOR. Forget TIE Fighter and Star Wars Battlefront. There is only one Star Wars video game, and it's an unfinished mod for a six-year-old medieval RPG built by an indie studio from Turkey."

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: export/import NPCs - source code released
« Reply #6 on: April 12, 2009, 11:24:58 AM »
source code released.

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: export/import NPCs - source code released
« Reply #7 on: April 23, 2009, 05:51:11 AM »
add some simple instruction inside the menus instead the string "Export/import npcs". now you know how to operate it.

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&BWB
Re: export/import NPCs - source code released
« Reply #8 on: April 23, 2009, 06:03:50 AM »
I had previous added this (thanks!) so just updated the new line.   The "You choose" doesn't seem to be working correctly, it always displays the last name on each page when you click on it?

edit:   adding  (str_store_troop_name, s0, "trp_npc1") to each section looks like it would fix it when I did a quick test....  But when you go to the character screen and then click done, it will just display the work "none" and regardless of what you click on it won't display the npc name again.   Anyway, just though I'd let you know, this really is great tho, very handy.
« Last Edit: April 23, 2009, 06:09:16 AM by HokieBT »
 
PC Gamer - "Uninstall KOTOR. Forget TIE Fighter and Star Wars Battlefront. There is only one Star Wars video game, and it's an unfinished mod for a six-year-old medieval RPG built by an indie studio from Turkey."

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: export/import NPCs - source code released
« Reply #9 on: April 23, 2009, 06:35:42 AM »
I have not the problem, it always works right. maybe it is needed to assign "trp_player" to "$g_player_troop" before entering the menu of export/import NPCs.

Quote
#### export/import NPCs begin ####
     
("action_export_import",[],"Export/import NPCs.",
        [
          (assign,
"$g_player_troop", "trp_player"),
          (jump_to_menu,
"mnu_export_import_npcs"),
        ]
      ),
#### export/import NPCs end ####

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&BWB
Re: export/import NPCs - source code released
« Reply #10 on: April 23, 2009, 01:09:12 PM »

I re-pasted your code and started a new game and it worked fine, sorry, i should have tried that before.

I think your latest code is a good idea as well since i am also using your custom commander, so i added that, thanks!
 
PC Gamer - "Uninstall KOTOR. Forget TIE Fighter and Star Wars Battlefront. There is only one Star Wars video game, and it's an unfinished mod for a six-year-old medieval RPG built by an indie studio from Turkey."

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&BWB
Re: export/import NPCs - source code released
« Reply #11 on: May 29, 2009, 02:07:44 PM »

bump and minor comment for the code.  I had a small issue because s0 wasn't cleared so the NPC name randomly appeared in a few spots.   I added the following to fix this, otherwise it seems to work fine and is included in the latest release of my star wars mod.  thx

Quote
      ("export_import_back",[],"Go back",
        [
          (assign, "$g_player_troop", "trp_player"),
          (set_player_troop, "$g_player_troop"),
        #SW - modified to clear the s0 string
        (str_clear, s0),

          (jump_to_menu, "mnu_camp_action"),
        ]
      ),
 
PC Gamer - "Uninstall KOTOR. Forget TIE Fighter and Star Wars Battlefront. There is only one Star Wars video game, and it's an unfinished mod for a six-year-old medieval RPG built by an indie studio from Turkey."

HokieBT

  • Grandmaster Knight
  • *
  • may the force be with you
    • View Profile
  • Faction: Neutral
  • M&BWB
Re: export/import NPCs - source code released
« Reply #12 on: December 29, 2009, 01:51:02 AM »

bump for those that are not aware of this code....
 
PC Gamer - "Uninstall KOTOR. Forget TIE Fighter and Star Wars Battlefront. There is only one Star Wars video game, and it's an unfinished mod for a six-year-old medieval RPG built by an indie studio from Turkey."

rubik

  • Squire
  • *
    • View Profile
  • Faction: Vaegir
Re: export/import NPCs - source code released
« Reply #13 on: December 29, 2009, 12:00:08 PM »
I use some PYTHON code in it. The code is shorter now. Maybe there is a bit difficulty to understand the new code.
« Last Edit: December 29, 2009, 12:04:15 PM by rubik »

Wu-long

  • Sergeant Knight at Arms
  • *
    • View Profile
  • Faction: Vaegir
  • MP nick: Wulong
  • WBWF&SNW
Re: export/import NPCs - source code released
« Reply #14 on: December 31, 2009, 05:48:35 AM »
is it save game combitable ?