Author Topic: M&B Scripting Q&A  (Read 63448 times)

Yoshiboy

  • Guest
M&B Scripting Q&A
« on: January 12, 2007, 12:56:22 PM »
This thread is for people to ask quick questions regarding M&B scripting. Any question that (probably) has a well-known, easily summarised solution qualifies as a quick question (e.g. how does this command work, how do I set up a custom encounter, etc).

If you feel your question is rather complex (e.g. how could I make an animated cutscene, how do I implement dynamic formations), feel free to start a new topic to discuss various possiblities of approaching the issue.

(---edited by Fisheye)
« Last Edit: February 04, 2007, 10:10:49 AM by Fisheye »

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: FAQ project!
« Reply #1 on: January 12, 2007, 10:40:48 PM »
Okay.  Why start with the easy stuff?  In all cases note that I am not asking how it is done in theory; several of these things appear easy to do in theory, but don't work the way that would imply.

1) Can I cause a particle system to be added and/or emit, as the result of a (module_mission_templates.py) trigger?  (And if so, how?)

2) How do I make use of the optional second argument in (particle_system_add_new), the [position_no] argument, without having it do nothing at all?

3) Can I cause an animated scene prop to make an agent move?

4) How do I change the yes/no strings on a question box?

5) What's the max slot on an agent?

6) What's the game's max number of parties extant?  Does it help if they're disabled?

7) What's "troop DNA" and what does it do?

Perniciously,
- Hellequin

Offline Fisheye

  • Blues Brother
  • Moderator
  • *****
  • Posts: 427
  • My scalp's so bright, I gotta wear shades.
    • View Profile
Re: FAQ project!
« Reply #2 on: January 12, 2007, 10:49:25 PM »
I can only answer question 7.

Troop DNA is the random seed that determines their face and equipment selection (non-heroes only). So if you make a vaegir veteran with the same DNA, he'll have the same face and equipment each time.

Yoshiboy

  • Guest
Re: FAQ project!
« Reply #3 on: January 13, 2007, 05:13:34 AM »
Okay.  Why start with the easy stuff?  In all cases note that I am not asking how it is done in theory; several of these things appear easy to do in theory, but don't work the way that would imply.

1) Can I cause a particle system to be added and/or emit, as the result of a (module_mission_templates.py) trigger?  (And if so, how?)

2) How do I make use of the optional second argument in (particle_system_add_new), the [position_no] argument, without having it do nothing at all?

3) Can I cause an animated scene prop to make an agent move?

4) How do I change the yes/no strings on a question box?

5) What's the max slot on an agent?

6) What's the game's max number of parties extant?  Does it help if they're disabled?

7) What's "troop DNA" and what does it do?

Perniciously,
- Hellequin

1) There are several work-arounds you can use for this. The one I use mainly in the new release of pirates is to have a scene prop that emits a particle effect all the time and then have a trigger that uses the new move scene prop command to move the prop to the position you want particles to be emitted, you then need to add a trigger that moves it back to where it was before again. Another way of doing it (I've tested this and it didn't work but It was only a short test and I could have easily been doing something wrong, I'd like a second opinion) is to make an item that emits particles when added to the scene using the item simple triggers (on the pistol) and then use the "spawn_item" command to spawn it into the scene.

2) Hmmm, I've never seen this, this could be useful and mean that there is no need for the above work around. What I'd imagine the second argument is, is a global scene position, like you get from storing a agent position or spawn point position or whatever. Better test it and then tell me ;)

3) If you use the animated scene prop command the collision mesh does move with the object, but this doesn't mean it will move an agent all of the time. There are several problems with agents culling the collision mesh. I'd imagine the problem arises when the agent moves against the direction the prop is moving, this will cause him to clip it. In any means, its certainly not practical.

4)
Code: [Select]
question_box           = 10121 # (tutorial_box,<string_id>, [<yes_string_id>], [<no_string_id>]), Simply add the strings to the arguments.

If you mean the result you do it by adding a trigger like this to the mission template:
Code: [Select]
      (ti_question_answered, 0, 0, [],
       [(store_trigger_param_1,":answer"),(eq,":answer",0),(finish_mission,0),]),

5) Not sure, but from other peoples explanations of slots I'd take a guess if there was one it might be the same as the number of agents in the scene. Although its highly probable its higher or without limit. Better test it.

6) There was a limit, I think it was 512, but I also think armagan extended it for this version or an older one. I wouldn't worry about it until you reach it :P Better ask Winter as well.

7) Fisheye answered.

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: FAQ project!
« Reply #4 on: January 13, 2007, 10:35:51 AM »
Question number four is why I asked for "actually working" answers, and not theoretical ones.  Have you tried the above?  I have. :P

And for q1, pity.  That's the trick I'm using, too, but it's a right pain.

Yoshiboy

  • Guest
Re: FAQ project!
« Reply #5 on: January 13, 2007, 10:43:16 AM »
Question number four is why I asked for "actually working" answers, and not theoretical ones.  Have you tried the above?  I have. :P

And for q1, pity.  That's the trick I'm using, too, but it's a right pain.

No, I hadn't tried it but I tried it now. Looks like there is a bug in the code. The No option appeared in the yes box for me and the Yes option was no where to be seen. Did you experience the same thing?

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: FAQ project!
« Reply #6 on: January 13, 2007, 10:54:51 AM »
Yup.  Also tried args 4&5, nothing.

Leprechaun

  • Guest
Re: FAQ project!
« Reply #7 on: January 14, 2007, 12:03:23 PM »
Didn't know where else to post this, so here's how to get shiny water on the world map.

You will need:

A computer
Mount and Blade
BRF Edit
Mouse and keyboard
Eyes
Hands

Go to your Mount&Blade directory, then into CommonRes. Select materials.brf, and make a backup copy of it, stored elsewhere. Open materials.brf in BRF Edit.

Select map_ocean.dds

Change the shader from "map_ocean_shader" to "water_shader"
Change the bumpmap from "none" to "waterbump"
Change Specular to 100
Change RGB to 300 (each)
In the list of other options, select Render Order +3

Save the modified materials.brf, overwriting the original

You now have reflective water on the world map, like in battles.


To do this for a mod, simply copy materials.brf into your module's Resource folder and in module.ini, change load_resource = materials to load_module_resource = materials, before following these instructions:

Go to your Mount&Blade module, then into Resource. Select materials.brf, and make a backup copy of it, stored elsewhere. Open materials.brf in BRF Edit.

Select map_ocean.dds

Change the shader from "map_ocean_shader" to "water_shader"
Change the bumpmap from "none" to "waterbump"
Change Specular to 100
Change RGB to 300 (each)
In the list of other options, select Render Order +3

Save the modified materials.brf, overwriting the original



I'm wondering about on getting fog effects on the worldmap, and getting rid of the oddness that occurs where rivers meet the ocean.

For the first, could it be done by simply unselecting the No Fog option?

For the second, I have a feeling it's something to do with the Blend option, but I know next to nothing about that, so I'll leave that up to Thorgrim.

Scion

  • Guest
Re: FAQ project!
« Reply #8 on: January 14, 2007, 12:15:59 PM »
Splitting module python files into several files?

Easy. The module system content, for example the scripts are just plain python list.

To split up scripts.py with some scripts in scripts.py and some in my_scripts.py , do the following.

Scripts.py: rename the list scripts to for example scripts_.
Code: [Select]
scripts_ = [
...
]

In My_scripts.py, make another python list with the scripts. Remember to import everything you need, possibly copy the start of scripts.py.
Code: [Select]
my_scripts = [
...
]

At the end of scripts.py, do the following:
Code: [Select]
from my_scripts.py import my_scripts

scripts = scripts_[:] + my_scripts[:]

Done.

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: FAQ project!
« Reply #9 on: January 14, 2007, 02:42:01 PM »
As an alternate to Scion's trick, you can as easily not rename the Native one, but instead add to it:

Code: [Select]
from module_myscripts import *
...
scripts = my_scripts + [
... (existing content) ...
]

This works just as well.

Also, you can use this trick within files, to clean up things like mission templates.  For instance (from my own code):

Code: [Select]
standard_fighting_triggers = [
(ti_on_tab_key_pressed, 0, 0, [stuff]),
(ti_on_inventory_key_pressed, 0, 0, [stuff]),
(0, 0, ti_once, [stuff]),
etc.
]




mission_templates = [
...etc...


  ("lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
     (1,mtef_defenders,0,group(1)|aif_start_alarmed,6,[]),
     (0,mtef_defenders,0,group(1)|aif_start_alarmed,0,[]),
     (4,mtef_attackers,0,aif_start_alarmed,6,[]),
     (4,mtef_attackers,0,aif_start_alarmed,0,[]),
     ],
    standard_fighting_triggers + [
... template-specific stuff ...
    ]),

svaucher

  • Guest
Re: FAQ project!
« Reply #10 on: January 16, 2007, 02:33:19 AM »
Party locations, can we get them via mbscript? I wish to calculate distances between different parties. I can imagine doing that with cities using python directly, but I didn't find the appropriate operation in headers_ops for mobile parties.

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: FAQ project!
« Reply #11 on: January 16, 2007, 03:43:06 AM »
Monsieur Vaucher... the op you're looking for is (store_distance_to_party_from_party).  There's no way to get cartesian coords per se, but this op will do just as well.  And I suppose if you really needed cartesians you could get there with clever math and placement of reference parties.

(One of the tricks I use to figure out whether to suppress random encounters or not is whether you're still at the same distance from both town1 and town2 that you were 15 game minutes ago.  If yes, no encounters; you're waiting or sleeping.)

svaucher

  • Guest
Re: FAQ project!
« Reply #12 on: January 16, 2007, 03:54:46 AM »
Thanks, I feel foolish now since I believe I saw that operation in a someone's mod source... I should have figured that one out, that ought to teach me to ask questions at 2:30 in the morning.  :-[

Leprechaun

  • Guest
Re: FAQ project!
« Reply #13 on: January 16, 2007, 07:58:55 AM »
I'm wondering about on getting fog effects on the worldmap, and getting rid of the oddness that occurs where rivers meet the ocean.

For the first, could it be done by simply unselecting the No Fog option?

For the second, I have a feeling it's something to do with the Blend option, but I know next to nothing about that, so I'll leave that up to Thorgrim.

Also, is it possible to alter the worldmap skybox so it changes with the time like in battles? Because at the moment I only get blue skies, even at night, reflecting off my water and it's driving me crazy.

Yoshiboy

  • Guest
Re: FAQ project!
« Reply #14 on: January 16, 2007, 10:58:35 AM »
I'm wondering about on getting fog effects on the worldmap, and getting rid of the oddness that occurs where rivers meet the ocean.

For the first, could it be done by simply unselecting the No Fog option?

For the second, I have a feeling it's something to do with the Blend option, but I know next to nothing about that, so I'll leave that up to Thorgrim.

Also, is it possible to alter the worldmap skybox so it changes with the time like in battles? Because at the moment I only get blue skies, even at night, reflecting off my water and it's driving me crazy.

Don't think its possible to put fog on the world map. pretty sure its not anyway.

It is kind of possible, you have to create a party with the sky box for the mesh and have a trigger that constantly makes it re-locate to the player party. The problem with this is that it disappears when the player party is not in view. Essentially going back to normal. You can then switch this party for different times of day.