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

0 Members and 1 Guest are viewing this topic.

Thymo

  • Sergeant at Arms
  • *
  • Snow and science!
    • View Profile
  • Faction: Nord
  • M&B
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #330 on: November 22, 2008, 12:10:34 AM »
Bla, bla, bla..

Impressive! :shock:


 Altgouh:

I get this when i build it:

(click to show/hide)

End of scripts.py:
(click to show/hide)

I'm not familiar with scripts of this caliber (hehe) so, if possible, could you maybe brief me about what's wrong?


Edit: Thanks! ;)


~ Thymo
« Last Edit: December 03, 2008, 03:37:58 PM by Thymo »
e^(i*π)+1=0

Geoffrey Ashe

  • Squire
  • *
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #331 on: November 29, 2008, 11:18:41 AM »
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)

Talk to village elder/guild master
(click to show/hide)

Bandit bribery
(click to show/hide)

Tavern recruitment and ale
(click to show/hide)

Patrol
(click to show/hide)

I hope I didn't forget anything and please keep the discussion in the NNY thread.

06.12.08 fixed talk to village elder/guild master feature (replace it again, if you were already using it)
05.12.08 fixed tavern recruitment, thanks to vonmistont (green text).
« Last Edit: December 06, 2008, 09:29:27 PM by Geoffrey Ashe »

Rongar

  • Master Knight
  • *
  • Cave canem
    • View Profile
  • Faction: Sarranid
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #332 on: November 29, 2008, 02:16:15 PM »
Large arrays 

Here are a little crazy thing I made based on fujiwara's arrays idea.
I was going to handle array with above 1,5K+ elements. Don't ask why :)  Now I'm sure 400 is enough, but still use the same code.

Additional party for dynamic arrays creating.
Code: (module_parties.py) [Select]
  ('array','array',pf_disabled,0,fac_neutral,0,[]),

Scripts for handing.
Code: (module_scrpts.py) [Select]
  # script_init_array
  # Input:
  #arg1=length,
  #arg2=array
  # Output: none
  ("init_array",
    [
      (store_script_param, ":length", 1),
      (store_script_param, ":array", 2),
      (try_begin),
      (troop_slot_eq,":array",0,0),#if not zero means array already been inited, to avoid memory leak.
(store_div,":num_of_box",":length",256),
(try_begin),
(store_mod,reg0,":length",256),
(neq,reg0,0),
(val_add,":num_of_box",1),
(try_end),
(troop_set_slot,":array",0,":length"),
(try_for_range,":i",0,":num_of_box"),
        (store_random_in_range,reg1,"p_zendar","p_village_90"),
        (set_spawn_radius,20),
        (spawn_around_party,reg1,'pt_array'),       
(store_add,":i_s",":i",1),
(try_end),
      (try_end),

      ]), 
Usage (call_script,"script_init_array",":length","trp_array"),
init_array creates new array with arbitrary ":length" and  control varible "trp_array".
I am in need of very limited number of such arrays, so I use troops as control variable. But i can be changed to dynamic fujiwara's parties arrays.

Code: (module_scrpts.py) [Select]
             
  # script_array_set
  # Input:
  #  arg1=array
  #  arg2=index
  #  arg3=value
  # Output: none
  ("array_set",
    [
      (store_script_param, ":array", 1),
      (store_script_param, ":index", 2),
      (store_script_param, ":value", 3),
      (store_div,":box",":index",256),
      (val_add,":box",1),#cause 0 is rezerved for array size
      (val_mod,":index",256),     
      (troop_get_slot,reg0,":array",":box"),       
      (party_set_slot,reg0,":index",":value"),       

      ]), 
   
Usage (call_script,"script_array_set","trp_array",":index",":value"),
array_set puts value ":value" into ":index" position of "trp_array" (trp_array[index]=value).

Code: (module_scrpts.py) [Select]
                   
  # script_array_set
  # Input:
  #  arg1=array 
  #  arg2=index
  # Output:
  #  reg0=value
  ("array_get",
    [
      (store_script_param, ":array", 1),
      (store_script_param, ":index", 2),     
      (store_div,":box",":index",256),
      (val_add,":box",1),#cause 0 is rezerved for array size
      (val_mod,":index",256),     
      (troop_get_slot,reg0,":array",":box"),       
      (party_get_slot,reg0,reg0,":index"),       

      ]),           
Usage (call_script,"script_array_set","trp_array",":index"),
array_get retrives value from ":index" position of "trp_array" and return it in reg0 (reg0=trp_array[index]).
« Last Edit: November 29, 2008, 02:24:08 PM by Rongar »


Factionize items tool
I hear and I forget.
I see and I remember.
I do and I understand...
 that would better if I heard.

Slawomir of Aaarrghh

  • Grandmaster Knight
  • *
    • YouTube - daedalus1pl
    • View Profile
    • The Deluge
  • Faction: Neutral
  • MP nick: Daedalus
  • WBM&BWF&SVCNW
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #333 on: January 12, 2009, 03:11:19 PM »
Hi.

Here is a very simple way to add voices for player commands during the battles. It's simplified version of my voice_orders scripts (this version is not supporting toggable commands. Full version is working fine, but it's a little "messy" and I have to clear it before releasing). Here you go:

First you'll need the proper files for group selection and orders. I asume you have such files. Put them im "Sounds" folder of your mod, make sure you have "scan_module_sounds = 1" in your module.ini, and the you can move to adding the files to module_sounds:

(click to show/hide)

Change bolded to the real names of your sound files.

Now move to mission_templates and add this somewhere at the begining:

(click to show/hide)

Then, in every mission template, that you wish to hear the voices, add this:
(click to show/hide)

Save changes, compile module, run the game and "Chaaaaaaargeeee!!!" the enemies. :D

Have fun shouting at your men, ;)
Daedalus

PS. You may want to add player gender check, so that females won't be screaming orders for troops with male voice. :P I ripped the trigger of any other additional variables to make it as clear as possible, so even beginner modders could use (and understand) the code.
« Last Edit: January 12, 2009, 03:19:58 PM by Slawomir of Aaarrghh »

timedanze

  • Knight at Arms
  • *
  • Permanently Banned
  • MaranZaaaBoY aT YouR CoMMannNnnD!!
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #334 on: January 12, 2009, 03:43:40 PM »

(click to show/hide)

what means: "daedalus'"  ??? :idea:
BEING A MACHINE - KNIGHT OF THE UNIVERSE

Kolba

  • Guest
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #335 on: January 12, 2009, 03:52:58 PM »
Quote
what means: "daedalus'"  ???

When you copy it ("daedalus") your computer will suddenly crash and explode.

timedanze

  • Knight at Arms
  • *
  • Permanently Banned
  • MaranZaaaBoY aT YouR CoMMannNnnD!!
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #336 on: January 12, 2009, 03:56:07 PM »
Quote
what means: "daedalus'"  ???

When you copy it ("daedalus") your computer will suddenly crash and explode.

:shock:

 :( :cry:
BEING A MACHINE - KNIGHT OF THE UNIVERSE

Slawomir of Aaarrghh

  • Grandmaster Knight
  • *
    • YouTube - daedalus1pl
    • View Profile
    • The Deluge
  • Faction: Neutral
  • MP nick: Daedalus
  • WBM&BWF&SVCNW
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #337 on: January 12, 2009, 03:58:49 PM »
Hehe... I lol'd :D

When I look at this:
I ripped the trigger of any other additional variables to make it as clear as possible, so even beginner modders could use (and understand) the code.
...I get a strange feeling, that I've failed. :D

jik

  • Knight
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #338 on: January 12, 2009, 08:37:49 PM »
Is Chel still around?

I was wondering if you have a posting for your morale script?  I love that one.  wanted to see it and see if it is possible to add Renown bonuses per battle based on how many units you personally kill.  It would be even better if the bonus was based on the level of difficulty the game is set to...

timedanze

  • Knight at Arms
  • *
  • Permanently Banned
  • MaranZaaaBoY aT YouR CoMMannNnnD!!
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #339 on: January 14, 2009, 10:38:58 AM »
Hi.

Here is a very simple way to add voices for player commands during the battles. It's simplified version of my voice_orders scripts (this version is not supporting toggable commands. Full version is working fine, but it's a little "messy" and I have to clear it before releasing). Here you go:

First you'll need the proper files for group selection and orders. I asume you have such files. Put them im "Sounds" folder of your mod, make sure you have "scan_module_sounds = 1" in your module.ini, and the you can move to adding the files to module_sounds:

(click to show/hide)

Change bolded to the real names of your sound files.

Now move to mission_templates and add this somewhere at the begining:

(click to show/hide)

Then, in every mission template, that you wish to hear the voices, add this:
(click to show/hide)

Save changes, compile module, run the game and "Chaaaaaaargeeee!!!" the enemies. :D

Have fun shouting at your men, ;)
Daedalus

PS. You may want to add player gender check, so that females won't be screaming orders for troops with male voice. :P I ripped the trigger of any other additional variables to make it as clear as possible, so even beginner modders could use (and understand) the code.


DID IT! RESULT = NOTHING

ok... summary...
you meant this files:

module_mission_template.py
module_sounds.txt

or??


BEING A MACHINE - KNIGHT OF THE UNIVERSE

spiritwind

  • Squire
  • *
  • Check out the Fallout Mod
    • View Profile
    • Myspace Page
  • Faction: Vaegir
  • MP nick: [SG]Spiritwind
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #340 on: January 14, 2009, 09:32:44 PM »
Does anyone have the script for automatic weapons.  I know a mod had a gatlin gun, or minigun but no1 seems to know the script that was used...
Also, if there are any python coders out there looking for the mod then please look into the fallout mod!  We greatly need an advanced coder.
If you are interested in joining please contact me.
Our pages are here, http://www.moddb.com/mods/fallout
http://forums.taleworlds.com/index.php/topic,37788.0.html
----
Sorry, not trying to use this as a recruitment page, I really need the script for automatic firing weapons!

Visit endlessages.com for more details =)

Garnier

  • Sergeant
  • *
    • View Profile
    • www.philipmcg.com
  • Faction: Vaegir
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #341 on: January 16, 2009, 12:38:36 AM »
I made this for my mod, the script picks a random castle from the list of castles belonging to the player's faction.  I use it at the start of the game when the player chooses to start as a lord.
Code: [Select]
# script_choose_starting_castle
# Called at the beginning if the player chose to be a lord.  This script choses a random castle from the faction the player chose.
  ("choose_starting_castle",
    [
(assign, ":random_castle_found", 1),
(try_for_range, ":unused", 0, 40),
(try_begin),
(eq, ":random_castle_found",1),
(store_random_in_range,":center_no",castles_begin,castles_end),
(store_faction_of_party, ":center_faction", ":center_no"),
(try_begin),
(eq, ":center_faction", "$players_kingdom"),
(assign, "$g_center_to_give_to_player", ":center_no"),
(assign, ":random_castle_found", 0),
(try_end),
(try_end),

(try_begin), # if it didn't find one, pick the first one this time.
(eq, ":random_castle_found", 1),
(try_for_range, ":center_no", castles_begin, castles_end),
(store_faction_of_party, ":center_faction", ":center_no"),
(try_begin),
(eq, ":random_castle_found", 1),
(eq, ":center_faction", "$players_kingdom"),
(assign, "$g_center_to_give_to_player", ":center_no"),
(assign, ":random_castle_found", 0),
(try_end),
(try_end),
(try_end),
]),

This is what you can use to give the castle to the player:
Code: [Select]
        (call_script,"choose_random_castle_for_player"),
        (jump_to_menu,"mnu_give_center_to_player"),

Note the script only works if the player has joined a faction.
« Last Edit: January 18, 2009, 11:21:57 PM by Garnier »

Amman de Stazia

  • Master Knight
  • *
  • schizophrenic? There's three of us now!
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #342 on: January 19, 2009, 08:11:16 AM »
Is Chel still around?

I was wondering if you have a posting for your morale script?  I love that one.  wanted to see it and see if it is possible to add Renown bonuses per battle based on how many units you personally kill.  It would be even better if the bonus was based on the level of difficulty the game is set to...

I think Highlander used this script in Age of Machinery, so he might have the answers for you, jik.
http://forums.taleworlds.net/index.php/topic,12250.msg208344.html#msg208344

Family IS more important than Mount and Blade. 

Family D'Stazia.  (A, K and S )

PS - this line plugs TPW - The Peninsular War mod.http://forums.taleworlds.net/index.php/topic,42454.0.html

Garnier

  • Sergeant
  • *
    • View Profile
    • www.philipmcg.com
  • Faction: Vaegir
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #343 on: January 20, 2009, 02:02:02 PM »
Simple Trigger to normalize the player's relations with lords and towns, as well as the player's honor.


What it does:
Each day, there is a separate chance that each of these things (town relations, lord relations and honor) will try to normalize themselves, in other words go toward zero.  For example, say the chance succeeds for honor normalization.  If you have positive honor then your honor is the percent chance that it will drop by one.  So if you have 20 honor, there's a 20% chance that you will lose one.  And on the flip side if you have -20 honor, there is a 20% chance that you will gain one.

The code is in the spoiler;
(click to show/hide)
« Last Edit: January 20, 2009, 02:05:28 PM by Garnier »

raowyn

  • Recruit
  • *
    • View Profile
  • Faction: Bandit
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #344 on: January 24, 2009, 02:04:11 AM »
YAY I finally got registered. Been busily coding away a few different things, and wanted to post everything as a reference for anybody that wanted to look. A lot of the credit goes to Magelord, at least indirectly, for the 83 tweaks thread. I took a lot of those ideas and rendered them .py. Changelog + link to my .py files below. Last note: within the .py files, you can search for these changes by searching for '#ajm' case insensitive no quotes- Every change should have one of those by it.

Add: my first post, so YAY M&B rocks.

Quote
----WHOLE NEW BUNCHA HEROS----
------------------------------
generic dialog for em is in module_strings
module_scripts sets their morality n junk and ties each of em to the dialog in strings
troops contains the new hero units
constants has the constant declaration for ajm_companions_begin/end which is used to iterate thru them all
   inside scripts where it sets them all to use the generic dialog
game menus to make em show up in taverns
------------------------------

CONSTANTS
>chance lords escape after being defeated in battle (this seems to affect them being captured by the player or AI's)

DIALOGS
>halved cost of gifts for improving relations with a lord
>>additionally, you can buy gifts to improve your relations up to 100
>relation changes (with NPCs and locations) are much more dramatic; each has been multiplied by 4
>your ranks in persuasion and the days defenders have spent starving affect your chance to persuade town/castle defenders to surrender.
>>each rank of persuasion increases your forces apparent strength by 5% when persuading the defending commander to surrender
>>for each day the defenders spend starving (no food left), your apparent strength goes up by 50% when persuading for surrender

ITEMS
>tripled food units provided by all food to coincide with food changes in food consumption trigger
>increased speed of non-parry weaps, swapped thrust/swing damage of the knife and dagger
>doubled max ammo of arrows/bolts/thrown weaps since nothing under the sun seems to make npc's more accurate

GAME MENUS
>cattle follow instead of flee
>lord will pay out 12,000 if you request a location you've conquered and he awards it to someone else
>allowed hotkey use in the siege menu (so you can look at inventory, party, etc)
>added menu text for defenders surrendering due to starvation (sieged till they ran outta food)
>>currently this isn't actually seen, it just goes straight to the after-battle freed/captured prisoner interface.
>improvement build times (prison tower, mill, etc...) have been drastically reduced
>you collect taxes from ALL your fiefs by visiting any one of them
>siege towers build faster
>SIEGES
>>defenders will try to wait you out for 3 days after they run outta food
>>>after that time, they will surrender
>>>during that time, defenders may sally out in an attempt to break your siege
>>>>they have a chance to sally out once every 12 hours
>>>>the number of troops advantage/disadvantage will make them more/less likely to sally out
>allow player to attack even if relationship is positive
>you can besiege anyone regardless of relationship
>changed menu text to clearly identify recruiting prisoners as being affected by persuasion
>recruiting from villages is now affected by persuasion.
>>each rank of persuasion increases the number of volunteers by 1 (if there are any volunteers to be had), and reduces the denar cost by 1 (taken out of 11 denars base cost)
>each rank of persuasion increases the amount of supplies villagers bring out for you by 3% when you force them to give you supplies
>each rank of looting increases amt of loot you get for raiding villages by 3%
>each rank of looting increases the number of cattle you steal by 1

SCRIPTS
>companions all get along
>renown increases max party size quicker; every 5 morale increases troop cap by +1 (mostly affects player)
>party size has no affect on morale
>being your king's buddy has 10x more affect on him giving you conquered locations
>the one who initiates a siege has a better chance than before of being awarded the conquered location
>player is always in command of all allies on the field, not some dumbass ai lord
>trade skill reduces trade penalty by 7% per skill rank
>repeatable quests from lords, village elders, etc, are repeatable 2x faster
>the max food stores of towns/castles are now randomly determined each 8 hours, from 10-100 percent of the normal max.
>>actually possible now to starve out a place if you show up at a time when their food stores are 'running low'
>Pretty drastically shifted price determination towards the player's favor
>>those previously puny lord ransoms will seem pretty good now cause 2000 denars will actually buy some stuff now
>the troop wages displayed in the party window include the total amt you must pay to everyone, not just units in your party currently
>the level of prisoners is added to 50 to determine how much you get for selling them
>each rank of prisoner mgmt lets you handle 10 prisoners
>you can handle 5 prisoners even w/o ranks in prisoner management
>persuasion affects number of villagers you recruit and commission of recruiting, as noted under GAME MENUS section
>Siege towers should move a lot faster while moving up to the castle/town
>Leadership is A PARTY SKILL... kinda
>>The highest Leadership skill of the party is used to determine max party size, BUT...
>>only your Leadership skill applies to wage reduction, morale, and recruited prisoner desertion chances
>>IMPORTANT NOTE! Leadership now counts wether the companion is wounded or not,
>>>so you don't have to worry about suddenly losing your army cause your charismatic co-leader
>>>got all gung-ho about running their face into a pointy object

TRIGGERS
>armor/weap merchants have x10 avail gold (between 2-4k), goods/horse merchants have x2 avail gold (between 1-2k)

SIMPLE TRIGGERS
>imprisoned lords escape much less often, and the check is only made 1x per week.
>>Prisoner mgmt skill of the player reduces escape chances
>food consumption easier to predict in-game for player party (1 unit eats 1 food each 24 hrs)
>>Every 24 hours, each unit in your party eats 1 food
>schools add +1 to your relationship with the town each week, instead of +1/month (roughly 4x as much)
>bandit spawning is done every 12 hours, instead of 36. Tired of empty maps and hunting eternally for those 'troublesome looters'
>>Looters are guaranteed to be spawned at the quest-center you got the looters quest from, and they will patrol around it
>>>even if they get chased off, they'll return to patrol around the center
>takes less time to plunder & raze a village
>renown does not deteriorate each week
>prisoner management actually reduces escape chances for your captured lords by 2% per rank
>>base escape chances are 30 in party, 15 in castle/town, 5 in prison tower

MISSION TEMPLATES
>HEY, THIS ISN'T CURRENTLY IN RIGHT NOW. in sieges, normal open-ground battles, and village raids, both attackers and defenders get up to 100 waves of reinforcements.
>>basically, this means battles are start to finish without a menu screen in between battles.

SKILLS
>updated some descriptions to be more informative

link to the mod files: http://www.mediafire.com/?sharekey=9b288b7cd06cde857432d3c9683f450ae04e75f6e8ebb871 [nofollow]
Zipped with Winrar, though I think pretty much any zip program will open rars these days.