Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Okay, so I've been posting these questions around and haven't been able to find much help yet and I don't feel like sifting through thousands of pages to see if they've already been answered, although I could try if I must. So anyway, yeah, making a small mod for me and a few friends and need help with a few things. I'm managing for the most part, but I'm still new at this.

First off, how do I get Diplomacy into my mod without overwriting what I've already done to it? If I can't do that can I use build_module without writing over the diplomacy additions?

Second, I want to create a new start where you begin as a king, but I can't seem to find any tutorials on how to do this. If there are any, or if anyone knows how to, that would be great.

Finally, is there a way to make a town start off being owned by a small group of bandits or something? My mod involves taking a town at the start of the game as your factions starting point in Calradia. If not, i'm going to have to create a whole new faction just to take it from.

There are probably a few other small things I'm forgetting, but these are my main issues. Thank you for any help!
 
projecthamster said:
First off, how do I get Diplomacy into my mod without overwriting what I've already done to it? If I can't do that can I use build_module without writing over the diplomacy additions?
you need to combine the code (source) and test, test, test, rewrite code as needed, test, ...

tools like Winmerge will be your friend.

projecthamster said:
Second, I want to create a new start where you begin as a king, but I can't seem to find any tutorials on how to do this. If there are any, or if anyone knows how to, that would be great.
look at the OSP section and you will find OSP code for that you can use or reference to

-> [LSP] KAOS Political KIT 1.5 Updated (is a good example)

projecthamster said:
Finally, is there a way to make a town start off being owned by a small group of bandits or something?
it is not hardcoded, so yes it is possible, but you will need to handle a few things on how your own module rules work to allow a "independent" sort of city. If you make those bandits a normal kingdom faction it would be much easier (just name them bandits of XXX and make them hostile to the entire world). Just one small example on how you can go around this.

modsys is quite open and you can do pretty much anything you want with gameplay rules, but how much YOU can do depends on your experience with the coding part. So go slow and tackle one issue at time.
 
@projecthamster

1.
To have a Diplomacy in your mod you can use modmerger. You can add POBD and freelancer as well, it is not so hard and what is more important files from modmerger do not change vanilla files, they are new files that integrate with your mod.
So you can read a bit about modmerger and have a lots of small and big modifications in your mod without actually having to rewrite everything. ->  https://forums.taleworlds.com/index.php/topic,320834.0.html

There is ready-to-play modmerger with diplo pobd and freelancer in one pack.

2. To be a king. You can try to implement code provided by kalarhan. However if you want just play a small mod when you start with better things then you can go as well and see this code of mine. I wrote it to make becoming 'king' as fast as possible. Few aesy commands and you get it:
   
  ##setting player stats
(troop_add_gold, "trp_player", 75000),
(add_xp_to_troop, 5000, "trp_player"),
(call_script, "script_change_player_honor", -5),
(troop_set_slot, "trp_player", slot_troop_renown, 1000),
(call_script, "script_change_doomsday_clock", 200),

#adding new troops for hero
      (party_add_members, "p_main_party", "trp_scoiatael_human_hunter", 16),
(party_add_members, "p_main_party", "trp_scoitael_commando", 16),

#giving new castles to hero  
      (call_script, "script_give_center_to_lord", "p_town_3", "trp_player", 0),
      (call_script, "script_give_center_to_lord", "p_castle_15", "trp_player", 0),
      (call_script, "script_give_center_to_lord", "p_castle_16", "trp_player", 0),
  (call_script, "script_give_center_to_lord", "p_castle_33", "trp_player", 0),
  (call_script, "script_give_center_to_lord", "p_castle_28", "trp_player", 0),

#clear 'old' army in castle
(party_clear, "p_town_3"),
    (party_clear, "p_castle_15"),
    (party_clear, "p_castle_16"),
    (party_clear, "p_castle_33"),
(party_clear, "p_castle_28"),

# add new army to a castle
(party_add_members, "p_town_3", "trp_scoiatael_human_hunter", 16),
(party_add_members, "p_town_3", "trp_scoiatael_partizan", 16),
(party_add_members, "p_town_3", "trp_scoitael_ranger", 16),
(party_add_members, "p_town_3", "trp_scoiatael_saboteur", 16),
(party_add_members, "p_town_3", "trp_scoitael_commando", 16),
(party_add_members, "p_town_3", "trp_scoiatael_commando_joined_leader", 3),

#set relation to faction4 to good (if you set it to -40 then you have war|!)

(call_script, "script_change_player_relation_with_faction", "fac_kingdom_4", 25),

(call_script, "script_change_player_right_to_rule", 40),


(else_try),

There is a command like ->  (call_script, "script_give_center_to_lord", "p_town_3", "trp_player", 0),  that gives you town nr 3. Engine will treat you as a new king, you can also add new troops to your castle/town, and so on. This is not copy-paste cause I use other troops and parties but you should get the idea.

And kalarhan was right about changing one faction to be 'Bad'. It is a lot easier than to remake bandits into a new 7th faction (which is rather not simple and needs lots of coding.

Just use something like ->
Code:
(party_add_members, "p_town_3", "trp_scoiatael_partizan", 16),
and instead trp_scoiatael_partizan put your own "bandit" or whatever.


 
HI All!

In my mod player can give orders to scouts and patrols of his own faction. (Yes, I made patrols, scouts and mercenaries to spawn again , but it is not the matter here).

So I give them orders like Patrol around town X and it works fine. However when I tell them to attack stronger enemy they always run away, changing their minds.

If I ask them to escort me it is the same, they see bigger army and come back after *I* deal with it.

So these descriptions from Lav's say:
Code:
                                             # Retrieves what position is currently used as object for AI behavior.
get_party_ai_current_behavior         = 2293  # (get_party_ai_current_behavior, <destination>, <party_id>),
                                              # Retrieves current AI behavior pattern when it was overridden by current situation (fleeing from enemy when en route to destination).
get_party_ai_current_object           = 2294  # (get_party_ai_current_object, <destination>, <party_id>),
                                              # Retrieves what party has caused temporary behavior switch.

that any ai army change its behaviour 'because something is happened' for example they met stronger army and decided to flee instead of fighting for me.

I have tried to mess with 'helpfulness' and 'courage', 'aggressivnes' but that doesn't help.

Is there any way, to turn off their AI and FORCE them to to my biddings?
Agents have this 'scripted mode' but is there something like that for parties?

Below is vanilla script that I had modiefied to work for me :
# script_party_set_simple_ai
  # Input: arg1 = party_no, arg2 = new_ai_state, arg3 = action_object (if necessary)
  # Output: given action
 
  #Party react to simple orders
 
  ("party_set_simple_ai",
    [
 
      (store_script_param, ":party_no", 1),  #who?
      (store_script_param, ":new_ai_state", 2), # what spai eg. spai_accompanying_army, spai_screening_army
      (store_script_param, ":new_ai_object", 3), #what? enemy party, or castle
 
  (store_faction_of_party, ":faction_no", ":party_no"),
 
#accompany or screen
  (try_begin),
            (this_or_next|eq, ":new_ai_state", spai_accompanying_army),
            (eq, ":new_ai_state", spai_screening_army),
           
            (party_set_ai_behavior, ":party_no", ai_bhvr_escort_party),
            (party_set_ai_object, ":party_no", ":new_ai_object"),
            (party_set_flags, ":party_no", pf_default_behavior, 0),
           
           
           
            (try_begin),
              (eq, ":new_ai_state", spai_screening_army),
              (assign, ":aggressiveness", 12),
              (assign, ":courage", 15),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 190),
            (else_try),
              (assign, ":aggressiveness", :cool:,
              (assign, ":courage", 9),
              (assign, ":initiative", 10),
  (assign, ":helpfulness", 190),
            (try_end),
(try_end),
 
 

#raid around village
(try_begin),
            (eq, ":new_ai_state", spai_raiding_around_center),
            (party_get_position, pos1, ":new_ai_object"),
            (map_get_random_position_around_position, pos2, pos1, 1),
            (party_set_ai_behavior, ":party_no", ai_bhvr_patrol_location),
            (party_set_ai_patrol_radius, ":party_no", 10),
            (party_set_ai_target_position, ":party_no", pos2),
            (party_set_ai_object, ":party_no", ":new_ai_object"),
            (party_set_flags, ":party_no", pf_default_behavior, 0),
        (party_set_slot, ":party_no", slot_party_follow_me, 1),

(try_begin),
              (assign, ":aggressiveness", 13),
              (assign, ":courage", 13),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 160),
            (try_end),
(try_end),



#attack enemy party
(try_begin),
            (eq, ":new_ai_state", spai_engaging_army),
        (party_set_ai_behavior, ":party_no", ai_bhvr_attack_party),
        (party_set_ai_object, ":party_no", ":new_ai_object"),
        (party_set_flags, ":party_no", pf_default_behavior, 0),

(try_begin),
              (assign, ":aggressiveness", 14),
              (assign, ":courage", 14),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 120),
            (try_end),

  (try_end), 




(try_begin), #scouting - try rather to scout not engage
(eq, ":new_ai_state", spai_scouting_around_center),  #scout at  - we need differ somehow from patrol...!

#but:
            #(assign, ":new_ai_state", spai_patrolling_around_center),
            (party_get_position, pos1, ":new_ai_object"),
            (map_get_random_position_around_position, pos2, pos1, 1),
            (party_set_ai_behavior, ":party_no", ai_bhvr_patrol_location),
            (party_set_ai_target_position, ":party_no", pos2),
            (party_set_ai_object, ":party_no", ":new_ai_object"),
           
            (try_begin),
              (faction_slot_eq, ":faction_no", slot_faction_ai_state, sfai_attacking_enemies_around_center),
              (party_set_ai_patrol_radius, ":party_no", 3), #line 100
            (else_try), 
              (party_set_ai_patrol_radius, ":party_no", :cool:, #line 100
            (try_end),

(try_begin),
              (assign, ":aggressiveness", 5),
              (assign, ":courage", 5),
              (assign, ":initiative", 60),
              (assign, ":helpfulness", 60),
            (try_end),
  (try_end),

#patrol around center
  (try_begin),
            (eq, ":new_ai_state", spai_patrolling_around_center),
            (party_get_position, pos1, ":new_ai_object"),
            (map_get_random_position_around_position, pos2, pos1, 1),
            (party_set_ai_behavior, ":party_no", ai_bhvr_patrol_location),
            (party_set_ai_target_position, ":party_no", pos2),
            (party_set_ai_object, ":party_no", ":new_ai_object"),
           
            (try_begin),
              (faction_slot_eq, ":faction_no", slot_faction_ai_state, sfai_attacking_enemies_around_center),
              (party_set_ai_patrol_radius, ":party_no", 1), #line 100
  (assign, ":aggressiveness", 12),
              (assign, ":courage", 12),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 260),
            (else_try), 
              (party_set_ai_patrol_radius, ":party_no", 5), #line 100
  (assign, ":aggressiveness", :cool:,
              (assign, ":courage", 9),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 160),
            (try_end),

          (party_set_flags, ":party_no", pf_default_behavior, 0),
            (party_set_slot, ":party_no", slot_party_follow_me, 1),
            (party_set_slot, ":party_no", slot_party_ai_substate, 0),

  (try_end),
 


#defend center
  (try_begin),
            (eq, ":new_ai_state", spai_retreating_to_center),
            (party_get_position, pos1, ":new_ai_object"),
            (map_get_random_position_around_position, pos2, pos1, 1),
            (party_set_ai_behavior, ":party_no", ai_bhvr_patrol_location),
            (party_set_ai_target_position, ":party_no", pos2),
            (party_set_ai_object, ":party_no", ":new_ai_object"),
           
            (try_begin),
              (faction_slot_eq, ":faction_no", slot_faction_ai_state, sfai_attacking_enemies_around_center),
              (party_set_ai_patrol_radius, ":party_no", 1), #line 100
  (assign, ":aggressiveness", 9),
              (assign, ":courage", 14),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 100),
            (else_try), 
              (party_set_ai_patrol_radius, ":party_no", 1), #line 100
  (assign, ":aggressiveness", :cool:,
              (assign, ":courage", 14),
              (assign, ":initiative", 80),
  (assign, ":helpfulness", 80),
            (try_end),

          (party_set_flags, ":party_no", pf_default_behavior, 0),
            (party_set_slot, ":party_no", slot_party_follow_me, 1),
            (party_set_slot, ":party_no", slot_party_ai_substate, 0),

  (try_end), 
 
 
 
 
          (party_set_aggressiveness, ":party_no", ":aggressiveness"),
      (party_set_courage, ":party_no", ":courage"),
      (party_set_ai_initiative, ":party_no", ":initiative"),
          (party_set_helpfulness, ":party_no", ":helpfulness"),  

  ]),

Thanks for help!
 
JuJu70 said:
KratosMKII said:
Code:
          (str_clear, s68),
          (try_begin),
            (this_or_next|is_between, ":troop_no", lords_begin, lords_end),
            (is_between, ":troop_no", companions_begin, companions_end),
              (troop_get_slot, ":troop_reputation", ":troop_no", slot_lord_reputation_type),
              (store_add, ":troop_reputation_string", ":troop_reputation", "str_personality_archetypes"),
              (str_store_string, s68, ":troop_reputation_string"),
          (else_try),
            (str_store_string, s68, "str_none"),
          (try_end),
The code above is supposed to show the lord's reputation in the notes, but all i get is "Sir" in the place of the personality string.

Here's the strings from the file:
Code:
  ("personality_archetypes", "liege"),
  ("martial", "martial"),
  ("quarrelsome", "bad-tempered"),
  ("selfrighteous", "pitiless"),
  ("cunning", "cunning"),
  ("debauched", "sadistic"),
  ("goodnatured", "good-natured"),
  ("upstanding", "upstanding"),
  ("roguish", "roguish"),
  ("benevolent", "benevolent"),
  ("mercantile", "mercantile"),

probably not a good idea to add strings and slots together
But that's how vanilla does this kind of thing.
 
KratosMKII said:
But that's how vanilla does this kind of thing.

pretty simple. Just add a test message and validate each step.

1) slot_value
2) str_base_id + slot_value = result_id
3) string using that result_id

etc. That is why we have rgl_log.txt and display_message to debug bugs. Eliminate the variables and find which step is broken.

you have all the string IDs from ID_strings.py

you can also stop using strings and use quick strings instead with a simple IF-ELSE-END block.
 
I'm trying to remove the shore effect from certain terrain types on the world map. Tried changing the shader on map_plains to the same one used on map_mountains - but no cigar.

Is it coded somewhere?
 
Cozur said:
I'm trying to remove the shore effect from certain terrain types on the world map. Tried changing the shader on map_plains to the same one used on map_mountains - but no cigar.

Is it coded somewhere?

I believe the shore effect is created by the shader blending where sea or ford tiles are adjacent. If I remember correctly, deep ocean tiles adjacent to land do not blend into a shore effect. However, parties can walk on them.
 
NPC99 said:
Cozur said:
I'm trying to remove the shore effect from certain terrain types on the world map. Tried changing the shader on map_plains to the same one used on map_mountains - but no cigar.

Is it coded somewhere?

I believe the shore effect is created by the shader blending where sea or ford tiles are adjacent. If I remember correctly, deep ocean tiles adjacent to land do not blend into a shore effect. However, parties can walk on them.

Deep ocean does - the only one that doesn't seem to do so it map_mountains - but I've been unable to figure out what causes ONLY that to avoid the shore effect.
 
How can I create new type of ammo? I found a model for one-handed crossbow, made it to be type_pistol but it obviously doesn't allow me to use default bolts as ammo. I can duplicate bolts and change their type to bullets, but it will make it possible to use them for pistol and musket which I also don't want to allow. Is there any way out?
 
Okay so I am trying to use modmerger due to the suggestion, it seems like it'd be very useful to, but there's something I can't wrap my head around. I'm not stupid, but I can be slow to understand things sometimes.

Anyway, so I installed it into the module system folder I was using for my mod and it works fine, it's all good, then it says to merge mods the other mod also has to be modmerged, but I am trying to add diplomacy. I'm guessing it's possible to edit already made mods using the module system, but whenever I do it just wipes them over with the native files... I'm obviously missing something very obvious, how do I use the module system on already made mods? Sorry if this is something very obvious or if I'm missing something, I can be very blind sometimes.

Edit: Also I do realise there is an already made pack with Dip and other useful mods in, I just feel as though going forward this is something I need to know.

Edit two: I think I may have figured it out, people have been saying it this whole time, I am dumb. Still I wont be against any more advice.
 
Looking for some help here! I'm trying to make a range of parties that would get assigned the same scenes like this:                                                 

  (try_for_range, ":center_no", roman_towns_begin, roman_towns_end),
        (try_begin),
            (party_set_slot,":town_no", slot_town_center, "scn_roman_town_center_1"),
            (party_set_slot,":town_no", slot_town_castle, "scn_roman_town_castle_1"),
            (party_set_slot,":town_no", slot_town_prison, "scn_roman_town_prison_1"),
            (party_set_slot,":town_no", slot_town_tavern, "scn_roman_town_tavern_1"),
            (party_set_slot,":town_no", slot_town_arena, "scn_roman_town_arena_1"),
            (party_set_slot,":town_no", slot_town_walls, "scn_roman_town_walls_1"),
        (try_end),
    (try_end),

Although I don't get any errors, it isn't working in-game. So I'm probably doing this completely wrong... :lol: 
Can anyone send me in the right direction?

Thanks in advance!
 
Alright so I've been working on a system that returns a thrown weapon back to it's thrower via some dumb hackery, and right now it works pretty well.

range_equation_initial_velocity.png


Since we know the distance (R), gravity (g), and we determine the angle (theta), all we need is the speed, right?

My issue is that during testing to simplify the math I used a 45 degree angle (sin2(45))=1, eliminating the denominator). The problem with that is a 45 is the most efficient path for a projectile so it launches back at a pretty leisurely pace, and I wanna feel like ****ing Thor.

I was trying to update the math so I can use any angle, but I seem to be running into some issues with it.

So the formula I'm using (that works) is:
Code:
				(store_mul, ":speed_prime", ":distance", 981),				# v = sqrt((d*g)/(sin(2 a)))
				(store_sqrt, ":speed", ":speed_prime"),					# if a = 45 it becomes sqrt(d*g)

The formula I'm trying to use that doesn't work, but should, is:
Code:
				# ##########################################
				# ## For Modular Speed Function ############
				# # v = sqrt(((d)*(g))/(sin(2 a))) #########
				# ### d = distance, g = gravity, a = angle #
				# ##########################################
				
				# (assign, ":chosen_angle", 15),
				
				# (store_mul, ":numerator", ":distance", 981),
				# (store_mul, ":2theta", ":chosen_angle", 2),
				# (store_sin, ":denominator", ":2theta"),
				
				# (store_div, ":speed_prime", ":numerator", ":denominator"),
				
				# (store_sqrt, ":speed", ":speed_prime"),

I think the problem is the numbers get too big so it just becomes a 0 instead.
Can someone more mathematically minded help me out here?

Also, the the fixed_point_multiplier is set to 100 and the returning weapon does ignore friction. Just so no one pulls that old phun physics chestnut
 
@SupaNinjaMan
Add debug messages after each operation to check the results.

Also keep in mind that before manipulating a value by a math operation that uses the fixed point multiplier, the value must be multipied by that.

More related Info;
_Sebastian_ said:
Fire_and_Blood said:
using the math operations, what does "fixed point numbers" refer to? Does it still have decimal points?
It simply multiplies the result <destination_fixed_point> with the given fixed point multiplier, allowing for more precise calculations.
Keep in mind that <value_fixed_point> has to be multiplied by the fixed point value before using the specific math operation.

Lets say you want to find out the square root of 123 and the result should be accurate to 3 decimal places;
Code:
(assign, ":value", 123),
(val_mul, ":value", 1000),
(set_fixed_point_multiplier, 1000),
(store_sqrt, ":result", ":value"),
":result" would be 11090.
 
Status
Not open for further replies.
Back
Top Bottom