OSP Code SP tf_guarantee_polearm

Currently Viewing (Users: 0, Guests: 1)

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
This code is intended to provide an easy way for modders to define troops with guaranteed polearms. It borrows an existing flag and slot, but if for whatever reason you want troops that can't be arsed to move because they have too much wood feel free to use another flag that isn't already used by the engine. What you actually do with the slot is up to you - there are a number of OSP scripts already that make use of troop slots to guarantee their usage in a mission.
Code:
tf_guarantee_polearm = tf_unmoveable_in_party_window
Code:
slot_troop_polearm = 40
Code:
from process_troops import save_troops
...
scripts = [


  #script_game_start:
  # This script is called when a new game is started
  # INPUT: none
  ("game_start",
   save_troops() + [
...
Code:
import string

from module_info import *
from module_troops import *
#polearm
from header_troops import tf_hero, tf_unmoveable_in_party_window
from header_items import itp_type_polearm
from header_operations import troop_set_slot
from module_constants import slot_troop_polearm
from module_items import items

from process_common import *
#from process_operations import *


num_face_numeric_keys = 4

def save_troops():
  #polearm
  troop_polearm = []
  troop_id = 0
  file = open(export_dir + "troops.txt","w")
  file.write("troopsfile version 2\n")
  file.write("%d "%len(troops))
  for troop in troops:
    troop_len = len(troop)
    if troop_len == 11:
      troop[11:11] = [0, 0, 0, 0, 0]
    elif troop_len == 12:
      troop[12:12] = [0, 0, 0, 0]
    elif troop_len == 13:
      troop[13:13] = [0, 0, 0]
    elif troop_len == 14:
      troop[14:14] = [0, 0]
    elif troop_len == 15:
      troop[15:15] = [0]

    #polearm
    troop_flags = troop[3]
    if troop_flags & tf_hero != tf_hero and troop_flags & tf_unmoveable_in_party_window == tf_unmoveable_in_party_window:
      troop[3] ^= tf_unmoveable_in_party_window
      troop_flags = 0
    
    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  "%(convert_to_identifier(troop[0]),replace_spaces(troop[1]),replace_spaces(troop[2]), replace_spaces(str(troop[13])), troop[3],troop[4],troop[5], troop[6], troop[14], troop[15]))
    inventory_list = troop[7]
    for inventory_item in inventory_list:
      if (isinstance(inventory_item,list))|(isinstance(inventory_item,tuple)):
        file.write("%d %d "%(inventory_item[0],inventory_item[1]<<24))
        item_id = inventory_item[0]
      else:
        file.write("%d 0 "%inventory_item)
        item_id = inventory_item
      #polearm
      if troop_flags == 0 and items[item_id][3] & 0x000000ff == itp_type_polearm:
        troop_polearm.append((troop_set_slot, troop_id, slot_troop_polearm, item_id))
        # print troop[2] + " is using " + items[item_id][1]
        troop_flags = 1
    for i in xrange(64 - len(inventory_list)):
      file.write("-1 0 ")
    file.write("\n ")
    attrib = troop[8]
    strength = (attrib & 0xff)
    agility  = ((attrib >> 8)& 0xff)
    intelligence = ((attrib >> 16)& 0xff)
    charisma = ((attrib >> 24)& 0xff)
    starting_level = (attrib >> level_bits) & level_mask
    
    file.write(" %d %d %d %d %d\n"%(strength,agility,intelligence,charisma,starting_level))
    wp_word = troop[9]
    for wp in xrange(num_weapon_proficiencies):
      wp_level = wp_word & 0x3FF
      file.write(" %d"%wp_level)
      wp_word = wp_word >> 10
    file.write("\n")
      
    skill_array = troop[10]
    for i in xrange(num_skill_words):
      file.write("%d "%((skill_array >> (i * 32)) & 0xffffffff))
    file.write("\n  ")

    face_keys = [troop[11],troop[12]]
    
    for fckey in (face_keys):
      word_keys = []
      for word_no in xrange(num_face_numeric_keys):
        word_keys.append((fckey >> (64 * word_no)) & 0xFFFFFFFFFFFFFFFF)
      for word_no in xrange(num_face_numeric_keys):
        file.write("%d "%(word_keys[(num_face_numeric_keys -1) - word_no]))

    file.write("\n")
    troop_id += 1
...
Nothing too fancy, just list processing with flags.
module_troops said:
["swadian_infantry_ai","Swadian Landsknecht","Swadian Landsknechts",tf_guarantee_polearm|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet,0,0,fac_kingdom_1,
[itm_fighting_pick,itm_swadian_pike1,itm_swadian_cloth1,itm_swadian_cloth4,itm_white_hose,itm_leather_gloves,itm_hat1,itm_hat2,itm_swadian_cloth1,itm_swadian_cloth4,itm_white_hose,itm_leather_gloves],
def_attrib|level(14),wpex(175,155,165,100,150,100),knows_common|knows_power_strike_1|knows_weapon_master_2|knows_athletics_3,swadian_face_young_1, swadian_face_old_2],
 

Life_Erikson

Master Knight
M&BWBNWVC
Best answers
0
When compiling it tells me: "cannot import name polearm_list"

My code:

Code:
...

#NAMES:
#

tf_guarantee_all = tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_helmet|tf_guarantee_horse|tf_guarantee_shield|tf_guarantee_ranged
tf_guarantee_all_wo_ranged = tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_helmet|tf_guarantee_horse|tf_guarantee_shield
tf_guarantee_polearm = tf_unmoveable_in_party_window

troops = [
  ["player","Player","Player",tf_hero|tf_unmoveable_in_party_window,no_scene,reserved,fac_player_faction,
   [],
   str_4|agi_4|int_4|cha_4,wp(15),0,0x000000018000000136db6db6db6db6db00000000001db6db0000000000000000],
  ["multiplayer_profile_troop_male","multiplayer_profile_troop_male","multiplayer_profile_troop_male", tf_hero|tf_guarantee_all, 0, 0,fac_commoners,

...
Code:
...

from header_map_icons import *
from ID_animations import *
##diplomacy start+
from module_factions import dplmc_factions_begin, dplmc_factions_end, dplmc_non_generic_factions_begin
##diplomacy end+
from process_troops import polearm_list

##diplomacy begin
##jrider reports
from header_presentations import tf_left_align

...




  #script_game_start:
  # This script is called when a new game is started
  # INPUT: none
  ("game_start",
   [
      (call_script, "script_init_troop_polearms"),
      (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
      (assign, "$g_player_luck", 200),
      (assign, "$g_player_luck", 200),
      (troop_set_slot, "trp_player", slot_troop_occupation, slto_kingdom_hero),
      (store_random_in_range, ":starting_training_ground", training_grounds_begin, training_grounds_end),
      (party_relocate_near_party, "p_main_party", ":starting_training_ground", 3),
      (str_store_troop_name, s5, "trp_player"),
      (party_set_name, "p_main_party", s5),
      (call_script, "script_update_party_creation_random_limits"),
      (assign, "$g_player_party_icon", -1),

	  #Warband changes begin -- set this early
	  (try_for_range, ":npc", 0, kingdom_ladies_end),
	    (this_or_next|eq, ":npc", "trp_player"),
		(is_between, ":npc", active_npcs_begin, kingdom_ladies_end),
		(troop_set_slot, ":npc", slot_troop_father, -1),
		(troop_set_slot, ":npc", slot_troop_mother, -1),
		(troop_set_slot, ":npc", slot_troop_guardian, -1),
		(troop_set_slot, ":npc", slot_troop_spouse, -1),
		(troop_set_slot, ":npc", slot_troop_betrothed, -1),
        (troop_set_slot, ":npc", slot_troop_prisoner_of_party, -1),
        (troop_set_slot, ":npc", slot_lady_last_suitor, -1),
        (troop_set_slot, ":npc", slot_troop_stance_on_faction_issue, -1),

		(store_random_in_range, ":decision_seed", 0, 10000),
        (troop_set_slot, ":npc", slot_troop_set_decision_seed, ":decision_seed"),	#currently not used
        (troop_set_slot, ":npc", slot_troop_temp_decision_seed, ":decision_seed"),	#currently not used, holds for at least 24 hours
	  (try_end),
	  
	  ("init_troop_polearms", polearm_list),

	  
	  (assign, "$g_lord_long_term_count", 0),
	  ##diplomacy start+ Clear faction leader/marshall, since 0 is the player
	  (try_for_range, ":faction_no", 0, dplmc_factions_end),
	     (neq, ":faction_no", "fac_player_faction"),
	     (neq, ":faction_no", "fac_player_supporters_faction"),
	     (faction_set_slot, ":faction_no", slot_faction_leader, -1),
	     (faction_set_slot, ":faction_no", slot_faction_marshall, -1),
	  (try_end),
	  ##diplomacy end+

...
Code:
...


def save_troops():
#polearm
  troop_polearm = []
  troop_id = 0
  file = open(export_dir + "troops.txt","w")
  file.write("troopsfile version 2\n")
  file.write("%d "%len(troops))
  for troop in troops:
    troop_len = len(troop)
    if troop_len == 11:
      troop[11:11] = [0, 0, 0, 0, 0]
    elif troop_len == 12:
      troop[12:12] = [0, 0, 0, 0]
    elif troop_len == 13:
      troop[13:13] = [0, 0, 0]
    elif troop_len == 14:
      troop[14:14] = [0, 0]
    elif troop_len == 15:
      troop[15:15] = [0]
    if (troop[4] > 0):
#      add_tag_use(tag_uses,tag_scene,troop[4] & tsf_site_id_mask)
      id_no = find_object(troops,convert_to_identifier(troop[0]))
#      if (id_no >= 0):  add_tag_use(tag_uses,tag_troop,id_no)
#    if (troop[6] > 0):  add_tag_use(tag_uses,tag_faction,troop[6])

#polearm
    troop_flags = troop[3]
    if troop_flags & tf_hero != tf_hero and troop_flags & tf_unmoveable_in_party_window == tf_unmoveable_in_party_window:
      troop[3] ^= tf_unmoveable_in_party_window
      troop_flags = 0

    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  "%(convert_to_identifier(troop[0]),replace_spaces(troop[1]),replace_spaces(troop[2]), replace_spaces(str(troop[13])), troop[3],troop[4],troop[5], troop[6], troop[14], troop[15]))
    inventory_list = troop[7]
#    inventory_list.append(itm_arrows)
#    inventory_list.append(itm_bolts)
    for inventory_item in inventory_list:
#      add_tag_use(tag_uses,tag_item,inventory_item)
      file.write("%d 0 "%inventory_item)

...
Code:
...

slot_troop_trainer_met                       = 30
slot_troop_trainer_waiting_for_result        = 31
slot_troop_trainer_training_fight_won        = 32
slot_troop_trainer_num_opponents_to_beat     = 33
slot_troop_trainer_training_system_explained = 34
slot_troop_trainer_opponent_troop            = 35
slot_troop_trainer_training_difficulty       = 36
slot_troop_trainer_training_fight_won        = 37
slot_troop_polearm                           = 40

slot_lady_used_tournament	    = 40


slot_troop_current_rumor       = 45
slot_troop_temp_slot           = 46
slot_troop_promised_fief       = 47

...
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
Yeah you need to define init_polearm as a separate script and call it with no parameters - save_troops() will return a list, which is formatted as a bunch of troop_set_slot tuples.
Also, your process_troops should have a
Code:
polearm_list = save_troops()
somewhere near the bottom. Or just import the save_troops() function instead.
 

Life_Erikson

Master Knight
M&BWBNWVC
Best answers
0
Thanks!

Now it compiles without error. The only thing it tells me is that it is unable to find object:script_init_troop_polearms

If I understood you correctly I need to create a comlete new python file called "init_polearms" which serves as a polearm list.
If I need to do so, how do I need to set the list up?
(A piece of working script with some random items in it would help me alot to understand how it works.)
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
save_troops is a python method that happens to return a list (a list of troops with polearms). The list is generated when the function is run (more times than it needs to), and can then be appended to an existing list. In our case, this list is the body of a script we've defined. We then call that script from
Code:
script_game_start
or wherever it is appropriate. I've updated the original post, should work now.
 

Life_Erikson

Master Knight
M&BWBNWVC
Best answers
0
Excuse me for responding so late.

Your last post confused me a bit. I now tried to implement the code how you've written it in the reedited top post.
But however it doesn't compile correctly.
I get this error:
Exporting troops data
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_global_variables.py", line 12, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting troops data
Traceback (most recent call last):
  File "process_map_icons.py", line 6, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting faction data...
Exporting item data...
Exporting troops data
Traceback (most recent call last):
  File "process_items.py", line 66, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting scene data...
Exporting troops data
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Exporting particle data...
Exporting troops data
Traceback (most recent call last):
  File "process_scene_props.py", line 7, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting party_template data...
Exporting troops data
Traceback (most recent call last):
  File "process_parties.py", line 6, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting quest data...
Exporting info_page data...
Exporting troops data
Traceback (most recent call last):
  File "process_scripts.py", line 4, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_mission_tmps.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_game_menus.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_global_variables_unused.py", line 3, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'function' and 'list'
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

Here the bits of code I used:

tf_guarantee_all = tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_helmet|tf_guarantee_horse|tf_guarantee_shield|tf_guarantee_ranged
tf_guarantee_all_wo_ranged = tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_helmet|tf_guarantee_horse|tf_guarantee_shield
tf_guarantee_polearm = tf_unmoveable_in_party_window

troops = [
["player","Player","Player",tf_hero|tf_unmoveable_in_party_window,no_scene,reserved,fac_player_faction,
  [],
  str_4|agi_4|int_4|cha_4,wp(15),0,0x000000018000000136db6db6db6db6db00000000001db6db0000000000000000],

slot_troop_trainer_met                      = 30
slot_troop_trainer_waiting_for_result        = 31
slot_troop_trainer_training_fight_won        = 32
slot_troop_trainer_num_opponents_to_beat    = 33
slot_troop_trainer_training_system_explained = 34
slot_troop_trainer_opponent_troop            = 35
slot_troop_trainer_training_difficulty      = 36
slot_troop_trainer_training_fight_won        = 37
slot_troop_polearm                          = 40

slot_lady_used_tournament = 40


slot_troop_current_rumor      = 45
slot_troop_temp_slot          = 46
slot_troop_promised_fief      = 47

scripts = [


  #script_game_start:
  # This script is called when a new game is started
  # INPUT: none
  ("game_start",
  save_troops + [
 
      (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
      (assign, "$g_player_luck", 200),
      (assign, "$g_player_luck", 200),
      (troop_set_slot, "trp_player", slot_troop_occupation, slto_kingdom_hero),
      (store_random_in_range, ":starting_training_ground", training_grounds_begin, training_grounds_end),
      (party_relocate_near_party, "p_main_party", ":starting_training_ground", 3),
      (str_store_troop_name, s5, "trp_player"),
      (party_set_name, "p_main_party", s5),
      (call_script, "script_update_party_creation_random_limits"),
      (assign, "$g_player_party_icon", -1),

import string

from module_info import *
from module_troops import *
#polearm
from header_troops import tf_hero, tf_unmoveable_in_party_window
from header_items import itp_type_polearm
from header_operations import troop_set_slot
from module_constants import slot_troop_polearm
from module_items import items

from process_common import *
#from process_operations import *


num_face_numeric_keys = 4

def save_troops():
  #polearm
  troop_polearm = []
  troop_id = 0
  file = open(export_dir + "troops.txt","w")
  file.write("troopsfile version 2\n")
  file.write("%d "%len(troops))
  for troop in troops:
    troop_len = len(troop)
    if troop_len == 11:
      troop[11:11] = [0, 0, 0, 0, 0]
    elif troop_len == 12:
      troop[12:12] = [0, 0, 0, 0]
    elif troop_len == 13:
      troop[13:13] = [0, 0, 0]
    elif troop_len == 14:
      troop[14:14] = [0, 0]
    elif troop_len == 15:
      troop[15:15] = [0]

    #polearm
    troop_flags = troop[3]
    if troop_flags & tf_hero != tf_hero and troop_flags & tf_unmoveable_in_party_window == tf_unmoveable_in_party_window:
      troop[3] ^= tf_unmoveable_in_party_window
      troop_flags = 0
   
    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  "%(convert_to_identifier(troop[0]),replace_spaces(troop[1]),replace_spaces(troop[2]), replace_spaces(str(troop[13])), troop[3],troop[4],troop[5], troop[6], troop[14], troop[15]))
    inventory_list = troop[7]
    for inventory_item in inventory_list:
      if (isinstance(inventory_item,list))|(isinstance(inventory_item,tuple)):
        file.write("%d %d "%(inventory_item[0],inventory_item[1]<<24))
        item_id = inventory_item[0]
      else:
        file.write("%d 0 "%inventory_item)
        item_id = inventory_item
      #polearm
      if troop_flags == 0 and items[item_id][3] & 0x000000ff == itp_type_polearm:
        troop_polearm.append((troop_set_slot, troop_id, slot_troop_polearm, item_id))
        # print troop[2] + " is using " + items[item_id][1]
        troop_flags = 1
    for i in xrange(64 - len(inventory_list)):
      file.write("-1 0 ")
    file.write("\n ")
    attrib = troop[8]
    strength = (attrib & 0xff)
    agility  = ((attrib >> :cool:& 0xff)
    intelligence = ((attrib >> 16)& 0xff)
    charisma = ((attrib >> 24)& 0xff)
    starting_level = (attrib >> level_bits) & level_mask
   
    file.write(" %d %d %d %d %d\n"%(strength,agility,intelligence,charisma,starting_level))
    wp_word = troop[9]
    for wp in xrange(num_weapon_proficiencies):
      wp_level = wp_word & 0x3FF
      file.write(" %d"%wp_level)
      wp_word = wp_word >> 10
    file.write("\n")
     
    skill_array = troop[10]
    for i in xrange(num_skill_words):
      file.write("%d "%((skill_array >> (i * 32)) & 0xffffffff))
    file.write("\n  ")

    face_keys = [troop[11],troop[12]]
   
    for fckey in (face_keys):
      word_keys = []
      for word_no in xrange(num_face_numeric_keys):
        word_keys.append((fckey >> (64 * word_no)) & 0xFFFFFFFFFFFFFFFF)
      for word_no in xrange(num_face_numeric_keys):
        file.write("%d "%(word_keys[(num_face_numeric_keys -1) - word_no]))

    file.write("\n")
    troop_id += 1

     
       

#    word2 = (fckey >> 64) & 0xFFFFFFFFFFFFFFFF
#    word3 = (fckey >> 12:cool: & 0xFFFFFFFFFFFFFFFF
#    word4 = (fckey >> 192) & 0xFFFFFFFFFFFFFFFF
#      file.write("%d %d %d %d "%(word4, word3, word2, word1))

#    face_keys = troop[10]
#    for fckey in (face_keys):
#      file.write("%d "%(fckey))
#    for i in xrange(4 - len(face_keys)):
#      file.write("0 ")
     
   
  file.close()

def two_to_pow(x):
  result = 1
  for i in xrange(x):
    result = result * 2
  return result

def save_python_header():
  file = open("./ID_troops.py","w")
  for i_troop in xrange(len(troops)):
    file.write("trp_%s = %d\n"%(convert_to_identifier(troops[i_troop][0]),i_troop))
  file.close()

print "Exporting troops data"
#tag_uses = load_tag_uses(export_dir)
save_python_header()
save_troops()
#save_tag_uses(export_dir, tag_uses)
#print "Generating C header..."
#save_c_header()
#print "Generating Python header..."
#print "Finished."

Thanks in advance for any help!
 

Life_Erikson

Master Knight
M&BWBNWVC
Best answers
0
Tried it out and it seemed to collide with Diplomacy here:

Exporting troops data
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_global_variables.py", line 12, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting troops data
Traceback (most recent call last):
  File "process_map_icons.py", line 6, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting faction data...
Exporting item data...
Exporting troops data
Traceback (most recent call last):
  File "process_items.py", line 66, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting scene data...
Exporting troops data
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Exporting particle data...
Exporting troops data
Traceback (most recent call last):
  File "process_scene_props.py", line 7, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting party_template data...
Exporting troops data
Traceback (most recent call last):
  File "process_parties.py", line 6, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting quest data...
Exporting info_page data...
Exporting troops data
Traceback (most recent call last):
  File "process_scripts.py", line 4, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_mission_tmps.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_game_menus.py", line 8, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting troops data
Traceback (most recent call last):
  File "process_global_variables_unused.py", line 3, in <module>
    from process_operations import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\process_operations.py", line 20, in <module>
    from module_scripts import *
  File "C:\Spiele\Mount&Blade Warband\Modules\Calradia Medieval Warfare\Calradia
Medieval Warfare\module_scripts.py", line 1242, in <module>
    (troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLM
C_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

This is line 1242:
(troop_set_slot, "trp_dplmc_chamberlain", dplmc_slot_troop_affiliated, (DPLMC_CURRENT_VERSION_CODE * 12:cool: + DPLMC_VERSION_LOW_7_BITS),#Version number 1

However I'm not quite sure about that.

You have an open bracket here:
  #script_game_start:
  # This script is called when a new game is started
  # INPUT: none
  ("game_start",
  save_troops() + [

I simply assumed that this is the open bracket that is in the vanilla script the line below and deleted it as there is allready one.

If i keep it the MS tells me that there is a closing bracket missing. (of course)
So if I add a closing bracket for exemple after the first "(try_end)," however the MS gives me this error message:
"TypeError: 'list' object is not callable"


Is this error caused by Diplomacy or is something missing behind "save_troops() +[" ?
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
Why not just do a call_script if the concatenation isn't working? List this as one of the scripts (at the bottom)
Code:
("init_troop_polearms", save_troops()),
Then call it from either scripts game_start like so
Code:
(call_script, "script_init_troop_polearms"),
 

Life_Erikson

Master Knight
M&BWBNWVC
Best answers
0
Big leap forward. Thank you!

I put the "("init_troop_polearms", save_troops())," at the botom before the last bracket in module scripts and
put the "(call_script, "scipt_init_troop_polarms")," where the "save_troops() + [" was before as it seems that this is the only place where "game_start" is used in module_scripts.

But now MS puts out this:
Error in script: ('init_troop_ploearms', None)
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
Did you keep the import save_troops() at the top or do you have polearm_list for some reason?
 

Valon

Recruit
Best answers
0
Sorry if I am a bother, but I have a problem compiling the process_troops.py with your changes, and I can not see why.

Adding the save_troops()+ to the code in module_scripts.py makes another part of the file not work:

[...]\module_scripts.py", line 898, in <module>
TypeError: unsupported operand types(s) for +: 'NoneType' and 'List'

The thing that breaks is the thing that runs in the end of the script (try_end)

thank you in advance for any help provided
 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
Valon said:
[...]\module_scripts.py", line 898, in <module>
TypeError: unsupported operand types(s) for +: 'NoneType' and 'List'
You need to import it from the modified header_troops procedure.
 

Valon

Recruit
Best answers
0
Somebody said:
You need to import it from the modified header_troops procedure.
I am a new comer to modding, and I do not understand what you mean, unfortunately.
I do not know what you mean with the modified header_troops procedure, as header_troops have not been changed at all, only process_troops, right? (unless I am missing something)

in the top of my module_scripts file I have
from process_troops import save_troops

I can not think of anything else I have to import.

I looked through previous posts, and trying the way it was done before seems to be getting me closer to my goal.
The only problem is that it will not let a function be used as a script argument.

Error in script:
(1init_troop_polearms', <function save_troops at 0x02F18370>)

I have no idea what this error means other than it do not work, and the offset is plain out simply confusing me, there is another error, though:

  File "process_scripts.py", line 40, in <module>
    save_scripts(variables,variable_uses,scripts,tag_uses,quick_strings)
  File "process_scripts.py", line 21, in save_scripts
    file.write("%s %f\n"%(convert_to_identifier(func[0], func[1]))
TypeError: float argument required, not function

This leads me to believe that instead of actually using the returned list from the function, it throws the function itself directly into the save_scripts system, which of course will not work. (would be very useful if the game engine had a built-in python interpreter!)

So until then, I will try and find a way to return a list that the script can use, maybe make a seperate function for this entirely (would also prevert multiple writes)

Thank you for your reply and your time.

EDIT:
It just compiled without error, I will now test and see if it works.

def polearm_list():
troop_polearm = []
troop_id = 0
for troop in troops:
#polearm
troop_flags = troop[3]
if troop_flags & tf_hero != tf_hero and troop_flags & tf_unmoveable_in_party_window == tf_unmoveable_in_party_window:
troop[3] ^= tf_unmoveable_in_party_window
troop_flags = 0
#/polearm
inventory_list = troop[7]
for inventory_item in inventory_list:
#polearm
item_id = inventory_item
if troop_flags == 0 and items[item_id][3] & 0x000000ff == itp_type_polearm:
troop_polearm.append((troop_set_slot, troop_id, slot_troop_polearm, item_id))
# print troop[2] + " is using " + items[item_id][1]
troop_flags = 1
#/polearm

troop_id += 1
return troop_polearm

EDIT2:
I have tested it, and to my knowledge it works. Of course when I am new to modding, I have no idea if I have proberly tested it. if someone could tell me wether or not it works would be wonderful and appreciated.
 

wld427

Recruit
Best answers
0
Has anyone got this working?

I modified python files step by step from the original post.


Unfortunately it will not compile.

If anyone could post a working copy and paste version i would very much appreciate it.


Unfortunately most of us coming here to look for information like this are noobs in the truest sense and need to be hand walked through some of this stuff. I know nothing of scripting or its functions. I can copy and paste said info where you tell me too that is about it.

Thank You in advance.




 

Somebody

Code Pope
Baron
WBWF&S
Best answers
1
What errors are given when you try to compile?
For your specific usage (one pikeman) I'd just set the slot manually in script_game_start and then plug in your favourite weapon swapping trigger.
 

wld427

Recruit
Best answers
0
Somebody said:
What errors are given when you try to compile?
For your specific usage (one pikeman) I'd just set the slot manually in script_game_start and then plug in your favourite weapon swapping trigger.

Yeah... see thats my problem as described above. i know nothing of how to do that. Its why i come here to get snippets of code and tutorials. What i need is a paste in version sort of plug and play kind of setup. Respectfully, I just am not as smart as you and some of the other coders here. Y'all have my deepest respect for being able to do this stuff.