MBX

Mount&Blade Expansion => Mod Graveyard => Tutorials => Topic started by: Smaug_the_dragon on May 16, 2007, 07:29:25 pm

Title: Creating scripted battles?
Post by: Smaug_the_dragon on May 16, 2007, 07:29:25 pm
Is there anyone out there willing to take the time to walk me step by step into how to make a scripted battle?  Ive been trying to learn by examining native and others codes, but I just can't seem to wrap my head around it.  Ive got a scene all ready to go and entry points set up.  Id be ever so grateful.  I'd even be willing to trade some modelling work for it.  (as long as it wasn't too complecated)

Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 16, 2007, 07:30:49 pm
Whoops. sorry I noticed this is in the wrong forum, could someone move it please?
Title: Re: Creating scripted battles?
Post by: Winter on May 17, 2007, 12:35:59 am
The thread is fine where it is, don't worry about it.

I don't have time to give you a really detailed overview, but I can give you a quick list of what you need. So:

First -- Determine the source you're using for the enemy troops (enemy party or visitors). If visitors, you'll need to set them beforehand in game menu or dialogue. The enemy source you're using here will determine what kind of layout you'll need to use for your mission template.

Second -- Create a custom mission template to put troops on the scene and determine what happens when via the triggers. There are some simple visitor-based templates in Native, and the standard 'lead_charge' template for enemy-party battles, so it's handy to study them before you try anything of your own.

What I recommend for getting acquainted with mission templates is writing a simple duel-type template with visitors, just a one on one match, and then go from there.

Remember that set_visitor uses the mission template spawn entries (starting at 0 and counting from the top), not scene entry points directly!
Title: Re: Creating scripted battles?
Post by: nema on May 18, 2007, 07:01:30 am
simple duel:

___________________________________________________________ ________________________________________________

in module_dialogs.py

#ymira duel

  [trp_ymira,"start", [], "Would you like to fight?", "ymira_fight1", []],

  [trp_ymira|plyr,"ymira_fight1",[], "I guess so.", "ymira_fight2",[]],

  [trp_ymira,"ymira_fight2", [],"Good luck.",  "close_window",
    [[modify_visitors_at_site,"scn_four_ways_inn"],[reset_visitors],
#  [store_shuffled_range,4], for random entry point (you will need four of them)
#( if you don't want random entry, do not use next 5 lines and reg(0) and reg(1) change to some entry point numbers  
    [assign,reg(0),0],
    [assign,reg(1),1],
    [assign,reg(2),2],
    [assign,reg(3),3],
    [shuffle_range,0,4],
    [set_visitor,reg(0),0],
    [set_visitor,reg(1),"trp_ymira"],
    [set_jump_mission,"mt_ymira_fight"],
    [jump_to_scene,"scn_four_ways_inn"]]
   ],

___________________________________________________________ ________________________________________________

in module_mission_templates.py

#ymira duel
  (
    "ymira_fight",mtf_arena_fight,-1,
    "Let see.",

    [
      (0,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (1,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),
      (2,mtef_visitor_source|mtef_team_3,af_override_horse,aif_start_alarmed,1,[]),
      (3,mtef_visitor_source|mtef_team_4,af_override_horse,aif_start_alarmed,1,[]),
    ],

    [
      (ti_tab_pressed, 0, 0, [],
       [(question_box,"str_give_up_fight")]),
     
      (ti_question_answered, 0, 0, [],
       [(store_trigger_param_1,":answer"),(eq,":answer",0),(jump_to_scene,"scn_four_ways_inn"),]),

      (1, 3, ti_once, [(main_hero_fallen,0)],
       [(jump_to_scene,"scn_four_ways_inn")]),

      (1, 3, ti_once,
       [(store_mission_timer_a,reg(1)),(ge,reg(1),1),(num_active_teams_le,1),(neg|main_hero_fallen,0)],
       [(jump_to_scene,"scn_four_ways_inn")]),
 
     (ti_inventory_key_pressed, 0, 0, [(display_message,"str_cant_use_inventory_arena")], []),
    ],
  ),
Title: Re: Creating scripted battles?
Post by: Ahadhran on May 18, 2007, 09:24:42 am
Though I wasn't the one to ask for it, that was very helpful Nema. I have been avoiding mission templates for far too long... ;)
Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 18, 2007, 06:18:11 pm
Thank you very much.  Very helpful! :D
Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 24, 2007, 07:45:55 pm
Allright then, Ive been playing with this script and managed to get it too work very nicely.  But now im trying to figure out how to take it too the next step and add multiple enimies, mabye even multiple teams,  How would I do this?
Title: Re: Creating scripted battles?
Post by: Highlander on May 25, 2007, 07:00:26 am
mabye even multiple teams
(0,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
add multiple enimies
you can use
(add_reinforcements_to_entry,<mt_entry_no>,1),
The "1" is the number of new troops. For some reasons it adds only one new troop to the scene whatever the value is when you use visitors, so just use the command several times.
Title: Re: Creating scripted battles?
Post by: nema on May 25, 2007, 08:49:06 am
Upper code work very nice with at least 4 warriors in 4 teams. You must just add new visitors:

[set_visitor,reg(0),0],#this is player
[set_visitor,reg(1),"trp_ymira"],
[set_visitor,reg(2),"trp_mora"],
[set_visitor,reg(3),"trp_essa"],  

They will fight 1 on 1 on 1 on 1 because there are 4 teams (yes you already have 4 teams here):

      (0,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (1,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),
      (2,mtef_visitor_source|mtef_team_3,af_override_horse,aif_start_alarmed,1,[]),
      (3,mtef_visitor_source|mtef_team_4,af_override_horse,aif_start_alarmed,1,[]),

Try to change something here:

      (0,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (1,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (2,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),
      (3,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),

2 on 2 I think

Or:

      (0,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (1,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),
      (2,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),
      (3,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),

Randomly 1 on 3

but of course add_reinforcements is also very interesting and useful idea.
Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 25, 2007, 09:44:51 am
Allright, I think I'm starting to understand this now, and so to take it one step further, If I wanted to make this battle occur when you enterd the area, I could just put the dialoge code in the game_menus right?

And one more qustion.  Ive modded some of the troops to have no weapons at all (cause I want them to use thier fists) but when the battle commences it gives me an error talking about "no meele"  i can just hit ignore and the battle plays out normally, but it would be nice to have it work without the errors.  Any ideas?

Thanks for all the help guys.
Title: Re: Creating scripted battles?
Post by: Fisheye on May 26, 2007, 06:19:09 am
And one more qustion.  Ive modded some of the troops to have no weapons at all (cause I want them to use thier fists) but when the battle commences it gives me an error talking about "no meele"  i can just hit ignore and the battle plays out normally, but it would be nice to have it work without the errors.  Any ideas?

You have to give them some melee weapon (a knife, anything) then override it with nothing in the mission template.

E.g.

      (0,mtef_visitor_source|mtef_team_1,af_override_weapons,aif_start_alarmed,1,[]),
Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 26, 2007, 10:57:53 pm
hmm this dosn't seem to work.  When complling it gives me errors from that


Quote
      (0,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (1,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (2,mtef_visitor_source|mtef_team_3,af_override_weapons,aif_start_alarmed,1,[]),
      (3,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (4,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (5,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),
      (6,mtef_visitor_source|mtef_team_3,af_override_weapons,aif_start_alarmed,1,[]),
      (7,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (8,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),
      (9,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (10,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),
      (11,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),
      (12,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (13,mtef_visitor_source|mtef_team_3,af_override_weapons,aif_start_alarmed,1,[]),
      (14,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),
      (15,mtef_visitor_source|mtef_team_3,af_override_weapons,aif_start_alarmed,1,[]),
      (16,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),
      (17,mtef_visitor_source|mtef_team_2,af_override_weapons,aif_start_alarmed,1,[]),
      (18,mtef_visitor_source|mtef_team_4,af_override_weapons,aif_start_alarmed,1,[]),


This is the only thing Ive changed, like fisheye suggested.
Title: Re: Creating scripted battles?
Post by: Fisheye on May 27, 2007, 08:02:44 am
What's the error?

You probably stuffed up a comma or bracket somewhere (not in the block you showed).
Title: Re: Creating scripted battles?
Post by: nema on May 29, 2007, 02:21:01 am
I'd love a script to set up a dialog as soon as a player has been defeated in a scripted battle (like the arena)

Automatic dialog after arena fight? I don't know such. You just go back to arena master and there you can ask him something. Do you think such dialog?

Do you think string display?  (Your soldiers have all fallen.)
Some question? (Do you want to retreat?)...

Can you explain me what exactly do you want.

Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 29, 2007, 06:51:38 pm
I'm looking that the player death starts up a dialogue with someone, is that even possible?  or would I have to work it through a menu?
Title: Re: Creating scripted battles?
Post by: nema on May 30, 2007, 05:58:43 am
Change in upper code existing blue with red one

      (1, 3, ti_once, [(main_hero_fallen,0)],
       [ (jump_to_scene,"scn_four_ways_inn") ]),


(1, 3, ti_once, [(main_hero_fallen,0)], [ (start_mission_conversation,"trp_ymira") ]),

In current code you will get loop until you will win. (ha, it is nice to wait that someone kill you :green:)

Maybe you will setup some variables before red replacement, to create a condition for right dialog in module_dialogs.




I'd even be willing to trade some modelling work for it.

Can you tell me something about your modelling work. For my mod I done everything except models (and translations to english, heh) so maybe... ::)

You can check here for body meshes, weapons, dresses, but I also need some very simple things such are skined cubes, balls, pyramids..
Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on May 30, 2007, 07:33:11 pm
Well, I havn't done anything spectacular, and I'm only par with texturing but for some samples, check out the mod forum in my sig.  Thanks for the help though nema
Title: Re: Creating scripted battles?
Post by: nema on May 31, 2007, 12:09:32 am
Ah it is nothing. I will help you if I will know things you will ask. :) Any new problem with battles to resolve?

( I checked it. Are you still working on it? )
Title: Re: Creating scripted battles?
Post by: Smaug_the_dragon on June 02, 2007, 10:29:42 pm
you bet, its just going slow at the moment, school is getting in the way.
Title: Re: Creating scripted battles?
Post by: nema on June 04, 2007, 01:10:54 am
Maybe we can finish this nonscripting part of our conversation through my topic. You will find link below. ;)

Title: Re: Creating scripted battles?
Post by: bryce on June 10, 2007, 08:28:39 pm
Lot's of good stuff here. Thanks.

I am thinking it may be easier to move to using visitors for all my battles as it's just getting too nightmarish....
Title: Re: Creating scripted battles?
Post by: grailknighthero on March 28, 2008, 08:31:41 pm
A long time ago I made a mission and had the problem that the enemy just stood there and only swung their fists at you when you got near by.  I fixed it somehow, but I do not remember how I did it and I have run into this problem again.  Does anyone know how to fix it?  What have I done wrong?

Edit: nm I figured it out.  He didnt have any weapons because the weapons in the mission template are only given if you over ride that weapon slot.