Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
With the "hold" behavior think they'll still try to run away if a stronger party moves into their range before the pf_is_static flag takes hold - meaning the same moving campsite icon. I guess I could actually spawn a static campsite and have the party move into it, but that's more complicated and probably presents its own set of problems...
 
dstemmer said:
I guess I could actually spawn a static campsite and have the party move into it, but that's more complicated and probably presents its own set of problems...
Not that complicated.
You could just spawn a static campsite, and instead moving a party there, just copy all the members into the camp using the "party_copy" script, and then delete the original mobile party. Just remember that the party ID changes.
 
Alright Manitas, I took your suggestion and tried spawning a static camp, but now I'm getting an error with my script:

Assertion failed!

Program: C:\Program Files\Mount&Blade\mount&blade.exe
File: e:\develop\mb\program\src\../../rgl/rglHash_vector.h
Line: 109

Expression: num_ids < (rgl_hashmap_size / 2)


Here's my WIP script that's causing the error. The idea is to get every mobile party on the map to stop and set up a tent. Eventually I don't want them all to do it at the same time, but for now I'm not worried about it. Here's the script so far:
Code:
  ("parties_rest_once_daily",
    [
      (store_script_param, ":besiege_mode", 1),
      (try_for_parties, ":party_no"),
        (party_get_template_id,":party_id",":party_no"),
        (gt,":party_id",0),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", ai_bhvr_in_town), #party is not in town
        (eq, ":besiege_mode", 0),
        (set_spawn_radius, 0),
        (spawn_around_party,":party_no","pt_campsite"),
      (try_end),
    ]),

Does the error mean I've exceeded the maximum number of parties on the map? I tried adding this line to the end, as an experiment to see if it would prevent the crash:

Code:
(party_clear, ":party_no"),

But it didn't, same error.

 
Just to exclude the simplest case:

Did you start a new game?
If you add a record to ms and then continue a saved game, an ID assertion is imminent.
 
If that rgl_hashmap_size is a hardcoded, static limit then that's a bad news.
If you put a counter in the loop and make it issue a message, we could determine what the limit actually is.

I'd try remove_party instead of party_clear. Don't remember which of them is the right one, but remove_party sounds somewhat more removing :wink:
 
It's remove_party, not party_clear. party_clear just leaves you with a load of empty parties, and I wouldn't be surprised at that resulting in crashes. However, using remove_party is a bad idea because it deletes parties and all their records, including any slots they're carrying.

What you're trying to do is possible without remove_party, since I did exactly the same thing for Storymod C2 a while ago. Here is my working code:

  (1,
  [
(try_begin),
(is_currently_night), # If evening
(try_for_parties,":parties"),
(party_get_template_id,":template",":parties"),
(is_between,":template",foragers_begin,raiders_end),
(neq,":template","pt_siege_camp_party"), # And party is of the right template
(neg|party_is_in_any_town,":parties"), # And is not fighting or in town
(neg|party_slot_ge,":parties",slot_overnight_camp,1), # And is not already camping
(set_spawn_radius,0),
(spawn_around_party,":parties","pt_overnight_camp"), # Spawn a camp party
(party_set_slot,reg0,slot_overnight_camp,":parties"), # Set original party to a slot on camp party
(party_set_slot,":parties",slot_overnight_camp,reg0), # Set camp party to a slot on original party
(store_faction_of_party,":faction",":parties"),
(party_set_faction,reg0,":faction"), # Set camp faction to same
(str_store_party_name,s1,":parties"),
(party_set_name,reg0,"@Overnight Camp: {s1}"), # Change camp name
(call_script,"script_party_copy",reg0,":parties"), # Give camp same troops
(disable_party,":parties"), # Disable original party
(try_end),
(else_try),
(neg|is_currently_night), # If morning
(try_for_parties,":parties"),
(party_slot_ge,":parties",slot_overnight_camp,1), # And party is camping
(party_get_template_id,":template",":parties"),
(neq,":template","pt_overnight_camp"), # But is not itself a camp party (to avoid duplicate actions)
(enable_party,":parties"), # Enable original party
(party_get_slot,":camp",":parties",slot_overnight_camp), # Get camp party
(remove_party,":camp"), # Remove camp party
(party_set_slot,":parties",slot_overnight_camp,-1), # Set original party as not camping
(try_end),
(try_end),
    ]),

Cleverly,
Winter
 
Question about modeling:

I made a sword with 3d Wings.
What should i do now to put it in game?
Even replacing existing ones is ok.
Thanks
 
Winter said:
It's remove_party, not party_clear. party_clear just leaves you with a load of empty parties, and I wouldn't be surprised at that resulting in crashes. However, using remove_party is a bad idea because it deletes parties and all their records, including any slots they're carrying.

Winter, I'll look at that code and modify it for what I need, thanks! It's good to see that I was thinking along the right lines, since your script looks a lot like mine did before I commented out a lot for bugtesting.

But I was wondering if you could clear up a few more questions of mine. The script_party_copy calls party_clear in its code. Your code calls disable_party on the party you're moving into the camp. So at this point you have a copy of the party in the camp, and the original party is cleared and disabled, but not removed. Then later on you re-enable the party, and becomes active again - even though it had previously been "cleared". If the code works like you say it does, then what does "clearing" a party actually accomplish that's different than "disabling" it? When it's re-enabled, why isn't the party empty?

Second, in your code the copied party still retains the old party's behavior - you never set its AI behavior to be AI_bhvr_hold. Will this code ensure that parties stay in the camp overnight (since it's now part of the camp's static party), or will they start running away at the first sign of trouble?

Lastly, since you disabled the original party, will the try_for_parties loop still be able to "see" it? So, for example, if another trigger tells the party to change its behavior, will that kick in when it's re-enabled?
 
dstemmer said:
But I was wondering if you could clear up a few more questions of mine. The script_party_copy calls party_clear in its code. Your code calls disable_party on the party you're moving into the camp. So at this point you have a copy of the party in the camp, and the original party is cleared and disabled, but not removed. Then later on you re-enable the party, and becomes active again - even though it had previously been "cleared". If the code works like you say it does, then what does "clearing" a party actually accomplish that's different than "disabling" it? When it's re-enabled, why isn't the party empty?

The party that gets cleared is the TARGET party, not the SOURCE party. To end up with an exact copy of the SOURCE party, the TARGET party gets emptied of everything in it first, to make sure there are no hangers-on.


Second, in your code the copied party still retains the old party's behavior - you never set its AI behavior to be AI_bhvr_hold. Will this code ensure that parties stay in the camp overnight (since it's now part of the camp's static party), or will they start running away at the first sign of trouble?

The source party is disabled, as far as I'm aware it can't move while disabled. Don't make the mistake of thinking the two parties are connected somehow -- the only thing linking them is the slot value which I've set. You'll need additional custom code to handle attacks and other things that would affect both the camp party and the disabled source party.

Possibly you can change the code to attach the source party to an empty camp party instead of requiring two parties and a party_copy.


Lastly, since you disabled the original party, will the try_for_parties loop still be able to "see" it? So, for example, if another trigger tells the party to change its behavior, will that kick in when it's re-enabled?

Yes, disabled parties are still considered by try_for_parties.

Truthfully,
Winter
 
NEED HELP .. I TRIED TO EDIT WINGED HELMET WHICH IS ALREADY THERE IN THE GAME .. I MADE A NEW TEXTURE USING ABODE PHOTOSHOP .. BUT WHEN I TRY TO IMPORT THE 3D HELMET IT DOESNT WORK .. CUZ I AM NEW IN THIS ... I READ YOUSHI BOY TUTORIAL .. BUT WHEN I IMPORT MY HELMET TO BRF EDIT IT IS PINK NO TEXTURE AT ALL ..  SO DO I HAVE TO DELET THE OLD TEXTURE AND REPLACE IT WITH THE NEW ONE ?
 
clown369 said:
NEED HELP .. I TRIED TO EDIT WINGED HELMET WHICH IS ALREADY THERE IN THE GAME .. I MADE A NEW TEXTURE USING ABODE PHOTOSHOP .. BUT WHEN I TRY TO IMPORT THE 3D HELMET IT DOESNT WORK .. CUZ I AM NEW IN THIS ... I READ YOUSHI BOY TUTORIAL .. BUT WHEN I IMPORT MY HELMET TO BRF EDIT IT IS PINK NO TEXTURE AT ALL ..  SO DO I HAVE TO DELET THE OLD TEXTURE AND REPLACE IT WITH THE NEW ONE ?

NO YOU DO NOT NEED TO YOU CAN TRY TO TURN OFF CaPs LoCk THOUGH, because caps lock (like all things) is good in moderation.
 
I am also experiencing a syntex error. this is what it says:

SyntaxError: invalid syntax
Traceback (most recent call last):
File "C:\Program Files\Mount&Blade\Modules\ModuleSystem\process_operations.py"
, line 14, in <module>
   from module_troops import *
File "C:\Program Files\Mount&Blade\Modules\Modulesystem\module_troops.py",lin
e 312
       itm_mail_with_surcoat,itm_mail_coif],
                                      ^

anyone know how to solve this?
 
USMC Guardians USMC said:
clown369 said:
NEED HELP .. I TRIED TO EDIT WINGED HELMET WHICH IS ALREADY THERE IN THE GAME .. I MADE A NEW TEXTURE USING ABODE PHOTOSHOP .. BUT WHEN I TRY TO IMPORT THE 3D HELMET IT DOESNT WORK .. CUZ I AM NEW IN THIS ... I READ YOUSHI BOY TUTORIAL .. BUT WHEN I IMPORT MY HELMET TO BRF EDIT IT IS PINK NO TEXTURE AT ALL ..  SO DO I HAVE TO DELET THE OLD TEXTURE AND REPLACE IT WITH THE NEW ONE ?

NO YOU DO NOT NEED TO YOU CAN TRY TO TURN OFF CaPs LoCk THOUGH, because caps lock (like all things) is good in moderation.

what ? 
 
okay, never mind. all working for me now.
EDIT:er... almost all. whenever I try to start Mount&Blade, it stops loading at setting data, then when I minimise it an RGL error has popped up saying something about it unexpectedly stopping, and me needing to check  my item_kinds1.txt file. without it, according to the troop editor nobody has any weapons or armor or anything. when I check the file, none of my new equipment is added.

I am assuming, however, that this is because of a problem I'm having with my process_items.py. when I go to build_module, everything exports fine except for that. it says there's a problem with lines 65 and 43. to be more specific, it looks like this:

Exporting item data...
Traceback (most recent call last):
  File "process_items.py", line 65, in (module)
    write_items(variables,variable_uses,tag_uses,quick_strings)
  File "process_items.py", line 43, in write_items
    get_swing_damage(item[6]),
TypeError: function takes exactly 1 argument (17 given)

and in case it matters here's everything in that folder:
import string

from process_common import *
from module_items import *

def get_item_code(item):
  prefix = "it_"
  code = prefix + item[0]
  return code

def save_python_header():
  file = open("./ID_items.py","w")
  for i_item in xrange(len(items)):
    file.write("itm_%s = %d\n"%(convert_to_identifier(items[i_item][0]),i_item))
  file.close()

def write_items(variable_list,variable_uses,tag_uses,quick_strings):
  itemkinds_file_name = export_dir + "item_kinds1.txt"
  ofile = open(itemkinds_file_name,"w")
  ofile.write("itemsfile version 2\n")
  ofile.write("%d\n"%len(items))
  for item in items:
    if (item[3] & itp_merchandise) > 0:
      id_no = find_object(items,convert_to_identifier(item[0]))
      add_tag_use(tag_uses,tag_item,id_no)
    ofile.write(" itm_%s %s %s %d "%(convert_to_identifier(item[0]),replace_spaces(item[1]),replace_spaces(item[1]),len(item[2])))
    item_variations = item[2]
    for item_variation in item_variations:
      ofile.write(" %s %d "%(item_variation[0],item_variation[1]))
    ofile.write(" %d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\n""%(item[3]","item[4]","item[5]","item[7]",
                                                   get_weight(item[6]),
                                                   get_abundance(item[6]),                 
                                                   get_head_armor(item[6]),
                                                   get_body_armor(item[6]),
                                                   get_leg_armor(item[6]),
                                                   get_difficulty(item[6]),
                                                   get_hit_points(item[6]),
                                                   get_speed_rating(item[6]),
                                                   get_missile_speed(item[6]),
                                                   get_weapon_length(item[6]),
                                                   get_max_ammo(item[6]),
                                                   get_thrust_damage(item[6]),
                                                   get_swing_damage(item[6]),
                                                               )
    trigger_list = []
    if (len(item) > :cool::
      trigger_list = item[8]
    save_simple_triggers(ofile,trigger_list, variable_list,variable_uses,tag_uses,quick_strings)


  ofile.close()

print "Exporting item data..."
save_python_header()

from module_info import *

from process_common import *
from process_operations import *

variable_uses = []
variables = load_variables(export_dir,variable_uses)
tag_uses = load_tag_uses(export_dir)
quick_strings = load_quick_strings(export_dir)
write_items(variables,variable_uses,tag_uses,quick_strings)
save_variables(export_dir,variables,variable_uses)
save_tag_uses(export_dir,tag_uses)
save_quick_strings(export_dir,quick_strings)
#print "Finished with Items."
Never Mind. All fixed now.
 
I am having a bit of trouble making a new party.  Basically I am trying to create a party led by a Robin Hood type character that is not affiliated to any of the factions.  He is a stand alone party that will encounter the player party at the start of the game and with commence with a short dialogue and then to the battlefield.  Once the battle is over, the party is eliminated and will not show up again in the map.  This, for all I know, may not even be possible.  I started out by copying the peasants line and modifying the troops, spawn location and name of party.  It actually showed up on the map, but when it had a party size of zero and when I engaged the party a number of errors occur ed.  Is there a step by step on how I can obtain the above?  Any help will be appreciated.  Thanks.

The party templates:
##  ("farmers","Farmers",icon_peasant,0,fac_innocents,merchant_personality,[(trp_farmer,11,22),(trp_peasant_woman,16,44)]),
  ("village_farmers","Village Farmers",icon_peasant,0,fac_innocents,merchant_personality,[(trp_farmer,5,10),(trp_peasant_woman,3,:cool:]),
  ("village_destroyer","Village Destroyer",icon_axeman,0,fac_outlaws,soldier_personality,[(trp_npc17,1,1),(trp_hired_blade,5,10)]),##  ("refugees","Refugees",icon_woman_b,0,fac_innocents,merchant_personality,[(trp_refugee,19,4:cool:]),
##  ("dark_hunters","Dark Hunters",icon_gray_knight,0,fac_dark_knights,soldier_personality,[(trp_dark_knight,4,42),(trp_dark_hunter,13,25)]),

module factions:
("neutral","Neutral",0, 0.1,[("player_faction",0.0)], [],0xFFFFFF),
  ("innocents","Innocents", ff_always_hide_label, 0.5,[("outlaws",-0.05)], []),
  ("village_destroyer","Village Destroyer", ff_always_hide_label, 0.5,[("player_faction",-0.15)], []), 
("merchants","Merchants", ff_always_hide_label, 0.5,[("outlaws",-0.5),], []),


Module Troops:
["bandit","Bandit","Bandits",tf_guarantee_armor,0,0,fac_outlaws,  [itm_arrows,itm_spiked_mace,itm_sword_viking_1,itm_short_bow,itm_falchion,itm_nordic_shield,itm_rawhide_coat,itm_leather_cap,itm_leather_jerkin,itm_nomad_armor,itm_nomad_boots,itm_wrapping_boots,itm_saddle_horse],
  def_attrib|level(10),wp(60),knows_common|knows_power_draw_1,bandit_face1, bandit_face2],
["village_destroyer","village destroyer","village_destroyer",tf_guarantee_armor,0,0,fac_outlaws,
[itm_arrows,itm_spiked_mace,itm_sword_viking_1,itm_short_bow,itm_falchion,itm_nordic_shield,itm_rawhide_coat,itm_leather_cap,itm_leather_jerkin,itm_nomad_armor,itm_nomad_boots,itm_wrapping_boots,itm_saddle_horse],def_attrib|level(10),wp(60),knows_common|knows_power_draw_1,bandit_face1, bandit_face2],



Ok.  Here is the npc17 from the troops line (Basically I just copied the line from the npc16):

["npc16","Klethi","Klethi",tf_female|tf_hero, 0, reserved,  fac_commoners,[itm_peasant_dress,itm_nomad_boots, itm_dagger, itm_throwing_knives],
  str_7|agi_11|int_8|cha_7|level(2),wp(80),knows_tracker_npc|
  knows_power_throw_3|knows_athletics_2|knows_power_strike_1,
  0x00000000000c100739ce9c805d2f381300000000001cc7ad0000000000000000],
["npc17","Robin Hood","robin_hood",tf_hero, 0, reserved,  fac_commoners,[itm_peasant_dress,itm_nomad_boots, itm_dagger, itm_throwing_knives],
  str_7|agi_11|int_8|cha_7|level(2),wp(80),knows_tracker_npc|
  knows_power_throw_3|knows_athletics_2|knows_power_strike_1,
  0x00000000000c100739ce9c805d2f381300000000001cc7ad0000000000000000],

The Error message reads:
Script Error on Opcode 2049: Invalid Troop ID:-1:Line No:9
At Script: Setup_Party_meeting
At Script: Setup_Party_meeting
At Script: Setup_Party_meeting
At Game Menu: menu_simple_encounter
At Game Menu: menu_simple_encounter
At Game Menu: menu_simple encounter



Here is what I added in mod_game_menus:

  (try_begin),
          (eq, "$g_encountered_party_template", "pt_looters"),
          (set_background_mesh, "mesh_pic_bandits"),
        (else_try),
          (eq, "$g_encountered_party_template", "pt_mountain_bandits"),
          (set_background_mesh, "mesh_pic_mountain_bandits"),
        (else_try),
          (eq, "$g_encountered_party_template", "pt_steppe_bandits"),
          (set_background_mesh, "mesh_pic_steppe_bandits"),
        (else_try),
          (eq, "$g_encountered_party_template", "pt_sea_raiders"),
          (set_background_mesh, "mesh_pic_sea_raiders"),
        (else_try),
          (eq, "$g_encountered_party_template", "pt_forest_bandits"),
          (set_background_mesh, "mesh_pic_forest_bandits"),
        (else_try),
          (eq, "$g_encountered_party_template", "pt_village_destroyer"),
          (set_background_mesh, "mesh_pic_sea_raiders"),        (try_end),

    ],


The party on the map is static and has a party number of "0"
So from what I understand I need to fix something in mod scripts and mod game menus.. but I really don't know what or how to tweak.
What do you think?
 
Status
Not open for further replies.
Back
Top Bottom