Page 1 of 1
Effect emiters without OnHeartbeat?
Posted: Fri Oct 03, 2003 11:51 pm
by Starslayer_D
Two problems with effect emmiters
a)
Ok, I am using three effect emmitters with a OnHeartbeat script. Script does the following:
if (GetLocalInt(OBJECT_SELF,"LORD_EMITTER_ACTIVATED"))
return;
SetLocalInt(OBJECT_SELF,"LORD_EMITTER_ACTIVATED",TRUE);
string sTag = GetTag(OBJECT_SELF);
if (sTag == "lordo_em_dark")
{
effect eEff = EffectVisualEffect(VFX_DUR_DARKNESS);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEff, OBJECT_SELF);
}
// more lines with elseif for different effects
How can I call them up without using that OnHeartbeat script? The area is established, and entered by a normal transistion. Thus, I cannot simply write a teleportation script wich calls them up, as the area has three access points and I do not have the temple area in mikona from wich the area is accessed.
How can I do this?
b)
I have an area, wich I access with a script wich jumpes the character there. In that script, I have a line wich starts an effect emmitter:
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, EffectAreaOfEffect(AOE_PER_FOGMIND), GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_1")));
When I had this started by a onHeatbeat, the effect was fog only. Now the mindfog is there as spell, dazing people..

How do I make it visual effect only?
Posted: Fri Oct 03, 2003 11:54 pm
by Alexandru Stanicu
I have been told that you can use a trigger for this, and that it can be sut up so that the effect only runs while a player is in the area...
As far as the effect you need to use the visual effect for the spell...
-Alex
Posted: Sat Oct 04, 2003 12:54 am
by marauder
If it is an actual area you jump to (as in area transition) then you might be able to use the OnEnter event for the area. Worth a shot. I have had issues with the OnEnter event for a module, but I have never tried it for an area.
Posted: Sat Oct 04, 2003 1:46 am
by Mistcaller
Perhaps use the OnPerception event of an invisible NPC or something similiar with an invisible object.... but a generic trigger I think will be the most efficient
Posted: Sat Oct 04, 2003 6:39 am
by Neve
You could give him a custom "onSpawn" script which only adds the lines to give the effect to him. With the default script that would be something like :
Code: Select all
#include "x0_i0_anims"
#include "x0_i0_treasure"
void main(){
effect eEff = EffectVisualEffect(VFX_DUR_DARKNESS);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEff, OBJECT_SELF);
WalkWayPoints();
CTG_GenerateNPCTreasure(TREASURE_TYPE_MONSTER, OBJECT_SELF);
}
About the mindfog : AreaOfEffect gives a similiar effect as when someone would cast a spell on that location; The visual effects plus all other effects like daze etc would apply to that spot. Instead, you can use the EffectVisualEffect() function to just activate the visual effect on that place.
Code: Select all
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, EffectVisualEffect(AOE_PER_FOGMIND), GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_1")));
((I didn't test this, so I'm not sure wether the AOE_PER_FOGMIND would be the correct visualeffect, if it wouldn't work, try replacing it with SPELL_MIND_FOG))
Good luck !
Posted: Sat Oct 04, 2003 10:03 am
by Papillon
We generally do not accept scripts for player housing, except the standard scripts for sitting, autoclosing, and so on.
In the very slight chance that an exception is made to this rule, the scripts have to come from an expert coder and be optimized to the last few bits, have a proper naming scheme (i.e. all script names start with ply_ for player), and run by a team member prior to submitting the erf.
I strongely urge all players to ask the housing director before working on any scripts whatsoever.
Posted: Sun Oct 05, 2003 2:33 pm
by Starslayer_D
Ok, I managed teh first part without a hitch.
I have a script wich teleports the possesors of a key item into the secret temple, and turns on all the visual effects there without a heartbeat script.
void main()
{
if (GetItemPossessedBy(GetLastUsedBy(),"AngadarTempleMir")==OBJECT_INVALID)
{ }
else
{PlaySound("as_mg_telepout1");
// Ghosts placeable objects
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToA_largebench2"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToA_largebench3"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToA_largebench4"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToA_largebench5"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToA_largebench8"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToA_largebench9"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PaintingonEasel1"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PaintingonEasel2"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PaintingonEasel3"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_Bookcase3"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PottedPlant1"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PottedPlant2"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PottedPlant3"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PottedPlant4"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PillarStyle1_1"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_PillarStyle1_2"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_Couch_1"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_Couch_2"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_Couch_3"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_Couch_4"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_wizdesk_1"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_RugOriental1"));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag("ToAM_Urn"));
//Fog Emitters on
effect eEff = EffectAreaOfEffect(AOE_PER_FOGMIND,"lord_dummy","lord_dummy","lord_dummy");
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_1")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_2")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_3")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_4")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_5")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_6")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_7")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_8")));
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag("ToAM_lordo_em_fogm_9")));
effect eEff2 = EffectVisualEffect(VFX_DUR_SPELLTURNING);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEff2, GetObjectByTag("ToA_Mlordo_em_Sturn_1"));
//Teleportation
DelayCommand(1.0,AssignCommand(GetLastUsedBy(),ActionJumpToLocation(GetLocation(GetObjectByTag("NW_ToAMirror"))))); }
}
Now, next to do this by a trigger in an area to avoid the heartbeats in teh area where I can't controll access
Posted: Sun Oct 05, 2003 5:05 pm
by Tchus
Alternatively, make two separate objects. The first one with a heartbeat script that creates the second object at its current location, applies the visual effect to it, and destroys itself.
Posted: Sun Oct 05, 2003 6:46 pm
by Starslayer_D
Unfortunately, Heartbeat objects are the big anathemy for avlis servers. No, never use them at all...
Thus, they have to be avoided at all cost... specially in an area wich gets frepuently fairly often.. wich ruels out your destroys itself object...
Posted: Sun Oct 05, 2003 8:21 pm
by Alexandru Stanicu
Heatbeat scripts are EVIL!
They have been found to create lag.... nothing else needs be said.
-Alex
Posted: Sun Oct 05, 2003 9:24 pm
by Tchus
Yep, but it'll only run once...afaik, nonexistent objects don't run hb scripts. So, it shouldn't take up any more resources than any other script. You'll have to make two objects, but that shouldn't be a problem if you toy around with the tags so you can reuse the heartbeat script. (GetTag(OBJECT_SELF) then create the new object with that tag + "_2" or something)
Posted: Sun Oct 05, 2003 9:29 pm
by Alexandru Stanicu
why when you cna put it on a trigger? set the trigger up so that it cant be avoided and run it form the on_entered of the trigger.
-Alex
Posted: Sun Oct 05, 2003 9:40 pm
by Starslayer_D
I am currently going the way alex said: Trigger OnEnter.... is reuseable, too.
Posted: Sun Oct 05, 2003 9:52 pm
by Tchus
Just a thought in case theres ever a need to do something similar to this, but sometime a trigger wouldn't work. Also, it'll only fire once, instead of every time someone passes through- although thats really moot. Yep, trigger'd do.
Posted: Mon Oct 06, 2003 12:40 am
by Alexandru Stanicu
part of the script can reset the trigger and remove the effect when there have been no PC's in the area for X amount of time.
removing the effect when noone is around will also reduce the overhead.
-Alex
Posted: Mon Oct 06, 2003 8:50 am
by Starslayer_D
How does one remove the effect if no one is around?
Posted: Mon Oct 06, 2003 9:46 am
by Papillon
I don't think removing the effect would reduce CPU time. Once the effect has been created, I don't see how it would need CPU cycles - on the client yes, but on the server ? Don't think so.
Posted: Mon Oct 06, 2003 8:02 pm
by Alexandru Stanicu
Papillon wrote:I don't think removing the effect would reduce CPU time. Once the effect has been created, I don't see how it would need CPU cycles - on the client yes, but on the server ? Don't think so.
I stand corrected.
-Alex
Posted: Mon Oct 06, 2003 8:43 pm
by Aloro
Client CPU (and more importantly GCPU) cycles will only be taken up while the emitter is onscreen and active. I don't think there's any problem with setting up an emitter and just leaving it on.
But NO HEARTBEATS!
Star, that code could be a LOT shorter. One approach to shorten it would be to give all the emitting objects the same basic Tag, but serialize them by adding a number to the end. E.g. ToAEmitter1, ToAEmitter2, ToAEmitter3. Then replace that loooooong application bit with something like
Code: Select all
for (iCounter=1; iCounter<16, iCounter++)
{
sObjectTag = ?ToAEmitter? + IntToString(iCounter);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTagsObjectTag));
}
You should do the same thing with the fog, as the tags there are already serialized.
That's a LOT of emitters in one place. Have you tested this on a midlevel computer with a midlevel graphics card? I'm concerned some clients will slow to a crawl when they get to this area.
- Aloro
Posted: Tue Oct 07, 2003 12:49 am
by Starslayer_D
Is a pentium III 700 mhz with 32 MB asus graphic card mid level enough? I freeze every time I encounter spawning ghosts in the dwarven quarters, and my area with the emitters doesn't freeze me.
So it has been tested.
I will try the sequential emmitter thing... each object has a unique tag to make it turn on reliably.... but later some got taken out for better visual effect. Should renumber the benches there.
One can see that I had so far no experience with C++ but I am allways willing to learn

Posted: Tue Oct 07, 2003 2:15 am
by marauder
Instead of re-tagging everything he could also use the getFirstObjectInArea followed by getNextObject inArea to cycle through everything. That way unique tags can be used still, but you can use a loop.
Posted: Tue Oct 07, 2003 8:47 am
by Papillon
Marauder, you can do things like this in single player, but doing this in an Avlis script is a sure way to get your script rejected

.
Posted: Mon Oct 20, 2003 6:38 pm
by Starslayer_D
Ok, the newest version... lost shorter, thanks to competend help from SylvanPhoenix:
//created by Starslayer_D, September 2003
//Scripts tests if person posseses key item, plays a sound
// applies visual effects, teleports user
//
void main()
{
if (GetItemPossessedBy(GetLastUsedBy(),"AngadarTempleMir")!=OBJECT_INVALID){
PlaySound("as_mg_telepout1");
string sObjectTag = "";
int iCounter = 0;
int jCounter = 0;
// Ghosts placeable objects
for (iCounter=1; iCounter<25; iCounter++)
{
sObjectTag = "ToAEmitter" + IntToString(iCounter);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), GetObjectByTag(sObjectTag));
}
//Fog Emitters on
effect eEff = EffectAreaOfEffect(AOE_PER_FOGMIND,"lord_dummy","lord_dummy","lord_dummy");
for (jCounter=1; jCounter<9; jCounter++)
{
sObjectTag = "ToAM_lordo_em_fogm_" + IntToString(jCounter);
ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, eEff, GetLocation(GetObjectByTag(sObjectTag)));
}
effect eEff2 = EffectVisualEffect(VFX_DUR_SPELLTURNING);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEff2, GetObjectByTag("ToA_Mlordo_em_Sturn_1"));
//Teleportation
DelayCommand(1.0,AssignCommand(GetLastUsedBy(),ActionJumpToLocation(GetLocation(GetObjectByTag("NW_ToAMirror")))));
}
}
Is this an avlis-acceptable script?