PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

Distinct Heraldry
(NOT custom heraldry... really)
This set of scripts does the following:
on reaching faction rank of Knight, 20 town_shields are dropped in the zendar chest*.  You can equip NPCs and yourself with them.          *I have renamed Zendar Dhorak in the scripts below...  easily changed back....
All the top-tier upgrades (plyr -prefixed troops) are equipped with one of the same town_shield.
Every town has a different shield, and NONE of the AI troops are equipped with it.
Result - every one of your elite troops carries a shield with a distinct design, matching that of yourself and your NPC companions.

The script can be adjusted to allow ALL non-AI troops to receive the shield.
It can, theoretically, be used for a surcoat or plumed helmet as well/instead of a shield...
It cannot force troops to equip the shield.  If they use a two-hander or bow, the shields are redundant.   I have not used 'guarantee shield' with my plyr-troops, because they do not have ANY shield to start with (this means that when they do get the shields, only the special shields will be used).

In py.dialogues:
for every lord of a town:

[trp_town_4_ruler_a,"governer_pretalk_ally", [[ge,"$quest_points",60],[lt,"$faction_rank",6]],
   "You have completed your service as a squire, {playername}, and proven your valor in battle many times. Now, bow before me to receive this well deserved honor you have earned - {playername}! In recognition of your services to our kingdom, I dub thee knight. Carry your title with honour and humility. I am assigning you a troop of horse, (sir/lady} {playername}.   To distinguish yourselves on the field of battle, give your lieutenants one of these shields - I will have some sent to your rooms in Dhorak Inn.   The enemy shall know you and fear you!",
"governer_pretalk_ally",
   [[assign,"$weekly_wage",28],
      [troop_add_items,"trp_dhorak_chest","itm_shield_town4",20],
    [party_add_members,"p_main_party","trp_mercenary",15],[assign,reg(0),"$weekly_wage"],[assign,"$playershield4",1],[assign,"$faction_rank",6]]],
[trp_town_5_ruler_a,"governer_pretalk_ally", [[ge,"$quest_points",60],[lt,"$faction_rank",6]],
   "You have completed your service as a squire, {playername}, and proven your valor in battle many times. Now, bow before me to receive this well deserved honor you have earned - {playername}! In recognition of your services to our kingdom, I dub thee knight. Carry your title with honour and humility. I am assigning you a troop of horse, (sir/lady} {playername}.   To distinguish yourselves on the field of battle, give your lieutenants one of these shields - I will have some sent to your rooms in Dhorak Inn.  The enemy shall know you and fear you!",
"governer_pretalk_ally",
   [[assign,"$weekly_wage",28],
       [troop_add_items,"trp_dhorak_chest","itm_shield_town5",20],
   [party_add_members,"p_main_party","trp_mercenary",15],[assign,reg(0),"$weekly_wage"],[assign,"$playershield5",1],[assign,"$faction_rank",6]]],


in py.triggers
once for every town, where playershield99 is altered to correspond to the number of the town (and, therfore, the number of the unique shield granted to you as Knight)

  #  re equip player troops 
  (2.0, 0, 1.0,

   [
       (eq,"$playershield13",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_playerinfantry1" ,"itm_shield_town13",),
       (troop_add_item,"trp_playermanatarms3" ,"itm_shield_town13",),
       (troop_add_item,"trp_playerinfantry2" ,"itm_shield_town13",),
       (troop_add_item,"trp_playerarcher1" ,"itm_shield_town13",),
       (troop_add_item,"trp_playerarcher2" ,"itm_shield_town13",),
       (troop_add_item,"trp_playerkhergit1" ,"itm_shield_town13",),
       (troop_add_item,"trp_playerkhergit2" ,"itm_shield_town13",),
       (troop_add_item,"trp_playerkhergit3" ,"itm_shield_town13",),
       (troop_add_item,"trp_fighter_woman" ,"itm_shield_town13",),
       (troop_add_item,"trp_sword_sister" ,"itm_shield_town13",),


   ]
   ),


In py.items
one shield per town.  make sure they are NOT merchandise, and make them good!  No point in swapping a hardened heater shield for a scrap of rotten pine, is there?

["shield_town1",         "Shield", [("town1shield",0)], itp_type_shield , itcf_carry_kite_shield,  318 , weight(2.5)|hit_points(480)|body_armor(5)|spd_rtng(82)|weapon_length(95),imodbits_good ],
["shield_town2",         "Shield", [("town2shield",0)],itp_type_shield , itcf_carry_kite_shield,  318 , weight(2.5)|hit_points(480)|body_armor(5)|spd_rtng(82)|weapon_length(95),imodbits_good ],
["shield_town3",         "Shield", [("town3shield",0)],itp_type_shield , itcf_carry_kite_shield,  318 , weight(2.5)|hit_points(480)|body_armor(5)|spd_rtng(82)|weapon_length(95),imodbits_good ],
["shield_town4",         "Shield", [("town4shield",0)],itp_type_shield , itcf_carry_kite_shield,  318 , weight(2.5)|hit_points(480)|body_armor(5)|spd_rtng(82)|weapon_length(95),imodbits_good ],
["shield_town5",         "Shield", [("town5shield",0)],itp_type_shield , itcf_carry_kite_shield,  318 , weight(2.5)|hit_points(480)|body_armor(5)|spd_rtng(82)|weapon_length(95),imodbits_good ],
["shield_town8",      "Shield", [("town8shield",0)], itp_type_shield , itcf_carry_round_shield,  697 , weight(2)|hit_points(800)|body_armor(14)|spd_rtng(9:cool:|weapon_length(45),imodbits_good ],


in py.troops
you can use any name you want for the non-AI troops, or you can copy exisiting troops.  The important thing is that NO AI party or party-template contains these troops, so that the only time they come into existence is when the player creates them through upgrades - hence the inclusion of the sword sister in the above scripts....

upgrade2(troops,"swadian_infantry","swadian_sergeant","playerinfantry1")
upgrade2(troops,"swadian_sharpshooter","playerarcher2","playerarcher1")
upgrade2(troops,"swadian_man_at_arms","playerinfantry2","playermanatarms3")

and

#plyrtrp               bias polearm, mounted
["playerinfantry2","Elite Man at Arms","Elite Men at Arms",tf_mounted|tf_guarantee_horse|tf_guarantee_boots|tf_guarantee_horse,no_scene,reserved,fac_commoners,
etc etc
   def_attrib|wp_polearm(205)|level(26),wp75),knows_common|knows_riding_5|knows_athletics_1|knows_shield_3|knows_ironflesh_3,swadian_face1, swadian_face2],
#plyrtrp          bias tall bow
["playerarcher1","Elite Archer","Elite Archers",tf_guarantee_boots|tf_guarantee_rangedreserved,fac_commoners,
etc etc
  def_attrib|level(26),wp(75)|wp_archery(220),knows_common|knows_power_draw_6|knows_ironflesh_3,swadian_face1, swadian_face2],
#plyrtrp      bias 2hander/polearm
["playermanatarms3","Elite Guard","Elite Guards",tf_mounted|tf_guarantee_boots
etc etc
itm_nordic_helmet,itm_bascinet,itm_warhorse,],
   def_attrib|wp(55)|wp_two_handed(190)|wp_polearm(195)|level(26),knows_common|knows_power_strike_4|knows_athletics_1|knows_ironflesh_3,swadian_face1, swadian_face2],


Obvious things to remember:
Trp-IDs must be DIFFERENT to anything that will occur in AI parties.
Trp-IDs must correspond exactly across all module files (as usual)
shields (or any other distinct items you want to make) should NOT be merchandise, and must have unique IDs.
Any questuins I'll try to answer - but I'm not a python expert like some people.  I developed this through a lot of trial-and-error, to be honest!


Oh - and you'll need to model and texture the shields, unless you want to reduce the variety of shields otherwise available to native/AI troops.  That shouldn't be too hard...
 
Wee... Knock down spell with friendly fire!

Code:
("knockdownspell",
[
	   (get_player_agent_no, ":player_agent"),
       (agent_is_alive, ":player_agent"),
	   (agent_get_position, 1, ":player_agent"),
	(try_begin),
    (try_for_agents,":cur_agent"),
    (neq, ":cur_agent", ":player_agent"),
    (agent_is_alive, ":cur_agent"),
    (agent_is_human, ":cur_agent"),
	(agent_get_position, 2, ":cur_agent"),
	(get_distance_between_positions,"$anim_range",1,2),
		(try_begin),
        (lt,"$anim_range",200),
		(agent_set_animation, ":cur_agent", anim_strike_fall_back_rise),
	(try_end),
	(try_end),
	#Set an animation for player show a string do something here for "casting"

]),

Edit; Thinking of which with some moving props and stuff it can be some sort of non-leathal artillery or fail mission instantly for player... weee...
 
another question:

As we know,
shield can be destroyed,
but other things like sword, armor .... can't be destroyed.

In fact, if we defend with a sword, the sword something will drop off (you know, it is not easy to destroy a sword).
now, question: what should I do to make the sword drop off?
I have two ideas:
1. in module_item.py
["sword","Sword", [("long_sword",0),("scab_longsw_a", ixmesh_carry)], itp_type_one_handed_wpn|itp_merchandise|itp_primary, itc_longsword|itcf_carry_sword_left_hip|itcf_show_holster_when_drawn, 148 , weight(1.5)|difficulty(0)|spd_rtng(100) | weapon_length(102)|swing_damage(24 , cut) | thrust_damage(20 ,  pierce)|hit_points(360),imodbits_sword ],

but I think this will lead to an error

2. I don't know what kind of code can do this. If you know, please tell me,
while we are defending with a sword, get a random number to decide whether the sword should drop or not
 
A question again:

what will happen, if I add the blue sentence into module_mission_templates.py?
  (
    "visit_town_arena",0,-1,
    "You enter the arena",
    [(0,mtef_scene_source|mtef_team_1,af_override_horse,group(1),1,[]),
    (50,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),(51,mtef_scene_source|mtef_team_1,af_override_horse,0,1,[]),
    (52,mtef_scene_source,af_override_horse,0,1,[]),(53,mtef_scene_source,af_override_horse,0,1,[]),(54,mtef_scene_source,af_override_horse,0,1,[]),(55,mtef_scene_source,af_override_horse,0,1,[]),(56,mtef_scene_source,af_override_horse,0,1,[]),
    (57,mtef_scene_source,af_override_horse,0,1,[]),(58,mtef_scene_source,af_override_horse,0,1,[]),(59,mtef_scene_source,af_override_horse,0,1,[]),(60,mtef_scene_source,af_override_horse,0,1,[]),(61,mtef_scene_source,af_override_horse,0,1,[]),(62,mtef_scene_source,af_override_horse,0,1,[]),(63,mtef_scene_source,af_override_horse,0,1,[])
    ],
    [

      (0,0,ti_once,[],[(play_sound,"snd_bgmusic")]),
      (1, 0, ti_once, [], [
          (store_current_scene, reg(1)),
          (scene_set_slot, reg(1), slot_scene_visited, 1),
        ]),
      (ti_inventory_key_pressed, 0, 0, [(display_message,"str_cant_use_inventory_arena")], []),
      (ti_tab_pressed, 0, 0, [(set_trigger_result,1)], []),
    ],
  ),


snd_bgmusic  has already been defined in module_sound.py,it is a music(in /sound/bgmusic.ogg  , about 1:21).



 
It'll start playing as soon as the mission starts and keep playing it untill the sound file ends. For example if the mission ends before music, the music will keep playing untill it is over.
 
sjmind said:
another question:

As we know,
shield can be destroyed,
but other things like sword, armor .... can't be destroyed.

In fact, if we defend with a sword, the sword something will drop off (you know, it is not easy to destroy a sword).
now, question: what should I do to make the sword drop off?
I have two ideas:
1. in module_item.py
["sword","Sword", [("long_sword",0),("scab_longsw_a", ixmesh_carry)], itp_type_one_handed_wpn|itp_merchandise|itp_primary, itc_longsword|itcf_carry_sword_left_hip|itcf_show_holster_when_drawn, 148 , weight(1.5)|difficulty(0)|spd_rtng(100) | weapon_length(102)|swing_damage(24 , cut) | thrust_damage(20 ,  pierce)|hit_points(360),imodbits_sword ],

but I think this will lead to an error

2. I don't know what kind of code can do this. If you know, please tell me,
while we are defending with a sword, get a random number to decide whether the sword should drop or not

i tried this, won't do anything. it seems that shield damage is tagged through the imodbits code.

however...

you can code a tracking number, or a random subtractor keyed to each strike - ie start with 100 and have a rand 1-10 deducted per strike, then, when and if zero is reached, remove the weapon and re-equip with a broken one. maw
 
Can I control a horse by using agent_set_scripted_destination?

Can knights build the formation?

Can knights build the formation like this?
___________
|                |
|                |
|                |
-------------------
Can knights build the formation like this?
\    /
\  /
  \/
 
Can archer build a formation?

Why I used agent_set_scripted_destination to control archers, but nothing happened?
 
Is there anything wrong in my code? It doesn't work(First:"SCRTIPT WARNING......" ,  then  "somebody's horse is dead" ).


module_scripts.py

# script_check_horse
("check_horse",
[
(get_player_agent_no,reg(10)),
(assign,reg60,0),
(try_for_agents,":check_rider"),
(neq,reg10,":check_rider"),
(agent_is_human,":check_rider"),
(agent_is_ally,":check_rider"),
(agent_is_alive,":check_rider"),
(agent_set_slot,":check_rider",slot_agent_have_horse,0),
(try_for_range,":horse_id",horses_begin,horses_end),
(try_begin),
(agent_has_item_equipped,":horse_id",":check_rider"),
(agent_set_slot,":check_rider",slot_agent_have_horse,1),
(val_add,reg60,1),
(try_end),
(try_end),
(display_message,"str_agent_horse_distance"),
(try_begin),
(agent_slot_eq,":check_rider",slot_agent_have_horse,1),
(agent_get_position,11, ":check_rider"),
(try_for_agents,":check_horse"),
(neg|agent_is_human,":check_horse"),
(agent_get_position,10, ":check_horse"),
(get_distance_between_positions,":horse_agent_dist", 10, 11),
(assign,reg60,":horse_agent_dist"),
(display_message,"str_agent_horse_distance"),
(try_begin),
(lt,":horse_agent_dist",1),
(agent_set_slot,":check_rider",slot_agent_horse_agent_id,":check_horse"),
(str_store_agent_name,1,":check_rider"),
#(str_store_agent_name,2,":check_horse"),
(display_message,"str_agent_has_horse"),
(try_end),
(try_end),
(try_end),
(try_end),
]
),


# script_check_horse_alive
("check_horse_alive",
[
(get_player_agent_no,reg(10)),
(try_for_agents,":check_rider"),
(neq,reg10,":check_rider"),
(agent_is_human,":check_rider"),
(agent_is_ally,":check_rider"),
(agent_is_alive,":check_rider"),
(try_begin),
(agent_slot_eq,":check_rider",slot_agent_have_horse,1),
(agent_get_slot,":check_horse",":check_rider",slot_agent_horse_agent_id),
(str_store_agent_name,1,":check_rider"),
#(str_store_agent_name,2,":check_horse"),
(try_begin),
(agent_is_alive,":check_horse"),
(display_message,"str_agents_horse_alive"),
(else_try),
(display_message,"str_agents_horse_dead"),
(agent_slot_eq,":check_rider",slot_agent_have_horse,0),
(try_end),
(try_end),
(try_end),
]
),

module_constants.py

slot_agent_have_horse=12
slot_agent_horse_agent_id=13

module_mission_templates.py

  (0,0,ti_once,[],[(call_script,"script_check_horse")]),
  (3,0,0,[],[(call_script,"script_check_horse_alive")]),

module_strings.py

  ("agent_has_horse","{s1} has a horse"),
  ("agent_horse_distance","dis:{reg60}"),
  ("agents_horse_alive","{s1}'s horse is alive"),
  ("agents_horse_dead","{s1}'s horse is dead"),
 
KON_Air said:
Wee... Knock down spell with friendly fire!

Code:
("knockdownspell",
[
	   (get_player_agent_no, ":player_agent"),
       (agent_is_alive, ":player_agent"),
	   (agent_get_position, 1, ":player_agent"),
	(try_begin),
    (try_for_agents,":cur_agent"),
    (neq, ":cur_agent", ":player_agent"),
    (agent_is_alive, ":cur_agent"),
    (agent_is_human, ":cur_agent"),
	(agent_get_position, 2, ":cur_agent"),
	(get_distance_between_positions,"$anim_range",1,2),
		(try_begin),
        (lt,"$anim_range",200),
		(agent_set_animation, ":cur_agent", anim_strike_fall_back_rise),
	(try_end),
	(try_end),
	#Set an animation for player show a string do something here for "casting"

]),

Edit; Thinking of which with some moving props and stuff it can be some sort of non-leathal artillery or fail mission instantly for player... weee...

i'm thinking this can be a base for a Shield Bash script. maw
 
Highlander said:
The problem is that we don't have anything like ti_on_parry

use a ti, like the inventory key, or tab, or whatever. make it a dual condition that if the key is pressed when an enemy is within a ti_val(x)distance and shield is active? i dunno.

it would seem to me if you could simulate the effects of a shield bash using the knockdown spell code, you can figure a way to implement it. maw
 
Mirathei said:
The only problem I can think of with that is making the ai do it as well.

one thing at a time, baby.... overcome arranging for the player to do it, then someone might come up with a way for the ai to do it. maw
 
Who knows what are these:

I find them in header_operations.py

#-------------------------
# Mission Condition types
#-------------------------
all_enemies_defeated      = 1003 # (all_enemies_defeated),
race_completed_by_player  = 1004 # (race_completed_by_player),
num_active_teams_le      = 1005 # (num_active_teams_le,<value>),
 
sjmind said:
Who knows what are these:

I find them in header_operations.py

#-------------------------
# Mission Condition types
#-------------------------
all_enemies_defeated      = 1003 # (all_enemies_defeated),
race_completed_by_player  = 1004 # (race_completed_by_player),
num_active_teams_le       = 1005 # (num_active_teams_le,<value>),
1 check if there are any killeable unit
2 no idea
3 check the number of live teams in the scene
 
maw said:
Mirathei said:
The only problem I can think of with that is making the ai do it as well.

one thing at a time, baby.... overcome arranging for the player to do it, then someone might come up with a way for the ai to do it. maw
we need a animation however
we can use agent has iten equiped and store random in range
 
Back
Top Bottom