Page 1 of 1

Weather-based tasks - sometimes it works, sometimes not

Posted: Mon Sep 05, 2022 8:50 pm
by haloterm
Hi again,

the following code segment is supposed to do the following:

- if it's evening or night, and if the weather is fog, rain or thunderstorm, and if the player is at the correct location, a specific type of monster will be generated.
- if it's day, the night monsters disappear and are not generated. Instead, a day type will be generated

Code: Select all

-- during foggy and rainy nights in my location, the monsters arrive
_NightFoes_ task:
    when _wet_ and _dark_ and _atMyLocation_
        create foe _FoeA_ every 4 minutes 12 times with 100% success
        create foe _FoeB_ every 30 minutes 15 times with 100% success

-- at daytime, a few other foes appear
_DayFoes_ task:
    when _bright_ and _atMyLocation_
        create foe _FoeC_ every 11 minutes 13 times with 60% success

-- when it is day again, the night foes disappear
_RemoveNightFoes_ task:
    when _bright_
        remove foe _FoeA_
        remove foe _FoeB_
        clear _NightFoes_
        clear _RemoveNightFoes_


-- to determine weather
_wet_ task:
    when _rain_ or _fog_ or _thunderstorm_

_rain_ task:
    weather rain

_fog_ task:
    weather fog

_thunderstorm_ task:
    weather thunder


-- to determine time of day
_bright_ task:
    when _day_

_dark_ task:
    when _evening_ or _night_

_day_ task:
    daily from 04:31 to 21:29

_evening_ task:
    daily from 21:30 to 23:59

_night_ task:
    daily from 00:00 to 04:30


-- to determine correct location (gets set with pc at command somewhere else in the script)
_atMyLocation_ task:
Problem: This works quite often. But sometimes it does not, even though nothing is different.

I have to purge the quest and re-start it, then it works.

But the variables / tasks status in the quest debugger are correct even when it does not work.

Once again I'm clueless. It should work all the time, not just sometimes...

Re: Weather-based tasks - sometimes it works, sometimes not

Posted: Tue Sep 06, 2022 6:55 am
by Jay_H
I haven't tested your specific code out, but the "remove" action is permanent as long as the quest is running. If you tell the game to remove FoeA, every future instance of FoeA will be prevented from spawning until the quest ends. That sounds reasonable to me, why the enemies aren't spawning for you.

Re: Weather-based tasks - sometimes it works, sometimes not

Posted: Tue Sep 06, 2022 7:10 am
by haloterm
Jay_H wrote: Tue Sep 06, 2022 6:55 am I haven't tested your specific code out, but the "remove" action is permanent as long as the quest is running. If you tell the game to remove FoeA, every future instance of FoeA will be prevented from spawning until the quest ends.
Oh. Thanks!

This could actually make sense. When I arrive in my location during daytime, my "RemoveNightFoes" task is already executed and thus preventing the foes appearing at all once it is dark...

I did not know that (and in the TIpton docs there is no description of "remove foe" at all (the link in the table of contents goes to another action instead).

Is there a known way of "hiding" foes and later let them re-appear?

Re: Weather-based tasks - sometimes it works, sometimes not

Posted: Thu Sep 08, 2022 4:11 am
by imsobadatnicknames
haloterm wrote: Tue Sep 06, 2022 7:10 am Is there a known way of "hiding" foes and later let them re-appear?
Only way I can think of off the top of my head:

Create a second quest file that contains the enemy spawn in the quest start up and the condition to despawn the enemy.
Then from the first quest file you can create a new instance of this second quest as many times as you want. Since they're not the same quest, the enemy despawns won't be permanent.