login

Author Topic: Random Notes  (Read 25173 times)

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Random Notes
« on: September 02, 2007, 08:41:28 AM »
Just notes nothing else;

Equipment more then just Inventory Chest on Random scenes.
You can add any scene prop to random scene(s) but they will always keep their coordiantes so thye might be floating next time generated or remain under the terrain. But there is one lovely thing in scene props goes as "place at the origin", which is also used by the inventory chest, so you can place stuff more stuff around inventory chest, they would look nice unless you get to start on a steep hill. A way to hide them is moving them under the surface (problem here is multimeshed props don't move), but another way will be avaible by spawn_prop command which will be avaible in next version. But if the prop that will be added requires specific terrain conditions (such as siege weaponary, command tent... etc would require flat terrain to look good but if player don't have any of these so the terrain can become more random), we will have to define characteristic of the scene (flatter terrain, less rivers and trees etc) which can be done with relative ease by altering combat start dialogues or even simplier by game menus.

Another trick is making the scene props origin lets say T is tent and I is inventory chest. To have Tent next to chest (T..I) the Tent meshes origin will have to be (..) away from the tent itself. etc etc...

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #1 on: September 10, 2007, 03:09:56 PM »
Funny little thing you probably already know;

At troop headers;
Code: [Select]
tf_upgrade3_mask = 0x0000FF0000000000
tf_upgrade3_bits     = 40
tf_upgrade2_mask     = 0x00FF000000000000
tf_upgrade2_bits     = 48
tf_upgrade_mask      = 0xFF00000000000000
tf_upgrade_bits      = 56
...

def upgrades3_to(upgraded_troop_no):
  if upgraded_troop_no >= 256:
        upgraded_troop_no = 0
  return ((bignum | upgraded_troop_no) << tf_upgrade3_bits) & tf_upgrade3_mask
...
def upgrade3(troops,troop1_id,troop2_id,troop3_id,troop4_id):
  troop1_no = find_troop(troops,troop1_id)
  troop2_no = find_troop(troops,troop2_id)
  troop3_no = find_troop(troops,troop3_id)
  troop4_no = find_troop(troops,troop4_id) 
  if (troop1_no == -1):
    print "Error with upgrade3 def: Unable to find troop1-id: " + troop1_id
  elif (troop2_no == -1):
    print "Error with upgrade3 def: Unable to find troop2-id: " + troop2_id
  elif (troop3_no == -1):
    print "Error with upgrade3 def: Unable to find troop3-id: " + troop3_id
  elif (troop4_no == -1):
    print "Error with upgrade3 def: Unable to find troop4-id: " + troop4_id
  else:
    troops[troop1_no][3] = upgrades3_to(troop4_no) | upgrades2_to(troop3_no) | upgrades_to(troop2_no) | (~(tf_upgrade2_mask|tf_upgrade_mask|tf_upgrade3_mask) & troops[troop1_no][3])

The picture below is what happens if you have four arguments (base, upgrade 1, upgrade 2), if I have all arguments there is no error, so I assume bits and mask values are correct.

So, it works but the third slot won't be visible at the party screen, I'll try to rescale those buttons meshes, maybe it is because of their sizes?
« Last Edit: September 10, 2007, 03:11:34 PM by KON_Air »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #2 on: September 20, 2007, 06:58:25 AM »
Notes to the future;
At the bottom of the troops.txt there is the quick battle player, does it mean that troop becomes players? Is there a posses command in new version?

Presentations file! Does it mean I can go ahead and make Gimmick Arena more like UT and get rid of world map?
« Last Edit: September 20, 2007, 10:10:10 AM by Fisheye »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #3 on: September 26, 2007, 03:58:21 AM »
Non Square texture work with .89x! But they still have to be squares of 2! Wee!

Offline Cartread

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #4 on: October 02, 2007, 04:19:20 PM »
It looks like the "No lighting" flag is now disabled.  That means all models go through time-of-day lighting and can never be fully intense.
Also, the torch scene prop no longer adds_light and there are new scene props: light, light_night, light_red and light_sun which do the lighting in scenes.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #5 on: October 03, 2007, 02:00:18 PM »
Not really a script, how to get player kills/wounds
#Gets count of wounded troops by player
   (get_player_agent_kill_count, reg9, 1),
#Get count of killed troops by player
   (get_player_agent_kill_count, reg10, 0),
then you can use reg9 as a string via {reg9}... etc.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #6 on: October 03, 2007, 06:00:58 PM »
Context menu is somewhere around #1668 line in module_scripts called   #script_game_context_menu_get_buttons

  #script_game_context_menu_get_buttons:
  # This script is called from the game engine when the player clicks the right mouse button over a party on the map.
  # INPUT: arg1 = party_no
  # OUTPUT: none, fills the menu buttons
  ("game_context_menu_get_buttons",
   [(store_script_param, ":party_no", 1),
    (try_begin),
      (neq, ":party_no", "p_main_party"),
      (context_menu_add_item, "@Move here", cmenu_move),
    (try_end),
    (try_begin),
      (is_between, ":party_no", centers_begin, centers_end),
      (context_menu_add_item, "@View notes", 1),
    (else_try),
      (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
      (gt, ":num_stacks", 0),
      (party_stack_get_troop_id, ":troop_no", ":party_no", 0),
      (is_between, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end),
      (context_menu_add_item, "@View notes", 2),
    (try_end),
  ]),

  #script_game_event_context_menu_button_clicked:
  # This script is called from the game engine when the player clicks on a button at the right mouse menu.
  # INPUT: arg1 = party_no, arg2 = button_value
  # OUTPUT: none
  ("game_event_context_menu_button_clicked",
   [(store_script_param, ":party_no", 1),
    (store_script_param, ":button_value", 2),
    (try_begin),
      (eq, ":button_value", 1),
      (change_screen_notes, 3, ":party_no"),
    (else_try),
      (eq, ":button_value", 2),
      (party_stack_get_troop_id, ":troop_no", ":party_no", 0),
      (change_screen_notes, 1, ":troop_no"),
    (try_end),
  ]),

Super sweet

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #7 on: October 03, 2007, 06:43:59 PM »
Don't tell there is an operation to emit particles on worldmap and keep telling people that it was caused by a failed experiment with torches or villagers did it.

Confused? I'm talking about this:
http://forums.taleworlds.net/index.php/topic,27130.msg679234.html#msg679234
« Last Edit: October 03, 2007, 07:46:11 PM by Fisheye »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #8 on: October 04, 2007, 07:21:27 PM »
How replace tavern visitors with others for dummies. Probably nobody here needs that. I must be in some kind of depression because I don't remember myself coding such tedious stuff in 4.30 Am...

go to constants, add;
to the bottom of slots
slot_center_mercenary_troop_type2 = 141 (I chose those numbers so no other slot_... has the same ones)
slot_center_mercenary_troop_amount2 = 142

then I'll add them to refresh script,

Code: [Select]
  ("update_mercenary_units_of_towns",
    [(try_for_range, ":town_no", towns_begin, towns_end),
      (store_random_in_range, ":troop_no", mercenary_troops_begin, mercenary_troops_end),
      (store_random_in_range, ":troop_no2", mercenary_troops_begin, mercenary_troops_end),
      (party_set_slot, ":town_no", slot_center_mercenary_troop_type, ":troop_no"),
      (party_set_slot, ":town_no", slot_center_mercenary_troop_type2, ":troop_no2"),
      (store_random_in_range, ":amount", 3, 8),
  (store_random_in_range, ":amount2", 3, 8),
      (party_set_slot, ":town_no", slot_center_mercenary_troop_amount, ":amount"),
      (party_set_slot, ":town_no", slot_center_mercenary_troop_amount2, ":amount2"),
    (try_end),
     ]),

now go to game menus;
see that under "visit tavern";

Code: [Select]
             (modify_visitors_at_site,reg(11)),(reset_visitors),
             (party_get_slot, ":mercenary_troop", "$current_town", slot_center_mercenary_troop_type),
             (party_get_slot, ":mercenary_amount", "$current_town", slot_center_mercenary_troop_amount),
             (try_begin),
               (gt, ":mercenary_amount", 0),
               (set_visitor, 17, ":mercenary_troop"),
             (try_end),
             
             (try_begin),
               (party_get_slot, ":companion_candidate", "$current_town", slot_center_companion_candidate),
               (gt, ":companion_candidate", 0),
               (troop_slot_eq, ":companion_candidate", slot_troop_occupation, 0),
               (set_visitor, 18, ":companion_candidate"),
             (try_end),

now I'd usually go with blunt approach and add a new entry point to a tavern and then tell you to do it in all taverns but I didn't...

see companion candidate? now there are few of them and don't show up frequently any way.
the (gt, ":companion_candidate", 0), tells me that this "try" will fail if there are 0 or less companions candidates chosen.
So I'll go ahead and add an new "try" (else_else) in that try, which will succed and add slot_center_mercenary_troop_type2 instead of canditate, if there are 0 candidates chosen other wise fail.

Code: [Select]
             (try_begin),
               (party_get_slot, ":companion_candidate", "$current_town", slot_center_companion_candidate),
               (gt, ":companion_candidate", 0),
               (troop_slot_eq, ":companion_candidate", slot_troop_occupation, 0),
               (set_visitor, 18, ":companion_candidate"),
   (else_try),
   (gt, ":mercenary_amount2", 0), #if there are mercs (hired, left) they will show up
               (set_visitor, 18, ":mercenary_troop2"),
             (try_end),

but ohnoes! I forgots to assign :mercenary_amount2, :mercenary_troop2 variables!

So I add it under the first ones and the whole thing looks like this now
Code: [Select]
             (party_get_slot, ":mercenary_troop", "$current_town", slot_center_mercenary_troop_type),
             (party_get_slot, ":mercenary_amount", "$current_town", slot_center_mercenary_troop_amount),
(party_get_slot, ":mercenary_troop2", "$current_town", slot_center_mercenary_troop_type2),
             (party_get_slot, ":mercenary_amount2", "$current_town", slot_center_mercenary_troop_amount2),
             (try_begin),
               (gt, ":mercenary_amount", 0),
               (set_visitor, 17, ":mercenary_troop"),
             (try_end),
             
             (try_begin),
               (party_get_slot, ":companion_candidate", "$current_town", slot_center_companion_candidate),
               (gt, ":companion_candidate", 0),
               (troop_slot_eq, ":companion_candidate", slot_troop_occupation, 0),
               (set_visitor, 18, ":companion_candidate"),
   (else_try),
   (gt, ":mercenary_amount2", 0),
               (set_visitor, 18, ":mercenary_troop2"),
             (try_end),

Ok I've been missing the sad fact that you still need to add dialogues for each slot_merc.... in dialogues file :P Just copy/paste original one and edit the values accordingly :P

If you don't you get to hire slot 1 regardless who you are talking to :P Sorry.

DO DIALOGUES


Well there are few things,
it turned out to be almost identical to grailknightheros one :P
you can edit merc. conversation (for example volunteers one and their price)
and I believe I've explained a lot of stuff.
« Last Edit: October 06, 2007, 04:16:00 PM by KON_Air »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #9 on: October 09, 2007, 09:17:41 AM »
Dang! You can start/end/fail quests in mission templates... Why didn't I think of that before?

Code: [Select]
  (
    "sir_kran_quest",mtf_arena_fight,-1,
    "You barge into the tavern.",
    [
#Don't delete them or add, match to the happy boars entries
      (0,mtef_visitor_source|mtef_team_0,0,aif_start_alarmed,1,[]),
      (1,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
      (2,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
      (3,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
      (4,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
      (5,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
      (6,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
      (7,mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
    ],
    [

      (ti_tab_pressed, 0, 0, [],
       [(question_box,"str_give_up_fight")]),
      (ti_question_answered, 0, 0, [],
       [(store_trigger_param_1,":answer"),(eq,":answer",0),(jump_to_scene,"scn_zendar_center"),(display_message,"str_kran_retreat")]),
      (1, 3, ti_once, [(main_hero_fallen,0)],
       [(jump_to_scene,"scn_zendar_center"),
   (display_message,"str_kran_again")
   ]),
      (1, 3, ti_once, [(store_mission_timer_a,reg(1)),(ge,reg(1),1),(num_active_teams_le,1),(neg|main_hero_fallen,0)],
       [(jump_to_scene,"scn_the_happy_boar"),
   (display_message,"str_kran_complete"),
   (troop_add_item, "trp_player","itm_sovereign",imod_balanced),
(call_script, "script_end_quest", "qst_sir_kran"),
(try_begin),
(eq,"$loveaurlon",1),
    (setup_quest_text,"qst_sir_kran_love"),
(str_store_string, s2, "@ You are faced and made Sir Kran run away in shame. Go tell Aurlon that her revenge has been taken. You can also propose her marriage if you go buy a ring from local merchant."),

(str_store_troop_name,s0,"trp_aurlon"),
    (setup_quest_giver, "qst_sir_kran_no_love", "str_s0"),
(call_script, "script_start_quest", "qst_sir_kran_no_love","trp_aurlon"),
   (assign,"$sir_kran_quest",2),
(else_try),
    (setup_quest_text,"qst_sir_kran_no_love"),
(str_store_string, s2, "@ You are faced and made Sir Kran run away in shame. Go tell Aurlon that her revenge has been taken."),

(str_store_troop_name,s0,"trp_aurlon"),
    (setup_quest_giver, "qst_sir_kran_no_love", "str_s0"),
(call_script, "script_start_quest", "qst_sir_kran_no_love","trp_aurlon"),
   (assign,"$sir_kran_quest",3),
(try_end),
   ]),
      (ti_inventory_key_pressed, 0, 0, [(display_message,"str_cant_use_inventory_arena")], []),
    ],
  ),

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #10 on: October 17, 2007, 06:32:10 AM »
A lot better camera control code, sure still needs tweaking but this time makes the player stay put (thought didn't test the horse one) and uses game_keys!

Code: [Select]
#set camera switch just to be sure
(ti_before_mission_start, 0, 0, [], [(assign,"$camera_mode",0),(assign,"$xmax",0),]),
   #camera toggle
(0, 0, 0,
      [(key_clicked, key_numpad_0)],
  [
  (try_begin),
       (eq,"$camera_mode",0),
   (mission_cam_set_mode,1),
   (assign,"$camera_mode",1),
   (get_player_agent_no, ":player_agent"),
(agent_get_position,pos20,":player_agent"),
#high enough
(position_move_z,pos20,700),
#far enough
(position_move_y,pos20,-100),
    (mission_cam_set_position, pos20),
   (else_try),
   (eq,"$camera_mode",1),
   (mission_cam_set_mode,0),
   (assign,"$camera_mode",0),
(assign,"$xmax",0),
   (end_try),
        ]),

#This will render player immobile playing anim_unused_human_anim_1 (edited to last 0,1 so when camera mode returns player won't notice there was an animation playing) repeatedly while $camera_mode is 1.
(0,0,0, [(eq,"$camera_mode",1)],
[
(get_player_agent_no, ":player_agent"),
(agent_get_horse, ":horse_agent", ":player_agent"),
(agent_set_animation, ":player_agent", anim_unused_human_anim_1),
(try_begin),
(ge, ":horse_agent", 0),
(agent_set_animation, ":horse_agent", anim_unused_horse_anim_1),
(try_end),
]),
#Move camera
#Z? Forward/Backward
(0, 0, 0,
      [(game_key_is_down, gk_move_forward)],[
  (position_move_y,pos20,7),
  (mission_cam_animate_to_position,pos20),
  ]),
(0, 0, 0,
      [(game_key_is_down, gk_move_backward)],[
  (position_move_y,pos20,-7),
  (mission_cam_animate_to_position,pos20),]),
#X? Sides
(0, 0, 0,
      [(game_key_is_down, gk_move_left)],
  [(position_move_x,pos20,-7),
  (mission_cam_animate_to_position,pos20),]),
(0, 0, 0,
      [(game_key_is_down, gk_move_right),
  (position_move_x,pos20,7),
  (mission_cam_animate_to_position,pos20),],[]),
#Rotate up and down
(0, 0, 0,
#Make sure other rotation keys don't work
      [(key_is_down, key_mouse_scroll_up)],
 
  [(position_rotate_x,pos20,-30),
  (mission_cam_animate_to_position,pos20),
  (val_sub, "$xmax", -30),]),
(0, 0, 0,
      [(key_is_down, key_mouse_scroll_down)],
 
  [(position_rotate_x,pos20,30),
  (mission_cam_animate_to_position,pos20),
  (val_add, "$xmax", 30),]),
#fix camera
(0, 0, 0,
      [(game_key_clicked, gk_jump)],
  [
  (val_mul, "$xmax", -1),
  (position_rotate_x,pos20,"$xmax"),
  (mission_cam_animate_to_position,pos20),
  ]),

anim codes;

 ["unused_horse_anim_1", 0,
 [0.1, "anim_horse", horse_move+2000, horse_move+2001, arf_cyclic]],
 ["unused_human_anim_1", 0,
  [0.1, "anim_human", 90, 100, arf_cyclic]],
« Last Edit: October 17, 2007, 06:46:17 AM by KON_Air »

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #11 on: October 29, 2007, 05:39:24 AM »
I was messing around to make an artillery, and this is how it works (note it kills everyone on the scene other then player, next step will to be to kill everyone in an area);

(get_player_agent_no, ":player_agent"),
(try_for_agents, ":artykill"),
(neq, ":artykill", ":player_agent"),
(agent_is_alive, ":artykill"),
(agent_deliver_damage_to_agent, ":player_agent", ":artykill", 100),
 (try_end),

What's the point of this post? It is (agent_deliver_damage_to_agent, ":player_agent", ":artykill", 100), This is how you kill agents, 100 means %100 of hit points (I'm not %100 sure about that but 100 killed river pirates :P) of the agents will be delivered as damage, messages comes up as a regular weapon hit "X hit Y for Z damage" and "X killed Y"

Edit; 100 is direct damage, has nothing to do with agents health and is effected by armor of agent.
« Last Edit: October 29, 2007, 06:12:42 AM by KON_Air »

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: Random Notes
« Reply #12 on: October 29, 2007, 10:20:34 AM »
Thanks, KON_Air.  That was the thing I was wondering about that op.

Note from my previous work, I assume it's still this way in the new version... if the agent is at zero HP, then he dies as soon as he takes any hit - even one which does zero damage.  So if you want to do damage which ignores armour, you can probably use:
Code: [Select]
(agent_get_hit_points, ":agent_hp", ":tgt_agent", const_absolute), # Absolute = 1, relative = 0.
(val_sub, ":agent_hp", ":damage_value_ignoring_armour"),
(val_max, ":agent_hp", 0),
(agent_set_hit_points, ":this_agent", ":agent_hp", const_absolute),
(agent_deliver_damage_to_agent", ":source_agent", ":tgt_agent", 0),
... basically using the deliver_damage to force a check for "is it dead".

Have you checked whether (set_show_messages) works on the damage output messages?

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #13 on: October 29, 2007, 02:13:46 PM »
Something else I noticed that makes that script even more awesome and suitable for Diablo like battle skills (namely shield bash, power attack, cleave (ok those are mostly from D&D)), the damage given to player by this trigger is also relative to difficulty :shock: So, if someone makes AI use such skills lower difficulty players won't be suffering unexpected super damages.

I am yet to test set_show_messages but damages given by this trigger already generate messages.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Artillery
« Reply #14 on: October 30, 2007, 08:10:32 AM »
A piece of the working artillery script by the stuff from above,
note; jeep_yellow can be anything, I'll use a flare with red smoke in final to point the targeted area and move around an invisible prop/entry to land the shell so the attack won't be %100 acc., to have a visual confirmation I'm using it :P
Code: [Select]
("cf_arty_kill",[
(play_sound, "snd_arty_land"),
(get_player_agent_no, ":player_agent"),
(agent_is_alive, ":player_agent"),
(scene_prop_get_instance,"$artywaypoint","spr_jeep_yellow",0),
(prop_instance_get_position, pos11, "$artywaypoint"),
 #This is backup
 (prop_instance_get_position, pos7, "$artywaypoint"),
(try_for_agents,":cur_agent"),
# (neq, ":cur_agent", ":player_agent"),
(agent_is_alive, ":cur_agent"),
(agent_is_human, ":cur_agent"),
(agent_get_position, pos21, ":cur_agent"),
(get_distance_between_positions,":artysplash",pos11,pos21),
(try_begin),
(lt,":artysplash",1000),
(agent_deliver_damage_to_agent, ":player_agent", ":cur_agent", 100),
(try_end),
(try_end),
]),

What does this script lacks is accuracy setting, I have stuck those into a mission template to see them easier, will migrate all the stuff into the script, so to give you an idea how to work on a not %100 acc. artillery;

Code: [Select]
(0,0,0, [(key_clicked, key_space), (eq, "$arty_shot", 2)],[
 (play_sound, "snd_arty_shoot"),
 (prop_instance_get_position, pos2, "$artywaypoint"),
 (store_random_in_range, "$landingzone", -500, 501),


 (position_move_y,pos2,"$landingzone"),
 (position_move_x,pos2,"$landingzone"),
 (prop_instance_animate_to_position, "$artywaypoint", pos2, 1),
 (prop_instance_animate_to_position, "$artyshell", pos2, 50),
(assign, "$arty_shot", 1),
 ]),

Currently lacks particles will update this post when I make up my mind and experiment with new operand that replaces scene props.

also I'm yet to test position_set_z_to_ground_level I'm not sure how exactly it works :P
« Last Edit: October 30, 2007, 08:24:25 AM by KON_Air »

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),

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Stationary Horses
« Reply #30 on: October 12, 2008, 11:35:01 PM »
Stationary Horses Without Riders In Battlefield

Mission Template
     (0.1, 0, 0,
      [
(try_for_agents, ":cur_agent"),
  (agent_is_alive, ":cur_agent"), #so we don't try dead agents
    (neg|agent_is_human,":cur_agent"), #agent is a horse
      (agent_get_rider,":cur_rider", ":cur_agent"),
        (lt, ":cur_rider", 0), #horse does not have a rider
  (agent_set_animation, ":cur_agent", "anim_unused_horse_anim_1"), #so the horse doesn't move, must include module_animations at the top
(try_end),
      ], []),


Animations
 ["unused_horse_anim_1", 0, [1.0, "anim_horse", 0, 1, 0]],

Kon_Air & HokieBT For Speeder Bikes in M&B Starwars Mod

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Village Recruits According to The Villages Faction
« Reply #31 on: October 12, 2008, 11:36:13 PM »
in menu recruit_volunteers,

this will give the preset,
(party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),

replace that line with this;
(store_faction_of_party, ":cur_faction", "$current_town"),
(faction_get_slot, ":volunteer_troop", ":cur_faction", slot_faction_tier_1_troop),

grailknighthero

  • Guest
Re: Random Notes
« Reply #32 on: October 13, 2008, 06:21:02 PM »
Another way is to have it so a center's culture is changed when it is taken over.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #33 on: November 04, 2008, 03:07:18 PM »
Town Cultures are just slot values incase you didn't notice :P Just look for the script that changes its faction and add it there.

Offline KON_Air

  • Craftsman
  • **
  • Posts: 110
    • View Profile
Re: Random Notes
« Reply #34 on: November 17, 2008, 05:46:00 PM »
Don't teach monkeys how to play poker and then cheat while gambling with them.