thanks for the reply. Here's what I did, which also includes use of custom tokens.
Essentially, I'm trying to create a list of selected areas in the module so that faction and guild leaders can target to launch "long range" attacks using siege engine placeables. Through a conversation, they can choose the type of siege engine (trebuchet, catapault, ballista, etc...) with each type having various quantity of ammunition, qualities of ammunition (damage), accuracy, and cost. The leader also gets to determine what portion of the target area to launch at (upper left, upper middle, upper right, middle left, middle middle, middle right, lower left, lower middle, lower right) Once launched, the system determines if, given the accuracy of the seige engine, whether the shot was "on target" or not. It then creates effects in a random spot within the spot that was hit and does the appropriate damage.
The area list will be static (i.e. the number of areas "shouldn't" change during the game, though it would be cool for DMs to have the flexibility to place down temporary banners that the system would recognize...), so I'm toying with the idea of writing the list to the module on the first use of the placeable so as to reduce system resource needs to do the loop every time the placeable is used.
So in the below code, I figure I'll use less than 100 waypoints in the module as being targettable (the areas are selected based on their proximity to all the faction headquarters).
My area tagging referenced in the code is based on the following convention: AX100Y100, where "A" or some other letter designates the type of map it is (A is for outdoor, B is for indoor) and then the X/Y coordinates on my map.
I'd be interested to hear how the above code might be better than what I've cobbled together, though I think we largely went in the same direction. I'm not sure that it would be appropriate to set the custom tokens here or set them in a different script. I was thinking of changing the SetCustomToken to SetLocalString and write it to the mod.
What do you think?
void main()
{
object oPC = GetPCSpeaker();
object oWP;
object oWPArea;
string sWPAreaName;
string sWPAreaTag;
string sWPAreaTagLeft1;
int iModSet = GetLocalInt (GetModule(), "SiegeListSet");
int iN;
int iWPCustomToken;
//if the loop has been done before, no need to do it again
if (iModSet !=0)
{
//Loop to look for waypoints
for (iN =0; iN
{
oWP = GetObjectByTag("WP_Siege, iN");
oWPArea = GetArea (oWP);
sWPAreaName = GetName (oWPArea);
sWPAreaTag = GetTag (oWPArea);
sWPAreaTagLeft1 = GetStringLeft (sWPAreaTag, 1);
int iAreaRace = GetLocalInt (oWPArea, "SeigeRace");
//Use area tag classification to determine if the area is outdoor, indoor, or underdark. Skip random dungeon areas. Others possible.
if (sWPAreaTagLeft1 == "A") //Outdoor
{
//Separate Feylands from non-fey. 1 = Fey, 2=Bastion/Human/Halfelf, 3 = Dwarf, 4 = Gnome, 5 = Monster, 6= halfling
if (iAreaRace ==1)
{
SetCustomToken (410000 + iN, sWPAreaName);
SetCustomToken (510000 + iN, sWPAreaTag);
}
else if (iAreaRace ==2)
{
SetCustomToken (442000 + iN, sWPAreaName);
SetCustomToken (542000 + iN, sWPAreaTag);
}
else if (iAreaRace ==3)
{
SetCustomToken (443000 + iN, sWPAreaName);
SetCustomToken (543000 + iN, sWPAreaTag);
}
else if (iAreaRace ==4)
{
SetCustomToken (444000 + iN, sWPAreaName);
SetCustomToken (544000 + iN, sWPAreaTag);
}
else if (iAreaRace ==5)
{
SetCustomToken (445000 + iN, sWPAreaName);
SetCustomToken (545000 + iN, sWPAreaTag);
}
else if (iAreaRace ==6)
{
SetCustomToken (446000 + iN, sWPAreaName);
SetCustomToken (546000 + iN, sWPAreaTag);
}
//Nonclaimed lands
else
{
SetCustomToken (470000 + iN, sWPAreaName);
SetCustomToken (570000 + iN, sWPAreaTag);
}
}
else if (sWPAreaTagLeft1 == "B")//indoor
{
//Separate Feylands from non-fey. 1 = Fey, 2=Bastion/Human/Halfelf, 3 = Dwarf, 4 = Gnome, 5 = Monster, 6= halfling
if (iAreaRace ==1)
{
SetCustomToken (420000 + iN, sWPAreaName);
SetCustomToken (520000 + iN, sWPAreaTag);
}
else if (iAreaRace ==2)
{
SetCustomToken (452000 + iN, sWPAreaName);
SetCustomToken (552000 + iN, sWPAreaTag);
}
else if (iAreaRace ==3)
{
SetCustomToken (453000 + iN, sWPAreaName);
SetCustomToken (553000 + iN, sWPAreaTag);
}
else if (iAreaRace ==4)
{
SetCustomToken (454000 + iN, sWPAreaName);
SetCustomToken (554000 + iN, sWPAreaTag);
}
else if (iAreaRace ==5)
{
SetCustomToken (455000 + iN, sWPAreaName);
SetCustomToken (555000 + iN, sWPAreaTag);
}
else if (iAreaRace ==6)
{
SetCustomToken (456000 + iN, sWPAreaName);
SetCustomToken (556000 + iN, sWPAreaTag);
}
//Nonclaimed lands
else
{
SetCustomToken (480000 + iN, sWPAreaName);
SetCustomToken (580000 + iN, sWPAreaTag);
}
}
else if (sWPAreaTagLeft1 == "U") //Underdark
{
//Separate Feylands from non-fey. 1 = Fey, 2=Bastion/Human/Halfelf, 3 = Dwarf, 4 = Gnome, 5 = Monster, 6= halfling
if (iAreaRace ==1)
{
SetCustomToken (430000 + iN, sWPAreaName);
SetCustomToken (530000 + iN, sWPAreaTag);
}
else if (iAreaRace ==2)
{
SetCustomToken (452000 + iN, sWPAreaName);
SetCustomToken (552000 + iN, sWPAreaTag);
}
else if (iAreaRace ==3)
{
SetCustomToken (463000 + iN, sWPAreaName);
SetCustomToken (563000 + iN, sWPAreaTag);
}
else if (iAreaRace ==4)
{
SetCustomToken (464000 + iN, sWPAreaName);
SetCustomToken (564000 + iN, sWPAreaTag);
}
else if (iAreaRace ==5)
{
SetCustomToken (465000 + iN, sWPAreaName);
SetCustomToken (565000 + iN, sWPAreaTag);
}
else if (iAreaRace ==6)
{
SetCustomToken (466000 + iN, sWPAreaName);
SetCustomToken (566000 + iN, sWPAreaTag);
}
//Nonclaimed lands
else
{
SetCustomToken (490000 + iN, sWPAreaName);
SetCustomToken (590000 + iN, sWPAreaTag);
}
}
}
}
SetLocalInt (GetModule(), "SiegeListSet",1);
}
Modifié par BelowTheBelt, 23 juillet 2010 - 08:00 .