Author Topic: Tutorial: Healing and Teleporting  (Read 2660 times)

0 Members and 1 Guest are viewing this topic.

Kolba

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Kolba
Tutorial: Healing and Teleporting
« on: December 28, 2008, 08:28:29 PM »
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.  :)
2. Open module_troops.py and add following line:

(click to show/hide)

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:

(click to show/hide)

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
  • *
    • View Profile
  • Faction: Swadian
Re: Tutorial: Healing and Teleporting
« Reply #1 on: December 29, 2008, 01:54:02 PM »
Very handy. Thank you Kolba.

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

Strent

  • Veteran
  • *
    • View Profile
  • Faction: Khergit
  • M&BWBWF&S
Re: Tutorial: Healing and Teleporting
« Reply #2 on: December 30, 2008, 12:11:21 PM »
i tryed it on native and it work very well im always aware of cheating methods like this :)     

Kolba

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Kolba
Re: Tutorial: Healing and Teleporting
« Reply #3 on: December 30, 2008, 01:39:28 PM »
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
  • *
    • View Profile
  • Faction: Swadian
Re: Tutorial: Healing and Teleporting
« Reply #4 on: December 30, 2008, 02:37:58 PM »
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  :D

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

Strent

  • Veteran
  • *
    • View Profile
  • Faction: Khergit
  • M&BWBWF&S
Re: Tutorial: Healing and Teleporting
« Reply #5 on: December 30, 2008, 08:11:53 PM »
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
  • *
    • View Profile
    • Exilian Forums
  • Faction: Rhodok
Re: Tutorial: Healing and Teleporting
« Reply #6 on: December 31, 2008, 08:52:12 PM »
I wish I had the patence to write more tutorials... writing up seabattles nearly killed me.   :|
Creator of the mod Southern Realms, Head Admin of Exilian

Strent

  • Veteran
  • *
    • View Profile
  • Faction: Khergit
  • M&BWBWF&S
Re: Tutorial: Healing and Teleporting
« Reply #7 on: December 31, 2008, 11:06:26 PM »
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
  • *
    • View Profile
  • Faction: Neutral
Re: Tutorial: Healing and Teleporting
« Reply #8 on: August 31, 2009, 06:15:35 PM »
Is it possible to add time delay between teleporting and appearing to teleport location?
Modding ain't fun when Wings and Thorgrim's map editor crash all the time