Python scripting questions

Users who are viewing this thread

Tooff

Squire
hi, how can i code this:
when player attack bandits, other closest bandits join the battle(like a kingdoms allies or enemy parties)
 
Tooff said:
hi, how can i code this:
when player attack bandits, other closest bandits join the battle (like a kingdoms allies or enemy parties)

hmmm... the logic of what i think you need to do is below.

get player party xy location
try for parties within a certain distance of that xy (at the same time check faction alleigence)

then either -

A) add parties suitable parties as companion parties or
B) intereigate the party stack add the troops to the encountered party (remembering to destroy the party that is being added to the conflict)

Look in header_operations for correct commands.

I seem to remember seeing a flag in header_mission_templates that said whether or not other parties could join the battle - not sure what that does so check it out :wink: it might do the same thing but I doubt it - world time stops when your in scenes like battles or villages.
 
i found it in module_scripts.py  under "let_nearby_parties_join_current_battle"
Code:
("let_nearby_parties_join_current_battle",
    [
      (assign, ":enemy_party_no", "$g_encountered_party"),
      (try_for_parties, ":party_no"),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", ai_bhvr_in_town),

        (assign, ":join_distance", 5),
        (try_begin),
          (is_currently_night),
          (assign, ":join_distance", 3),
        (try_end),
      
        (store_distance_to_party_from_party, ":distance", ":party_no", "p_main_party"),
        (lt, ":distance", ":join_distance"),

        (store_faction_of_party, ":faction_no", ":party_no"),
        (store_faction_of_party, ":enemy_faction", ":enemy_party_no"),
        (store_relation, ":reln_with_player", ":faction_no", "fac_player_faction"),
        (store_relation, ":reln_with_enemy", ":faction_no", ":enemy_faction"),

        (try_begin),
      #TODO: Fix this
          (lt, ":reln_with_player", 0),
          (gt, ":reln_with_enemy", 0),
          (party_get_slot, ":party_type", ":party_no"),
          (eq, ":party_type", spt_kingdom_hero_party),
          (get_party_ai_behavior, ":ai_bhvr", ":party_no"),
          (neq, ":ai_bhvr", ai_bhvr_avoid_party),
          (party_quick_attach_to_current_battle, ":party_no", 1), #attach as enemy
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_enemy"),
        (else_try),
      #TODO: Fix this
          (gt, ":reln_with_player", 0),
          (lt, ":reln_with_enemy", 0),
          (party_get_slot, ":party_type", ":party_no"),
          (eq, ":party_type", spt_kingdom_hero_party),
          (party_stack_get_troop_id, ":leader", ":party_no", 0),
          (troop_get_slot, ":player_relation", ":leader", slot_troop_player_relation),
          (ge, ":player_relation", 0),
          (party_quick_attach_to_current_battle, ":party_no", 0), #attach as friend
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_friend"),
        (try_end),
      (try_end),
  ]),
but what i need to place for bandits?
 
I havent tested this out, so there are probably errors and you need to test it, but something like this:

("let_nearby_parties_join_current_battle",
    [
      (assign, ":enemy_party_no", "$g_encountered_party"),
      (try_for_parties, ":party_no"),
        (party_get_battle_opponent, ":eek:pponent",":party_no"),
        (lt, ":eek:pponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", ai_bhvr_in_town),

        (assign, ":join_distance", 5),
        (try_begin),
          (is_currently_night),
          (assign, ":join_distance", 3),
        (try_end),
     
        (store_distance_to_party_from_party, ":distance", ":party_no", "p_main_party"),
        (lt, ":distance", ":join_distance"),

        (store_faction_of_party, ":faction_no", ":party_no"),
        (store_faction_of_party, ":enemy_faction", ":enemy_party_no"),
        (store_relation, ":reln_with_player", ":faction_no", "fac_player_faction"),
        (store_relation, ":reln_with_enemy", ":faction_no", ":enemy_faction"),

        (try_begin),
      #TODO: Fix this
          (lt, ":reln_with_player", 0),
          (gt, ":reln_with_enemy", 0),
          (party_get_slot, ":party_type", ":party_no"),
          (eq, ":party_type", spt_kingdom_hero_party),
          (get_party_ai_behavior, ":ai_bhvr", ":party_no"),
          (neq, ":ai_bhvr", ai_bhvr_avoid_party),
          (party_quick_attach_to_current_battle, ":party_no", 1), #attach as enemy
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_enemy"),
        (else_try),                  #add this red stuff in this exact spot in this script
          (lt, ":reln_with_player", 0),
          (gt, ":reln_with_enemy", 0), # I am not sure about this because I do not know what relationship bandits will have with each other.  if this doesnt work change gt to ge
          (party_get_template_id,":party_template",":party_no"),
          (is_between,":party_template",bandits_begin,bandits_end),
          (get_party_ai_behavior, ":ai_bhvr", ":party_no"),
          (neq, ":ai_bhvr", ai_bhvr_avoid_party),
          (party_get_slot,":protected_until_hours", ":party_no",slot_party_ignore_player_until),
          (store_current_hours,":cur_hours"),
          (store_sub, ":protection_remaining",":protected_until_hours",":cur_hours"),
          (le, ":protection_remaining", 0)
          (party_quick_attach_to_current_battle, ":party_no", 1), #attach as enemy
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_enemy"),

        (else_try),
      #TODO: Fix this
          (gt, ":reln_with_player", 0),
          (lt, ":reln_with_enemy", 0),
          (party_get_slot, ":party_type", ":party_no"),
          (eq, ":party_type", spt_kingdom_hero_party),
          (party_stack_get_troop_id, ":leader", ":party_no", 0),
          (troop_get_slot, ":player_relation", ":leader", slot_troop_player_relation),
          (ge, ":player_relation", 0),
          (party_quick_attach_to_current_battle, ":party_no", 0), #attach as friend
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_friend"),
        (try_end),
      (try_end),
  ]),

In module party templates, have all of your bandit parties grouped together, ex:
("forest_bandits",  blah blah blah),
("steppe_bandits", blah blah blah),
("river_pirates", blah blah blah),

In module constants add this near village_elders_end
bandits_begin = "pt_"  # after pt_ put the first bandit party template here.
bandits_end = "pt_"  # after pt_ put the party template that is after the last bandit party

Or instead of messing with the stuff in module constants and party templates, and instead of using this line in the script: (is_between,":party_template",bandits_begin,bandits_end), you could store the party's faction and make a check to see if it is of the outlaw/bandit faction. Ex:
use (store_faction_of_party, ":party_faction", ":party_no"),
(eq, ":party_faction", "fac_"), # after fac_ put the faction
 
grailknighthero ! thank you ,it`s work, all nearly bandits join the battle
Code:
(else_try),                  #add this red stuff in this exact spot in this script
          (lt, ":reln_with_player", 0),
          (gt, ":reln_with_enemy", 0), 
          (party_get_template_id,":party_template",":party_no"),
          (is_between,":party_template",bandits_begin,bandits_end),
          (get_party_ai_behavior, ":ai_bhvr", ":party_no"),
          (neq, ":ai_bhvr", ai_bhvr_avoid_party),
#          (party_get_slot,":protected_until_hours", ":party_no",slot_party_ignore_player_until),
#          (store_current_hours,":cur_hours"),
#          (store_sub, ":protection_remaining",":protected_until_hours",":cur_hours"),
#          (le, ":protection_remaining", 0)
          (party_quick_attach_to_current_battle, ":party_no", 1), #attach as enemy
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_enemy"),
i just comments 4 lines coz does it need.
 
question:
How to reduce the siege time for AI,so they can take the town or castle about 3 or 5 days?
and one more:
when right click on nearly party i see "move here" and "notes" buttons, how can i add  command "follow" to there, means the player not move in ,just follow.
Code:
  ("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),
  ]),
 
If you look, there isnt anything else like this in the stickied portion of the forum.  All this is is simple coding anyway.  There is no reason for it to be stickied, otherwise everything else should be.
 
I made Altair from Assassins Creed with all the clothes and stuff, so now I want to feel like Altair :grin:
http://img75.imageshack.us/my.php?image=mountbladeassassinscreezm4.jpg
So, here are the questions:

Is it possible to make player jump higher?

Any script that makes player an enemy to all factions? So, you can't go to towns without being noticed?

Is it possible to change the looting skill to sneak skill and modify it a little bit? So, the higher sneak skill you have, the guards in towns will not see you?

And of course, some sort of an assassination quest.

-Teshin
 
Back
Top Bottom