MBX

Mount&Blade Expansion => Mod Graveyard => Discussion => Topic started by: Yoshiboy on January 12, 2007, 12:56:22 pm

Title: M&B Scripting Q&A
Post by: Yoshiboy 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)
Title: Re: FAQ project!
Post by: Hellequin 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
Title: Re: FAQ project!
Post by: Fisheye 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.
Title: Re: FAQ project!
Post by: Yoshiboy 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.
Title: Re: FAQ project!
Post by: Hellequin 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.
Title: Re: FAQ project!
Post by: Yoshiboy 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?
Title: Re: FAQ project!
Post by: Hellequin on January 13, 2007, 10:54:51 am
Yup.  Also tried args 4&5, nothing.
Title: Re: FAQ project!
Post by: Leprechaun 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.
Title: Re: FAQ project!
Post by: Scion 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.
Title: Re: FAQ project!
Post by: Hellequin 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 ...
    ]),
Title: Re: FAQ project!
Post by: svaucher 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.
Title: Re: FAQ project!
Post by: Hellequin 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.)
Title: Re: FAQ project!
Post by: svaucher 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.  :-[
Title: Re: FAQ project!
Post by: Leprechaun 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.
Title: Re: FAQ project!
Post by: Yoshiboy 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.
Title: Re: FAQ project!
Post by: Hellequin on January 16, 2007, 11:27:46 am
Yoshi - could you not make a version of the skybox which was scaled up enough to enclose the map entire (even if the PC party's in one corner), and use that for the mesh instead?

I have a couple more questions:

1) How do I make the camera switch back to the player (instead of the conversation partner) during a conversation?
2) Can I (and how can I) bring a third party into a conversation, giving them lines and camera time?
Title: Re: FAQ project!
Post by: Yoshiboy on January 16, 2007, 12:06:23 pm
Yoshi - could you not make a version of the skybox which was scaled up enough to enclose the map entire (even if the PC party's in one corner), and use that for the mesh instead?

I have a couple more questions:

1) How do I make the camera switch back to the player (instead of the conversation partner) during a conversation?
2) Can I (and how can I) bring a third party into a conversation, giving them lines and camera time?

Well, you can't scale it up too much anyway or it just breaks but even still the same problem occurs. As soon as the center of a mesh goes out of view on the world map, it is not drawn. As soon as the player icon/skybox icon center goes out of view the reflection goes.

1) Just make the next part of the conversation be said by the player. e.g

[trp_trainer|plyr,"novicemaster_introduce", [], "{playername}.", "novicemaster_introduce_2",[]],

(done by adding the |plyr tag to the entry).

2) check the FAQ ;P

Just make the state use the other troop tag. E.g

[trp_trainer|other(trp_yourNPChere),"novicemaster_introduce", [], "{playername}.", "novicemaster_introduce_2",[]],
Title: Re: FAQ project!
Post by: Hellequin on January 16, 2007, 12:19:04 pm
Thanks.  Sorry - I did check it; just not right now!  And thank you, I should just have checked Winter's docs for the first one.  In a way, I had it backwards; I hadn't ever not offered multiple dialogue entries for the player, it hadn't occurred to me that anything special would happen then.

Is there any way I can use a variable instead of an explicit troop name in the |other(trp_XXX) syntax, for example if I want that to devolve on my best healer?  Does 'anyone' work in that construction?  (And does store_conversation_troop within such a statement store the original conversation partner, or the person currently speaking the line?)

And, lastly, one more - what's the skinny on the [options] parameter on the (play_sound) operation?  Can we dynamically set the volume (without having a bunch of near-duplicate snd_ objects)?
Title: Re: FAQ project!
Post by: Leprechaun on January 16, 2007, 12:25:05 pm
Yoshi - could you not make a version of the skybox which was scaled up enough to enclose the map entire (even if the PC party's in one corner), and use that for the mesh instead?
Well, you can't scale it up too much anyway or it just breaks but even still the same problem occurs. As soon as the center of a mesh goes out of view on the world map, it is not drawn. As soon as the player icon/skybox icon center goes out of view the reflection goes.
I haven't found that - when I zoom right out the skybox reflects on every bit of water in sight just fine. Even if I move away from the party so it's no longer in sight. Or have I misunderstood your point?
Title: Re: FAQ project!
Post by: Hellequin on January 16, 2007, 12:27:58 pm
Maybe you've set it to pf_always_visible and Yoshi hasn't?
Title: Re: FAQ project!
Post by: Yoshiboy on January 16, 2007, 12:35:37 pm
Thanks.  Sorry - I did check it; just not right now!  And thank you, I should just have checked Winter's docs for the first one.  In a way, I had it backwards; I hadn't ever not offered multiple dialogue entries for the player, it hadn't occurred to me that anything special would happen then.

Is there any way I can use a variable instead of an explicit troop name in the |other(trp_XXX) syntax, for example if I want that to devolve on my best healer?  Does 'anyone' work in that construction?  (And does store_conversation_troop within such a statement store the original conversation partner, or the person currently speaking the line?)

And, lastly, one more - what's the skinny on the [options] parameter on the (play_sound) operation?  Can we dynamically set the volume (without having a bunch of near-duplicate snd_ objects)?

Well, what you need to do is list all the possible troops with conditions of which one to pick.

[anyone|other(trp_man1),"man_introduce", [(eq,":man_to_talk_to",1)], "Hi, I am man 1.", "man_introduce_2",[]],
[anyone|other(trp_man2),"man_introduce", [(eq,":man_to_talk_to",2)], "Hi, I am man 2.", "man_introduce_2",[]],
[anyone|other(trp_man3),"man_introduce", [(eq,":man_to_talk_to",3)], "Hi, I am man 3.", "man_introduce_2",[]],

This is unfortunately the only way to do it, its not possible to put a variable for the troop name.
Quote
I haven't found that - when I zoom right out the skybox reflects on every bit of water in sight just fine. Even if I move away from the party so it's no longer in sight. Or have I misunderstood your point?

Are you talking about a new party skybox that is added like I said? Or what is already there? What is already there you cannot change. You have to use this workaround.

Quote
Maybe you've set it to pf_always_visible and Yoshi hasn't?

Nah, thats to do with visibility of the party, not the camera. I'm pretty sure this thing is Hardcoded, me and Thorgrim were thinking ways around it for a long time.
Title: Re: FAQ project!
Post by: Fisheye on January 16, 2007, 12:45:01 pm
does store_conversation_troop within such a statement store the original conversation partner, or the person currently speaking the line?)

I think it stores the current speaker, I've had silly errors when I use the command when the player is talking.
Title: Re: FAQ project!
Post by: Yoshiboy on January 16, 2007, 01:02:01 pm
Quote
And, lastly, one more - what's the skinny on the [options] parameter on the (play_sound) operation?  Can we dynamically set the volume (without having a bunch of near-duplicate snd_ objects)?

Sorry, don't know this one. I don't think it does anything.
Title: Re: FAQ project!
Post by: svaucher on January 17, 2007, 03:19:40 am
I'm wondering about debugging. How do you gurus do it?

I currently use dialogs with a ficticious character who'd tell me the state of different global variables. I also use add_xp to see different values in the game when it's a triggered event.

Also, how do you start the game so that it's quickest? Since I play with the mechanics, I always start a new character to test a small increments, and it's a really a pain.
Title: Re: FAQ project!
Post by: Yoshiboy on January 17, 2007, 03:31:29 am
I'm wondering about debugging. How do you gurus do it?

I currently use dialogs with a ficticious character who'd tell me the state of different global variables. I also use add_xp to see different values in the game when it's a triggered event.

Also, how do you start the game so that it's quickest? Since I play with the mechanics, I always start a new character to test a small increments, and it's a really a pain.

Commonly the best way is to assign variables to a register and then use the display message command with a string containing that register. Like the test string for example. Then put this in the script you are testing. Although your techniques seem to work just as well :)

There isn't really a quickest way. Just click all the options as fast as you can.
Title: Re: FAQ project!
Post by: Hellequin on January 17, 2007, 11:43:03 am
Yah.  If you want to speed things up slightly, you might try adding a definition for int_1 & agi_1 to header_troops.py, and setting trp_player to those.  (Or just using troop_raise_attribute with a negative raise, during the opening menus, such as when hitting a "Debugging quickstart" option instead of Male/Female.)  Similarly you could put a call to troop_add_proficiency_points with a negative raise there, so as to have none of those to spend - haven't tried this, though, can't confirm that this function accepts negative args nor do I know what happens if you go below zero points this way.

But that's about it.

Incidentally, when doing high-volume debugging (esp. on loops), your method is probably working better, because you can overload the (display_message) queue pretty easily, all it takes is more than about six messages in a short time.
Title: Modding Q&A
Post by: Highlander on January 18, 2007, 10:12:36 am
could somebody give a good explanation of "player not placed on the scene"?
I'm getting mad here while trying to fix it for more than two hours.

btw: this is my script,
Code: [Select]
   (modify_visitors_at_site,"scn_wh_battle1"),(reset_visitors),
    (set_visitor,0,"trp_orc"),
    (set_visitor,1,"trp_orc"),
    (set_visitor,2,"trp_orc"),
    (set_visitor,5,"trp_orc"),
    (set_visitor,6,"trp_orc"),
    (set_visitor,8,"trp_orc"),
    (set_visitor,9,"trp_orc"),
    (set_visitor,10,"trp_space_marine"),
    (set_visitor,11,"trp_space_marine"),
(set_visitor,13,"trp_player"),
    (set_visitor,15,"trp_space_marine"),
    (set_visitor,16,"trp_space_marine"),
    (set_visitor,18,"trp_space_marine"),
    (set_visitor,19,"trp_space_marine"),
    (set_visitor,20,"trp_chaos_space_marine"),
    (set_visitor,21,"trp_chaos_space_marine"),
    (set_visitor,25,"trp_chaos_space_marine"),
    (set_visitor,26,"trp_chaos_space_marine"),
    (set_visitor,28,"trp_chaos_space_marine"),
    (set_visitor,29,"trp_chaos_space_marine"),
   (jump_to_scene,"scn_wh_battle1"),
   (set_jump_mission,"mt_warhammer40k_battle1"),
        (change_screen_mission),
[...]
    [
(1,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(1,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(1,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(1,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(4,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(4,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(4,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(7,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(7,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(7,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
(2,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(2,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(2,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(9,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]), #players entry point
(5,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(5,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(5,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(8,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(8,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(8,mtef_visitor_source|mtef_team_2,0,aif_start_alarmed,1,[]),
(3,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(3,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(3,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(3,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(6,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(6,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(6,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(9,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(9,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
(9,mtef_visitor_source|mtef_team_3,0,aif_start_alarmed,1,[]),
     ],
the thing that is making me mad is, that (set_visitor,0,"trp_player"), works well.
Title: Re: FAQ project!
Post by: Hellequin on January 18, 2007, 10:29:23 am
As ever, Armagan is on top of it.  Check it:

Quote from: Armagan
I am afraid the opcode definition of play_sound is misleading. Currently the options are ignored.

Quote from:  Hellequin on January 17, 2007, 05:53:39 pm
Is there a way to make a played sound stop, such as ending when the encounter or mission ends?
Sorry. There's no operation for that ATM. If you like I can add an operation which will stop all sounds.

Quote
BTW, there's a bug in (question_box), see (link) bug report for details, if you haven't already seen it.  Not a big issue, but I wanted to make sure you were aware it existed.
Ooops. Fixing it right away. Thanks a lot! :)

My response:

Quote
Quote from: armagan on Today at 09:41:43 am
If you like I can add an operation which will stop all sounds.
That would make a good segment of the modding community jump up and down for sheer joy.  Yes, please!
Title: Re: FAQ project!
Post by: Yoshiboy on January 18, 2007, 11:42:05 am
Good to know :)
Title: Modding Q&A
Post by: Winter on January 18, 2007, 01:55:19 pm
Always put the player's spawn entry first in the mission template. That should fix your problem.

Appropriately,
Winter
Title: Modding Q&A
Post by: Highlander on January 18, 2007, 02:42:32 pm
yeah,  I'll have to use 3 several mission templates to get 3 options for the player, not very elegant, but at least it works,
Title: Modding Q&A
Post by: Winter on January 18, 2007, 02:47:39 pm
yeah,  I'll have to use 3 several mission templates to get 3 options for the player, not very elegant, but at least it works,

I'm going to have to look into this more deeply when I start porting Storymod anyway, so I'll let you know what happens.

Truthfully I don't like M&B getting more fiddly than it already was . . .

Illusionistically,
Winter
Title: Modding Q&A
Post by: Hellequin on January 18, 2007, 04:07:23 pm
I've successfully got the player spawning at entry 4 during a custom mission template in Schattenlander.  What changed is the spawn record in the mission template; player uses mtef_scene_source, as compared with mtef_visitor_source for most entry points in the town_default mission template.  That spawn record isn't the first one listed, either, it's after some visitor_source spawn records.

That mission template does also have an entry-point-0 spawn record with an mtef_scene_source (player-friendly) entrance, so you should be okay if you just use one mission template with player-friendly spawn records at each of the entry points you want to use.  If, that is, I'm understanding correctly why mine worked, anyway.
Title: Modding Q&A
Post by: Winter on January 18, 2007, 05:10:48 pm
I've successfully got the player spawning at entry 4 during a custom mission template in Schattenlander.  What changed is the spawn record in the mission template; player uses mtef_scene_source, as compared with mtef_visitor_source for most entry points in the town_default mission template.  That spawn record isn't the first one listed, either, it's after some visitor_source spawn records.

This usually works, but with the new unpredictable nature of mission templates, there may be problems with multiple (variable) playerspawns in a scene.


Quote
That mission template does also have an entry-point-0 spawn record with an mtef_scene_source (player-friendly) entrance, so you should be okay if you just use one mission template with player-friendly spawn records at each of the entry points you want to use.

That's one idea worth exploring/verifying. Are you sure this works, and the scene_source doesn't override or spawn a duplicate player anywhere?

Intransitively,
Winter
Title: Modding Q&A
Post by: Hellequin on January 18, 2007, 05:25:11 pm
Absolutely.  The entry points 0 and 4 are quite close together, #4 was created basically to start the player looking at a specific other character in the bar, rather than standing by the counter.  Here's the code:

("inn_at_game_start",0,-1,"Default town visit plus PC at entry four allowed, entry points over 16 removed, and triggers added",
    [
(0,mtef_scene_source|mtef_team_1,af_town_overrides,group(1),1,[]),
(1,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(2,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(3,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),
(4,mtef_scene_source|mtef_team_1,af_town_overrides,group(1),1,[]),
(5,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(6,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(7,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(8,mtef_visitor_source,af_town_overrides,0,1,[]),(9,mtef_visitor_source,af_town_overrides,0,1,[]),(10,mtef_visitor_source,af_town_overrides,0,1,[]),(11,mtef_visitor_source,af_town_overrides,0,1,[]),(12,mtef_visitor_source,af_town_overrides,0,1,[]),
   (13,mtef_visitor_source,0,0,1,[]),(14,mtef_visitor_source,0,0,1,[]),(15,mtef_visitor_source,0,0,1,[]),(16,mtef_visitor_source,0,0,1,[]),
     ],
    [
   (various triggers here)
    ]),

No duplicate players present.  No chance to override since those entry points are reserved for the player only, which is probably wise.  Likewise the fact that my spawn records are in order, one per entry point, strictly ascending, may have mattered.  In any event it works just fine - apparently better than I deserve.  Amusingly, it was your cryptic hint, Winter, which made me try the change of mtef_ flag, and it worked first try after that.

- Hellequin
Title: Modding Q&A
Post by: Winter on January 18, 2007, 08:10:07 pm
Absolutely.  The entry points 0 and 4 are quite close together, #4 was created basically to start the player looking at a specific other character in the bar, rather than standing by the counter.  Here's the code:

("inn_at_game_start",0,-1,"Default town visit plus PC at entry four allowed, entry points over 16 removed, and triggers added",
    [
(0,mtef_scene_source|mtef_team_1,af_town_overrides,group(1),1,[]),
(1,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(2,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(3,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),
(4,mtef_scene_source|mtef_team_1,af_town_overrides,group(1),1,[]),
(5,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(6,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(7,mtef_visitor_source|mtef_team_1,af_town_overrides,0,1,[]),(8,mtef_visitor_source,af_town_overrides,0,1,[]),(9,mtef_visitor_source,af_town_overrides,0,1,[]),(10,mtef_visitor_source,af_town_overrides,0,1,[]),(11,mtef_visitor_source,af_town_overrides,0,1,[]),(12,mtef_visitor_source,af_town_overrides,0,1,[]),
   (13,mtef_visitor_source,0,0,1,[]),(14,mtef_visitor_source,0,0,1,[]),(15,mtef_visitor_source,0,0,1,[]),(16,mtef_visitor_source,0,0,1,[]),
     ],
    [
   (various triggers here)
    ]),

No duplicate players present.  No chance to override since those entry points are reserved for the player only, which is probably wise.  Likewise the fact that my spawn records are in order, one per entry point, strictly ascending, may have mattered.  In any event it works just fine - apparently better than I deserve.  Amusingly, it was your cryptic hint, Winter, which made me try the change of mtef_ flag, and it worked first try after that.

- Hellequin

Well, if the set_jump_entry operation works nowadays, we'll never need to use visitor_source for the player ever again. Which is a good thing because visitor_source for the player doesn't seem to work anymore.

Though I have most certainly used visitor_source succesfully in Craftmod on 0.808 . . .

Fuck, I just don't know anymore. I'm tired of it.

Senatorially,
Winter
Title: Modding Q&A
Post by: Hellequin on January 18, 2007, 09:24:58 pm
Yeah - I'm actually rather glad I came to modding only recently, when it seems to be simmering into a much less baroque form - and that's certainly saying something.  But yes; as far as I can tell, there is neither a need nor a reason to use the (set_visitor/mtef_visitor_source) pair with the player, ever.  The (set_jump_entry/mtef_scene_source) pair seems to do the trick just dandy.
Title: Modding Q&A
Post by: Raz on January 22, 2007, 04:30:48 pm
Hey, here's me with a simple question agian. The meaning of this trigger is to provide each city with new troops each day. I copied this from the tavern refresh, but for some reason this has a total different effect. It chooses just 1 city and keeps it each day. What am I doing wrong?

Quote
#CITY GARRISON
  (24.0, 0, 0.0,
   [ ],
   [   
#REPLENISH
# Refresh Jerusalem Cities

   (try_for_range, reg(1), towns_begin, towns_end),
   (store_faction_of_party, reg(2), reg(1)),
   (try_begin,0),
   (store_random,reg(12),10),
   (val_add,reg(12),3),
   (store_random,reg(13),5),
   (val_add,reg(13),2),
   (store_random,reg(14),3),
   (val_add,reg(14),2),
   (store_random,reg(15),2),
   (val_add,reg(15),1),
   (party_add_members, reg(1), "trp_jerusalem_sergeant1", reg(12)),
   (party_add_members, reg(1), "trp_jerusalem_sergeant2", reg(13)),
   (party_add_members, reg(1), "trp_jerusalem_sergeant3", reg(14)),
   (party_add_members, reg(1), "trp_jerusalem_sergeant_mounted", reg(14)),
   (party_add_members, reg(1), "trp_jerusalem_bowman", reg(13)),
   (party_add_members, reg(1), "trp_jerusalem_crossbowman", reg(12)),
   (party_add_members, reg(1), "trp_jerusalem_knight1", reg(14)),
   (party_add_members, reg(1), "trp_jerusalem_knight2", reg(15)),
]
Title: Modding Q&A
Post by: Yoshiboy on January 22, 2007, 04:34:14 pm
you need to end the try :)
Title: Modding Q&A
Post by: Raz on January 22, 2007, 05:29:44 pm
Right, thanks! Problem solved, case closed. :D
Title: Modding Q&A
Post by: fujiwara on January 22, 2007, 11:30:14 pm
(http://i46.photobucket.com/albums/f127/texan_otaku/cursorlenbug-1.png)

This just popped up out of nowhere...please don't tell me I've got to go back and recompile everything from Native >:(
Title: Re: Modding Q&A
Post by: Hellequin on January 23, 2007, 08:24:31 am
I seem to recall the above happening when I tried to run a save that was no longer compatible due to ID_strings having substantially changed.  Might that be the cause?
Title: Re: Modding Q&A
Post by: fujiwara on January 23, 2007, 12:42:37 pm
I thought that too, so I started a new game. Same problem. Last time this happened, I had to completely clean out all the module files and start with empty lists *grr*  >:(
Title: Re: Modding Q&A
Post by: Hellequin on January 23, 2007, 01:13:24 pm
You could try wiping out all the xx.txt and ID_xx.py generated files, and replacing them with the ones from the unchanged Native modsys build, maybe.  Worth a shot, anyway.
Title: Re: FAQ project!
Post by: Leprechaun on January 24, 2007, 03:16:28 pm
Can't find any mention of this - if both values are the same, will a val_min operation bugger up or simply do nothing?

Like, say reg(4) is 2, and so is reg(5), will [val_min,reg(4),reg(5)] cause an error or simply leave reg(4) as 2?
Title: Re: FAQ project!
Post by: Yoshiboy on January 24, 2007, 03:55:48 pm
I'd imagine it will just leave reg(4) (the first value) as reg(4) (the first value) but I'm not sure.
Title: Re: FAQ project!
Post by: Hellequin on January 24, 2007, 07:45:40 pm
I'm certain that it will do nothing.  I use a lot of (val_min) and (val_max) in my code, often in loops, and Schattenlander would be dying every ten seconds if that caused a problem.
Title: Re: FAQ project!
Post by: Leprechaun on January 25, 2007, 11:12:35 am
Oh good, that's good to know.
Title: Re: Modding Q&A
Post by: fujiwara on January 25, 2007, 10:29:32 pm
I figured it out: a few days I got a message that I had exceeded the maximum number of scenes (~460). I got rid of a few, which worked for a while, but then everything fell apart. This morning I realized that 90% of my scenes are repeated over and over, so I cut out all the redundant stuff and wrote a script to assign visitors to the scene in the menu options. Went from > 400 scenes to 130.

EDIT: Back up and running again! Clearing out all the scenes has had the great bonus of MUCH improved load times (~1 min, instead of almost 5). And here we thought it was the map the whole time.
Title: Re: Modding Q&A
Post by: Unknown on January 27, 2007, 03:40:32 am
Any idea what's wrong with this code?
Quote
(1, 4, ti_once, [(main_hero_fallen,0)], [(tutorial_box,"str_deadmessage", "str_dead")], []),
It says "An Integer is required" when I try to compile it..

?
Title: Re: Modding Q&A
Post by: Highlander on January 27, 2007, 04:37:49 am
Quote
(1, 4, ti_once, [(main_hero_fallen,0)], [(tutorial_box,"str_deadmessage", "str_dead")]),
that should work
Title: Re: Modding Q&A
Post by: Unknown on January 27, 2007, 05:55:17 am
Ahh.. got that solved by myself... Error was elsewhere.

Anyway now I got new problem.. How I can remove every item player has? I know how to empty his inventory, but I don't know how to remove all his equipment.

?
Title: Re: Modding Q&A
Post by: Highlander on January 27, 2007, 07:19:46 am
(try_for_range,reg(1),<first_item>,<last_item+1>),
(troop_remove_items,"trp_player",reg(1),99),
(try_end),
Title: Re: Modding Q&A
Post by: Hellequin on January 27, 2007, 09:38:43 am
Or, perhaps slightly faster, or just useful to see as an alternate approach,

(troop_get_inventory_capacity, ":Inv_cap", "trp_player"),
(try_for_range, ":Inv_slot", 0, ":Inv_cap"),
   (troop_get_inventory_slot, ":Item", "trp_player", ":Inv_slot"),
   (troop_remove_item, "trp_player", ":Item"),
(try_end),


Note that either approach will spam the player with "lost item X" messages.  You might wish to follow it with the trick of ten or twenty (display_message, "str_empty_string") to hide that spam.
Title: Re: Modding Q&A
Post by: Fisheye on January 27, 2007, 06:48:44 pm
I've found this works more reliably for me. Presumably remove_item sometimes shifts things around or doesn't remove the first item in the list

   (troop_get_inventory_capacity, ":inv_cap", ":troop"),
   (assign, ":num_items", 0),
   (try_for_range, ":i_slot", 0, ":inv_cap"),
      (troop_get_inventory_slot, ":item_id", ":troop", ":i_slot"),
      (ge, ":item_id", 0),
      (troop_set_slot, "trp_temp_array_a", ":num_items", ":item_id"),
      (val_add, ":num_items", 1),
   (try_end),
   (try_for_range, ":i_slot", 0, ":num_items"),
      (troop_get_slot, ":item_id", "trp_temp_array_a", ":i_slot"),
      (troop_remove_items, ":troop", ":item_id", 1),
   (try_end),
Title: Re: Modding Q&A
Post by: Raz on January 31, 2007, 02:59:21 pm
I'm experiencing problems with a ground material. In brf, it looks like this:

http://i2.photobucket.com/albums/y26/khaya/weird_material_brf.jpg

While ingame, it looks like this:

http://i2.photobucket.com/albums/y26/khaya/weird_material.jpg

Does anybody know why it turns totally grey? I tried using different materials.
Title: Re: Modding Q&A
Post by: Fisheye on January 31, 2007, 03:37:31 pm
Is it one big square? If so it may be culled (or something don't know what the correct term is).

Just put a bunch of grid lines over it to break it up.
Title: Re: Modding Q&A
Post by: Raz on January 31, 2007, 03:47:55 pm
Yes it's just 2 polygons, but they strech to the horizon. So I should increase the polycount?
Title: Re: Modding Q&A
Post by: Scion on February 01, 2007, 10:58:06 am
I might have encountered the same problem. You UV map much larger than the original image, and hope for a tile, right? Well, from my experiences only Native textures could handle this in 0.751, that is, I had to replace a tileable native texture to get it to tile properly. With the new BRF-Edit, I guess you can just set the proper texture flags. Must be it.
Title: Re: Modding Q&A
Post by: Fisheye on February 01, 2007, 12:53:03 pm
Yes it's just 2 polygons, but they strech to the horizon. So I should increase the polycount?

Yeah I had the same problem when making the scenes in Storymod C1. Big flat poly for the ground wouldn't show up. Fixed when I threw a bunch of extra lines across the face.

I think the engine culls the shape if the center of the poly is too far from the player. I can understand why it's doing it for me, but for your rig it may be something else altogether, so no guarantees.
Title: Re: Modding Q&A
Post by: Raz on February 01, 2007, 01:23:50 pm
Thanks guys, that should solve it.
Title: Re: Modding Q&A
Post by: Raz on February 02, 2007, 03:56:54 am
Can somebody please tell me what's wrong with this trigger? The troops need to be relocated to a new tavern scene every 3 days, but it only happens with a single troop.

Quote
(1.0, 0, (3.0 * 24.0),
 [(try_for_range, reg(1),norman_merc_captains_begin, norman_merc_captains_end),
  (troop_get_slot, reg(2), reg(1), slot_captain_mercs),
  (party_count_members_of_type, reg(3), reg(2), "trp_norman_knight"),
  (party_count_members_of_type, reg(4), reg(2), "trp_norman_sergeant"),
  (party_count_members_of_type, reg(5), reg(2), "trp_genoese_crossbowman"),

  (store_random,reg(7),4),
  (val_add,reg(7),1),
  (store_random,reg(8),10),
  (val_add,reg(8),2),
  (store_random,reg(9),6),
  (val_add,reg(9),2),
  (party_add_members, reg(2), "trp_norman_knight", reg(7)),
  (party_add_members, reg(2), "trp_norman_sergeant", reg(8)),
  (party_add_members, reg(2), "trp_genoese_crossbowman", reg(9)),
  (end_try),
 
  (try_for_range, reg(10), towns_begin, towns_end),
  (party_get_slot, reg(11), reg(10), slot_town_tavern),
  (add_troop_to_site, reg(1), reg(11), 6),
  (end_try)
  ],
 
 []),
Title: Re: Modding Q&A
Post by: Winter on February 02, 2007, 06:36:09 am
Can somebody please tell me what's wrong with this trigger? The troops need to be relocated to a new tavern scene every 3 days, but it only happens with a single troop.

Quote
(1.0, 0, (3.0 * 24.0),
 [(try_for_range, reg(1),norman_merc_captains_begin, norman_merc_captains_end),
  (troop_get_slot, reg(2), reg(1), slot_captain_mercs),
  (party_count_members_of_type, reg(3), reg(2), "trp_norman_knight"),
  (party_count_members_of_type, reg(4), reg(2), "trp_norman_sergeant"),
  (party_count_members_of_type, reg(5), reg(2), "trp_genoese_crossbowman"),

  (store_random,reg(7),4),
  (val_add,reg(7),1),
  (store_random,reg(8),10),
  (val_add,reg(8),2),
  (store_random,reg(9),6),
  (val_add,reg(9),2),
  (party_add_members, reg(2), "trp_norman_knight", reg(7)),
  (party_add_members, reg(2), "trp_norman_sergeant", reg(8)),
  (party_add_members, reg(2), "trp_genoese_crossbowman", reg(9)),
  (end_try),
 
  (try_for_range, reg(10), towns_begin, towns_end),
  (party_get_slot, reg(11), reg(10), slot_town_tavern),
  (add_troop_to_site, reg(1), reg(11), 6),
  (end_try)
  ],
 
 []),

You're ending the try_for_range in the middle of what you're wanting to do. Move the bolded try_end down to the bottom.

Particularly,
Winter
Title: Re: Modding Q&A
Post by: Highlander on February 02, 2007, 07:41:34 am
if you use add_troop_to_site, the game assigns this troop to the chosen entry point. If you use it again with the same entry point, it removes the old troop and uses the new one. Several troops can't be added to one entry point.

The solutions I can think of are:
You can use 6 different entry points
or you use a variable to make the game menu use the right troop with set_visitor and use add_reinforestments_to_entry in the mission_template.
Title: Re: Modding Q&A
Post by: Raz on February 02, 2007, 08:31:05 am
Okay, thanks guys I'll try it out. By the way, is there a way to mark the individual cities which are chosen?

Oh, I already know what went wrong. The try_for_range operation with towns should be store random; now it just picks one town and keeps adding them there right?

I don't fully get your last line Highlander. Wouldn't it just be possible to register the cities already picked? (after the store random operation)

edit: Is this the correct way for doing the store random the same number of times as the try_for_range?
Title: Re: Modding Q&A
Post by: Fisheye on February 02, 2007, 10:45:00 am
Raz, if you'll tell me exactly what you want I can try to give you a section of code that does just that. I'm a big fan of Holy War.

I believe there are several things wrong with the above code, that's why it's hard to really figure out what's what.
Title: Re: Modding Q&A
Post by: Raz on February 02, 2007, 10:55:35 am
Hey fisheye, thanks a lot :)

Every three days I need the mercenary captains (they're with 10) to each spawn to a tavern scene in a random town (34 of 'em), and to give that captain's merc party a semi-random amount of troops every three days. Is that what you want to hear?
Title: Re: Modding Q&A
Post by: Fisheye on February 02, 2007, 11:54:51 am
Quote
(1.0, 0, (3.0 * 24.0), [],
 [
  # Randomly select new position of captains
  # first make an array with all the towns in it
  (assign, ":num_towns", 0),
  (try_for_range, ":town", towns_begin, towns_end),
    (troop_set_slot, "trp_temp_array_a", ":num_towns", ":town"),
    (val_add, ":num_towns", 1),
  (try_end),
  # now randomly shuffle the array
  (try_for_range, ":i", 100),
     (store_random, ":slot_a", 0, ":num_towns"),
     (store_random, ":slot_b", 0, ":num_towns"),
     (neq, ":slot_a", ":slot_b"),
     (troop_get_slot, ":town_a", "trp_temp_array_a", ":slot_a"),
     (troop_get_slot, ":town_b", "trp_temp_array_a", ":slot_b"),
     (troop_set_slot, "trp_temp_array_a", ":slot_a", ":town_b"), #swap
     (troop_set_slot, "trp_temp_array_a", ":slot_b", ":town_a"), #swap
  (try_end),

  # ok, we know where to put these guys now, let's process them
  # Replenish troops
  (try_for_range, ":merc_captain_troop" ,norman_merc_captains_begin, norman_merc_captains_end),
    (troop_get_slot, ":merc_party", ":merc_captain_troop", slot_captain_mercs),
    (party_count_members_of_type, ":num_knights", ":merc_party", "trp_norman_knight"),
    (party_count_members_of_type, ":num_sergeants", ":merc_party", "trp_norman_sergeant"),
    (party_count_members_of_type, ":num_crossbowmen", ":merc_party", "trp_genoese_crossbowman"),

    (store_random_in_range,":additional_troops", 1,5),
    (store_sub, ":max_addable_troops", norman_merc_max_knights, ":num_knights"),
    (val_min, ":additional_troops", ":max_addable_troops"),
    (party_add_members, ":merc_party", "trp_norman_knight", ":additional_troops"),

    (store_random_in_range,":additional_troops", 2,12),
    (store_sub, ":max_addable_troops", norman_merc_max_sergeants, ":num_sergeants"),
    (val_min, ":additional_troops", ":max_addable_troops"),
    (party_add_members, ":merc_party", "trp_norman_sergeant", ":additional_troops"),

    (store_random_in_range,":additional_troops", 2,8),
    (store_sub, ":max_addable_troops", norman_merc_max_crossbowmen, ":num_crossbowmen"),
    (val_min, ":additional_troops", ":max_addable_troops"),
    (party_add_members, ":merc_party", "trp_genoese_crossbowman", ":additional_troops"),
  (try_end),

  # remove them from old location
  (try_for_range, ":merc_captain_troop" ,norman_merc_captains_begin, norman_merc_captains_end),
    (troop_get_slot, ":current_site", ":merc_captain_troop", slot_current_site),
    (neq, ":current_site", 0),
    (remove_troop_from_site, ":merc_captain_troop", ":current_site"),
  (try_end),

  # put them in new locations
  (try_for_range, ":merc_captain_troop" ,norman_merc_captains_begin, norman_merc_captains_end),
    (store_sub, ":index", ":merc_captain_troop", norman_merc_captains_begin),
    (troop_get_slot, ":target_town", ":troop_temp_array_a", ":index"),
    (party_get_slot, ":target_scene", ":target_town", slot_town_tavern),
    (troop_set_slot, ":merc_captain_troop", slot_current_site, ":target_scene"),
    (add_troop_to_site, ":merc_captain_troop", ":target_scene",6),
  (try_end),
],

),

You'll need to define a slot_current_site in your module_constants.py.

Also define norman_merc_max_knights to be the maximum number of knights allowable in the merc party.

Same with norman_merc_max_sergeants and norman_merc_max_crossbowmen.
Title: Re: Modding Q&A
Post by: Raz on February 03, 2007, 03:33:07 pm
Thanks :), though I need some time to test it out and to decipher all that. I'll keep you informed how it went.
Title: Re: FAQ project!
Post by: ex_ottoyuhr on February 03, 2007, 04:20:50 pm
To start with, let me observe that I probably owe this thread a substantial set of entries. (Edit: By "entries" I mean "FAQ entries," not "questions.") Don't worry, I won't be quite so bad this time as i was back in Modmakers' Q&A. I hope... :) (And I'll try to put together a tutorial for writing 'cutscenes,' to be submitted to the tutorials section here.)

To get to the point, I'm having trouble figuring out how to 'cannibalize' the tavern code -- what command to use to make the game jump back to a party encounter after resting for a while. I'm trying this:

Quote
(assign,"$auto_enter_town","$current_town"),
(rest_for_hours,"$rest_for_hours"),
(change_screen_return),

-- leveraging the extant code in taverns and the simple_triggers "map_free" trigger, but it's not getting me anywhere -- the party rests correctly, but then falls back to the world map...
Title: Re: FAQ project!
Post by: Fisheye on February 03, 2007, 05:41:06 pm
Is the trigger not firing at all? So if you put a debug string on the map free (preferably printing out the value of $auto_enter_town), it doesn't print?

I've had rare instances where map_free simply does not fire after a few hours of working fine. But if you consistently can't get it to fire then it might be something else.
Title: Re: FAQ project!
Post by: Hellequin on February 03, 2007, 09:34:04 pm
I've seen the same thing as Fisheye has, where map_free will sometimes simply stop working.  For me it's usually been immediately after loading a game, it just doesn't kick in until you quit and reload.  Very infrequent, though.

And by 'cutscenes' do you mean 'scripted sequences using the M&B engine" or "videos made using other means and spliced in somehow"?  Mostly I'm just curious, because I spent a long time making two fairly simple cutscenes of the first sort (admittedly, one of which segues into a fight)... be nice to compare notes.
Title: Re: FAQ project!
Post by: ex_ottoyuhr on February 03, 2007, 10:25:52 pm
Fisheye -- It didn't occur to me to try debugging it with a string message -- but hearing what you're saying about map_free just quitting at times, I think it'd be better to do the Storymod-style "encounter party" after all. Thanks a lot.

Hellequin -- I should be more unambiguous. I mean what you're talking about -- scripted scenes in the M&B engine -- and it would be pretty interesting to compare notes on them. "A long time" sounds about right; I had a heck of a time figuring the things out at first, and there's always an extreme amount of overhead involved...
Title: Re: M&B Scripting Q&A
Post by: Raz on February 05, 2007, 08:04:22 am
Hey fisheye, I spent some time studying your code, I added in the constants you told me and I get this error:

(http://i2.photobucket.com/albums/y26/khaya/error.jpg)

I tried to see if there were some errors in your code but I didn't find any. Perhaps the slot_current_site constant should be a specific number?
Title: Re: M&B Scripting Q&A
Post by: Fisheye on February 05, 2007, 11:04:44 am
Ooops typo.

Replace all instances of ":troop_temp_array_a" with "trp_temp_array_a".

i.e.

Quote
(1.0, 0, (3.0 * 24.0), [],
 [
  # Randomly select new position of captains
  # first make an array with all the towns in it
  (assign, ":num_towns", 0),
  (try_for_range, ":town", towns_begin, towns_end),
    (troop_set_slot, "trp_temp_array_a", ":num_towns", ":town"),
    (val_add, ":num_towns", 1),
  (try_end),
  # now randomly shuffle the array
  (try_for_range, ":i", 100),
     (store_random, ":slot_a", 0, ":num_towns"),
     (store_random, ":slot_b", 0, ":num_towns"),
     (neq, ":slot_a", ":slot_b"),
     (troop_get_slot, ":town_a", "trp_temp_array_a", ":slot_a"),
     (troop_get_slot, ":town_b", "trp_temp_array_a", ":slot_b"),
     (troop_set_slot, "trp_temp_array_a", ":slot_a", ":town_b"), #swap
     (troop_set_slot, "trp_temp_array_a", ":slot_b", ":town_a"), #swap
  (try_end),

  # ok, we know where to put these guys now, let's process them
  # Replenish troops
  (try_for_range, ":merc_captain_troop" ,norman_merc_captains_begin, norman_merc_captains_end),
    (troop_get_slot, ":merc_party", ":merc_captain_troop", slot_captain_mercs),
    (party_count_members_of_type, ":num_knights", ":merc_party", "trp_norman_knight"),
    (party_count_members_of_type, ":num_sergeants", ":merc_party", "trp_norman_sergeant"),
    (party_count_members_of_type, ":num_crossbowmen", ":merc_party", "trp_genoese_crossbowman"),

    (store_random_in_range,":additional_troops", 1,5),
    (store_sub, ":max_addable_troops", norman_merc_max_knights, ":num_knights"),
    (val_min, ":additional_troops", ":max_addable_troops"),
    (party_add_members, ":merc_party", "trp_norman_knight", ":additional_troops"),

    (store_random_in_range,":additional_troops", 2,12),
    (store_sub, ":max_addable_troops", norman_merc_max_sergeants, ":num_sergeants"),
    (val_min, ":additional_troops", ":max_addable_troops"),
    (party_add_members, ":merc_party", "trp_norman_sergeant", ":additional_troops"),

    (store_random_in_range,":additional_troops", 2,8),
    (store_sub, ":max_addable_troops", norman_merc_max_crossbowmen, ":num_crossbowmen"),
    (val_min, ":additional_troops", ":max_addable_troops"),
    (party_add_members, ":merc_party", "trp_genoese_crossbowman", ":additional_troops"),
  (try_end),

  # remove them from old location
  (try_for_range, ":merc_captain_troop" ,norman_merc_captains_begin, norman_merc_captains_end),
    (troop_get_slot, ":current_site", ":merc_captain_troop", slot_current_site),
    (neq, ":current_site", 0),
    (remove_troop_from_site, ":merc_captain_troop", ":current_site"),
  (try_end),

  # put them in new locations
  (try_for_range, ":merc_captain_troop" ,norman_merc_captains_begin, norman_merc_captains_end),
    (store_sub, ":index", ":merc_captain_troop", norman_merc_captains_begin),
    (troop_get_slot, ":target_town", "trp_temp_array_a", ":index"),
    (party_get_slot, ":target_scene", ":target_town", slot_town_tavern),
    (troop_set_slot, ":merc_captain_troop", slot_current_site, ":target_scene"),
    (add_troop_to_site, ":merc_captain_troop", ":target_scene",6),
  (try_end),
],

),
Title: Re: M&B Scripting Q&A
Post by: Raz on February 05, 2007, 11:58:02 am
Hey, that worked. Thanks Fisheye, I'll list you at the contributors ;)
Title: Re: M&B Scripting Q&A
Post by: Fisheye on February 05, 2007, 12:04:50 pm
Oh by the way the captains should start unplaced, i.e. should not have an initial scene/entry point in their module_troops entry. Just let the script fire and place them after the first game hour.

If you need anything else, just post a request at the Script Requests topic on this board and I'll see if I can provide.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on February 06, 2007, 06:34:30 pm
Is there a way to "short-circuit" a try_for_range section? For instance, I want to find the first town for which some condition is true:

(assign,":found",0),
(assign,":found_town",0),
(try_for_range,":town",towns_begin,towns_end),
 (eq,":found",0),
 (party_get_slot,":foo",":town",slot_town_foo),
 (eq,":foo",1),
 (assign,":found_town",":town"),
 (assign,":found",1),
(try_end),


The whole ":found" is tacked on in order to jump out of the try_for_range section once a match is found, but is there some other way of accomplishing the same?
Something like:

(assign,":found_town",0),
(try_for_range,":town",towns_begin,towns_end),
 (party_get_slot,":foo",":town",slot_town_foo),
 (eq,":foo",1),
 (assign,":found_town",":town"),
 (try_break), # <--- Breaks out of the try_for_range
(try_end),
Title: Re: M&B Scripting Q&A
Post by: Scion on February 06, 2007, 07:00:31 pm
Haven`t tried it myself, but what about
(assign, ":town", towns_end),
?
Title: Re: M&B Scripting Q&A
Post by: Neophyte on February 06, 2007, 07:28:52 pm
That sounds like it should work, and made me go "Doh! Why didn't I think of that?". :)   Thanks.
Title: Re: M&B Scripting Q&A
Post by: Winter on February 07, 2007, 05:05:25 am
Haven`t tried it myself, but what about
(assign, ":town", towns_end),
?

Not sure if that would work, but if it does, very nice.

Here's something I've used myself:

Code: [Select]
(store_add,":range_end",towns_begin,1), # ":range_end" = towns_begin+1
(try_for_range,":town",towns_begin,":range_end"), # try for towns_begin to towns_begin+1
(eq,":town",":found"), # if condition is true . . .
# more here
(else_try),
(neq,":town",":found"), # if condition is not true . . .
(val_add,":range_end",1), # ":range_end" = ":range_end"+1, i.e. continue the try_for_range
(try_end),

Basically it keeps adding 1 to the upper bound of the try_for_range if conditions aren't met. Works like a charm.

Sepulchrally,
Winter
Title: Re: M&B Scripting Q&A
Post by: Scion on February 07, 2007, 11:40:22 am
When can agents walk?

agent_set_scripted_destination doesn`t seem to work for me, but it is a peaceful scene and mission template.
Title: Re: M&B Scripting Q&A
Post by: Highlander on February 07, 2007, 12:24:57 pm
there has to be at least one enemy.
Title: Re: M&B Scripting Q&A
Post by: Scion on February 07, 2007, 01:12:19 pm
Thanks Highlander, it worked! Still, one can give order to walking-around citizen  ??? I guess the whole hack has its disadvantages.
Title: Re: M&B Scripting Q&A
Post by: Highlander on February 08, 2007, 10:32:57 am
is it just me or does the edit mode for getting the coordinates of the main party not work?
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 09, 2007, 11:53:56 am
Can anyone tell me why this does not work?

Code: [Select]
(try_for_range,':currstack',0,':stacknumber'),
        (party_stack_get_troop_id,':troopid',':party',':currstack'),
        (party_stack_get_size,':troopnumber',':party',':currstack'),
        (party_stack_get_num_wounded,':wounded',':party',':currstack'),
        (val_sub,':troopnumber',':wounded'),
        (try_for_range,':anyhorse',"itm_horses_begin","itm_horses_end"),
          (troop_has_item_equipped,':troopid',':anyhorse'),
          (store_skill_level,':troopman',skl_riding),
          (val_mul,':troopman',2),
          (val_mul,':troopman',':troopnumber'),
          (val_add,':manoeuvre',':troopman'),
        (else_try),
          (store_skill_level,':troopman',skl_athletics),
          (val_mul,':troopman',':troopnumber'),
          (val_add,':manoeuvre',':troopman'),
        (try_end),
      (try_end),
      (party_get_skill_level,':pathfinding',':party',skl_pathfinding),
      (val_div,':pathfinding',5),
      (val_mul,':manoeuvre',':pathfinding'),
      (val_div,':manoeuvre',':forcesize'),
      (store_div,':avgmorale',':morale',':forcesize'),
      (val_div,':avgmorale',3),
      (val_mul,':manoeuvre',':avgmorale'),
      (assign,reg62,':morale'),
      (assign,reg63,':manoeuvre'),
:stacknumber, :party, :morale and :forcesize are determined in working portions of the script. The dummy items horses_begin and horses_end are correctly placed. The script returns the correct value in reg62 but leaves reg63 at 0.
Title: Re: M&B Scripting Q&A
Post by: Scion on February 09, 2007, 12:04:29 pm
to translate the last part...

pathfinding = pathfinding / 5             <----- ? if Pathfinding < 5, pathfinding = 4/5 = 0 ?
manouvre = manouvre * pathfinding
manouvre = manouvre / forcesize
avgmorale = morale / forcesize
avgmorale = avgmorale / 3

manoueuvre = manoueuvre * avgmorale

Ah well anyway, somewhere there`s a zero of course. Lot`s of divisions, could be there.

reg63 = manoueuvre
Title: Re: M&B Scripting Q&A
Post by: Fisheye on February 09, 2007, 12:10:56 pm
Yup. Good catch Scion. Always multiply before you divide - M&B script doesn't do floating point or fractions.
Title: Re: M&B Scripting Q&A
Post by: Nethros on February 09, 2007, 07:12:20 pm
Do you know how to give units firearm profiencies? It doesn't seem to add anything when I do wp(XX) and wp_firearms is not defined.
Title: Re: M&B Scripting Q&A
Post by: Hellequin on February 09, 2007, 08:15:21 pm
That's 'cause it's defined as wp_firearm.  Try that.

If you want you could of course add an appropriate line to the wp(x) definition in module_troops, using the singular as above.
Title: Re: M&B Scripting Q&A
Post by: Nethros on February 10, 2007, 05:12:47 am
Danke, mein freund! You shall be remembered! Now finally my units can aim!
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 10, 2007, 07:30:34 am
Scion and Fisheye, thank you. I'll multiply all the values susceptible of turning in a zero by ten and then divide the final number to make it what it should be.
Title: Very noobie question, should be simply answered...
Post by: freepower on February 13, 2007, 12:43:56 pm
Firstly, how does one check for whether a player has multiples of a single object? eg -

[trp_marnid|plyr,"marnid_leather_hauberk_2", [(player_has_item,"itm_padded_cloth")], "Then, take this padded cloth I have. I want you to join me.", "marnid_leather_hauberk_3_cloth",[]],
 
How would i check for 2 padded_cloth?

Also, it seems that using the same face code, a troop and hero end up with different faces?
Title: Re: Very noobie question, should be simply answered...
Post by: Hellequin on February 13, 2007, 12:48:35 pm
I didn't spot this one for ages when I first started.  The operation you're looking for is (store_item_kind_count).  Check it out in header_operations.py.  Stores the number of a particular item possessed by a particular troop into a variable you designate; you can then compare that variable in whatever way you like, >=2 or <8 or whatever.
Title: Re: Very noobie question, should be simply answered...
Post by: freepower on February 13, 2007, 12:53:31 pm
Thanks very much, that makes my life a lot easier!
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 15, 2007, 11:10:18 am
What makes creating a bow or crossbow mesh with a bowstring so hard? All modded (cross)bows do not have a bowstring, including those from mods like Craftmod which are otherwise extremly well-made, so I suppose it must be extremely difficult if not impossible. But why? is it because we can't tell M&B which part of the mesh is the string?

Also--can anyone tell if (and how) it would be possible to edit the ammount of textures available to the in-game facegen? Not that i'm likely to succeed in creating a working texture for it but you never know...
Title: Re: M&B Scripting Q&A
Post by: Winter on February 15, 2007, 11:44:49 am
What makes creating a bow or crossbow mesh with a bowstring so hard? All modded (cross)bows do not have a bowstring, including those from mods like Craftmod which are otherwise extremly well-made, so I suppose it must be extremely difficult if not impossible. But why? is it because we can't tell M&B which part of the mesh is the string?

Also--can anyone tell if (and how) it would be possible to edit the ammount of textures available to the in-game facegen? Not that i'm likely to succeed in creating a working texture for it but you never know...

All Craftmod's bows were made before 0.800, when bowstrings didn't exist. I haven't changed them to include bowstrings because easily adding bowstrings was impossible until BRFEdit 0.82 was released just the other day. Plus, adding the strings is a real drudge job for the number and variety of bows in Craftmod.

New face textures are added by including the textures in the appropriate entries of module_skins.py.

Botheredly,
Winter
Title: Re: M&B Scripting Q&A
Post by: Fisheye on February 15, 2007, 12:09:25 pm
What makes creating a bow or crossbow mesh with a bowstring so hard? All modded (cross)bows do not have a bowstring, including those from mods like Craftmod which are otherwise extremly well-made, so I suppose it must be extremely difficult if not impossible.

It's the same reason why swords with scabbards are so scarce. Bows have vertex animation. Creating the animation itself is relatively easy. The problem is prior to v0.8.2 BRF Edit did not support import of vertex animation file formats from anything other than VTA and the only program known to support exporting to VTA is 3DSMax which costs $3500 retail. Until v0.8.2 which was released on 2/11/07... which allows import of vertex animation via separate OBJ files (yay I can use Wings) so yeah we've had 4 days to actually do this stuff. They'll pop up soon enough.
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 15, 2007, 03:15:28 pm
Excellent! It sounds like something even I could do! It will be more trouble to create the new textures than anything; one more question though, can I "hide" face textures so only my NPCs can use them, not the PC?
Title: Re: M&B Scripting Q&A
Post by: Winter on February 15, 2007, 03:40:53 pm
Excellent! It sounds like something even I could do! It will be more trouble to create the new textures than anything; one more question though, can I "hide" face textures so only my NPCs can use them, not the PC?

If you create a new 'race' entry for your NPCs in module_skins, and flag the appropriate NPCs to that race, the PC will be unable to use them.

Prevocalically,
Winter
Title: Re: M&B Scripting Q&A
Post by: Scion on February 15, 2007, 04:19:50 pm
Is there any clever way to detect if the player have reached a certain place, like a point in a corridor in mission templates?
Title: Re: M&B Scripting Q&A
Post by: Fisheye on February 15, 2007, 04:23:44 pm
Put an entry point or scene prop there, get its position, then use get_distance_between_positions.

Or you can do it manually with position_get_x etc.
Title: Re: M&B Scripting Q&A
Post by: Scion on February 15, 2007, 04:25:06 pm
Exactly, solved. Thanks a lot.
Title: Re: M&B Scripting Q&A
Post by: Scion on February 15, 2007, 06:22:07 pm
Is there any way to spawn enemies into a scene? From what I can see, you can do one of the following:
- Spawn a NPC at a position, but he will be friendly.
- Bring him as reinforcement, but then you`ll have to have somebody there from before.

I would like to spawn him without having anyone before him.
Title: Re: M&B Scripting Q&A
Post by: Hellequin on February 15, 2007, 08:20:25 pm
Bring the enemies in at an entry point with capacity zero initially, then spawn the reinforcements there (which ignores the listed capacity of the entry).

Check the Schattenlander source, (mnu_burning_inn_intro) in module_city_contents and (mt_battle_outside_the_burning_inn) in module_mission_templates; they do exactly that with the Watch.
Title: Re: M&B Scripting Q&A
Post by: Scion on February 16, 2007, 01:41:19 am
Thanks  :)
And now you really made me want to play Schattenländer
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 18, 2007, 10:33:19 am
Yet another one of my stupid questions: if I want to make a weapon with a visible magazine, and have the ammount of projectiles actually match the projectiles remaining, I'd have to make a frame for each number of prejectiles that could possibly be seen. But, will the game use this? Will it go to the next frame each time a shot is fired, like quivers which seem to update the number of remaining arrows each time you take one, or will it simply ignore the additional frames on a weapon?
Title: Re: M&B Scripting Q&A
Post by: morgoth2005 on February 19, 2007, 10:22:47 am
I try to compile my mod - I'm still learning coding and the Documnetation on the taleworlds forum is not finished -
anyway, when i compile it drops me into this:

http://img87.imageshack.us/my.php?image=weird3bi8.png (http://img87.imageshack.us/my.php?image=weird3bi8.png)
Title: Re: M&B Scripting Q&A
Post by: Scion on February 19, 2007, 10:28:41 am
My guess is that you are missing an argument. My experience from "int argument required" is that the line is built up wrong and the module system does not find what it expects. You are for example missing item modifiers or something, and ending the line too early.
Title: Re: M&B Scripting Q&A
Post by: morgoth2005 on February 19, 2007, 03:40:58 pm
but its a damn process file. I replaced it and it still says that.

And how do I fix it?
Title: Re: M&B Scripting Q&A
Post by: Scion on February 19, 2007, 03:43:18 pm
No it`s in Module_*something*. The process file reads the module_*something* file to convert it into M&B code. When Python reports about the process_... file, it is actually the process file reporting about the module_*..* file. Never mess with a process file, it can only get you into trouble.  :lol:
Title: Re: M&B Scripting Q&A
Post by: morgoth2005 on February 19, 2007, 04:43:10 pm
(http://img89.imageshack.us/img89/9646/weird4uj6.th.jpg) (http://img89.imageshack.us/my.php?image=weird4uj6.jpg)
(http://img89.imageshack.us/img89/2815/72754471fm5.th.jpg) (http://img89.imageshack.us/my.php?image=72754471fm5.jpg)

would these help.
This is when I start a new game then M&B freezes. I know to not mess with process file sthat was said in the documnetation

BTW what happened to the modding documentation - it stops abruptly
Title: Re: M&B Scripting Q&A
Post by: Fisheye on February 19, 2007, 05:18:52 pm
Same deal: missing comma or bracket or some such formatting thing.
Title: Re: M&B Scripting Q&A
Post by: Hellequin on February 22, 2007, 08:46:12 pm
Okay, does anyone know exactly how the imodbits_good and imodbits_bad are applied?

I keep having imodbits which are on one of these two lists - particularly the first one on the list - show up applied to inappropriate items, like a Sturdy pickaxe or a Rusty hood.

I've also had this problem with Lame being attached to things inappropriately, which may mean it's a coincidence that all the other wrong imodbits I'm currently seeing are from the _good and _bad lists; Lame isn't on either.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on February 22, 2007, 11:17:31 pm
I have yet to delve into the art of agent scripting, so I'm unsure how all the operations work. If I wanted to check if a particular troop died on the battlefield, could I use try_for_agents in a trigger, something like (in MoBo script):

Code: [Select]
try_for_agents :input_agent
     agent_get_troop_id :agent_id :input_agent
     :agent_id = <target troop id>
     !agent_is_alive :input_agent
     $target_is_dead = 1
try_end

and loop this every 10 seconds or so?
Title: Re: M&B Scripting Q&A
Post by: bryce on February 23, 2007, 01:51:07 am
Here is a code snippet from within a loop.  Why oh why won't the actual items get removed from the companions' inventories, which is the point of this?

Anyone have any idea.  troop_clear_inventory seems to do nothing, and doing troop_remove_item on every item item one by one does nothing as well....


    (str_store_troop_name, 45,"$current_hero"),
    (display_message, '_Clearing inventory for {s45}_'),
    (troop_clear_inventory,"$current_hero"),

        (try_for_range, ":current_item", 1, "itm_last_item"),
        (troop_remove_item, ":current_item"),
        (end_try),
Title: Re: M&B Scripting Q&A
Post by: bryce on February 23, 2007, 01:54:10 am
I have yet to delve into the art of agent scripting, so I'm unsure how all the operations work. If I wanted to check if a particular troop died on the battlefield, could I use try_for_agents in a trigger, something like (in MoBo script):

Code: [Select]
try_for_agents :input_agent
     agent_get_troop_id :agent_id :input_agent
     :agent_id = <target troop id>
     !agent_is_alive :input_agent
     $target_is_dead = 1
try_end

and loop this every 10 seconds or so?

I use code like that for finding fallen comrades and it works fine.

(try_for_agents, "$current_agent"),
 (agent_is_ally, "$current_agent"),
 (agent_is_human, "$current_agent"),
 (neg|agent_is_alive, "$current_agent"),
 (agent_get_troop_id, "$current_agent_troop_id", "$current_agent"),
 (main_party_has_troop, "$current_agent_troop_id"),

your code here

(end_try),
Title: Re: M&B Scripting Q&A
Post by: Winter on February 23, 2007, 07:03:47 am
Here is a code snippet from within a loop.  Why oh why won't the actual items get removed from the companions' inventories, which is the point of this?

Anyone have any idea.  troop_clear_inventory seems to do nothing, and doing troop_remove_item on every item item one by one does nothing as well....


    (str_store_troop_name, 45,"$current_hero"),
    (display_message, '_Clearing inventory for {s45}_'),
    (troop_clear_inventory,"$current_hero"),

        (try_for_range, ":current_item", 1, "itm_last_item"),
        (troop_remove_item, ":current_item"),
        (end_try),

This doesn't work because you're using the wrong item remove operation. If you want to remove all items with script, use the following:


        (try_for_range, ":current_item", 1, "itm_last_item"),
        (store_item_kind_count,":num_items",":current_item",":troop"),
        (troop_remove_items, ":troop", ":current_item", ":num_items"),
        (end_try),

Be sure to assign ":troop" beforehand, of course.

Substantively,
Winter
Title: Re: M&B Scripting Q&A
Post by: Nethros on February 23, 2007, 07:48:09 am
For my mod, I made my bayonets based on a lance, and I can't make it block. Does anyone know how to make it be able to block?
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on February 23, 2007, 10:03:47 am
For my mod, I made my bayonets based on a lance, and I can't make it block. Does anyone know how to make it be able to block?

The block abilities are a type of item flag. Most of the items have default configurations that are given certain names in header_items but you can list the flags individually as well. You have to list one for each block direction that you want.

For example:
itcf_parry_forward_polearm, itcf_parry_up_polearm, itcf_parry_right_polearm, itcf_parry_left_polearm,

These, if put in the item capability flag area of the item in its entry, you would be able to block in every direction as per the polearm animations. You can mix and match however, so you could have the left block be a one handed animation with top block being a two handed animation. You can also do this with attack animations, you just have to make sure in both cases that there isn't a default setup overriding or conflicting with your individual choices.

All these item capability flags are at the bottom of header_items.
Title: Re: M&B Scripting Q&A
Post by: bryce on February 23, 2007, 10:15:07 am
Thaks! I feel silly now....
Title: Re: M&B Scripting Q&A
Post by: Nethros on February 23, 2007, 01:38:00 pm
Now I get some TypeError: len<> of unsized object

Could you tell me in where I am to put those?

["unimportantIDname", "Unimportant Name", [("unimportantmeshname",0)], itp_type_polearm|itp_merchandise| itp_spear|itp_primary|itp_penalty_with_shield, itc_greatlance, 237 , weight(5)|difficulty(0)|spd_rtng(55) | weapon_length(100)|swing_damage(0 , cut) | thrust_damage(19 ,  pierce),imodbits_polearm ],
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on February 23, 2007, 06:34:04 pm
itc_greatlance is an item capability constant defined in header_items so you should put any itcf_XXXXXXXXXXX commands after it as I have done below.

["unimportantIDname", "Unimportant Name", [("unimportantmeshname",0)], itp_type_polearm|itp_merchandise| itp_spear|itp_primary|itp_penalty_with_shield, itc_greatlance|itcf_parry_forward_polearm|itcf_parry_up_polearm|itcf_parry_right_polearm|itcf_parry_left_polearm, 237 , weight(5)|difficulty(0)|spd_rtng(55) | weapon_length(100)|swing_damage(0 , cut) | thrust_damage(19 ,  pierce),imodbits_polearm ],

Alternatively if you don't want to mix and match at all you can use one of the predefined item capability constants for parrying from header_items:

itc_parry_two_handed  #this gives all the two handed parry possibilities
itc_parry_onehanded    #this gives all the one handed parry possibilities
itc_parry_polearm         #this gives all the polearm parry possibilities (this is the same as writing out everything in green above)

Hope that helps
Ahadhran
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 24, 2007, 08:26:33 am
I have trouble with a script which is turning up the wrong mathematical results.

Code: [Select]
("eval_party_morale_man",
    [
       
      (store_script_param_1,':party'),
      (assign,':morale',0),
      (assign,':manoeuvre',0),
      (party_get_num_companion_stacks,':stacknumber',':party'),
      (call_script,"script_party_count_fit_for_battle",':party'),
      (assign,':forcesize',reg0),
      (try_for_range,':currstack',0,':stacknumber'),
        (party_stack_get_troop_id,':troopid',':party',':currstack'),
        (party_stack_get_size,':troopnumber',':party',':currstack'),
        (party_stack_get_num_wounded,':wounded',':party',':currstack'),
        (store_sub,':troopnumber',':troopnumber',':wounded'),
        (try_begin),
          (troop_is_hero,':trooptype'),
          (assign,':moraleboost',0),
          (store_attribute_level,':moraleboost',':trooptype',ca_charisma),
          (store_mul,':moraleboost',':moraleboost',5),
          (store_add,':morale',':morale',':moraleboost'),
        (else_try),
          (assign,':moraleboost',0),
          (store_character_level,':moraleboost',':trooptype'),
          (store_mul,':moraleboost',':moraleboost',':troopnumber'),
          (store_add,':morale',':morale',':moraleboost'),
        (try_end),
      (try_end),
      (party_get_skill_level,':leadership',':party',skl_leadership),
      (store_mul,':morale',':morale',':leadership'),
      (store_div,':morale',':morale',10),
      (try_begin),
        (lt,':morale',':forcesize'),
        (assign,':morale',':forcesize'),
      (try_end),
      (try_for_range,':currstack',0,':stacknumber'),
        (party_stack_get_troop_id,':troopid',':party',':currstack'),
        (party_stack_get_size,':troopnumber',':party',':currstack'),
        (party_stack_get_num_wounded,':wounded',':party',':currstack'),
        (val_sub,':troopnumber',':wounded'),
        (try_for_range,':anyhorse',"itm_horses_begin","itm_horses_end"),
          (troop_has_item_equipped,':troopid',':anyhorse'),
          (store_skill_level,':troopman',skl_riding),
          (val_mul,':troopman',2),
          (val_mul,':troopman',':troopnumber'),
          (val_add,':manoeuvre',':troopman'),
        (else_try),
          (store_skill_level,':troopman',skl_athletics),
          (val_mul,':troopman',':troopnumber'),
          (val_add,':manoeuvre',':troopman'),
        (try_end),
      (try_end),
      (party_get_skill_level,':pathfinding',':party',skl_pathfinding),
      (val_mul,':pathfinding',2),
      (val_mul,':manoeuvre',':pathfinding'),
      (store_div,':avgmorale',':morale',':forcesize'),
      (val_mul,':manoeuvre',':avgmorale'),
      (val_div,':manoeuvre',5),
      (assign,'$temp_morale',':morale'),
      (assign,'$temp_manoeuvre',':manoeuvre'),

        ]),

Morale is about twice as high as it should be (except for a lone PC, when it is correct but irrelevant), whereas manoeuvre is also higher although I havn't found a pattern. The systematic use of the store_xxxx operations and the assigning to zero of the :moraleboost variable are my shot-in-the-dark attempts at debugging.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on February 24, 2007, 08:47:07 am
In the morale-calculations you never assign a value to the variable ":trooptype" before you start using it, so you'll get somewhat random numbers back when querying the troops level.

Your maneuver-calculations also have some problems (fairly sure that (try_for_range) (condition) (else_try) isn't going to do what you think, but even if it does you'll get too high numbers as each troop will be counted as an infantry-man (and adding his athletics to the total maneuver-value) once *for each horse he doesn't ride*.

My guess, is that you should replace your ":trooptype" references with ":troopid" (which you *do* read properly).

For the maneuver part, replace your "try_for_range, ":anyhorse" section with this
Code: [Select]
(assign,":mounted",0),
(try_for_range, ":anyhorse", "itm_horses_begin", "itm_horses_end"),
  (try_begin),
    (troop_has_item_equipped, ":troopid", ":anyhorse"),
    (assign,":mounted",1),
  (try_end),
(try_end),

(assign,":troopman", 0),
(try_begin),
  (eq,":mounted",1),
  (store_skill_level, ":troopman", skl_riding),
  (val_mul, ":troopman", 2),
(else_try),
  (store_skill_level, ":troopman", skl_athletics),
(try_end),
(val_mul,":troopman",":troopnumber"),
(val_add,":manoeuvre", ":troopman"),
Title: Re: M&B Scripting Q&A
Post by: Cirdan on February 24, 2007, 09:00:53 am
Thanks for the :trooptype error. That had me, litterally, laughing out loud. Here i've been looking around for all sorts of weird errors because I typed the wrong variable name :lol: .

For the second part--good catch about the unequipped horse types, and thanks for the solution.
Title: Re: M&B Scripting Q&A
Post by: ex_ottoyuhr on February 24, 2007, 06:09:12 pm
I've run into a serious bug with the very beginning of the siege system I'm (going to be) building for ASLOW. Basically, in order to have room for time to pass between "rounds" of a siege, I'm going to need to do the "Storymod style" of continuing scenes -- creating a party with the siege system as its encounter menu and capable of moving incredibly fast, and pointing it at the player. (I can go into more detail if you want, but I don't know how necessary it'll be for this question.)

The trouble is that the code I've created is crashing whenever I try to spawn the "siege daemon" party around the player's location, giving an RGL error of "get_object failed for: <blank>"...

The relevant source code is as follows:

(In module_simple_triggers:)
Quote
  (ti_on_party_encounter,
   [
       (store_encountered_party, "$g_encountered_party"),
       (store_encountered_party2,"$g_encountered_party_2"), # encountered_party2 is set when we come across a battle or siege, otherwise it's a minus value
       (assign, "$talk_context", 0),
       (assign,"$g_player_surrenders",0),
       (assign,"$g_enemy_surrenders",0),
       (assign, "$g_leave_encounter",0),
       (assign, "$new_encounter", 1), #check this in the menu.
       (try_begin),
         (lt, "$g_encountered_party_2",0), #Normal encounter. Not battle or siege.
         (try_begin),
<snip non-battle>
       (else_try), #Encountering a battle
         (try_begin),
           (is_between, "$g_encountered_party", towns_begin, towns_end),
           (try_begin),
             (eq, "$auto_enter_town", "$g_encountered_party"),
             (jump_to_menu, "mnu_town"),
      (else_try),
<Joining a siege:>
                (jump_to_menu,"mnu_start_siege"),
           (try_end),
         (else_try),
           (jump_to_menu, "mnu_pre_join"),
         (try_end),
       (try_end),
       (assign,"$auto_enter_town",0),
    ]),

(In module_game_menus: -- Note that there are a few 'leftover' assigns from earlier debugging, which I'll have to remove...)
Quote
  ("start_siege",0,
   "You arrive at the town of {s0}, which is besieged by {s1} (party {reg8} of fac {reg9}). What will you do?",
   "none",
   [
    (store_faction_of_party, "$fac1buf", "$g_encountered_party"),
   (store_faction_of_party, "$fac2buf", "$g_encountered_party_2"),
   (assign,"$siege_city","$g_encountered_party"),
   (str_store_party_name,0,"$g_encountered_party"),
   (str_store_faction_name,1,"$fac2buf"),
   (assign,reg(8 ),"$g_encountered_party_2"),
   (assign,reg(9),"$fac2buf"),
   (try_begin),
      (eq,"$fac2buf","fac_player_faction"),
      (str_store_string,1,"str_your_soldiers"),
   (try_end),
    (store_relation, "$town_rel_to_player","$fac1buf","fac_player_faction"),
   (store_relation, "$other_rel_to_player","$fac2buf","fac_player_faction"),
   ],
   [
      ("siege_help_defenders",
         [
         (ge,"$town_rel_to_player",0),
         (lt,"$other_rel_to_player",0),
         ],
         "Fight your way in and direct the defense.",
         [
         (assign,"$player_siege_state",sst_defending), # Stub
         (change_screen_return),
         ]),
      ("siege_help_attackers",
         [
         (ge,"$other_rel_to_player",1),
         (lt,"$town_rel_to_player",0),
         ],
         "Take command of the siege yourself.",
         [
         (assign,"$player_siege_state",sst_attacking),
         (assign,reg(6),"$g_encountered_party"),
         (assign,reg(7),"pt_siege_daemon"),
         (display_message,"str_regs6and7"),
         # This crashes.
         (spawn_around_party,reg(6),reg(7)),
         (change_screen_return),
         ]),
      ("siege_leave",[],"Stay out of the fighting.",
         [
         (assign,"$siege_city",0),
         (change_screen_return),
         ]),
   ]),

(In module_party_templates: -- Note that menu_siege is defined, but I haven't managed to pull it up yet...)
Quote
("siege_daemon",
   "siege_daemon",
   icon_gray_knight|pf_icon_mask|pf_auto_start_dialog|pf_no_label|pf_hide_defenders|pf_non_attackable,
   menu_siege,
   fac_commoners,
   merchant_personality,
   [(trp_speed_demon,1,1)]),

(In module_troops:)
Quote
  ["speed_demon","speed_demon","speed_demons",tf_male,0,reserved,fac_commoners,
   [itm_kantis,itm_footwear,itm_hunter],
   def_attrib|level(50),wp(50),knows_common|knows_riding_9|knows_pathfinding_9,0],

(I should probably have posted this much, much sooner than I have...)
Title: Re: M&B Scripting Q&A
Post by: bryce on February 24, 2007, 06:24:58 pm
Instead of having it run at you call (start_encounter, <party_id>)
I had to do what you are talking about back in .751 and it just doesn't work right in .808
Aside from that you can put them as a party in the parties file if they will always be the same.
Then you will know it is not the encounter code, anyhow.

It sounds like it may be some odd item issue or something, though.  Try spawning some other party as the first step and see if that works.  If not you know that's the issue.
Title: Re: M&B Scripting Q&A
Post by: ex_ottoyuhr on February 25, 2007, 10:33:33 pm
Where do you mean that I should use start_encounter? (Edit: not stat_encounter...) I didn't quite understand that part...

I'm about to try spawning a different party type, though; I'll let you know the results.

EDIT: Spawning worked correctly for another party type! You're right -- there's nothing in this code (a relief to learn; I should've tried this much sooner), it's a party or item issue. Thanks enormously for your help!
Title: Re: M&B Scripting Q&A
Post by: bryce on February 25, 2007, 11:46:58 pm
Just immediately spawn the party and then call (start_encounter, reg(0)), either from a menu or a trigger or even a conversation - so long as you are not in another ecounter already.
Title: Re: M&B Scripting Q&A
Post by: ex_ottoyuhr on February 26, 2007, 10:54:26 pm
Oh, OK. That'll make life a good bit easier, too...
Title: Re: M&B Scripting Q&A
Post by: Yoshiboy on February 28, 2007, 10:04:27 am
"get_object failed for: <blank>"...
is a missing mesh error no?  ???
Title: Re: M&B Scripting Q&A
Post by: bryce on February 28, 2007, 12:45:52 pm
"get_object failed for: <blank>"...
is a missing mesh error no?  ???

I don't think so.  I have gotten that a few times but I don't recall why.  Something code related but I can't for the life of me remember what this second.  I will try to recall....
Title: Re: M&B Scripting Q&A
Post by: Winter on February 28, 2007, 01:03:07 pm
"get_object failed for: <blank>"...
is a missing mesh error no?  ???

I don't think so.  I have gotten that a few times but I don't recall why.  Something code related but I can't for the life of me remember what this second.  I will try to recall....

That can be caused by empty strings in your code.

Stalkingly,
Winter
Title: Re: M&B Scripting Q&A
Post by: dannyboy on March 14, 2007, 04:56:25 pm
What am I doing wrong here? This should a simple script to tally up reputation gained by beating enemies, yet in-game it tends to stack spectacularly to 255 without any parties being destroyed at all...

(0.5, 0, 0.5, [], [(assign,"$kill_points",0),
     (store_num_parties_destroyed_by_player, ":river_pirates_rep", "pt_river_pirates"),
     (val_mul,":river_pirate_rep",2),
     (val_add,"$kill_points",":river_pirate_rep"),

     (store_num_parties_destroyed_by_player, ":devotees_rep", "pt_mountain_bandits"),
     (val_mul,":devotee_rep",1),
     (val_add,"$kill_points",":devotee_rep"),

     (store_num_parties_destroyed_by_player, ":possessed_knights_rep", "pt_forest_bandits"),
     (val_mul,":possessed_knights_rep",3),
     (val_add,"$kill_points",":possessed_knights_rep"),

     (store_num_parties_destroyed_by_player, ":demon_army_rep", "pt_dark_hunters"),
     (val_mul,":demon_army_rep",5),
     (val_add,"$kill_points",":demon_army_rep"),

     (store_num_parties_destroyed_by_player, ":minions_rep", "pt_minions"),
     (val_mul,":minions_rep",3),
     (val_add,"$kill_points",":minions_rep"),

     (store_num_parties_destroyed_by_player, ":cult_rep", "pt_sea_raiders"),
     (val_mul,":cult_rep",2),
     (val_add,"$kill_points",":cult_rep"),

     (store_num_parties_destroyed_by_player, ":demon_lord_rep", "pt_demon_lord"),
     (val_mul,":demon_lord_rep",3),
     (val_add,"$kill_points",":demon_lord_rep"),

     (store_num_parties_destroyed_by_player, ":terror_horde_rep", "pt_terror_horde"),
     (val_mul,":terror_horde_rep",10),
     (val_add,"$kill_points",":terror_horde_rep"),

     (store_num_parties_destroyed_by_player, ":hydra_rep", "pt_hydra"),
     (val_mul,":hydra_rep",10),
     (val_add,"$kill_points",":hydra_rep"),
     
     ]),




Should be a simple error due to my extreme inexperience. Thanks very much for whoever's time i'm using.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on March 14, 2007, 05:57:06 pm
Code: [Select]
(store_num_parties_destroyed_by_player, ":devotees_rep", "pt_mountain_bandits"),
     (val_mul,":devotee_rep",1),
     (val_add,"$kill_points",":devotee_rep"),
There's your problem right there... Look again... (Hint: ":devotees_rep" vs ":devotee_rep" :) ).
Title: Re: M&B Scripting Q&A
Post by: Leprechaun on March 25, 2007, 09:36:35 am
I've just heard about this ai_mask command from Cartread's Catacombs mod, and I'm wondering, can it be used in a scene so that until you get inside a certain radius of someone they do not attack?
Title: Re: M&B Scripting Q&A
Post by: Winter on March 25, 2007, 12:45:41 pm
I've just heard about this ai_mask command from Cartread's Catacombs mod, and I'm wondering, can it be used in a scene so that until you get inside a certain radius of someone they do not attack?

That can be done with simple agents code. Keep agents moving to the same entry point they spawned at. If player is within X distance, remove scripted mode.
Title: Re: M&B Scripting Q&A
Post by: Leprechaun on March 26, 2007, 03:18:43 pm
True, but what I'd like to know is what exactly does the command do?
Title: Re: M&B Scripting Q&A
Post by: Winter on March 27, 2007, 07:07:53 am
True, but what I'd like to know is what exactly does the command do?

I can't even find an "ai_mask" command in the module system. Maybe he means AI limiters, perhaps they block the vision of NPCs.

Totteringly,
Winter
Title: Re: M&B Scripting Q&A
Post by: Leprechaun on March 27, 2007, 09:58:16 am
Probably. I've asked Cartread about it and am awaiting his reply, because it said on the first post of Catacombs about ai_mask. I'm intrigued, so I'll get back to you with it.
Title: Re: M&B Scripting Q&A
Post by: Leprechaun on March 29, 2007, 09:45:37 am
AHA!


The monsters are ai_mask so they only notice you after you bust down their door.

What exactly does this command do? Does it suppress the combat AI until you get within a certain radius of the, or something? I'd love to know how it works.

I'm not exactly certain, but aif_group_bits & aif_group_mask (i didn't notice any differences) seem to keep a troop still until it "sees" (doesn't go through collision meshes, usually) an enemy troop, then it goes to alarmed.


That looks handy.
Title: Re: M&B Scripting Q&A
Post by: Nethros on April 02, 2007, 11:39:31 am
I've been getting this error while compiling:
(All the datas export perfectly except for items)
Code: [Select]
Exporting item data...
Traceback <most recent call last>:
  File  "process_items.py", line 59 in ?
    write_items<variables>
  File "process_items.py", line 27, in write items
    ofile.write(" %d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\n"%(item[3], item[4], item[5], item[7],
IndexError: list index out of range

What I remember doing was remove a few horses. (I had removed all references including triggers.)
Title: Re: M&B Scripting Q&A
Post by: Hellequin on April 02, 2007, 01:07:55 pm
That's a "this tuple has too many arguments" error, I think.  Try and isolate the section of your code it's in, and then skim counting commas.
Title: Re: M&B Scripting Q&A
Post by: Highlander on April 05, 2007, 11:23:25 am
Hi,
I'm pretty young, so I don't have had already all Mathematics basics in school.
Is there a elegant way to calculate a term like 18^0,3 in M&B?
Title: Re: M&B Scripting Q&A
Post by: Hellequin on April 05, 2007, 03:30:15 pm
Do you mean the cube root (power of 1/3) or an exact power (power of 0.3)?  Either way the answer is, not yet... but it's possible that there may exist a variant on the iterative algorithm Manitas found, which does square roots, which could get you that.  Dunno.
Title: Re: M&B Scripting Q&A
Post by: Highlander on April 05, 2007, 03:40:56 pm
0,3 was only an example for a decimal value. I wanted a half-life script to work.
You know,
(http://upload.wikimedia.org/math/1/e/e/1eed2b117ae1afe2f68f9457b5b8952c.png)
Thanks anyway.
Title: Re: M&B Scripting Q&A
Post by: Hellequin on April 05, 2007, 08:09:34 pm
Ah.  Well, this isn't obvious from the formula, but that's the continuous-curve behaviour which matches a really easy discrete (i.e. programmable using triggers) behaviour.  In fact, many potions in Schattenlander have that behaviour in their effects, with a varying time constant based on their quality, and a stochastic (aka probabilistic) drop rather than a strictly multiplicative one.

To get the behaviour you describe, just decay away X% of whatever quantity is currently present, on a regular schedule of increments of time T.  For instance, dropping something to 95% of its current value every 1s will have the behaviour you describe in the aggregate.  That'll be much, much easier to code than figuring out how to do a general nth-root script.  (If, for instance, you used X=50%, T=T1/2, you'd get exactly the rate/odds of your equation.  But you probably want a finer time scale so that it doesn't take 50% jumps, and I'm guessing you'll be tweaking the overall values anyway for gameplay.  If you do want an exact conversion of some real-world T1/2, let me know and I can help you figure it out.)
Title: Re: M&B Scripting Q&A
Post by: Highlander on April 06, 2007, 02:27:42 am
yeb, 50% steps are far too rude, I'll try something else.
Title: Re: M&B Scripting Q&A
Post by: Nethros on April 13, 2007, 05:42:20 am
That's a "this tuple has too many arguments" error, I think.  Try and isolate the section of your code it's in, and then skim counting commas.
I don't understand, what do you mean?

Code: [Select]
ofile.write(" %d %d %d %d %f %d %d %d %d %d %d %d %d %d %d %d %d\n"%(item[3], item[4], item[5], item[7],
                                                   get_weight(item[6]),
                                                   get_abundance(item[6]),                 
                                                   get_head_armor(item[6]),
                                                   get_body_armor(item[6]),
                                                   get_leg_armor(item[6]),
                                                   get_difficulty(item[6]),
                                                   get_hit_points(item[6]),
                                                   get_speed_rating(item[6]),
                                                   get_missile_speed(item[6]),
                                                   get_weapon_length(item[6]),
                                                   get_max_ammo(item[6]),
                                                   get_thrust_damage(item[6]),
                                                   get_swing_damage(item[6]),
                                                               ))
    trigger_list = []
    if (len(item) > 8):
      trigger_list = item[8]
    save_simple_triggers(ofile,trigger_list, variable_list)


  ofile.close()

print "Exporting item data..."
save_python_header()

from module_info import *

from process_common import *
from process_operations import *

variables = load_variables(export_dir)
write_items(variables)
save_variables(export_dir,variables)
#print "Finished with Items."


There's the code that's not working.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on April 13, 2007, 09:41:20 am
No-no, that's the code that tries to write the code that's not working. :)

Basically, that code expects an item-definition to contain a specific number of fields, and your item-code that it's trying to handle doesn't contain the required number of fields (either too few or too many).
So, double-check the item-code it complains about and make sure you have the necessary number of fields in it.
Title: Re: M&B Scripting Q&A
Post by: Nethros on April 14, 2007, 02:38:58 am
The problem is, it doesn't say what item it's complaining about.
Title: Re: M&B Scripting Q&A
Post by: aGorilla on April 18, 2007, 06:48:09 pm
What does it take for you to get the following message (re: random governer's quests)?
  "I am afraid I wasn't able to come up with a mission for you."

I'm assuming it only comes up when you already have too many missions - ie: the # of attempts to come up with a mission you don't already have has been exceeded.

Am I right?
Title: Re: M&B Scripting Q&A
Post by: Neophyte on April 19, 2007, 09:34:48 am
It can actually happen in many more situations than that, but it's random.
Basically, when you ask for a quest the guy picks a random one from a list to give to you, and then pick some random town to deliver the message to, random troop to recruit, whatever.
And if this combination comes up as "no good", then he will default to "Nope, sorry, no mission".

For instance, if the random quest is picked as "deliver_message" quest (run to noble in town X and deliver message), he will pick a random friendly town to deliver the message to. But that random pick could come up as the town you're already in, in which case the combination is "no good", and he ends up not giving you a mission.
Title: Re: M&B Scripting Q&A
Post by: aGorilla on April 19, 2007, 04:48:42 pm
Thanks much.  Hadn't thought about the possibility of 'invalid' missions.
Title: Re: M&B Scripting Q&A
Post by: Lagnar on April 22, 2007, 05:54:40 am
I just have a quick question to ask about a problem I have

The problem is that whenever I try to run Pirates, it comes up with a error saying "get_object failed for 5". Before this happened I have a problem with two of the beards, I fixed that by getting rid of beards through the word skins document, but im unsure how to fix this problem.

This most likely has been discussed before but I cant seem to find those topics/posts.

All help is appreciated as I would like to play pirates as soon as possible.
Title: Re: M&B Scripting Q&A
Post by: Nethros on April 23, 2007, 08:06:14 pm
You can't play the Pirates mod on 0.808. You have to get 0.751.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on April 24, 2007, 05:43:27 pm
I've set up a basic siege system for Onin no Ran, and it works well enough. In the event of a capture of a town by a faction, I'd like for the town's patrol (if out patrolling) to return to the town and attempt to recapture the town. I know that this works in Native with the Castles (they change factions regularly), but looking through the code didn't help much. Is there something special about towns/castles that makes them immune to normal encounter/combat routines? If someone could point me in the right direction, I'd be very appreciative.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on April 24, 2007, 07:31:35 pm
The only specific thing I know of is the pf_hide_defenders flag which is set for towns but not for any other party. Then again, I haven't mucked about with anything like a siege-system, so that probably doesn't mean much.
Title: Re: M&B Scripting Q&A
Post by: ex_ottoyuhr on April 24, 2007, 11:04:46 pm
I've set up a basic siege system for Onin no Ran, and it works well enough. In the event of a capture of a town by a faction, I'd like for the town's patrol (if out patrolling) to return to the town and attempt to recapture the town. I know that this works in Native with the Castles (they change factions regularly), but looking through the code didn't help much.

The obvious way to do this -- assuming that each town only gets one patrol -- is to create a slot for the town's patrol, and call a script on town conquest that will send its patrol back to attack it; see my further statements below.

Quote
Is there something special about towns/castles that makes them immune to normal encounter/combat routines? If someone could point me in the right direction, I'd be very appreciative.

Yes and no. Towns can be attacked like anything else, but I don't *think* that the AI of random parties will ordinarily try to attack them (and I don't especially care to find out, if it will :)) -- you have to specifically order the party to ai_bhvr_attack_party (used to be _track_party), and they'll go over to "Following Wherever" and will begin fighting when they arrive.

Be warned that once they have arrived they will stay fighting -- you need a trigger (ASLOW's fires hourly [edit: and this still leads to the occasional strange behavior; half an hour might be more appropriate]) to check for any cities that have been taken over, and process them appropriately.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on April 25, 2007, 11:26:07 am
Thanks, this is good stuff. I figured regarding the out-and-about patrol (those slots are already set up).

Is there any obvious indication that a town has been taken over? Or just a trigger to check if the town's garrison has dropped to zero (and the attacker has at least one guy left)?
Title: Re: M&B Scripting Q&A
Post by: Winter on April 25, 2007, 01:23:47 pm
Thanks, this is good stuff. I figured regarding the out-and-about patrol (those slots are already set up).

Is there any obvious indication that a town has been taken over? Or just a trigger to check if the town's garrison has dropped to zero (and the attacker has at least one guy left)?

How about checking the faction of the patrol party against the faction of the town?
Title: Re: M&B Scripting Q&A
Post by: fujiwara on April 25, 2007, 08:19:54 pm
Winter, I thought that too. I wrote a trigger to artificially send an enemy patrol against a town, just to watch what happens. Didn't know about the 'Siege' label, which is cool. ottoyuhr is right; they do keep fighting after the defender strength has dropped to zero. I wrote a couple scripts to check for towns under siege. I'd like a second (or third) set of eyes to see if any optimization can be done, or if not, this can be donated to the script repository. The faction_enemies script can be implemented in any number of ways. With the slot_town_under_siege flag, it would be trivial to check for number of defenders, and lots of other goodies.

Code: [Select]
  ('check_city_under_siege',
   [
       (try_for_parties,':attacker'),                                                                   # Loop through all the parties
           (store_faction_of_party,':attacker_faction',':attacker'),                             # get the party's faction
           (party_is_in_any_town,':attacker'),                                                     # Is the party in a town?
           (get_party_ai_object,':defender',':attacker'),                                       # If so, get the town
           (store_faction_of_party,':defender_faction',':defender'),                       # get the town's faction
           (call_script,'script_faction_enemies',':attacker_faction',':defender_faction'), # check to see if the factions are enemies
           (eq,reg0,1),                                                                                    # If true
           (assign,':under_siege',1),                                                                   # set siege flag to true
       (try_end),
       (try_begin),
           (eq,':under_siege',1),                                                                       # if siege flag is true
           (party_set_slot,':defender',slot_town_under_siege,1),                          # set slot flag to true
       (else_try),
           (party_set_slot,':defender',slot_town_under_siege,0),                          # else, set slot flag to false
       (try_end),
       ]
   ),
  ('faction_enemies',
   [
       (store_script_param_1,':fac1'),
       (store_script_param_2,':fac2'),
       (store_relations,':relations',':fac1',':fac2'),
       (try_begin),
           (lt,':relations',0),
           (assign,reg0,1),
       (else_try),
           (assign,reg0,0),
       (try_end),
       ]
   ),

Title: Re: M&B Scripting Q&A
Post by: Winter on April 26, 2007, 12:17:05 am
Winter, I thought that too. I wrote a trigger to artificially send an enemy patrol against a town, just to watch what happens. Didn't know about the 'Siege' label, which is cool. ottoyuhr is right; they do keep fighting after the defender strength has dropped to zero. I wrote a couple scripts to check for towns under siege. I'd like a second (or third) set of eyes to see if any optimization can be done, or if not, this can be donated to the script repository. The faction_enemies script can be implemented in any number of ways. With the slot_town_under_siege flag, it would be trivial to check for number of defenders, and lots of other goodies.

With that script, you're also going to end up grabbing caravans and prisoner trains that are temporarily staying at the town.

I'm not sure if this is quite the way it works, but you could try iterating over the town's attached parties instead. If it works the way I think it does, it should be a whole lot more efficient than try_for_parties. Just make sure you put in checks to exclude caravan and prisoner train templates.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on April 26, 2007, 03:22:57 am
How about rather than keeping track of towns under siege you keep track of parties attacking towns?
That way you can be absolutely sure you're not including non-besieging parties hanging out in towns.

You could, for instance, use some variation of the array-scripts you and I have discussed previously.
I say "some variation" because you don't really need random access to values in the array, you only ever need to add values, remove them, and loop through them.
And in fact, I think I have just the thing: The Set:
Code: [Select]
# Constants
set_first_index = 10
set_last_index = 200
set_park_index = 0
slot_set_index = 1

# The set party-template
("set_template", "Set Template", pf_disabled, 0, fac_commoners, 0, []),

# Strings for displaying set-related messages
("empty_set", "Set {reg10} is empty."),
("set_value", "Set {reg10}, index {reg11}: {reg12}"),

# Scripts
("set_add",
 [
  (store_script_param_1, ":set_id"),
  (store_script_param_2, ":value"),

  (party_get_slot, ":index", ":set_id", slot_set_index),

  (try_begin),
   (eq, ":index", set_park_index),  # Is set empty?
   (party_set_slot, ":set_id", set_first_index, ":value"), # Add value at front
   (assign, ":index", set_first_index),
   (val_add, ":index", 1),
  (else_try),
   (neq, ":index", set_last_index), # Is set non-full
   (party_set_slot, ":set_id", ":index", ":value"),
   (val_add, ":index", 1),
  (try_end),

  (party_set_slot, ":set_id", slot_set_index, ":index"), # Update index-slot
 ]
),

("set_create",
 [
  # Spawn "set" party, and store the id
  (set_spawn_radius,0),
  (spawn_around_party, "p_zendar","pt_set_template"),
  (assign, ":set_id", reg0),

  # Initialize set slots
  (party_set_slot, ":set_id", slot_set_index, set_park_index),

  # Make sure reg0 contains set-id
  (assign,reg0,":set_id"),
 ]
),

("set_remove",
 [
  (store_script_param_1, ":set_id"),
  (store_script_param_2, ":value"),

  (party_get_slot, ":index", ":set_id", slot_set_index),

  # Return if set is empty
  (neq|eq, ":index", set_park_index),

  (assign, ":found", 0),
  (store_sub, ":last_value_index", ":index", 1), # last_value_index = index - 1
  (party_get_slot, ":last_value", ":set_id", ":last_value_index"),

  (try_for_range, ":idx", set_first_index, ":index"),
   # Make doubly sure that we haven't already found the value
   (eq, ":found", 0),
   (party_slot_eq, ":set_id", ":idx", ":value"),
   # Found the value to remove at index ":idx"
   (assign, ":found", 1),
   (try_begin),
    (neq|eq, ":idx", ":last_value_index"),
    # If the value is not the last value in the set
    # Then exchange the value at ":idx" with the last
    # value in the set, and remove last value
    (party_set_slot, ":set_id", ":idx", ":last_value"),
    (val_sub, ":index", 1),
   (else_try),
    # If the value is the last value in the set
    # Then simply remove the last value
    (val_sub, ":index", 1),
   (try_end),
   # Break out of the for-loop
   (assign, ":index", ":idx"),
  (try_end),
 ]
),

("set_print",
 [
  (store_script_param_1, ":set_id"),

  (party_get_slot, ":index", slot_set_index),

  (assign, reg(10), ":set_id"),

  (try_begin),
   (eq, ":index", set_park_index),
   (display_message, "string_empty_set"),
  (else_try),
   (try_for_range, ":idx", set_first_index, ":index"),
    (party_get_slot, ":value", ":set_id", ":idx"),
    (assign, reg(11), ":value"),
    (display_message, "string_set_value"),
   (try_end),
  (try_end),
 ]
),

Just add the party-id to a set you create at startup whenever they go besieging, and remove them when they stop. And your trigger checking for active sieges can just loop through that set to see who's besieging what, etc.

At least that would be my suggestion, but YMMV.
Title: Re: M&B Scripting Q&A
Post by: Winter on April 26, 2007, 04:07:58 am
How about rather than keeping track of towns under siege you keep track of parties attacking towns?
That way you can be absolutely sure you're not including non-besieging parties hanging out in towns.

Just add the party-id to a set you create at startup whenever they go besieging, and remove them when they stop. And your trigger checking for active sieges can just loop through that set to see who's besieging what, etc.

At least that would be my suggestion, but YMMV.

That may not be possible, as there's no kind of operation that can be called when a party attacks another one on the map. With custom siege scripts like mine, then it's possible, but even then it's a problem because sieging parties can die. The party_is_alive operation is unreliable and any scripts using it can end up screwing up your array.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on April 26, 2007, 04:46:10 am
To clarify what I meant, I was suggesting adding the besiegers to the set when they decide to go besiege a town, not when they actually started the siege proper, and using party_is_in_town on those to figure out when the sieges themself start.

As for party_is_active (I assume that's what you mean when you say party_is_alive, as I can't find any operation by that name), I wasn't aware of any unreliability with it, but that definitely adds a little curve-ball...
I guess a combination of party_get_num_companion_stacks, party_stack_get_size and party_stack_get_num_wounded would work as a replacement, although it's hardly elegant. store_party_size_wo_prisoners might work as well, if it doesn't return wounded party-members, at least.


Title: Re: M&B Scripting Q&A
Post by: fujiwara on April 26, 2007, 02:33:10 pm
Neophyte
I like it. So if I understand you correctly, I would need to have a trigger that loops through all the active parties and checks for 1) behavior = ai_bhvr_attack_party (since that's the only way I know of to get an AI to besiege a town), and 2) target (get_party_ai_object) that equals one of the towns. If both are true, add to the besieger_set, then loop through that to check for an actual siege (party_is_in_town,':target'), strength of attackers and defenders, etc. Very interesting indeed.

BTW, the arrays work like a champ. There's a good deal I've been able to do with them that otherwise would have been difficult, a horrible kludge, or just not possible. Thanks for planting the seed.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on April 26, 2007, 03:55:22 pm
I wouldn't think you'd need to loop through your parties to see if they have the ai_bhvr_attack_party behavior. After all, some piece of your code sets the partys behaviour to be that in the first place, in order to besiege a city, right?
Unless you're randomly picking targets in a manner that makes it hard to figure out exactly when your code gives the order for a party to besiege a city, you can just add it to the set when that decision is made.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on April 27, 2007, 05:47:53 am
You're right, that is true. The reason for the first loop is this: in addition to besieging towns, I'm setting up a system of outposts that the player constructs. These by necessity are party_templates and are not set to is_static so that the player (or AI) has the chance to either take over an enemy outpost or raze it. I've made some modifications to the simulate_battle simple trigger to allow for either AI choice, but haven't progressed enough to be able to test it.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on May 19, 2007, 10:59:56 am
First problem I've encountered: party_is_in_town isn't being triggered when an attacking party lays siege to a town. Consider the following:

Code: [Select]
(6.0, 0, ti_once,[],
     [
         (set_spawn_radius,0),
         (spawn_around_party,hikami,'pt_yamana_war_party'),
         (assign,'$besieger2',reg0),
         (party_set_ai_behavior,'$besieger2',ai_bhvr_attack_party),
         (party_set_ai_object,'$besieger2',ikuno),
         (party_set_slot,ikuno,slot_town_siege_attacker,'$besieger2'),
         (display_message,'str_war_party_spawned'),
         ]
     ),

(0.0, 0, ti_once, [(party_is_in_town,ikuno,'$besieger2')],
     [
         (display_message,'str_siege_test_1'),
         ]
     ),

The first trigger works fine, spawning the war party and assigning it to $besieger2. The spawn then merrily goes on its way to ikuno. But, when it gets to Ikuno and begins sieging the town, the second trigger does not fire. I'm assuming that this is because the war party really isn't in town? How else have other's handled this? Would a combination of store_distance_from_party_to_party and checking for < 1 do the trick? THANKS!

Also, has anyone ever tried to use a try_for_range loop in the conditions block of a trigger?
Title: Re: M&B Scripting Q&A
Post by: Fisheye on May 19, 2007, 11:50:30 am
I recall winter saying "party_is_in_town" doesn't work. So what you suggested would work.

Anything is ok inside a conditions block, I think.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on May 19, 2007, 12:46:19 pm
My test confirmed the store_distance_to_party_from_party method. Funny, party_is_in_town has worked in other situations for me.  Thanks, Fisheye.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on May 19, 2007, 01:00:11 pm
I've never had any problems with party_is_in_town, but then I've never put someone to attack a town rather than just move there.

My guess on the behaviour we're seeing here is, as Fuji mentioned a couple of posts ago, that when the ai behaviour is set to attack a town it never actually enters it, and that that's what party_is_in_town actually checks for.

How about initially setting the behavior to moving to the target city, which would hopefully cause it to "enter" it when it arrives (so you should be able to use party_is_in_town to check for arrival); and then when it arrives set the behavior to attack instead (when you already know it has arrived).

Title: Re: M&B Scripting Q&A
Post by: DarthLlama226 on May 19, 2007, 01:46:35 pm
How can you change what attacks are availible for a weapon without python or the unofficial editor?
Title: Re: M&B Scripting Q&A
Post by: nema on May 21, 2007, 05:22:44 am
How can you change what attacks are available for a weapon without python or the unofficial editor?

It is possible directly in item_kinds1.txt files, but you are limited with existing attacks sets from other weapons.


They are hiding, with many other informations in these numbers:

itm_lighting_staff staff_of_light staff_of_light 1  light_staff 0  541097988 9227874537204355071  90000 0 5.500000 100 0 0 0 0 16384 110 0 150 0 500 500
0   (for 0.751 wear)

 itm_sword_of_war Sword_of_War Sword_of_War 2  b_bastard_sword 0  scab_bastardsw_b 3458764513820540928  6356995 9223635958660858096 524 532 3.000000 100 0 0 0 11 16384 65 0 130 0 49 80
0  (for 0.808 wear)

I don't believe that you can change this non decimal numbers without python or unofficial editor and get something useful.


rather try with pythone:

["sword_of_war", "Sword of War", [("b_bastard_sword",0),("scab_bastardsw_b", ixmesh_carry)], itp_type_two_handed_wpn|itp_merchandise| itp_two_handed|itp_primary, itc_greatsword|itcf_carry_sword_back|itcf_show_holster_when_drawn, 524 , weight(3)|difficulty(11)|spd_rtng(93) | weapon_length(130)|swing_damage(35 , cut) | thrust_damage(28 ,  pierce),imodbits_sword ],

For meaning and other possibilities check in header_items.py:

itc_greatsword = itc_cut_two_handed |  itcf_thrust_twohanded | itc_parry_two_handed
Title: Re: M&B Scripting Q&A
Post by: fujiwara on May 22, 2007, 11:30:02 am
I've never had any problems with party_is_in_town, but then I've never put someone to attack a town rather than just move there.

My guess on the behaviour we're seeing here is, as Fuji mentioned a couple of posts ago, that when the ai behaviour is set to attack a town it never actually enters it, and that that's what party_is_in_town actually checks for.

How about initially setting the behavior to moving to the target city, which would hopefully cause it to "enter" it when it arrives (so you should be able to use party_is_in_town to check for arrival); and then when it arrives set the behavior to attack instead (when you already know it has arrived).

The party_is_in_town behavior seems borne out in some other observations, since when a party actually enters a town it disappears from the map, while a party laying siege to a town is visible. The store_distance_to_party_from_party method seems to work smoothly with the logical test set to < 1, which makes sense, since you don't actually enter the town when you lay siege to it, unless the attacker possesses a huge advantage.

The travel_to_party idea is interesting, but I have to wonder if once party_is_in_town, you can change the behavior. I'd have to test that.
Title: Re: M&B Scripting Q&A
Post by: Neophyte on May 22, 2007, 02:32:46 pm
Thinking about it I suspect you may have to re-spawn the party near the target town after it has entered, so store_distance_to_party may end up being a better way to go.
Title: Re: M&B Scripting Q&A
Post by: Raz on June 16, 2007, 01:55:42 am
I've got myself 2 issues. First of all, in Mission Templates: Troops are supposed to follow the next waypoint when they're within 50 cm of the current one. However, they only follow the first and second. I'm guessing I did something wrong with the tries, and try ends? The 8 entry points they should follow range from 11 to 18, but I've just numbered them with 1 - 8.

Quote
    (3, 0, 0, [],
       [
           (get_player_agent_no, ":player_agent_no"),
           (entry_point_get_position,1,11),(entry_point_get_position,5,15),
           (entry_point_get_position,2,12),(entry_point_get_position,6,16),
           (entry_point_get_position,3,13),(entry_point_get_position,7,17),
           (entry_point_get_position,4,14),(entry_point_get_position,8,18),
           (try_for_agents,":agents"),
             (neq, ":agents", ":player_agent_no"),
             (agent_is_alive, ":agents"),
             (agent_is_human, ":agents"),
             (neg|agent_is_defender, ":agents"),
          (agent_set_scripted_destination,":agents",1),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",1,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",2),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",2,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",3),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",3,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",4),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",4,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",5),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",5,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",6),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",6,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",7),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",7,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",8),
          (agent_get_position,35,":agents"),
          (get_distance_between_positions,":agent_destination_distance",8,35),
         (try_begin),
          (lt, ":agent_destination_distance", 50),
          (agent_clear_scripted_mode,":agents"),
           (try_end),
           (try_end),
          (try_end),
         (try_end),
         (try_end),
        (try_end),
       (try_end),
      (try_end),
        ]),


My other problem would be concerning a troop not showing up on a scene. The barracks get chosen according to what faction the town is.

Quote from: game_menus
      ("town_barracks",
       [(party_slot_eq,"$current_town",slot_party_type, spt_town),(store_faction_of_party, "$current_town_faction", "$current_town"),(faction_get_slot, "$current_town_barracks", "$current_town_faction",slot_faction_barracks)],
       "Enter the barracks.",
       [
             (set_jump_mission,"mt_town_default"),
             (jump_to_scene,"$current_town_barracks"),
             (change_screen_mission),
        ],"Door to the barracks."),

However, the first one, "Jerusalem_barrackskeeper" doesn't show up at all while the other 2 do. The entry # and scene name are both correct. The only thing that differs is that I've also linked to the jerusalem barracks scene seperately in another game menu. I really can't figure out what's wrong here or what it could be.
Quote
  ["jerusalem_barrackskeeper","Barrackskeeper","Barrackskeeper", tf_hero|tf_guarantee_gloves|tf_guarantee_ranged|tf_guarantee_horse|tf_guarantee_armor|tf_guarantee_boots|tf_guarantee_helmet|tf_guarantee_shield, scn_jerusalem_barracks|entry(9),0, fac_jerusalem,[itm_jerusalem_knight_mail1,itm_leather_boots, itm_mail_coif, itm_mail_mittens, itm_tiberias],def_attrib|level(20),wp(20),knows_common|knows_athletics_3|ca_strength, 0x00000000000c114501e36db6db6db6db],
  ["ayyubid_barrackskeeper","Barrackskeeper","Turegor",tf_hero|tf_undead|tf_guarantee_gloves|tf_guarantee_ranged|tf_guarantee_horse|tf_guarantee_armor|tf_guarantee_boots|tf_guarantee_helmet|tf_guarantee_shield,scn_ayyubid_barracks|entry(9),0, fac_ayyubids,[itm_islamic_mail_hauberk1,itm_leather_boots, itm_leather_gloves, itm_light_ghulam_helmet1],def_attrib|level(20),wp(20),knows_common|knows_athletics_3, 0x00000000000c218701e351450caad563],
  ["seljuk_barrackskeeper","Barrackskeeper","Matheas", tf_hero|tf_undead|tf_guarantee_gloves|tf_guarantee_ranged|tf_guarantee_horse|tf_guarantee_armor|tf_guarantee_boots|tf_guarantee_helmet|tf_guarantee_shield, scn_seljuk_barracks|entry(9),0, fac_seljuks,[itm_islamic_mail_hauberk3,itm_leather_boots, itm_leather_gloves, itm_light_ghulam_helmet3],def_attrib|level(20),wp(20),knows_common|knows_athletics_3, 0x00000000000c529201c36db6db6db6db],
Title: Re: M&B Scripting Q&A
Post by: Highlander on June 16, 2007, 03:49:42 am
1)
When the distance between position 2 and the agent is not less than 50, it won't even check the other tries.
this should work:
Code: [Select]

    (3, 0, 0, [],
       [
           (get_player_agent_no, ":player_agent_no"),
           (entry_point_get_position,1,11),(entry_point_get_position,5,15),
           (entry_point_get_position,2,12),(entry_point_get_position,6,16),
           (entry_point_get_position,3,13),(entry_point_get_position,7,17),
           (entry_point_get_position,4,14),(entry_point_get_position,8,18),
           (try_for_agents,":agents"),
             (neq, ":agents", ":player_agent_no"),
             (agent_is_alive, ":agents"),
             (agent_is_human, ":agents"),
             (neg|agent_is_defender, ":agents"),
          (agent_set_scripted_destination,":agents",1),
          (agent_get_position,35,":agents"),
         (try_begin),
          (get_distance_between_positions,":agent_destination_distance",1,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",2),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",2,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",3),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",3,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",4),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",4,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",5),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",5,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",6),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",6,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",7),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",7,35),
          (lt, ":agent_destination_distance", 50),
          (agent_set_scripted_destination,":agents",8),
          (agent_get_position,35,":agents"),
         (else_try),
          (get_distance_between_positions,":agent_destination_distance",8,35),
          (lt, ":agent_destination_distance", 50),
          (agent_clear_scripted_mode,":agents"),
           (try_end),
           (try_end),
        ]),
Title: Re: M&B Scripting Q&A
Post by: DarkAnd on June 19, 2007, 11:54:40 am
how i make a scene props to move?
i used this code


Code: [Select]
  ("siege_tower",0,"tower","bo_tower", [
      (ti_on_init_scene_prop,[
           (assign,"$tower",0),
           (store_trigger_param_1, reg59),    ]),
   ]),

Code: [Select]
    ("tower",
   [
           (prop_instance_get_starting_position, 1, reg59),
           (prop_instance_get_position, 120, reg59),
           (prop_instance_animate_to_position, reg59, 1, 6000), #animate to position 1 in 55.5 second
]),

Code: [Select]
    "visit_town_horseback",0,-1,
    "You enter the area",
    [(0,mtef_scene_source|mtef_team_1,0,0,1,[]),
     (1,mtef_scene_source|mtef_team_1,0,0,1,[]),(2,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),(3,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),(4,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),(5,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),(6,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),(7,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),
     (8,mtef_scene_source,af_override_horse,0,1,[]),
     (9,mtef_scene_source,af_override_horse,0,1,[]),(10,mtef_scene_source,af_override_horse,0,1,[]),(11,mtef_scene_source,af_override_horse,0,1,[]),(12,mtef_scene_source,af_override_horse,0,1,[]),(13,mtef_scene_source,0,0,1,[]),(14,mtef_scene_source,0,0,1,[]),(15,mtef_scene_source,0,0,1,[]),(16,mtef_scene_source,0,0,1,[]),
     (17,mtef_scene_source,af_override_horse,0,1,[]),(18,mtef_scene_source,af_override_horse,0,1,[]),(19,mtef_scene_source,af_override_horse,0,1,[]),(20,mtef_scene_source,af_override_horse,0,1,[]),(21,mtef_scene_source,af_override_horse,0,1,[]),(22,mtef_scene_source,af_override_horse,0,1,[]),(23,mtef_scene_source,af_override_horse,0,1,[]),(24,mtef_scene_source,af_override_horse,0,1,[]),
     (25,mtef_visitor_source,af_override_horse,0,1,[]),(26,mtef_visitor_source,af_override_horse,0,1,[]),(27,mtef_visitor_source,af_override_horse,0,1,[]),(28,mtef_visitor_source,af_override_horse,0,1,[]),(29,mtef_visitor_source,af_override_horse,0,1,[]),(30,mtef_visitor_source,af_override_horse,0,1,[]),(31,mtef_visitor_source,af_override_horse,0,1,[])
     ],
    [
      (ti_inventory_key_pressed, 0, 0, [(eq,"$tower",0),(assign,"$tower",1),(call_script,"script_tower")], []),
      (ti_tab_pressed, 0, 0, [(set_trigger_result,1)], []),
     ],
  ),

but nothing hapens

I also tried

    ("tower",
   [
           (prop_instance_get_starting_position, 1, reg59),
           (position_move_x, 1, 190),
           (prop_instance_animate_to_position, reg59, 1, 6000), #animate to position 1 in 55.5 second
Title: Re: M&B Scripting Q&A
Post by: bryce on July 01, 2007, 10:25:44 pm
Ok, this is a crosspost. I read at some point of a way to disable troops so if you get within a certain distance (or any other arbitrary thing in a trigger) they suddenly become aware and attack. Anyone know of this method???

It seemed easy and simple at the time, like setting some bits, but I can't for the life of me think what it was or find it in the heards.
Title: Re: M&B Scripting Q&A
Post by: Winter on July 02, 2007, 04:36:46 pm
Ok, this is a crosspost. I read at some point of a way to disable troops so if you get within a certain distance (or any other arbitrary thing in a trigger) they suddenly become aware and attack. Anyone know of this method???

It seemed easy and simple at the time, like setting some bits, but I can't for the life of me think what it was or find it in the heards.

The easiest way is to send the AI troops to their spawn entry points and then clearing their scripted behaviour when the player gets within X distance.

Regards,
Winter
Title: Re: M&B Scripting Q&A
Post by: bryce on July 02, 2007, 10:10:03 pm
Ok, this is a crosspost. I read at some point of a way to disable troops so if you get within a certain distance (or any other arbitrary thing in a trigger) they suddenly become aware and attack. Anyone know of this method???

It seemed easy and simple at the time, like setting some bits, but I can't for the life of me think what it was or find it in the heards.

The easiest way is to send the AI troops to their spawn entry points and then clearing their scripted behaviour when the player gets within X distance.

Regards,
Winter

Thanks, Winter. I see to have some problems.

I call a script like thus:

("hold_positions",[

(display_message, '_calling hold positions...._'),

(entry_point_get_position,3,20),


(try_for_agents,":current_agent"),

(agent_set_scripted_destination,":current_agent",3),


(try_end),

and nothing happens. Any idea?

Do I have to do anything with the mission template?



]),
Title: Re: M&B Scripting Q&A
Post by: Winter on July 03, 2007, 12:43:08 pm
Thanks, Winter. I see to have some problems.

I call a script like thus:

("hold_positions",[

(display_message, '_calling hold positions...._'),

(entry_point_get_position,3,20),


(try_for_agents,":current_agent"),

(agent_set_scripted_destination,":current_agent",3),


(try_end),

and nothing happens. Any idea?

Do I have to do anything with the mission template?

When exactly are you calling it?
Title: Re: M&B Scripting Q&A
Post by: bryce on July 03, 2007, 01:37:23 pm
Thanks, Winter. I see to have some problems.

I call a script like thus:

("hold_positions",[

(display_message, '_calling hold positions...._'),

(entry_point_get_position,3,20),


(try_for_agents,":current_agent"),

(agent_set_scripted_destination,":current_agent",3),


(try_end),

and nothing happens. Any idea?

Do I have to do anything with the mission template?

When exactly are you calling it?

I call it on a trigger every .7 seconds from within the mission template. I know it gets called, but nothing seems to happen :(
Title: Re: M&B Scripting Q&A
Post by: Winter on July 05, 2007, 01:44:43 pm
I call it on a trigger every .7 seconds from within the mission template. I know it gets called, but nothing seems to happen :(

I'm assuming the problem is that everyone is standing still. That would happen if you're calling it in a mission template where no enemies are present. In order for any agent to move, it needs to have a hostile in the same scene. Arrange this in the mission template with a hostile visitor spawned at a position of your choosing, hidden and boxed in with barrier scene props.

It's possible to make particular NPCs move or stay still as you choose. Look at the Craftmod patrolling-NPCs mission template for an example of how it's done.
Title: Re: M&B Scripting Q&A
Post by: bryce on July 05, 2007, 02:09:22 pm
I call it on a trigger every .7 seconds from within the mission template. I know it gets called, but nothing seems to happen :(

I'm assuming the problem is that everyone is standing still. That would happen if you're calling it in a mission template where no enemies are present. In order for any agent to move, it needs to have a hostile in the same scene. Arrange this in the mission template with a hostile visitor spawned at a position of your choosing, hidden and boxed in with barrier scene props.

It's possible to make particular NPCs move or stay still as you choose. Look at the Craftmod patrolling-NPCs mission template for an example of how it's done.

Maybe I will look in the source.

It's the enemies I am trying to get to move. Is that the problem?

Actually, none of my side will move either.

It seems I am doing everything right. I mean, it is pretty simple to do the basic case. So, I don't see how this can be happening.
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on July 06, 2007, 06:23:33 pm
I am having a problem with a script I wrote which checks the player's and the opponents skill level in spotting and tactics when the battle choice menu comes up with the options to; charge, leave, surrender...ect. The difference is I am adding more options than just charge at default battle size. All the battle stuff works fine however, the problem is getting the right value for the skills of the enemy party. The script is below:
Quote
("get_tactical_status",
  [
  #find the enemies tactical abilities
   (store_encountered_party,":party"),
   (party_get_skill_level,":tactics",":party",9),
   (party_get_skill_level,":spotting",":party",7),
   (store_add,":enemy_tactic_advantage",":tactics",":spotting"),
   #error checking display
   (assign,reg0,":spotting"),
   (assign,reg1,":tactics"),
   (display_message,"str_enemy_spotting",0x3300ff),
   (display_message,"str_enemy_tactics",0x3300ff),
  #find players tactical abilities   
   (party_get_skill_level,":tactics","p_main_party",9),
   (party_get_skill_level,":spotting","p_main_party",7),
   (store_add,":player_tactic_advantage",":tactics",":spotting"),
    #error checking display
   (assign,reg2,":spotting"),
   (assign,reg3,":tactics"),
   (display_message,"str_player_spotting",0x3300ff),
   (display_message,"str_player_tactics",0x3300ff),
  #find the tactical advantage based on numbers
   (store_party_size_wo_prisoners,":enemy_party_size",":party"),
   (store_party_size_wo_prisoners,":player_party_size","p_main_party"),
   (store_sub,":party_difference",":player_party_size",":enemy_party_size"),
   (store_div,":tactical_size_mod",":party_difference",10),
   #error checking display
   (assign,reg4,":tactical_size_mod"),
   (display_message,"str_tactical_size_mod",0x3300ff),
  #calculate the players tactical status
   (store_sub,"$tactical_status",":player_tactic_advantage",":enemy_tactic_advantage"),
   (val_add,"$tactical_status",":tactical_size_mod"),
   #error checking display
   (assign,reg5,"$tactical_status"),
   (display_message,"str_tactical_status",0x3300ff),
  ]),

The code in red is whats not working. The enemy skill values always come up as 0 even when some of the members of the party being attacked have very high skill levels in spotting and tactics. All the code for the player part displays correctly. I'm guessing that I am miss using the operations in some small fundamental way.

Any help will be much appreciated.
Ahadhran
Title: Re: M&B Scripting Q&A
Post by: Hellequin on July 06, 2007, 07:39:01 pm
Are the enemies with those skills marked trp_hero?  Regular troops don't contribute to the party's effective skill when they're on your own side... can't imagine it'd be otherwise on the other side, either.

You can manually loop through the party members of the other team and check their skills; the only 'virtue' of party_get_skill_level is that it incorporates the "companions' skills are reduced if too different from the player's" logic of 0.8x.  For stuff like this, you're better off just finding the actual highest skill.  Come to that, the "reduce skill if too distinct from player's skill" may have weird interactions if the player is not, in fact, even on their side.  That could be the reason, too.
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on July 07, 2007, 12:50:31 am
ah ha, thats the problem then, I need hero captains for all the parties. Somewhat tedious way of keeping track of skills, but I suppose it can't be helped.

As to companions having the lowered effect, I think thats just nitpicking. Most of my differences for battles are in a range of three or more skill points so I think just ignoring that is the easiest route.
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on August 10, 2007, 03:45:44 pm
I'm having a very weird issue with the math operations doing strange things. I didn't realize it till I starting displaying messages that told me the variable values.

Here is the chunk of code:

Quote
   (val_add,":current_spawn_sum","$peak_lost_souls"),
   (val_add,":current_spawn_sum","$peak_dark_wanderers"),
   (val_add,":current_spawn_sum","$peak_damned_hosts"),
   (val_add,":current_spawn_sum","$peak_slayer_border_guard"),
      (assign,reg0,"$peak_lost_souls"),
      (assign,reg1,"$peak_dark_wanderers"),
      (assign,reg2,"$peak_damned_hosts"),
      (assign,reg3,"$peak_slayer_border_guard"),
      (display_message,"str_variable_report",0xff0000),
   (val_add,":current_spawn_sum","$peak_blood_riders"),
   (val_add,":current_spawn_sum","$peak_slayer_host"),
   (val_add,":current_spawn_sum","$peak_rampagers"),
   (val_add,":current_spawn_sum","$peak_slayer_scouts"),
      (assign,reg0,"$peak_blood_riders"),
      (assign,reg1,"$peak_slayer_host"),
      (assign,reg2,"$peak_rampagers"),
      (assign,reg3,"$peak_slayer_scouts"),
      (display_message,"str_variable_report",0xff0000),
   (val_add,":current_spawn_sum","$peak_followers"),
      (assign,reg0,"$peak_followers"),
      (assign,reg1,":current_spawn_sum"),
      (assign,reg2,0),
      (assign,reg3,0),
      (display_message,"str_variable_report",0xff0000),

All the the spawn $peak variables show up correctly, but the sum ends up being wildly huge. All I'm trying to do is add all the $peak values up into one number in the variable ":current_spawn_sum". One time it came out as 427, the next as 63697506 (it should come to 34)  :shock: By the way, I do zero it out after running through the script, even though I shouldn't need to since its a local variable...

Please help before I go insane  :lol:
Title: Re: M&B Scripting Q&A
Post by: fujiwara on August 10, 2007, 04:20:25 pm
At first glance I don't see an issue here. I assume all the $peak variables are constants that don't change? Maybe seeing the whole operations block might help.
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on August 10, 2007, 04:58:48 pm
I fixed the problem by zeroing ":current_spawn_sum" right before the operation, rather than after. It appears the variable was getting filled with something in the interim between script runs even though nothing I have written does so.

Is it possible that I have gone over the limit on local variables such that the memory space for this one is overlapping with another? This doesn't make sense to me though since the whole idea behind local variables is that they don't exist outside the operations block.

As to the $peak values, they didn't change during my test runs...

Here is the whole script with the display message parts removed:

Quote
("army_base_enable_calc",
  [
  (try_begin),
   (eq,"$player_is_good",0),
   (display_message,"str_false",0xff0000),
   (assign,":current_spawn_sum",0),
   (val_add,":current_spawn_sum","$peak_alliance_foragers"),
   (val_add,":current_spawn_sum","$peak_alliance_scouts"),
   (val_add,":current_spawn_sum","$peak_alliance_harassers"),
   (val_add,":current_spawn_sum","$peak_alliance_war_parties"),
   #(val_add,":current_spawn_sum" for when more rangers are added
   #(val_add,":current_spawn_sum" for when more guardians are added
   (val_mul,":current_spawn_sum",100),
   (store_div,":percent_enable_chance",":current_spawn_sum",sum_alliance_spawn_forces),
   (store_random_in_range,":random_num",1,101),
   (try_begin),
      (le,":random_num",":percent_enable_chance"), #chance that a party will be enabled as scheduled"
      (assign,"$enable_base_ready",1),
   (try_end),
  (else_try),
   (eq,"$player_is_good",1),
   (assign,":current_spawn_sum",0),
   (val_add,":current_spawn_sum","$peak_lost_souls"),
   (val_add,":current_spawn_sum","$peak_dark_wanderers"),
   (val_add,":current_spawn_sum","$peak_damned_hosts"),
   (val_add,":current_spawn_sum","$peak_slayer_border_guard"),
   (val_add,":current_spawn_sum","$peak_blood_riders"),
   (val_add,":current_spawn_sum","$peak_slayer_host"),
   (val_add,":current_spawn_sum","$peak_rampagers"),
   (val_add,":current_spawn_sum","$peak_slayer_scouts"),
   (val_add,":current_spawn_sum","$peak_followers"),
   (val_mul,":current_spawn_sum",100),
   (store_div,":percent_enable_chance",":current_spawn_sum",sum_damned_spawn_forces),
   (store_random_in_range,":random_num",1,101),
   (try_begin),
      (le,":random_num",":percent_enable_chance"), #chance that a party will be enabled as scheduled
      (assign,"$enable_base_ready",1),
   (try_end),
  (try_end),
  ]),

Basically the script takes the current number of parties allowed to spawn for a faction and divides by what it would be at its strongest point (sum_xxxxxx_spawn_forces) in order to determine the % strength of the faction. This is then compared against the random number, if the faction is at full strength, its military expansion will continue unabated but as it loses (the $peak #s go down) it becomes less likely to expand its army bases.

The idea is to have the $peak numbers go down as result of completing quests.

Just for further info, here are the triggers that run the script and determines when it is run.

Quote
#Expansion of NPC army bases
(3,0,1.0,[
   (ge,"$darmy_base_counter","$darmy_base_wait"),
   (ge,"$aarmy_base_counter","$aarmy_base_wait"),
   ],
   [
   (call_script,"script_army_base_enable_calc"),
   (try_begin),
      (eq,"$player_is_good",1),
      (eq,"$enable_base_ready",1),
      (call_script,"script_choose_army_base_damned"),
   (else_try),
      (eq,"$player_is_good",0),
      (eq,"$enable_base_ready",1),
      (call_script,"script_choose_army_base_alliance"),
   (try_end),
   (assign,"$darmy_base_counter",0),
   (assign,"$aarmy_base_counter",0),
   (assign,"$enable_base_ready",0),

Quote
#counter trigger
(1,0,1.0,[],
[
(val_add,"$darmy_base_counter",1),
(val_add,"$aarmy_base_counter",1),
]),
Title: Re: M&B Scripting Q&A
Post by: fujiwara on August 11, 2007, 12:04:51 pm
I find it's good programming practice to zero variables before using them, since I'm not certain whether or not MBScript does any initialization beforehand.

As far as memory goes, I would think not. I would be surprised if that were the case, given the amounts of memory available on modern boxen.
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on August 11, 2007, 12:16:32 pm
I find it's good programming practice to zero variables before using them, since I'm not certain whether or not MBScript does any initialization beforehand.

As far as memory goes, I would think not. I would be surprised if that were the case, given the amounts of memory available on modern boxen.

I usually do zero variables before use, I just didn't think it would be necessary with local variables. Clearly I was wrong. Oh well, its a very simple solution to make everything work right.
Title: Re: M&B Scripting Q&A
Post by: Winter on August 12, 2007, 11:14:39 am
Always, ALWAYS zero your local variables before use. They use an array of data slots that is constantly re-used in a cyclic pattern -- basically, when an operations block is called, it assigns the local vars to this array of slots, and when the block is finished and the next block begins, the new block's locals will use the exact same slots used by the old block. This happens over and over and over, and Native scripts use locals extensively, so you can never know what leftover value a local var might end up containing unless you zero it first.
Title: Re: M&B Scripting Q&A
Post by: Ahadhran on August 12, 2007, 04:03:24 pm
Always, ALWAYS zero your local variables before use. They use an array of data slots that is constantly re-used in a cyclic pattern -- basically, when an operations block is called, it assigns the local vars to this array of slots, and when the block is finished and the next block begins, the new block's locals will use the exact same slots used by the old block. This happens over and over and over, and Native scripts use locals extensively, so you can never know what leftover value a local var might end up containing unless you zero it first.

Thank you for the clarification Winter, I now understand how it works! One other question I would be curious to know the answer to is: how many local variables can you use at once(within one operation block)? Its probably a very large number, but it might be worth knowing anyway.
Title: Re: M&B Scripting Q&A
Post by: fujiwara on August 13, 2007, 11:36:11 am
Always, ALWAYS zero your local variables before use. They use an array of data slots that is constantly re-used in a cyclic pattern -- basically, when an operations block is called, it assigns the local vars to this array of slots, and when the block is finished and the next block begins, the new block's locals will use the exact same slots used by the old block. This happens over and over and over, and Native scripts use locals extensively, so you can never know what leftover value a local var might end up containing unless you zero it first.

Interesting. Has anyone tried to exploit this 'carry-over' effect? Such that if I declare ':var1' in the first op block, then refer to ':var1' in the second block, is it guaranteed to store the same value as in the first block, or are locals assigned slots based on first-come-first-served?
Title: Re: M&B Scripting Q&A
Post by: Winter on August 16, 2007, 07:50:20 am
Interesting. Has anyone tried to exploit this 'carry-over' effect? Such that if I declare ':var1' in the first op block, then refer to ':var1' in the second block, is it guaranteed to store the same value as in the first block, or are locals assigned slots based on first-come-first-served?

No, it's not guaranteed to store the same value, I'm afraid. Otherwise why would you need script params at all?
Title: Re: M&B Scripting Q&A
Post by: Marcus on October 07, 2007, 11:43:58 am
Ok, just a quick question, how would I use a dialog to make the player join a faction depending on what choice he'/she makes? You could also point me to the code that makes you join a faction once you've spoken to the king.
Title: Re: M&B Scripting Q&A
Post by: Fisheye on October 07, 2007, 11:56:57 am
script_player_join_faction

search for that in module_dialogs to see when it is used.
Title: Re: M&B Scripting Q&A
Post by: Marcus on October 07, 2007, 12:48:50 pm
Seen it, what bit of code activates the quest to find the lord and swear allegiance?
Title: Re: M&B Scripting Q&A
Post by: Fisheye on October 07, 2007, 12:50:58 pm
Search for:

# Offer player to join faction

in module_simple_triggers
Title: Re: M&B Scripting Q&A
Post by: Marcus on October 07, 2007, 12:55:50 pm
Faster than lightening you are. ;)

Because that's a randomised menu event as such, I'm not sure how I would implement it to a dialog to offer to join the swadians, any ideas?
Title: Re: M&B Scripting Q&A
Post by: grailknighthero on October 16, 2007, 08:12:59 am
Faster than lightening you are. ;)

Because that's a randomised menu event as such, I'm not sure how I would implement it to a dialog to offer to join the swadians, any ideas?
Take out the simple trigger or modify it.  I have heavily modified it for my mod.
Title: Re: M&B Scripting Q&A
Post by: LCJr on October 17, 2007, 06:57:43 pm
Is "mission_time" measured in seconds?

For example:
Code: [Select]
(try_begin), # charge everyone after a while
        (eq, "$everyone_charge_order_given", 0),
        (ge,":mission_time",300),
        (assign, "$everyone_charge_order_given", 1),
        (team_give_order, "$ai_team", grc_everyone, mordr_charge),
        (team_get_leader, ":ai_leader", "$ai_team"),
        (agent_set_speed_limit, ":ai_leader", 60),
      (try_end),
Title: Re: M&B Scripting Q&A
Post by: grailknighthero on October 17, 2007, 11:20:47 pm
Is "mission_time" measured in seconds?

For example:
Code: [Select]
(try_begin), # charge everyone after a while
        (eq, "$everyone_charge_order_given", 0),
        (ge,":mission_time",300),
        (assign, "$everyone_charge_order_given", 1),
        (team_give_order, "$ai_team", grc_everyone, mordr_charge),
        (team_get_leader, ":ai_leader", "$ai_team"),
        (agent_set_speed_limit, ":ai_leader", 60),
      (try_end),

It was in .808, I havent messed around with it in .89x but I assume it hasn't changed.
Title: Re: M&B Scripting Q&A
Post by: Highlander on October 30, 2007, 08:51:39 am
Does anyone know how sqrt works?
 (store_sqrt, <destination_fixed_point>, <value_fixed_point>),
I have no idea about the fixed point stuff.
Title: Re: M&B Scripting Q&A
Post by: Fisheye on October 30, 2007, 09:17:03 am
Does anyone know how sqrt works?
 (store_sqrt, <destination_fixed_point>, <value_fixed_point>),
I have no idea about the fixed point stuff.

http://mbx.streetofeyes.com/index.php/topic,956.0.html
Title: Decreasing party limit, increasing affect of leadership
Post by: bungus on June 26, 2008, 02:12:00 pm
I want to lower the maximim number of units the player can have in his party. To counteract this affect, then, increase the number of party members the leadership skill gives you.

I don't use python. Any one know what text file and where in it are these variables?
Title: Re: Decreasing party limit, increasing affect of leadership
Post by: Ron Losey on June 28, 2008, 12:38:25 am
I want to lower the maximim number of units the player can have in his party. To counteract this affect, then, increase the number of party members the leadership skill gives you.

I don't use python. Any one know what text file and where in it are these variables?

I answered this in the other thread.  There's no way in heck.  You would have to calculate the exact offset in a hex .txt file ... which will be different depending on which mod you are using, and each version thereafter.  Even if you could somehow compile Python code in your head, it would take days to find it.  It would be easier to build a nuclear reactor out of a microwave oven and a hot water tank.  (Not "impossible", but certainly unlikely to the point of being ineffective.)

The only way to do that without the source code would be to compile two versions from Python - one with the changes you wanted, one as per Native - and then cut and paste the changes you wanted ... and hope that you didn't miss the hex offset by one space.  And that's not exactly a "don't use Python" solution ... it's just a cut-and-paste for portions of the source code that you don't have.  Even then, it might or might not work, depending on what else that particular mod had changed.

Stick to flapping your arms and trying to fly to Jupiter ... your odds are better.

Some things just can't be effectively done without the source code.  That's just about all there is to it.
Title: Re: M&B Scripting Q&A
Post by: bungus on June 28, 2008, 04:20:04 pm
Oh... Well, thanks for the tip.

I'm used to medieval2, stalker, and a few others where ini editing is possible, and easy. No idea what I'm doing here, though, I was able to edit the text file for items1.
Title: Re: M&B Scripting Q&A
Post by: Ron Losey on June 28, 2008, 07:00:08 pm
Oh... Well, thanks for the tip.

I'm used to medieval2, stalker, and a few others where ini editing is possible, and easy. No idea what I'm doing here, though, I was able to edit the text file for items1.

The item_kinds1.txt file is almost human-readable, if you are extremely patient.  You can edit it some, if you are careful what you change, without screwing up the rest of the game.  (Note that if you add a line, every other piece of equipment in the game will be in the wrong places.)  The troops text file can be similarly edited manually, again if you are extremely patient.  The others become progressively less likely to work.

It's easier to learn Python, at least enough to do whatever you're wanting to do.  That's what I finally had to do.
Title: Re: M&B Scripting Q&A
Post by: Shik on December 06, 2008, 09:07:12 pm
    if (len(entry[5]) > 8 ):
TypeError: object of type 'int' has no len()

What does this error mean? What should I be looking for to resolve it?
Title: Re: M&B Scripting Q&A
Post by: Fisheye on December 07, 2008, 11:49:10 am
The usual punctuation error, missing or extra commas, mismatched brackets, etc.
Title: Re: M&B Scripting Q&A
Post by: Shik on April 10, 2009, 04:09:52 pm
Apparently the compiler doesn't like it when I use characters like these in the module files:

  ô œ ù û ü ÿ à â ç é è ê ë ï î

SyntaxError: Non-ASCII character '/xf4' ..., but no encoding declared; http://www.python.org/dev/peps/pep-0263/

I have no idea what I should do about this. How can I resolve this issue?
Title: Re: M&B Scripting Q&A
Post by: Ron Losey on April 10, 2009, 04:57:57 pm
Well, the obvious answer would be to avoid using characters like that....  ::)
Title: Re: M&B Scripting Q&A
Post by: Shik on April 10, 2009, 07:21:36 pm
...how did I totally know someone was going to say that? Honestly, if I simply wanted to resolve the issue by removing all accented characters, I would have done so.
The point is, I want to have troops with accented names, but it appears that the module system doesn't like the encoding or whatever. I'm just wondering if it's possible to get around it by typing some definitions somewhere. For now, I'll just use the language files to get around it, but it makes things a hassle.
Title: Re: M&B Scripting Q&A
Post by: Ron Losey on April 10, 2009, 10:47:09 pm
Honestly, if I simply wanted to resolve the issue by removing all accented characters, I would have done so.

Yes, well, that was implied ... hence the little guy rolling his eyes  ::)

But seriously, that could be a real pain to beat.  I don't think there's anywhere in the header_(whatever) files that defines characters to use in names or script (at least not any that I have seen), so it may be a problem in Python in general, or M&B.  Same way you can't use quotation marks in your text, because Python uses the quotation marks to define what the text is.

So what you "wanted" may not be helpful at the moment ... it might be another item to chalk up in the "M&B Oddities" collection.

Like the classical medical diagnosis:
Patient:  "Doctor, it hurts to breathe when I run."
Doctor: "So don't run."
Title: Re: M&B Scripting Q&A
Post by: fujiwara on December 05, 2009, 12:45:00 am
Python defaults to ASCII when no other encoding is specified (UTF-8 or other). Furthermore, I don't know if M&B itself supports anything other than ASCII. The developers used a number of Turkish place names in Native, and Turkish uses a number of diacritical marks. None showed up in Native, so I have to assume M&B doesn't support them. Any evidence to the contrary would help solve the problem.
Title: Re: M&B Scripting Q&A
Post by: wombn8t on December 05, 2009, 09:14:32 pm
Hello! I'm new to modding.

I'm thinking of a starting a small little mini-mod to learn the basics.

I've cruised the forums and haven't found updated tutorials on using python. I got errors when I tried to go through the one posted in 2006.

Am I going to have to adapt them or are there updated step-by-step ones?

Also, I can't get Thorgrim's map editor to work. It says it can't find the directory of Mount and Blade. I've tried re-installing it. Should I re-install Mount and Blade?

Thanks,

Womb8t
Title: Re: M&B Scripting Q&A
Post by: Madmax on July 16, 2010, 01:05:09 pm
OK, I ll start here then, I guess I am right now :-)

hallo everybody, my first post here! (actually the second, I first posted in the wrong place, I guess)

I would like to tweak one thing. I have the problem, with this game (which I LOVE!!!!), that I advance so slowly, and I have actually so little time to play it.

This brings to the question:
I would like to increase in level, to increase my party capability, to improve my reputation ... in one word: to become king with a certain character in a shorter time than what the Native allows you.

Any idea, how can one make the games "faster" at his own will? Is something already out there, based on native?

A last thing: I am a newby at modding, you ll have to explain me in details what I do have to do  :D

Thank you in advance!
Title: Re: M&B Scripting Q&A
Post by: GetAssista on July 21, 2010, 01:12:50 am
Madmax, I think you need to look through the sticky threads in Taleworlds forum. There are tools & directions  for simple text tweaks there, and that's what you need
Title: Re: M&B Scripting Q&A
Post by: Madmax on July 29, 2010, 05:16:50 am
Ok, Thanks :-)