There have been requests on the board for a weapon like Sting from the Hobbit. That is, if a certain enemy is the vicinity, then the sword should glow. However, I have failed to figure out how to apply spell effects to swords, so I wrote a script that makes the wielder glow instead. Close enough, perhaps.

Currently, if a PC (though my script should be general enough for NPCs as well; haven't tested that) is wielding the sword with the appropriate tag ("CAL_SWORD") in either hand, then when the PC is rather close to an object of the appropriate tag ("CAL_COW"), the PC will start pulsating between white and red. This is the paralyzed visual effect, which is cool, and has the bonus that the PC should know whether he is paralyzed or it's actually the sword's effect. Since this is an OnHeartbeat script, you sometimes have to wait a bit for the glowing to start and to stop. However, since in most applications of this script, the distances to check will probably be beyond perception range, that delay shouldn't be a problem. I have declared at the beginning of the script all the variables that users of the script will want to modify to fit their modules.

1. Script Name: cal_glow
2. What It Does: Wielder of a weapon glows when a certain object is near
3. Notes: Call this script OnHeartbeat, and make sure you have a weapon and an object with tags matching those in the script. Then play around with the glowing.
4. The Script Itself:




//Script: cal_glow
//Author: Albert Shih (Calidarien)
//Version: v0.9, 2002-06-27
//Description: When a creature wields a item with a certain tag in its hands,
// it will "glow" when near an object of a specific tag.
//Usage: Attach to OnHeartbeat
//Notes:
// v0.9: Pretty cool
//
string ITEM_GLOW_TAG = "CAL_SWORD"; //Item that will cause glowing
string TRIGGER_GLOW_TAG = "CAL_COW"; //Thing to look for
float PROXIMITY_DISTANCE = 4.; //Distance to check within
int VFX_EFFECT = VFX_DUR_PARALYZED; //Which VFX to use
int CAL_DEBUG = FALSE; //Useful debugging messages
//
//Sends a message to all connected people if CAL_DEBUG == TRUE
void Alert(string szMessage) {
if(CAL_DEBUG) {
object oPC = GetFirstPC();
SendMessageToAllDMs(szMessage);
while(GetIsObjectValid(oPC)) {
SendMessageToPC(oPC, szMessage);
oPC = GetNextPC();
}
}
}
//
//Checks whether any objects with tag sTag are within fDist of oCenter
int Proximity(object oCenter, string sTag, float fDist) {
int nCounter = 0;
object oThing;
Alert("Proximity(): Checking proximity");
while(GetIsObjectValid(oThing = GetNearestObjectByTag(sTag, oCenter, ++nCounter))) {
if((GetArea(oCenter) == GetArea(oThing)) && ((GetDistanceBetween(oCenter, oThing)) < fDist)) {
Alert("Proximity(): Found one thing with tag " + sTag + " in distance " + FloatToString(fDist));
return TRUE;
}
}
Alert("Proximity(): Found " + IntToString(nCounter-1) + " things with tag " + sTag + " outside of distance " + FloatToString(fDist));
return FALSE;
}
//
//"Glowing" function, checks for inventory conditions (in this case, in hands)
void Glow(object oItem) {
object oOwner = GetItemPossessor(oItem);
Alert("Glow(): Item is being carried");
if((GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oOwner) == oItem) ||
(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oOwner) == oItem)) {
if(Proximity(oOwner, TRIGGER_GLOW_TAG, PROXIMITY_DISTANCE)) {
Alert("Glow(): Starting/continuing glow");
effect eVis = EffectVisualEffect(VFX_EFFECT);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oOwner, 7.);
}
}
}
//
//Search for through all instances of sTag and run Glow() on only those which
//are currently in a creature's inventory
void SearchAndGlow(string sTag) {
int nCounter = -1;
object oOwner, oItem;
while(GetIsObjectValid(oItem = GetObjectByTag(sTag, ++nCounter))) {
oOwner = GetItemPossessor(oItem);
if(GetIsObjectValid(oOwner)) {
Glow(oItem);
}
}
Alert("SearchAndGlow(): Found " + IntToString(nCounter) + " item(s) with tag " + sTag);
}
//
//Main function
void main()
{
SearchAndGlow(ITEM_GLOW_TAG);
}