Modified CEP 2DA hak to remove extraneous creatures from palette. Added door closer script to most town doors. Added Amulet of Mighty Fists +1 through +5 to loot table. Fixed names on remainder of creatures. Updated PEPS. Set PEPS to server mode. Set module to server mode. Updated Class Title function in ms_name_inc. Updated dungeon areas to reset, globally & per player. Added "new" weapons to the Blacksmith. Added magical "new" weapons to the treasure tables. Fixed persistent storage.
311 lines
13 KiB
Plaintext
311 lines
13 KiB
Plaintext
void main()
|
|
{
|
|
object oPC = GetEnteringObject();
|
|
if (!GetIsPC(oPC)) return;
|
|
|
|
int bDebug = GetLocalInt(GetModule(), "MMD_DEBUG");
|
|
|
|
int iLevel = GetHitDice(oPC);
|
|
if (iLevel > 20) iLevel = 20;
|
|
string sLevel = IntToString(iLevel);
|
|
|
|
string sMytag, sPtag, sNum, sSix;
|
|
int iType, iNum, iSix;
|
|
location lMyloc;
|
|
|
|
string sAreaTag = GetTag(OBJECT_SELF);
|
|
|
|
if (bDebug) SendMessageToPC(oPC, "Entered area " + sAreaTag + " at level " + sLevel);
|
|
WriteTimestampedLogEntry("PC " + GetName(oPC) + " entered " + sAreaTag + " at level " + sLevel);
|
|
|
|
// check if this PC is still on cooldown for this area
|
|
int iCooldown = GetLocalInt(oPC, "DungeonCooldown_" + sAreaTag);
|
|
if (iCooldown == 1)
|
|
{
|
|
if (bDebug) SendMessageToPC(oPC, "Cooldown active for " + sAreaTag + ". Skipping spawn.");
|
|
WriteTimestampedLogEntry("Spawn skipped: " + GetName(oPC) + " entered " + sAreaTag + " but is on cooldown.");
|
|
return;
|
|
}
|
|
|
|
// check if another PC is in the area already
|
|
object oCheck = GetFirstObjectInArea(OBJECT_SELF);
|
|
while (oCheck != OBJECT_INVALID)
|
|
{
|
|
if (GetIsPC(oCheck) && oCheck != oPC)
|
|
{
|
|
if (bDebug) SendMessageToPC(oPC, "Another character is already in the area. Skipping spawn.");
|
|
WriteTimestampedLogEntry("Spawn skipped: " + GetName(oPC) + " entered " + sAreaTag + " but another PC is already inside.");
|
|
return;
|
|
}
|
|
oCheck = GetNextObjectInArea(OBJECT_SELF);
|
|
}
|
|
|
|
// mark this PC as having triggered the dungeon
|
|
SetLocalInt(oPC, "DungeonCooldown_" + sAreaTag, 1);
|
|
if (bDebug) SendMessageToPC(oPC, "Cooldown set. Starting spawns...");
|
|
WriteTimestampedLogEntry("Spawns triggered: " + GetName(oPC) + " started dungeon " + sAreaTag);
|
|
|
|
object oSpawn = GetFirstObjectInArea(OBJECT_SELF);
|
|
while (oSpawn != OBJECT_INVALID)
|
|
{
|
|
int iSpawn = GetLocalInt(oSpawn,"done");
|
|
int iKind = GetObjectType(oSpawn);
|
|
|
|
if (iSpawn != 1 && iKind == OBJECT_TYPE_WAYPOINT)
|
|
{
|
|
SetLocalInt(oSpawn,"done",1);
|
|
|
|
sMytag = GetTag(oSpawn) + sLevel;
|
|
sPtag = GetTag(oSpawn);
|
|
iType = StringToInt(GetStringLeft(sMytag,1));
|
|
lMyloc = GetLocation(oSpawn);
|
|
iNum = d10(1);
|
|
sNum = IntToString(Random(41)+1);
|
|
iSix = d6();
|
|
sSix = IntToString(iSix);
|
|
|
|
if (bDebug) SendMessageToPC(oPC, "Spawning type " + IntToString(iType) +
|
|
" from WP " + sPtag);
|
|
WriteTimestampedLogEntry("Spawn point " + sPtag + " (type " + IntToString(iType) + ") activated by " + GetName(oPC));
|
|
|
|
switch (iType)
|
|
{
|
|
case 1:
|
|
if (bDebug) SendMessageToPC(oPC, " -> Encounter roll " + IntToString(iNum));
|
|
WriteTimestampedLogEntry("Encounter roll " + IntToString(iNum) + " at " + sPtag + " for " + GetName(oPC));
|
|
switch (iNum)
|
|
{
|
|
case 1: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc); break;
|
|
case 2: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc); break;
|
|
case 3: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc); break;
|
|
case 4: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc); break;
|
|
case 5: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc); break;
|
|
case 6: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc); break;
|
|
case 7: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc); break;
|
|
case 8: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc); break;
|
|
case 9: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc); break;
|
|
case 10: CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"b",lMyloc); break;
|
|
}
|
|
break;
|
|
|
|
case 2: CreateObject(OBJECT_TYPE_PLACEABLE,sPtag+sNum,lMyloc);
|
|
if (bDebug) SendMessageToPC(oPC," -> Placed object: " + sPtag+sNum);
|
|
WriteTimestampedLogEntry("Placed object " + sPtag+sNum + " at " + sPtag + " for " + GetName(oPC));
|
|
break;
|
|
case 3: CreateObject(OBJECT_TYPE_PLACEABLE,sPtag+sNum,lMyloc);
|
|
if (bDebug) SendMessageToPC(oPC," -> Placed mundane: " + sPtag+sNum);
|
|
WriteTimestampedLogEntry("Placed mundane " + sPtag+sNum + " at " + sPtag + " for " + GetName(oPC));
|
|
break;
|
|
case 4: CreateObject(OBJECT_TYPE_ITEM,sMytag+"_"+sSix,lMyloc);
|
|
if (bDebug) SendMessageToPC(oPC," -> Dropped item: " + sMytag+"_"+sSix);
|
|
WriteTimestampedLogEntry("Dropped item " + sMytag+"_"+sSix + " at " + sPtag + " for " + GetName(oPC));
|
|
break;
|
|
case 5: CreateObject(OBJECT_TYPE_CREATURE,sPtag+sNum,lMyloc);
|
|
if (bDebug) SendMessageToPC(oPC," -> Special encounter: " + sPtag+sNum);
|
|
WriteTimestampedLogEntry("Special encounter " + sPtag+sNum + " spawned at " + sPtag + " for " + GetName(oPC));
|
|
break;
|
|
case 6: CreateObject(OBJECT_TYPE_PLACEABLE,sMytag,lMyloc);
|
|
if (bDebug) SendMessageToPC(oPC," -> Treasure chest: " + sMytag);
|
|
WriteTimestampedLogEntry("Treasure chest " + sMytag + " spawned at " + sPtag + " for " + GetName(oPC));
|
|
break;
|
|
}
|
|
}
|
|
|
|
oSpawn = GetNextObjectInArea(OBJECT_SELF);
|
|
}
|
|
|
|
// attach OnExit handler once
|
|
SetEventScript(OBJECT_SELF, EVENT_SCRIPT_AREA_ON_EXIT, "area_onexit");
|
|
if (bDebug) SendMessageToPC(oPC, "OnExit script linked: area_onexit");
|
|
WriteTimestampedLogEntry("OnExit script linked for " + sAreaTag);
|
|
}
|
|
|
|
|
|
/* void main()
|
|
{
|
|
object oPC = GetEnteringObject();
|
|
int iLevel = GetHitDice(oPC);
|
|
if (iLevel>20) iLevel=20;
|
|
string sLevel = IntToString(iLevel);
|
|
string sMytag;
|
|
int iType;
|
|
location lMyloc;
|
|
int iNum;
|
|
string sNum;
|
|
string sPtag;
|
|
int iSix;
|
|
string sSix;
|
|
if (GetIsPC(oPC) != TRUE) return;
|
|
|
|
if (!GetIsPC(oPC)) return;
|
|
|
|
string sAreaTag = GetTag(OBJECT_SELF);
|
|
|
|
// already done for this PC?
|
|
if (GetLocalInt(oPC, "DungeonSetup_" + sAreaTag) == 1)
|
|
return;
|
|
|
|
// check if another PC is in the area
|
|
object oCheck = GetFirstObjectInArea(OBJECT_SELF);
|
|
while (oCheck != OBJECT_INVALID)
|
|
{
|
|
if (GetIsPC(oCheck) && oCheck != oPC)
|
|
{
|
|
// someone else is already here -> skip
|
|
return;
|
|
}
|
|
oCheck = GetNextObjectInArea(OBJECT_SELF);
|
|
}
|
|
|
|
// mark this PC as having triggered setup here
|
|
SetLocalInt(oPC, "DungeonSetup_" + sAreaTag, 1);
|
|
|
|
object oSpawn = GetFirstObjectInArea(OBJECT_SELF);
|
|
//SendMessageToPC(oPC,"get first wp");
|
|
int iSpawn = GetLocalInt(oSpawn,"done");
|
|
int iKind = GetObjectType(oSpawn);
|
|
|
|
|
|
while (oSpawn != OBJECT_INVALID)
|
|
{
|
|
int iKind = GetObjectType(oSpawn);
|
|
if (iSpawn != 1 && iKind == OBJECT_TYPE_WAYPOINT)
|
|
{
|
|
string sWTF = GetTag(oSpawn);
|
|
//SendMessageToPC(oPC,"tag is "+sWTF);
|
|
SetLocalInt(oSpawn,"done",1);
|
|
//SendMessageToPC(oPC,"spawning stuff");
|
|
sMytag = GetTag(oSpawn)+sLevel;
|
|
sPtag = GetTag(oSpawn);
|
|
iType = StringToInt(GetStringLeft(sMytag,1));
|
|
lMyloc = GetLocation(oSpawn);
|
|
iNum = d10(1);
|
|
sNum = IntToString(Random(40)+1);
|
|
iSix = d6();
|
|
sSix = IntToString(iSix);
|
|
|
|
switch (iType)
|
|
{
|
|
case 1:
|
|
switch (iNum)
|
|
{
|
|
case 1:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
break;
|
|
|
|
case 2:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
break;
|
|
|
|
case 3:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"m",lMyloc);
|
|
break;
|
|
|
|
case 4:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
break;
|
|
|
|
case 5:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
break;
|
|
|
|
case 6:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
break;
|
|
|
|
case 7:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
break;
|
|
|
|
case 8:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
break;
|
|
|
|
case 9:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
break;
|
|
|
|
case 10:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"h_alt",lMyloc);
|
|
CreateObject(OBJECT_TYPE_CREATURE,sMytag+"b",lMyloc);
|
|
break;
|
|
}
|
|
//CreateObject(OBJECT_TYPE_CREATURE,sMytag,lMyloc);
|
|
break;
|
|
|
|
case 2:
|
|
CreateObject(OBJECT_TYPE_PLACEABLE,sPtag+sNum,lMyloc);//interactive placeables
|
|
break;
|
|
|
|
case 3:
|
|
CreateObject(OBJECT_TYPE_PLACEABLE,sPtag+sNum,lMyloc);//mundane placeables
|
|
break;
|
|
|
|
case 4:
|
|
CreateObject(OBJECT_TYPE_ITEM,sMytag+"_"+sSix,lMyloc);//loose items
|
|
break;
|
|
|
|
case 5:
|
|
CreateObject(OBJECT_TYPE_CREATURE,sPtag+sNum,lMyloc);//special encounters
|
|
break;
|
|
|
|
case 6:
|
|
CreateObject(OBJECT_TYPE_PLACEABLE,sMytag,lMyloc);//treasure chests
|
|
break;
|
|
}
|
|
}
|
|
|
|
oSpawn = GetNextObjectInArea(OBJECT_SELF);
|
|
iSpawn = GetLocalInt(oSpawn,"done");
|
|
//SendMessageToPC(oPC,"get next wp");
|
|
|
|
SetEventScript(OBJECT_SELF, EVENT_SCRIPT_AREA_ON_EXIT, "area_onexit");
|
|
}
|
|
} */ |