Kill Quest Script

*Function Main()*

   Player% = Actor()

   PlayerName$ = Name(Player)

   Target% = ContextActor()

   TargetName$ = Name(Target)

 Persistent(1)

   QuestName$ = "A Ratty Problem"

   QuestResults$ =
QuestStatus(Player, QuestName)

   QuestReturn$ = "Return to " + TargetName +
" to complete this quest."

   ; Objective Variables for Quest
completion

   WaitRace$ = "Rat"

   WaitClass$ = "Rat"

 WaitKillQuantity% = 5

   ; Variables for Rewards

   RewardMoney% =
25

   RewardXp% = 100

   RewardItem$ = ""

   RewardItemQuantity% = 1

   RewardFaction$ = ""

   RewardFactionValue% = 0

 QuestStatusText$ = "Rid the town of rats(Kill 5 rats)"

   D% =
OpenDialog(Player%, Target%, TargetName$)

   ; Player Greeting to NPC:

 DialogOutput(Player%, D%, "Hi " + TargetName + "", 255, 255, 255)

 DoEvents (1000)

   ; NPC Greeting to Player:

 DialogOutput(Player%, D%, "Help " + PlayerName + "!", 255, 255, 255)

 DoEvents (1000)

   If (QuestResults = "")

      ; The quest needs
to be started

      DialogOutput(Player%, D%, "Will you help me rid the
town of those pesky rats?", 255, 255, 255)

      Result% =
DialogInput(Player, D, "Accept Quest|Refuse Quest","|")

      If
(Result% = 1)

         ; Create the new quest

 NewQuest(Player, QuestName, QuestStatusText, 255, 255, 255)

 QuestTemp$ = QuestName + ": " + QuestStatusText

         Output(Player,
QuestTemp, 255, 255, 255)

            DialogOutput(Player, D, "Here, take
these items, you will need them in your quest.", 255,255,255)

 CloseDialog(Player, D)

            Output(Actor,"You received a bronze
sword, and a full set of armour!")

            GiveItem(Player, "Sword",1)

            GiveItem(Player, "Imperial Helmet",1)

            ;place
holders

            GiveItem(Player, "Sword",1)

GiveItem(Player, "Sword",1)

            GiveItem(Player, "Sword",1)

    D% = 0

         ; Wait for Kills

         WaitID% =
ActorID(WaitRace, WaitClass)

         WaitKill(Player, WaitID,
WaitKillQuantity)

         UpdateQuest(Player, QuestName, QuestReturn, 255,
255, 255)

         QuestTemp$ = QuestName + ": " + QuestReturn

 Output(Player, QuestTemp, 255, 255, 255)

      Else

 CloseDialog(Player, D)

            Return

         D% = 0

 EndIf

   EndIf

   If (QuestResults = QuestReturn)

      ; The quest
has been almost completed, assign rewards

      DialogOutput(Player, D, "You
have rid the town of rats and completed " + QuestName + "" + CHR(44) + " great
job !", 255, 255, 255)

      DialogResult = DialogInput(Player, D,
"Goodbye")

      CompleteQuest(Player, QuestName)

      ; Item
reward for Step/Quest

      GiveItem(Player, RewardItem, RewardItemQuantity)

      ; XP reward for Step/Quest

      GiveXp(Player, RewardXp)

      ; Money reward for Step/Quest

      ChangeGold(Player,
RewardMoney)

      ; Faction change

 ChangeFactionRating(Player, RewardFaction, RewardFactionValue)

 Output(Player, "You take " + RewardItemQuantity + " " + RewardItem + " and " +
RewardMoney + "gp and " + RewardXp + "xp you have earnt it!")

 CloseDialog(Player, D)

   ElseIf (QuestComplete(Player, QuestName) = 1)

      ; The quest has been completed

      DialogOutput(Player, D,
"Thanks for helping me out with " + QuestName + "" + CHR(44) + " I have no other
quests for you at this time ... good day !", 255, 255, 255)

      DoEvents
(1000)

      CloseDialog(Player, D)

   EndIf

   Return

End Function