Scripting - (Any questions on scripting ask here)

This forum is for discussing anything related to The Quest editor.

Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 7:50 am

Ask any questions about scripting here.
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 7:53 am

Alright, my quest is to go kill some bandits. i have went to World>quests added the quests, i have the ID as 0610_7723, (0610 is my base ID) and i have put 'Got any work?'>Infact i do, (To simplyfy, go kill some bandits) < (scripting on that text) Player.AddQuest("0610_7723")
It crashes the program, everytime i bring up the subject 'Got any work?'
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Sylon / Redshift » Sun Jun 10, 2012 8:18 am

Sorry but I don't really understand what do you do. : ) I don't need any IDs or things like that - I need much more details, like the scripting from the script windows to check for possible bugs.
To take it simple: do you have some NPCs (non player characters) you need for this quest? Edited them, added some dialogues in their script window? What is in their dialogue window? Just copy and paste it here.
User avatar
Sylon / Redshift
 
Posts: 620
Joined: Sun Oct 09, 2011 9:23 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 8:22 am

ok, you get the quest from Gerald, he is an inn keeper.
I have added this script to the quest
player.addquest("0610_7723")
Is that what you mean? he is the only npc involved in the quest.
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 8:24 am

That is all he has in his script window
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Sylon / Redshift » Sun Jun 10, 2012 8:43 am

Oh well, then of course it will not work. : ) You have to learn scripting, it's like a programming language inside the game.
I strongly recommend to open the base game's world and check how things work. Select an NPC, click on Dialogues, select the Topics he/she has, and then check anything you can see in the Responses, Conditions, Answers, and Script windows. It's much more complicated than just giving one quest to a character. Also you should read the two pdf files for the Editor which you can get in "The Editor" thread here. : )
User avatar
Sylon / Redshift
 
Posts: 620
Joined: Sun Oct 09, 2011 9:23 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 8:50 am

oh lol i learned the add quest thing from there, thought that was all. i had the subject, response and a script, i thought the rest were for stuff like @E.G. If player is ravism say:sjdhfrsf' <That makes no sense atall but,
Yeah thanks i'll read through the things properly now
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 9:48 am

Alright, sorry to ask questions :roll: :P But if i want to give player a quest, what do i need in the script box?
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Sylon / Redshift » Sun Jun 10, 2012 11:21 am

Just ask questions, that's why I am here. : )
Adding a quest is a complex thing. First you have to learn how to create a working dialogue, with questions, answers, etc. Get used to the whole system first, understand its logic. The script window is the last step, when everything works well during a dialogue.

If you have an NPC in your world, go to his/her dialogue window.

1. For example, create a talking topic (in the top left corner of the dialogue window) with a title like "Do you need something?" Type in your question "Do you need something?" in the displayed question box.

2. Create a new response (responses - new). Type in a result text which the character will give you as an answer to your question (result text box). Like "Yes, I need a hammer. Will you accept my quest? I will give you 500 gold for it as a reward."

3. Create your answers to this question - check the "Result Answers" at the bottom, choose at least two (A1, A2), set them to Always so these answer possibilities will be always there. Type in some text for them like "Yes, I will get that hammer" for answer 1, and "No, thanks" for answer 2.

4. Create two new responses, these will be the second and third in the line. For the second, select "Answer==1" at Conditions (around the center of the window), while for the third response, select "Answer==2" as a Condition. So now you have two new responses, one which you can get when you say yes to the quest offer, and one which you can get when you say no.

5. Let's start with the second possibility (third response) because this will have a short outcoming: type in some result text for the NPC ("All right, maybe next time!") and type in a script command in the Script box (bottom right corner). Type in just this:
goodbye();
So the whole discussion will end and you can exit from the dialogue.

6. Now on the hard part: go back to the first possibility (second response in the line), and type in some result text for the NPC like "Ah, great, you are my hero! Now you have my quest, get that hammer!"
Now you can add your quest in the script box:
player.addquest("0610_hammer");
But only if you already created this quest! For this first (before starting this whole dialogue) go to the World/Manage Quests menu and add this quest, with the ID above, a title, and a description (what the player must do, which NPC adds this quest, etc).
Also you have to create the hammer itself - go to the World/Manage items menu, create a new hammer and give it a special ID like 0610_hammer, give it a name (like Jacob's hammer), etc.

7. You also have to give a sign to the game that something happened, changed with this NPC because you got a quest from him/her, so next time you meet him/her this NPC will know you and your quest. So in the script window above where you get the quest, you have to type in more commands:
setstate(1);
goodbye();
This will set the whole NPC's state to 1 and ends the discussion. Now go back to all responses in the line above this one (including this one) and set a new condition at the Conditions window for each response: select ObjectThisState==0
So now that the player received the quest all those dialogue lines will not respawn and the player will get a new response - a response with the hammer quest.

8. Create this new response, this will be the fourth in the line I think. Give it a condition with ObjectThisState==1
Then type in some welcome text for the NPC in the result text box like "Ah, Player, welcome back, do you have the hammer?"
Create two possible answers at the bottom (A1, A2), for the first one, select "PCHasItem" from that little menu, select the hammer with its unique ID, and set == 1 at the end. So this player answer will appear only if you have the hammer. Type in some text as an answer like "Yes, here is your hammer".
For the second answer, just select Always and type in some text like "No, I don't have the hammer yet".

9. Create two new responses (5th and 6th in the line) for the two possible answers. In the first, set the conditions to ObjectThisState==1, and Answer==1 so this will appear only if you give the hammer to the NPC. In the second, set the conditions to ObjectThisSate==1 and Answer==2 so this will appear if you don't have the hammer.
For the first response, type in some thankful text in the result text window for the NPC ("Thank you very much, here is your reward!"), and in the script window type these commands:
player.solvequest("0610_hammer");
player.removeitem("0610_hammer");
player.receivegold(500);
setstate(2);
goodbye();
These commands are for solving your quest in the quest list, giving the hammer to the NPC, getting your reward, setting the NPC's state to the next level, and closing the dialogue.
For the second response, just type in some result text for the NPC like "Okay, I'm waiting here for my hammer!" and type in the usual goodbye(); script command to end the discussion.

10. Create the last response (7th in the line). Set the condition to ObjectThisState==2 so this will appear only when you already completed the quest.
Just type in some greeting like "Ah, Player, it''s good to see you back, thank you again for the hammer!"

I think that's it. : ) Don't be so scared, if you get used to it, it will be not that complex.
If you have any bugs or problems with this, just write, probably this quide is not perfect, I didn't checked it within the Editor, it was just from my head. : ) And of course this is just the very base of quest-making, there are much much more possibilities.
User avatar
Sylon / Redshift
 
Posts: 620
Joined: Sun Oct 09, 2011 9:23 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 12:25 pm

OMG lol -____- now, i edit npc's dialouge and i talk to them and it doesn't come up lol.. This Editor hates me..
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Sylon / Redshift » Sun Jun 10, 2012 4:30 pm

When you make a new NPC (World/Manage NPC menu, Add, then giving ID and name), you have to put it somewhere in the world, I hope you know that. : ) For example, put it inside a house's door. Put a city door type object on a wall's side, select it with pressing shift and clicking on the door. Edit. Select an NPC from the NPC list there. And he/she will be there inside the door.
Or you want to make a walking NPC? That's easy too, just ask.

As for the NPC, first give him/her a greeting text from the dialogue window's bottom left corner, or just select one greeting from the "add shared" list. So when you meet this NPC, he/she will start to talk with you with a greeting. : )
Other than that, it's up to you, I think my previous post contains all info you need to add not just a greeting but talk topics too to this NPC.

I hope it helped. : )
User avatar
Sylon / Redshift
 
Posts: 620
Joined: Sun Oct 09, 2011 9:23 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 4:32 pm

Oh ok thanks.
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 4:36 pm

Oh gawd, still isn't working. ok so i have made an npc, by world>manage npc menu, and i have added him to a door, i have made him so he says something but when i open the door, on the bottom right, it comes up with him but with no talk options, only goodbye?:(
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 4:39 pm

oh wow i really am stupid, i put conditions on answer.... -.- Sorry for wasting your time lol.. i'll probally have more problems though :(
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 5:12 pm

lol.... ok i entered
player.solvequest("0610_arniesHammer");
player.removeitem("0610_arniesHammer");
player.receivegold(600);
setstate(2);
goodbye();

That is the right id and everything, it says
'Error: line 2 Invalid number o arguments.
removeitrm(itemtypeid,amount)
And it gives me the same error if i do this:


player.solvequest("0610_arniesHammer");
player.removeitem("0610_arniesHammer,1");
player.receivegold(600);
setstate(2);
goodbye();
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 5:15 pm

nevermind i got it
it was

player.solvequest("0610_arniesHammer");
player.removeitem("0610_arniesHammer",1);
player.receivegold(600);
setstate(2);
goodbye();
The number shouldn't be inside the ", as that is showing the ID
I should stop asking questions i can easyily find out...
And it looks like i'm talking to myself since i answer my own questions 5 minutes after asking them :D
lol :D
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Sylon / Redshift » Sun Jun 10, 2012 5:20 pm

Ah yes, I forgot: to remove an item, you have to specify how many items you want to remove. The way you did for the second time was right, the number must be after the item's ID.

So now you have a working quest at last? : )
User avatar
Sylon / Redshift
 
Posts: 620
Joined: Sun Oct 09, 2011 9:23 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 5:46 pm

WELL... i used your hammer idea, and i just have to make a group of bandits, a leader and make the leader drop 'Arnies Hammer'
lol :D so after that, yeah. :P
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 5:48 pm

how do i make and place (in the map) bandit? (walking npc i think)
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby KGold » Sun Jun 10, 2012 8:22 pm

Jacob wrote:how do i make and place (in the map) bandit? (walking npc i think)


If you want to place it as an NPC, go here:
World<Manage Monster Types, select "bres_man" , "bres_lady", "bres_villagewoman" or "bres_villageman" as a base monster type, then click on the "Add" button below. Give it a unique identifier, a name what will be displayed in the game, a palette, and an NPC.
When it's ready , select {NPC} npc/walking (this world) from the list to the right-hand side of the window, find the NPC's identifier, click on it. Then select a place on your map with the mouse, and hit space. The NPC is placed. And you'll be able to talk to him/her if he/she has an NPC.
If you have been really too busy,
And you feel your head being dizzy,
It's recommended to have a rest,
I have a good offer-play the Quest! : )
User avatar
KGold
 
Posts: 161
Joined: Sun Jun 10, 2012 3:21 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 10, 2012 8:28 pm

oh ok, thanks.
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby KGold » Mon Jun 11, 2012 1:42 pm

Jacob wrote:oh ok, thanks.


Anytime! ;)
If you have been really too busy,
And you feel your head being dizzy,
It's recommended to have a rest,
I have a good offer-play the Quest! : )
User avatar
KGold
 
Posts: 161
Joined: Sun Jun 10, 2012 3:21 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby KGold » Sun Jun 17, 2012 8:53 am

What's the problem with this script? The editor says: error-line 4 (unenclosed block(s))

posx=player.getposx();
posy=player.getposy();
if(evtuse() && (getglobal("exp1_secretwalls")==0) &&
(posx==10) && (posy==10)) { setglobal("exp1_secretwalls",1);
message("Click"); }
else if(evtuse() && (getglobal("exp1_secretwalls")==1) &&
(posx==11) && (posy==11)) { setglobal("eyex_secretwalls",2);
message("Click"); }
else if(evtuse() && (getglobal("exp1_secretwalls")==2) &&
(posx==12) && (posy==10)) { setglobal("exp1_secretwalls",3);
message("Click");
else if(evtuse() && (getglobal("exp1_secretwalls")==3) &&
(posx==11) && (posy==9)) { setglobal("exp1_secretwalls",4);
player.finditem("exp1_torchunlit",1); sethidden(); }
else { message("Wrong. Sequence reset."); setglobal("exp1_secretwalls",0); }

Thanks!
If you have been really too busy,
And you feel your head being dizzy,
It's recommended to have a rest,
I have a good offer-play the Quest! : )
User avatar
KGold
 
Posts: 161
Joined: Sun Jun 10, 2012 3:21 pm
Location: Hungary

Re: Scripting - (Any questions on scripting ask here)

Postby Jacob » Sun Jun 17, 2012 3:37 pm

KGold wrote:What's the problem with this script? The editor says: error-line 4 (unenclosed block(s))

posx=player.getposx();
posy=player.getposy();
if(evtuse() && (getglobal("exp1_secretwalls")==0) &&
(posx==10) && (posy==10)) { setglobal("exp1_secretwalls",1);
message("Click"); }
else if(evtuse() && (getglobal("exp1_secretwalls")==1) &&
(posx==11) && (posy==11)) { setglobal("eyex_secretwalls",2);
message("Click"); }
else if(evtuse() && (getglobal("exp1_secretwalls")==2) &&
(posx==12) && (posy==10)) { setglobal("exp1_secretwalls",3);
message("Click");
else if(evtuse() && (getglobal("exp1_secretwalls")==3) &&
(posx==11) && (posy==9)) { setglobal("exp1_secretwalls",4);
player.finditem("exp1_torchunlit",1); sethidden(); }
else { message("Wrong. Sequence reset."); setglobal("exp1_secretwalls",0); }

Thanks!


I'm not very good with scripting but,
Since it says line 4, there is a problem with
(posx==10) && (posy==10)) { setglobal("exp1_secretwalls",1);
I'm not sure about it but i would probally say that the co ordanites have something wrong with them, idk though :( sorry :L
Jacob
Jacob
 
Posts: 91
Joined: Thu Oct 27, 2011 4:01 pm
Location: england

Re: Scripting - (Any questions on scripting ask here)

Postby Elendil / Redshift » Sun Jun 17, 2012 7:33 pm

The error is in line 11. There is a missing "}" after "message("Click");"

The script compiler just gets confused. While trying to pair opening and closing braces, it seems it decides that the very first opening brace in line 4 is the one missing it's closing brace, so that's why it says line 4.
User avatar
Elendil / Redshift
Site Admin
 
Posts: 940
Joined: Sun Oct 09, 2011 11:35 am

Next

Return to Editor

Who is online

Users browsing this forum: No registered users and 5 guests

cron