Author Topic: Trying to make a Quest System  (Read 358 times)

Narehop

  • Solodev on @Outline_team
Trying to make a Quest System
« on: 20 Apr 2018, 17:14 »
Hi guys, i'm trying to make a Quest System for my game but i've some problems with it.

i'm going to explain how it must work (sorry for my english):

0. In header's script i have this:
Code: Adventure Game Studio
  1. //import function open_menuQuest;
  2. import function open_menuQuest();
  3.  
  4. //import function close_menuQuest;
  5. import function close_menuQuest();
  6.  
  7. //import function openQuest(int a);
  8. import function open_quest (int number);
  9.  
  10. //import function openQuest(int a);
  11. import function close_quest (int number);
  12.  
  13.   // [x] is the totally numbers of quests have the game.
  14.   //how to work with quests: 0-off    1-turn on     2-finished
  15.   int arrQuest[2];
  16.  

1. Enter on a Region for example and run this script (GUI named "gNewObjective" appears)
Code: Adventure Game Studio
  1. function open_menuQuest()
  2. {
  3.   gNewObjective.Transparency = 100;
  4.   gNewObjective.Visible = true;
  5.   gNewObjective.TweenTransparency(0.3, 0, eEaseInCubicTween, eNoBlockTween);
  6.   a0000_bell_objective.Play();
  7. }
  8.  

2. We call a new objective (quest) and it appears too with our own function
Code: Adventure Game Studio
  1. function open_quest(int number)
  2. {
  3.   if(arrQuest[number] == 0)
  4.   {
  5.     gQuest.Visible = true;
  6.     gQuest.TweenX(0.1, 0,  eEaseOutQuintTween, eNoBlockTween);
  7.     int questY = 0;
  8.     for(int i = 0; i < gQuest.ControlCount; i++ )
  9.     {
  10.       if(arrQuest[i]==1)
  11.       {
  12.         gQuest.Controls[i].Y = 20+(questY*30);
  13.         questY++;
  14.       }
  15.     }
  16.     //turn on quest
  17.     arrQuest[number] = 1;
  18.     gQuest.Controls[number].Y = 20 + (questY*30);
  19.     gQuest.Controls[number].TweenX(1.0, 60, eEaseOutBackTween, eNoBlockTween);
  20.   }
  21. }
  22.  


3. (optional) With a similar function we can finish our quests
Code: Adventure Game Studio
  1. function close_quest (int number)
  2. {    
  3.   arrQuest[number] = 2;
  4.   gQuest.Visible = true;
  5.   gQuest.Transparency = 100;
  6.   gQuest.TweenTransparency(0.3, 0, eEaseInCubicTween, eNoBlockTween);
  7.   gQuest.TweenX(0.5, 0,  eEaseOutQuintTween, eNoBlockTween);
  8.   gQuest.Controls[number].TweenX(1.0, -800, eEaseInBackTween, eNoBlockTween, 1.0, eTweenSeconds );
  9.  
  10.   int questY = 0;
  11.   for(int i = 0; i < gQuest.ControlCount; i++ )
  12.   {
  13.     if(arrQuest[i]==1)
  14.     {
  15.       gQuest.Controls[i].Y = 20+(questY*30);
  16.       questY++;
  17.     }
  18.   }
  19. }
  20.  

4. And finishing we have to close our Quest GUI:
Code: Adventure Game Studio
  1. function close_menuQuest()
  2. {
  3.   gNewObjective.Transparency = 0;
  4.   gNewObjective.TweenTransparency(1.0, 100, eEaseInCubicTween, eNoBlockTween, 3.0, eTweenSeconds);
  5.   gQuest.Transparency = 0;
  6.   gQuest.TweenTransparency(1.0, 100, eEaseInCubicTween, eNoBlockTween, 3.0, eTweenSeconds);
  7. }
  8.  

5. Now this code is where i'm going to call the functions:
Code: Adventure Game Studio
  1.   open_menuQuest();
  2.   close_quest(0); //close quest number 0
  3.   open_quest(1); //open quest number 1
  4.   close_menuQuest();
  5.  

Ok so, now i'm going to show how it works with ONE QUEST.


And now we close the first Quest and open a second Quest at the same time:


Here's the problem... In my code i said that i want to check if we have one or more Quests opened and put the next quest 20+(questY*30) in Y position. And obviously this doesn't work and i don't know why :(

If someone can help me to do this work fine... if you need, you can copy the code and try to run it.

Thank you so much.
« Last Edit: 20 Apr 2018, 18:12 by Narehop »

Narehop

  • Solodev on @Outline_team
Re: Trying to make a Quest System
« Reply #1 on: 21 Apr 2018, 09:46 »
nobody can help me? :(:(:(:(:(

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Trying to make a Quest System
« Reply #2 on: 21 Apr 2018, 10:29 »
Here's the problem... In my code i said that i want to check if we have one or more Quests opened and put the next quest 20+(questY*30) in Y position. And obviously this doesn't work and i don't know why :(

Looks to me like it does work, you're just not thinking clearly about what you're telling it to do:
You remove the first quest, so the list is now empty.
Then you add the second quest, and it shows up in the first free slot (at the top).

If you want the second quest to show up in the second slot, you should add it to the list before you remove the first quest. Alternatively, you can add a delay, so it only shows up in the first slot after the first animation has finished and the first quest is gone.

Also, you shouldn't update the positions each time you add or remove an entry, unless you want exactly this behavior (other entries instantly move up or down). You should do it when you display the menu. (If you're going to add new quests in the middle of the list while it's being displayed, you probably need another state: a "save a space for this quest but don't actually display it yet" state.)

Finally, I should say that I think there are better ways to solve this whole task, but if you've found an approach that (almost) works for you, that's great.

Narehop

  • Solodev on @Outline_team
Re: Trying to make a Quest System
« Reply #3 on: 21 Apr 2018, 10:38 »
Here's the problem... In my code i said that i want to check if we have one or more Quests opened and put the next quest 20+(questY*30) in Y position. And obviously this doesn't work and i don't know why :(

Looks to me like it does work, you're just not thinking clearly about what you're telling it to do:
You remove the first quest, so the list is now empty.
Then you add the second quest, and it shows up in the first free slot (at the top).

If you want the second quest to show up in the second slot, you should add it to the list before you remove the first quest. Alternatively, you can add a delay, so it only shows up in the first slot after the first animation has finished and the first quest is gone.

Also, you shouldn't update the positions each time you add or remove an entry, unless you want exactly this behavior (other entries instantly move up or down). You should do it when you display the menu. (If you're going to add new quests in the middle of the list while it's being displayed, you probably need another state: a "save a space for this quest but don't actually display it yet" state.)

Finally, I should say that I think there are better ways to solve this whole task, but if you've found an approach that (almost) works for you, that's great.

I don't have any idea how to do this code better Snarky :(
Not always have to close and open Quests at the same time. Sometimes I'll open quests but no one were closed. So I can't make a delay for this question. I need to do this in real time.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Trying to make a Quest System
« Reply #4 on: 21 Apr 2018, 10:55 »
Not always have to close and open Quests at the same time. Sometimes I'll open quests but no one were closed. So I can't make a delay for this question. I need to do this in real time.

The way around that is to have a separate function, something like replace_quest(int questToRemove, int questToAdd) that does it, with a delay. (You might need to add a delay parameter to open_quest(), and set it to 0 by default.)

Narehop

  • Solodev on @Outline_team
Re: Trying to make a Quest System
« Reply #5 on: 21 Apr 2018, 10:57 »
Not always have to close and open Quests at the same time. Sometimes I'll open quests but no one were closed. So I can't make a delay for this question. I need to do this in real time.

The way around that is to have a separate function, something like replace_quest(int questToRemove, int questToAdd) that does it, with a delay. (You might need to add a delay parameter to open_quest(), and set it to 0 by default.)

i'm gonna try it

Narehop

  • Solodev on @Outline_team
Re: Trying to make a Quest System
« Reply #6 on: 21 Apr 2018, 17:43 »
The way around that is to have a separate function, something like replace_quest(int questToRemove, int questToAdd) that does it, with a delay. (You might need to add a delay parameter to open_quest(), and set it to 0 by default.)

I can't run it... I think, the problem is that my functions are running at the same time:

Code: Adventure Game Studio
  1.   open_menuQuest();
  2.   close_quest(0);
  3.   open_quest(1);
  4.   open_quest(2);
  5.   close_menuQuest();
  6.  

Maybe I've to close Quest and make some delay before open_quest start to run. But if I try to do "Wait()" it doesn't work... i don't know if I try to do this with timer will be work correctly. What do you think?