Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Alright, great, thanks! Got the texture working, and elephants now sort of work.

Onto the next question: How do I make the riders position to be higher? I understand that I need to most propably make new animations for elephants, but I have seen riders being higher than normal, like Meep Meep in Invasion, if anyone remembers.

Heres a few screenshots of the current progress. I will release elephants rigged and stuff as OSP if I ever get this to work :razz:

mbwarband20101220222751.jpg
mbwarband20101220222753.jpg
mbwarband20101220223146.jpg
 
Comrade Temuzu said:
Onto the next question: How do I make the riders position to be higher?
There is a parameter in WB to specify mount scale. Somewhere in items, I believe
Be warned that this just scales up horse skeleton  no matter skin you use for a mount, so hitboxes will be way off for elephants. Only single skeleton for all the mounts is possible. Not to mention single set of animations and sounds.
 
flyingchicken said:
With operations that ask for a <player_id>, like player_get_gender, how do you get the player_id? How do the conditional operations (like lt, ge, etc) work? found http://forums.taleworlds.com/index.php/topic,142422.msg3420094.html#msg3420094
Glad that was useful.

flyingchicken said:
EDIT: Okay, how about: Where is the thing that regularly updates village volunteer troops?
In Module_scripts. The script name is something very similar to what you've asked for here (unfortunately I don't have the module system infront of me).
 
Does someone know if the falling damage is affected by the weight of the items you are wearing? And so, can you modify this somewhere in the module system? Or add a factor that can increase or decrease the amount of falling damage you get when you fall?
 
What happened to reg64? In header_common, it's simply not defined, yet we have a reg65. Is it used for something special?
On a similar note, what's with pos64? Is it used solely for the belfry? Can we treat it like a normal pos register in all other cases?
 
MadocComadrin said:
On a similar note, what's with pos64? Is it used solely for the belfry? Can we treat it like a normal pos register in all other cases?

I believe it can be used. I've used high-range positions without error before.


EDIT...a question:
Has anyone used/tested the new ti_on_agent_dismount mission template trigger yet? If so, does it fire only when an agent dismounts by choice, or also when the agent's horse is killed and the 'dismount' is forced?

EDIT 2:
It would appear that it only fires when an agent is ordered to dismount by the player in SP. Can any confirm?
 
Caba`drin said:
EDIT 2:
It would appear that it only fires when an agent is ordered to dismount by the player in SP. Can any confirm?

confirmed on custom battle

Edit :
The bright side is I think I found the way to catch a forced dismount event. I tested already. We can use ti_on_agent_killed_or_wounded.
Horse killed will trigger that too, so we just check  (store_trigger_param_1, ":agent_no"), (neg|agent_is_human, ":agent_no"), to get the horse killed agent ID. But then we just can't use (agent_get_rider, ":troop_agent_rider", ":agent_no"), on a dead horse, because dead horse has no rider.
We must call (agent_get_rider, ":troop_agent_rider", ":agent_no"), before the horse killed. When the mission started, and when ti_on_agent_mount/dismount occured, and save/remove the rider agent id into/from horse agent slot.
 
dunde said:
Caba`drin said:
EDIT 2:
It would appear that it only fires when an agent is ordered to dismount by the player in SP. Can any confirm?

confirmed on custom battle

Edit :
The bright side is I think I found the way to catch a forced dismount event. I tested already. We can use ti_on_agent_killed_or_wounded.
Horse killed will trigger that too, so we just check  (store_trigger_param_1, ":agent_no"), (neg|agent_is_human, ":agent_no"), to get the horse killed agent ID. But then we just can't use (agent_get_rider, ":troop_agent_rider", ":agent_no"), on a dead horse, because dead horse has no rider.
We must call (agent_get_rider, ":troop_agent_rider", ":agent_no"), before the horse killed. When the mission started, and when ti_on_agent_mount/dismount occured, and save/remove the rider agent id into/from horse agent slot.

Thanks for the confirmation, dunde. I'd considered looking into the killed/wounded trigger, but was hoping for a short cut around marking the agent in a slot at mission start and then using that upon dismount or death.  But, looks like that's what will be needed. Thanks again for the further testing!
edit: I worked out what I was doing in the format you had suggested and posted a retro-style original M&B dehorsed cavalry becoming infantry 'tweak' using it here.



EDIT: To continue from a question I stated earlier...
Caba`drin said:
I was hoping someone more versed in this area might be able to shed some light: are there complications to using spawn_agent from within a mission_template to add other agents to a scene (say in a town) DURING the mission, rather than setting them as visitors through the game menu PRIOR to the mission beginning?

Heroes injured in-scene, are injured in party after the scene ends, which was one oversight I was worried about. I've not tested with non-hero troops though. Are there reasons I should use the visitor commands instead?
Somebody said:
A combination of the two, add_visitors_to_current_scene doesn't seem to work too well inside battles - at least when they're randomly generated (the entry points that is). Non-hero spawned troops just get added to casualties like any other troop. Some variables may not be set for spawned agents, like the values for agent_get_party_id or agent_get_entry_no, but I don't really know of any other complications.

...it appears that spawning Hero-troops from within a mission_template causes appearance problems: they show up without hair, or with the wrong hair or beard and sometimes with the wrong face. Their gear is always correct, however.

I'm assuming this has something to do with their "dna"? If that's the case, it can be acquired from the party list, but only set via the visitor code NOT from spawning an agent. And rather than being ready to release this bit of code, I need to completely rework it...though I'd still much rather deal with it within the mission template rather than prior to mission start in the menu.
 
I've experienced that problem too - but usually the spawned character is wearing a helmet, so it's not too noticeable. DNA also determines equipment loadout, so it has different implications for hero and regular troops. Also, have you experimented with entry_point_set_position in conjunction with visitors? I haven't had much success with using that inside quick battles, but I thought I'd post a code snippet which makes use of spawn_agent, allowing you to respawn as yourself or a certain agent being spectated. Set $g_hp_bar_key, $dmod_current_agent (see deathcam), and $g_player_troop to $g_quick_battle_troop or something for the code to work.

Code:
    (try_begin),#respawn
      (main_hero_fallen), #when dead
      (key_is_down, "$g_hp_bar_key"),
      (eq, "$g_battle_result", -1),#death already triggered
      (get_player_agent_no, ":player_agent"),
      (assign, "$g_battle_result", 0),#same as in beginning
      (assign, "$g_battle_won", 0), #this battle isn't over
      (agent_get_position, pos3, ":player_agent"),
      (set_spawn_position, pos3),
      (agent_get_team, ":player_team", ":player_agent"),
      # (assign, "$dmod_move_camera", -1),
      (mission_cam_set_mode, 0),#end camera
      (try_begin), #recently died
        (eq, "$dmod_current_agent", -1),
        (troop_set_inventory_slot, "$g_player_troop", ek_horse, -1),#remove your horse
        (troop_equip_items, "$g_player_troop"),
        (set_spawn_position, pos63), #this pos was stored on death
        (spawn_agent, "$g_player_troop"),
        (assign, ":player_agent", reg0),
        (try_begin),
          (position_get_distance_to_terrain, ":distance", pos63),
          (lt, ":distance", 500), #5 meters?
          (init_position, pos62),
          (position_set_z_to_ground_level, pos63), #ground
          (position_copy_rotation, pos63, pos62), #clear rotation
          (set_spawn_position, pos63),
          (spawn_scene_prop, "spr_grave_a"), #marker - might also cover body
        (try_end),

        (play_sound, "snd_unhide"),#will probably get annoying
      (else_try),
        (agent_is_alive, "$dmod_current_agent"),
        (agent_get_troop_id, ":troop", "$dmod_current_agent"),
        #we get a bunch of parameters
        (agent_get_wielded_item, ":item", "$dmod_current_agent", 0),
        (try_begin),#melee
           (call_script, "script_cf_is_melee_weapon_for_tutorial", ":item"),
           (assign, ":ammo", -1),
        (else_try),#is ranged
           (agent_get_ammo, ":amount", "$dmod_current_agent", 1),#ammo amount
           (gt, ":amount", 0),
           #get ammo type
           (assign, ":end", "itm_pilgrim_disguise"),
           (try_for_range, ":ammo_type", "itm_arrows", ":end"),
             (agent_has_item_equipped, "$dmod_current_agent", ":ammo_type"), #ammo counts as equipped?
             (assign, ":ammo", ":ammo_type"),
             (assign, ":end", "itm_arrows"),
           (try_end),
        (try_end),
        (agent_get_position, pos3, "$dmod_current_agent"),
        (agent_get_look_position, pos4, "$dmod_current_agent"),
        (store_agent_hit_points, ":hp", "$dmod_current_agent"),
        (agent_get_horse, ":horse", "$dmod_current_agent"),

        (try_begin), #dismounted
          (lt, ":horse", 0), #invalid agent
          (troop_get_inventory_slot, ":horse_item", ":troop", ek_horse),
          (troop_set_inventory_slot, ":troop", ek_horse, -1), #hopefully this won't **** up
        (else_try), #mounted
          (agent_get_item_id, ":horse_item", ":horse"),
        (try_end),

        (set_spawn_position, pos3),#distinguish from player hero's corpse
        (set_player_troop, ":troop"),
        (spawn_agent, ":troop"),
        (assign, ":player_agent", reg0),

        #parse inventory (thanks to agent_un/equip_item),
        (troop_get_inventory_capacity, ":cap", ":troop"),
        (try_for_range, ":slot", 0, ":cap"),
          (troop_get_inventory_slot, ":equipment", ":troop", ":slot"),
          (gt, ":equipment", 0),
          (try_begin),
            (agent_has_item_equipped, "$dmod_current_agent", ":equipment"),
            (neg|agent_has_item_equipped, ":player_agent", ":equipment"),
            (agent_equip_item, ":player_agent", ":equipment"),
          (try_end),
        (try_end),
        (try_begin), #dismounted
          (lt, ":horse", 0), #invalid agent
          (troop_set_inventory_slot, ":troop", ek_horse, ":horse_item"), #restore mount?
        (try_end), #mounted

        (agent_fade_out, "$dmod_current_agent"),#doppleganger culled off
        (party_remove_members, "p_ally_casualties", ":troop", 1), #not actually dead (yet) until you get killed again

        #apply to player
        (agent_set_look_target_position, ":player_agent", pos4),
        (agent_set_wielded_item, ":player_agent", ":item"),
        (agent_set_hit_points, ":player_agent", ":hp"),
        (try_begin),
          (gt, ":amount", 0),
          (gt, ":ammo", -1),
          (agent_set_ammo, ":player_agent", ":ammo", ":amount"),
        (try_end),
        (play_sound, "snd_hide"),#will probably get annoying
        (agent_set_team, ":player_agent", ":player_team"),#otherwise backstabbed
      (try_end),
    (try_end),

Here's a more comprehensive bunch of code - one slot associates both rider and horse. Haven't tested this one yet, but it should work similar to your code.
keep in mind that if you never had any cavalry/infantry group in your party in the first place when the encounter began, the battle presentations won't show the new divisions as a group. Make a check and set for group#_has_troop or something in script_agent_dismount and common_battle_cavalry_mount or something. If ti_on_agent_spawn works for horses when they spawn and fetch the rider properly then common_battle_cavalry_init can be simplified.
Code:
common_battle_cavalry_death = (
  ti_on_agent_killed_or_wounded, 0, 0, [],
  [
    (store_trigger_param_1, ":agent"),
    (try_begin),
      (agent_is_human, ":agent"),
      (call_script, "script_agent_dismount", ":agent"),
    (else_try), 
      (agent_get_slot, ":other", ":agent", slot_agent_mount),
      (call_script, "script_agent_dismount", ":other", ":agent"),
    (try_end),
  ])
common_battle_cavalry_init = (
  1, 0, ti_once, [],
  [
    (try_for_agents, ":agent"),
      (assign, ":other", -1),
      (try_begin),
        (agent_is_human, ":agent"),
        (agent_get_horse, ":other", ":agent"),
      (else_try),
        (agent_get_rider, ":other", ":agent"),
      (try_end),
      (try_begin),
        (gt, ":other", -1),
        (agent_set_slot, ":agent", slot_agent_mount, ":other"),
        (agent_set_slot, ":other", slot_agent_mount, ":agent"),
      (else_try),
        (agent_set_slot, ":agent", slot_agent_mount, -1),
      (try_end),
    (try_end),
  ])

common_battle_cavalry_dismount = (
  ti_on_agent_dismount, 0, 0, [],
  [
    (store_trigger_param_1, ":agent"),
    (store_trigger_param_2, ":horse"),
    (call_script, "script_agent_dismount", ":agent", ":horse"),
    # (agent_set_slot, ":horse", slot_agent_mount, -1),
    # (agent_set_slot, ":agent", slot_agent_mount, -1),
  ])
  
common_battle_cavalry_mount = (
  ti_on_agent_mount, 0, 0, [],
  [
    (store_trigger_param_1, ":agent"),
    (store_trigger_param_2, ":horse"),
    (agent_set_slot, ":horse", slot_agent_mount, ":agent"),
    (agent_set_slot, ":agent", slot_agent_mount, ":horse"),
    (try_begin), #Look up
      (agent_get_division, ":div", ":agent"), #Now back at me
      (eq, ":div", grc_infantry), #I'm on a horse
      (agent_set_division, ":agent", grc_cavalry),
    (try_end),
  ])
Code:
("agent_dismount", [
    (store_script_param, ":agent", 1),
    (store_script_param, ":horse", 2),
    (try_begin), #parameter not given - fetch from slot
      (eq, ":horse", -1),
      (agent_get_slot, ":other", ":agent", slot_agent_mount),
    (try_end),
    (try_begin), #human
      (agent_is_human, ":agent"),
      (agent_is_alive, ":agent"),
      (agent_get_division, ":div", ":agent"),
      # (try_begin),
        (eq, ":div", grc_cavalry),
        (agent_set_division, ":agent", grc_infantry),
      # (try_end),
    # (else_try), #horse
    (try_end),
    (agent_set_slot, ":other", slot_agent_mount, -1),
    (agent_set_slot, ":agent", slot_agent_mount, -1),
]),
 
Thanks, as always, for your response Somebody.

Somebody said:
I've experienced that problem too - but usually the spawned character is wearing a helmet, so it's not too noticeable.
A good point...perhaps I'll call it good enough. I'm fighting perfectionist tendencies on this one.

Somebody said:
Also, have you experimented with entry_point_set_position in conjunction with visitors? I haven't had much success with using that inside quick battles,
I just have, actually...and I've not really gotten it to work. I can identify the first available entry point, but setting the position doesn't seem to have any effect. Also, the first available entry point can throw the spawned agent onto the wrong team and since setting a visitor doesn't return an agent ID like spawning the agent does, it requires an agent loop to identify the agent ID to reset the team, etc. So, at present, setting the visitor within the mission will then require me to use agent_set_position to move the agent to the correct location, I believe...after finding the correct agent, etc, etc.

Re the dynamic groups bit:
Somebody said:
keep in mind that if you never had any cavalry/infantry group in your party in the first place when the encounter began, the battle presentations won't show the new divisions as a group.
Right. I've noted that.

Somebody said:
If ti_on_agent_spawn works for horses when they spawn and fetch the rider properly then common_battle_cavalry_init can be simplified.
This does work well. Since the human spawn seems to trigger the spawning of a suitable mount if need be, capturing a horse spawn implies that the rider has previously been spawned, so agent_get_rider works just fine on horse-agent spawn.
 
What's 4th part of party for?
Code:
#  4) Menu. ID of the menu to use when this party is met. The value 0 uses the default party encounter system.

Native MS has no_menu=0 for this part for all party and there's no ID_menus import at the beginning of module_parties.py.

EDIT :
same case and same question for module_party_templates.py
 
A question of my own: In Thorgrim's map editor I sometimes have the "red lines" invisible and I can see only the yellow lines (the red lines are actually contracted somewhere in the middle of the map all on one spot), so could someone tell me what are their positions affected by? It should be something in module.ini, but I can't find anything like it.
 
Status
Not open for further replies.
Back
Top Bottom