Author Topic: Is There a Workaround For  (Read 419 times)

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Is There a Workaround For
« on: December 24, 2015, 11:30:30 am »


               

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



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Is There a Workaround For
« Reply #1 on: December 24, 2015, 12:12:39 pm »


               

i dont think so


 


trigger if this is a specific situation you can control


 


invis creature/AOE aura if trigger is not possible



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Is There a Workaround For
« Reply #2 on: December 24, 2015, 05:16:31 pm »


               

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


 


TR



               
               

               
            

Legacy_dunahan_schwerterkueste_de

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Is There a Workaround For
« Reply #3 on: December 27, 2015, 08:48:17 pm »


               

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 '<img'>



               
               

               
            

Legacy_dunahan_schwerterkueste_de

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Is There a Workaround For
« Reply #4 on: December 28, 2015, 07:47:54 pm »


               

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 '<img'>


 


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
   


 



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Is There a Workaround For
« Reply #5 on: December 29, 2015, 12:02:50 am »


               

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.



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Is There a Workaround For
« Reply #6 on: December 29, 2015, 12:34:59 am »


               

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


 


TR



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Is There a Workaround For
« Reply #7 on: December 29, 2015, 01:14:52 am »


               

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



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Is There a Workaround For
« Reply #8 on: December 29, 2015, 10:21:27 am »


               

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



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Is There a Workaround For
« Reply #9 on: January 01, 2016, 04:19:11 pm »


               

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.



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Is There a Workaround For
« Reply #10 on: January 03, 2016, 02:58:01 am »


               

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