//::///////////////////////////////////////////////
//:: Create Food and Water
//:: shaz_sp_create_food_and_water.nss
//:://////////////////////////////////////////////
/*
    Creates enough food and water for three people per level.
	The food is highly nourishing, if somewhat bland.
	The food goes bad and becomes inedible within 8 hours. 
*/
//:://////////////////////////////////////////////
//:: Created By: Ken Cockerham
//:: Created On: 4/30/08
//:://////////////////////////////////////////////

#include "ginc_debug"
#include "ginc_math"
#include "jx_inc_magic"
#include "x2_inc_spellhook" 
#include "shaz_inc_forcewall"

void mainSpell();
void main()
{
	AssignCommand(JXGetCaster(), mainSpell());
}

void mainSpell()
{

/* 
  Spellcast Hook Code 
  Added 2003-06-20 by Georg
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more
  
*/

    if (!X2PreSpellCastCode())
    {
	// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        { JXPostSpellCastCode(); return; }
    }

// End of Spell Cast Hook
	object oTarget = JXGetSpellTargetObject();

	// Shaz: I've got it "self only" in the 2da, but the PHB seems to suggest it could be cast on anyone nearby...
	// so anyway i;ll do it like this until i fix the 2da and other crap
	if(GetIsObjectValid(oTarget)) {
		CreateItemOnObject("summoned_food", oTarget, JXGetCasterLevel());
		CreateItemOnObject("summoned_water", oTarget, JXGetCasterLevel());
	} else {
		CreateItemOnObject("summoned_food", OBJECT_SELF, JXGetCasterLevel());
		CreateItemOnObject("summoned_water", OBJECT_SELF, JXGetCasterLevel());
	}
   
	
	JXPostSpellCastCode();
}