62 lines
2.7 KiB
Plaintext
62 lines
2.7 KiB
Plaintext
#include "nw_i0_generic"
|
|
#include "nw_i0_tool"
|
|
void main()
|
|
{
|
|
int RADIUS = 5; // Number of tiles from the waypoint tagged "di_wp_center"
|
|
string CREATURE = "di_ghost_pirate"; // creature to spawn
|
|
object oPC = GetItemActivator();
|
|
|
|
|
|
if(GetIsPC(oPC) || GetIsDM(oPC))
|
|
{
|
|
if(GetArea(oPC) == GetArea(GetWaypointByTag("di_wp_center")))
|
|
{
|
|
if(!HasItem(oPC, "di_treasure_map6"))
|
|
{
|
|
SendMessageToPC(oPC, "You need the correct map in order for this compass to be of use.");
|
|
}
|
|
else
|
|
{
|
|
object oTarget = GetWaypointByTag("di_xspot");
|
|
if(oTarget == OBJECT_INVALID)
|
|
{
|
|
location lLoc1 = GetLocation(GetWaypointByTag("di_wp_center"));
|
|
float angle = Random(3600) / 10.0f;
|
|
// float fDistance = Random(RADIUS * 10) / 10.0f; // bugged version
|
|
float fDistance = Random(RADIUS * 100) / 10.0f; // Corrected version
|
|
location lLoc2 = GenerateNewLocationFromLocation(lLoc1, fDistance, angle, angle);
|
|
oTarget = CreateObject(OBJECT_TYPE_WAYPOINT, "NW_WAYPOINT001", lLoc2, FALSE, "di_xspot");
|
|
// CreateObject(OBJECT_TYPE_PLACEABLE, "plc_barrel", lLoc2);
|
|
}
|
|
|
|
if(oTarget != OBJECT_INVALID)
|
|
{
|
|
location lLoc1 = GetLocation(oPC);
|
|
location lLoc2 = GetLocation(oTarget);
|
|
float fDistance = GetDistanceBetweenLocations(lLoc1, lLoc2);
|
|
SendMessageToPC(oPC, "Current Distance is " + FloatToString(fDistance));
|
|
if(fDistance < 1.0)
|
|
{
|
|
DestroyObject(oTarget);
|
|
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_WAIL_O_BANSHEES), GetLocation(oPC));
|
|
CreateObject(OBJECT_TYPE_CREATURE, CREATURE, lLoc2);
|
|
//DestroyObject(OBJECT_SELF);
|
|
object oItemToTake;
|
|
oItemToTake = GetItemPossessedBy(oPC, "di_treasure_map6");
|
|
if(GetIsObjectValid(oItemToTake) != 0)
|
|
DestroyObject(oItemToTake);
|
|
oItemToTake = GetItemPossessedBy(oPC, "di_compas");
|
|
if(GetIsObjectValid(oItemToTake) != 0)
|
|
DestroyObject(oItemToTake);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SendMessageToPC(oPC, "The compass doesn't seem to be very effective at your current location.");
|
|
}
|
|
}
|
|
}
|