ACR creatures scripts: VFX?

Scripted ALFA systems & related tech discussions (ACR)

Moderators: ALFA Administrators, Staff - Technical

Locked
User avatar
AcadiusLost
Chosen of Forumamus, God of Forums
Posts: 5061
Joined: Tue Oct 19, 2004 8:38 am
Location: Montara, CA [GMT -8]
Contact:

ACR creatures scripts: VFX?

Post by AcadiusLost »

Cipher: I've had some reports of heavy and sudden lag in combat, roughly around the time the creatures first perceive the players (especially when there are multiple PCs on, and multiple creatures.)

In the creature OnPerception() event, I see this:

Code: Select all

  305 void ACR_CreatureOnPerception()
  306 {
  307     object oPerceived = GetLastPerceived();
  308 
  309     // apply any effects on the creature
  310     ACR_VFXOnPerception(oPerceived, OBJECT_SELF);
  311 
  312 	// still call the Obsidian script for AI for now.
  313 	ExecuteScript("nw_c2_default2", OBJECT_SELF);
  314 }
which calls this function in acr_vfx_i

Code: Select all

  446 void ACR_VFXOnPerception(object oPerceived, object oPerceiver)
  447 {
  448     // Load the effect strings
  449     string sVisualEffect = GetLocalString(oPerceiver, ON_PERCEPTION_EVENT + EFFECT_VISUAL);
  450     string sPhysicalEffect = GetLocalString(oPerceiver, ON_PERCEPTION_EVENT + EFFECT_PHYSICAL);
  451     string sDamageEffect = GetLocalString(oPerceiver, ON_PERCEPTION_EVENT + EFFECT_DAMAGE);
  452 
  453     // Apply the effects
  454     _applyVisualEffect(sVisualEffect, oPerceived, _applyDamage(sDamageEffect, sPhysicalEffect, oPerceived));
  455 }
So, at the moment of perception, each of the creatures is checking variables on each of the objects perceived, and trying to apply effects on all of them? I'm not sure what the intent was here- why should they be applying effects on everything they perceive?

There is also a similar check OnHeartbeat for creatures, to apply VFX to themselves- presumably that wouldn't need to be happening every heartbeat for every creature, would it?

I may be missing some of the intention of the VFX system here- hopefully you can clarify things somewhat. When I get a bit of time, I'll try some combat comparisons with and without the perception-based and heartbeat VFX to see if it's affecting performance.
User avatar
ç i p h é r
Retired
Posts: 2904
Joined: Fri Oct 21, 2005 4:12 pm
Location: US Central (GMT - 6)

Post by ç i p h é r »

The intent was/is to permit builders to incorporate dynamic effects on objects, including creatures. For instance, you can easily create statues of specific creatures as they spawn in this way and even cause them to take life once they perceive a player (like the Caryatid Columns of Undermountain). That's but one example. The imagination is probably the limit when mixing events with visual effects. It's not limited to visuals either. Real effects can be applied as well, whatever the game supports, with save DCs.

That said, we've got to be mindful of the cost, and that goes for any script in the game. Does the profiler offer any insights into this? We can add a system toggle so builders or even DMs can turn it on or off I suppose but the creature heartbeats and perceptions always run. The system doesn't do anything unless something is actually defined (ie it aborts in the absence of any local variables).

So we're talking about what...micro seconds to load the locals and perform a check? Unless it's not coded optimally, I don't think the system will be a source of lag while it's dormant. Conversely, it is very likely to be a source of lag if not used judiciously. Defining effects on many creatures that spawn at the same time, in combat situations, may not be very wise, for example.
Locked