User Tools

Site Tools


dev_todo:time_of_day_based_events

Hooks have been added to the plugin system for time of day based events. Additionaly, the python plugin was extended with those hooks. Now all thats left is making scripts that use it.

On the sourceforge tracker

Time of Day based events

Allow map makers to utilize date and time for their maps.

Developper working on it: tchize

Implementation documentation: tod

Possible Uses

  • Stores open and close. → script uploaded that can close/open gates depending on time
  • Monsters sleep at different times of day → see python/tod/sleep.py (add various moods?)
  • Holidays
    • Stores can have sales
  • NPCs that move to different locationsEither activate move floors depending on time, either use werewolf mecanism to make NPC 1 disappear and NPC2 appear.
  • Alchemy formulae that will only yeild a result at a certain time (night, full moon, etc) → could filter on event_trigger be used on alchemy object?
  • Dungeons only accessable at certain times → gates can close/open depending on time
  • Monsters like Werewolfs→script build that can change monster depending on time of day
    • Can we (is it copyrighted?) have monsters turn to stone based on the time?
  • Items being affected by the time of day → Demo weapons in test/tod that attack only at night / during day
  • Perhaps connected values alter/default, so scorn gates are open during the day, closed at night. → predefined python filters can be used on event, object can bythemself trigger some connected value at specific time
  • Add Gridarta UI to easily use prebuild python scripts → asked to gridarta team, they are thinking about script UI

current stage

Approximatively 90% work done on this. Still need to build a few script, like one to alter the destination of a map depending on hour and another to freeze/make alive all monster in map at a certain time. Note: some things below may only be working currently on developper's computer and may not yet have been commited

C code

  • Transfert of Month/weekday/season names to plugins.
  • Add notions for periods of the day. (night, dawn, morning, noon, evening, dusk/sunset)
  • provide a name→index hastable for periods of day/year

python

Example (verbose) python code using time based informations

import Crossfire
import string
 
Crossfire.Log(Crossfire.LogDebug, "Number of seasons for this server: %d" %Crossfire.Time.SEASONS_PER_YEAR)
for x in range(Crossfire.Time.SEASONS_PER_YEAR):
	Crossfire.Log(Crossfire.LogDebug, "Season %d is %s" %(x,Crossfire.GetSeasonName(x)))
Crossfire.Log(Crossfire.LogDebug, "Number of week days for this server: %d" %Crossfire.Time.DAYS_PER_WEEK)
for x in range(Crossfire.Time.DAYS_PER_WEEK):
	Crossfire.Log(Crossfire.LogDebug, "weekday %d is %s" %(x,Crossfire.GetWeekdayName(x)))
Crossfire.Log(Crossfire.LogDebug, "Number of months for this server: %d" %Crossfire.Time.MONTHS_PER_YEAR)
for x in range(Crossfire.Time.MONTHS_PER_YEAR):
	Crossfire.Log(Crossfire.LogDebug, "Month %d is %s" %(x,Crossfire.GetMonthName(x)))
 
 
 
now = Crossfire.GetTime()
parameters = string.split(Crossfire.ScriptParameters(),",")
current = [Crossfire.GetMonthName(now[1]),Crossfire.GetWeekdayName(now[5]),Crossfire.GetSeasonName(now[7])]
 
Crossfire.SetReturnValue(1)
if (set(parameters) & set(current)):
	Crossfire.SetReturnValue(0)

filter event

Prebuild scripts are available in /python/tod/sleep.py.

dev_todo/time_of_day_based_events.txt · Last modified: 2007/12/16 07:05 (external edit)