login

Show Posts

You can view here all posts made by this member. Note that you can only see posts made in areas to which you currently have access.


Topics - Winter

Pages: 1 [2] 3 4
17
Tutorials / Winter's Guide To: header_operations.py
« on: September 11, 2007, 07:54:07 AM »
Winter's Guide to header_operations
----

In this guide I'll try to briefly explain the function of each operation in header_operations.py, and on occasion add anecdotes of my own experiences with troublesome or tricky operations.

Starting from the top.


SCRIPT OPERATIONS

call_script
----
This operation calls a script tuple from module_scripts.py. Effectively this runs all of the operations in the script before continuing through the operations block where the call_script op was used. One of the most versatile and important operations in the module system, can be used both for very simple and very advanced things.

An important thing to note is that local variables don't carry over into the script, nor do they carry over from the script back to whatever block from which you called the script.

You can feed input to a script through the use of script parameters, which can be any numerical entry, variable or register. You can input up to two script parameters just by typing them in after the script name. See how call_script is used in Native for examples on how to do this. Alternatively you can use global variables or registers, whose values will carry over into and out of scripts.

In order for a script to output any information, it needs to store values to one or more global variables or registers.


end_try
----
This operation is deprecated. That means it's obsolete and may not be supported in future versions of M&B. You should use try_end instead.


try_end
----
This operation ends a try statement started by try_begin, try_for_range(_backwards), try_for_parties or try_for_agents.


try_begin
----
This operation opens a try statement. Try statements are handy because they let you use conditions inside them without ending the whole operations block if a non-match occurs.

Without try statements, if any condition operation in a block fails (i.e. the inputs don't match), the block is ended and all further operations in the block are ignored. However, within a try statement, if a condition operation fails, only those operations inside the try statement are ignored. The rest of the block continues running as normal after the try statement is finished.


else_try_begin
----
Another deprecated operation. Use else_try instead.


else_try
----
This operation is placed in between a try statement starter and try_end, and modifies the try statement. If any condition operation placed above the else_try fails, the else_try is activated and the game starts running all operations below the else_try. However, if all of the operations in the try statement (or other else_try) above the else_try succeed, then the else_try is ignored and the game skips straight to the next try_end.

You can have several else_trys in a single try statement. They are evaluated from top to bottom, with each else_try activating as the one above it fails. As soon as all the conditions in an else_try succeed then iit will skip to the next try_end.


try_for_range
----
This operation opens a for loop. It requires you to designate a lower bound (a beginning location) and an upper bound (an ending location) for the loop. When run, the try_for_range will loop through every number between the lower bound and the (upper bound-1).

For example, if the lower bound is 0 and the upper bound is 5, then the try_for_range will first attempt to run all its operations as 0 (contained in the destination). Then, when finished as 0, it will run all the operations again as 1, and then 2, and so on. Please note, ranges in M&B are not inclusive of the upper bound -- that means that in a range of 0 to 5, the last number it will run as is 4. Take care that you select the correct upper bound.

You can freely modify the destination variable used in try_for_range without affecting the order or health of the loops. You can also increase or decrease the upper bound if variable and the script will keep running until it reaches the modified lower or upper bound. However, do not decrease the upper bound below the current value of the destination variable.


try_for_range_backwards
----
Same as try_for_range, but instead it starts at the (upper bound-1) and runs down to the lower bound.


try_for_parties
----
Opens a try statement for every party on the overland map.


try_for_agents
----
Opens a try statement for every agent on the battle map.


store_script_param_1
----
Stores the value of the first script parameter to a destination of your choice. If left unset it will be equal to 0.


store_script_param_2
----
Stores the value of second first script parameter to a destination of your choice. If left unset it will be equal to 0.



CONDITION OPERATIONS

ge
----
Requires the first value to be greater than or equal to the second value. If this is not true then the operation fails.


eq
----
Requires the first value to be exactly equal to the second value. If this is not true then the operation fails.


gt
----
Requires the first value to be greater than the second value. If this is not true then the operation fails.


is_between
----
Requires the first value to be any number in between the designated lower bound and (upper bound-1). If this is not true then the operation fails. The same rules apply for is_between as for try_for_range, neither operation is inclusive of the upper bound. That means if you use (is_between,":variable",0,5), it will only succeed if ":variable" is equal to 0,1,2,3 or 4. It will not check 5.


entering_town
----
Succeeds when the player is beginning an encounter with a particular town.


map_free
----
Succeeds when the player is free (not resting) on the overland map.

Winter's comment: Occasionally fails to succeed for no discernible reason until you enter and leave an encounter.


encountered_party_is_attacker
----
Succeeds when the encountered party is designated as the attacker.


conversation_screen_is_active
----
Succeeds when the conversation screen is active. Can only be used in module_mission_templates.py


in_meta_mission
----
Another deprecated operation, don't use this.


troop_is_hero
----
Succeeds if the input troop is a hero (has tf_hero in troop flags).


hero_can_join
----
Succeeds if you have a free troop stack AND enough room in your party for 1 additional troop.


hero_can_join_as_prisoner
----
Succeeds if you have a free prisoner stack AND enough room in your party for 1 additional prisoner.


party_can_join
----
Succeeds if you have enough free troop stacks AND enough room in your party for all the troops of the encountered party.


party_can_join_as_prisoner
----
Succeeds if you have enough free prisoner stacks AND enough room in your party to imprison all the troops of the encountered party.


main_party_has_troop
----
Succeeds if you have the input troop in your party.


party_is_in_town
----
Succeeds if the input party is inside the input town.

Winter's comment: This operation has never worked properly when I've tried to use it. Better to bodge something with party_is_in_any_town and store_distance_to_party_from_party.


party_is_in_any_town
----
Succeeds if the input party is in any town.


party_is_active
----
Succeeds if the input party is alive.

Winter's comment: This operation seems to work intermittently sometimes, which can end up causing assertion errors when coupled with remove_party -- the game ends up trying remove parties that are already dead! Another op best left unused.


player_has_item
----
Succeeds if the player has the input item in inventory. Works only for NON-equipped items.


troop_has_item_equipped
----
Succeeds if the input troop has the input item equipped.


check_quest_active
----
Succeeds if the input quest is active.


check_quest_finished
----
Succeeds if the input quest is finished.


*_set_slot
----
These operations set a value to one of the slots attached to various entries in the game. Currently you can attach slots to troops, parties, factions, scenes, party templates, agents and quests. Each slot on each object can store data like any register or variable, and will do so permanently unless overwritten.


*_get_slot
----
Gets the contents of a slot of your choice and outputs it to the destination of your choice.


*_slot_eq
----
Succeeds if the content of the input slot on the input entry is equal to the input value.


*_slot_ge
----
Succeeds if the content of the input slot on the input entry is greather than or equal to the input value.


play_sound
----
Plays a sound of your choice.


copy_position
----
Copies the second input position to the first input position.


init_position
----
To tell you the truth? No idea.


get_trigger_object_position
----
Function nebulous, currently unused in Native. Possibly used in future versions to get the position of an item using item triggers.


get_distance_between_positions
----
Gets the distance between the two input positions and outputs it to the destination of your choice.


position_is_behind_position
----
Succeeds if the first input position is behind the second input position.


position_transform_position_to_parent
----
Hellequin explains it far better than I can in this MBXForum post: http://mbx.streetofeyes.com/index.php/topic,502.msg10495.html#msg10495


position_move_*
----
Moves the input position along the X, Y or Z axis by the input number of centimetres.


position_rotate_*
----
Rotates the input position along the X, Y or Z axis by the input number of degrees.


position_get_*
----
Gets the X, Y or Z coordinate of the input position and outputs it to a destination of your choice.


position_set_*
----
Sets the X, Y or Z coordinate of the input position to the input value.


MISSION CONDITIONS

all_enemies_defeated
----
Succeeds if all spawned enemies are unconscious or dead.


race_completed_by_player
----
Deprecated, don't use it.


num_active_teams_le
----
Succeeds if the number of active teams (i.e. the number of teams with active members) is less than or equal to the input value.


main_hero_fallen
----
Succeeds if the player is knocked unconscious.


NEGATIONS

neg
----
This is a tag that can be added to any condition operation, and it changes that condition to instead require the opposite of its usual requirements to succeed. For example, where (eq, ":variable", 1), requires ":variable" to be equal to 1 to succeed, (neg|eq, ":variable", 1), requires ":variable" to be INequal to 1 in order to succeed.


this_or_next
----
This is a tag that can be added to any condition operation, and it changes the condition to succeed if either this condition or the next condition operation in the block succeed.

It's quite possible to string loads of this_or_next-modified operations together, as long as they're in an unbroken chain. If any of the conditions in the chain succeed, they will all succeed and the script will continue running.


lt
----
Requires the first value to be less than the second value. If this is not true then the operation fails.

neq
----
Requires the first value to be inequal to the second value. If this is not true then the operation fails.


le
----
Requires the first value to be less than or equal to the second value. If this is not true then the operation fails.


CONSEQUENCE OPERATIONS


set_party_battle_mode
----
Sets battle mode to active. This means that losses taken in the following battle will be applied to the party at the end of the battle. Otherwise no losses are taken.

Please note that losses will only be taken by normally spawned troops. Any visitors or agents spawned by the spawn_agent operation do not count for losses.


start_map_conversation
----
Starts a conversation on the overland map with the input troop. Will only consider dialogue lines with the starting dialog-state "event_triggered".

Winter's comments: Slightly dodgy operation, and there are now Native scripts with the same functionality that don't use start_map_conversation. Probably best avoided.


rest_for_hours
----
Causes the input number of hours to go by quickly. The player party will disappear from the map for this period, cannot be attacked, and receives increased healing of wounds, etc.


add_xp_to_troop
----
Adds the input number of experience points to the input troop.


add_gold_as_xp
----
Old operation, possibly deprecated, should never be necessary.


add_xp_as_reward
----
Adds the input number of experience points to the player party.


add_gold_to_party
----
Adds the input amount of gold to the input party. The input party for this operation should not be the player party, use troop_add_gold for giving gold to the player.


spawn_around_party
----
Spawns a new party of the input party template around the input party. Once spawned the identifier of the spawned party is stored to reg(0).


set_spawn_radius
----
Sets the size of the radius (around the input party) at which new parties will spawn.

display_message
----
Displays a string as text to the left of the screen.


set_show_messages
----
Enables or disables showing of messages to the left of the screen.

Winter's comments: I'm not sure whether this operation actually works or not, it seems to function intermittently if at all.


tutorial_box
----
Pauses the game and pops up a small textbox in the middle of the screen, containing the input string as the main body (and a possible second input string as the box title).


question_box
----
Pauses the game and pops up a small textbox in the middle of the screen, requiring the player to click on one of two options. You can input the strings to be displayed on the option buttons. If left unset the buttons will show 'Yes' and 'No'.


reset_price_rates
----
Resets price rates to normal.


set_price_rate_for_item
----
Sets the price rate for the input item to an input percentage of its normal price rate (determined by value and trading skill).


set_price_rate_for_item_type
----
Sets the price rate for a type of input items to a percentage of their normal price rate (determined by value and trading skill).


party_join
----
Adds the input party to the player party.


party_join_as_prisoner
----
Adds the input party to the player party as prisoners.


troop_join
----
Adds the input troop to the player party. Only 1 troop is added, and a message describing the effects is displayed to the left of the screen.

troop_join_as_prisoner
----
Adds the input troop to the player party as a prisoner. Only 1 troop is added, and a message describing the effects is displayed to the left of the screen.


remove_member_from_party
----
Removes an input troop from the input party. Only 1 troop is removed, and a message describing the effects is displayed to the left of the screen.


remove_regular_prisoners
----
Removes all non-hero prisoners. Dodgy operation, may not work, and is rendered obsolete by Native scripts and other operations anyway.


remove_troops_from_companions
----
Removes an input number of troops of the input troop type from the input party. Does not remove prisoners of the same type.


remove_troops_from_prisoners
----
Removes an input number of prisoners of the input troop type from the input party. Does not remove normal troops of the same type.


heal_party
----
Restores the input party to full health.


disable_party
----
Disables the input party, hiding it from the map. Will still be a valid target for ai behaviours and can still be affected by script.


enable_party
----
Enables the input party, restoring it to the map. Parties can start out as disabled by adding the party flag pf_disabled to the party or party template.


remove_party
----
Removes the input party from the game.


add_companion_party
----
Creates a new party led by the input hero troop.


add_troop_to_site
----
Adds the input troop to the input scene at the input entry point. Becomes native to the scene, not a visitor. This automatically removes the troop from any previous attached scene.


remove_troop_from_site
----
Removes the input troop from the input scene. Does not work for visitors.


modify_visitors_at_site
----
Allows modification of visitors at the input scene.


reset_visitors
----
Removes all visitors currently at the scene.


set_visitor
----
Sets a visitor of the input troop type to the input mission template spawn entry. This operation does not set visitors directly to scene entry points.

For example, (set_visitor,":troop",3), will set ":troop" as the visitor on the fourth line in the mission template spawn record. If this spawn entry doesn't exist, or is set to use scene_source rather than visitor_source, no visitor will appear. If the spawn entry is set to the wrong entry point, the visitor will appear at the entry point specified in the spawn entry.


set_relation
----
Sets relations between the two input factions to the input value.


start_quest
----
Sets the quest status of the input quest to active.


complete_quest
----
Sets the quest status of the input quest to having been completed. Quest is no considered active.


succeed_quest
----
Sets the quest status of the input quest to having been succeeded. Quest is no considered active.


fail_quest
----
Sets the quest status of the input quest to having been failed. Quest is no longer considered active.


cancel_quest
----
Sets the quest status of the input quest to having been cancelled. Quest is no longer considered active.


set_quest_progression
----
If the input quest has the quest flag qf_show_progression, this operation sets the percentage of completion displayed in the quest screen to the input value.


setup_quest_text
----
Not entirely sure, but my guess is that it stores quest text with the current string register values, so that the quest text doesn't get corrupted by string register changes.


start_encounter
----
Starts an encounter with the input party.


leave_encounter
----
Leaves an encounter.


encounter_attack
----
Used in dialogue, sets an encounter to hostile and jumps to the attack menu.

select_enemy
----
If entering an existing battle, this operation selects which party is considered an enemy to the player.


set_passage_menu
----
New operation, function still nebulous. Possible explanation: May set a passage to jump straight to a different game menu without requiring messy mission-ending code.


end_current_battle
----
Ends the current battle. Used in Native to end battles with multiple participants.


TO BE CONTINUED . . .

18
Storymod / Storymod Chapter 2 v0.1 TECH DEMO: Release!
« on: August 31, 2007, 07:24:09 PM »
I've released a tech demo of Chapter 2 to the Mount&Blade Repository.

Please note that this is a NON-INTERACTIVE demo of the Chapter 2 war system. You can't interact with anything in any way. You will, however, be able to watch the Dalicians, Swadians and Vaegirs wage war with each other and eventually conquer each other town by town.

Please report any bugs to this thread, particularly anything odd that occurs after one or more towns have been taken over. I haven't tested much to takeover and beyond.

Download link: http://www.mbrepository.com/modules/PDdownloads/singlefile.php?cid=7&lid=505

22
Discussion / Modding War Stories
« on: August 26, 2007, 02:43:44 PM »
Back in the old days, when we had to wade through hex code to get new models into M&B, I spent 3 days getting the Magnificent 7/Hugemod items and Dablade's textures pack into Storymod 0.5's BRFs. One at a time.

Share your modding war stories here, old or new! Tell us of your hardships and we promise we won't point and laugh. Much.

23
Minor Mods / MOVED: Guardians party 1.2.3.
« on: August 25, 2007, 03:57:09 PM »

24
Storymod / Progress? Progress!
« on: August 24, 2007, 04:29:37 PM »
Against all odds, I find myself working on Chapter 2 again, and in the last 2 days I've managed to debug a large part of the war system. Scripts are starting to kick in that have never been activated before. Parties are being managed from spawn to battle, and it is good.

Today for the very first time the AI sieged, stormed and took over a town on its own. The town actually switched factions. I'm so happy I could cry!

25
Storymod / The Big W
« on: May 16, 2007, 03:48:53 AM »
It had to happen sooner or later, and now it's happened to me. The ugly spectre of gainful employment has marked me, and I've now got a day job.

This means I will have absolutely no time to port Storymod C1, and my C2 time will also be severely curtailed in favour of more important (and less frustratingly bug-ridden) projects.

I'm still looking for support scripters for Chapter 2, or even just people who want to help get Chapter 1 working on 0.808. Most of the work is rewriting the code to use slots and local variables instead of messy global variables. I've done some of this already, but it's a big tedious job that needs to be done with exacting care.

26
Discussion / Ask Winter
« on: May 03, 2007, 12:31:17 AM »
If there was ever anything you wanted to know about the module system but were afraid to ask, some obscure or complicated piece of scripting knowledge or advice that you thought would require a long trek to the dragon's lair, then look no further. This is the thread where you can ask Winter about what happens or what is needed in the dark recesses of the module system.

The only things I ask are:

1) That your questions relate to using the official module system, not to any other part of modding or modelling.

2) That you not throw me really basic stuff which is better left for the FAQ or other parts of this forum.

3) Please be specific. If you're asking about a bug in your code, try to include all related code. If you want to do something complicated, write up a full description. I can't help you if I can't make out what you want to do.

If you obey these simple rules, I'll do what I can to answer you.

27
Storymod / New Chapter 2 Screenshot
« on: April 20, 2007, 08:50:11 AM »
http://crossedswords.co.nr/stuff/storymodc2_1.jpg

I'll leave the purpose of the markers as an exercise to the reader.

Hint: It has to do with food.

28
Craftmod Community Expansion Project / Crafting system bug in 1.5!
« on: April 12, 2007, 04:20:06 AM »
Once again bugs have crept in due to wrong material values. I've finally had it with the way Craftmod handles these things, so I've now coded a little script to calculate these values dynamically, saving myself and all future Craftmod users a lot of headache.

The updated 1.5.1 source will be up on the Repository soon. Everyone playing 1.5 or using it for modding is recommended to grab this new source and compile it to fix their Craftmod installs.

29
Due to increasing life commitments, I don't think I can continue to support Craftmod. So in order to fulfill its promise and keep it alive, I'm consider making it fully open-source to anyone and everyone who's interested in downloading it (and perhaps fixing the remaining bugs).

If we go open, all versions of the Craftmod source will be released -- one version with Retainers, and one without Retainers and Retained-related systems.

Cast your vote now!

30
Discussion / Pleasant surprise for modders
« on: February 28, 2007, 07:12:19 AM »
I've recently discovered an interesting key command in M&B that's come in very handy for M&B modding. After asking Armagan about it and giving it some testing, here's my results.

Pressing CTRL+M at any time while running M&B will cause the game to reload all module information (i.e. modular text files) without having to exit and restart the game. However, this command should only be used from the game's main menu, such as after quitting your game, because otherwise it will break things quite spectacularly. Despite that little limitation, it's sped up my mod testing by a hell of a lot.

I don't know if it reloads any BRFs; this will require some testing. Either way, use it and prosper!

Cleverly,
Winter

Pages: 1 [2] 3 4