help! random crashing

Users who are viewing this thread

Estepki

Recruit
I have put this code into the modules_troops file (the code in between the #### ####)

  ["mercenaries_end","mercenaries_end","mercenaries_end",0,no_scene,reserved,fac_commoners,
  [],
  def_attrib|level(4),wp(60),knows_common,mercenary_face_1, mercenary_face_2],

####
  ["ranger","Ranger","Rangers",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_ranged,0,0,fac_neutral,
  [itm_long_bow,itm_khergit_arrows,itm_arrows, itm_barbed_arrows, itm_bodkin_arrows,itm_sword_medieval_b_small,
      itm_splinted_greaves,itm_black_greaves,itm_leather_boots,itm_leather_gloves,itm_black_hood,itm_black_hood,itm_black_hood,itm_robe],
  def_attrib|level(25),wp_archery(300),wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],
####


#peasant - retainer - footman - man-at-arms -  knight
  ["swadian_recruit","Swadian Recruit","Swadian Recruits",tf_guarantee_armor,0,0,fac_neutral,
  [itm_scythe,itm_hatchet,itm_pickaxe,itm_club,itm_stones,itm_tab_shield_heater_a,itm_leather_cap,itm_felt_hat,itm_felt_hat,
    itm_shirt,itm_coarse_tunic,itm_leather_apron,itm_nomad_boots,itm_wrapping_boots],
  def_attrib|level(4),wp(60),knows_common,swadian_face_younger_1, swadian_face_middle_2],

and down the bottom

upgrade(troops,"mercenary_horseman","mercenary_cavalry")

####
upgrade(troops,"mercenary_cavalry","ranger")
upgrade(troops,"mercenary_crossbowman","ranger")
upgrade(troops,"hired_blade","ranger")
upgrade(troops,"swadian_sharpshooter","ranger")
upgrade(troops,"swadian_knight","ranger")
upgrade(troops,"swadian_sergeant","ranger")
####

upgrade(troops,"swadian_recruit","swadian_militia")

now when I upgrade troops to this new class, my game crashes.... anyone know why?
 
You probably need to start a new game.  VERY, VERY odd things happen if you change the troops out from under a current save game. :wink:
 
Maybe because the troop you're trying to upgrade is higher level than 25, so it cannot go down to 25.

Example : Swadian knight is level 30, then ranger is 25, so when you upgrade it it would cause a loss of xp. And that may cause a crash.
 
hmm..... maybe.... ill give that a go....

EDIT: Nope... still crashing when I upgrade them... the new code is this:

  ["ranger","Ranger","Rangers",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_ranged,0,0,fac_neutral,
  [itm_long_bow,itm_khergit_arrows,itm_arrows, itm_barbed_arrows, itm_bodkin_arrows,itm_sword_medieval_b_small,
      itm_splinted_greaves,itm_black_greaves,itm_leather_boots,itm_leather_gloves,itm_black_hood,itm_black_hood,itm_black_hood,itm_robe],
  def_attrib|level(40),wp_archery(300),wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],
 
Estepki said:
hmm..... maybe.... ill give that a go....

EDIT: Nope... still crashing when I upgrade them... the new code is this:

  ["ranger","Ranger","Rangers",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_ranged,0,0,fac_neutral,
  [itm_long_bow,itm_khergit_arrows,itm_arrows, itm_barbed_arrows, itm_bodkin_arrows,itm_sword_medieval_b_small,
      itm_splinted_greaves,itm_black_greaves,itm_leather_boots,itm_leather_gloves,itm_black_hood,itm_black_hood,itm_black_hood,itm_robe],
  def_attrib|level(40),wp_archery(300),wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],

What troop are you trying to upgrade from? Make sure that troop is lower than 40. If you are, then I don't know, maybe there is two 'ranger' in the troops. Does the compiler give you any error?
 
no compile error and every other troop is the native troop

and I think their level is under 40... the upgrades code is at the top of this topic
 
You seem to have too many pieces of data in your tuple:
def_attrib|level(40),wp_archery(300),wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],

This is probably throwing the fields off by one for the face codes which is probably why it's crashing. 

Change this to:
def_attrib|level(40),wp_archery(300)|wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],

and I bet the crash will go away.
 
kt0 said:
You seem to have too many pieces of data in your tuple:
def_attrib|level(40),wp_archery(300),wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],

This is probably throwing the fields off by one for the face codes which is probably why it's crashing. 

Change this to:
def_attrib|level(40),wp_archery(300)|wp(200),knows_common|knows_athletics_4|knows_power_draw_7,swadian_face_middle_1, swadian_face_older_2],

and I bet the crash will go away.

Kt0 is right and there is additional information I would like to share with you.

When you input this: wp_archery(300),wp(200) you are modifying the archer skill to 300, then randomizing all weapon skills to 200.. including archery.  (unless you changed the wp(x) function.

I have noticed that when we duplicate skill values or weapon values in this troop randomization process that we get bad face codes and makes the game unstable in other ways and you get unpredictable results.

Saxondragon



 
ahhhh. OK. thanks alot for that. Ill go test it now!

also, what should I do if I want all their skills bar one to be at 200 at the other at 300? switch the order?

**Nice color coding btw... makes it real easy to see what your talking about :grin: **

EDIT: Yes! It works! thanks for correcting that.... also, one final question... Does anyone have any hints for replacing every native troops???
 
I built a pile of python functions to set stuff for archetypes like arch_wp(x) for everything I cared about then scrubbed through all of the troop entries and replaced all the data based on archetype.  This way if I need to adjust stuff across the board, I can do so by changing the macro and re-compiling.  So I get stuff that looks like this:
[
"ranger",
"Ranger",
"Rangers",
tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_ranged,
0, 0, fac_neutral,
[
# items go in here...
],
arch_att(5) | level(25),
arch_wp(5),
arch_skills_5 | knows_common,
swadian_face_middle_1, swadian_face_older_2
],
And, yes, I reformatted all the code because the way it is in Native is almost completely unmanageable. 

The functions arch_att and arch_wp do maths on the tier passed in and set all the weapon proficiencies appropriately.  The same is true for arch_att.  The constant arch_skills_5 is just a formulaic aggregate of a bunch of skills that I thought a tier 5 archer should have. 

As for your first question, I think you can just or the results of the wp_melee and wp_archery together and it'll do the right thing but I don't have the code in front of me.  If you want to see for sure, just look at the wp() function definition and see what it does with the data. 
 
hmm, thats an idea...


one more thing...

How does the unit tier section work? I want to replace all native troops but don't know what to put in here... it just seems random to me...
# Cultures:
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_1_troop, "trp_swadian_recruit"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_2_troop, "trp_swadian_militia"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_3_troop, "trp_swadian_footman"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_4_troop, "trp_swadian_infantry"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_5_troop, "trp_swadian_knight"),


      (faction_set_slot, "fac_culture_2", slot_faction_tier_1_troop, "trp_vaegir_recruit"),
      (faction_set_slot, "fac_culture_2", slot_faction_tier_2_troop, "trp_vaegir_footman"),
      (faction_set_slot, "fac_culture_2", slot_faction_tier_3_troop, "trp_vaegir_veteran"),
      (faction_set_slot, "fac_culture_2", slot_faction_tier_4_troop, "trp_vaegir_infantry"),
      (faction_set_slot, "fac_culture_2", slot_faction_tier_5_troop, "trp_vaegir_knight"),

      (faction_set_slot, "fac_culture_3", slot_faction_tier_1_troop, "trp_khergit_tribesman"),
      (faction_set_slot, "fac_culture_3", slot_faction_tier_2_troop, "trp_khergit_skirmisher"),
      (faction_set_slot, "fac_culture_3", slot_faction_tier_3_troop, "trp_khergit_horseman"),
      (faction_set_slot, "fac_culture_3", slot_faction_tier_4_troop, "trp_khergit_horse_archer"),
      (faction_set_slot, "fac_culture_3", slot_faction_tier_5_troop, "trp_khergit_veteran_horse_archer"),

      (faction_set_slot, "fac_culture_4", slot_faction_tier_1_troop, "trp_nord_recruit"),
      (faction_set_slot, "fac_culture_4", slot_faction_tier_2_troop, "trp_nord_footman"),
      (faction_set_slot, "fac_culture_4", slot_faction_tier_3_troop, "trp_nord_trained_footman"),
      (faction_set_slot, "fac_culture_4", slot_faction_tier_4_troop, "trp_nord_warrior"),
      (faction_set_slot, "fac_culture_4", slot_faction_tier_5_troop, "trp_nord_veteran"),

      (faction_set_slot, "fac_culture_5", slot_faction_tier_1_troop, "trp_rhodok_tribesman"),
      (faction_set_slot, "fac_culture_5", slot_faction_tier_2_troop, "trp_rhodok_spearman"),
      (faction_set_slot, "fac_culture_5", slot_faction_tier_3_troop, "trp_rhodok_trained_spearman"),
      (faction_set_slot, "fac_culture_5", slot_faction_tier_4_troop, "trp_rhodok_veteran_spearman"),
      (faction_set_slot, "fac_culture_5", slot_faction_tier_5_troop, "trp_rhodok_sergeant"),
 
kt0 said:
And, yes, I reformatted all the code because the way it is in Native is almost completely unmanageable. 
BLARG!  Why didn't I see your post before I went and did all of that with SoD's troops as well.

I have a number of macros I wrote to base everything off of 1) type of unit, and 2) level.  Again, I can modify the entire file from one or two macros:
Code:
# skill points per level
wp_anemic = 4
wp_weak = 6
wp_regular = 8
wp_expert = 10

# variability of skill level (+/- this amount per skill)
wp_rand = 0

def wp_all(x):
  n = 0
  n |= wp_archery(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_crossbow(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_throwing(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_one_handed(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_two_handed(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_polearm(x + random.randrange(-wp_rand, wp_rand+1))
  return n

def wp_bow(x):
  n = wp_archery(x + random.randrange(-wp_rand, wp_rand+1))
  return n

def wp_xbow(x):
  n = wp_crossbow(x + random.randrange(-wp_rand, wp_rand+1))
  return n

def wp_thrown(x):
  n = wp_throwing(x + random.randrange(-wp_rand, wp_rand+1))
  return n

def wp_ranged(x):
  n = 0
  n |= wp_archery(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_crossbow(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_throwing(x + random.randrange(-wp_rand, wp_rand+1))
  return n

def wp_melee(x):
  n = 0
  n |= wp_one_handed(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_two_handed(x + random.randrange(-wp_rand, wp_rand+1))
  n |= wp_polearm(x + random.randrange(-wp_rand, wp_rand+1))
  return n

# melee troops

def weak_melee(lvl):
  return wp_melee(lvl*wp_weak)|wp_ranged(lvl*wp_anemic)

def regular_melee(lvl):
  return wp_melee(lvl*wp_regular)|wp_ranged(lvl*wp_weak)

def expert_melee(lvl):
  return wp_melee(lvl*wp_expert)|wp_ranged(lvl*wp_regular)

# archers

def weak_archer(lvl):
  return wp_bow(lvl*wp_weak)|wp_xbow(lvl*wp_anemic)|wp_thrown(lvl*wp_anemic)|wp_melee(lvl*wp_anemic)

def regular_archer(lvl):
  return wp_bow(lvl*wp_regular)|wp_xbow(lvl*wp_weak)|wp_thrown(lvl*wp_weak)|wp_melee(lvl*wp_weak)

def expert_archer(lvl):
  return wp_bow(lvl*wp_expert)|wp_xbow(lvl*wp_regular)|wp_thrown(lvl*wp_regular)|wp_melee(lvl*wp_regular)

# crossbowman

def weak_crossbow(lvl):
  return wp_xbow(lvl*wp_weak)|wp_bow(lvl*wp_anemic)|wp_thrown(lvl*wp_anemic)|wp_melee(lvl*wp_anemic)

def regular_crossbow(lvl):
  return wp_xbow(lvl*wp_regular)|wp_bow(lvl*wp_weak)|wp_thrown(lvl*wp_weak)|wp_melee(lvl*wp_weak)

def expert_crossbow(lvl):
  return wp_xbow(lvl*wp_expert)|wp_bow(lvl*wp_regular)|wp_thrown(lvl*wp_regular)|wp_melee(lvl*wp_regular)

# javelinmen (or any throwing weapon unit)

def weak_javelinmen(lvl):
  return wp_thrown(lvl*wp_weak)|wp_xbow(lvl*wp_anemic)|wp_bow(lvl*wp_anemic)|wp_melee(lvl*wp_anemic)

def regular_javelinmen(lvl):
  return wp_thrown(lvl*wp_regular)|wp_xbow(lvl*wp_weak)|wp_bow(lvl*wp_weak)|wp_melee(lvl*wp_weak)

def expert_javelinmen(lvl):
  return wp_thrown(lvl*wp_expert)|wp_xbow(lvl*wp_regular)|wp_bow(lvl*wp_regular)|wp_melee(lvl*wp_regular)

# mixed troops

def weak_all(lvl):
  return wp_melee(lvl*wp_weak)|wp_ranged(lvl*wp_weak)

def regular_all(lvl):
  return wp_melee(lvl*wp_regular)|wp_ranged(lvl*wp_regular)

def expert_all(lvl):
  return wp_melee(lvl*wp_expert)|wp_ranged(lvl*wp_expert)

And then my troops look like:
Code:
  ["swadian_recruit", "Swadian Recruit", "Swadian Recruits", tf_guarantee_armor, 0, 0, fac_neutral,
   [itm_scythe, itm_hatchet, itm_pickaxe, itm_club, itm_stones, itm_tab_shield_heater_a, itm_leather_cap, itm_felt_hat, itm_felt_hat,
    itm_shirt, itm_coarse_tunic, itm_leather_apron, itm_nomad_boots, itm_wrapping_boots],
   def_attrib|level(4), regular_melee(4), 0, swadian_face_younger_1, swadian_face_middle_2],

  ["swadian_knight", "Swadian Knight", "Swadian Knights", tf_mounted|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_helmet|tf_guarantee_horse|tf_guarantee_shield, 0, 0, fac_neutral,
   [itm_heavy_lance, itm_bastard_sword_b, itm_sword_medieval_c, itm_tab_shield_heater_cav_b,
    itm_plate_armor, itm_ant_plate_armor2, itm_plate_armor2, itm_mail_chausses, itm_iron_greaves, itm_guard_helmet, itm_great_helmet, itm_bascinet, itm_mail_mittens,
    itm_charger],
   def_attrib|level(25), regular_melee(25), knows_riding_5|knows_shield_2|knows_ironflesh_3|knows_power_strike_5, swadian_face_middle_1, swadian_face_older_2],
etc..

I think your method is even cleaner than mine, kt0 :wink:
 
Estepki said:
How does the unit tier section work? I want to replace all native troops but don't know what to put in here... it just seems random to me...
The best way to figure it out is to do a file search for the slot values and see what comes up.  I'm at work so I can't easily check but some of it is used for reinforcements for certain, and some of it is used for recruits. 

And even more edits:
It bothered me that I couldn't remember which troops/slots were used/unused so I looked it all up.  Here's the slots that I thought were questionable and if/when they're used:
- slot_faction_deserter_troop:  never used
- slot_faction_guard_troop:  used in scenes
- slot_faction_messenger_troop:  never used
- slot_faction_prison_guard_troop:  used in scenes
- slot_faction_castle_guard_troop:  used in scenes

There are troops in Native that do nothing but go into these slots (setup at init time in script_game_start).  If you don't want to pay the maintenance cost of upgrading/editing/tiptoeing around those guys,  you can remove them and substitute them with normal combat troops which is what I did. 
 
kt0 said:
Estepki said:
How does the unit tier section work? I want to replace all native troops but don't know what to put in here... it just seems random to me...
The best way to figure it out is to do a file search for the slot values and see what comes up.  I'm at work so I can't easily check but some of it is used for reinforcements for certain, and some of it is used for recruits. 

edit:  I confused myself writing that post.  The stuff that never gets used that I was thinking about is elsewhere (messenger/guard troops which we take great pains to enumerate and set but which never seem to get used).

so it dosnt matter what goes in the tier slots??
 
Estepki said:
so it dosnt matter what goes in the tier slots??
Among other things, the troop type tier slots are used for quests.  Don't take my word for it; do a "find in files" in your favorite editor and find out for yourself. 
 
Back
Top Bottom