Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Look this stuff up, goldarn it.

The fact that ti_once is there in place of an integer should tell you that it's a constant with a value. It's defined in header_triggers.py as an arbitrary big number. So putting ti_once in the re-arm field means the trigger comes back into effect after three-four years in real time letting the game run. (i.e. never).

The delays stuff is easy to work out. If you're lost just add all three numbers and you'll get the total time for the trigger to reset.

simple_triggers is probably a ram-saving thing as you said. There's no reason to out them in module_triggers. All you're missing out on is the delay values and the conditions field, neither of which are necessary when you can stick the consequences and conditions together like in simple_triggers.
 
Thanks for the reply. People don't learn unless this is explained. The comments in the files provide minimal explanation. I am adding them to my source files as I learn here.

The fact that ti_once is there in place of an integer should tell you that it's a constant with a value. It's defined in header_triggers.py as an arbitrary big number. So putting ti_once in the re-arm field means the trigger comes back into effect after three-four years in real time letting the game run. (i.e. never).
I realize it triggers once. But doesn't that trigger mean it is checking for that condition if it hasn't occurred yet happen every 0.1 hours like it says? I am worried about that trigger as it is an add-on by idibil.

I don't quiet understand this statement:
All you're missing out on is the delay values and the conditions field, neither of which are necessary when you can stick the consequences and conditions together like in simple_triggers.
I would like to force the simple triggers to occur 12 hours after they're currently happening. How can I do this within simple triggers if it only lets me state the interval "How frequently this trigger will be checked"?

If this is too big of a question, I will make a forum thread on it.
 
wrwlf said:
Vornne said:
wrwlf said:
For example, if I change the fixed point multiplier, will it reset to it's default/previous value upon leaving my code block (whatever that may be...)?
No: I think it is reset to 100 at certain times (not exactly sure when, but maybe once per frame), but I suggest you always set the fixed point multiplier to what you need in the same trigger or script block before using any operations that are affected by it. I have had problems in the past where a position related script would sometimes work correctly, other times not; probably depending on whether the engine ran it before or after presentation triggers using a 1000 or 10000 fixed point multiplier.

I guess (hopefully) every code block which needs a specific multiplier will set it itself (oh the joys of programming with mutable global flags/vars  :facepalm:)

EDIT: This position code is driving me nuts, seems like I cannot get a consistent measurement in-game (referring to my question on the previous page about spawning an item flat/flush with the terrain by altering it's rotation).
Has anyone else ever attempted this? Or maybe somebody with some more experience with the position_* ops can provide some more insight.

All I want is to find angle "alpha" in this case:
example2.jpg

Here's my test code so far:
Code:
        # experimenting with precision values...
        (set_fixed_point_multiplier, 10000),
        (get_player_agent_no, l.player),
        (agent_get_position, pos0, l.player),
        
        (copy_position, pos1, pos0),
        
        (position_move_y, pos1, 60),
        (position_set_z_to_ground_level, pos1),
        
        (position_get_z, reg0, pos0),
        (position_get_z, reg1, pos1),
        (display_message, "@Original Height: {reg0}", 0x0000FF),
        (display_message, "@Offset   Height: {reg1}", 0x00FF00),
        
        (assign, l.offset_oppDIVadj, reg1),
        (val_mul, l.offset_oppDIVadj, 100),
        (val_div, l.offset_oppDIVadj, 60),
        (store_tan, l.offset_tan, l.offset_oppDIVadj),
        (store_atan, l.offset_rot, l.offset_tan),
        
        (assign, reg0, l.offset_rot),
        (display_message, "@Offset Rotation Angle: {reg0}", 0x00FF00),
        (position_rotate_x_floating, pos0, l.offset_rot),

        (set_spawn_position, pos1),
        (spawn_item, itm.test, 0, 0),

Definitely appreciate any help, thanks!

Here's my latest try:

Code:
        (set_fixed_point_multiplier, 10000), # 'um' unit
        (get_player_agent_no, l.player),
        (agent_get_position, pos0, l.player),
        
        #
        #         pos2
        #          |\
        #          | \
        #          |  \
        #  pos1 -> |___\ <- pos0
        #          |   /
        #          |  /
        #          | /
        #          |/
        #         pos2(negative, not handled yet!)
        #
        (copy_position, pos1, pos0),
        (position_move_y, pos1, 60),
        (copy_position, pos2, pos1),
        (position_set_z_to_ground_level, pos2),
        # TODO check for negative(s) to change sign on angle
        (get_distance_between_positions, l.dist12, pos1, pos2), # opposite
        (get_distance_between_positions, l.dist01, pos0, pos1), # adjacent
        (val_mul, l.dist12, 100), # convert 'cm' to 'um'
        (val_mul, l.dist01, 100), # convert 'cm' to 'um'
        (assign, reg0, l.dist12),
        (display_message, "@Distance 1->2: {reg0}", 0x0000FF),
        (assign, reg0, l.dist01),
        (display_message, "@Distance 0->1: {reg0}", 0x0000FF),
        (convert_to_fixed_point, l.dist12),
        (store_div, l.oa, l.dist12, l.dist01),
        (assign, reg0, l.oa),
        (display_message, "@Opp/Adj: {reg0}", 0x0000FF),
        (store_tan, l.tan, l.oa),
        (assign, reg0, l.tan),
        (display_message, "@Tangent: {reg0}", 0x0000FF),
        (store_atan, l.angle, l.tan), 
        
        (assign, reg0, l.angle),
        (display_message, "@Angle: {reg0}", 0x00FF00),
        
        (position_rotate_x_floating, pos0, l.angle, 1),   
        (set_spawn_position, pos0),
        (spawn_item, itm.test, 0, 0),

Problem seems to be that the 'opposite' length (height difference z_pos2 -> z_pos1) is generally orders of magnitude smaller than the corresponding 'adjacent' length, so the angle always turn out tiny. Even when standing next to a very steep incline (which looks by inspection to have an angle >45*), the calculated angle result is still tiny.

I would assume 'position_set_z_to_ground_level' would be the correct operation to set the pos2 z-coord to the terrain at those xy-coords.

Has anyone ever dealt with 'scene' position math? I've scoured the forums and only found an old post about fireballs, which did not really help me much (seems that guy's problem was mostly fixed-pt math and wrong op related, http://forums.taleworlds.com/index.php?topic=265612.10).

EDIT: Massive derp moment....I was doing tan(o/a) and then arctan(tan(o/a)) instead of arctan(o/a)... :lol: (trig...it's been a while)
Fixed it now and code works!
 
gdwitt said:
I would like to force the simple triggers to occur 12 hours after they're currently happening. How can I do this within simple triggers if it only lets me state the interval "How frequently this trigger will be checked"?
you don't, as they were not created for that. They are a "simple" trigger, so you use them for "simple" cases (always happen in a know interval).

If you need advanced conditions and timer control you use the "normal" triggers, which let you do whatever you want.

like @jacobhinds said this kind stuff is already on the community written tutorials or part of a normal modder exploration routine (learn by doing it), so yeah you won't find it written inside a mod source code
 
Thanks for the information Kalarhan and Jacob.
I'm not sure that solves the stuttering problem, but I will keep experimenting with triggers.
How would you code this example to go off at say, 2am:
Code:
(1.0, 8, 24.0, [],
  [
    (call_script, "script_refresh_special_merchants1"),
    (display_debug_message,"@refresh_special_merchants1"),
  ]),
And how would I add a time to a debug message?
It appears that every new game has a different 24 hour clock on the script run-time.
They are usually at 6 am or about 3pm.

Another simple question:
How do I force troops to spawn with a weapon?
I have bandits spawning with only rocks to throw.
Here is the troop:
["looter","Theow","Theows",0,0,0,fac_outlaws,
[itm_stones1,itm_slingrocks,itm_basic_sling,itm_stones1,itm_slingrocks,itm_basic_sling,itm_ankleboots,itm_cheap_shoes,itm_woolencap_newblu,itm_woolencap_newgrn,itm_head_wrappings,itm_ptunic3,itm_ptunic1,itm_ptunic3,itm_briton_tunic2,itm_briton_tunic2,itm_thick_body,itm_knifechp,itm_clubcudgel,itm_clubsmooth,itm_sickle,itm_axe1,itm_club_stick,itm_axe2],def_attrib|level(15),wp(110),knows_common,bandit_face1,bandit_face2],

These guarantess only work for armors, correct?
tf_guaranteeexhorhelm = tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_shield|tf_guarantee_ranged
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|
 
gdwitt said:

use this operations for time
Code:
is_currently_night         = 2273  # (is_currently_night),
                                   # Checks that it's currently night in the game.
map_free                   =   37  # (map_free),
                                   # Checks that the player is currently on the global map and no game screens are open.

# Time-related operations
store_current_hours        = 2270  # (store_current_hours, <destination>),
                                   # Stores number of hours that have passed since beginning of the game. Commonly used to track time when accuracy up to hours is required.
store_time_of_day          = 2271  # (store_time_of_day, <destination>),
                                   # Stores current day hour (value in 0..24 range).
store_current_day          = 2272  # (store_current_day, <destination>),
                                   # Stores number of days that have passed since beginning of the game. Commonly used to track time when high accuracy is not required.

are you sure the agents don't have a melee weapon? Create a logger that loops all agents and lists which weapons they have, as you could have a bug with your scripts to choose a weapon. They should start with a dagger or similar weapon, and choose the stone as primary if they are setup (skills and flags) as ranged units
 
So far, it's just the bandits and theows doing the no-weapon thing.
The other bandit groups are fine.
I moved the weapons to the front of the string in troop inventory.
I checked to see if they are doing formations and they are not set to formations.
The other possibility is that the script_force_weapon, is causing trouble. I haven't touched that one.

Do bandits follow the same mission_template as the player?

"lead_charge",mtf_battle_mode|mtf_synch_inventory,charge,
  "You lead your men to battle.",
    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ], [
      (ti_on_agent_spawn, 0, 0, [], [
        (store_trigger_param_1, ":agent_no"),
        (call_script, "script_force_weapon", ":agent_no"), ###chief anadido para forzar jabalinas#line13here
        ##gdw put (call_script, "script_equip_best_melee_weapon", ":agent", 1, 0, ":fire_order"),

        (call_script, "script_agent_reassign_team", ":agent_no"),
        (assign, ":initial_courage_score", 4000), #chi
 
What about adding this to a simple trigger that I suspect is 1 primary cause:
Code:
 #POLITICAL TRIGGERS
	#POLITICAL TRIGGER #1`
   # (8, #increased from 12
 (8, #increased from 12##gdw was at 4 for BW 1.41 081715
    [	 
       (store_time_of_day, ":cur_hour"),
       (ge, ":cur_hour", 20), plus (or less than 6)
	(call_script, "script_cf_random_political_event"),

Would that time check mess up the trigger somehow?
Is the logic: 1) It's 8 hours, check simple trigger
2) It's not after 20, skip
I don't want to skip the trigger if it's before 6am.
Is there a way to check greater than 20 but less than 6?

Should I start a separate thread for this issue?
 
Use friggen debugs mayne. Spam "display_message" whenever possible and use your own logic to work out how the system works.

jacobhinds said:
You'll learn a lot, lot faster this way. If you try to jump into modelling coding without comparing your work to the hundreds of working examples the developers have very kindly given you, you'll end up creating a new topic for the thousands of increasingly complex problems you are inevitably going to face if you decide to do more than just create items change integers.
 
gdwitt said:
Should I start a separate thread for this issue?

guess so, as the moderator created one for you: http://forums.taleworlds.com/index.php/topic,336421.0.html

I can't help with AI, as my advice was skipped, so now it is up to you to explore it deeper

kalarhan said:
gdwitt said:
I usually can solve problems by looking at code I've changed, but I didn't change any scripts for politics except the one here where I shortened days between

You answered your own question there. You have two alternatives:

1) spend weeks learning how AI works in Warband and Brytenwalda
2) revert the changes you don't understand

learning how the AI works and how you can change it would be a great way to alter the mod. But you need to see if it the Reward x Cost is worth to you right now

Good luck (AI code is quite complicate, but quite cool to explore and learn as well)
 
I have a little problem. I have two helmets and they have a texture etc. In BRF they get shown correctly.. now IG they are not shown correctly (only white surface).
Now.. I have the textures 100% definitely and sure in textures.brf and I am 100% sure that they load IG.

What could cause such a thing even if the textures are loaded?
 
I can't find a guide to debugging.
I need a simple way to insert tracking statements after many simple triggers that will print to the rgl_log.
I've been trying to use display_debug_message, but it's not showing up in the rgl.

I need it to print in normal game mode so I can troubleshoot errors from new mod players.
I know the method below works, but it's too large and clumsy and I need a method that will print when not in cheat mode.
(try_begin),
  (eq, "$cheat_mode", 1),
  (try_begin),
    (is_between, ":center_to_attack", centers_begin, centers_end),
    (str_store_party_name, s4, ":center_to_attack"),
    (display_message, "@{!}Best offensive target {s4} has value level of {reg1}"),
  (else_try),
    (display_message, "@{!}No center found to attack"),
  (try_end),

  (try_begin),
    (is_between, ":most_threatened_center", centers_begin, centers_end),
    (str_store_party_name, s4, ":most_threatened_center"),
    (assign, reg1, ":threat_danger_level"),
    (display_message, "@{!}Best threat of {s4} has value level of {reg1}"),
  (else_try),
    (display_message, "@{!}No center found to defend"),
  (try_end), 
(try_end),

Here's a sample of the use of display_debug_message in Brytenwalda's original source files:
(try_begin),
    (le, ":right_dist", ":left_dist"),
(copy_position, pos1, pos3),
(display_debug_message,"@right_position"),
(scene_prop_set_slot, ":ship1_instance", 14, ":ship2_instance"),
(scene_prop_set_slot, ":ship1_instance", 15, 0), # because it is possible that the position is changing in the three steps
  (else_try),
    (le, ":left_dist", ":right_dist"),
    (copy_position, pos1, pos4),
(display_debug_message,"@left_position"),
(scene_prop_set_slot, ":ship1_instance", 15, ":ship2_instance"),
(scene_prop_set_slot, ":ship1_instance", 14, 0), # because it is possible that the position is changing in the three steps
  (else_try),
    (display_debug_message,"@ERROR!_KEINE_ENTSCHEIDUNG!"),
  (end_try),
  ### OUTPUT
  (val_sub, ":boarding_progress", 1),
  (scene_prop_set_slot, ":ship1_instance", 16, ":boarding_progress"), 
(try_end),

I'm imitating this but not getting any output.
 
gdwitt said:
I can't find a guide to debugging.
I need a simple way to insert tracking statements after many simple triggers that will print to the rgl_log.

create a custom operation using WRECK for printing debug messages that are locked by one (or more) Python variables (so you can turn it/them ON or OFF at compile time) and you are set.

I posted a very early version of my own extensions here http://forums.taleworlds.com/index.php/topic,325102.msg7771552.html#msg7771552

I now use compiler processor to create a automatic log message with the variables values, but you can use that simple form or something more advanced as you may require.

I also posted earlier in this thread  a way to inject debug code in triggers (can be used anywhere really) using Python, so you do not need to insert them manually.
 
So, hey folks, I have a question:

I am looking at a module system for a third party, the module system itself is pretty old and had a good deal of syntax errors. I fixed most, although a problem escapes me and annoys me. In module_items it gives me a "item not defined" error for an item that is very much defined. That happens even if I erase the item entry completely and put something else in its place, even entirely different. The message appears again, this time with the name of the new entry. There are no syntax error and at one time, I copied an exact entry from above and just altered the entry name, like "itm_name1" to "itm_name2". Nothing, it seems as if it has some problem to do with the line.  :???:

The exact same thign happens with a troop entry, out of the close to 2000 that exist in there.

Any help would be greatly appreciated. Thank you!  :smile:
 
Antonis said:
So, hey folks, I have a question:
I am looking at a module system for a third party, the module system itself is pretty old and had a good deal of syntax errors. I fixed most, although a problem escapes me and annoys me. In module_items it gives me a "item not defined" error for an item that is very much defined. That happens even if I erase the item entry completely and put something else in its place, even entirely different. The message appears again, this time with the name of the new entry. There are no syntax error and at one time, I copied an exact entry from above and just altered the entry name, like "itm_name1" to "itm_name2". Nothing, it seems as if it has some problem to do with the line.  :???:

The exact same thign happens with a troop entry, out of the close to 2000 that exist in there.

Any help would be greatly appreciated. Thank you!  :smile:

1) Which compiler are you using? Native, WRECK, something else?
2) Did you remove the item usage, compiled and then tried to add it back? Or in other words, check if the item is listed on your ID_items.py (remember that with native compiler you first need to add a item, compile the code, then give that item to a troop and compile again... so you get a updated ID_xxxx.py index)
3) If all that fails you will need to post the exact error message here, plus the snippets
 
Thanks, I haven't tried to update the ids, I figured it would already be there. It's for the 'Europe 1200' mod, the team started working again on it and contacted me. So, I figured they would have a solid module system.  :???:

I use Native on that one, by the way. Normally, I use WRECK, it makes life easier, especially in situations like that. But the module files are pretty messed up, so I figured I tried with the native compiler for compatibility. Thanks!
 
Well I load:
load_mod_resource = textures
at the top. Then the normal resources of the game is loaded.
Then mod resources.... load_mod_resource = HELMETS.

The weird thing is, all helmets work except two.
 
I need a guide for simple destructible walls for AoFI's cannons. I've made that, but it is not working;

Code:
("destructible_wall_damage_receive",
	[
	(store_script_param_1, ":projectile_instance"),
        (store_script_param_2, ":wall_instance"),
        (store_script_param  , ":damage", 3),
 (try_begin),
 (multiplayer_is_server),
 (game_in_multiplayer_mode),
 (assign, ":wall_hitpoints", wall_health), # wall health is 2500
 
 (this_or_next|scene_prop_get_instance, ":projectile_instance", "spr_mp_cannonball_3lb"), #get instances
 (this_or_next|scene_prop_get_instance, ":projectile_instance", "spr_mp_cannonball_6lb"),
 (scene_prop_get_instance, ":projectile_instance", "spr_mp_cannonball_12lb"),
 
 (prop_instance_get_position, pos1, ":projectile_instance"), #get the positions of instances
 (prop_instance_get_position, pos2, ":wall_instance"),
 
 (prop_instance_is_valid, ":wall_instance"), # ask that props are valid
 (prop_instance_is_valid, ":projectile_instance"),
 
 (get_distance_between_positions, ":destination", pos1, pos2), # if it is valid, ask the distance between them
 (le, ":destination", 5), # check if distance between them is lower than 5
  (try_begin), # start the party :)
  (eq, ":projectile_instance", "spr_mp_cannonball_3lb"),
  (assign, ":damage", 200),
  (val_sub, ":damage", ":wall_hitpoints"), #subtract the damage number i assigned to cannonball from wall_hitpoints.
  (display_message, "@debug: delivered 200 damage with 3lb ball!"),
  (else_try),
  (eq, ":projectile_instance", "spr_mp_cannonball_6lb"),
  (assign, ":damage", 400),
  (val_sub, ":damage", ":wall_hitpoints"),
  (display_message, "@debug: delivered 200 damage with 6lb ball!"), # show a note for debug.
  (else_try),
  (eq, ":projectile_instance", "spr_mp_cannonball_12lb"),
  (assign, ":damage", 750),
  (val_sub, ":damage", ":wall_hitpoints"),
  (display_message, "@debug: delivered 200 damage with 12lb ball!"),
  (try_end),
  (try_end),
	]),
	
	("destructible_wall_init",
	[
	(store_script_param_1, ":wall_instance"),
 (store_script_param_2, ":wall_hitpoints"),
 (try_begin),
 (assign, ":wall_hitpoints", wall_health), # wall_health is 2500
 (try_for_range, ":wall_instance", walls_begin, walls_end), # try for the walls i signed
 (try_begin), # start the destroying
 (le, ":wall_hitpoints", 0), # if wall hitpoints is equal to 0 or lower than 0
 (play_sound, "snd_dummy_destroyed"), # play the sound
		
		(prop_instance_get_position, pos1, ":wall_instance"), #get the instance
		
		(particle_system_burst, "psys_dummy_smoke", pos1, 15), # handle the particles
        (particle_system_burst, "psys_dummy_straw", pos1, 25),
		
		(try_begin),# start the replacing with an empty prop.
	      (multiplayer_is_server),
		  (set_spawn_position, pos1),
		  (spawn_scene_prop, "spr_empty"),# spawn the empty prop
		  (position_set_z, pos1, -1200),
		  (prop_instance_animate_to_position, ":wall_instance", pos1, 4), # move the destroyed wall to underground. But i want that make in 4 secons, i dont know i did correctly.
		  (prop_instance_clear_attached_missiles, ":wall_instance"), # clear the arrows attached to wall, if i dont do that, missiles will be stay in air.
		(try_end),
		(try_end),#end...
		]),

Code:
destructible_init = (ti_on_init_scene_prop,
 [

(assign, ":wall_instance", 1),
(assign, ":wall_hitpoints", wall_health),
 
 (call_script, "script_destructible_wall_init", ":wall_instance", ":wall_hitpoints"),
 
 ])
 
destructible_wall_damage_system = (ti_on_init_scene_prop,
[
(assign, ":projectile_instance", 1),
(assign, ":wall_instance", 1),
(assign, ":damage", 1),
 (call_script, "script_destructible_wall_damage_receive", ":projectile_instance", ":wall_instance", ":damage"),
 
 ])

In the game, there is no errors and positive result. Where's my fault ?

Also, assigning the variables on wall_damage_system was necessary, it was giving unassigned local variable warning.
 
Dirk Robbing said:
How is music changed during a fight once the first song is over? Is it possible to direct it to call a script or does it just automatically decide anything with mtf_sit_fight or whatever? Same with the world map.

Basically I'm trying to make music more culture/situation specific, similar to the way Pendor has done it.
Anyone got an idea?
 
Status
Not open for further replies.
Back
Top Bottom