Skip to content
User Avatar
#1549
Auto-translated
AkaR
I'm having a problem: (
I can't seem to get the GetDate function to work.
I need it so that when quest N is received, the countdown to day M (in my case, 10) begins, and when the 10th day arrives since the quest was received, a certain action is performed. But it's also necessary that if the hero completes the quest within those 10 days, the trigger resets, and the function loses its meaning. I wrote a complicated function with a bunch of if statements, but it refuses to work. The console doesn't output anything :( .

I don't think it's that complicated. Here's how you can do it. You have the quest being received triggered by a function, right?

Then:
n = 0 (write this outside of all functions)

--Your function--
....
Quest received (the required one)
n = 1 -- now we set n to one
--end of function--

Now, through a trigger for a new day (Trigger(NEW_DAY_TRIGGER , 'day')) (example), call the function to execute.

--new day function--
if n > 0, then
n = n + 1 -- if n > 0, which in our case means that the quest has already become active, we increment n by 1.
--end of new day function--

Thus, we add +1 to n each day, starting from the day after the quest is received.
Now, all that remains is to write the verification function (it can be written directly inside the new day function)

--new day function--
--what is written above--
if n == 11 and the quest has already been completed, then
Your actions
Otherwise, if n == 11, then (this already means that after this time, the quest has not been completed)
Your other actions
"For aesthetics, if you don't need the counter to continue, make n = 0"
--end of new day function--

If "Your actions" are already written in another function, that's not a problem. Instead, write startThread (name_of_function_with_actions). That's it, I think.
[/code]
Now, a little reference material:

Trigger(NEW_DAY_TRIGGER , 'day') -- trigger for a new day
SetObjectiveState ('objname' , OBJECTIVE_ACTIVE) -- activate the quest, replace the first parameter with the name of your quest
SetObjectiveState ('objname' , OBJECTIVE_COMPLETED/FAILED) -- complete the quest, or fail it.
n = 0 -- and so on (variable)
Trigger(TRIGGER_NAME, nil) -- reset the trigger.


Thus, here is the complete script: (instead of red, you substitute your values):

n = 0

function xxx
...
SetObjectiveState ('obj1' , OBJECTIVE_ACTIVE)
n = 1
end

Trigger(NEW_DAY_TRIGGER , 'day')

function day
if n > 0 then
n = n + 1
end
if n == 11 and GetObjectiveState ('obj1') == OBJECTIVE_COMPLETED then
...
elseif n == 11 then
...
end
end

I don't think I wrote anything more complicated. ;)

Whatever