Author Topic: Random Notes  (Read 24829 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 »