Lumos said:That's a bit more complicated and there are a number of variants. I am unfortunately busy right now, but I'll answer your question later today if nobody does it before me. (It's 09:20 where I am, I should be back online at about 13:00-14:00. Please be patient.)
cwr said:YES!!! I can make everything in quests, except mission templates, so that would be great.
Lumos said:FantasyWarrior, please don't get offended
(24, [
(troop_add_gold, "trp_player", 100),
]),
[color=navy](check_interval, [ operations_block ]),[/color]
(24, [
# (try_begin), # We don't need try blocks right now
(lt, "$player_honor", 0),
(troop_add_gold, "trp_player", 100),
# (try_end),
]),
(24, [
(try_begin), # Better safe than sorry
(lt, "$player_honor", 0), # Make sure your indentation is always correct!
(troop_add_gold, "trp_player", 100), # Tabs don't look so huge in the text editors, only here on the forum.
(try_end),
]),
["flintlock_pistol", "Flintlock Pistol", [("flintlock_pistol",0)], itp_type_pistol|itp_merchandise|itp_primary, itcf_shoot_pistol|itcf_reload_pistol, 230, weight(1.5)|difficulty(0)|spd_rtng(38)|shoot_speed(160)|thrust_damage(10, pierce)|max_ammo(1)|accuracy(65), imodbits_none, [ # A comma is always followed by a spacebar, as your friendly schoolbooks teach you
(ti_on_weapon_attack, [
(play_sound,"snd_pistol_shot"),
(position_move_x, pos1,27),
(position_move_y, pos1,36),
(particle_system_burst, "psys_pistol_smoke", pos1, 15) # The last line in a field can remain without a comma, but be careful when adding more lines later
])]],
("catapult_destructible", sokf_moveable|sokf_show_hit_point_bar|sokf_destructible, "Catapult", "bo_Catapult", [
(ti_on_init_scene_prop, [
(store_trigger_param_1, ":instance_no"),
(scene_prop_set_hit_points, ":instance_no", 1600),
]),
# Other triggers omitted for clarity
]),
[color=navy]ti_on_weapon_attack[/color]
[color=navy]ti_on_init_scene_prop[/color]
(check_interval, delay_interval, re-arm_inverval, [ conditions_block], [ operations_block ]),
(24, 0, 0, [], [
(try_begin),
(lt, "$player_honor", 0),
(troop_add_gold, "trp_player", 100),
(try_end),
]),
(24, 6, 48, [
(lt, "$player_honor", 0),
], [
(troop_add_gold, "trp_player", 400),
]),
ti_before_mission_start
ti_on_agent_spawn
(store_trigger_param)
(set_jump_mission, "mt_mission_template"), (jump_to_scene, "scn_selected_scene"), (change_screen_mission),
(mission_template_id, flags, type, useless_text, [ spawn_records ], [ triggers ]),
(entry_id, spawn_flags, alter_flags, ai_flags, num_troops, [ equipment_list ]),
[color=navy]mtef_team_0[/color]
af_override_horse
af_override_all
aif_start_alarmed
("useless_template",0,-1, "Nothing to see here", [
(0, mtef_visitor_source|mtef_team_0, af_override_fullhelm, aif_start_alarmed, 1, []),
(1, mtef_visitor_source|mtef_team_1, af_override_fullhelm, aif_start_alarmed, 1, []),
], [
(ti_on_agent_spawn, 0, 0, [], [
(display_message, "@Agent spawned"),
]),
(ti_on_agent_killed_or_wounded, 0, 0, [], [
(store_trigger_param, ":dead_agent_id", 1),
(agent_get_troop_id, ":troop", ":dead_agent_id"),
(str_store_troop_name, s1, ":troop"),
(display_message, "@{s1} died a gruesome death. Or was knocked unconsious, we're not checking that."),
]),
# Health regen for the player
(1, 0, 0, [
(neg|main_hero_fallen),
(get_player_agent_no, ":agent"),
(agent_is_alive, ":agent"),
], [
(get_player_agent_no, ":agent"), # Local variables are not transferred between conditions and consequences
(store_agent_hit_points, ":health", ":agent", 1),
(val_add, ":health", 1),
(agent_set_hit_points, ":agent", ":health", 1),
]),
]),
mtef_visitor_source
(modify_visitors_at_site, "scn_current_scene"), (set_visitor, entry_point_number, "trp_whatever"),
mtef_scene_source
Somebody said:Did you give the troops the proper factions and differentiate them from the bot versions?xPearse said:I have been setting up units for multiplayer and for some reason I can't select troops for faction 3 and 4. Any reason why this would happen.
(set_show_messages,0),
(display_log_message,"@{s1} with id {reg1} connected!"),
(set_show_messages,1),
(display_message,"@{s1} just connected!",0xFFFF00),
Aratar1 with id 2 connected!
March 23, 1257 just connected!
Lumos said:FantasyWarrior posted that while I was writing, I will not be taking his post into any consideration. FantasyWarrior, please don't get offended, but your posts that are similar to that one above are almost painful to read. I understand what you've done with your code, but damn, the way you post such "guides" is mind-numbing.
WARNING MASSIVE WALL OF TEXT INBOUND
Walking home about (EDIT: two hours and a) half an hour ago, I was thinking about writing a full-fledged tutorial about implementing a quest along with additions to nearly every file, but then I realised two things. First, this is a massive overhead and requires more time than I can spare at the moment. Secondly, I'm too short on beer for such an endeavour.
So, I decided to simply explain how triggers and mission templates work, and I'll do it in detail and with examples. So let's get started, shall we?
- (Simple) Triggers:
There are two types of triggers in M&B: Regular triggers and simple triggers. We'll begin with the simple triggers, because they're generally smaller and easier to understand.
Before that though, what is a trigger? A trigger is a block of code that executes multiple times as the game progresses. It's called a trigger, because it fires - that's how it's called when the time comes for the trigger to do its job.
Simple triggers:
Simple triggers are generally found in module_simple_triggers.py and despite being... well, simpler, they're not to be underestimated. Let's have a look at a simple trigger and then explain what does what:
This is rather simple, isn't it? Every 24 hours, this trigger will give 100 gold to the player. Yes, it makes no sense, but it works. And that's basically how every simple trigger operates. Here's the structure:Code:(24, [ (troop_add_gold, "trp_player", 100), ]),
This is shared by each and every simple trigger, including the gold-giving one we've got above. Now let's look at the components: check_interval is how frequently this trigger will be checked, measured in in-game hours. Using 24 will make the trigger fire once every day, using 1 will make it fire 24 times per day.Code:[color=navy](check_interval, [ operations_block ]),[/color]
NB: Using 0 as a check interval will make the trigger fire once every frame, i.e. a lot of times per second, dependent on the user's frame rate. Such triggers are potential performance hogs, so be cautious when using them.
The operations block is what happens when the trigger fires, and can contain whatever codes you want to place in it. Yes, checks are allowed. For an example, we can enhance our aforementioned code by doing this:
Now it will give a hundred gold per day to the player, if he/she is dishonourable. It makes even less sense now, but whatever. As you can see, a trigger can fail with no problems whatsoever, however be careful when not wrapping statements in try_ blocks. Of course, it's always safer to use the try blocks, just in case.Code:(24, [ # (try_begin), # We don't need try blocks right now (lt, "$player_honor", 0), (troop_add_gold, "trp_player", 100), # (try_end), ]),
Same but fixed:Right, so we've got the basics covered now. There are more things you need to know though. Simple triggers are also used in other places, such as on items and scene props, but with special conditions, for an example:Code:(24, [ (try_begin), # Better safe than sorry (lt, "$player_honor", 0), # Make sure your indentation is always correct! (troop_add_gold, "trp_player", 100), # Tabs don't look so huge in the text editors, only here on the forum. (try_end), ]),
Code:["flintlock_pistol", "Flintlock Pistol", [("flintlock_pistol",0)], itp_type_pistol|itp_merchandise|itp_primary, itcf_shoot_pistol|itcf_reload_pistol, 230, weight(1.5)|difficulty(0)|spd_rtng(38)|shoot_speed(160)|thrust_damage(10, pierce)|max_ammo(1)|accuracy(65), imodbits_none, [ # A comma is always followed by a spacebar, as your friendly schoolbooks teach you (ti_on_weapon_attack, [ (play_sound,"snd_pistol_shot"), (position_move_x, pos1,27), (position_move_y, pos1,36), (particle_system_burst, "psys_pistol_smoke", pos1, 15) # The last line in a field can remain without a comma, but be careful when adding more lines later ])]],
As you can see, these two examples use respectivelyCode:("catapult_destructible", sokf_moveable|sokf_show_hit_point_bar|sokf_destructible, "Catapult", "bo_Catapult", [ (ti_on_init_scene_prop, [ (store_trigger_param_1, ":instance_no"), (scene_prop_set_hit_points, ":instance_no", 1600), ]), # Other triggers omitted for clarity ]),
andCode:[color=navy]ti_on_weapon_attack[/color]
. which are hard-coded conditions passed by the engine at the right times. A list of all such "special" check intervals can be found in header_triggers.py.Code:[color=navy]ti_on_init_scene_prop[/color]
This about sums up everything related to simple triggers, now let's move on to...
Triggers:
The regular triggers, called only "triggers" are a bit more complex and versatile than their simpler counterparts, but are largely the same. These triggers are more important, however, because they are used in the mission templates, which we'll talk about afterwards.
Let's examine the structure of a trigger:
As you can see, there're more fields present here than there were above. Now let's examine them one by one.Code:(check_interval, delay_interval, re-arm_inverval, [ conditions_block], [ operations_block ]),
- The check_interval is absolutely the same as before - how often the trigger fires;
- The delay_interval is how much the consequences should be delayed once the conditions are true;
- The re-arm_interval is how long should the trigger remain inactive once the consequences are applied;
- The conditions_block contains the code that needs to be checked in order to allow for the consequences to fire;
- The consequences_block is where the majority of your ocde is usually located, it will be executed once the conditions are evaluated to true and the delay_interval wears off.
Now, how would our senseless trigger from above look like?
This is perfectly valid, but it's frankly kind of stupid if we're going to use a regular trigger. Let's buff up the rewards and rework the code a bit in order to make use of the systems that this trigger allows us:Code:(24, 0, 0, [], [ (try_begin), (lt, "$player_honor", 0), (troop_add_gold, "trp_player", 100), (try_end), ]),
Now, every 24 hours this trigger will evaluate the player's honour. If it's below zero, six hours will pass, keeping the player on edge (okay, not really), and then he or she will be awarded four hundred gold. However, the trigger will not fire for the next 48 hours, which kind of compensates for the greater reward.Code:(24, 6, 48, [ (lt, "$player_honor", 0), ], [ (troop_add_gold, "trp_player", 400), ]),
Yes, the trigger is still dumb, but serves as a nice example.
Regular triggers also have their special conditions, most of which related to missions -,Code:ti_before_mission_start
and so on, once again listed in header_triggers.py.Code:ti_on_agent_spawn
NB: Local variables are not transferred between conditions and consequences. In other words, you'll need to store a variable again to modify it in the consequences if you've already stored it to check it.
NB: When dealing with triggers with special conditions, you are likely to need to check their parameters using theoperation. Consult header_triggers.py for a list of parameters for each trigger.Code:(store_trigger_param)
I hope you've learned something. If you haven't, I'm sorry.
Now, we'll take a look at...
- Mission templates
First of all, you need to understand one simple concept - that a mission template is largely a template to be used for similar missions. A mission is any occasion that you're controlling your character in. Mission templates provide different functions through trigger usage and are pretty important, being the second required component of a mission (the other one is a scene for them ission to play in). They are usually accessed through a menu with theset of commands.Code:(set_jump_mission, "mt_mission_template"), (jump_to_scene, "scn_selected_scene"), (change_screen_mission),
A mission template's structure is a lot more complex than a trigger, and contains lists of objects such as triggers. Let us examine a mission template:
- The mission_template_id is what you're going to be referencing this mission template with;Code:(mission_template_id, flags, type, useless_text, [ spawn_records ], [ triggers ]),
- The flags are just that - flags. Look in header_mission_templates.py for a list of flags, leave it a zero when you've not got any special conditions;
- The type is a special value that is usually -1, you're unlikely to need to change it;
- The useless_text is a mission template's description, which serves absolutely no purpose. I guess you could use it to describe stuff for yourself, but I believe it only takes up space;
- The spawn_records is a list of spawn points and conditions for them;
- The triggers is a list of triggers, much like the ones we discussed above.
First of all, we have to look through the structure of each spawn record and see what they're made of.
- The entry_id is the spawn point number which the troops from this record will use;Code:(entry_id, spawn_flags, alter_flags, ai_flags, num_troops, [ equipment_list ]),
- The spawn_flags are flags that dictate something about the spawning - likeand so on;Code:[color=navy]mtef_team_0[/color]
- The alter_flags are flags that say what equipment should the agents NOT spawn with - for an example,orCode:af_override_horse
- The ai_flags are flags that will give the AI agents spawned from this record a specific behavour. Usually used withCode:af_override_all
;Code:aif_start_alarmed
- The num_troops is how many agents should spawn from this record;
- The equipment_list is a maximum of items that will be added to the agent's inventory, eight at max. Overriding all and adding the pilgrim disgiuse in the equipment_list results in the player being disguised while "fooling the town guards".
Let's make a dummy mission template, so we can talk about stuff. Consider this:
In this mission template, two agents on two different teams are going to spawn, and they'll spawn without helmets. Upon their spawning, two "Agent spawned" messages will roll out, and when one dies you will be notified by another message. On top of all that, you will regenerate health wat a rate of 1 HP/second (which is quite overpowered).Code:("useless_template",0,-1, "Nothing to see here", [ (0, mtef_visitor_source|mtef_team_0, af_override_fullhelm, aif_start_alarmed, 1, []), (1, mtef_visitor_source|mtef_team_1, af_override_fullhelm, aif_start_alarmed, 1, []), ], [ (ti_on_agent_spawn, 0, 0, [], [ (display_message, "@Agent spawned"), ]), (ti_on_agent_killed_or_wounded, 0, 0, [], [ (store_trigger_param, ":dead_agent_id", 1), (agent_get_troop_id, ":troop", ":dead_agent_id"), (str_store_troop_name, s1, ":troop"), (display_message, "@{s1} died a gruesome death. Or was knocked unconsious, we're not checking that."), ]), # Health regen for the player (1, 0, 0, [ (neg|main_hero_fallen), (get_player_agent_no, ":agent"), (agent_is_alive, ":agent"), ], [ (get_player_agent_no, ":agent"), # Local variables are not transferred between conditions and consequences (store_agent_hit_points, ":health", ":agent", 1), (val_add, ":health", 1), (agent_set_hit_points, ":agent", ":health", 1), ]), ]),
As you can see, this mission template contains two spawn records and three triggers. Thewill allow for agents to spawn through the usage ofCode:mtef_visitor_source
whileCode:(modify_visitors_at_site, "scn_current_scene"), (set_visitor, entry_point_number, "trp_whatever"),
... I've got no idea what it does. Feel free to experiment.Code:mtef_scene_source
The triggers here are pretty self-explanatory, I reckon.
And given that I've wasted too much time already on this, I'll have to wrap it up here. The best advice I could give you is to LOOK at the files and see how things are already done. Then you'll understand how to do them yourself.
Hope this helps. If it doesn't, I won't write another one.
("beacon_fire_big", psf_billboard_3d|psf_global_emit_dir|psf_always_emit|psf_randomize_size|psf_randomize_rotation, "prt_mesh_fire_1",
30, 1.0, 0, -1.2, 10.0, 5.0, #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength
(0.2, 0.7), (1, 0), #alpha keys
(0.2, 1.0), (1, 0.9), #red keys
(0.2, 0.7),(1, 0.3), #green keys
(0.2, 0.2), (1, 0.0), #blue keys
(0, 1), (1, 1), #scale keys
(1, 1, 0.5), #emit box size
(0, 0, 0.0), #emit velocity
0.0, #emit dir randomness
250, #rotation speed
0.3 #rotation damping
Quintillius said:Does "Create new face" show the same problem?
Hartzekar said:Hey all. I'm wondering if it is possible to add a poison type effect to weapons. For example, the first hit inflicts 25 damage, and then it deals an additional 25 damage over 10 seconds. Is it possible? If so, where do I need to go to add it?
Thanks.
Quintillius said:Which of these values controls the height of a particle?Code:("beacon_fire_big", psf_billboard_3d|psf_global_emit_dir|psf_always_emit|psf_randomize_size|psf_randomize_rotation, "prt_mesh_fire_1", 30, 1.0, 0, -1.2, 10.0, 5.0, #num_particles, life, damping, gravity_strength, turbulance_size, turbulance_strength (0.2, 0.7), (1, 0), #alpha keys (0.2, 1.0), (1, 0.9), #red keys (0.2, 0.7),(1, 0.3), #green keys (0.2, 0.2), (1, 0.0), #blue keys (0, 1), (1, 1), #scale keys (1, 1, 0.5), #emit box size (0, 0, 0.0), #emit velocity 0.0, #emit dir randomness 250, #rotation speed 0.3 #rotation damping
It's Lumos's!!!1!Zephilinox said:Lumo's earlier post regarding triggers
Unfortunately not...Willhelm said:Is it possible to add vertex animations to scene props?
It may works with the WSE operationWillhelm said:Is it possible to add vertex animations to scene props? I've made a Ballista over the framework of the cannons in the Napoleonic Wars DLC, but unfortunately although it is working great in every other way, I can't figure out a way to make the limbs and string move back as you cock it.
(prop_instance_set_vertex_keys_time_point, <prop_instance_no>, <time_point>), #Sets <prop_instance_no>'s mesh vertex keys time point to <time_point>
Lumos said:It's Lumos's!!!1!Zephilinox said:Lumo's earlier post regarding triggers
Unfortunately not...Willhelm said:Is it possible to add vertex animations to scene props?
cwr said:rt_bridge.
Bridges are just map icons placed over that, so it looks realistic.
Traceback (most recent call last):
File "process_init.py", line 2, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_global_variables.py", line 12, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Traceback (most recent call last):
File "process_map_icons.py", line 6, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
File "process_items.py", line 66, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting scene data...
Traceback (most recent call last):
File "process_scenes.py", line 15, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_troops.py", line 4, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting particle data...
Traceback (most recent call last):
File "process_scene_props.py", line 7, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_tableau_materials.py", line 8, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_presentations.py", line 8, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting party_template data...
Traceback (most recent call last):
File "process_parties.py", line 6, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting quest data...
Exporting info_page data...
Traceback (most recent call last):
File "process_scripts.py", line 7, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_mission_tmps.py", line 8, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_game_menus.py", line 8, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_simple_triggers.py", line 5, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_dialogs.py", line 9, in <module>
from process_operations import *
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "process_global_variables_unused.py", line 3, in <module>
from process_operations import*
File "C:\Program Files (x86)\Module_system 1.158\process_operations.py", line
14, in <module>
from module_troops import *
File "C:\Program Files (x86)\Module_system 1.158\module_troops.py", line 2139
upgrade2(troops,"watchman","caravan_guard","mercenary_crossbowman")
^
SyntaxError: invalid syntax
Exporting postfx_params...