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

0 Members and 1 Guest are viewing this topic.

KorpiSoturi

  • Recruit
  • *
  • M&B, best game ever!
    • View Profile
  • Faction: Nord
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #360 on: March 08, 2009, 08:53:58 PM »
I tried to add that simple_trigger you gave but it didn't work. For now everything else has worked except when I try to put the extra variable in the game_menu, comes SyntaxError. :?:

(click to show/hide)

It looks like this when I put the variables in.
« Last Edit: March 08, 2009, 09:12:22 PM by KorpiSoturi »

Genveir

  • Recruit
  • *
    • View Profile
  • Faction: Nord
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #361 on: March 08, 2009, 10:19:57 PM »
I tried to add that simple_trigger you gave but it didn't work. For now everything else has worked except when I try to put the extra variable in the game_menu, comes SyntaxError. :?:

(click to show/hide)

It looks like this when I put the variables in.

I didn't read all of it, but you don't have commas on (jump_to_menu,"mnu_start_game_2"). So that's a syntax error right there.

Mordachai

  • Squire
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #362 on: March 09, 2009, 03:29:25 AM »
Ok, I'm posting a bit of code that is fully functional, as far as I can tell, with a fair bit of testing (been playing using it for about 2 weeks).  It was originally written by Leprechaun, but of course I've extended it and modified it, and fixed bugs, and so on, so its considerably more than it was when I first came by it (great idea from Leprechaun!).

Feel free to use it, abuse it, etc.  As always, Leprechaun and I should get some mention. 

Features:
* New, extended Prisoner Chat
* Ability to persuade prisoners to join you directly
* Ability to set them free
* Ability to murder regular prisoners
* Ability to taunt nobles
* Ability to let nobles go, with a gain to honor and relation
* Ability to kill nobles permanently in-game.

This last feature - permanent death to an enemy noble, includes selection of a new king for a kingdom, as well as extensive repercussions for ones actions.  See the comments in the code for specifics, but it aint good. :evil:

The whole succession part of the code hasn't been tested in practice.  There may be a bug or two there, so use at your own risk.

Update: I just happened to capture a King, and tested the succession code by having him killed.  It works properly now, as I made some minor bug fixes to the code to correct for some missing messages and the order the messages were being produced so that its easier to get a sense of what happened if you look at the Quest->Recent Messages.

Enjoy: 8-)
The following goes in your module_dialogs.py.  It must precede or replace the native prisoner dialogs (if you place it after, then it will be ignored in favor of the native code).
Code: [Select]
  ###################################################################################################
  # Prisoner Talk - Originally written by Leprechaun, majorly overhauled & extended by Mordachai
  ###################################################################################################

  # this is a dummy dialog - it sets up the globals we need
  [anyone|plyr, "prisoner_chat", [
    (store_conversation_troop,"$g_talk_troop"),
    (store_troop_faction,"$g_talk_troop_faction","$g_talk_troop"),
    (store_relation, "$g_talk_troop_faction_relation", "$g_talk_troop_faction", "fac_player_faction"),
    (call_script, "script_troop_get_player_relation", "$g_talk_troop"),
    (assign, "$g_talk_troop_relation", reg0),
    (eq, 1, 0)
  ], "", "close_window", []],

  # the following is intended to catch when you free up space for a prisoner that already agreed to join you
  [anyone|plyr, "prisoner_chat", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 1),(troops_can_join, 1)], "All right, I have made room for you.", "prisoner_chat_accept_confirm", []],
  [anyone,      "prisoner_chat_accept_confirm", [], "I am at your command, my {lord/lady}.", "prisoner_chat_accept3", []],

  # and we catch the case where you still don't have any room for a pending conscripted prisoner
  [anyone|plyr, "prisoner_chat", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 1),(neg|troops_can_join, 1)], "I am sorry, I still have no room for you. You'll have to wait a while longer.", "close_window",[]],

  # default entry (no prior join agreement, or they've previously refused)
  [anyone|plyr, "prisoner_chat", [(neg|troop_slot_eq, "$g_talk_troop", slot_troop_occupation, slto_kingdom_hero)], "You there!", "prisoner_chat_commoner", []],
  [anyone|plyr, "prisoner_chat", [(troop_slot_eq, "$g_talk_troop", slot_troop_occupation, slto_kingdom_hero),(str_store_troop_name, s1, "$g_talk_troop")], "{s1}", "prisoner_chat_lord", []],

  # reaction to you based on noble or low-birth
  [anyone,     "prisoner_chat_commoner", [], "Me?! (Gulp!)", "prisoner_chat_menu",[]],
  [anyone,     "prisoner_chat_lord", [(str_store_troop_name, s1, "trp_player")], "Yes, {Lord/Lady} {s1}?", "prisoner_chat_noble",[]],

  # nobles chat begin
  [anyone|plyr,"prisoner_chat_noble", [], "You are free to go.", "prisoner_chat_noble_prerelease",[]],
  [anyone|plyr,"prisoner_chat_noble", [], "You will remain my prisoner.", "prisoner_chat_noble_prekeep",[]],
  [anyone|plyr,"prisoner_chat_noble", [(gt, "$players_kingdom", 0)], "You have committed high treason!", "prisoner_chat_treason",[]],

  [anyone|plyr,"prisoner_chat_noble_prerelease", [], "Despite what you may have heard, I am a {man/woman} of honor.  You are free to go.", "prisoner_chat_noble_release", []],
  [anyone,     "prisoner_chat_noble_release", [], "I will not forget this act of Chivalry!", "close_window",
   [
    # remove the troop from prison
    (call_script, "script_remove_troop_from_prison", "$g_talk_troop"),
    (party_remove_prisoners, "p_main_party", "$g_talk_troop", 1),

    # determine how much honor and faction relation change this prisoner is worth
    (try_begin),
      # king
      (faction_slot_eq, "$g_talk_troop_faction", slot_faction_leader, "$g_talk_troop"),
      (assign, ":honor", 5),
      (assign, ":fac_reln", 15),
    (else_try),
      # other lord
      (assign, ":honor", 2),
      (assign, ":fac_reln", 5),
    (try_end),

    # give the player their honor, faction relation, and lord relation change
    (call_script, "script_change_player_relation_with_troop", "$g_talk_troop", 10),
    (call_script, "script_change_player_honor", ":honor"),
    (call_script, "script_change_player_relation_with_faction", "$g_talk_troop_faction", ":fac_reln" ),
  ]],

  [anyone|plyr,"prisoner_chat_noble_prekeep", [], "You will understand if I keep you hostage until your family can afford to... compensate me for certain expenses and hardships I have endured to keep you fed and ...safe... these past weeks.", "prisoner_chat_noble_keep",[]],

  [anyone,     "prisoner_chat_noble_keep", [(ge, "$player_honor", 10),(ge, "$g_talk_troop_relation", 0)], "Truly, this is beneath you.", "close_window",[]],
  [anyone,     "prisoner_chat_noble_keep", [], "And I trust you will be as understanding when I hunt you down like the dog you are!", "close_window",[(call_script, "script_change_player_relation_with_troop", "$g_talk_troop", -1)]],

  # commoners chat begin
  [anyone|plyr,"prisoner_chat_menu", [], "Hmmm... perhaps you're not as stupid as the rest of those rabble.", "prisoner_chat_offer",[]],
  [anyone|plyr,"prisoner_chat_menu", [], "As wretched as you are, I cannot help but feel sorry for you.", "prisoner_chat_release",[]],
  [anyone|plyr,"prisoner_chat_menu", [], "The sight of you makes me sick! You.. Die.. Now!", "prisoner_chat_die1",[]],
  [anyone|plyr,"prisoner_chat_menu", [], "Get back in line, Scum!", "close_window",[]],

  [anyone|plyr,"prisoner_chat_release", [], "I'm feeling magnanimous today.  Begone, before I change my mind!", "prisoner_chat_release2", []],
  [anyone,     "prisoner_chat_release2", [], "Oh, thank you, {sir/madam}.  Blessings on you!", "close_window",
    [(remove_troops_from_prisoners, "$g_talk_troop", 1),(call_script, "script_change_player_honor", 1)]],

  [anyone|plyr,"prisoner_chat_offer", [], "Listen, scum, you have one last chance to redeem yourself before I sell you to the slave-traders.  "\
                                      "Drop all your previous allegiances and swear fealty to me, obey my every order to the letter, and you'll be paid, fed and equipped.  "\
                                      "If you don't....well, let's just say that life as a slave will be seemingly unending years of agony, malnutrition and beatings.  "\
                                      "I'd advise you to think very, very carefully before choosing.  ", "prisoner_chat_reaction",
                                      [(call_script, "script_determine_prisoner_agreed", "$g_talk_troop", "$g_talk_troop_faction_relation")]],

  [anyone,     "prisoner_chat_reaction", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 1)], "Thank you for your mercy, {sir/madam}. I swear on my mothers grave I will serve you, my {lord/lady}!","prisoner_chat_accept1",[]],
  [anyone,     "prisoner_chat_reaction", [], "I'll show you what I think of your offer! (The prisoner spits at your feet) There. Now get lost, I'm not interested.", "prisoner_chat_refuse",[]],

  [anyone|plyr,"prisoner_chat_refuse", [], "I see...", "prisoner_chat_menu",[]],

  [anyone|plyr,"prisoner_chat_die1", [], "(You advance on the prisoner...)", "prisoner_chat_die2",[]],
  [anyone,     "prisoner_chat_die2", [], "Please, {sir/madam}, don't kill me. I am a defenceless prisoner. Surely you're not that cruel?", "prisoner_chat_die3",[]],
  [anyone|plyr,"prisoner_chat_die3", [], "(Kill the prisoner)", "prisoner_chat_die4",[]],
  [anyone|plyr,"prisoner_chat_die3", [], "No, I will not sink that low.", "close_window",[]],
  [anyone|plyr,"prisoner_chat_die4", [], "(The prisoner struggles against his shackles, desperate to free himself and escape you, but to no avail. You slit their throat with a knife and watch, satisfied, as his corpse sags to the floor.)", "close_window",
   [(remove_troops_from_prisoners, "$g_talk_troop", 1),
    (call_script, "script_change_player_honor", -1)]],

  [anyone|plyr, "prisoner_chat_accept1", [], "If you so much as fail to tremble on my command, I will have you severely disciplined!", "prisoner_chat_accept2",[]],
  [anyone|plyr, "prisoner_chat_accept1", [], "In my camp we are all treated as equals.  I expect your obedience, but also your trust.", "prisoner_chat_accept2",[]],

  [anyone,      "prisoner_chat_accept2", [], "I will obey your wishes, my {lord/lady}.  I swear!", "prisoner_chat_accept3",[]],

  [anyone|plyr, "prisoner_chat_accept3", [(neg|troops_can_join, 1)], "Oh! Apparently there isn't enough room for you in my party. I will be back when I have made space.", "close_window", []],
  [anyone|plyr, "prisoner_chat_accept3", [(troops_can_join, 1)], "Excellent. Report to the quartermaster for provisions and equiment.  There is hard fighting ahead.", "close_window",
   [(troop_set_slot, "$g_talk_troop", slot_prisoner_agreed, 0),
    (remove_troops_from_prisoners, "$g_talk_troop",1),
    (party_add_members, "p_main_party", "$g_talk_troop", 1),
    (call_script, "script_change_troop_renown", "trp_player", 1),]],

  [anyone|plyr, "prisoner_chat_treason", [(str_store_troop_name, s1, "$g_talk_troop"), (str_store_faction_name, s2, "$players_kingdom")],
    "{s1}, you have committed cimes against the {s2}, for which you will now stand trial.^How plead you?", "prisoner_chat_treason_plead",
    [
      # determine the noble's reaction to this accusation
      (store_random_in_range, reg0, 1, 5),#bug: must set upper number one higher to actually generate correct range
      #TODO: weight the reaction according to the renown?  Or at least according to king or not...
      (troop_set_slot, "$g_talk_troop", slot_prisoner_agreed, reg0),
    ]
  ],

  [anyone,      "prisoner_chat_treason_plead", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 1),],
    "Please have mercy upon my soul.  All I have done, I have done in the name of my King and Country!  I am but a patriot, as you, and I deserve your respect, if nothing else.", "prisoner_chat_treason_choose", []],
  [anyone,      "prisoner_chat_treason_plead", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 2),],
    "You are gravely mistaken!  I am an honorable Lord, and I have done nothing that you would not do were our roles exchanged.", "prisoner_chat_treason_choose", []],
  [anyone,      "prisoner_chat_treason_plead", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 3),],
    "I spit on you and yours!  You are but a cur come to put on airs, as though you were Noble and had any right whatsoever to judge me!  Me!  You are a nothing but a common brigand and a coward!  I do not bow to you.  You should drop to your knees and beg *my* forgiveness!", "prisoner_chat_treason_choose", []],
  [anyone,      "prisoner_chat_treason_plead", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 4),],
    "You dare accuse me?!  You sniveling whelpling!  I should see you flogged and put in chains in one of my prisons for your insolence!", "prisoner_chat_treason_choose", []],

  [anyone|plyr, "prisoner_chat_treason_choose", [], "I am a {man/woman} of honor.  I shall spare your life this day!", "prisoner_chat_treason_not_guilty",
    [
      #TODO: have the relation with the prison have a mixed (random) result - relief, anger, etc, which dictates their final monologue to the player before exiting the dialog

      # make sure we don't try to recruit this prisoner later!
      (troop_set_slot, "$g_talk_troop", slot_prisoner_agreed, 0),
    ]
  ],

  [anyone,      "prisoner_chat_treason_not_guilty", [(str_store_troop_name, s1, "trp_player")], "There is yet hope for you, {s1}.", "close_window", []],

  [anyone|plyr, "prisoner_chat_treason_choose", [], "You do not deserve leiniency.  You must pay for your crimes with your life.", "prisoner_chat_treason_guilty", []],

  [anyone|plyr, "prisoner_chat_treason_guilty", [], "For your many crimes against {s1}, I hereby sentence you to death, to be carried out immediately.  Have you any final words to say?", "prisoner_chat_treason_final_words",
    [(store_random_in_range, reg0, 1, 6), (troop_set_slot, "$g_talk_troop", slot_prisoner_agreed, reg0)]],

  [anyone,      "prisoner_chat_treason_final_words", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 1)], "I believe you will one day come to regret your actions.  There is only one who is worthy to decide another's fate... and that one is not you.", "prisoner_chat_treason_execute", []],
  [anyone,      "prisoner_chat_treason_final_words", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 2)], "You are a coward and a dog!  May your soul rot eternal, damn you!", "prisoner_chat_treason_execute", []],
  [anyone,      "prisoner_chat_treason_final_words", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 3)], "Winter's mortality,^locked in frozen indifference,^melts with Spring's rebirth.", "prisoner_chat_treason_execute", []],
  [anyone,      "prisoner_chat_treason_final_words", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 4)], "You will find no peace on this earth!  I shall haunt thee eternal!  Unto death you will find nothing but unhappiness and fear.  And beyond... only torture and pain!", "prisoner_chat_treason_execute", []],
  [anyone,      "prisoner_chat_treason_final_words", [(troop_slot_eq, "$g_talk_troop", slot_prisoner_agreed, 5)], "Who are you?^A day passes^We are but children", "prisoner_chat_treason_execute", []],

  [anyone|plyr, "prisoner_chat_treason_execute", [],
    "(The prisoner struggles against his shackles, desperate to free himself and escape you, but to no avail. You slit his throat and watch, satisfied, as his corpse sags to the floor.)",
    "close_window",
    [
      # attempt to allow the player to see the consequences of their actions
      #(set_show_messages, 1),  # this not only fails - but messages are hereafter disabled in the main game...

      # make sure we don't try to recruit this prisoner stack later!
      (troop_set_slot, "$g_talk_troop", slot_prisoner_agreed, 0),

      # "kill" the NPC - force the 48 hr respawn kingdom heros trigger to ignore this troop (no party will be created for this troop, ever again)
      # [q.v. script_create_kingdom_hero_party]
      (troop_set_slot, "$g_talk_troop", slot_troop_occupation, slto_dead),

      # remove them from their faction
      (troop_set_slot, "$g_talk_troop", slot_troop_change_to_faction, "fac_no_faction"),
      (troop_set_slot, "$g_talk_troop", slot_troop_original_faction, "fac_no_faction"),

      # determine the penalty for this act (based on the honor of the troop they've killed)
      (troop_get_slot, ":impact", "$g_talk_troop", slot_troop_renown),
      (val_div, ":impact", -33),
      (store_div, ":half", ":impact", 2),

      # reduce the player's relationship with every village, town, and castle
      (try_for_range, ":center", centers_begin, centers_end),
        (store_faction_of_party, ":faction", ":center"),
        (store_relation, ":relation", ":faction", "$g_talk_troop_faction"),
        (try_begin),
          (le, ":relation", -10),
          # enemies, half impact
          (call_script, "script_change_player_relation_with_center", ":center", ":half"),
        (else_try),
          # not at war, full impact
          (call_script, "script_change_player_relation_with_center", ":center", ":impact"),
        (try_end),
      (try_end),

      # reduce the player's relationship with every hero, companion, lady, and daughter
      (try_for_range, ":troop", trp_npc1, trp_heroes_end),
        # don't make the dead any angrier than they already are!
        (neg|troop_slot_eq, ":troop", slot_troop_occupation, slto_dead),
        (store_troop_faction, ":faction", ":troop"),
        (store_relation, ":relation", ":faction", "$g_talk_troop_faction"),
        (try_begin),
          (le, ":relation", -10),
          # enemies, half impact
          (call_script, "script_change_player_relation_with_troop", ":troop", ":half"),
        (else_try),
          # not at war, full impact
          (call_script, "script_change_player_relation_with_troop", ":troop", ":impact"),
        (try_end),
      (try_end),

      # reduce the player's relationship with every faction (enemies 1/2 as much)
      (try_for_range, ":faction", kingdoms_begin, kingdoms_end),
        (store_relation, ":relation", ":faction", "$g_talk_troop_faction"),
        (try_begin),
          (le, ":relation", -10),
          # enemies, half impact
          (call_script, "script_change_player_relation_with_faction", ":faction", ":half"),
        (else_try),
          # not at war, full impact
          (call_script, "script_change_player_relation_with_faction", ":faction", ":impact"),
        (try_end),
      (try_end),

      # apply the honor hit
      (call_script, "script_change_player_honor", ":impact"),

      # party morale takes a hit as well
      (call_script, "script_change_player_party_morale", ":half"),

      # but give them renown for this evil deed (their deed spreads upon every tongue, impressing some, and cowing others)
      (val_mul, ":impact", -1),
      (call_script, "script_change_troop_renown", "trp_player" , ":impact"),

      # start with the assumption that the fief should return to its faction for redistribution
      (assign, ":fief_faction", "$g_talk_troop_faction"),

      (try_begin),
        # handle executing the King!
        (faction_slot_eq, "$g_talk_troop_faction", slot_faction_leader, "$g_talk_troop"),

        # find best candidate to become king
        (assign, ":best_troop", -1),
        (assign, ":best_renown", -1),
        (try_for_range, ":troop", kingdom_heroes_begin, kingdom_heroes_end),
          (neg|troop_slot_eq, ":troop", slot_troop_occupation, slto_dead),  #can't choose a dead hero!
          (store_troop_faction, ":faction", ":troop"),
          (eq, ":faction", "$g_talk_troop_faction"),
          (troop_slot_eq, ":troop", slot_troop_occupation, slto_kingdom_hero),  #only other heros of this faction may become the king
          (troop_get_slot, ":renown", ":troop", slot_troop_renown),
          (gt, ":renown", ":best_renown"),
          (assign, ":best_troop", ":troop"),
          (assign, ":best_renown", ":renown"),
        (try_end),

        (try_begin),
          # check if a candidate was found
          (neq, ":best_troop", -1),

          # make them king
          (faction_set_slot, "$g_talk_troop_faction", slot_faction_leader, ":best_troop"),

          # announce it!
          #TODO: generate a presentation for this! (start_presentation, "prsnt_enemy_succession"),
          (str_store_troop_name, s1, ":best_troop"),
          (str_store_faction_name, s2, "$g_talk_troop_faction"),
          (display_message, "@{s1} is the new King of the {s2}!!!", 0xFFFF2222),
          #TODO: update the game log for this event
        (else_try),
          # all of the lords have been eliminated - so eliminate the faction by making their last fief neutral (q.v. trigger: # Check if a faction is defeated every day)
          (assign, ":fief_faction", "fac_no_faction"),
        (try_end),
      (try_end),

      # free up the deceased's fief
      (try_for_range, ":fief", centers_begin, centers_end),
        (party_get_slot, ":lord", ":fief", slot_town_lord),
        (eq, ":lord", "$g_talk_troop"),
        (call_script, "script_give_center_to_faction", ":fief", ":fief_faction"),
      (try_end),

      # no longer our prisoner
      (call_script, "script_remove_troop_from_prison", "$g_talk_troop"),
      (remove_troops_from_prisoners, "$g_talk_troop", 1),
    ]
  ],

  ###################################################################################################
  # End Prisoner Talk
  ###################################################################################################

Please note that slto_dead is not a native symbol - if you want to use the above you'll also need to add slto_dead = 86 in your module_constants.py.

Please note that slot_prisoner_agreed is not a native symbol - simply add slot_prisoner_agreed = 142 to your module_constants.py.  Actually, 142 is arbitrary - any unused slot will do.

Additionally, you'll need to add this script to module_scripts.py - I added it towards the end, as the last script in the file, but you're welcome to place it anywhere within the list of scripts within that file:
Code: [Select]
  #MORDACHAI - update whether the specified prisoner would like to join the player's party
  # script_determine_prisoner_agreed
  # Input: arg1 = troop, arg2 = troop faction relation
  # Output: slot_prisoner_agreed is set to 1 if they agreed, or 0 if not
  #         reg0 = agreed or not
  ("determine_prisoner_agreed",
    [
      (store_script_param, ":troop", 1),
      (store_script_param, ":relation", 2),

      # upper bound = Persuasion*3 + Charisma + Leadership*3 + Honor/2 + Renown/100
      (store_attribute_level, ":charisma", "trp_player", ca_charisma),
      (store_skill_level, ":persuasion", "skl_persuasion", "trp_player"),
      (store_skill_level, ":leadership", "skl_leadership", "trp_player"),
      (val_mul, ":persuasion", 3),
      (val_mul, ":leadership", 3),
      (store_div, ":half_honor", "$player_honor", 2),
      (troop_get_slot, ":renown_factor", slot_troop_renown),
      (val_div, ":renown_factor", 100),
      (assign, ":upper_bound", ":persuasion"),
      (val_add, ":upper_bound", ":leadership"),
      (val_add, ":upper_bound", ":charisma"),
      (val_add, ":upper_bound", ":half_honor"),
      (val_add, ":upper_bound", ":renown_factor"),
      (val_min, ":relation", ":upper_bound"),

      # determine their reaction (relation...upper_bound)
      (store_random_in_range, ":reaction", ":relation", ":upper_bound"),
      (assign, reg1, ":reaction"),
      (assign, reg2, ":relation"),
      (assign, reg3, ":upper_bound"),
      #(display_message, "@Prisoner Agrees Check: rolled a {reg1} out of a possible {reg2}-{reg3}"),#diagnostic only

      # record whether they agree or not
      (try_begin),
        (ge, ":reaction", 0),
        (troop_set_slot, ":troop", slot_prisoner_agreed, 1),
      (else_try),
        (troop_set_slot, ":troop", slot_prisoner_agreed, 0),
      (try_end),

      # return the results
      (troop_get_slot, reg0, ":troop", slot_prisoner_agreed),
      #(display_message, "@Prisoner Agrees Check: slot_prisoner_agreed = {reg0?yes:no}"),#diagnostic only
    ]
  ),
« Last Edit: March 11, 2009, 02:54:50 PM by Mordachai »

MartinF

  • Squire
  • *
  • Down Under
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #363 on: March 09, 2009, 05:44:08 AM »
I tried to add that simple_trigger you gave but it didn't work. For now everything else has worked except when I try to put the extra variable in the game_menu, comes SyntaxError. :?:

(click to show/hide)

It looks like this when I put the variables in.

Yeah it's no wonder that doesn't work.. you're duplicating the start options, adding new menu's inside other menus and I don't know what else. There's at least three options of each type now and you've added them inside other menu tuples  :roll:
When something doesn't work, at least make sure you check the way tuples are built up. There's an explanation at the top of each module file and if in doubt, just look at existing tuples.

You need to add the variable.. not the whole thing. It should look like this:

(click to show/hide)

So don't add loads of stuff to the menu, add just those two variables to each of the options.

KorpiSoturi

  • Recruit
  • *
  • M&B, best game ever!
    • View Profile
  • Faction: Nord
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #364 on: March 09, 2009, 06:23:37 AM »
Thanks a LOT! Now it works! :D

Kolba

  • Guest
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #365 on: March 09, 2009, 01:42:36 PM »
Mordachai's code doesn't completely work. I need to add some troop slots in module_constants.py, but I've got another error. The script:

"script_determine_prisoner_agreed"

is missing. You forgot to paste on forum new module_scripts.py code. I hope you'll post it soon.

jik

  • Knight
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #366 on: March 09, 2009, 01:59:55 PM »
Ok, I'm posting a bit of code that is fully functional, as far as I can tell, with a fair bit of testing (been playing using it for about 2 weeks).  It was originally written by Leprechaun, but of course I've extended it and modified it, and fixed bugs, and so on, so its considerably more than it was when I first came by it (great idea from Leprechaun!).

Feel free to use it, abuse it, etc.  As always, Leprechaun and I should get some mention. 

Features:
* New, extended Prisoner Chat
* Ability to persuade prisoners to join you directly
* Ability to set them free
* Ability to murder regular prisoners
* Ability to taunt nobles
* Ability to let nobles go, with a gain to honor and relation
* Ability to kill nobles permanently in-game.
.
.
.
Make sure that when you post code like this (which is nice, I need permadeath for lords/nobles in my mod) make sure you put all the reference and related stuff with your post.  I noticed (pretty much right away) that the slot_occupation slto_death is not native.  Sure an easy fix, but some might not get that.  The reference material is just as important as the code. 

[EDIT] :Sorry, trimmed the quote...
« Last Edit: March 09, 2009, 02:41:31 PM by jik »

MartinF

  • Squire
  • *
  • Down Under
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #367 on: March 09, 2009, 02:26:44 PM »
do you need to even bother with making a new slto_?

If you just set it to 0, wouldn't that accomplish the same thing without having to change the constants.py?

Mordachai

  • Squire
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #368 on: March 09, 2009, 02:29:38 PM »
MartinF - Probably.  Zero is also used for "not in the game yet", which may work perfectly fine.  I just wanted to make the code slightly more self-documenting, and a single constant seems like a minuscule thing.   But feel free to do a search & replace of sto_dead -> 0 or even to 86 (the value I used) to avoid having to add that constant to your constants.py. :wink:

Jik - I added a note to the bottom of my post indicating that sto_dead would need to be added to constants.py - thanks for pointing that out.   Also, would you mind not copying my entire post - esp. the code piece - in your response, as that way, if I need to update the code due to a bug fix or whatever, there's only one bit of code to have to change, and it will be more likely that others will copy the code from my post instead of the possibly-out-of-date code copy from yours?  Thanks!
« Last Edit: March 09, 2009, 02:37:48 PM by Mordachai »

jik

  • Knight
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #369 on: March 09, 2009, 02:43:15 PM »
Don't forget Kolba's remark...

Won't affect me, cause I will be usinging it in other ways, but again, make sure that all parts are posted, including related scripts....

(I trimmed my other post...  Sorry for that.)

Mordachai

  • Squire
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #370 on: March 09, 2009, 04:18:20 PM »
Mordachai's code doesn't completely work. I need to add some troop slots in module_constants.py, but I've got another error. The script:
"script_determine_prisoner_agreed"
is missing. You forgot to paste on forum new module_scripts.py code. I hope you'll post it soon.

D'oh!   :oops:  New to posting my code... and I was afraid of this.  Sigh... I will modify my original post to include this script when I have a chance later today (I'm on Eastern Standard Time).   :?

Edit: I have now added that script.  Please let me know if you find further omissions or issues with it, and I will keep fixing it until it is perfect.
« Last Edit: March 09, 2009, 05:41:15 PM by Mordachai »

MartinF

  • Squire
  • *
  • Down Under
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #371 on: March 09, 2009, 06:11:34 PM »
you might want to change the text of your msg so it says slto_dead instead of sto_dead or whatever it says now otherwise it still won't work :D

nice piece of code btw, there've been a couple of lords I've been wanting to put out of commission permanently!

Mordachai

  • Squire
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #372 on: March 09, 2009, 06:43:36 PM »
Martin - thanks, fixed.

One thing I would love community feedback on is how draconian do you think the ramifications for killing a lord should be?

Currently, I deduct 1/33 of the target's renown against your honor, your relations with every lord, lady, faction, and center on good terms with the deceased, and 1/2 that against every such entity which is at war with them, including your own party morale.

So, for a common example, your target has 450 honor you're looking at a 13 point loss in Honor, relations with most lords, ladies, towns, villages, castles, and other factions, and a 7 point loss of party morale.

The biggest impact of that is that its very hard to acquire village volunteers.  Generally, this much of a loss of relation puts every village solidly in the "I dislike you" camp, and no more reinforcements for you (You'd have to work hard to regain their favor, or you can only recruit from town mercenaries & by freeing prisoners).

For another example, a king is more like 1/33 of 1000 = 30 point penalty to Honor and almost every relation...
« Last Edit: March 09, 2009, 06:56:49 PM by Mordachai »

Kolba

  • Guest
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #373 on: March 09, 2009, 07:44:37 PM »
I found something weird in script:

(store_skill_level, ":persuasion", skl_persuasion, "trp_player"),

I built module and got error saying, that: "skl_persuasion" is not defined. So, I deleted skl_persuasion from this part of script and it worked.  :shock:
Anyone had same problem?

« Last Edit: March 09, 2009, 07:47:06 PM by Kolba »

Mordachai

  • Squire
  • *
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #374 on: March 09, 2009, 08:02:38 PM »
I added an import of the skills id file at the top of my modules_scripts.py - you can do the same, or you can simply put skl_persuasion in quotes: "skl_persuasion".

Actually, this brings up another point: the module system handles this inconsistently - sometimes they use the symbols directly, as I did, and other times they use them indirectly, by quoting them.  Either way amounts to the same thing, IFF you've imported the file that defines the given symbol.  I just hate inconsistency, and chose to go with unquoted constants for skills and attributes.  But, this means I had to import some extra ID files to a few of my module files.  You may wish to stick with quoting them instead, as there are fewer changes required for that to work (fewer = none for the native code, and only minor change to my code).
« Last Edit: March 09, 2009, 08:05:31 PM by Mordachai »