mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-09-28 14:13:01 -04:00
147 lines
3.2 KiB
Plaintext
147 lines
3.2 KiB
Plaintext
include library.utils;
|
|
include library.stealth;
|
|
include library.prose;
|
|
|
|
const java.text.NumberFormat floatFormat = new java.text.DecimalFormat("###");
|
|
|
|
messageHandler msgDecaySample()
|
|
{
|
|
stealth.cleanComponentFromContainer(self, getContainedBy(self));
|
|
|
|
setObjVar(self, stealth.BIO_PROBE_DECAYED, 1);
|
|
removeObjVar(self, stealth.BIO_PROBE_TRAP_TARGET);
|
|
|
|
obj_id player = utils.getContainingPlayer(self);
|
|
if(!isIdValid(player))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string targetName = getStringObjVar(self, stealth.BIO_PROBE_TARGET_NAME);
|
|
prose_package pp = prose.getPackage(new string_id("spam", "probe_decayed_target"));
|
|
pp = prose.setTT(pp, targetName);
|
|
sendSystemMessageProse(player, pp);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnDestroy()
|
|
{
|
|
stealth.cleanComponentFromContainer(self, getContainedBy(self));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
int free = getFirstFreeIndex(names);
|
|
if (free == -1)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
float effectiveness = getIntObjVar(self, stealth.DETECT_EFFECTIVENESS);
|
|
float thisProbeStorage = getFloatObjVar(self, stealth.BIO_PROBE_STORAGE_TIME);
|
|
|
|
names[free] = "sample_preserve";
|
|
if(hasObjVar(self, stealth.BIO_PROBE_SAMPLE_TIME))
|
|
{
|
|
int when = getIntObjVar(self, stealth.BIO_PROBE_SAMPLE_TIME);
|
|
int now = getGameTime();
|
|
float timespan = thisProbeStorage - (now - when);
|
|
if(timespan < 1)
|
|
{
|
|
attribs[free++] = "@spam:already_expired";
|
|
}
|
|
else
|
|
{
|
|
if(timespan < 60)
|
|
{
|
|
attribs[free++] = floatFormat.format(timespan) + " secs left";
|
|
}
|
|
else
|
|
{
|
|
attribs[free++] = floatFormat.format(timespan / 60) + " mins left";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
attribs[free++] = "" + floatFormat.format((thisProbeStorage / 60 )) + " minutes";
|
|
}
|
|
|
|
names[free] = "sample_target";
|
|
if(!hasObjVar(self, stealth.BIO_PROBE_TRAP_TARGET))
|
|
{
|
|
if(hasObjVar(self, stealth.BIO_PROBE_DECAYED))
|
|
{
|
|
attribs[free++] = "@spam:already_expired";
|
|
}
|
|
else
|
|
{
|
|
attribs[free++] = "Not Yet Sampled";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
attribs[free++] = "" + getStringObjVar(self, stealth.BIO_PROBE_TARGET_NAME);
|
|
}
|
|
|
|
|
|
utils.addClassRequirementAttributes(player, self, names, attribs, free, "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if(!utils.isNestedWithin(self, player))
|
|
{
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
if(!utils.testItemClassRequirements(player, self, true, ""))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(!utils.testItemLevelRequirements(player, self, true, ""))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
menu_info_data mid2 = mi.getMenuItemByType(menu_info_types.ITEM_USE);
|
|
if(mid2 != null )
|
|
{
|
|
mid2.setServerNotify(true);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if(item == menu_info_types.ITEM_USE)
|
|
{
|
|
if(!utils.isNestedWithin(self, player))
|
|
{
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
if(!utils.testItemClassRequirements(player, self, false, ""))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(!utils.testItemLevelRequirements(player, self, false, ""))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id target = getLookAtTarget(player);
|
|
if(stealth.canBioProbe(player, self, target))
|
|
{
|
|
stealth.bioProbe(player, self, target);
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
} |