Author Topic: PYTHON SCRIPT/SCHEME EXCHANGE  (Read 286667 times)

0 Members and 1 Guest are viewing this topic.

SupaNinjaMan

  • Baron
  • *
  • 🆗🆒
    • Steam - sionfel
    • Twitch.tv - Sionfel
    • YouTube - DinosaurWithRobotEye
    • View Profile
  • Faction: Nord
  • MP nick: SupaNinjaMan
  • M&BWBWF&SNWVC
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #735 on: February 12, 2019, 11:51:43 PM »
So it makes me sad that this thread isn't as heavily used as it used to be. So here's a new addition from my mod.

Supa's Double-Throw Script

Code: (module_scripts) [Select]
##################### Supa's Dual Wielding Throw #######################
# USAGE: Please only declare inside ti_on_weapon_attack! Although you might end up with a funny endless chain of throws if declared on ti_on_missile_hit. I haven't tried this particular case, but it /feels/ right.
# INPUT: arg1 = offhand itm_name, arg2 = thrown itm_name
# OUTPUT: none
("cf_fate_double_throw", [
(store_trigger_param_1, ":agent_no"), # info from ti_on_weapon_attack, determines throwing agent
(store_script_param_1, ":itm_shield"), # declared user parameter 1, off-hand weapon that enables the agent to double throw
(store_script_param_2, ":itm_thrown"), # declared user parameter 2, thrown version of the off-hand weapon
(agent_get_ammo, ":ammo", ":agent_no", 1), # counts ammo in active ranged weapon, in this case, the right hand's throwing weapon
(agent_get_wielded_item, ":right", ":agent_no", 0), # gets the name of the right hand weapon
(agent_get_wielded_item, ":left", ":agent_no", 1), # gets the name of the left hand weapon
(item_get_missile_speed, ":missile_speed", ":right"), # checks missile speed of right hand weapon
(gt, ":ammo", 1), # checks that agent has ammo to throw two weapons
(eq, ":left", ":itm_shield"), # checks if left hand weapon is declared weapon in parameter 2
(agent_get_look_position, pos1, ":agent_no"), # checks agents aim
(position_move_y, pos1, 130, 0), # adjust missile spawn point to ~roughly~ hand height
(position_move_x, pos1, -40, 0), # adjust missile spawn point to ~roughly~ left hand
(position_move_z, pos1, 170, 0), # I genuinely forget why this one is here.
(val_mul, ":missile_speed", 100), # converts missile speed to something useable by add_missile
(add_missile, ":agent_no", pos1, ":missile_speed", ":itm_thrown", 0, ":itm_thrown", 0), # finally commits the left hand throw
(val_sub, ":ammo", 1), # takes 1 from ammo count
(agent_set_ammo, ":agent_no", ":right", ":ammo"), # adjusts ammo count to take double throw into account
]
),

Code: (module_items) [Select]
## Place within the right hand throwing weapon ##
[(ti_on_weapon_attack, [
(call_script, "script_cf_fate_double_throw", "itm_shield_version", "itm_thrown_version"),
            ]),]

Ways the code could be improved:
When ammo count is equal to one, dequip off-hand version.
Left hand arc variance, right now the agent's left hand is always spot on and can throw as well as their right.
I noticed that the Ambidextrous Firearms OSP includes variance based on the agent's current speed, I haven't noticed this being an issue, but it could make your right hand weapon fly further than the left one.
Check agent's Weapon Master, Power Throw and Throwing Weapon Proficiency to change various attributes so someone isn't perfectly ambidextrous but can improve.

Known Issues:
Occasionally, when fighting in certain random battles, your add_missile weapon will fly in slow motion. I do not know what might cause this, but I personally find it hilarious.
The arc on the add_missile weapon is always a touch shallower, no matter the missile_speed. I also do not know how to modify this.

I also do not take into account whether the user is mounted since that will never be the case in my usage, and this is already a much more modular version of the one I actually use. But if you would like to do that check out the Ambidextrous Firearms OSP as a reference.
« Last Edit: February 12, 2019, 11:59:59 PM by SupaNinjaMan »
-

_Sebastian_

  • Punkbuster 2.0
  • Baron
  • *
  • Lazy Wizard
    • Steam - themostlazy
    • YouTube - UCfHPlDpBaLtqFjy_gMJFtCg
    • View Profile
    • Bad Bug Busters Discord
  • Faction: Bandit
  • MP nick: _Sebastian_
  • NWWBVC
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #736 on: February 25, 2019, 09:32:26 PM »
Known Issues:
Occasionally, when fighting in certain random battles, your add_missile weapon will fly in slow motion. I do not know what might cause this, but I personally find it hilarious.
The arc on the add_missile weapon is always a touch shallower, no matter the missile_speed. I also do not know how to modify this.
It's due to the changing fixed point multiplier during the mission.
You assume it's always 100, but it usually changes within several scripts.
So before you use operations that make use of the fixed point multiplier, set it to your needs.

Dj_FRedy

  • Count
  • *
  • "game_start"
    • View Profile
  • Faction: Swadian
  • M&BWBNWVCWF&S
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #737 on: June 09, 2019, 05:22:41 AM »
Tired of crossing the hall so there's no interesting character to talk to?
Something similar happened to me and I wrote this script, feel free to use it.
(click to show/hide)
To insert in module_script
(click to show/hide)
To insert in menu "town" with the string {s16}
(click to show/hide)
To insert at the end of module_strings
(click to show/hide)
"Lately I have had little time to play. That is the downside of modding. And once you get behind the scenes (no pun intended) some of the magic disappears. You start contemplating ways to change the game instead of just playing and having fun. Suddenly it is more fun modding than actually playing".
Adorno

Silver Wolf

  • Grandmaster Knight
  • *
  • Mad God's Blessings!
    • View Profile
    • Exilian
  • Faction: Neutral
  • WBNWVCWF&SM&B
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #738 on: August 15, 2019, 03:22:47 PM »
This is Mordechai's Extended Prisoner Chat script, made ready for Warband 1.143 by me. ;) Enjoy!

(click to show/hide)

So I've tested this on Warband 1.174 with Diplomacy mod and it works well.

The only suggestion I have is to limit the use of this option:
Code: [Select]
  [anyone|plyr,"prisoner_chat_menu", [], "Hmmm... perhaps you're not as stupid as the rest of those rabble.", "prisoner_chat_offer",[]],
Right now it seems like it can just be spammed until all of your prisoners finally accept to join you, basically rendering Natives's "Recruit some of your prisoners to your party" obsolete.

Also, does anyone have the additional piece of code that lets you loot the items for the executed lord's inventory?

Dj_FRedy

  • Count
  • *
  • "game_start"
    • View Profile
  • Faction: Swadian
  • M&BWBNWVCWF&S
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #739 on: August 15, 2019, 06:13:28 PM »
mm I see that this modification was updated for Warband 1.143, since then new slots have been added, 146 and 147, in vanilla or Diplomacy, are already in use ...

To loot the inventory you can use the operation:
Code: [Select]
change_screen_loot                    = 2041  # (change_screen_loot, <troop_id>),
                                              # Opens the Looting interface, using the provided troop as loot storage. Player has full access to troop inventory.

"Lately I have had little time to play. That is the downside of modding. And once you get behind the scenes (no pun intended) some of the magic disappears. You start contemplating ways to change the game instead of just playing and having fun. Suddenly it is more fun modding than actually playing".
Adorno

Silver Wolf

  • Grandmaster Knight
  • *
  • Mad God's Blessings!
    • View Profile
    • Exilian
  • Faction: Neutral
  • WBNWVCWF&SM&B
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #740 on: August 19, 2019, 02:11:05 PM »
mm I see that this modification was updated for Warband 1.143, since then new slots have been added, 146 and 147, in vanilla or Diplomacy, are already in use ...

Thanks for noticing that Dj_FRedy, I'll try assigning different numbers to those two slots!


Okay here it goes, the sources of the NNY mod. I hope they are getting used:

Explanation how to the read/insert the code
(click to show/hide)

Bandit bribery
(click to show/hide)

I also made some adjustments to this script...
I think that the actual payment part of the script was somehow messed up so I fixed that issue first.
I also added some consequences for recruiting bandits, like morale and honour loss and aristocratic NPC complaints.
The morale impact is the same as the one used for recruiting prisoners (-4 morale per man) and the impact also depends on selected campaign AI difficulty.

Follow the same code placement as the one in Geoffrey Ashe's original version:

Code: (module_dialogs.py) [Select]
# BANDIT BRIBE BEGIN
   [anyone|plyr,"bandit_meet", [], "I'll spare your life if you join me.", "bandit_recruit",[]],
   
   [anyone,"bandit_recruit", [
      (store_random_in_range,":rand",0,20),
      (gt,"$player_honor",":rand"),
   ], "A {boy/girl} like you, who could do no misdeeds? Heck no. We will slit your throat for your impudence!","close_window",[encounter_attack]],
         
   [anyone,"bandit_recruit",[
      (store_encountered_party,":party"),
      (store_party_size,":size",":party"),
      (store_mul,":size_bribe",":size",50),
      (assign, reg0, ":size_bribe"),
   ],"We'll consider your offer for {reg0} denars.","bandit_recruit_2",[]],
   
   [anyone|plyr,"bandit_recruit_2",
   [
        (store_troop_gold, ":gold", "trp_player"),
        (ge, ":gold", reg0),
      (party_can_join),
   ],"Very well.","close_window",
   [
      (store_encountered_party,":party"),
      (store_party_size,":size",":party"),
      (store_mul,":size_bribe",":size",50),
      (assign, reg0, ":size_bribe"),
      (troop_remove_gold, "trp_player", reg0),
      (play_sound, "snd_money_paid"),
      # change base morale reduction based on difficulty:
      (game_get_reduce_campaign_ai, ":reduce"),
      (val_sub, ":reduce", 4),
      (store_mul, ":morale_change", ":reduce", ":size"),
      (call_script, "script_change_player_party_morale", ":morale_change"),
      (party_join),
      (assign, "$g_leave_encounter", 1),
      (call_script, "script_change_player_honor", -1),
      (call_script, "script_objectionable_action", tmt_aristocratic, "str_pay_bandits"),

   ]],
               
   [anyone|plyr,"bandit_recruit_2",[],"Forget about it.","bandit_meet",[]],
# BANDIT BRIBE END

As and optional part, you can also find the used companion complaint lines ("script_objectionable_action", tmt_aristocratic, "str_pay_bandits") and edit them so they're more to you liking.
I like to make them a bit more vague since they're used as a response for paying off the bandits to leave you alone in Native.
Which means that your aristocratic companion will refer to recruiting bandits as "Bla bla such cowardice, bla never truly feared by his men bla bla."
I just tend to replace "such cowardice" with "such actions" and "truly feared" with "truly respected".
But even if you leave them the way they are in Native it's acceptable.

And yeah, I'm pretty new at this so feel free to suggest any adjustments that would make the code less messy.
« Last Edit: August 19, 2019, 03:43:08 PM by Silver Wolf »

Woyeyeh

  • Sergeant
  • *
  • hey there
    • View Profile
  • Faction: Khergit
  • MP nick: hdggDalton
  • WF&SWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #741 on: September 04, 2019, 06:20:08 AM »
Hey guys, I edited the script for calculating the score for each lord when it's time for the king to hand out fiefs. Instead of heavily relying on renown, which inevitably leads the king and a few other super-lords to control everything, this script heavily relies on how many fiefs the lord owns, what kind of fief it is, and also HEAVILY penalizes the faction leader unless they themselves are landless. It also tries to give out walled centers equitably, so if a lord doesn't have a walled center and a walled center is up for grabs, it favors them over lords that already have a walled center. Also, it makes a lord's relationship with his king more important because it slightly influences the score for all lords, whereas previously the script only handled a human player's relationship with their king. It also decreases bonus to score for being the one to capture the fief, so marshals don't grab all the land. tl;dr it makes faction leaders a hell of a lot more reasonable and a lot less selfish when distributing fiefs. So far it works, I infinite camped for an ingame year and most of the faction leaders only had 1 town, maybe 1 or 2 castles here and there, and when the king's last fief was taken, they assigned themselves a new one. Pretty neat, huh? :D

(click to show/hide)

The above script also goes well with the one I edited for give_center_to_lord. It changes how much relations change between a king and a lord when the king gives the lord a fief depending on what type of fief it is. I've long detested how giving a village gave the same amount of relations as a town, and this changes that! Also, other lords will change their relations with their king more dramatically than before from a fief assignment to counterbalance the increase in relations per fief and to promote internal cliques.

(click to show/hide)
[hdggDalton] KILL ME MAO
[hdggDalton] SET ME FREE
Mao -----> hdggDalton
*DEAD* [ShoeKnight] wtf was that

Crysix

  • Regular
  • *
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #742 on: September 04, 2019, 04:16:50 PM »
Change the item(itm_arquebus) and constants "is_between"(thunder_braves_begin, thunder_braves_end) to the troops range you wish, same as "trp_thunder_brave", change it to your troop.
its basically a dialog to give a specific item to one of the troops you putted in the constants range, remove the talked troop and item, and add the new unit, you can expand it or modify to your needs(the "trp_thunder_brave"  is a custom troop, not connected to the troop trees in my case)-

Code: [Select]
# TheSwan Thunder braves begin
  [anyone|plyr,"regular_member_talk", [(player_has_item, "itm_arquebus"), (is_between,"$g_talk_troop",thunder_braves_begin, thunder_braves_end),], "I got some of those invaders fire thunders, take it, it will serve you well in battle.", "thunder_braves1",[]],
  [anyone|plyr, "thunder_braves2", [], "Here you can have it.", "close_window", [(party_remove_members,"p_main_party","$g_talk_troop", 1), (party_add_members, "p_main_party", "trp_thunder_brave", 1), (troop_remove_item, "trp_player", "itm_arquebus")]],
  [anyone|plyr, "thunder_braves2", [], "I change my mind.", "close_window", []],
  [anyone, "thunder_braves1", [], "Thank you, {sir/madam}.", "thunder_braves2", []],
# TheSwan Thunder braves end


In that code its basically giving that troop a gun(if you have it in your inventory), the custom troop there  (trp_thunder_brave) is similar troop to the talked troop you about to remove, only with a gun(can be any different gear you wish) so its kind of evolving you can say, this should be changed according to your desire
« Last Edit: September 04, 2019, 05:16:37 PM by Crysix »

diegoami

  • Regular
  • *
    • Steam - lynxsupercluster
    • YouTube - UCQHMx6rNOKfLxFRI4_Tf6cA
    • View Profile
  • Faction: Khergit
  • WBNWVCWF&SM&B
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #743 on: October 12, 2019, 11:58:52 AM »
Tired of crossing the hall so there's no interesting character to talk to?
Something similar happened to me and I wrote this script, feel free to use it.
To insert in menu "town" with the string {s16}
(click to show/hide)

Nice script. You have also to add {s16} to the town heading, I guess.
(click to show/hide)
In Diplomacy it looks like that

(click to show/hide)
« Last Edit: October 12, 2019, 12:18:52 PM by diegoami »

Dj_FRedy

  • Count
  • *
  • "game_start"
    • View Profile
  • Faction: Swadian
  • M&BWBNWVCWF&S
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #744 on: October 12, 2019, 02:28:23 PM »
Right, I'm glad you find it useful, you can also add a circumflex to make a line break, if you prefer.
Code: [Select]
"{s10} {s14}^{s11}{s12}{s13}^{s16}",
"Lately I have had little time to play. That is the downside of modding. And once you get behind the scenes (no pun intended) some of the magic disappears. You start contemplating ways to change the game instead of just playing and having fun. Suddenly it is more fun modding than actually playing".
Adorno

Crysix

  • Regular
  • *
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #745 on: October 21, 2019, 05:39:59 PM »
TheSwanDay&NightArrows
Swapping normal arrows to flaming arrows according to day and night time, few things to do to make this work:
1)add the flaming arrow item yourself(itm_your_fire_arrow and put him instead of the "itm_barbed_arrows" that you see in the trigger block, so instead of
       
(click to show/hide)
2)add all your troops that using arrows to this trigger, for now you can see only "trp_swadian_archer" is effected from this.
3)add the global variable "$arrowdayandnight" or make a new one, to scripts.py, (you can find the global variables if you search for "GLOBAL VARIABLES INITIALIZATION" in scripts.py and add this "(assign, "$arrowdayandnight", 0)," under this "(assign, "$g_lco_panel_found", 0), " it should look like this:
(click to show/hide)
4)put this code below in simple_triggers.py and have automatically flaming arrows in night battles and normal arrows in day battles, remember you can modify it freely to your needs.

(click to show/hide)


Link to tutorial and download Flaming arrow item and texture -
https://www.youtube.com/watch?v=bv5sj5bZQ5g
« Last Edit: October 25, 2019, 07:45:07 AM by Crysix »

Dj_FRedy

  • Count
  • *
  • "game_start"
    • View Profile
  • Faction: Swadian
  • M&BWBNWVCWF&S
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #746 on: October 22, 2019, 04:29:39 AM »
Hello @Crysix
Of course you say well, 'some things'. This isn't much use if you don't provide 'fire arrows', or any particle code, which I think would be the most interesting thing to offer the rest of the modders. On the other hand, I would personally set the triggers in the corresponding mission templates, instead of making calls every 0.1 seconds constantly.
Also tell you that g_lco' are global corresponding to an @Lav's modification, you should specify it, not everyone has such a modification added, although it would be easy to explain where to define the variables within the system.
I hope I haven't been too punctilious with my comment.
"Lately I have had little time to play. That is the downside of modding. And once you get behind the scenes (no pun intended) some of the magic disappears. You start contemplating ways to change the game instead of just playing and having fun. Suddenly it is more fun modding than actually playing".
Adorno

Crysix

  • Regular
  • *
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #747 on: October 22, 2019, 06:01:54 AM »
Hey Dj_FRedy, the fire arrow item\model can be found in varied mods, for example there is in the-12th- mod, you can set the trigger where ever you want yes, but in simple triggers it work just fine, and yes i forgot its Lav global variables and addition.

Artam

  • Veteran
  • *
    • View Profile
  • Faction: Neutral
  • WBNWVCM&BWF&S
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #748 on: October 22, 2019, 07:06:58 PM »
Hello everyone,

I would like to share code that reduces enemy lords escape chance after defeat by 5% depending on each point given to prisoner management. Code has been approved by Dj_FRedy, so I share with you guys.  :party:

In Script "cf_check_hero_can_escape_from_player" search (lt, ":rand", hero_escape_after_defeat_chance), and replace with below.
Code: (module_scripts.py) [Select]
### BEGIN + REDUCING CHANCE OF LORD ESCAPE
# (lt, ":rand", hero_escape_after_defeat_chance),
(assign, ":escape_chance", 70),
(try_begin),
(store_skill_level, ":level", "skl_prisoner_management", "trp_player"),
(val_mul, ":level", 5), # reducing 5%
(val_sub, ":escape_chance", ":level"),
(try_end),
(lt, ":rand", ":escape_chance"),
### END - REDUCING CHANCE OF LORD ESCAPE

Feel free to use and improve it.

Kind regards,
« Last Edit: October 22, 2019, 07:09:40 PM by Artam »