Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Made by DarkShadow44
- Discussion and updates on: http:--www.mobtalker.net/forums/viewtopic.php?f=15&t=29
- Please don't redistribute, just link to there.
- If you want to use this script as base for yours you may do that, but please copy only the basics, not the story.
- I don't want someone to extend or change it a bit and give it away as his/hers.
- ]]
- function CONFIG()
- CurrentLanguage = Languages.Eng;
- DEBUG = false;
- DEBUG_SkipIntro = false;
- DEBUG_DayChooser = true;
- STARTPOS = 0;
- useBetterLog = true;
- end
- function TEST()
- --askQuestion(Creeper_All_QuestionsGeneric);
- end
- function ShowDayChooser()
- SAY("<ScriptInfo>", "Choose a day to start at.");
- local maxStory = GetMaxStory();
- local tableDisplay = {};
- local i = 0;
- while(i <= maxStory) do
- tableDisplay[i+1] = ""..i;
- i = i + 1;
- end
- local choice = PromtChoiceStringsInt(tableDisplay, 5) - 1;
- return choice;
- end
- function GetMaxStory()
- local index = 0;
- while(List_Func_Story[index] ~= nil) do
- index = index + 1;
- end
- return index-1;
- end
- function initGenerics()
- player = DCLib.Player.GetName();
- List_Func_Story = {};
- List_Func_Story_Sub = {};
- registerStory();
- Languages = {};
- Languages.Eng = 0;
- Languages.Ger = 1;
- Languages.Rus = 2;
- Wait = {};
- Wait.Tired = 0;
- Wait.JustLeft = 1;
- Wait.Insulted = 2;
- Wait.SomethingToDo = 3;
- Wait.Depressed = 4;
- Wait.Sleeping = 5;
- Wait.NotFound = 404;
- CONFIG();
- if(not TableSaveGenerics) then
- TableSaveGenerics = {};
- TableSaveGenerics["HatedPersons"] = {};
- TableSaveGenerics["KnownPersons"] = {};
- if(DCLib.Player.GetGameMode() == "creative") then
- if(DEBUG_DayChooser) then
- TableSaveGenerics["DoScriptChooser"] = true;
- STARTPOS = ShowDayChooser();
- TableSaveGenerics["KnownPersons"][player] = true;
- TableSaveGenerics["DoScriptChooser"] = false;
- end
- end
- TableSaveGenerics["NextStory"] = STARTPOS;
- TableSaveGenerics["NextSubStory"] = -1;
- end
- if(TableSaveGenerics["DoScriptChooser"]) then
- STARTPOS = ShowDayChooser();
- TableSaveGenerics["KnownPersons"][player] = true;
- TableSaveGenerics["DoScriptChooser"] = false;
- TableSaveGenerics["NextStory"] = STARTPOS;
- TableSaveGenerics["NextSubStory"] = -1;
- end
- end
- function Start_Generic()
- if(DEBUG == true) then
- LoveInc(1000);
- end
- TEST();
- if(LoveGet() < -1) then
- HatePlayer();
- end
- if(TableSaveGenerics["HatedPersons"][player] ~= nil) then
- RefusingToTalk();
- else
- if((TableSaveGenerics["KnownPersons"][player] == nil) and (DEBUG ~= true) and (DEBUG_SkipIntro ~= true)) then
- FirstMet();
- else
- Story_Play();
- end
- end
- end
- function Random(min, max)
- return DCLib.Math.Random(min, max+1);
- end
- function Rnd(new)
- if(new) then
- _rndLast = Random(0, 99);
- end
- return _rndLast;
- end
- function Max(var1, var2)
- return Math.Max(var1, var2);
- end
- function Min(var1, var2)
- return Math.Min(var1, var2);
- end
- function HatePlayer()
- TableSaveGenerics["HatedPersons"][player] = true;
- end
- function TableDelete(tab, value)
- keyFound = nil;
- for key, val in next,tab do
- if(val == value) then
- keyFound = key;
- end
- end
- if(keyFound ~=nil) then
- tab[keyFound] = nil;
- end
- end
- function TableRandom(tab)
- local tabCopy = {};
- local index = 1;
- for key, val in next,tab do
- tabCopy[index] = val;
- index = index + 1;
- end
- local rnd = DCLib.Table.Random(tabCopy);
- return rnd;
- end
- function TableCopy(tab)
- ret = {};
- for key, val in next, tab do
- ret[key] = val;
- end
- return ret;
- end
- -- Table.Copy, deep copy
- if(not Table.Copy) then
- Table.Copy = function(tab)
- local ret = {};
- for key, val in next, tab do
- if(typeof(val) == "table") then
- ret[key] = Table.Copy(val);
- else
- ret[key] = val;
- end
- end
- return ret;
- end
- end
- function TableContains(tab, value)
- for key, val in next, tab do
- if(val == value) then
- return true;
- end
- end
- return false;
- end
- function TableGetKey(tab, value)
- for key, val in next, tab do
- if(val == value) then
- return key;
- end
- end
- return nil;
- end
- --returns count random entrys, in random order
- function TableGetNumRandom(tab, count)
- ret = {};
- item = nil;
- found = 0;
- if(Table.Count(tab) < count) then
- count = Table.Count(tab);
- end
- tab = TableCopy(tab);
- while(found < count) do
- item = TableRandom(tab);
- TableDelete(tab, item);
- ret[found] = item;
- found = found + 1;
- end
- return ret;
- end
- --Let's call it "a working PromtChoice"
- function PromtChoiceStrings(questions)
- return PromtChoiceStringsEx(questions, Table.Count(questions));
- end
- function PromtChoiceQuestion(questions, numPerPage)
- askTable={};
- pos=1;
- for key, val in next, questions do
- askTable[pos] = val["question"];
- pos = pos + 1;
- end
- string = PromtChoiceStringsEx(askTable, numPerPage);
- ret = nil;
- for key, val in next, questions do
- if(string == val["question"]) then
- ret = val;
- end
- pos = pos + 1;
- end
- return ret;
- end
- --displays all strings and returns the position of the selected string in the array
- function PromtChoiceStringsInt(questions, numPerPage)
- sel = PromtChoiceStringsEx(questions, numPerPage);
- pos = 1;
- found = false;
- for key,val in next, questions do
- if(val == sel) then
- found = true;
- else if(not found) then
- pos = pos + 1;
- end
- end
- return pos;
- end
- function TableCopyLinear(tab)
- ret = {};
- num = 1;
- for key, val in next, tab do
- ret[num] = val;
- num = num + 1;
- end
- return ret;
- end
- function PromtChoiceStringsEx(questions, numPerPage)
- tab = TableCopyLinear(questions);
- selectedIndex = ShowMenu(nil, tab);
- return tab[selectedIndex];
- --[[
- if(Table.Count(questions) ~= 0) then
- curTable = 1;
- curTablePos = 1;
- seperatedTables = {};
- seperatedTables[1] = {};
- for key, val in next, questions do
- if(curTablePos <= numPerPage) then
- seperatedTables[curTable][curTablePos] = val;
- else
- curTablePos = 1;
- curTable = curTable+1;
- seperatedTables[curTable] = {};
- seperatedTables[curTable][curTablePos] = val;
- end
- curTablePos = curTablePos + 1;
- end
- numTables = Table.Count(seperatedTables);
- seperatedTablesMapped = {};
- i=1;
- while(i<=numTables) do
- pos = 1;
- seperatedTablesMapped[i] = {};
- if(i<numTables) then
- seperatedTablesMapped[i][pos] = "-->";
- pos = pos+1;
- end
- if(i ~= 1) then
- seperatedTablesMapped[i][pos] = "<--";
- pos = pos+1;
- end
- for key, val in next, seperatedTables[i] do
- seperatedTablesMapped[i][pos] = val;
- pos = pos+1;
- end
- i=i+1;
- end
- currentTable = 1;
- ended = false;
- selected = 1;
- while(not ended) do
- selected = PromtChoice2(seperatedTablesMapped[currentTable]);
- if(currentTable == 1) then -- first page
- if(numTables > 1 and selected == 1) then -- more pages available + first option selected
- currentTable = currentTable + 1;
- else
- ended = true;
- end
- else if(currentTable == numTables) then -- last page
- if(selected == 1) then
- currentTable = currentTable - 1;
- else
- ended = true;
- end
- else
- if(selected == 1) then
- currentTable = currentTable + 1;
- else if(selected == 2) then
- currentTable = currentTable - 1;
- else
- ended = true;
- end
- end
- end
- return seperatedTablesMapped[currentTable][selected];
- end
- ]]
- end
- function PromtChoice2(questions) -- max: 7
- if(Table.Count(questions) > 7) then
- SAY("<ScriptError>", "In PromtChoice2, max numer of questions too big.");
- end
- clicked = nil;
- if(Table.Count(questions) ~= 0) then
- if(Table.Count(questions) < 8) then
- toask = {};
- curr = 1;
- for key, val in next, questions do
- toask[curr] = val;
- curr = curr + 1;
- end
- if(Table.Count(toask) == 1) then
- menu
- option toask[1]
- clicked = 1;
- end
- else if(Table.Count(toask) == 2) then
- menu
- option toask[1]
- clicked = 1;
- option toask[2]
- clicked = 2;
- end
- else if(Table.Count(toask) == 3) then
- menu
- option toask[1]
- clicked = 1;
- option toask[2]
- clicked = 2;
- option toask[3]
- clicked = 3;
- end
- else if(Table.Count(toask) == 4) then
- menu
- option toask[1]
- clicked = 1;
- option toask[2]
- clicked = 2;
- option toask[3]
- clicked = 3;
- option toask[4]
- clicked = 4;
- end
- else if(Table.Count(toask) == 5) then
- menu
- option toask[1]
- clicked = 1;
- option toask[2]
- clicked = 2;
- option toask[3]
- clicked = 3;
- option toask[4]
- clicked = 4;
- option toask[5]
- clicked = 5;
- end
- else if(Table.Count(toask) == 6) then
- menu
- option toask[1]
- clicked = 1;
- option toask[2]
- clicked = 2;
- option toask[3]
- clicked = 3;
- option toask[4]
- clicked = 4;
- option toask[5]
- clicked = 5;
- option toask[6]
- clicked = 6;
- end
- else if(Table.Count(toask) == 7) then
- menu
- option toask[1]
- clicked = 1;
- option toask[2]
- clicked = 2;
- option toask[3]
- clicked = 3;
- option toask[4]
- clicked = 4;
- option toask[5]
- clicked = 5;
- option toask[6]
- clicked = 6;
- option toask[7]
- clicked = 7;
- end
- end
- end
- end
- return clicked;
- end
- function addQuestion(tab, tabDone, func, question, once)
- if(tabDone[question] ~= true) then
- temp = {};
- temp["func"] = func;
- temp["question"] = question;
- temp["once"] = once;
- temp["done"] = tabDone;
- tab[question] = temp;
- end
- end
- function askQuestionMob(questions, wasQuestion)
- if(Table.Count(questions) == 0) then
- if(wasQuestion == true) then
- SAY(CurrentMobname, T("Ah forget it.", "Ach, vergiss es."));
- else
- SHOW(_CurrentMob, "Sad");
- SAY(CurrentMobname, T("I can't remeber of anything left to tell you...", "Mir fällt nichts mehr ein was ich dir erzählen könnte..."));
- SHOW(_CurrentMob, "Normal");
- end
- return -1;
- end
- choice = TableRandom(questions);
- if(choice["once"]) then
- choice["done"][choice["question"]] = true;
- TableDelete(questions, choice);
- end
- waitReturned = choice["func"]();
- if(waitReturned ~= nil) then
- WaitTomorrow(waitReturned);
- return waitReturned;
- end
- return -1;
- end
- function askQuestion(questions)
- return askQuestionEx(questions, 3); -- show 3 questions
- end
- function askQuestionEx(questions, num)
- questionsCopy = TableGetNumRandom(questions, num);
- if(Table.Count(questionsCopy) == 0) then
- return -2;
- end
- choice = PromtChoiceQuestion(questionsCopy, 3); -- show 3 quesitons per page
- if(choice["once"]) then
- choice["done"][choice["question"]] = true;
- TableDelete(questions, choice);
- end
- waitReturned = choice["func"]();
- if(waitReturned ~= nil) then
- --WaitTomorrow(waitReturned);
- return waitReturned;
- end
- return -1;
- end
- function WaitTomorrow(mode)
- WaitTime(mode, 10000);
- end
- function WaitTime(mode, time)
- WaitSet(time);
- TableSaveGenerics["Wait_Mode"] = mode;
- end
- function WaitSet(ticks)
- TableSaveGenerics["Wait_TimeStart"] = DCLib.World.GetTime();
- TableSaveGenerics["Wait_TimeTicks"] = ticks;
- end
- function WaitReady()
- if(TableSaveGenerics["Wait_TimeTicks"] == nil) then
- return true;
- end
- if(DCLib.World.GetTime() < TableSaveGenerics["Wait_TimeStart"]) then
- SAY(T("<ScriptWarning>", "ScriptWarnung>"), T("Invalid Time - Resetting wait timer to keep things running. Did you change the world time ?", "Ungültige Zeit - Timer wird zurückgesetzt um das Script am Laufen zu halten. Wurde die Weltzeit geändert ?"));
- WaitSet(TableSaveGenerics["Wait_TimeTicks"], 10000);
- return false;
- end
- return DCLib.World.GetTime() >= TableSaveGenerics["Wait_TimeStart"] + TableSaveGenerics["Wait_TimeTicks"];
- end
- function MathAbs(num)
- if(num < 0) then
- num = -num;
- end
- return num;
- end
- function GetAge()
- if(TableSaveGenerics["Age"] ~= nil) then
- return TableSaveGenerics["Age"];
- end
- return AskAge();
- end
- function AskAge() --!!! SaveTable["Age"], ask in beginning, or when unused bevore NSFW scenes
- SHOW(_CurrentMob, "Normal");
- SAY(CurrentMobname, T("By the way, how old are you ?", "So nebenbei, wie alt bist du eigentlich ?"));
- selected = "";
- finished = false;
- age = -1;
- loveDec = 1;
- while(not finished) do
- menu
- option "0-9"
- menu
- option "0-4"
- selected = PromtChoiceStrings({"0", "1", "2", "3", "4"});
- option "5-9"
- selected = PromtChoiceStrings({"5", "6", "7", "8", "9"});
- end
- option "10-30"
- menu
- option "10-15"
- selected = PromtChoiceStrings({"10", "11", "12", "13", "14", "15"});
- option "16-20"
- selected = PromtChoiceStrings({"16", "17", "18", "19", "20"});
- option "21-25"
- selected = PromtChoiceStrings({"21", "22", "23", "24", "25"});
- option "26-30"
- selected = PromtChoiceStrings({"26", "27", "28", "29", "30"});
- end
- option "31-60"
- menu
- option "31-35"
- selected = PromtChoiceStrings({"31", "32", "33", "34", "35"});
- option "36-40"
- selected = PromtChoiceStrings({"36", "37", "38", "39", "40"});
- option "41-45"
- selected = PromtChoiceStrings({"41", "42", "43", "44", "45"});
- option "46-50"
- selected = PromtChoiceStrings({"46", "47", "48", "49", "50"});
- option "51-55"
- selected = PromtChoiceStrings({"51", "52", "53", "54", "55"});
- option "56-60"
- selected = PromtChoiceStrings({"56", "57", "58", "59", "60"});
- end
- option "> 60"
- menu
- option "61-65"
- selected = PromtChoiceStrings({"61", "62", "63", "64", "65"});
- option "66-70"
- selected = PromtChoiceStrings({"66", "67", "68", "69", "70"});
- option "71-75"
- selected = PromtChoiceStrings({"71", "72", "73", "74", "75"});
- option "76-80"
- selected = PromtChoiceStrings({"76", "77", "78", "79", "80"});
- option "> 80"
- menu
- option "81-85"
- selected = PromtChoiceStrings({"81", "82", "83", "84", "85"});
- option "86-90"
- selected = PromtChoiceStrings({"86", "87", "88", "89", "90"});
- option "91-95"
- selected = PromtChoiceStrings({"91", "92", "93", "94", "95"});
- option "96-99"
- selected = PromtChoiceStrings({"96", "97", "98", "99"});
- end
- end
- end
- age = toNumber(selected);
- if((age > 60) or (age < 10)) then
- SHOW(_CurrentMob, "Happy");
- SAY(CurrentMobname, T("Sure you are ", "Sicher dass du ")..age..T(" years old ?", " Jahre alt bist ?"));
- if(age < 10) then
- SHOW(_CurrentMob, "Angry");
- LoveDec(loveDec);
- loveDec = loveDec + 2;
- SAY(CurrentMobname, T("Please be honest, you CANNOT be that young...", "Bitte sei ehrlich du KANNST nicht so jung sein..."));
- SAY(CurrentMobname, T("You wouldn't even be here if you were...", "Sonst wärst du gar nicht hier..."));
- end
- else
- finished = true;
- SHOW(_CurrentMob, "Normal");
- SAY(CurrentMobname, T("Ah ok.", "Ah, Ok."));
- if(age == 21) then
- SHOW(_CurrentMob, "Happy");
- SAY(CurrentMobname, T("Hey, I am also 21 years old.", "Ich bin auch 21 Jahre alt."));
- SAY(CurrentMobname, T("That's cool, we are exactly the same age!", "Ist ja cool, wir haben das selbe Alter!"));
- else
- SAY(CurrentMobname, T("So you are ", "Also bist du ")..age..T(" years old.", " Jahre alt"));
- SHOW(_CurrentMob, "Happy");
- SAY(CurrentMobname, T("I am 21.", "Ich bin 21."));
- if(MathAbs(age-21) <2) then
- SAY(CurrentMobname, T("Cool then we are nearly the same age.", "Cool, dann sind wir ja fast gleichalt!"));
- end
- end
- end
- end
- SHOW(_CurrentMob, "Normal");
- TableSaveGenerics["Age"] = age;
- return age;
- end
- function Story_Generic_JustLeft()
- SHOW(_CurrentMob, "Sad");
- SAY(CurrentMobname, T("Why did you just went away yesterday... ?", "Warum bist du gestern einfach so gegangen... ?"));
- LoveDec(4);
- end
- function Story_Generic_Busy()
- if(TableSaveGenerics["Wait_Mode"] == Wait.Tired) then
- SHOW(_CurrentMob, "Tired");
- SAY(CurrentMobname, T("I'm tired...", "Ich bin müde..."));
- else if(TableSaveGenerics["Wait_Mode"] == Wait.JustLeft) then
- SAY(CurrentMobname, T("*She is busy*", "*Sie ist beschäftigt*"));
- else if(TableSaveGenerics["Wait_Mode"] == Wait.Insulted) then
- SAY(CurrentMobname, T("I don't want to talk right now...", "Ich will jetzt nicht mit dir reden..."));
- else if(TableSaveGenerics["Wait_Mode"] == Wait.SomethingToDo) then
- SHOW(_CurrentMob, "Normal");
- SAY(CurrentMobname, T("Sorry I have to do something for now.", "Sorry ich hab zu tun."));
- SAY(CurrentMobname, T("Catch you later.", "Wir sehen uns später."));
- else if(TableSaveGenerics["Wait_Mode"] == Wait.Depressed) then
- SHOW(_CurrentMob, "Sad");
- if(Rnd(true) < 25) then
- SAY(CurrentMobname, T("*Sobs*", "*Schluchzt*"));
- else
- SAY(CurrentMobname, T("*Looks sad*", "*Schaut traurig*"));
- SAY(CurrentMobname, T("*She seems not responsive*", "*Sie scheint nicht zu reagieren*"));
- end
- else if(TableSaveGenerics["Wait_Mode"] == Wait.Sleeping) then
- SAY(CurrentMobname, T("*She is sleeping*", "*Sie schläft*"));
- else if(TableSaveGenerics["Wait_Mode"] == Wait.NotFound) then
- SAY(T("*You can't find her*", "Du kannst sie nicht finden*"));;
- else
- SAY(CurrentMobname, T("*She seems busy*", "*Sie scheint beschäftigt*"));
- end
- end
- function Story_Play()
- if((not WaitReady()) and (DEBUG ~= true)) then
- Story_Generic_Busy();
- else if(TableSaveGenerics["NextSubStory"] ~= -1) then
- TableSaveGenerics["LeftByEsc"] = true;
- pos = TableSaveGenerics["NextSubStory"];
- TableSaveGenerics["NextSubStory"] = -1;
- if(List_Func_Story_Sub[pos]() == false) then
- TableSaveGenerics["NextSubStory"] = pos;
- end
- TableSaveGenerics["LeftByEsc"] = false;
- else if(List_Func_Story[TableSaveGenerics["NextStory"]] ~= nil) then
- if((TableSaveGenerics["LeftByEsc"] == true) and (DEBUG ~= true)) then
- if(TableSaveGenerics["LeftByEsc2"] ~= true) then
- TableSaveGenerics["LeftByEsc2"] = true;
- WaitTomorrow(Wait.JustLeft);
- TableSaveGenerics["NextStory"] = TableSaveGenerics["NextStory"] + 1;
- Story_Generic_Busy();
- else
- TableSaveGenerics["LeftByEsc"] = false;
- TableSaveGenerics["LeftByEsc2"] = false;
- Story_Generic_JustLeft();
- end
- else
- TableSaveGenerics["LeftByEsc"] = true;
- if((List_Func_Story[TableSaveGenerics["NextStory"]]() == true) and (DEBUG ~= true)) then
- TableSaveGenerics["NextStory"] = TableSaveGenerics["NextStory"] + 1;
- end
- TableSaveGenerics["LeftByEsc"] = false;
- end
- else
- SAY("<ScriptWarning>", T("No more story left. Please wait for an update.", "Keine Story mehr verfügbar. Bitte warten sie auf ein Update."));
- end
- end
- function T(eng, ger, rus)
- if(CurrentLanguage == Languages.Eng) then
- return eng;
- else if(CurrentLanguage == Languages.Ger); then
- return ger;
- else if(CurrentLanguage == Languages.Rus); then
- return rus; end
- return "";
- end
- --returns the number of items taken, for partial requests
- function TakeItem2(itemID, amount, meta)
- num = 0;
- while(DCLib.Player.TakeItem(itemID, 1, meta)) do
- num = num + 1;
- end
- return num;
- end
- function LoveSet(num)
- TableSaveGenerics["LoveLevel"] = num;
- if(num > 0) then
- Wrapper.SetReaction("friendly");
- end
- end
- function LoveInc(num)
- LoveSet(LoveGet() + num);
- end
- function LoveDec(num)
- LoveSet(LoveGet() - num);
- end
- function LoveGet()
- if(TableSaveGenerics["LoveLevel"] == nil) then
- TableSaveGenerics["LoveLevel"] = 0;
- end
- return TableSaveGenerics["LoveLevel"];
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement