// SCENARIO SCRIPT

// This is the special script for your entire scenario. It contains
// special encounters and code accessable from anywhere in the scenario. it also
// contains the code that initializes important special things in the
// scenario (like shops and names and descriptions of special items).

// You can create your own states, but you should give all of them numbers greater than
// or equal to 10.

beginscenarioscript;

variables;
short time;

body;

// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//    Names and descriptions of special items.
//    Names and effects of custom special abilities.
beginstate LOAD_SCEN_STATE;
	init_special_item(0,"Mysterious Package","This is a strange box that the wizard Hubert wants you to deliver to Boltforth.");
	init_special_item(1,"Flower","This is a pretty flower that you found mysteriously growing in a patch of snow on the mountain trail.");
	init_special_item(2,"Ancient Ring","This is a strange cobalt-blue ring displaying a skull in front of a cresent moon.");
	init_special_item(3,"Ancient Runestone","This is a large smooth stone wth several cryptic glyphs cut into it. They glow faintly.");
	
	init_quest(0,"Deliver Package","You need to take a package to a wizard in the town of Boltforth.");
	break;

// This is the state that is called only once at the very beginning of 
// the scenario. Some things that should go here:
//    The stuff in shops.
//    Creating horses and boats.
beginstate START_SCEN_STATE;
break;

// This state is called every tick wherever the party is in the scenario.
// You can use the set_state
beginstate START_STATE;
time = (1 + -2 * (get_flag(100,2) > 128)) * (get_flag(100,1) + 256 * (get_flag(100,2) - (128 * (get_flag(100,2) > 128))));
if(get_current_tick()<4200){ //should only happen at scenario start
	set_ticks_forward(4200-get_current_tick()); //jump to tick 4200
	time = 0;
}
if(get_current_tick()<4200 && get_flag(0,12)==0){ //should only happen at scenario start
	set_ticks_forward(4200-get_current_tick()); //jump to tick 4200
	time = 0;
}
else if(get_current_tick()>=4200 && get_flag(0,12)==0){
	set_ticks_forward(-10); //go back to keep it night time
	time = time + 1;
}
else
	time = time + 1;
if(time>=30000)
	time = 0;
set_flag(100,1,(1 + -2 * (time < 0)) * time);
set_flag(100,2,(time / (256 * (1 + -2 * (time < 0)))) + (128 * (time < 0)));

break;

// Place your own states below. Give each a number at least 10.
beginstate 10;
break;
