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 ;)
Ich werde erst einmal das gesamte Script posten und es danach erklären.
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, "DIA_Gothicfreak_Trade_15_00"); //Zeig mir deine Ware.
if (hero.guild == GIL_PAL)
|| (hero.guild == GIL_KDF)
{
AI_Output (self,other,"DIA_Gothicfreak_Trade_12_01"); //Wow, ein Vertreter der heiligen Kirche interessiert sich für meine Waren!
};
};
Wir fangen damit an, womit wir bei normalen Dialogen auch anfangen:
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! „permanent = TRUE;“ sollte eigentlich immer da stehen, außer man will, dass man nur ein einziges Mal mit dem NPC handeln kann.
func int DIA_Gothicfreak_Trade_Condition ()
{
return TRUE;
};
func void DIA_Gothicfreak_Trade_Info ()
{
B_GiveTradeInv (self);
AI_Output (other, self, "DIA_Gothicfreak_Trade_15_00"); //Zeig mir deine Ware.
Auch hier sollte nichts neu sein, außer dem „B_GiveTradeInv (self);
Dies darf bei einem Händlerdialog nicht vergessen werden!
Eigentlich könnte ich den Dialog hier schon mit einem “};„ beenden, doch ich möchte noch, dass ein zusätzlicher Dialog erscheint, wenn man ein Paladin oder ein Feuermagier ist.
Wir schreiben also noch dazu:
if (hero.guild == GIL_PAL)
|| (hero.guild == GIL_KDF)
{
AI_Output (self,other,"DIA_Gothicfreak_Trade_12_01"); //Wow, ein Vertreter der heiligen Kirche interessiert sich für meine Waren!
};
};
Ich werde das Inventar so scripten, dass der Händler in jedem Dialog neue Items dazubekommt. Zuerst poste ich wieder das gesamte Skript:
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, 1);
CreateInvItems (slf, ItMw_Schwert3, 2);
CreateInvItems (slf, ItMw_Schiffsaxt, 1);
CreateInvItems (slf, ItMiSwordraw, 5);
CreateInvItems (slf, ItBE_Addon_Leather_01, 1);
CreateInvItems (slf, ItFo_Beer, 9);
CreateInvItems (slf, ItFo_Wine, 4);
CreateInvItems (slf, ItFo_Water, 13);
CreateInvItems (slf, ItFo_Bread, 5);
CreateInvItems (slf, ItFo_Fish, 3);
Gothicfreak_ItemsGiven_Chapter_1 = TRUE;
};
if ((Kapitel >= 2)
&& (Gothicfreak_ItemsGiven_Chapter_2 == FALSE))
{
CreateInvItems (slf, ItMi_Gold, 100);
CreateInvItems (slf, ItMiSwordraw, 5);
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, 2);
CreateInvItems (slf, ItMw_Streitkolben, 1);
CreateInvItems (slf, ItMw_2H_BAU_AXE, 2);
CreateInvItems (slf, ItMi_Gold, 100);
CreateInvItems (slf, ItMiSwordraw, 5);
CreateInvItems (slf, ItBe_Addon_Prot_Point, 1);
Gothicfreak_ItemsGiven_Chapter_3 = TRUE;
};
if ((Kapitel >= 4)
&& (Gothicfreak_ItemsGiven_Chapter_4 == FALSE))
{
CreateInvItems (slf, ItMi_Gold, 150);
CreateInvItems (slf, ItMiSwordraw, 5);
CreateInvItems (slf, ItBe_Addon_Prot_EDGE, 1);
CreateInvItems (slf, ItBe_Addon_Prot_TOTAL, 1);
Gothicfreak_ItemsGiven_Chapter_4 = TRUE;
};
if ((Kapitel >= 5)
&& (Gothicfreak_ItemsGiven_Chapter_5 == FALSE))
{
CreateInvItems (slf, ItMi_Gold, 200);
CreateInvItems (slf, ItMiSwordraw, 5);
CreateInvItems (slf, ItFo_Cheese, 14);
Gothicfreak_ItemsGiven_Chapter_5 = TRUE;
};
};
Die „var int“-Variablen stehen dafür, dass die jeweiligen Kapitelspeziefischen Items bereits verteilt wurden(bei TRUE) oder nicht verteilt wurden (bei FALSE).
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, 1);
CreateInvItems (slf, ItMw_Schwert3, 2);
CreateInvItems (slf, ItMw_Schiffsaxt, 1);
CreateInvItems (slf, ItMiSwordraw, 5);
CreateInvItems (slf, ItBE_Addon_Leather_01, 1);
CreateInvItems (slf, ItFo_Beer, 9);
CreateInvItems (slf, ItFo_Wine, 4);
CreateInvItems (slf, ItFo_Water, 13);
CreateInvItems (slf, ItFo_Bread, 5);
CreateInvItems (slf, ItFo_Fish, 3);
Gothicfreak_ItemsGiven_Chapter_1 = TRUE;
};
if ((Kapitel >= 1)
&& (Gothicfreak_ItemsGiven_Chapter_1 == FALSE))
Die „if“-Funktion sollte bekannt sein. In diesem Falle ist ihre Bedeutung: „Wenn der Held im 1. Kapitel ist“ und „dem NPC Gothicfreak noch keine Items gegeben wurden“, dann spawnen im Händler-NPC Gothicfreak die folgenden Items. (Diese kann man natürlich variieren!)
CreateInvItems (slf, ItMi_Gold, 100);
CreateInvItems (slf, ItMw_ShortSword3, 1);
CreateInvItems (slf, ItMw_Schwert3, 2);
CreateInvItems (slf, ItMw_Schiffsaxt, 1);
CreateInvItems (slf, ItMiSwordraw, 5);
CreateInvItems (slf, ItBE_Addon_Leather_01, 1);
CreateInvItems (slf, ItFo_Beer, 9);
CreateInvItems (slf, ItFo_Wine, 4);
CreateInvItems (slf, ItFo_Water, 13);
CreateInvItems (slf, ItFo_Bread, 5);
CreateInvItems (slf, ItFo_Fish, 3);
Gothicfreak_ItemsGiven_Chapter_1 = TRUE;
};
„CreateInvItems“ bedeutet, dass der NPC diese Gegenstände im Inventar erschafft, also praktisch „herstellt“ und so im Inventar hat. In unserem Falle hat er unter anderem 100 Gold, 1 Kurzschwert, 1 normales Schwert usw. Wie gesagt, kann man dies - je nach beliebem - verändern oder gar weglassen.
Vielleicht ist euch das „Gothicfreak_ItemsGiven_Chapter_1 = TRUE;“ am Ende aufgefallen, denn am Anfang stand da doch „FALSE;“. Dies sollte man nicht vergessen, da sonst möglicherweise das Skript nicht funktioniert, denn schließlich ist es doch wahr, dass unser „Gothicfreak“ Items in sein Inventar bekommen hat ;)
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 „1“, für Kapitel Nr. 1, eben die jeweilige Zahl des Kapitels einträgt.
if 1)