Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onActionServerside()
- {
- switch (params[0])
- {
- case "finishedDialog":
- level.npc.(@params[1]).trigger("DialogDone");
- break;
- case "removeWeapon":
- player.removeWeapon(escapestring2(params[1]));
- break;
- }
- }
- //#CLIENTSIDE
- public function loadDialog(temp.imgHead, temp.speaker, temp.msg, temp.options, temp.quest, temp.questItem, temp.questQty)
- {
- this.join("functions_graalcontrol");
- this.imgHead = temp.imgHead;
- this.speaker = temp.speaker;
- this.msgWhole = temp.msg;
- this.msg = temp.msg[0];
- this.optionsWhole = temp.options;
- this.options = temp.options[0];
- this.msgSizeInx = temp.msg.size();
- this.optsSizeInx = temp.options.size();
- this.countOpts = 0;
- this.countMsgs = 0;
- this.isOptions = false;
- this.quest = temp.quest;
- this.questItem = temp.questItem;
- this.questQty = temp.questQty;
- this.join("functions_options");
- //echo(this.speaker@ "--" @this.headImg@ "--" @this.msg@ "--" @this.options@"");
- //echo(this.countOpts@ "--" @this.options.size());
- // stop player
- setani("idle", null);
- disabledefmovement();
- if (this.countOpts < 1)
- {
- // show up dialog
- showBG();
- showHead();
- showName();
- showMsg();
- if (this.options.size() > 0)
- {
- // show up options gui
- for (temp.i = 0; temp.i < this.options.size() - 1; temp.i++)
- {
- showOptions(temp.i);
- }
- this.isOptions = true;
- }
- }
- if (this.msgWhole[this.countOpts + 1].size() > 0)
- {
- if (! this.isOptions)
- {
- this.nextText = "Press ENTER to continue.";
- }else
- {
- this.nextText = "Select an option.";
- }
- showNext();
- }else
- {
- this.nextText = "Press ENTER to close.";
- showNext();
- }
- }
- // Function to show up background and extra text
- function showBG()
- {
- // set up background
- showPoly(304, {0, (screenheight / 3) - 50, screenwidth, (screenheight / 3) - 50, screenwidth, (screenheight / 2), 0, (screenheight / 2)});
- changeImgVis(304, 6);
- changeImgColors(304, 0, 0, 0, .05);
- this.join("tween");
- // fade in background
- tweenimg(304, "alpha", 0.15, 0, 0.75);
- waitfor(this, "TweenimgFinished");
- // set up gui control
- new GuiControl("Dialog_Control")
- {
- x = 0;
- y = (screenheight / 3) - 50;
- width = screenwidth;
- height = ((screenheight / 3) - 50) + 350;
- layer = 7;
- // show up skip text
- Dialog_Skip.destroy();
- new GuiTextCtrl("Dialog_Skip")
- {
- x = 0;
- y = 0;
- useownprofile = true;
- profile = Armageddon_Text;
- destroyonhide = true;
- text = "Press 'b' to skip.";
- width = 150;
- height = 32;
- //layer = 7;
- //zoom = 0.4;
- profile.fontsize = 10;
- alpha = 0;
- this.join("tween");
- }
- }
- // fade in skip text
- (@"Dialog_Skip").tween("alpha", 0.25, 0, 1);
- waitfor((@"Dialog_Skip"), "TweenFinished", 0.05);
- }
- // Function to move in head on the screen
- function showHead()
- {
- //echo(this.imgHead);
- Dialog_Head.destroy();
- new GuiShowImgCtrl("Dialog_Head")
- {
- y = 20;
- x = 30;
- destroyonhide = true;
- useownprofile = true;
- image = thiso.imgHead;
- //bitmap = temp.headNPC;
- partx = 0;
- party = 64;
- partw = 32;
- parth = 32;
- width = 64;
- height = 64;
- //layer = 7;
- zoom = 1.2;
- alpha = 0;
- this.join("tween");
- }
- Dialog_Control.addcontrol(Dialog_Head);
- // tween the image
- (@"Dialog_Head").tween("alpha", 0.25, 0, 1);
- waitfor((@"Dialog_Head"), "TweenFinished", 0.5);
- }
- // Function to move in name on the screen
- function showName()
- {
- //echo(this.speaker);
- Dialog_Name.destroy();
- new GuiTextCtrl("Dialog_Name")
- {
- y = 30;
- profile = Armageddon_Text;
- destroyonhide = true;
- useownprofile = true;
- text = thiso.speaker;
- width = 128;
- height = 320;
- //layer = 7;
- zoom = 0.7;
- alpha = 1;
- profile.fontsize = 12;
- profile.fonttype = "Palatino Linotype";
- profile.fontstyle = "bu";
- profile.textshadow = true;
- profile.shadowcolor = {60, 60, 45};
- profile.shadowoffset = {4, 3};
- this.join("tween");
- }
- Dialog_Control.addcontrol(Dialog_Name);
- // tween the image
- (@"Dialog_Name").tween("x", 0.25, 0, 110);
- waitfor((@"Dialog_Name"), "TweenFinished", 0.05);
- }
- // Function to move in message on the screen
- function showMsg()
- {
- if (getOptionsVariable("sound")) play(this.slideInSound);
- //echo(this.msg);
- Dialog_Msg.destroy();
- new GuiTextCtrl("Dialog_Msg")
- {
- y = 50;
- profile = Armageddon_Text;
- destroyonhide = true;
- useownprofile = true;
- text = thiso.msg;
- width = 128 * text.length();
- height = 32;
- //layer = 7;
- zoom = 1;
- alpha = 1;
- profile.fontsize = 14;
- profile.fonttype = "Palatino Linotype";
- profile.fontstyle = "b";
- this.join("tween");
- }
- Dialog_Control.addcontrol(Dialog_Msg);
- // tween the image
- (@"Dialog_Msg").tween("x", 0.25, 0, 50);
- waitfor((@"Dialog_Msg"), "TweenFinished", 0.05);
- }
- // Function to move in message on the screen
- function showOptions(temp.idC)
- {
- //echo(this.options[temp.idC]);
- ("Dialog_Choice" @temp.idC).destroy();
- new GuiBitmapButtonCtrl("Dialog_Choice" @temp.idC)
- {
- profile = NoneNpc;
- //y = 150;
- y = 320;
- destroyonhide = true;
- text = thiso.options[temp.idC];
- //normalbitmap = "";
- //mouseoverbitmap = "";
- width = 250;
- //layer = 7;
- zoom = 0.6;
- alpha = 1;
- this.join("tween");
- this.catchId = temp.idC;
- thiso.catchevent(this, "onMouseUp", "selectedOpt");
- }
- //Dialog_Control.addcontrol(@ "Dialog_Choice" @temp.idC);
- //(@ "Dialog_Choice" @temp.idC).bringtofront();
- // tween the image x
- (@"Dialog_Choice" @temp.idC).tween("x", 0.5, 0, 50);
- waitfor((@"Dialog_Choice" @temp.idC), "TweenFinished", 0.05);
- // tween the image y
- (@"Dialog_Choice" @temp.idC).tween("y", 0.5, (@"Dialog_Choice" @temp.idC).y, (@"Dialog_Choice" @temp.idC).y + (temp.idC * 300));
- waitfor((@"Dialog_Choice" @temp.idC), "TweenFinished", 0.05);
- }
- // Function to show up text if conversation can continue
- function showNext(temp.nextMsg)
- {
- //echo(this.msg);
- Dialog_Next.destroy();
- new GuiTextCtrl("Dialog_Next")
- {
- y = 135;
- profile = Armageddon_Text;
- destroyonhide = true;
- text = thiso.nextText;
- width = 128 * text.length();
- height = 32;
- //layer = 7;
- zoom = 0.4;
- alpha = 1;
- fonttype = "Palatino Linotype";
- fontstyle = "b";
- this.join("tween");
- }
- Dialog_Control.addcontrol(Dialog_Next);
- // tween the image
- (@"Dialog_Next").tween("x", 0.25, 0, 10);
- waitfor((@"Dialog_Next"), "TweenFinished", 0.05);
- }
- // Function to handle if option was selected
- function selectedOpt(obj)
- {
- temp.nextOptSize = this.optionsWhole[this.countOpts].size();
- if (getOptionsVariable("sound")) play(this.enterSound);
- // catch player response
- this.choiceMade = obj.text;
- this.choicePos = obj.catchId;
- // checks to see if question flagged for a quest starter
- if (this.choicePos == this.options[this.options.size() - 1][2])
- {
- // checks if there are any quests at all
- if (clientr.activeQuests != null)
- {
- // run through all active quests
- for(temp.p = 0; temp.p < clientr.activeQuests.size(); temp.p++)
- {
- // if one equals this quest giver
- if (clientr.activeQuests[p][1] == this.quest)
- {
- // see if meets required item/quantity this is wrong items are weapons not clientr.vars redo for weapons
- // and make weapon pull how many it has in its own function
- if ((findweapon("Item/"@this.questItem).getItemName() == this.questItem
- || findweapon("Quest/"@this.questItem).getItemName() == this.questItem)
- && (findweapon(@"Item/"@this.questItem).getQuantity() >= this.questQty
- || findweapon(@"Quest/"@this.questItem).getQuantity() >= this.questQty))
- {
- // will want to remove quantity per weapon script
- // make sure weapon script deletes itself if its empty
- if (this.questQty > 1)
- {
- if (findweapon("Item/"@this.questItem).getItemName() == this.questItem)
- {
- findweapon("Item/"@this.questItem).removeQuantity(this.questQty);
- }
- if (findweapon("Quest/"@this.questItem).getItemName() == this.questItem)
- {
- findweapon("Quest/"@this.questItem).removeQuantity(this.questQty);
- }
- }else
- {
- triggerServer("gui", this.name, "removeWeapon", this.questItem);
- }
- findweapon("-System/QuestTracker").completeQuest(this.quest);
- break;
- }else
- {
- // deletes next message and changes it to whats needed
- // for the quest
- this.msgWhole = "";
- this.msgWhole.add("er");
- this.msgWhole.add("You still need a total of "@this.questQty@" "@this.questItem@"(s)!");
- this.countMsgs = 0;
- this.choicePos = 0;
- }
- }else
- {
- // no quests match this one mark true to set quest
- this.markQuestStart = true;
- }
- }
- }else
- {
- // no quests active at all, mark to set
- // need to make sure its not in completed quests too !!!!!!
- this.markQuestStart = true;
- }
- }
- // set new message or stop completely
- if (this.choicePos == this.optionsWhole[this.countOpts][temp.nextOptSize - 1][0])
- {
- this.countMsgs++;
- this.msg = this.msgWhole[this.countMsgs][this.choicePos];
- this.msgWhole = "";
- }else
- {
- this.countMsgs++;
- this.countOpts++;
- this.msg = this.msgWhole[this.countMsgs][this.choicePos];
- }
- for (temp.i = 0; temp.i < this.options.size() + 10; temp.i++)
- {
- // hide old options
- (@"Dialog_Choice" @i).tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Choice" @i), "TweenFinished", 0.05);
- (@"Dialog_Choice" @i).destroy();
- }
- this.options.clear();
- // load in new message
- if (this.msg != "")
- {
- loadNewMessage();
- }
- }
- // Function to show next message
- function loadNewMessage()
- {
- // hide old message text
- (@"Dialog_Msg").tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Msg"), "TweenFinished", 0.05);
- // set new message text
- showMsg();
- // check for more options if there
- temp.nextOptSize = this.optionsWhole[this.countOpts].size();
- if (this.countMsgs == this.optionsWhole[this.countOpts][temp.nextOptSize - 1][1])
- {
- // set next set of options
- this.options = this.optionsWhole[this.countOpts];
- this.isOptions = true;
- // show up options gui
- for (temp.j = 0; temp.j < this.options.size() - 1; temp.j++)
- {
- showOptions(temp.j);
- }
- }else
- {
- this.isOptions = false;
- }
- // check for a next message
- if (this.msgWhole[this.countMsgs + 1] != "" || this.msgWhole[this.countMsgs + 1].size() > 0)
- {
- // hide old next message
- (@"Dialog_Next").tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Next"), "TweenFinished", 0.05);
- // send to show if continue message
- if (! this.isOptions)
- {
- this.nextText = "Press ENTER to continue.";
- }else
- {
- this.nextText = "Select an option.";
- }
- showNext();
- }else
- {
- this.nextText = "Press ENTER to close.";
- showNext();
- this.isOptions = false;
- }
- }
- // Function to read if a key is pressed while message shown
- function onKeyPressed(temp.keycode, temp.key, temp.scancode)
- {
- //13 enter 32 space
- if (temp.keycode == 66)
- {
- onMakeGraalFirst();
- if (getOptionsVariable("sound")) play(this.closeSound);
- closeImages();
- triggerserver("gui", this.name, "finishedDialog", this.speaker);
- }
- if (temp.keycode == 13)
- {
- if (this.nextText == "Press ENTER to close.")
- {
- onMakeGraalFirst();
- this.isOptions = false;
- if (getOptionsVariable("sound")) play(this.closeSound);
- closeImages();
- triggerserver("gui", this.name, "finishedDialog", this.speaker);
- }else
- {
- if (! this.isOptions)
- {
- // fade out old choices no matter what
- for (temp.i = 0; temp.i < this.options.size() + 10; temp.i++)
- {
- // hide old options
- (@"Dialog_Choice" @i).tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Choice" @i), "TweenFinished", 0.05);
- }
- // set new message
- this.countMsgs++;
- this.msg = this.msgWhole[this.countMsgs];
- // load in new message
- if (this.msg != "")
- {
- loadNewMessage();
- }
- // check for more options if there
- temp.nextOptSize = this.optionsWhole[this.countOpts].size();
- if (this.countMsgs == this.optionsWhole[this.countOpts][temp.nextOptSize - 1])
- {
- this.isOptions = true;
- // set next set of options
- this.options = this.options[this.countOpts];
- // show up options gui
- for (temp.j = 0; temp.j < this.options.size() - 1; temp.j++)
- {
- showOptions(temp.j);
- }
- }else
- {
- this.isOptions = false;
- }
- }
- }
- }
- }
- // Function to close images and return movement
- public function closeImages()
- {
- // fade out skip text
- (@"Dialog_Skip").tween("alpha", 0.10, 1, 0);
- waitfor((@"Dialog_Skip"), "TweenFinished", 0.05);
- Dialog_Skip.hide();
- // hide old next message
- (@"Dialog_Next").tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Next"), "TweenFinished", 0.05);
- // hide message text
- (@"Dialog_Msg").tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Msg"), "TweenFinished", 0.05);
- Dialog_Msg.hide();
- // hide name text
- (@"Dialog_Name").tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Name"), "TweenFinished", 0.05);
- Dialog_Name.hide();
- // hide head img
- (@"Dialog_Head").tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Head"), "TweenFinished", 0.05);
- Dialog_Head.hide();
- // fade out choices, to 10 to make sure they ALL hide
- for (temp.i = 0; temp.i < this.options.size() + 10; temp.i++)
- {
- (@"Dialog_Choice" @i).tween("alpha", 0.05, 1, 0);
- waitfor((@"Dialog_Choice" @i), "TweenFinished", 0.05);
- (@"Dialog_Choice" @i).hide();
- }
- // fade out background
- tweenimg(304, "alpha", 0.5, 0.30, 0);
- waitfor(this, "TweenimgFinished");
- hideimg(304);
- enabledefmovement();
- Dialog_Control.active = false;
- // show quest if there is one
- if (this.markQuestStart == true && this.quest != null)
- {
- this.markQuestStart = false;
- echo("add quest");
- findweapon("-System/QuestTracker").addQuest(this.quest, this.questItem, this.questQty);
- }
- }
- /* SET UP OF THE LV NPC
- function onCreated()
- {
- level.npc.Jaqor = this;
- this.join("npc_movement");
- this.can_stop = true;
- // Initialize the attributes
- showcharacter();
- this.head = "head0.png";
- this.body = "body.png";
- this.colors = {"orange", "blue", "darkblue", "red", "yellow"};
- this.shield = "shield1.png";
- this.dir = 1;
- //Ganis
- this.ani_walk = ""; //Gani while walking.
- this.ani_idle = ""; //Gani after finished moving.
- this.speed = 4; // Movement Speed (tiles per second, default is 6)
- //Actions
- this.actions = {
- "action: waitRandom",
- "move:-8:-6",
- "action: waitRandom",
- "move: -6:3",
- "move:-3:7",
- "action: waitRandom",
- "move:-4:5",
- "move:-22:-12",
- "action: waitRandom",
- "reversemove",
- "repeat"
- };
- //Sub-Actions
- /*
- "action:fishing",
- Example:
- this.action_fishing = {
- "setani:zodiac_fishingattack",
- "wait:5",
- "randomaction:0.25:reel",
- "wait:3",
- "setani:zodiac_fishingattack",
- "wait:1"
- };
- this.action_reel = {
- "setani:zodiac_fishingreeling",
- "randomchat:0.3:Almost had that one.. -sigh-:4"
- };
- this.action_waitRandom = {
- "wait: " @random(1, 16)@""
- };
- }
- function onPlayerTouchsMe()
- {
- npc_stop();
- this.dir = (player.dir + 2) % 4;
- waitfor(this, "onDialogDone", 3600);
- npc_continue();
- }
- //CLIENTSIDE
- function onCreated()
- {
- // DECLARATIONS
- this.countOpts = 0;
- // this must match a quest in sql
- this.quest = "Fake Quest 1";
- // the item the giver needs
- this.questItem = "Red Gem";
- // how many of the item the giver needs
- this.questQty = 4;
- // see description above in options to set quest off or on
- this.questYes = int(0);
- // initial set for quest not done
- this.questDone = false;
- // set up npc attributes
- this.speaker = "Jaqor";
- this.head = "head0.png";
- }
- function doRegularMessage()
- {
- this.msg.clear();
- this.msg.add("I love pretty, red gems!");
- }
- function doQuestMessage()
- {
- // set up messages
- this.msg.clear();
- this.msg.add("I need some help!");
- this.msg.add({"I've heard that you have a sword. Can you go get me
- some rocks out of the north cave?","Alright, your loss..."});
- this.msg.add({"Thanks! Come see me when you have 4 red gems!",
- "If you change your mind I'll be here!"});
- // set up options, for quests the option to start the quest
- // MUST be the first option or it will not work.
- // array at the end defines if next message shows an option or
- // not based on the number, which is referring to the index of the
- // option array to select that option and stop there (ex: 1 will
- // kill it if the second option is picked).
- // Set the number to what option you want it to stop at (
- // no more options or message). If you want to continue regardless
- // put -1 (options like array start at 0)
- // last num in that array is for the quest starter option.
- // put to -1 for no quest, put to the array index for the option
- // to start a quest
- this.options.clear();
- this.options.add({"What can I help you with?", "I don't care", {1,0,-1}});
- this.options.add({"I'll get you 4 red gems.", "Nope.", {-1,1,this.questYes}});
- }
- function doQuestMessage2()
- {
- this.msg.clear();
- this.msg.add("Have you found my red gems?");
- this.msg.add({"Awesome! Here is your prize!", "Ok, I need them really bad..."});
- this.options.clear();
- this.options.add({"I sure have! Here you go!", "Still looking...", {-1,0,0}});
- }
- function onPlayerTouchsMe()
- {
- // checks if the quest was already done, if repeatable quest,
- // set this.questYes = 1 below instead of false, but the
- // system right now does not allow for a prize to be given more than
- // once
- for (temp.i = 0; temp.i < clientr.completedQuests.size(); temp.i++)
- {
- if (clientr.completedQuests[i][1] == this.quest)
- {
- this.questDone = true;
- this.options.clear();
- }
- }
- if (this.questDone == false && this.quest != null)
- {
- if (clientr.activeQuests != null)
- {
- for(temp.p = 0; temp.p < clientr.activeQuests.size(); temp.p++)
- {
- if (clientr.activeQuests[p][1] == this.quest)
- {
- // quest in progress messages
- doQuestMessage2();
- }else
- {
- // regular messages
- doQuestMessage();
- }
- }
- }else
- {
- //regular messages
- doQuestMessage();
- }
- }else
- {
- // regular message
- doRegularMessage();
- }
- findweapon("-System/NPCDialog").loadDialog(this.head, this.speaker, this.msg, this.options, this.quest, this.questItem, this.questQty);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement