HoS_PRC8/_mod/_module/nss/rts_build_datao.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

1238 lines
48 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////
// Real Time Strategy - NWN - Build data for use in module
//==========================================================================
// By Deva Bryson Winblood. 02/24/2003
////////////////////////////////////////////////////////////////////////////
/* This script processes all the data way points provided to do several
actions which should speed up things in the module.
#1 - Process unit waypoints and build the unit variables
#2 - Process the area related waypoints to build a map of sorts
that can tell a path waypoint to waypoint between any two areas.
It will provide waypoints in the intervening areas as well. This
will reduce the amount of work the AI and custom path finding
routines will have to do later */
int NUM_MAGIC_ITEMS = 46;
void fnError(string sE)
{ // quick error message
SendMessageToPC(GetFirstPC(),sE);
PrintString(sE);
} // fnError()
string fnParsePeriod(string sIn)
{ // Parse period
string sH=sIn;
string sR="";
while (GetStringLength(sH)>0&&GetStringLeft(sH,1)!=".")
{ // build string
sR=sR+GetStringLeft(sH,1);
sH=GetStringRight(sH,GetStringLength(sH)-1);
} // build string
return sR;
} // fnParsePeriod()
string fnRemParsed(string sO, string sP)
{ // Remove parsed portion from sO
string sR="";
if (GetStringLength(sO)>=GetStringLength(sP))
sR=GetStringRight(sO,GetStringLength(sO)-GetStringLength(sP));
if (GetStringLeft(sR,1)==".") sR=GetStringRight(sR,GetStringLength(sR)-1);
return sR;
} // fnRemParsed()
void fnBuildTeamUnits(string sTeamP,int nNumUnits,int nTeamC)
{ // Process an individual team's units
int nL=1;
int nWork=nNumUnits;
int nC=0;
object oData, oWP;
object oTempC;
object oMod=GetModule();
string sStore;
string sWork;
string sParse;
string sDetail;
string sCreature;
// Place Permanent guard posts
sParse="oGuard4"+sTeamP;
oData=GetWaypointByTag(sTeamP+"_VAULT");
oTempC=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_marker",GetLocation(oData));
SetLocalObject(oMod,sParse,oTempC);
sParse="oGuard5"+sTeamP;
oData=GetWaypointByTag(sTeamP+"_START");
oTempC=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_marker",GetLocation(oData));
SetLocalObject(oMod,sParse,oTempC);
// End place permanent guard posts
sParse="";
oData=OBJECT_INVALID;
oTempC=OBJECT_INVALID;
while(nL<=nWork)
{ // process units
sWork=sTeamP+IntToString(nC)+"_INFO";
oData=GetWaypointByTag(sWork);
sCreature=sTeamP+IntToString(nC);
oWP=oData;
if (oData!=OBJECT_INVALID)
{ // information on unit found
oTempC=CreateObject(OBJECT_TYPE_CREATURE,sTeamP+IntToString(nC),GetLocation(oWP),FALSE);
SetLocalString(oMod,"sCToken"+IntToString(nTeamC*1000+nC),GetName(oTempC));
SetLocalString(oMod,sCreature+"_name",GetName(oTempC));
SetLocalInt(oMod,sCreature+"_hitdice",GetHitDice(oTempC));
sDetail="";
DelayCommand(0.5,DestroyObject(oTempC));
sStore=GetName(oData);
//SendMessageToPC(GetFirstPC(),"#"+IntToString(nL)+"= "+sStore);
sWork=sTeamP+IntToString(nC);
sParse=fnParsePeriod(sStore); // mana
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_ccmana",StringToInt(sParse));
sDetail="Cost(M:"+sParse;
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore); // gold
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_ccgold",StringToInt(sParse));
sDetail=sDetail+",G:"+sParse;
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore); // soul
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_ccsoul",StringToInt(sParse));
sDetail=sDetail+",S:"+sParse+")";
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore); // tax in
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_taxin",StringToInt(sParse));
sDetail=sDetail+"Tax(In:"+sParse;
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore); // tax out
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_taxout",StringToInt(sParse));
sDetail=sDetail+",Out:"+sParse+")";
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore); // upgrade tag
sStore=fnRemParsed(sStore,sParse);
//SendMessageToPC(GetFirstPC(),"--- UPGRADE:"+sParse+" Rem:"+sStore);
SetLocalString(oMod,sWork+"_uptag",sParse);
if (sParse!="NA") sDetail=sDetail+" [upgradeable]";
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
//SendMessageToPC(GetFirstPC(),"-----Timed:"+sWork+"_timeup ="+sParse);
SetLocalInt(oMod,sWork+"_timeup",StringToInt(sParse));
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalString(oMod,sWork+"_timers",sParse);
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_minlev",StringToInt(sParse));
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalString(oMod,sWork+"_requnit",sParse);
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_harvest",StringToInt(sParse));
if (sParse=="1") sDetail=sDetail+"[harvest]";
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_nopay",StringToInt(sParse));
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalString(oMod,sWork+"_item",sParse);
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_create",StringToInt(sParse));
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_soul",StringToInt(sParse));
if (sParse=="1") sDetail=sDetail+" [has soul].";
SetLocalString(oMod,"sCToken"+IntToString(nTeamC*10000+nC),sDetail);
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_light",StringToInt(sParse));
if (sParse=="1") { sDetail=sDetail+"[light sensitive]";
SetLocalString(oMod,"sCToken"+IntToString(nTeamC*10000+nC),sDetail); }
else if (sParse=="2") { sDetail=sDetail+"[sun fatal]";
SetLocalString(oMod,"sCToken"+IntToString(nTeamC*10000+nC),sDetail); }
if (GetStringLength(sStore)>0)
{ // more to get
sParse=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sParse);
SetLocalInt(oMod,sWork+"_scout",StringToInt(sParse));
if (sParse=="1") { sDetail=sDetail+"[scout]";
SetLocalString(oMod,"sCToken"+IntToString(nTeamC*10000+nC),sDetail); }
if (GetStringLength(sStore)>0)
{ // more to get
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name. It is supplying more data than needed!!");
} // more to get
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // more to get
else
fnError("ERROR RTS: Unit data in '"+sWork+"_INFO' setup improperly. Double check its name.");
} // information on unit found
else
fnError("ERROR RTS: Missing unit information waypoint '"+sWork+"'");
/// test resrefs
sStore=GetLocalString(oMod,sWork+"_uptag");
if (sStore!="NA")
{ // test
oData=CreateObject(OBJECT_TYPE_CREATURE,sStore,GetLocation(oWP),FALSE);
if (oData!=OBJECT_INVALID)
DelayCommand(1.5,DestroyObject(oData));
else
fnError("ERROR RTS: The Unit tag "+sWork+"_INFO makes reference to ResRef '"+sStore+"' which is invalid!");
} // test
sStore=GetLocalString(oMod,sWork+"_timers");
if (sStore!="NA")
{ // test
oData=CreateObject(OBJECT_TYPE_CREATURE,sStore,GetLocation(oWP),FALSE);
if (oData!=OBJECT_INVALID)
DelayCommand(1.5,DestroyObject(oData));
else
fnError("ERROR RTS: The Unit tag "+sWork+"_INFO makes reference to ResRef '"+sStore+"' which is invalid!");
} // test
sStore=GetLocalString(oMod,sWork+"_requnit");
if (sStore!="NA")
{ // test
oData=CreateObject(OBJECT_TYPE_CREATURE,sStore,GetLocation(oWP),FALSE);
if (oData!=OBJECT_INVALID)
DelayCommand(1.5,DestroyObject(oData));
else
fnError("ERROR RTS: The Unit tag "+sWork+"_INFO makes reference to ResRef '"+sStore+"' which is invalid!");
} // test
sStore=GetLocalString(oMod,sWork+"_item");
if (sStore!="NA")
{ // test
oData=CreateObject(OBJECT_TYPE_ITEM,sStore,GetLocation(oWP),FALSE);
if (oData!=OBJECT_INVALID)
DelayCommand(1.5,DestroyObject(oData));
else
fnError("ERROR RTS: The Unit tag "+sWork+"_INFO makes reference to ResRef '"+sStore+"' which is invalid!");
} // test
nC++;
nL++;
} // process units
} // fnBuildTeamUnits()
//----------------------------------[ Build Units ]-----------
void fnBuildUnitData()
{ // Build unit database
object oMod=GetModule();
string sWork;
int nWork;
object oWork;
object oData;
object oWP;
string sName;
int nStore;
int nC;
int nL;
int nTeamC=0; // team count
string sStore;
object oTempC;
string sParse;
string sTeamP;
string sTeamN;
string sTeamPre="";
string sTeamName="";
/* NAMES and Tokens need to be saved for use in conversation as well
nTeams = # of teams
sTeamID# = Team prefic
sTeamN# = Team Name
nTeamU# = Stores number of units
Token Creature = (Team#x1000)+Creature # (0+) stores name of unit
*/
oData=GetWaypointByTag("RTS_TEAM_PREFIXES");
if (oData!=OBJECT_INVALID) sTeamPre=GetName(oData);
oData=GetWaypointByTag("RTS_TEAM_NAMES");
if (oData!=OBJECT_INVALID) sTeamName=GetName(oData);
if (GetStringLength(sTeamPre)>0&&GetStringLength(sTeamName)>0)
{ // names and prefix data found
while(GetStringLength(sTeamPre)>0&&GetStringLength(sTeamName)>0)
{
nTeamC++;
sTeamP=fnParsePeriod(sTeamPre);
sTeamN=fnParsePeriod(sTeamName);
SetLocalString(oMod,"sTeamID"+IntToString(nTeamC),sTeamP);
SetLocalString(oMod,"sTeamN"+IntToString(nTeamC),sTeamN);
SetLocalString(oMod,"sTeamName"+sTeamP,sTeamN);
//SendMessageToPC(GetFirstPC(),"TEAM:"+sTeamP+" NAME:"+sTeamN);
sTeamPre=fnRemParsed(sTeamPre,sTeamP);
sTeamName=fnRemParsed(sTeamName,sTeamN);
//// Error check - make sure required waypoints are present
oData=GetWaypointByTag(sTeamP+"_START");
if (oData==OBJECT_INVALID)
fnError("ERROR RTS: Missing required waypoint '"+sTeamP+"_START'");
oData=GetWaypointByTag(sTeamP+"_HEAL");
if (oData==OBJECT_INVALID)
fnError("ERROR RTS: Missing required waypoint '"+sTeamP+"_HEAL'");
oData=GetWaypointByTag(sTeamP+"_VAULT");
if (oData==OBJECT_INVALID)
fnError("ERROR RTS: Missing required waypoint '"+sTeamP+"_VAULT'");
oData=GetWaypointByTag(sTeamP+"_RESOURCES");
if (oData==OBJECT_INVALID)
fnError("ERROR RTS: Missing required waypoint '"+sTeamP+"_RESOURCES'");
oData=GetWaypointByTag(sTeamP+"_UNITS");
if (oData==OBJECT_INVALID)
fnError("ERROR RTS: Missing required waypoint '"+sTeamP+"_UNITS'");
else
{ // process units
nWork=StringToInt(GetName(oData));
SetLocalInt(oMod,sTeamP+"_num",nTeamC);
SetLocalInt(oMod,"nTeamU"+IntToString(nTeamC),nWork);
SetLocalInt(oMod,sTeamP+"_UNITS",nWork);
if (nWork>0)
{// there are units
nC=0;
nL=1;
SendMessageToPC(GetFirstPC(),"PROCESS UNITS:"+sTeamP);
DelayCommand(1.0,fnBuildTeamUnits(sTeamP,nWork,nTeamC));
} // there are units
else
fnError("ERROR RTS: "+sTeamP+"_UNITS should have the number of units for team "+sTeamN+" typed in as its name. Value 0 is not acceptable.");
} // process units
SetLocalString(oMod,sTeamP+"Name",sTeamN);
} // while
SetLocalInt(oMod,"nNumTeams",nTeamC);
if (GetStringLength(sTeamPre)>0||GetStringLength(sTeamName)>0)
{ // error
fnError("ERROR RTS Setup: RTS_TEAM_ PREFIXES and NAMES are present but, are not setup properly. Data amounts do not match!!");
} // error
} // names and prefix data found
else
{ // error
fnError("ERROR RTS Setup: RTS_TEAM_PREFIXES and RTS_TEAM_NAMES waypoints need to be setup. See documentation!!");
} // error
} // fnBuildUnitData()
int fnObjectCount(object oArea,int nOBTYPE)
{ // return how many objects of this type in the area there are
int nRet=0;
object oOb=GetFirstObjectInArea(oArea);
while (oOb!=OBJECT_INVALID)
{ // count
if(GetObjectType(oOb)==nOBTYPE||nOBTYPE==OBJECT_TYPE_ALL) nRet++;
oOb=GetNextObjectInArea(oArea);
} // count
//SendMessageToPC(GetFirstPC(),"["+GetName(oArea)+"] Count:"+IntToString(nRet));
return nRet;
} // fnObjectCount()
//----------------------[ Build Map ]-------------------
void fnBuildMapData()
{ // Build path for AI to traverse
object oMod=GetModule();
string sWork;
int nWork;
object oWork;
object oData;
object oWP;
object oDest;
string sName;
string sOut="";
int nStore;
int nC;
int nL;
string sStore;
string sParse;
string sA;
string sS;
string sFullA="";
string sFullS="";
int nLevels;
int nX;
int nY;
int nXX;
int nYY;
oData=GetWaypointByTag("RTS_MAP_LEVELS");
if (oData!=OBJECT_INVALID)
{ // !OI - Map Levels
sName=GetName(oData);
sParse=fnParsePeriod(sName);
sName=fnRemParsed(sName,sParse);
nLevels=StringToInt(sParse);
sParse=fnParsePeriod(sName);
sName=fnRemParsed(sName,sParse);
nX=StringToInt(sParse);
sParse=fnParsePeriod(sName);
sName=fnRemParsed(sName,sParse);
nY=StringToInt(sParse);
if (nLevels>0&&nX>0&&nY>0)
{ // proper coordinates found
SetLocalInt(oMod,"MapX",nX);
SetLocalInt(oMod,"MapY",nY);
SetLocalInt(oMod,"MapZ",nLevels);
nC=1;
while(nC<=nLevels)
{ // read the levels
oData=GetWaypointByTag("RTS_MAP_LEVEL"+IntToString(nC));
oWP=GetWaypointByTag("RTS_MAP_STAIRS"+IntToString(nC));
//fnError("[--- Level "+IntToString(nC)+" ---]");
if (oWP==OBJECT_INVALID)
fnError("ERROR RTS: Waypoint for pathing 'RTS_MAP_STAIRS"+IntToString(nC)+"' is missing.");
if (oData!=OBJECT_INVALID)
{ // !OI
sName=GetName(oData);
sStore=GetName(oWP);
nYY=1;
while(nYY<=nY)
{ // Y Dimension
nXX=1;
sOut="";
while (nXX<=nX)
{ // X Dimension
sParse=fnParsePeriod(sName);
sName=fnRemParsed(sName,sParse);
sWork=fnParsePeriod(sStore);
sStore=fnRemParsed(sStore,sWork);
sOut=sOut+GetStringLeft(sParse,1);
if (sParse!="N")
{ // found something
oWork=GetObjectByTag(sParse);
if (oWork!=OBJECT_INVALID)
{ //!OI
SetLocalObject(oMod,"AMAP_"+IntToString(nXX)+"_"+IntToString(nYY)+"_"+IntToString(nC),oWork);
SetLocalInt(oWork,"RTS_Xpos",nXX);
SetLocalInt(oWork,"RTS_Ypos",nYY);
SetLocalInt(oWork,"RTS_Zpos",nC);
DelayCommand(0.5,SetLocalInt(oWork,"nWaypoints",fnObjectCount(oWork,OBJECT_TYPE_WAYPOINT)));
DelayCommand(0.7,SetLocalInt(oWork,"nDoors",fnObjectCount(oWork,OBJECT_TYPE_DOOR)));
DelayCommand(0.9,SetLocalInt(oWork,"nTriggers",fnObjectCount(oWork,OBJECT_TYPE_TRIGGER)));
DelayCommand(1.1,SetLocalInt(oWork,"nPlaceables",fnObjectCount(oWork,OBJECT_TYPE_PLACEABLE)));
DelayCommand(1.1,SetLocalInt(oWork,"nAllObjects",fnObjectCount(oWork,OBJECT_TYPE_ALL)));
sOut=sOut+sWork;
if (sWork=="U") SetLocalInt(oWork,"RTS_Portal",1);
else if (sWork=="D") SetLocalInt(oWork,"RTS_Portal",2);
else if (sWork=="B") SetLocalInt(oWork,"RTS_Portal",3);
//fnError(GetTag(oWork)+" Portal:"+sWork);
oDest=GetFirstObjectInArea(oWork);
if (GetTag(oDest)!="RTS_AI_DEST")
oDest=GetNearestObjectByTag("RTS_AI_DEST",oDest);
if (oDest!=OBJECT_INVALID)
SetLocalObject(oWork,"RTS_Dest",oDest);
else
fnError("ERROR RTS: Area '"+GetName(oWork)+"' does not have a RTS_AI_DEST tag in a reachable location.");
} //!OI
else
fnError("ERROR RTS: Map coordinate ("+IntToString(nXX)+","+IntToString(nYY)+","+IntToString(nC)+") references TAG '"+sParse+"' which does not exist!");
} // found something
sOut=sOut+".";
nXX++;
} // X Dimension
//fnError(sOut);
nYY++;
} // Y Dimension
} // !OI
else
fnError("ERROR RTS: Missing critical pathing waypoint 'RTS_MAP_LEVEL"+IntToString(nC)+"'!");
nC++;
} // read the levels
} // proper coordinates found
else
fnError("ERROR RTS: 'RTS_MAP_LEVELS' stores dimensions in name z.x.y and one or more of these is currently 0 which does not work!");
} // !OI - Map Levels
else
fnError("ERROR RTS: Critical waypoint 'RTS_MAP_LEVELS' not found.");
} // fnBuildMapData()
void fnPlaceThings()
{ // place mana pools, etc.
object oMain;
object oWPA;
object oWPB;
int nR;
int nB;
int nL=0;
object oThing;
string sNum;
string sItem;
object oMod=GetModule();
while(nL<15)
{ // place minor mana
nL++;
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"minormanapool",GetLocation(oMain));
SetLocalInt(oMain,"nUsed",1);
} // place minor mana
nL=0;
while(nL<8)
{ // place mana pool
nL++;
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"manapool",GetLocation(oMain));
SetLocalInt(oMain,"nUsed",1);
} // place mana pool
nL=0;
while(nL<3)
{ // place mana pool
nL++;
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"strongmanapool",GetLocation(oMain));
SetLocalInt(oMain,"nUsed",1);
} // place mana pool
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
SetLocalInt(oMain,"nUsed",1);
// place the Smith
oThing=CreateObject(OBJECT_TYPE_CREATURE,"smith",GetLocation(oMain),FALSE);
SetCustomToken(13,GetName(GetArea(oMain)));
sNum=GetTag(oMain);
oMain=GetWaypointByTag(sNum+"_B");
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"plc_anvil",GetLocation(oMain),FALSE);
SetLocalInt(oThing,"bNoClean",TRUE);
oMain=GetWaypointByTag(sNum+"_A");
oThing=CreateObject(OBJECT_TYPE_STORE,"hm_smith",GetLocation(oMain),FALSE);
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
SetLocalInt(oMain,"nUsed",1);
// place the potions
oThing=CreateObject(OBJECT_TYPE_CREATURE,"apothecary",GetLocation(oMain),FALSE);
sNum=GetTag(oMain);
SetCustomToken(15,GetName(GetArea(oMain)));
oMain=GetWaypointByTag(sNum+"_B");
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"plc_alchapprtus",GetLocation(oMain),FALSE);
SetLocalInt(oThing,"bNoClean",TRUE);
oMain=GetWaypointByTag(sNum+"_A");
oThing=CreateObject(OBJECT_TYPE_STORE,"hm_potions",GetLocation(oMain),FALSE);
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
SetLocalInt(oMain,"nUsed",1);
// place the black market
oThing=CreateObject(OBJECT_TYPE_CREATURE,"fence",GetLocation(oMain),FALSE);
sNum=GetTag(oMain);
SetCustomToken(14,GetName(GetArea(oMain)));
oMain=GetWaypointByTag(sNum+"_B");
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"plc_campfrwpot",GetLocation(oMain),FALSE);
SetLocalInt(oThing,"bNoClean",TRUE);
oMain=GetWaypointByTag(sNum+"_A");
oThing=CreateObject(OBJECT_TYPE_STORE,"hm_bm",GetLocation(oMain),FALSE);
/// healer
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
SetLocalInt(oMain,"nUsed",1);
// place the black market
oThing=CreateObject(OBJECT_TYPE_CREATURE,"healer",GetLocation(oMain),FALSE);
sNum=GetTag(oMain);
SetCustomToken(16,GetName(GetArea(oMain)));
oMain=GetWaypointByTag(sNum+"_B");
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"plc_well",GetLocation(oMain),FALSE);
SetLocalInt(oThing,"bNoClean",TRUE);
oMain=GetWaypointByTag(sNum+"_A");
oThing=CreateObject(OBJECT_TYPE_STORE,"hm_healer",GetLocation(oMain),FALSE);
/// items
nL=0;
while(nL<10)
{ // place unique magic items ------------
nL++;
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
}
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oMain));
if (oThing!=OBJECT_INVALID)
{
SetLocalInt(oThing,"bNoClean",TRUE);
switch(d6())
{ // Guardian
case 1: { // Krenshar
oThing=CreateObject(OBJECT_TYPE_CREATURE,"krenshar001",GetLocation(oThing));
SetLocalObject(oThing,"oGuardPoint",oMain);
break;
} // Owlbear
case 2: { // Krenshar
oThing=CreateObject(OBJECT_TYPE_CREATURE,"gnoll003",GetLocation(oThing));
SetLocalObject(oThing,"oGuardPoint",oMain);
break;
} // Gnoll Shaman
case 3: { // Bandit
oThing=CreateObject(OBJECT_TYPE_CREATURE,"bandit006",GetLocation(oThing));
SetLocalObject(oThing,"oGuardPoint",oMain);
break;
} // Bandit
case 4: { // Yuan-Ti
oThing=CreateObject(OBJECT_TYPE_CREATURE,"yuan_ti002",GetLocation(oThing));
SetLocalObject(oThing,"oGuardPoint",oMain);
break;
} // Yuan-Ti
case 5: { // Invisible Stalker
oThing=CreateObject(OBJECT_TYPE_CREATURE,"invis_stalk001",GetLocation(oThing));
SetLocalObject(oThing,"oGuardPoint",oMain);
break;
} //Invisible Stalker
case 6: { // Will-O'-Wisp
oThing=CreateObject(OBJECT_TYPE_CREATURE,"willow_wisp001",GetLocation(oThing));
SetLocalObject(oThing,"oGuardPoint",oMain);
break;
} // Will-O'-Wisp
// 5 and 6 = no guardian
} // Guardian
SetAILevel(oThing,AI_LEVEL_NORMAL);
}
//SendMessageToPC(GetFirstPC(),"Magic Item Placed in Area:"+GetName(GetArea(oThing)));
SetLocalInt(oMod,sItem,1);
SetLocalInt(oMain,"nUsed",1);
} // place unique magic items ------------
// place 4 more magic items in dungeon crawl areas
nL=0;
while(nL<4)
{
nL++;
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
}
oThing=GetObjectByTag("SPECIAL_ITEM"+IntToString(nL));
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oThing));
SetLocalInt(oThing,"bNoClean",TRUE);
SetLocalInt(oMod,sItem,1);
}
// place 6 more items in the desert areas
nL=0;
while(nL<6)
{ // while desert
nL++;
nR=Random(30)+1;
oThing=GetWaypointByTag("DESERT_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(30)+1;
oThing=GetWaypointByTag("DESERT_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oWPA=oThing;
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{ // pick a different item
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
} // pick a different item
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oWPA));
SetLocalInt(oThing,"bNoClean",TRUE);
SetLocalInt(oMod,sItem,1);
// desert guardian
nR=d6();
switch(nR)
{ // desert guardian
case 1: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian1",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 2: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian2",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 3: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian3",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 4: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian41",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian41",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian42",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 5: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian51",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian51",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian52",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 6: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"desguardian6",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
} // desert guardian
} // while desert
// -- place 3 mana pools in the desert
nL=0;
while(nL<3)
{ // place mana pool
nL++;
nR=Random(30)+1;
oThing=GetWaypointByTag("DESERT_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(30)+1;
oThing=GetWaypointByTag("DESERT_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"manapool",GetLocation(oThing));
} // place mana pool
// place one strong mana pool
nR=Random(30)+1;
oThing=GetWaypointByTag("DESERT_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(30)+1;
oThing=GetWaypointByTag("DESERT_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"strongmanapool",GetLocation(oThing));
// --- place frozen north treasure and guardians
nL=0;
while(nL<10)
{ // place 10 magic items
nL++;
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oWPA=oThing;
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{ // pick a different item
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
} // pick a different item
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oWPA));
SetLocalInt(oThing,"bNoClean",TRUE);
SetLocalInt(oMod,sItem,1);
// choose winter guardian
nR=d8();
if (nR<4) nR=1;
switch(nR)
{ // place guardian
case 1: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"winguardian1",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 4: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"winguardian2",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 5: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"winguardian3",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 6: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"winguardian4",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 7: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"winguardian5",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 8: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"winguardian6",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
} // place guardian
} // place 10 magic items
// place 6 minor mana pools
nL=0;
while(nL<6)
{ // place minor mana pool
nL++;
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"minormanapool",GetLocation(oThing));
} // place minor mana pool
// place 3 mana pools
nL=0;
while(nL<3)
{ // place mana pool
nL++;
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"manapool",GetLocation(oThing));
} // place mana pool
// place 2 strong mana pools
nL=0;
while(nL<2)
{ // place mana pool
nL++;
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"strongmanapool",GetLocation(oThing));
} // place mana pool
// place northern trader
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(63)+1;
oThing=GetWaypointByTag("NORTHERN_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oWPA=oThing;
oThing=CreateObject(OBJECT_TYPE_STORE,"northerntrader",GetLocation(oWPA));
oThing=CreateObject(OBJECT_TYPE_CREATURE,"northerntrader",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
// place world treasure
nL=0;
while(nL<3)
{ // place 3 magic items
nL++;
nR=Random(21)+1;
oThing=GetWaypointByTag("WORLD_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(21)+1;
oThing=GetWaypointByTag("WORLD_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oWPA=oThing;
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{ // pick a different item
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
} // pick a different item
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oWPA));
SetLocalInt(oThing,"bNoClean",TRUE);
SetLocalInt(oMod,sItem,1);
// choose winter guardian
nR=d4();
if (nR<4) nR=1;
switch(nR)
{ // place guardian
case 1: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"wolguardian1",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 2: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"wolguardian2",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 3: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"wolguardian3",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 4: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"wolguardian4",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
} // place guardian
} // place 3 magic items
// Place Dragon Isle Cave treasures
oThing=GetWaypointByTag("DRAGON_TREASURE1");
oWPA=oThing;
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{ // pick a different item
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
} // pick a different item
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oWPA));
SetLocalInt(oThing,"bNoClean",TRUE);
SetLocalInt(oMod,sItem,1);
DelayCommand(5.0,ExecuteScript("unique_dragon_t",OBJECT_SELF));
nL=0;
while(nL<3)
{ // place mana pool
nL++;
nR=Random(21)+1;
oThing=GetWaypointByTag("WORLD_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(21)+1;
oThing=GetWaypointByTag("WORLD_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oThing=CreateObject(OBJECT_TYPE_PLACEABLE,"manapool",GetLocation(oThing));
} // place mana pool
// Place Undersea treasure (30 locations) 5 treasures
nL=0;
while(nL<6)
{ // place 6 magic items
nL++;
nR=Random(30)+1;
oThing=GetWaypointByTag("UNDERSEA_TREASURE"+IntToString(nR));
while(GetLocalInt(oThing,"nUsed")==TRUE)
{ // find another
nR=Random(30)+1;
oThing=GetWaypointByTag("UNDERSEA_TREASURE"+IntToString(nR));
} // find another
SetLocalInt(oThing,"nUsed",TRUE);
oWPA=oThing;
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
while(GetLocalInt(oMod,sItem)==1)
{ // pick a different item
nR=Random(NUM_MAGIC_ITEMS)+1;
sItem="rts_it_mag"+IntToString(nR);
} // pick a different item
oThing=CreateObject(OBJECT_TYPE_ITEM,sItem,GetLocation(oWPA));
SetLocalInt(oThing,"bNoClean",TRUE);
SetLocalInt(oMod,sItem,1);
// choose undersea guardian
nR=d8();
switch(nR)
{ // place guardian
case 1: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"invis_stalk001",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 2: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"krenshar001",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 3: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"drgblack002",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 4: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"wolguardian4",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 5: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"harpy003",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 6: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"ct_owlbear001",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 7: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"golflesh001",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
case 8: {
oThing=CreateObject(OBJECT_TYPE_CREATURE,"golclay001",GetLocation(oWPA));
SetLocalObject(oThing,"oGuardPoint",oWPA);
break;
}
} // place guardian
} // place 6 magic items
//---------------- place mercenary lords --------------------------------
nL=1;
while(nL<4)
{ // place merc lord
oMain=OBJECT_INVALID;
while(oMain==OBJECT_INVALID)
{
nR=Random(100);
if (nR>9) sNum=IntToString(nR);
else sNum="0"+IntToString(nR);
oMain=GetWaypointByTag("RL_"+sNum);
if (GetLocalInt(oMain,"nUsed")==1) oMain=OBJECT_INVALID;
}
SetLocalInt(oMain,"nUsed",1);
// place the black market
oThing=CreateObject(OBJECT_TYPE_CREATURE,"merc_lord"+IntToString(nL),GetLocation(oMain),FALSE);
sNum=GetTag(oMain);
SetCustomToken(9+nL,GetName(GetArea(oMain)));
nB=Random(25);
SetLocalInt(oThing,"nMer1",nB);
nR=Random(25);
while(nR==nB)
{
nR=Random(25);
}
SetLocalInt(oThing,"nMer2",nR);
nL++;
} // place merc lord
} // fnPlaceThings()
void fnSetResourceAmount(object oPlc,int nMode=0)
{
int nP=d100();
int nN1;
int nN2;
if (nP<41)
{
nN1=10;
nN2=200;
}
else if (nP<81)
{
nN1=20;
nN2=400;
}
else if (nP<96)
{
nN1=30;
nN2=600;
}
else
{
nN1=60;
nN2=1200;
}
if (nMode==0) SetLocalInt(oPlc,"nResAmt",nN1);
else { SetLocalInt(oPlc,"nResAmt",nN2); }
} // fnSetResourceAmount()
void fnPlaceMineables()
{ // place mineable
int nR;
object oWP;
object oP;
int nC=1;
while(nC<=3)
{ // admantium
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
while(GetLocalInt(oWP,"nUsed")==TRUE)
{ // keep looking
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
} // keep looking
SetLocalInt(oWP,"nUsed",TRUE);
oP=CreateObject(OBJECT_TYPE_PLACEABLE,"resadm",GetLocation(oWP));
//SendMessageToPC(GetFirstPC(),GetName(oP)+" created in "+GetName(GetArea(oWP)));
fnSetResourceAmount(oP);
nC++;
} // admantium
nC=1;
while(nC<=2)
{ // mithral
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
while(GetLocalInt(oWP,"nUsed")==TRUE)
{ // keep looking
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
} // keep looking
SetLocalInt(oWP,"nUsed",TRUE);
oP=CreateObject(OBJECT_TYPE_PLACEABLE,"resmith",GetLocation(oWP));
//SendMessageToPC(GetFirstPC(),GetName(oP)+" created in "+GetName(GetArea(oWP)));
fnSetResourceAmount(oP);
nC++;
} // mithral
nC=1;
while(nC<=8)
{ // iron
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
while(GetLocalInt(oWP,"nUsed")==TRUE)
{ // keep looking
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
} // keep looking
SetLocalInt(oWP,"nUsed",TRUE);
oP=CreateObject(OBJECT_TYPE_PLACEABLE,"resiron",GetLocation(oWP));
//SendMessageToPC(GetFirstPC(),GetName(oP)+" created in "+GetName(GetArea(oWP)));
fnSetResourceAmount(oP);
nC++;
} // iron
nC=1;
while(nC<=6)
{ // gold
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
while(GetLocalInt(oWP,"nUsed")==TRUE)
{ // keep looking
nR=Random(80)+1;
oWP=GetWaypointByTag("MINE_"+IntToString(nR));
} // keep looking
SetLocalInt(oWP,"nUsed",TRUE);
oP=CreateObject(OBJECT_TYPE_PLACEABLE,"resgold",GetLocation(oWP));
//SendMessageToPC(GetFirstPC(),GetName(oP)+" created in "+GetName(GetArea(oWP)));
fnSetResourceAmount(oP,1);
nC++;
} // gold
} // fnPlaceMineables()
//========================================================[ M A I N ]=======
void main()
{
fnError("[============ BUILDING UNITS ============]");
fnBuildUnitData();
fnError("[============ BUILDING AI PATHING MAPS ============]");
fnBuildMapData();
fnError("[============ PLACING OBJECTS =============]");
fnPlaceThings();
fnError("[============ BUILDING COMPLETED ============]");
SetLocalInt(GetModule(),"RTSDATABUILT",TRUE);
DelayCommand(2.5,fnPlaceMineables());
DelayCommand(4.0,ExecuteScript("hos_place_hench",OBJECT_SELF));
DelayCommand(8.0,ExecuteScript("place_more_stuff",OBJECT_SELF));
DelayCommand(10.0,ExecuteScript("mel_placement",OBJECT_SELF));
DelayCommand(12.0,ExecuteScript("place_underwater",OBJECT_SELF));
}
//========================================================[ M A I N ]=======