PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

bryce777 said:
What does maw do?  I always sort of wondered that.  If you remove the main party, the game will crash, so I don't think that is a great way to handle things.

There is a tag to make the player (or player party i can't remember) always die.
 
bryce777 said:
What does maw do?  I always sort of wondered that.  If you remove the main party, the game will crash, so I don't think that is a great way to handle things.
it does? I once made soimething accidently that removes your party, I thought it was remove party, I can't remember
 
Yoshiboy said:
bryce777 said:
What does maw do?  I always sort of wondered that.  If you remove the main party, the game will crash, so I don't think that is a great way to handle things.

There is a tag to make the player (or player party i can't remember) always die.

Ok, that would make sense.  you could still wander around, but you would be dead.


@duke maw made maw's murder mod and it has permadeath but I have not played because I am not up for ironman.
 
the permanent death applies to the player and the heroes too? then that's just what i wanted : a "gameover". but what happens when the player dies? a reset to main menu and a game over message or what?
 
i am maw.... fear me.

or at least cautiously move away without being noticed...

actually, there is a tag/flag, tf_allways_fall_dead, that you add to the troop in the python module file. thats the simple one. if a player gets to zero hp's by end of battle, when the party is reconstituted on the main map, he is removed as dead.

which leaves the party without the player in the party - which in essence locks up the game. i got fancy once and had a pop up describing that the game was over, you're dead, restart normally at one point. i didn't follow up on having ana auto kick back to the start screen (even if it can be done).

i had a moderately more complex idea that i never finished that operated as a condition through module_mission_templates that if the player character was in the status of 'main_hero_fallen' that randomized the death or permenant loss of one str, agl, int, or chr. i didn't like it. rather more, i like Last Days temp injury but never followed up on trying to copy it - it was more realistic in impacting a long, temporary loss. i would rather have that, with apossibility of death, and another possibility of permanant loss.

if you pull the main party off the map, the game goes into a loop or crashes, depending on what you have going on.

screw it. i'm putting a version of m3 up tonite. everyone can scream at me afterwards. since the new vbersions coming out soon, it doesn't matter. i pulled a lot of my extras out but i have a functional bland copy i'll dump on the repository. play it. its a twist on m&b. maw
 
hey... not REALLY a python SCRIPT... but... did you know...

that although the items have a limit (i forget - 512?) you can have lot more different skins by adding multyiple meshes to an item and giving it a modifier bit, in module_items.py      ie:


["quality_leather","Quality  Leather", [("brown_leather",imodbit_ragged),("black_leather",imodbit_hardened),("gray_leather",imodbit_thick ),("red_leather", imodbit_sturdy)], itp_type_body_armor|itp_covers_legs|itp_merchandise, 0, 252,weight(7)|body_armor(13)|leg_armor(3),imodbits_cloth ],

every time my "quality_leather" is randomly pulled, and is sturdy, it shows up with a red_leather mesh, every time it randomly appears in a merchants invesntory as "hardened" it is the black_leather mesh.

why is this cool?

well... on one hand you can edit and armor or a weapon meshes just slightly to reflect its condition, then associate it so it really looks like that condition...

for instance, you can make a mesh reflecting a ragged leather that actucally looks ragged, or a rusty sword with rust actually on it...

why did i really think this important?

well, to mix up visuals in the game, at one time i added 16 war horses, and although they were added as separate items (warhorse1, warhorse2, etc) when the mission came up from a governor 'bring me 6 warhorses' only the 'wahorse' common would be counted, although i wanted all of them to be warhorses.

by adding all the meshes to one item, the one item (an its values) are all associated with one item... so various swords with the same stats can be all called in the class of 'longsword' or 'shortsword' or 'bastard sword' but allow different visuals....

bah. i'm drunk. i hope i don't look stupid writing this tomorrow. amw
 
Sorry, Colt, for for breaking your monopoly.
The formation code:

in module_scripts:
========================
("formation_start",
[(get_player_agent_no,reg(10)),
(agent_get_position,1,reg(10)),
  (try_for_range,reg(20),1,100), #reset of the player dummy-slots
  (agent_set_slot,reg(10),reg(20),0),
  (try_end),
          (try_for_agents,reg(5)),
            (assign,reg(0),0),
            #Not the player
            (neq, reg(5), reg(10)),
            #Not Dead
            (agent_is_alive, reg(5)),
            #Not a Horse?
            (agent_is_human, reg(5)),
            #If the Selected Troop is an Ally
            (agent_is_ally,reg(5)),
  (assign,reg(1),1),
(try_begin),
    (assign,reg(20),1), #reg(20) is the agent number to use every position only once
    (agent_get_slot,reg(21),reg(10),reg(20)), #player agent used as a dummy not to make several agent use one position
    (eq,reg(21),0), #number isn't used, yet
    (assign,reg(1),reg(20)),
(assign,reg(3),reg(1)),
(val_mul,reg(3),100),
(copy_position,reg(1),1),
(position_move_x,reg(1),reg(3)), #number 1 = 100 metres right to the player agent 2= 200 etc...
(agent_set_scripted_destination,reg(5),reg(1)), #tells the agent to run there
    (agent_set_slot,reg(5),1,reg(1)), #tells the agent which position he has - only important if you want to do somethink else with the script, it would work without it right now.
(agent_set_slot,reg(10),reg(20),1), #tells the game that the number is used, by using the player slots.
(else_try),
#very odd, sorry (the more call_scripts are there \/, the more agents will build a formation
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),(else_try),
(call_script,"script_formation_repeat"),(else_try),(call_script,"script_formation_repeat"),
  (try_end),  
(try_end),
]),
("formation_repeat",
[     (val_add,reg(20),1), # adds 1 to the agent number
    (agent_get_slot,reg(21),reg(10),reg(20)),
    (eq,reg(21),0), # again, is the number already used?
    (assign,reg(1),reg(20)), #just copying the number to use it somewhere else...
(assign,reg(3),reg(1)), #again copying
(assign,reg(4),0), #assigns the row of this agent to 0
#-#-#-#-#-#-#-#-#-#
(try_for_range,reg(15),1,100), #this try-code assigns the right row.
(assign,reg(17),reg(15)),
(assign,reg(16),reg(15)),
(val_mul,reg(15),5), #number of troops in one line
(val_mul,reg(16),5), #has to be the same as above
(val_add,reg(16),5), #has to be the same as above
(gt,reg(3),reg(15)),
(le,reg(3),reg(16)),
(assign,reg(15),reg(17)),
(val_mul,reg(15),6), #number of troops in one line + 1
(val_sub,reg(3),reg(15)),
(assign,reg(4),reg(17)),
(try_end),
#delete these lines to get a 1 line formation
#-#-#-#-#-#-#-#-#-#

(val_mul,reg(3),100),
(val_mul,reg(4),200),
(copy_position,reg(1),1),
(position_move_x,reg(1),reg(3)),
(position_move_y,reg(1),reg(4)),
(agent_set_scripted_destination,reg(5),reg(1)),
    (agent_set_slot,reg(5),1,reg(1)),
(agent_set_slot,reg(10),reg(20),1),
]),
========================
100 is the distance between the agents from right to left,
200 is the distance between the agents from the front to background


how to use:
add [(ti_on_weapon_attack,[(call_script,"script_formation_start")])] to the weapon that should cause the formation
!Don't change the distance to less than 70 in a line formation, less than 100 otherwise! The guys will build the formation after weapon attack on your right hand site. The max. number of agents is 40 right now.
Everyone feel free to use it, would be nice if I get credit.
Screenshot? Here you go:
formationdq3.jpg
 
Pretty sexy, nice work. Any tips on how you got them so close or is that just a good screenshot. In all of my tests the agent positioning was very innaccurate even though technically the script was fine.
 
x distance of that picis 100,
z is 200.
I think they just look that close because the screen is from above them. I had the same problem with closer distances
 
Oh sorry, by close i really ment lined up. When i used the agent scripted destination command the position they were meant to move to they always wandered around it, not really getting in the right position or at least not getting in there very accurately.
 
I waited untill the agents weren't trolling around and took a screenshoot.
maybe setting them to mtef_defenders would help? I'll try tomorrow
 
Highlander said:
x distance of that picis 100,
z is 200.
I think they just look that close because the screen is from above them. I had the same problem with closer distances

That's what I used for my formation scripts -- exactly the same measurements -- and in all my testing no more than two agents have ever gotten into proper position in a real combat scenario. So I crafted another script to make the agents continuously 'follow the leader', in a disorganised clump, but they still move and fight better.

I just need a way to check agent troop types so I can tell disciplined from undisciplined troops, so I can set which ones will stay in formation and which ones won't.

Wistfully,
Winter
 
i beleive they mill about for a while because they try to stop the moment they get to the position they are supposed to be in, if this is the case try to set a waypoint in between them and thier position, then when they reach the waypoint then have them continue to their position, in effect manually slowing them down, you might need multiple waypoints to slow them enough.  i'd try right now, but i have to go, might not get a chance for a while.
 
Highlander said:
how to use:
add [(ti_on_weapon_attack,[(call_script,"script_formation_start")])] to the weapon that should cause the formation
!Don't change the distance to less than 70 in a line formation, less than 100 otherwise! The guys will build the formation after weapon attack on your right hand site. The max. number of agents is 40 right now.
Everyone feel free to use it, would be nice if I get credit.

Where should i add this "[(ti_on_weapon_attack,[(call_script,"script_formation_start")])] "? In the triggers part of the chosen weapons code?
 
Ok i've already made it work. Thanks for the script. i only use it for my own.

EDIT: Nah. NOt working my way. Maybe some advice? =]
 
Couldn't find it anywhere here, but I assume it's been done before by others. However, I just finished work on a script that lets you give money to heroes in your party, so they have no excuse for not paying you for the stuff you give them. I'm partway through testing, but it should work on both 0.751 and 0.806.

Increments (denars):
5
10
20
50
100
200
500
1000

Worked it out, oddly, by adapting the betting system and combining it with a small portion of Dionisia code. I can't entirely confirm that it works quite yet, but I'll post the code here and any holes you find can be fixed quickly. However, I can't see anything wrong with it - it should work.

Code:
  [anyone|plyr,"member_talk", [[store_troop_gold,reg(0)],[ge,reg(0),5]],
   "Here, let me give you some money to pay your way.", "member_money",[]],
  [anyone|plyr,"member_money", [[store_troop_gold,reg(0)],[ge,reg(0),5]],
   "[Give five denars]", "member_finish_money",[(troop_add_gold,reg(3),5),(troop_remove_gold,"trp_player",5)]],
  [anyone|plyr,"member_money", [[store_troop_gold,reg(0)],[ge,reg(0),10]],
   "[Give ten denars]", "member_finish_money",[(troop_add_gold,reg(3),10),(troop_remove_gold,"trp_player",10)]],
  [anyone|plyr,"member_money", [[store_troop_gold,reg(0)],[ge,reg(0),20]],
   "[Give twenty denars]", "member_finish_money",[(troop_add_gold,reg(3),20),(troop_remove_gold,"trp_player",20)]],
  [anyone|plyr,"member_money", [[store_troop_gold,reg(0)],[ge,reg(0),50]],
   "[More]", "member_money_more",[]],
  [anyone|plyr,"member_money", [],
   "[Cancel]", "member_money_reconsider",[]],
  [anyone|plyr,"member_money_more", [[store_troop_gold,reg(0)],[ge,reg(0),50]],
   "[Give fifty denars]", "member_finish_money",[(troop_add_gold,reg(3),50),(troop_remove_gold,"trp_player",50)]],
  [anyone|plyr,"member_money_more", [[store_troop_gold,reg(0)],[ge,reg(0),100]],
   "[Give one hundred denars]", "member_finish_money",[(troop_add_gold,reg(3),100),(troop_remove_gold,"trp_player",100)]],
  [anyone|plyr,"member_money_more", [[store_troop_gold,reg(0)],[ge,reg(0),200]],
   "[Give two hundred denars]", "member_finish_money",[(troop_add_gold,reg(3),200),(troop_remove_gold,"trp_player",200)]],
  [anyone|plyr,"member_money", [[store_troop_gold,reg(0)],[ge,reg(0),500]],
   "[More]", "member_money_more_more",[]],
  [anyone|plyr,"member_money_more", [],
   "[Less]", "member_money",[]],
  [anyone|plyr,"member_money_more_more", [[store_troop_gold,reg(0)],[ge,reg(0),500]],
   "[Give five hundred denars]", "member_finish_money",[(troop_add_gold,reg(3),500),(troop_remove_gold,"trp_player",500)]],
  [anyone|plyr,"member_money_more_more", [[store_troop_gold,reg(0)],[ge,reg(0),1000]],
   "[Give one thousand denars]", "member_finish_money",[(troop_add_gold,reg(3),1000),(troop_remove_gold,"trp_player",1000)]],
  [anyone|plyr,"member_money_more_more", [],
   "[Less]", "member_money_more",[]],
  [anyone|plyr,"member_money_reconsider", [],
   "Actually, I reconsidered.", "member_talk",[]],
  [anyone|plyr,"member_finish_money", [],
   "I'm done for now.", "member_talk",[]],
  [anyone|plyr,"member_finish_money", [[store_troop_gold,reg(0)],[ge,reg(0),5]],
   "[Give more]", "member_money",[]],

Hmm... how about another version where you can take money from them? I might have to do that...


EDIT: Recruiting prisoners

This code I know for a fact works like a beauty. I know it's easy to figure out, but I thought I'd share it to save you the bother of working it out for yourself.

EDIT again: I've improved it again.
This will now work much better. It stores the conversation troop's relation with the player, then generates a number between that number and good relations. The prisoner will join you if that random number is above 0, so the worse their relation with you, the wider the range for the random number, so the less likely it is to be between 0 and 3.

EDIT: It seems to be unstable. Best to leave it until I fix it.

EDIT once more: Wasn't the problem, but fisheye pointed out a slight niggle that I've now fixed. Should now work perfectly. Enjoy.

Code:
  [anyone|plyr,"prisoner_chat", [[store_conversation_troop,reg(2)],[store_troop_faction,reg(3),reg(2)],[store_relation,reg(4),reg(3),"fac_player_faction"]], "Don't try running away or trying something stupid. I will be watching you.", "prisoner_chat_2",
   [[store_random_in_range,reg(5),reg(4),4]]],
  [anyone,"prisoner_chat_2", [], "No, I swear I won't.", "prisoner_chat_3",[]],
  [anyone|plyr,"prisoner_chat_3", [], "Good. You're not stupid like the rest of these scum.", "prisoner_chat_4",[]],
  [anyone|plyr,"prisoner_chat_4", [], "[End the conversation]", "prisoner_chat_5",[]],
  [anyone|plyr,"prisoner_chat_5", [], "I hope you're looking forward to life as a slave, scum.", "close_window",[]],
  [anyone|plyr,"prisoner_chat_4", [], "[Try to recruit the prisoner]", "prisoner_chat_6",[]],
  [anyone|plyr,"prisoner_chat_6", [], "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 to fight for me and 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 refusing.", "prisoner_chat_7",[]],
  [anyone,"prisoner_chat_7", [[lt,reg(5),0]], "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_8",[]],
  [anyone|plyr,"prisoner_chat_8", [], "[Kill the prisoner]", "prisoner_chat_14",[]],
  [anyone|plyr,"prisoner_chat_8", [], "[Sell the prisoner]", "prisoner_chat_10",[]],
  [anyone|plyr,"prisoner_chat_9", [], "(You advance on the prisoner with your weapon drawn)", "prisoner_chat_11",[]],
  [anyone|plyr,"prisoner_chat_4", [], "[Kill the prisoner]", "prisoner_chat_9",[]],
  [anyone|plyr,"prisoner_chat_10", [], "We have found a roaming slave trader. It's time for us to part ways. Goodbye, it was nice not to know you.", "close_window",
   [[store_conversation_troop,reg(2)],[remove_troops_from_prisoners,reg(2),1],[troop_add_gold,"trp_player",20]]],
  [anyone,"prisoner_chat_11", [], "Please, {sir/madam}, don't kill me. I am a defenceless prisoner. Surely you're not that cruel?", "prisoner_chat_12",[]],
  [anyone|plyr,"prisoner_chat_12", [], "[Kill the prisoner]", "prisoner_chat_13",[]],
  [anyone|plyr,"prisoner_chat_13", [], "Yes, idiot. I am that cruel. Prepare to die.", "prisoner_chat_14",[]],
  [anyone|plyr,"prisoner_chat_14", [], "(The prisoner struggles against his shackles, desperate to free himself and escape you, but to no avail. You slit his throat with a knife and watch, satisfied, as his corpse sags to the floor.)", "close_window",
   [[store_conversation_troop,reg(2)],[remove_troops_from_prisoners,reg(2),1]]],
  [anyone|plyr,"prisoner_chat_12", [], "[Let him live]", "prisoner_chat_15",[]],
  [anyone|plyr,"prisoner_chat_15", [], "Very well, I'll let you live. I hope you enjoy life as a slave.", "prisoner_chat_16",[]],
  [anyone,"prisoner_chat_16", [], "Oh, thank you, {sir/madam}.", "close_window",[]],
  [anyone,"prisoner_chat_7", [[ge,reg(5),0]], "Thank you for your mercy, {sir/madam}. I promise to drop all allegiances to serve you in any way I can.","prisoner_chat_17",[]],
  [anyone|plyr,"prisoner_chat_17", [], "Good. Now, I'll make the rules clear to you. There will be no discrimination against other soldiers in my army because they were once on the opposing side or were bandits. They fight for me now, as do you. Their ties with the past are broken. Think you can handle it?", "prisoner_chat_18",[]],
  [anyone,"prisoner_chat_18", [], "Yes, {sir/madam}. I will obey the rules.", "prisoner_chat_19",[]],
  [anyone|plyr, "prisoner_chat_19", [[neg|hero_can_join]],"Oh. There isn't enough room in my party for you. I will be back when I have made room.", "close_window",
   [[store_conversation_troop,reg(0)],[troop_set_slot,reg(0),slot_prisoner_agreed,1]]],
  [anyone|plyr, "prisoner_chat_19", [[hero_can_join]], "Excellent. From now on, you fight alongside these men. Help them when they need it, and they'll do the same for you. Get equipped and fed. We'll head out as soon as you're done.", "close_window",
   [[store_conversation_troop,reg(0)],[troop_join,reg(0)],[remove_troops_from_prisoners,reg(0),1]]],
  [anyone|plyr,"prisoner_chat", [[store_conversation_troop,reg(0)],[troop_get_slot,reg(1),reg(0),slot_prisoner_agreed],[eq,reg(1),1],[hero_can_join]], "All right, I have made room for you to join my party. Welcome aboard.", "close_window",
   [[store_conversation_troop,reg(0)],[troop_join,reg(0)],[remove_troops_from_prisoners,reg(0),1]]],
  [anyone|plyr,"prisoner_chat", [[store_conversation_troop,reg(0)],[troop_get_slot,reg(1),reg(0),slot_prisoner_agreed],[neg|reg(1),1],[eq,hero_can_join]], "I am sorry, I still have no room for you. You'll have to wait a while longer, I'm afraid.", "close_window",[]],
 
Back
Top Bottom