Aller au contenu

Photo

Is There a Workaround For


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
Tarot Redhand

Tarot Redhand
  • Members
  • 2 675 messages

Placeables do not have the OnPerceived event. Is there a workaround for this? Ideally I would like to be able to detect whether the (1st) PC is visible/invisible as well. Or am I stuck with using a trigger?

 

Thanks in advance.

 

TR



#2
Shadooow

Shadooow
  • Members
  • 4 470 messages

i dont think so

 

trigger if this is a specific situation you can control

 

invis creature/AOE aura if trigger is not possible



#3
Tarot Redhand

Tarot Redhand
  • Members
  • 2 675 messages

Thanks. I have had a crazy idea for a creature and posted a question in the cc threads.

 

TR



#4
dunahan_schwerterkueste_de

dunahan_schwerterkueste_de
  • Members
  • 44 messages

What if you use a OnEnter/OnUserDefined/OnSpawn event, check for the placeable and call a faked heartbeat, that scans like any perception script?

I'll try such a thing tomorrow. It's too late for me now ;)



#5
dunahan_schwerterkueste_de

dunahan_schwerterkueste_de
  • Members
  • 44 messages

Okay, I scribbled something together, but it isn't exactly what I want. It simulates a perception-script with a fake heartbeat. I think it will help a bit to come around :)

 

I've got problems with my while-loop in the perception-func, so I changed the last return to TRUE instead my wanted FALSE.... If someone could show a better way to get around with this, it could be the way Tarot Redhand wanted to simulate?

 

A Include-file following:

Spoiler

 

 

And the OnEnter-Script:

Spoiler

 



#6
kalbaern

kalbaern
  • Members
  • 824 messages

I have a few placeables that mimic perception checks using a script fired from their OnHearbeat event. The HB script has a do once check and will abort after the first time it calls the actual pseudo heartbeat I use. The actual pseudo heartbeats then fire , make checks for distance, seen/unseen and other things and either cause something to happen or simply execute the pseudo to refire after a 2-3 second delay. I use this for my various statues that come to life, like guardians or gargoyles as well as trees that become treants, shrubby mounds that awaken as shamblers and various other things both nasty and benign. Since I also use a lot of placeables with heartbeats, I also spawn/despawn them so they only exist when PCs are in the area to limit the impact on the server's CPU. I'm also sneaky as well. Most of these placeables spawn in semi-randomly with a chance of being just a statue, tree, shrub, etc... or one of the wakening versions.


  • Tarot Redhand et dunahan_schwerterkueste_de aiment ceci

#7
Tarot Redhand

Tarot Redhand
  • Members
  • 2 675 messages

@kalbaern Would you care to share some code to illustrate that?

 

TR



#8
kalbaern

kalbaern
  • Members
  • 824 messages

Sure thing, might take a couple of days as I'm away from home right now.



#9
Tarot Redhand

Tarot Redhand
  • Members
  • 2 675 messages

No worries. I've still got to make the placeables that I plan on using this with anyway. <note to self containing words "butt", "off", "big", "your", "get" and "fat"  >

 

TR



#10
kalbaern

kalbaern
  • Members
  • 824 messages

Here it comes ... hope it helps. I've added comments and notes so you can hopefully use, abuse and tweak them easily.

////////////////////////////////////////////////////////////////
//Kalbaern's Generic Placeable "Do Something" script.
////////////////////////////////////////////////////////////////
//1) Set this as the OnHeartbeat event of your desired placeable.
//2) Set a local string on the placeable named SCRIPT with the
// name of the script you want fired. Generally this script is a
// psuedo-heartbeat which will keep re-firing until your desired
// effect is met.
////////////////////////////////////////////////////////////////

void main()
{
string sScript = GetLocalString(OBJECT_SELF,"SCRIPT");
if (GetLocalInt(OBJECT_SELF,"DoOnce")==1) return;
SetLocalInt(OBJECT_SELF,"DoOnce",1);
DelayCommand(1.0,ExecuteScript(sScript,OBJECT_SELF));
return;
}


////////////////////////////////////////////////////////////////
//Kalbaern's Generic Placeable "Turns into Something Else" script.
////////////////////////////////////////////////////////////////
//1) Set a local string on the placeable named SCRIPT with the
// name of this script.
//2) Set a local string on the placeable named RESREF with the
// resref of the creature you want this placeable to morph into.
//3) Set a local float named DISTANCE with the maximum distance from the
// placeable to the nearest PC before morphing. Example 10.0 is 10 meters.
////////////////////////////////////////////////////////////////
void CreateCreature(object oPC, object oPlaceable)
{
string sResRef = GetLocalString(oPlaceable, "RESREF");
object oCreature = CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oPlaceable));
DelayCommand(0.1, AssignCommand(oCreature, ActionAttack(oPC)));
}
int GetCanSeePC(object oObject = OBJECT_SELF)
{
if(GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN)))
{
return TRUE;
}
return FALSE;
}
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
object oTransformer = OBJECT_SELF;
string sScript = GetLocalString(OBJECT_SELF,"SCRIPT");
float fDistance = GetLocalFloat(OBJECT_SELF,"DISTANCE");
effect eLoop = GetFirstEffect(oPC);
int bInvis = FALSE;

while (GetIsEffectValid(eLoop))
{
if (GetEffectType(eLoop) == EFFECT_TYPE_INVISIBILITY)
bInvis = TRUE;
eLoop=GetNextEffect(oPC);
}
//Check distance to nearest PC
if (GetIsObjectValid(oPC) == TRUE && GetDistanceToObject(oPC) < fDistance)

//Optional: Check distance to nearest PC and is not invisible
//if (GetIsObjectValid(oPC) == TRUE && GetDistanceToObject(oPC) < fDistance && bInvis != TRUE)

//Optional: Check distance to nearest PC and is invisible
//if (GetIsObjectValid(oPC) == TRUE && GetDistanceToObject(oPC) < fDistance && bInvis == TRUE)

//Optional: Check distance to nearest PC and can be seen
//if (GetIsObjectValid(oPC) == TRUE && GetDistanceToObject(oPC) < fDistance && GetCanSeePC(OBJECT_SELF) == TRUE)

{
CreateCreature(oPC, oTransformer);
SetPlotFlag(oTransformer, FALSE);
DestroyObject(oTransformer);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SCREEN_SHAKE), oPC);
}
else
{
DelayCommand(2.0,ExecuteScript("sScript",OBJECT_SELF));
}
return;
}

 

 

 

 

Hope those are useful to for what you are doing.


  • Tarot Redhand, dunahan_schwerterkueste_de et YeoldeFog aiment ceci

#11
Tarot Redhand

Tarot Redhand
  • Members
  • 2 675 messages

Thanks for that. I've bookmarked this thread so that when I do get the placeables made (actually working on another little utility to automate something to do with them), I can find this.

 

TR