Effect emiters without OnHeartbeat?

Moderator: Event DM

Post Reply
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Effect emiters without OnHeartbeat?

Post by Starslayer_D » Fri Oct 03, 2003 11:51 pm

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?
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
Posts: 14074
Joined: Sun Oct 20, 2002 10:59 pm
Timezone: CST
DM Avatar: The Hammer
Location: Texas

Post by Alexandru Stanicu » Fri Oct 03, 2003 11:54 pm

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
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
User avatar
marauder
Scholar
Posts: 1317
Joined: Sun Feb 23, 2003 3:36 am
Location: College Station, TX (GMT -6)
Contact:

Post by marauder » Sat Oct 04, 2003 12:54 am

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.
It is the mark of an educated mind to be able to entertain a thought without accepting it.

-Aristotle
User avatar
Mistcaller
Team Member; Retired with Honors
Posts: 5477
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

Post by Mistcaller » Sat Oct 04, 2003 1:46 am

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
User avatar
Neve
Prince of Bloated Discourse
Posts: 192
Joined: Mon Apr 14, 2003 4:09 pm
Location: The Netherlands
Contact:

Post by Neve » Sat Oct 04, 2003 6:39 am

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 !
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
Papillon
Team Member; Retired with Honors
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm
Contact:

Post by Papillon » Sat Oct 04, 2003 10:03 am

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.
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Post by Starslayer_D » Sun Oct 05, 2003 2:33 pm

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
Tchus
Squire of Babble
Posts: 36
Joined: Tue Jun 10, 2003 6:28 pm

Post by Tchus » Sun Oct 05, 2003 5:05 pm

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.
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Post by Starslayer_D » Sun Oct 05, 2003 6:46 pm

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...
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
Posts: 14074
Joined: Sun Oct 20, 2002 10:59 pm
Timezone: CST
DM Avatar: The Hammer
Location: Texas

Post by Alexandru Stanicu » Sun Oct 05, 2003 8:21 pm

Heatbeat scripts are EVIL!
They have been found to create lag.... nothing else needs be said.

-Alex
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
Tchus
Squire of Babble
Posts: 36
Joined: Tue Jun 10, 2003 6:28 pm

Post by Tchus » Sun Oct 05, 2003 9:24 pm

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)
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
Posts: 14074
Joined: Sun Oct 20, 2002 10:59 pm
Timezone: CST
DM Avatar: The Hammer
Location: Texas

Post by Alexandru Stanicu » Sun Oct 05, 2003 9:29 pm

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
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Post by Starslayer_D » Sun Oct 05, 2003 9:40 pm

I am currently going the way alex said: Trigger OnEnter.... is reuseable, too.
Tchus
Squire of Babble
Posts: 36
Joined: Tue Jun 10, 2003 6:28 pm

Post by Tchus » Sun Oct 05, 2003 9:52 pm

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.
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
Posts: 14074
Joined: Sun Oct 20, 2002 10:59 pm
Timezone: CST
DM Avatar: The Hammer
Location: Texas

Post by Alexandru Stanicu » Mon Oct 06, 2003 12:40 am

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
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Post by Starslayer_D » Mon Oct 06, 2003 8:50 am

How does one remove the effect if no one is around?
Papillon
Team Member; Retired with Honors
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm
Contact:

Post by Papillon » Mon Oct 06, 2003 9:46 am

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.
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
Posts: 14074
Joined: Sun Oct 20, 2002 10:59 pm
Timezone: CST
DM Avatar: The Hammer
Location: Texas

Post by Alexandru Stanicu » Mon Oct 06, 2003 8:02 pm

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
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by Aloro » Mon Oct 06, 2003 8:43 pm

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
Aleksandr Solzhenitsyn wrote:The meaning of earthly existence lies, not as we have grown used to thinking, in prosperity, but in the development of the soul.
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Post by Starslayer_D » Tue Oct 07, 2003 12:49 am

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 :)
User avatar
marauder
Scholar
Posts: 1317
Joined: Sun Feb 23, 2003 3:36 am
Location: College Station, TX (GMT -6)
Contact:

Post by marauder » Tue Oct 07, 2003 2:15 am

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.
It is the mark of an educated mind to be able to entertain a thought without accepting it.

-Aristotle
Papillon
Team Member; Retired with Honors
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm
Contact:

Post by Papillon » Tue Oct 07, 2003 8:47 am

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 :wink: .
Starslayer_D
Master Sage
Posts: 5178
Joined: Thu Oct 24, 2002 7:35 pm
Location: Germany (+1 GMT)
Contact:

Post by Starslayer_D » Mon Oct 20, 2003 6:38 pm

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?
Post Reply