login

Author Topic: Random Notes  (Read 25429 times)

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: Random Notes
« Reply #15 on: October 30, 2007, 09:55:35 AM »
Nice.  Copying a snippet (simplified for clarity for just the bit that would apply here) from my Schattenlander code, here's how to do a bell-curve scatter centered on the aim point.  Cf. Schattenlander source, module_throwing_code, line 840.
Code: [Select]
(agent_get_slot, ":Scatter", ":Owner", throw_inaccuracy), # Value from 0 (theoretical only, proficiency 1000) to 25 (proficiency zero), tending to be 15-23 for most realistic proficiencies.

(store_add, ":ScatterUpperLim", ":Scatter", 1),
(store_mul, ":ScatterLowerLim", ":Scatter", -1),

(try_for_range, ":Iter", 0, 20),  # Worst possible scatter (zero skill, horrible luck) is 5m (20 iters x 25cm ea) in each of X and Y.  It's a strong bell curve, though, likely to tend toward way, *way* less.
(store_random_in_range, ":Delta_x", ":ScatterLowerLim", ":ScatterUpperLim"),
(position_move_x, landing_position, ":Delta_x"),
(store_random_in_range, ":Delta_y", ":ScatterLowerLim", ":ScatterUpperLim"),
(position_move_y, landing_position, ":Delta_y"),
(try_end),

It's called a "Drunkard's Walk" in random number theory and it converges to a bell curve.  Many iterations, each of which is a straight random number (such as between -25 and +25 in this example, worst case).  I could look up what the "probable" range is, but I believe it'll be somewhere around a third of the worst case in a setup like this one, depending on how you define "probably".

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #16 on: October 30, 2007, 10:38:28 AM »
replace_scene_props seems be to be only working with ti_before_mission >:( mesa angrysa
« Last Edit: October 31, 2007, 06:50:49 AM by KON_Air »

Offline fujiwara

  • Master
  • *****
  • Posts: 858
    • View Profile
Re: Random Notes
« Reply #17 on: November 06, 2007, 12:46:17 PM »
Ah, the random walk. I'm using something similar to try and come up with a terrain generator.

The horses tend to get their legs caught in the catapult rather than being properly launched.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #18 on: December 30, 2007, 06:22:17 AM »
When (change_screen_buy_mercenaries) is called from a menu the buy mercenaries screen is underlaid the menu, thus effectively locking the game in the menu with no way to return to world map or select an option from the menu, only way to get rid of it is quitting the game.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #19 on: January 05, 2008, 04:24:18 AM »
Do not edit AI Meshes with active AIs (town walkers, warring troops... etc, but regular visitors (merchants, etc, one that don't move) won't cause any problems.)!

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Repeat_for_troops sample
« Reply #20 on: February 15, 2008, 07:05:12 AM »
Since you're asking for repeat_for_items over on the Taleworlds board, I assume you understand how the repeat_for_xxx works. Can you enlighten us? Thanks!

Sure. It's not too difficult, really.

Essentially a repeated dialogue entry iterates over every tuple of the specified type, like a try_for_range for the whole list of troops/factions/parties. You store the currently accessed tuple to a destination by using store_repeat_object. Then you add conditionals to the conditions block as per a normal dialogue entry, for example reading the repeat object's slots, in order to fail entries/hide ones that aren't applicable.

The repeat option will display a dialogue menu option for every tuple which meets all the conditionals, so you have to make sure the game doesn't end up with too many to display, or you'll end up with an assert.

A sample from Modplosion!

This one lists all your companions currently in your party as dialouge options and when that option is selected that troop is registered to "$hero_to_train";

Quote
[trp_combat_teac|plyr|repeat_for_troops,"ask_which_to_train", [
(store_repeat_object, ":troop_no"),
(is_between, ":troop_no", companions_begin, companions_end),
(main_party_has_troop,":troop_no"),
(str_store_troop_name, s1, ":troop_no")],
   "{s1}", "other_train",[(store_repeat_object, "$hero_to_train")]],


Offline fujiwara

  • Master
  • *****
  • Posts: 858
    • View Profile
Re: Random Notes
« Reply #21 on: February 15, 2008, 03:55:32 PM »
I have the same sort of thing in OnR, only implemented as separate dialog options for each troop. This will simplfy things immensely, and opens up opportunities elsewhere

The horses tend to get their legs caught in the catapult rather than being properly launched.

Offline Winter

  • I am Tek Jansen!
  • Administrator
  • *****
  • Posts: 476
  • MBX Forum owner
    • View Profile
    • Street of Eyes: The Writing of Ryan A. Span
Re: Random Notes
« Reply #22 on: February 15, 2008, 05:22:55 PM »
I have the same sort of thing in OnR, only implemented as separate dialog options for each troop. This will simplfy things immensely, and opens up opportunities elsewhere

Yeah. Personally I've hijacked repeat_for_troops to work for items, so that Craftmod crafting item selection now takes one dialogue option. Just one. It is beauty.

I've been using it in Storymod C2 for ages as well, for my rumours system. Quite handy.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Random Party Namer
« Reply #23 on: March 20, 2008, 09:49:08 AM »
A quickie, that can be applied to all party names, but this one is just for player party.
Script
Code: [Select]
  ("random_name",
    [
(store_random_in_range, ":word_num", 2,20),
(store_random_in_range, ":first", p_names_1_begin, p_names_1_end),
(store_random_in_range, ":second", p_names_1_begin, p_names_1_end),
(store_random_in_range, ":third", p_names_1_begin, p_names_1_end),
(store_random_in_range, ":fourth", p_names_2_begin, p_names_2_end),
(str_store_string, s1, ":first"),
(str_store_string, s2, "@_"),
(str_store_string, s3, ":fourth"),
(str_store_string, s4, "@_"),
(str_store_string, s5, "@_"),
(str_store_string, s6, "@_"),
(str_store_string, s7, "@_"),
(try_begin),
(gt, ":word_num", 7),
        (str_store_string, s1, ":first"),
(str_store_string, s2, "@_"),
(str_store_string, s3, ":third"),
(str_store_string, s4, "@_"),
        (str_store_string, s5, ":fourth"),
(str_store_string, s6, "@_"),
        (str_store_string, s7, "@_"),
(try_end),
(try_begin),
(gt, ":word_num", 10),
(str_store_string, s1, ":second"),
(str_store_string, s2, "@_"),
(str_store_string, s3, ":first"),
(str_store_string, s4, "@_"),
(str_store_string, s5, ":third"),
(str_store_string, s6, "@_"),
         (str_store_string, s7, ":fourth"),
(try_end),
(str_store_string, s50, "str_custom_p_name"),
     ]),

name samples
Code: [Select]
#constant p_names_1_begin
("p_name_1", "Deadly"),
("p_name_2", "Holy"),
("p_name_3", "Angry"),
("p_name_4", "Godly"),
("p_name_5", "Noble"),
#constant p_names_2_begin
("p_name_11", "Knights"),
("p_name_12", "Peasants"),
("p_name_13", "Pirates"),
("p_name_14", "Ninjas"),
("p_name_15", "Vikings"),

The dialouge for it
Code: [Select]
      [trp_fancy_trader,"fancy_name", [],
   "Our Elders shall decide a name for you.",    "fancy_name_list",[]],
   
         [trp_fancy_trader|plyr,"fancy_name_list", [],
   "I'll accept whatever name they see fit for me.",    "fancy_name_list2",[]],
   
      [trp_fancy_trader,"fancy_name_list2", [(call_script, "script_random_name"),
  (str_store_string, s4, s50),],
   "Elders decided that your army name shall be known as {s4}.",    "close_window",[(party_set_name, "p_main_party", s4),]],

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Custom Banner Creation
« Reply #24 on: April 29, 2008, 06:10:36 PM »
As I figured it out without peeking at module system, it will be really simple;

Three meshes for banner as a scene prop, Short, Tall, Square and three more for Icon mesh.

And Charges (symbols) have a mesh for them stored in module_meshes.py.

The all custom banner building is done within prsnt_custom_banner, which creates a material in tableau meshes. So the tableau meshes (ie. preset banner used on shields and tabards) are actually a bunch of meshes put on top of each (which unless is later exported as a 2d image is a probable resource hog in 950).

So if you want to make custom banners peek at custom_banner_charges.dds, start doing your own charges!
And the mod to take peek at how custom banner creation will work follow the link;
http://forums.taleworlds.net/index.php/topic,35742.0.html
« Last Edit: April 29, 2008, 07:41:40 PM by KON_Air »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #25 on: June 23, 2008, 06:12:26 AM »



Har, har, I'm awesome and I know it :P
Nothing complicated or elegant but regardless...

How to make set items;
First decide which items you want to a part of set. Breaking the order of Module_items and moving them to the bottom of the list is recommended if you are going to make them available as merchandise, that way they will be on top of the merchants inventory.

In this example I chose Light Leather Set, which is the most obivious choice.

Second Step is to set extra item texts see below (add those to script_game_get_item_extra_text);

Code: [Select]
(else_try),
        (is_between, ":item_no", set1_begin, set1_end), #Those are defined in constants itm_black_hood and itm_itm_byzantion_helmet_a
(try_begin),
          (eq, ":extra_text_id", 0),
          (set_result_string, "@Light Leather Set:^+1 Power Draw When Complete"),
          (set_trigger_result, 0xffc125),  #Always Gold
  (else_try),
  (eq, ":extra_text_id", 1),
  (set_result_string, "@_"), #The second line, empty, could have been the second line of first id...
  (set_trigger_result, 0xc4c4c4),
(else_try),
  (eq, ":extra_text_id", 2),
(try_begin),
(troop_get_inventory_slot,":head","trp_player",ek_head),
(eq, ":head", "itm_black_hood"),
(set_result_string, "@Black Hood"),
(set_trigger_result, 0x00ff7f), #Green Equipped By Player
(else_try),
(troop_get_inventory_slot,":head","$g_talk_troop",ek_head),
(eq, ":head", "itm_black_hood"),
(set_result_string, "@Black Hood"),
(set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
(else_try),
  (set_result_string, "@Black Hood"),
  (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
(try_end),

(else_try),
(eq, ":extra_text_id", 3),
(try_begin),
(troop_get_inventory_slot,":head","trp_player",ek_body),
(eq, ":head", "itm_light_leather"),
(set_result_string, "@Leather Armour"),
(set_trigger_result, 0x00ff7f), #Green Equipped By Player
(else_try),
(troop_get_inventory_slot,":head","$g_talk_troop",ek_body),
(eq, ":head", "itm_light_leather"),
(set_result_string, "@Leather Armour"),
(set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
(else_try),
  (set_result_string, "@Leather Armour"),
  (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
(try_end),

(else_try),
  (eq, ":extra_text_id", 4),
(try_begin),
(troop_get_inventory_slot,":head","trp_player",ek_foot),
(eq, ":head", "itm_light_leather_boots"),
(set_result_string, "@Leather Boots"),
(set_trigger_result, 0x00ff7f), #Green Equipped By Player
(else_try),
(troop_get_inventory_slot,":head","$g_talk_troop",ek_foot),
(eq, ":head", "itm_light_leather_boots"),
(set_result_string, "@Leather Boots"),
(set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
(else_try),
  (set_result_string, "@Leather Boots"),
  (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
(try_end),

So as you could have figured it out we make a inventory slot check to see if item is properly equipped, if you want weapons in set items use a (try_for_range, ":cur_slot", 0, 4), so you will pick up :cur_slot as any of the weapon slots (see Fisheyes Chart; http://mbx.streetofeyes.com/index.php/topic,972.0.html).

What we have so far is when an item of the set is equipped the Gray text turns Green or Blue. And when put back into inventory Green Or Blue become Gray.

Now, next step far easier goes into  script_game_get_skill_modifier_for_troop
Code: [Select]
(else_try),
(eq, ":skill_no", "skl_power_draw"),
(troop_get_inventory_slot,":cur_item1",":troop_no",ek_head),
(troop_get_inventory_slot,":cur_item2",":troop_no",ek_body),
(troop_get_inventory_slot,":cur_item3",":troop_no",ek_foot),
(eq, ":cur_item1", "itm_black_hood"),
(eq, ":cur_item2", "itm_light_leather"),
(eq, ":cur_item3", "itm_light_leather_boots"),
      (val_add, ":modifier_value", 1), 

Again we use inventory slot checks to make sure player has items in the proper slots and we do the rest just like books. So if a troop (player, companions... any troop) has all items in proper slots will get the bonus. (Note to self; Use incremental bonuses like 2 items give +1 full set gives +3... etc.)

Conclusion; M&B:Diablo was apperantly possible since .903 :P

grailknighthero

  • Guest
Re: Random Notes
« Reply #26 on: June 24, 2008, 04:35:14 AM »
Awesome!  This will be very useful for me once 1.0 comes out and I start the main work for my mod back up again.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #27 on: June 25, 2008, 08:21:12 AM »
A better version for more then one set;
(extra text id 7 is lie)

Code: [Select]
#Set items;
(try_begin),
 (eq, ":extra_text_id", 0),
 (try_begin),
 (troop_get_inventory_slot,":head","trp_player",ek_head),
 (eq, ":head", "itm_black_hood"),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Black Hood"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_head),
 (eq, ":head", "itm_black_hood"),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Black Hood"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 (else_try),
 (troop_get_inventory_slot,":head","trp_player",ek_head),
 (eq, ":head", "itm_khergit_set3"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Helmet"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_head),
 (eq, ":head", "itm_khergit_set3"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Helmet"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 (else_try),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Black Hood"),
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Helmet"),
 (try_end),
 (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
 (try_end),

 (else_try),
 (eq, ":extra_text_id", 1),
 (try_begin),
 (troop_get_inventory_slot,":head","trp_player",ek_body),
 (eq, ":head", "itm_light_leather"),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Leather Armour"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_body),
 (eq, ":head", "itm_light_leather"),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Leather Armour"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 (else_try),
 (troop_get_inventory_slot,":head","trp_player",ek_body),
 (eq, ":head", "itm_khergit_set1"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Armour"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_body),
 (eq, ":head", "itm_khergit_set1"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Armour"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 
 (else_try),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Leather Armour"),
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Armour"),
 (try_end),
 (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
 (try_end),

 
 (else_try),
 (eq, ":extra_text_id", 2),
 (try_begin),
 (troop_get_inventory_slot,":head","trp_player",ek_foot),
 (eq, ":head", "itm_light_leather_boots"),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Leather Boots"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_foot),
 (eq, ":head", "itm_light_leather_boots"),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Leather Boots"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 (else_try),
 (troop_get_inventory_slot,":head","trp_player",ek_foot),
 (eq, ":head", "itm_khergit_set2"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Boots"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_foot),
 (eq, ":head", "itm_khergit_set2"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Boots"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 
 (else_try),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@Leather Boots"),
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Boots"),
 (try_end),
 (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
 (try_end),

 (else_try),
 (eq, ":extra_text_id", 3),
 (try_begin),
 (troop_get_inventory_slot,":head","trp_player",ek_horse),
 (eq, ":head", "itm_khergit_set4"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Horse"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player
 (else_try),
 (troop_get_inventory_slot,":head","$g_talk_troop",ek_horse),
 (eq, ":head", "itm_khergit_set4"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Horse"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 
 (else_try),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@_^Worn by Watchtower Rangers.^This uniform offers protection without^hindering movement^+1 Atheletics For Full Set."),
 (set_trigger_result, 0xffc125), # Gold - Last item of Set 1
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Horse"),
 (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
 (try_end),
 (try_end),
 
 (else_try),
 (eq, ":extra_text_id", 4),
 (try_begin),
 (troop_get_inventory_slot,":head0","trp_player",ek_item_0),
 (troop_get_inventory_slot,":head1","trp_player",ek_item_1),
 (troop_get_inventory_slot,":head2","trp_player",ek_item_2),
 (troop_get_inventory_slot,":head3","trp_player",ek_item_3),
 (this_or_next|eq, ":head0", "itm_khergit_set5"),
 (this_or_next|eq, ":head1", "itm_khergit_set5"),
 (this_or_next|eq, ":head2", "itm_khergit_set5"),
 (eq, ":head3", "itm_khergit_set5"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Bow"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player

 (else_try),
 (troop_get_inventory_slot,":head0","$g_talk_troop",ek_item_0),
 (troop_get_inventory_slot,":head1","$g_talk_troop",ek_item_1),
 (troop_get_inventory_slot,":head2","$g_talk_troop",ek_item_2),
 (troop_get_inventory_slot,":head3","$g_talk_troop",ek_item_3),
 (this_or_next|eq, ":head0", "itm_khergit_set5"),
 (this_or_next|eq, ":head1", "itm_khergit_set5"),
 (this_or_next|eq, ":head2", "itm_khergit_set5"),
 (eq, ":head3", "itm_khergit_set5"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Bow"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 
 (else_try),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@_"),
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Bow"),
 (try_end),
 (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
  (try_end),
 
 
 (else_try),
 (eq, ":extra_text_id", 5),
 (try_begin),
 (troop_get_inventory_slot,":head0","trp_player",ek_item_0),
 (troop_get_inventory_slot,":head1","trp_player",ek_item_1),
 (troop_get_inventory_slot,":head2","trp_player",ek_item_2),
 (troop_get_inventory_slot,":head3","trp_player",ek_item_3),
 (this_or_next|eq, ":head0", "itm_khergit_set6"),
 (this_or_next|eq, ":head1", "itm_khergit_set6"),
 (this_or_next|eq, ":head2", "itm_khergit_set6"),
 (eq, ":head3", "itm_khergit_set6"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Spear"),
 (set_trigger_result, 0x00ff7f), #Green Equipped By Player

 (else_try),
 (troop_get_inventory_slot,":head0","$g_talk_troop",ek_item_0),
 (troop_get_inventory_slot,":head1","$g_talk_troop",ek_item_1),
 (troop_get_inventory_slot,":head2","$g_talk_troop",ek_item_2),
 (troop_get_inventory_slot,":head3","$g_talk_troop",ek_item_3),
 (this_or_next|eq, ":head0", "itm_khergit_set6"),
 (this_or_next|eq, ":head1", "itm_khergit_set6"),
 (this_or_next|eq, ":head2", "itm_khergit_set6"),
 (eq, ":head3", "itm_khergit_set6"),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Spear"),
 (set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
 
 (else_try),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@_"),
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@Outrider Spear"),
 (try_end),
 (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
  (try_end),
 
 (else_try),
 (eq, ":extra_text_id", 6),
 (try_begin),
 (is_between, ":item_no", set1_begin, set1_end), #If Set 1
 (set_result_string, "@_"),
 (else_try),
 (is_between, ":item_no", set2_begin, set2_end), #If Set 2
 (set_result_string, "@^Worn by famous Outriders.^These items provide everything a light cavalary needs.^+1 Power Draw^+1 Horse Archery For Full Set"),
 (try_end),
 (set_trigger_result, 0xffc125),
 (try_end),

 
 (try_end),

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Universal Troop Costumizing System (With Save Feature!)
« Reply #28 on: September 01, 2008, 07:42:35 PM »
Not tested throughly, but surely doesn't function as intended during a mission. Best done via menus.

What universal means is that it can re-equip any troop (except heroes) via a Paper Doll Troop. You may be asking why a second troop is required, my idea was to have manequinns in shops but it seems it will be a bit tricky to do now... but still, it will work great with menus and party talk.

It will also save equipped items in slots_ so equipped troops will recall their equipment after a saved game is loaded.

Code: [Select]
  #script_paper_doll_prep
  # INPUT: arg1 = Troop which will be used as paper dool arg2 = Troop which will be equipped
  # OUTPUT: Equalizes the skills and stats of the source troop with target troop
("paper_doll_prep", [
       (store_script_param_1, ":paper_doll"),
       (store_script_param_2, ":paper_doll_equipped"),
#Remove Stats and Skills
     (troop_raise_attribute, ":paper_doll", ca_strength, -1000),
(troop_raise_attribute, ":paper_doll", ca_agility, -1000),
     (troop_raise_skill, ":paper_doll", skl_shield, -1000),
     (troop_raise_skill, ":paper_doll", skl_riding, -1000),
     (troop_raise_skill, ":paper_doll", skl_power_throw, -1000),
     (troop_raise_skill, ":paper_doll", skl_power_draw, -1000),
#Get Stats and Skills
(store_attribute_level,":pe_str",":paper_doll_equipped",ca_strength),
(store_attribute_level,":pe_agi",":paper_doll_equipped",ca_agility),
(store_skill_level,":pe_skl1",skl_shield,":paper_doll_equipped"),
(store_skill_level,":pe_skl2",skl_riding,":paper_doll_equipped"),
(store_skill_level,":pe_skl3",skl_power_throw,":paper_doll_equipped"),
(store_skill_level,":pe_skl4",skl_power_draw,":paper_doll_equipped"),
#Replace Stats and Skills
     (troop_raise_attribute, ":paper_doll", ca_strength, ":pe_str"),
(troop_raise_attribute, ":paper_doll", ca_agility, ":pe_agi"),
     (troop_raise_skill, ":paper_doll", skl_shield, ":pe_skl1"),
     (troop_raise_skill, ":paper_doll", skl_riding, ":pe_skl2"),
     (troop_raise_skill, ":paper_doll", skl_power_throw, ":pe_skl3"),
     (troop_raise_skill, ":paper_doll", skl_power_draw, ":pe_skl4"),
#Change Gender
        (troop_get_type, ":is_female", ":paper_doll_equipped"),
        (try_begin),
          (eq, ":is_female", 1),
          (troop_set_type,":paper_doll",1),
        (else_try),
          (troop_set_type,":paper_doll",0),
        (try_end),
#Now equip what target troop has
(call_script, "script_paper_doll_execute", ":paper_doll_equipped", ":paper_doll"),

]),

  #script_paper_doll_price_get
  # INPUT: arg1 = Troop which will be used as paper dool arg2 = Troop which will be equipped.
  # OUTPUT: $paper_doll_equipped_surlups = Money that will return from previous items $paper_doll_equipped_expense = Money required to equip new items.
("paper_doll_price_get", [
       (store_script_param_1, ":paper_doll"),
       (store_script_param_2, ":paper_doll_equipped"),
(try_for_range, ":slot_no", 0, 9),#exclude food,
(troop_get_inventory_slot,":cur_item",":paper_doll",":slot_no"),
(neq, ":cur_item", -1),
(store_item_value, ":cur_item_value", ":cur_item"),
(store_mul, ":expense", ":cur_item_value", 50),
(val_add, "$paper_doll_equipped_expense", ":expense"),
(try_end),

(try_for_range, ":slot_no", 0, 9),#exclude food,
(troop_get_inventory_slot,":old_item",":paper_doll_equipped",":slot_no"),
(neq, ":old_item", -1),
(store_item_value, ":old_item_value", ":old_item"),
(store_mul, ":surlups", ":old_item_value", 25),
(val_add, "$paper_doll_equipped_surlups", ":surlups"),
(try_end),

#Debug... Might be useful...
# (assign, reg0, "$paper_doll_equipped_surlups"),
# (assign, reg1, "$paper_doll_equipped_expense"),
# (str_store_string, s33, "@Surplus: {reg0}"),
# (str_store_string, s34, "@Expense: {reg1}"),
# (display_message, "@{s33} {s34}"),
]),

  #script_paper_doll_execute
  # INPUT: arg1 = Troop which will be used as paper dool arg2 = Troop which will be equipped.
  # OUTPUT: Equips target troop with items from Source Troop
("paper_doll_execute", [
       (store_script_param_1, ":paper_doll"),
       (store_script_param_2, ":paper_doll_equipped"),
(troop_clear_inventory,":paper_doll_equipped"),
(try_for_range, ":slot_no", 0, 9),#exclude food,
(troop_get_inventory_slot,":cur_item",":paper_doll",":slot_no"),
(troop_get_inventory_slot,":old_item",":paper_doll_equipped",":slot_no"),
(try_begin),
(neq, ":cur_item", -1),
(troop_get_inventory_slot_modifier, ":item_modifier", ":paper_doll", ":slot_no"),
(troop_add_item, ":paper_doll_equipped", ":cur_item", ":item_modifier"),
(else_try),
(neq, ":old_item", -1), #my first legacy code... Not that it functions or anything.
(troop_remove_item, ":paper_doll_equipped", ":old_item"),
(try_end),
(try_end),
(troop_equip_items, ":paper_doll_equipped"),
(call_script, "script_paper_doll_memorize", ":paper_doll_equipped"),

]),

  #script_paper_doll_memorize
  # INPUT: arg1 = Troop which is equipped via paper doll
  # OUTPUT: Stores equipped items and their modifiers in slots
("paper_doll_memorize", [
       (store_script_param_1, ":paper_doll_equipped"),
#Get items
(assign, ":slot_no", ek_item_0),
(try_for_range, ":mem_slot_no", slot_troop_item_memory_1, slot_troop_item_memory_1_mod),
(troop_get_inventory_slot,":cur_item",":paper_doll_equipped", ":slot_no"),
(troop_set_slot, ":paper_doll_equipped", ":mem_slot_no", ":cur_item"),
(val_add, ":slot_no", 1),
(try_end),
 
#Get modifiers
(try_for_range, ":mem_slot_no", slot_troop_item_memory_1_mod, slot_troop_item_memory_end),
(troop_get_inventory_slot_modifier, ":item_modifier", ":paper_doll_equipped", ":slot_no"),
(troop_set_slot, ":paper_doll_equipped", slot_troop_item_memory_1_mod, ":item_modifier"),
(val_add, ":slot_no", 1),
(try_end),


]),
  #script_paper_doll_recall
  # INPUT: arg1 = Troop to be re-equipped
  # OUTPUT: none
("paper_doll_recall", [
(store_script_param_1, ":paper_doll_equipped"),
#Clearing all
(troop_clear_inventory,":paper_doll_equipped"),
(try_for_range, ":slot_no", slot_troop_item_memory_1, slot_troop_item_memory_1_mod),
(troop_get_slot,":cur_item",":paper_doll_equipped",":slot_no"),

#Do Not Want A Loop Inside A Loop... I'd Rather Copy/Pasta
(try_begin),
(eq, ":slot_no", slot_troop_item_memory_1),
(assign, ":cur_modifier", slot_troop_item_memory_1_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_2),
(assign, ":cur_modifier", slot_troop_item_memory_2_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_3),
(assign, ":cur_modifier", slot_troop_item_memory_3_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_4),
(assign, ":cur_modifier", slot_troop_item_memory_4_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_5),
(assign, ":cur_modifier", slot_troop_item_memory_5_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_6),
(assign, ":cur_modifier", slot_troop_item_memory_6_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_7),
(assign, ":cur_modifier", slot_troop_item_memory_7_mod),
(else_try),
(eq, ":slot_no", slot_troop_item_memory_8),
(assign, ":cur_modifier", slot_troop_item_memory_8_mod),
(else_try),#you will never know
(assign, ":cur_modifier", 0),
(try_end),

(troop_add_item, ":paper_doll_equipped", ":cur_item", ":cur_modifier"),
(try_end),
(troop_equip_items, ":paper_doll_equipped"),]),


Code: [Select]
slot_troop_item_memory_1 = 59
slot_troop_item_memory_2 = 60
slot_troop_item_memory_3 = 61
slot_troop_item_memory_4 = 62
slot_troop_item_memory_5 = 63
slot_troop_item_memory_6 = 64
slot_troop_item_memory_7 = 65
slot_troop_item_memory_8 = 66
slot_troop_item_memory_9 = 67

slot_troop_item_memory_1_mod = 68
slot_troop_item_memory_2_mod = 69
slot_troop_item_memory_3_mod = 70
slot_troop_item_memory_4_mod = 71
slot_troop_item_memory_5_mod = 72
slot_troop_item_memory_6_mod = 73
slot_troop_item_memory_7_mod = 74
slot_troop_item_memory_8_mod = 75
slot_troop_item_memory_9_mod = 76
slot_troop_item_memory_end = 77 #ninja slot, I think I have a use for it...
« Last Edit: September 02, 2008, 12:53:10 AM by KON_Air »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Universal Troop Costumizing System (With Save Feature!)
« Reply #29 on: September 02, 2008, 12:49:12 AM »
Sample use for UTCS;

Used for testing, the camp menu, has a hidden tiny mod called Simulation :P it eventually crashes game around 700~ days, a weaker Cpu may crash sooner;
Code: [Select]
  ("camp",mnf_scale_picture,
   "You set up camp. What do you want to do?",
   "none",
   [
     (assign, "$g_player_icon_state", pis_normal),
     (set_background_mesh, "mesh_pic_camp"),
    ],
    [
      ("camp_action_1",[(eq,"$cheat_mode",1)],"Cheat: Walk around.",
       [(set_jump_mission,"mt_ai_training"),
        (call_script, "script_setup_random_scene"),
        (change_screen_mission),
        ]
       ),
      ("camp_action",[],"Take an action.",
       [(jump_to_menu, "mnu_camp_action"),
        ]
       ),
      ("camp_action3",[],"Modifiy Paper Doll For Troop",
       [
(call_script, "script_paper_doll_prep", "trp_costum_maker", "trp_custom_1"),

                                (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
                                (set_visitor,0,"trp_player"),
                                (set_visitor,17,"trp_costum_maker"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation_scene"),
            (assign, "$talk_context", tc_custom_equip),
(assign, "$troop_to_equip", "trp_custom_1"),
(change_screen_map_conversation, "trp_costum_maker"),

        ]
       ),
      ("camp_action2",[],"Modifiy Paper Doll For Mercenary",
       [
(call_script, "script_paper_doll_prep", "trp_costum_maker", "trp_custom_a"),

                                (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
                                (set_visitor,0,"trp_player"),
                                (set_visitor,17,"trp_costum_maker"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation_scene"),
            (assign, "$talk_context", tc_custom_equip),
(assign, "$troop_to_equip", "trp_custom_a"),
(change_screen_map_conversation, "trp_costum_maker"),

        ]
       ),
         ("camp_action12",[],"Modifiy Paper Doll For Bodyguard",
       [
(call_script, "script_paper_doll_prep", "trp_costum_maker", "trp_custom_b"),

                                (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
                                (set_visitor,0,"trp_player"),
                                (set_visitor,17,"trp_costum_maker"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation_scene"),
            (assign, "$talk_context", tc_custom_equip),
(assign, "$troop_to_equip", "trp_custom_b"),
(change_screen_map_conversation, "trp_costum_maker"),

        ]
       ),
         ("camp_action22",[],"Modifiy Paper Doll For Sword Daughter",
       [
(call_script, "script_paper_doll_prep", "trp_costum_maker", "trp_custom_2"),

                                (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
                                (set_visitor,0,"trp_player"),
                                (set_visitor,17,"trp_costum_maker"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation_scene"),
            (assign, "$talk_context", tc_custom_equip),
(assign, "$troop_to_equip", "trp_custom_2"),
(change_screen_map_conversation, "trp_costum_maker"),

        ]
       ),

   
      ("camp_action7",[],"Recall All Paper Doll Equipment (use after loading a saved game).",
       [
   (call_script, "script_paper_doll_recall", "trp_custom_1"),
   (call_script, "script_paper_doll_recall", "trp_custom_a"),
   (call_script, "script_paper_doll_recall", "trp_custom_2"),
   (call_script, "script_paper_doll_recall", "trp_custom_b"),
   (change_screen_return),
        ]
       ),
      ("camp_action8",[],"Give Custom Troops (20 at a time).",
       [
(party_add_members, "p_main_party", "trp_custom_1", 5),
(party_add_members, "p_main_party", "trp_custom_a", 5),
(party_add_members, "p_main_party", "trp_custom_2", 5),
(party_add_members, "p_main_party", "trp_custom_b", 5),
(change_screen_return),
        ]
       ),
      ("camp_wait_here",[],"Wait here for some time.",
       [
           (assign,"$g_camp_mode", 1),
#           (assign,"$auto_menu","mnu_camp"),
           (assign, "$g_player_icon_state", pis_camping),
           (rest_for_hours_interactive, 72, 5, 1), #rest while attackable
           (change_screen_return),
        ]
       ),
      ("camp_wait_here2",[],"Simulation Mode",
       [
           (assign,"$g_camp_mode", 1),
#           (assign,"$auto_menu","mnu_camp"),
           (assign, "$g_player_icon_state", pis_camping),
         (rest_for_hours_interactive, 99999999999, 500, 0), #rest while not attackable
           (change_screen_return),
        ]
       ),
      ("camp_cheat",
       [(eq, "$cheat_mode", 1)
        ], "CHEAT MENU!",
       [(jump_to_menu, "mnu_camp_cheat"),
        ],
       ),
      ("resume_travelling",[],"Resume travelling.",
       [
           (change_screen_return),
        ]
       ),
      ]
  ),


Now the dialouge (note you should add tc_custom_equip constant, if not already);

Code: [Select]
  [anyone,"start", [(eq, "$talk_context", tc_custom_equip)],
   "Click To Acess Paper Doll.", "ct_equip", [(change_screen_equip_other)]],
  [anyone,"ct_equip", [],
   "Executing script_paper_doll_execute and closing window.", "close_window", [(jump_to_menu, "mnu_auto_apply_paper_doll"),]],

back to menus, because script_paper_doll_execute won't work when call inside a mission template

Code: [Select]
    ("auto_apply_paper_doll",mnf_auto_enter,
   "Apply Changes To The Latest Troop",
   "none",
   [],
    [
   ("camp_kappa", [], "Apply Changes To The Latest Troop", [
(call_script, "script_paper_doll_execute", "trp_costum_maker", "$troop_to_equip"),
(jump_to_menu, "mnu_camp"),
   ]),  ]),


Also added this to the paper_doll_prep, incase you are already playing with the script;
Code: [Select]
#Change Gender
        (troop_get_type, ":is_female", ":paper_doll_equipped"),
        (try_begin),
          (eq, ":is_female", 1),
          (troop_set_type,":paper_doll",1),
        (else_try),
          (troop_set_type,":paper_doll",0),
        (try_end),