Modding ranged troops, weapons and skills

正在查看此主题的用户

Koozer

Regular
I'm created some new troops that use a custom thrown weapon and should behave like archers, but the problem is they just charge at the enemy, throwing away until they get into melee range and start punching people. My question is, is the AI behaviour to stand and shoot tied to bows/crossbows weapon types?

Second question: is it possible to make said thrown weapons AoE?

EDIT: might as well put this in here too - how can I modify the effects of skills? I find nothing under module_skills, or the header or ID files. I've created 3 new skills in module_skills, but I have no idea where I'm supposed to define their behaviour. :/ Google and forum search fails me.
 
You may want to see http://forums.taleworlds.com/index.php?topic=137970.0
About the second question, I can't tell you anything further than 'very likely the answer is yes' by virtue of of the fact that i didn't understand single thing. Yet i have a feeling that the topic on the other side of the link above has your answer, yes. Age of empires... yeah, possibly yes.

addendum in re Edit:
As far as i can see, Skills in M&B usually works like gauges of handicap.
This one is from module_scripts
  ("game_get_party_companion_limit",
    [
      (assign, ":troop_no", "trp_player"),

      (assign, ":limit", 30),
      (store_skill_level, ":skill", "skl_leadership", ":troop_no"),
      (store_attribute_level, ":charisma", ":troop_no", ca_charisma),
      (val_mul, ":skill", 5),
      (val_add, ":limit", ":skill"),
      (val_add, ":limit", ":charisma"),

      (troop_get_slot, ":troop_renown", ":troop_no", slot_troop_renown),
      (store_div, ":renown_bonus", ":troop_renown", 25),
      (val_add, ":limit", ":renown_bonus"),

      (assign, reg0, ":limit"),
      (set_trigger_result, reg0),
  ]),
Find the script about what your skill does, then put some limits or bonuses for it. I'm afraid, some of the skill actions in the game are hardcoded. And I've never seen any practice about this before.
So, you may want to start it simple.

edit: lol
 
Koozer 说:
My question is, is the AI behaviour to stand and shoot tied to bows/crossbows weapon types?
As far as I know it is.
AI troops will still try to charge the enemy, they just stop to shoot and crossbow-wielders also cannot move while reloading, which has priority over running.
... Troops lack these behaviours with all thrown vanilla weapons as well.
Koozer 说:
Second question: is it possible to make said thrown weapons AoE?
"Area of Effect" is not an adjective.
But I recall seeing a grenade script for the original Mount&Blade, so it appears to be possible enough.
... I have never tried multiplayer, but there are catapults - if those had an area effect, you could reverse engineer that.
 
Koozer 说:
I'm created some new troops that use a custom thrown weapon and should behave like archers, but the problem is they just charge at the enemy, throwing away until they get into melee range and start punching people. My question is, is the AI behaviour to stand and shoot tied to bows/crossbows weapon types?

They try to move between shots, but yeah, if they're using a projectile that'll veer way off course if they're moving they'll calm down and stand still long enough to fire it.

Second question: is it possible to make said thrown weapons AoE?

Sure is, search this forum for ti_on_missile_hit

EDIT: might as well put this in here too - how can I modify the effects of skills? I find nothing under module_skills, or the header or ID files. I've created 3 new skills in module_skills, but I have no idea where I'm supposed to define their behaviour. :/ Google and forum search fails me.

You don't - base skills are hardcoded, and we don't have access to that. You'll need to do some scripting to add effects to things based on your level in that skill.
 
Thanks for the advice everyone. For future reference, I searched around for ti_on_missile_hit and found this thread on exploding arrows:

http://forums.taleworlds.com/index.php/topic,152127.0.html

I've just modified the code from that and it works perfectly.

Now I really should learn the syntax for scripting myself to make the skirmish mode kindly linked by ANTONIVS work and to add skills...
 
Okay, new problem. I've implemented the code for Skirmish Mode, and it needs to trigger at the start of every battle, but it doesn't. As far as I understand it the following should do that (in mission_templates, line 630 in vanilla file):

插入代码块:
(0.5, 0, 0, [(get_player_agent_no, ":player"),(agent_slot_eq, ":player", slot_agent_is_skirmisher, 1)], [(call_script, "script_skirmish")]),  #Use player's slot to track if any skirmishers are active
(ti_on_agent_spawn, 0, 0, [],
   [
    (display_message, "SKIRMISH MODE"),
    (store_trigger_param_1, ":agent"),
    (agent_get_troop_id, ":troop_no", ":agent"),
    (neq, ":troop_no", "trp_player"),
	
	##! - Do your stuff to pick the correct troops, however you want to do it
        ##Need code here to choose for which types of troops/agent you want to modify the AI
	
	(agent_get_class, ":class", ":troop_no"),
	(eq, ":class", "trp_fe_mage"),     #exits if not mage

	(agent_set_slot, ":agent", slot_agent_is_skirmisher, 1),
    (get_player_agent_no, ":player"),
    (agent_is_active, ":player"),
    (agent_set_slot, ":player", slot_agent_is_skirmisher, 1), #Notes that there are skirmishers active, rather than a global	
   ]),

My second thought would be to define it as skirmisher_mode = (code goes here), but I don't know where skirmish_mode should then be called.
 
If you place them there, they must of course be named and called. I advise to read the manual:
Caba`drin 说:
[...] stick them toward the top of the file [...]
You did that.
Caba`drin 说:
[...] and then just include the "order_skirmish_triggers" title in the actual mission templates.
That you did not (or you did and did not tell).

You may employ a named array around your triggers, which then be added to the existing by "extend":
插入代码块:
[<original code>].extend(<array name>)
... Although, as Caba`drin has demonstrated, a simple '+' does it just as well.

Concise:
插入代码块:
skirmisher_mode = [code goes here]
插入代码块:
  (
    "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,[]),
     ],
     skirmisher_mode + [
     [...]

... Oh yes, then there is something else: I do not know what "agent_get_class" returns, but you check against a troop ID and should thence employ "agent_get_troop_id" to ensure equal types lest your equation be of arbitrary result.

addendum:
"agent_get_class" returns one of these values:
插入代码块:
grc_infantry = 0
grc_archers  = 1
grc_cavalry  = 2
grc_heroes   = 3
Therefore, equating it to a troop ID will lead to arbitrary result.
Specifically, it may only resolve as 'true' for the first four troop IDs, which are:
  • trp_player
  • trp_multiplayer_profile_troop_male
  • trp_multiplayer_profile_troop_female
  • trp_temp_troop
 
Thanks for the help Zsar! I am actually using a slightly different version of Caba`drin from further down the thread, the different format confused my poor, syntax ignorant mind. I fixed the error you spotted, and put the code in a named array like so:
插入代码块:
skirmish_mode = [code here]

Then added it to the end of lead_charge as you suggested:
插入代码块:
(
    "lead_charge",mtf_battle_mode|mtf_synch_inventory,charge,
    "You lead your men to battle.",
    ...
    #more code here
    ...
    ] + skirmish_mode,
  ),

It now works perfectly. Thanks again everyone!

One more little question: how did you find out what agent_get_class returns? I can only find the parameters in header_operations, but not what each operation returns.
 
Koozer 说:
One more little question: how did you find out what agent_get_class returns?
The answer to this is really sad and pathetic:
I searched in Google for "agent_get_class" and got this as first result.
motomataru probably knows what he is doing, so I assumed his code to be correct.

... There are a few alternatives.
This here has been horribly broken a few weeks ago but seems to work now, albeit stuttering.
This is documentation directly written into header_operations.py.
Both are linked in this thread which contains more things you might consider useful.
 
Har! Google, browsing and the efforts of others make me a god!
Bow to Zsar Googalor, your new god!
 
后退
顶部 底部