146 lines
4.9 KiB
Plaintext
146 lines
4.9 KiB
Plaintext
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: areahandler_inc
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
This includefile contains all the nessesary
|
||
|
functions to set up and loop through all areas
|
||
|
that has a placable item in them that has a tag
|
||
|
value of your choice. The placable is destroyed
|
||
|
when InitializeAreaList is called.
|
||
|
|
||
|
InitializeArea - Call this only from OnModuleLoad.
|
||
|
GetFirstArea - Returns the first area from the modlues arealist.
|
||
|
GetNextArea - Returns the next area from the modlues arealist.
|
||
|
GetAreaByIndex - Returns the specified area in the modules arealist.
|
||
|
GetAreaLocationByIndex - Returns the location of the area designator in the area.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 02-mar-2005
|
||
|
//:: Updated By: Flash
|
||
|
//:: Updated On: 05-mar-2005
|
||
|
//:: Update: Save the location of the designator and added GetAreaLocationByIndex.
|
||
|
//:: Store Locations only, use Location.area to get area.
|
||
|
//:://////////////////////////////////////////////
|
||
|
string MOD_AREA_DESIGNATOR_TAG = "area_designator";
|
||
|
|
||
|
const string MOD_AREA_LIST_LOC = "MOD_AREA_LOC_";
|
||
|
const string MOD_AREA_LIST_COUNT = "MOD_AREA_COUNT";
|
||
|
const string MOD_AREA_LIST_POINTER = "MOD_AREA_LIST_POINTER";
|
||
|
|
||
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: InitializeAreaList
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Initialize the modules list of areas. This will
|
||
|
delete all placeables with the tag value defined
|
||
|
in AREA_DESIGNATOR_TAG. Add a placable with the
|
||
|
defined value in all areas you want to be able
|
||
|
to have in the list.
|
||
|
Call this function only from OnModuleLoad.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 02-mar-2005
|
||
|
//:://////////////////////////////////////////////
|
||
|
void InitializeAreaList()
|
||
|
{
|
||
|
int i = 0;
|
||
|
object oDesignator = GetObjectByTag(MOD_AREA_DESIGNATOR_TAG, i);
|
||
|
location lArea;
|
||
|
|
||
|
while (GetIsObjectValid(oDesignator))
|
||
|
{
|
||
|
lArea = GetLocation(oDesignator);
|
||
|
SetLocalLocation(GetModule(), MOD_AREA_LIST_LOC+IntToString(i), lArea);
|
||
|
DestroyObject(oDesignator);
|
||
|
oDesignator = GetObjectByTag(MOD_AREA_DESIGNATOR_TAG, ++i);
|
||
|
}
|
||
|
|
||
|
SetLocalInt(GetModule(), MOD_AREA_LIST_COUNT, --i);
|
||
|
}
|
||
|
|
||
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: GetAreaByIndex
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Returns the specified area in the modules arealist.
|
||
|
This function does not update the area pointer.
|
||
|
Returns OBJECT_INVALID on error.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 02-mar-2005
|
||
|
//:://////////////////////////////////////////////
|
||
|
object GetAreaByIndex(int iAreaIndex)
|
||
|
{
|
||
|
return GetAreaFromLocation(GetLocalLocation(GetModule(), MOD_AREA_LIST_LOC + IntToString(iAreaIndex)));
|
||
|
}
|
||
|
|
||
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: GetAreaLocationByIndex
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Returns the specified location of the area designator in the modules arealist.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 05-mar-2005
|
||
|
//:://////////////////////////////////////////////
|
||
|
location GetAreaLocationByIndex(int iAreaIndex)
|
||
|
{
|
||
|
return GetLocalLocation(GetModule(), MOD_AREA_LIST_LOC + IntToString(iAreaIndex));;
|
||
|
}
|
||
|
|
||
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: GetFirstArea
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Returns the first area in the modules arealist.
|
||
|
Returns OBJECT_INVALID on error.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 02-mar-2005
|
||
|
//:://////////////////////////////////////////////
|
||
|
object GetFirstArea()
|
||
|
{
|
||
|
SetLocalInt(GetModule(), MOD_AREA_LIST_POINTER, 0);
|
||
|
return GetAreaByIndex(0);
|
||
|
}
|
||
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: GetNextArea
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Returns the next area in the modules arealist
|
||
|
Returns OBJECT_INVALID on error.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 02-mar-2005
|
||
|
//:://////////////////////////////////////////////
|
||
|
object GetNextArea()
|
||
|
{
|
||
|
int i = GetLocalInt(GetModule(), MOD_AREA_LIST_POINTER);
|
||
|
object oArea = GetAreaByIndex(i);
|
||
|
if(GetIsObjectValid(oArea))
|
||
|
SetLocalInt(GetModule(), MOD_AREA_LIST_POINTER, ++i);
|
||
|
return oArea;
|
||
|
}
|
||
|
|
||
|
//::///////////////////////////////////////////////
|
||
|
//:: Name: GetAreaCount
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Returns the number of areas in the list
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: Flash
|
||
|
//:: Created On: 02-mar-2005
|
||
|
//:://////////////////////////////////////////////
|
||
|
int GetAreaCount()
|
||
|
{
|
||
|
return GetLocalInt(GetModule(), MOD_AREA_LIST_COUNT);
|
||
|
}
|
||
|
|