SP Tutorial Module System Healing and Teleporting

Currently Viewing (Users: 0, Guests: 1)

Kolba

This is my third tutorial after:

Tutorial: Making new quests
Tutorial: Creating new spawn points

In this part I will explain how to add a new NPC, who will heal your wounds and teleport to choosen place. Step by step tutorial is below:

1. Get something to drink and relax.  :smile:
2. Open module_troops.py and add following line:

  ["mardhug","Mardhug","Mardhug",tf_hero, scn_town_7_tavern|entry(3), reserved, fac_commoners,[itm_woolen_cap,itm_rawhide_coat,itm_hunter_boots],def_attrib|level(2),wp(20),knows_common,0x0000000f45041105241acd2b5a66a86900000000001e98310000000000000000,swadian_face_older_2],

I explained adding new troops in quest tutorial , so if you haven't read it yet - do it now. When you are ready, go to part 3.

3. Now open module_dialogs.py and paste it:

  [trp_mardhug,"start", [], "Hello. I can heal and teleport you.", "healer_talk",[]],
  [anyone|plyr,"healer_talk", [], "I have been hurt pretty bad, will you have a look?", "healing_asked",[]],
  [anyone|plyr,"healer_talk", [], "Teleport me?", "teleport",[]],
  [anyone,"teleport", [], "Yes, I can teleport you for free to kingdoms' capital towns. Where do you want to be?", "teleport_ask",[]],
  [anyone|plyr,"teleport_ask", [], "Praven", "go_praven",[]],
  [anyone|plyr,"teleport_ask", [], "Sargoth", "go_sargoth",[]],
  [anyone|plyr,"teleport_ask", [], "Reyvadin", "go_reyvadin",[]],
  [anyone|plyr,"teleport_ask", [], "Jelkala", "go_jelkala",[]],
  [anyone|plyr,"teleport_ask", [], "Tulga", "go_tulga",[]], 
  [anyone,"go_sargoth", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_town_1")]],
  [anyone,"go_praven", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_town_6")]],
  [anyone,"go_jelkala", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_town_5")]],
  [anyone,"go_reyvadin", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_town_8")]],
  [anyone,"go_tulga", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_town_10")]],
  [anyone,"healing_asked", [[assign,reg(1),100],[ge,reg(1),1]], "Hmm. I can heal you and everybody in your party, but it will cost you {reg1} denars.", "healing_asked_2",[]],
  [anyone|plyr,"healing_asked_2", [[assign,reg(1),100],[store_troop_gold,reg(2)],[ge,reg(2),reg(1)]], "Allright. Here's {reg1} denars. Please patch us up now.", "healing_start",[[troop_remove_gold, "trp_player",reg(1)]]],
  [anyone,"healing_start", [], "Well, this will take some time now.......Yes, here you go, you are healed.", "healing_finished",[[heal_party]]],
  [anyone|plyr,"healing_finished", [], "Eh, I feel much better now. Thank you medic.", "close_window",[]],
  [anyone|plyr,"healing_asked_2", [], "Well maybe I should do this later. Good-bye.", "healing_not_accepted",[]],
  [anyone,"healing_not_accepted", [], "Stay well.", "close_window",[]],
  [anyone,"healing_asked", [], "Well you seem perfectly healthy to me. You are probably just tired. Try to rest more and watch what you eat.", "close_window",[]],
  [anyone|plyr,"healer_talk", [], "Good-bye.", "close_window",[]],

For simple dialogue line analysis check very good Winter's dialog tutorial, we'll be concentrating on more difficult things. Now take a look on this part of code (don't paste it!):

  [anyone|plyr,"teleport_ask", [], "Praven", "go_praven",[]],
  [anyone|plyr,"teleport_ask", [], "Sargoth", "go_sargoth",[]],
  [anyone|plyr,"teleport_ask", [], "Reyvadin", "go_reyvadin",[]],
  [anyone|plyr,"teleport_ask", [], "Jelkala", "go_jelkala",[]],
  [anyone|plyr,"teleport_ask", [], "Tulga", "go_tulga",[]],

As you see, player now can select one of capital towns of Calradia to teleportation. You can add your own locations, for example:

  [anyone|plyr,"teleport_ask", [], "Grunwalder Castle", "go_grunwalder",[]],

Great, now let's analyse another piece of conversation:

  [anyone,"go_sargoth", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_town_1")]],

We can see that:
- the word "Sure!" is spoken by Mardhug.
- after that the conversation will end. ("close_window")
- current mission template will be finished. ("finish_mission")
- we'll leave current town. ("leave_encounter")
- our party will be relocated near Sargoth. (party_relocate_near_party,0,"p_town_1")

The other "teleportation lines" were made in the same way. Have in mind, that "p_town_1" is an ID of location, so you can manually change it. For example:

  [anyone,"go_grunwalder", [], "Sure!", "close_window",[(finish_mission),(change_screen_return),(leave_encounter),(party_relocate_near_party,0,"p_castle_28")]],

(Grunwalder Castle has ID "castle_28")


4. Teleportations are done, now let's go further - to healing system. Analyse this tuple:

  [anyone,"healing_asked", [[assign,reg(1),100],[ge,reg(1),1]], "Hmm. I can heal you and everybody in your party, but it will cost you {reg1} denars.", "healing_asked_2",[]],

In this example we set {reg1} to 100 denars. It's the cost of healing. Another line:

  [anyone|plyr,"healing_asked_2", [[assign,reg(1),100],[store_troop_gold,reg(2)],[ge,reg(2),reg(1)]], "Allright. Here's {reg1} denars. Please patch us up now.", "healing_start",[[troop_remove_gold, "trp_player",reg(1)]]],

Here is the paying line of dialogue. Now Python is checking player's money. If player HASN'T GOT 100 denars (it's set in "reg1") - this dialogue option won't appear, we'll automatically move to...

  [anyone|plyr,"healing_asked_2", [], "Well maybe I should do this later. Good-bye.", "healing_not_accepted",[]],

But if player HAS 100 denars, we'll automatically move to....

[anyone,"healing_start", [], "Well, this will take some time now.......Yes, here you go, you are healed.", "healing_finished",[[heal_party]]],

As you see, the party of player was healed. Save everything, run build_module.bat, run game and go to Uxkhal tavern (or your another scene).

This is the end of my tutorial.

Thanks for reading, sorry for my language, Merry Christmas!

:lol:

 

Luisrah

Sergeant
Best answers
0
Very handy. Thank you Kolba.

It's as I said, keep going, and sooner or later you'll get a sticky  :grin:
 

Strent

Veteran
M&BWBWF&S
Best answers
0
i tryed it on native and it work very well im always aware of cheating methods like this :smile:     
 

Kolba

Thanks, guys! I'm thinking about making a...surprise...new tutorial.  :lol:
Tell me, what aspect of Python modding you want to see?
 

Luisrah

Sergeant
Best answers
0
I'd say lots of tweaks in module_scripts

I think that's where you can REALLY change the game with many little things that together makes it spectacular  :grin:

Oh and I think I'm going to credit you in my mods lol
 

Strent

Veteran
M&BWBWF&S
Best answers
0
i agree whit him and maybe some functions that we dont all know you surley have some secrets that you can show us
 

Jubal

Knight
WBM&B
Best answers
0
I wish I had the patence to write more tutorials... writing up seabattles nearly killed me.  :neutral:
 

Strent

Veteran
M&BWBWF&S
Best answers
0
i tryed it too and it was great you should make others it would help a lot i would need one on how to change the start game choice and one on how to manage units who spawn in town and  in castle if you have some free time i would like it please  :lol:
 

Soturi

Recruit
Best answers
0
Is it possible to add time delay between teleporting and appearing to teleport location?