PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

Raz said:
DarkAnd said:
Raz it gave me a sintax error

tuple index out of range

and i don't use m&b dev because mi firewall blocks but i think this aren't the error
Ah, you copied the :cool: didn't you? You should quote first because there's a smiley in the code.
i quoted it
 
Below is a set of codes to make it so that your troops will actually carry the ladders to the walls and deposit them in a siege.  :cool: If the ladder carrier is killed, a new carrier will be selected and he will pick the ladder back up. To use follow the instructions below:


Add the following to module scripts:

("select_carrier",
  [(try_for_agents,reg(5)),
      (agent_is_ally,reg(5)),
      (agent_is_alive,reg(5)),
      (get_player_agent_no,":no"),
      (neq,reg(5),":no"),
      (assign,"$carrier",reg(5)),
  (end_try),]),

("ramp",
  [(agent_get_position,1,"$carrier"),
  (entry_point_get_position,2,1),
  (agent_set_scripted_destination,"$carrier",2),
  (try_begin),
      (get_distance_between_positions,":dist",1,2),
      (lt,":dist",100),
      (prop_instance_get_position,3,reg(59)),
      (prop_instance_animate_to_position,reg(60),3,50),
      (entry_point_get_position,1,1),
      (try_for_agents,reg(5)),
        (agent_is_ally,reg(5)),
        (agent_set_scripted_destination,reg(5),1),
      (end_try),
      (assign,"$ramp",1),
  (else_try),
      (position_move_y,1,-40),
      (try_begin),
        (neg|agent_is_alive,"$carrier"),
        (assign,"$ocarrier","$carrier"),
        (position_rotate_x,1,90),
        (position_move_y,1,40),
        (assign,"$ramp",-1),
        (prop_instance_animate_to_position,reg(60),1,75),
      (else_try),
        (prop_instance_animate_to_position,reg(60),1,10),
      (try_end),
      (call_script,"script_guard_carrier"),
  (try_end),]),

("guard_carrier",
  [(try_for_agents,reg(5)),
        (agent_is_alive,reg(5)),
        (agent_is_human,reg(5)),
        (agent_is_ally,reg(5)),
        (neq,reg(5),"$carrier"),
        (agent_get_position,1,"$carrier"),
        (position_move_y,1,500),
        (agent_set_scripted_destination,reg(5),1),
    (try_end),]),

("pass_ramp",
    [(agent_get_position,1,"$ocarrier"),
    (agent_set_scripted_destination,"$carrier",1),
    (agent_get_position,2,"$carrier"),
    (get_distance_between_positions,":dist",1,2),
    (lt,":dist",200),
    (assign,"$ramp",0)]),


Add the following to the castle attack mission template:

      (1.0,0,ti_once,[],[(assign,"$ramp",0),(call_script,"script_select_carrier")]),
     
      (0.1,0,0 ,[(eq,"$ramp",0)],[(call_script,"script_ramp")]),

      (0.25,0,0,[(eq,"$ramp",1)],[(call_script,"script_waypoint")]),  #you can use my script for this, but I recemend Raz's

      (2.5,0,0,[(eq,"$ramp",-1)],[(call_script,"script_select_carrier"),(call_script,"script_pass_ramp")]), 
     

Add the following to module scene props:

  ("ramp_invisible",sokf_invisible,"ramp2",0, [(ti_on_scene_prop_init,
    [(store_trigger_param_1,reg59)]),
    ]),
  ("ramp_14m",0,"ramp2","bo_ramp2", [(ti_on_scene_prop_init,
    [(store_trigger_param_1,reg60),(assign,"$ramp",-2)]),
    ]),

ramp2 is a prop I made, change this to whatever ladder you are going to use. Make sure that the invisible ramp is already in pricisely in the position you want the real ramp to fall into. I've tested this and it all works just fine. :grin: I always manage to get my carrier shot, though.
 
any ideas on this one?

I've been fiddling with the merchant restocking codes because I want vaegir and swadian merchants to hold a bias to different goods, horses, etc.  However, its gone a bit pear shaped - when I start a game, the player gets the merchant restock, but none of the goods merchants get the proper stock.  I can't work it out, to be honest....

I'm thinking about pasting the native scripts back in to replace mine...

I basically added some new ranges in the triggers module, and I've removed them all since, but still I have the probblem with the player being identified as a merchant... 

Any helpers?
 
You probably know this but, the native code use slots to track which merchant belong to the city:

Code:
(party_get_slot,reg(10),reg(2),slot_town_merchant),
(troop_add_merchandise,reg(10),itp_type_goods,num_merchandise_goods),

And the slots are initialized like this:

Code:
(party_set_slot,"p_town_1", slot_town_merchant,"trp_town_1_merchant"),

The thing is, if you forget to set the slot_town_merchant slot for a town it will be zero, and troop zero happens to be the player. My guess is you have the M&B-script equivalent of a null-pointer in your 'troop_add_merchandise' tuple.

(BTW. shouldn't questions like this go into the "Mount & Blade Mod Makers Q&A Thread" rather than the script exchange?)
 
you are prob. right about the place to post it, but to legitimise my post, here is a little something:

If you want to have eg Swadian and Vaegir merchants stocking different gear, simply add a new module constant for them:
Swadian_armormerchants_begin: "trp_bob"
Swadian_armormerchants_end: "trp_jim"

(can't remember their real ID.s)

then you can copy and paste the existing merchant refresh script, substituting "armourmerchants_begin" with "Swadian_armormerchants_begin" once, and with vaegir_armormerchants_begin the second time, etc.  Then simply tweak more crossbows in Swadian armouries, and more two-handers in Vaegir armouries, or however you want the bias to be.

Makes things a bit more interesting if you have to go find 10 crossbows as a Vaegir faction player!

The problem, I discoverd by elimination, lay with the use of centers rather than towns for the range begin/end.
 
Code:
("tutorial_question_no",[],"I want to attack Zendar.",[(jump_to_menu, "mnu_zendar"),
                                                                         ]),

I changed Zendar's faction(changed to outlaws and I deleted pf_hide_defenders) and i set 200 ninjas to city. What should I do/add?
 
Caravan said:
Code:
("tutorial_question_no",[],"I want to attack Zendar.",[(jump_to_menu, "mnu_zendar"),
                                                                         ]),

I changed Zendar's faction(changed to outlaws and I deleted pf_hide_defenders) and i set 200 ninjas to city. What should I do/add?

You want to fight  against a Zendar garrison, in Zendar, am I right?

You need to change the zendar entry in mission templates.  Copy the castle entry, and then replace references to 'castle1' with 'zendar'.

You may need to re-arrange entry points in edit mode.  Also, add some ai_limiters to stop the enemy and your own troops just mobbing each other in the town center.
 
You want to fight  against a Zendar garrison, in Zendar, am I right?
Yes.

Thank you for your help. But, when I want to attack Zendar, i don't want to see "attack"/"leave" menu. Does it make that?
 
Caravan said:
Thank you for your help. But, when I want to attack Zendar, i don't want to see "attack"/"leave" menu. Does it make that?

If you want it to be always attackable, and not actually visit it, you can add a condition block storing the encountered party and checking for zendar in module_game_menus.py. From there you can jump to the attack mission template Amman mentioned (and edit out the menu options attack/leave, heading straight to jump_to_scene so you won't have that menu popping up). If you want to check whether zendar is neutral, allied or enemy you'd need to add another check in the menu conditions block, that way you can make it possible to either visit the town or attack it, depending on player relations.
 
in the zendar menu
  (
    "zendar",mnf_auto_enter,
    "You enter the town of Zendar.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_tools",70),(set_price_rate_for_item,"itm_salt",140)],
    [
      ("zendar_enter",[],"_",[(set_jump_mission,"mt_town_default"),(jump_to_scene,"scn_zendar_center"),(change_screen_mission)],"Door to the town centre."),
      ("zendar_tavern",[],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_the_happy_boar"),
                                                   (change_screen_mission)],"Door to the tavern."),
      ("zendar_merchant",[],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_zendar_merchant"),
                                                   (change_screen_mission)],"Door to the merchant."),
      ("zendar_arena",[],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_zendar_arena"),
                                                   (change_screen_mission)],"Door to the arena."),
      ("town_1_leave",[],"_",[(leave_encounter),(change_screen_return)]),
    ]
  ),
add this
  (
    "zendar",0,
    "You enter the town of Zendar.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_tools",70),(set_price_rate_for_item,"itm_salt",140)],
    [
      ("zendar_enter",[],"_",[(set_jump_mission,"mt_town_default"),(jump_to_scene,"scn_zendar_center"),(change_screen_mission)],"Door to the town centre."),
      ("zendar_tavern",[eq,"$none",10],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_the_happy_boar"),
                                                   (change_screen_mission)],"Door to the tavern."),
      ("zendar_merchant",[eq,"$none",10],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_zendar_merchant"),
                                                   (change_screen_mission)],"Door to the merchant."),
      ("zendar_arena",[eq,"$none",10],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_zendar_arena"),
                                                   (change_screen_mission)],"Door to the arena."),
#      ("zendar_leave",[eq,"$none",10],"Leave town.",[[leave_encounter],[change_screen_return]]),
      ("town_1_leave",[],"_",[(leave_encounter),(change_screen_return)]),
    ]
  ),

this will make zendar to not be auto accessible so you have to chose a menu option and we made all options instead of enter and leave to appear only if none 10 has been assigned before you still can enter at them at the map but not thought the menu

so add a new option

  (
  (
    "zendar",0,
    "You enter the town of Zendar.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_tools",70),(set_price_rate_for_item,"itm_salt",140)],
    [
      ("zendar_enter",[],"_",[(set_jump_mission,"mt_town_default"),(jump_to_scene,"scn_zendar_center"),(change_screen_mission)],"Door to the town centre."),
      ("zendar_tavern",[eq,"$none",10],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_the_happy_boar"),
                                                   (change_screen_mission)],"Door to the tavern."),
      ("zendar_merchant",[eq,"$none",10],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_zendar_merchant"),
                                                   (change_screen_mission)],"Door to the merchant."),
      ("zendar_arena",[eq,"$none",10],"_",[(set_jump_mission,"mt_town_default"),
                                                   (jump_to_scene,"scn_zendar_arena"),
                                                   (change_screen_mission)],"Door to the arena."),
      ("attack",[
          (store_troop_health,reg(5),"trp_player"),
          (neq, "$encountered_party_friendly", 0),
          (ge,reg(5),20),
          ],
                            "Atack Zendar",[
                                (assign, "$cant_talk_to_enemy_party", 0),
                                (assign, "$cant_leave_encounter", 0),
                                (assign, "$g_battle_result", 0),
                                (assign, "$g_battle_needs_ack", 1),

                                (call_script, "script_calculate_battle_advantage", "p_collective_enemy", "p_collective_ally"),
                                (set_battle_advantage, reg0),
                                (set_party_battle_mode),
                                (set_jump_mission,"mt_lead_charge"),
                                (jump_to_scene,"scn_zendar_center"),
                                (change_screen_mission),
                                ]),
      ("town_1_leave",[],"_",[(leave_encounter),(change_screen_return)]),
    ]
  ),
so you will be able to attack zendar if it is enemy and you have enough health to a battle
also you can change the scene and you still wil fitgh zendar's garrison
PS:I am sleeping whit the eyes opened now i am 10% sure I missed something
 
Some stupid little thing;
Cursed Shotgun

Item
Code:
["cursedshotty", "Cursed Shotgun", [("shotgun",0)], itp_type_musket |itp_merchandise|itp_primary ,itcf_shoot_musket|itcf_reload_pistol|itcf_carry_sword_back, 5000 , weight(1.5)|difficulty(0)|spd_rtng(125) | shoot_speed(200) | thrust_damage(120 ,pierce)|max_ammo(7)|accuracy(93),imodbits_none,
 [(ti_on_init_item,[(set_position_delta,0,45,0),(particle_system_add_new, "psys_muzzle"), (particle_system_add_new, "psys_pistol_smoke")]),
  (ti_on_weapon_attack, [(play_sound,"snd_shot_pump"),(particle_system_emit, "psys_muzzle", 10),(call_script,"script_fallbackcurse",1,20)])]],


Script
Code:
("fallbackcurse",
[
		       (get_player_agent_no, ":player_agent"),
                       (ge, ":player_agent", 0),
                       (agent_set_animation, ":player_agent", anim_fall_head_front)
]),
 
Here's a question / idea.

I want to have all my troops (NPCs, regulars, etc) issued with steel shields when I reach  faction rank Knight.

Can I do this?  And, if so, how?

I know (I think!) how to do it for a defined troop using trp_add_item, but can I set a search or condition for my party, and then produce a 'troop_z' where 'z' = member of player party?

Alternatively, if I create a special upgrade-troop, and have a daily check trigger to equip them with steel shields, that should work too, right?
 
It's unlikely.
You can think about troops as about templates - recipes how to build and equip an agent.
That means, a troop is never really a member of a party, instead, a party can contain a number of references to a troop template.

A workaround might be to define another troop variant with shield and the same name as the basic one following the original, and when the conditions are met replace all the occurences of "trp_id" in your party with "trp_id" + 1 variant.

Maybe in the next wersion when toop dna wil be more developed it will be more feasible.
 
OK - so if I had a trigger for Swadian Knight, trp_add_item(steel shield) then ALL swadian knights get the shield?  There is no way of confining it to troops who are my party members?

I'll have a fiddle with non-AI upgraded troops, see what I can do, but.... might have to wait one.. or two... versions
 
Amman de Stazia said:
I'll have a fiddle with non-AI upgraded troops, see what I can do, but.... might have to wait one.. or two... versions

You might as well create a new troop id, with the same characteristics of the swadian knights, but equipped with steel shields.

You can make a trigger activate the script that will check whether the faction rank is knight or not. If it is, it will replace the current swadian knights for your own new swadians with the shield. I haven't tested this, but it should work. Let me know if it doesn't.

("player_knights",

[

(party_count_members_of_type,reg(0),"p_main_party","trp_swadian_knight"),

(try_begin),
[eq,"$faction_rank", 6],
(eq|main_party_has_troop,"trp_swadian_knight"),
(party_remove_members,"p_main_party","trp_swadian_knight",reg(0)),
(party_add_members,"p_main_party","trp_player_knights",reg(0)),
(end_try),

]),

I've used trp_player_knights as the new id as an example.
 
Hi,

I have a question about mission templates.

What are these?
# in header_mission_templates.py
aisb_hold    = 0
aisb_hit_run  = 1
aisb_flock    = 2
aisb_race    = 3
aisb_patrol  = 4

I want to make some of soldiers in my castle patrol my castle. Should I use "aisb_patrol"?
If I have to use that, how do I use that?
 
I'm not 100% sure, but most probably they are not used.
I tried to use these flags in the past but they did nothing.

If you want your agents to patrol, you have to set up a set of waypoints for them, and make them walk with  agent_set_scripted_destination
 
Lynores - thanks...  What I am currently trialling is as follows:

  #  re equip player troops 
  (2.0, 0, 1.0,
  [
      (eq,"$playershield1",1),
      ],
  [
      (troop_ensure_inventory_space,"trp_playermanatarms1" ,1),
      (troop_ensure_inventory_space,"trp_playerinfantry1" ,1),
      (troop_ensure_inventory_space,"trp_playermanatarms3" ,1),
      (troop_ensure_inventory_space,"trp_playerinfantry2" ,1),
      (troop_ensure_inventory_space,"trp_playerarcher1" ,1),
      (troop_ensure_inventory_space,"trp_playerarcher2" ,1),
      (troop_ensure_inventory_space,"trp_playerkhergit1" ,1),
      (troop_ensure_inventory_space,"trp_playerkhergit2" ,1),
      (troop_ensure_inventory_space,"trp_playerkhergit3" ,1),
      (troop_ensure_inventory_space,"trp_fighter_woman" ,1),
      (troop_ensure_inventory_space,"trp_sword_sister" ,1),
      (troop_add_item,"trp_playermanatarms1" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerinfantry1" ,"itm_shield_town1",),
      (troop_add_item,"trp_playermanatarms3" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerinfantry2" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerarcher1" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerarcher2" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerkhergit1" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerkhergit2" ,"itm_shield_town1",),
      (troop_add_item,"trp_playerkhergit3" ,"itm_shield_town1",),
      (troop_add_item,"trp_fighter_woman" ,"itm_shield_town1",),
      (troop_add_item,"trp_sword_sister" ,"itm_shield_town1",),     
    ]
  ),
all troops are only available to the player, and each town has a distinct shield.  Basically, if the count of town 1 promotes you knight, condition playershield1 is set active.... etc.
 
Back
Top Bottom