Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
|
quickstart:skripte:haendlerdialog [2026/08/12 07:59] 43.173.178.77 alte Version wiederhergestellt (2015/08/18 20:15) |
quickstart:skripte:haendlerdialog [2026/08/14 15:14] (aktuell) 43.173.180.21 alte Version wiederhergestellt (2026/07/10 22:02) |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== Händlerdialog ====== | ||
| + | In diesem Tutorial möchte ich euch das Scripten eines Händlerdialoges beibringen. | ||
| + | Man sollte schon die Kenntnisse über das Erstellen von normalen Dialogen haben, denn ansonsten hat dieses Tutorial keinen Sinn, da man herzlich wenig versteht und ich nicht noch einmal auf alle Einzelheiten eingehen möchte ;) | ||
| + | |||
| + | ===== Ein Händlerdialog entsteht ===== | ||
| + | |||
| + | Ich werde erst einmal das gesamte Script posten und es danach erklären. | ||
| + | |||
| + | <code C> | ||
| + | instance DIA_Gothicfreak_Trade (C_INFO) | ||
| + | { | ||
| + | npc = NONE_500000_Gothicfreak; | ||
| + | nr = 99; | ||
| + | condition = DIA_Gothicfreak_Trade_Condition; | ||
| + | information = DIA_Gothicfreak_Trade_Info; | ||
| + | permanent = TRUE; | ||
| + | trade = TRUE; | ||
| + | description = "Zeig mir deine Ware"; | ||
| + | }; | ||
| + | func int DIA_Gothicfreak_Trade_Condition () | ||
| + | { | ||
| + | return TRUE; | ||
| + | }; | ||
| + | func void DIA_Gothicfreak_Trade_Info () | ||
| + | { | ||
| + | B_GiveTradeInv (self); | ||
| + | AI_Output (other, self, " | ||
| + | |||
| + | if (hero.guild == GIL_PAL) | ||
| + | || (hero.guild == GIL_KDF) | ||
| + | { | ||
| + | AI_Output (self, | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | Wir fangen damit an, womit wir bei normalen Dialogen auch anfangen: | ||
| + | |||
| + | <code C> | ||
| + | instance DIA_Gothicfreak_Trade (C_INFO) | ||
| + | { | ||
| + | npc = NONER_500000_Gothicfreak; | ||
| + | nr = 99; | ||
| + | condition = DIA_Gothicfreak_Trade_Condition; | ||
| + | information = DIA_Gothicfreak_Trade_Info; | ||
| + | permanent = TRUE; | ||
| + | trade = TRUE; | ||
| + | description = "Zeig mir deine Ware"; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | Eigentlich ein gewohnter Anblick, nur das "trade = TRUE;" ist neu. Dies ist bei einem Händlerdialog sehr wichtig, da er sonst nicht funktioniert. Wir dürfen dies also nicht vergessen! " | ||
| + | |||
| + | <code C> | ||
| + | func int DIA_Gothicfreak_Trade_Condition () | ||
| + | { | ||
| + | return TRUE; | ||
| + | }; | ||
| + | func void DIA_Gothicfreak_Trade_Info () | ||
| + | { | ||
| + | B_GiveTradeInv (self); | ||
| + | AI_Output (other, self, " | ||
| + | </ | ||
| + | Auch hier sollte nichts neu sein, außer dem " | ||
| + | Dies darf bei einem Händlerdialog nicht vergessen werden! | ||
| + | |||
| + | |||
| + | Eigentlich könnte ich den Dialog hier schon mit einem " | ||
| + | Wir schreiben also noch dazu: | ||
| + | <code C> | ||
| + | if (hero.guild == GIL_PAL) | ||
| + | || (hero.guild == GIL_KDF) | ||
| + | { | ||
| + | AI_Output (self, | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Das Inventar des Händlers ===== | ||
| + | |||
| + | Ich werde das Inventar so scripten, dass der Händler in jedem Dialog neue Items dazubekommt. Zuerst poste ich wieder das gesamte Skript: | ||
| + | |||
| + | <code C> | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_1; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_2; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_3; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_4; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_5; | ||
| + | |||
| + | FUNC VOID B_GiveTradeInv_Gothicfreak (var C_NPC slf) | ||
| + | { | ||
| + | if ((Kapitel >= 1) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_1 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 100); | ||
| + | |||
| + | CreateInvItems (slf, ItMw_ShortSword3, | ||
| + | CreateInvItems (slf, ItMw_Schwert3, | ||
| + | CreateInvItems (slf, ItMw_Schiffsaxt, | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | |||
| + | CreateInvItems (slf, ItBE_Addon_Leather_01, | ||
| + | |||
| + | CreateInvItems (slf, ItFo_Beer, | ||
| + | CreateInvItems (slf, ItFo_Wine, | ||
| + | CreateInvItems (slf, ItFo_Water, 13); | ||
| + | CreateInvItems (slf, ItFo_Bread, | ||
| + | CreateInvItems (slf, ItFo_Fish, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_1 = TRUE; | ||
| + | }; | ||
| + | |||
| + | if ((Kapitel >= 2) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_2 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 100); | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | CreateInvItems (slf, ItFoMutton, 23); | ||
| + | CreateInvItems (slf, ItFo_Fish, 7); | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_2 = TRUE; | ||
| + | }; | ||
| + | |||
| + | if ((Kapitel >= 3) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_3 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMw_Steinbrecher , 1); | ||
| + | CreateInvItems (slf, ItMw_Doppelaxt, | ||
| + | CreateInvItems (slf, ItMw_Streitkolben, | ||
| + | CreateInvItems (slf, ItMw_2H_BAU_AXE, | ||
| + | |||
| + | CreateInvItems (slf, ItMi_Gold, 100); | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | CreateInvItems (slf, ItBe_Addon_Prot_Point, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_3 = TRUE; | ||
| + | }; | ||
| + | |||
| + | if ((Kapitel >= 4) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_4 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 150); | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | CreateInvItems (slf, ItBe_Addon_Prot_EDGE, | ||
| + | CreateInvItems (slf, ItBe_Addon_Prot_TOTAL, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_4 = TRUE; | ||
| + | }; | ||
| + | |||
| + | if ((Kapitel >= 5) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_5 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 200); | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | CreateInvItems (slf, ItFo_Cheese, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_5 = TRUE; | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | Die "var int" | ||
| + | |||
| + | <code C> | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_1; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_2; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_3; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_4; | ||
| + | var int Gothicfreak_ItemsGiven_Chapter_5; | ||
| + | |||
| + | Nun kommt das Inventar des Händlers im ersten Kapitel: | ||
| + | |||
| + | FUNC VOID B_GiveTradeInv_Gothicfreak (var C_NPC slf) | ||
| + | { | ||
| + | if ((Kapitel >= 1) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_1 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 100); | ||
| + | |||
| + | CreateInvItems (slf, ItMw_ShortSword3, | ||
| + | CreateInvItems (slf, ItMw_Schwert3, | ||
| + | CreateInvItems (slf, ItMw_Schiffsaxt, | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | |||
| + | CreateInvItems (slf, ItBE_Addon_Leather_01, | ||
| + | |||
| + | CreateInvItems (slf, ItFo_Beer, | ||
| + | CreateInvItems (slf, ItFo_Wine, | ||
| + | CreateInvItems (slf, ItFo_Water, 13); | ||
| + | CreateInvItems (slf, ItFo_Bread, | ||
| + | CreateInvItems (slf, ItFo_Fish, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_1 = TRUE; | ||
| + | }; | ||
| + | |||
| + | |||
| + | if ((Kapitel >= 1) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_1 == FALSE)) | ||
| + | </ | ||
| + | Die " | ||
| + | <code C> | ||
| + | CreateInvItems (slf, ItMi_Gold, 100); | ||
| + | |||
| + | CreateInvItems (slf, ItMw_ShortSword3, | ||
| + | CreateInvItems (slf, ItMw_Schwert3, | ||
| + | CreateInvItems (slf, ItMw_Schiffsaxt, | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | |||
| + | CreateInvItems (slf, ItBE_Addon_Leather_01, | ||
| + | |||
| + | CreateInvItems (slf, ItFo_Beer, | ||
| + | CreateInvItems (slf, ItFo_Wine, | ||
| + | CreateInvItems (slf, ItFo_Water, 13); | ||
| + | CreateInvItems (slf, ItFo_Bread, | ||
| + | CreateInvItems (slf, ItFo_Fish, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_1 = TRUE; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | '' | ||
| + | Vielleicht ist euch das '' | ||
| + | |||
| + | Würde man diese Variable nicht auf True setzen, nachdem er die Items erschaffen hat, so würden die gleichen Items immer wieder erschaffen werden sobald der Held den Handelsinventar von Gothicfreak öffnet | ||
| + | |||
| + | Die restlichen Kapitel scriptet man genauso wie das vom ersten, nur das man eben statt einer " | ||
| + | |||
| + | <code C> | ||
| + | if ((Kapitel >= 2) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_2 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 100); | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | CreateInvItems (slf, ItFoMutton, 23); | ||
| + | CreateInvItems (slf, ItFo_Fish, 7); | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_2 = TRUE; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | Nun poste ich noch das letzte Kapitel, denn alle brauche ich ja schließlich nicht. (siehe weiter oben) | ||
| + | |||
| + | <code C> | ||
| + | if ((Kapitel >= 5) | ||
| + | && (Gothicfreak_ItemsGiven_Chapter_5 == FALSE)) | ||
| + | { | ||
| + | CreateInvItems (slf, ItMi_Gold, 200); | ||
| + | CreateInvItems (slf, ItMiSwordraw, | ||
| + | CreateInvItems (slf, ItFo_Cheese, | ||
| + | |||
| + | Gothicfreak_ItemsGiven_Chapter_5 = TRUE; | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | Wichtig am Ende sind noch mal die beiden " | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== _work\data\Scripts\Content\Story\B_GiveTradeInv ===== | ||
| + | |||
| + | Damit der Händlerdialog auch im Spiel erscheint, müssen wir ihn noch in der Datei " | ||
| + | |||
| + | Wir tragen unseren " | ||
| + | |||
| + | <code C> | ||
| + | var C_NPC Trd_Gothicfreak; | ||
| + | </ | ||
| + | |||
| + | Wie ihr seht, kommt hier noch einmal die Instanz (also " | ||
| + | |||
| + | Nun seht ihr ein wenig weiter unten noch den Abschnitt "Hier auch!!!" | ||
| + | Dort müssen wir unseren Händler-NPC nochmal eintragen. (Wir tragen ihn einfach mal wieder unter Lutero ein) | ||
| + | |||
| + | <code C> | ||
| + | if Hlp_GetInstanceID (slf) == Hlp_GetInstanceID (Trd_Gothicfreak) | ||
| + | </ | ||
| + | |||
| + | So, das war's erst einmal. Falls ihr noch Fragen habt und/oder nicht weiterkommt, | ||
| + | Viel Glück, ich hoffe, ich konnte euch einigermaßen helfen... | ||
| + | |||
| + | |||
| + | Mit freundlichen Grüßen | ||
| + | Arthonius | ||