Author Topic: AOE powered "Gargoyles" to replace Bioware's heartbeat method  (Read 460 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0


               [This post was inspired by the thread titled, GetFirstObjectInShape versus GetNearestCreature]

[Oct 9 2012: I uploaded a leaner and meaner version of this for download to a BSN project of mine

In order to come up with a more efficient Gargoyle, I looked into replaceing a placeable's heartbeat event with an AOE's onEnter event. For those that do not know what I am talking about... consider the Gargoyle placeable that is scripted to turn into a Gargoyle creature when a PC gets too close, and transition back when the nearest PC is too distant.

The problem I have with this system is that it is heartbeat driven, and thus could be much more efficient. I really like using this method as it works well for undead, plants, and constructs - creatures that typically lie around in plain sight until a PC gets close enough to disturb them. And since I like using them, I'd like the ability to place many without worrying about all the resources they use up. The answer to this is to use AOE's.

AOE's are tricky however. My first implementation applied the AOE directly to the placeable when it was "spawned" via a NESS script. This didn't function. My next implementation applied the AOE to the location of the placeable when the placeable was spawned. The problem with this was two fold: (1) the AOE scripts did not run on the placeable and (2) when the placeable was destroyed, the AOE was not destroyed along with it. I solved this last pair of problems by using the SetLocalObject method  on the Area of Effect pointing to the placeable, as well as aon the placeable pointing to the AOE object. Each local object is named "PAIRED" which I have done similarly thorughout my scripts when paired pointers are called for.

SCRIPTS
  • spawn_sc_spawn (excerpt) - this is an excerpt from a NESS script which executes on spawn of the placeable
  • aa_plcspawn_ent - this is in the OnEnter of the AOE
  • aa_plcspawn - this is executed on the placeable, transforming it to a creature and called by other scripts including aa_plcspawn_ent
  • aa_ai_plc_hb - this is executed from the heartbeat event on the creature. I execute it from the creature's userdef script under the userdef heartbeat event.
  • placeable death event excerpt - this goes in the placeable's death event. It is garbage collection for the AOE when the placeable is destroyed.
OBJECTS
  • Placeable - the placeable can be any placeable object defined by you. It does however need a series of local objects. Please see aa_plcspawn for a list.
  • Monster - the monster created from the placeable. This should have at least two of the local variables defined SPAWN_PLACE and SPAWN_DISTANCE. These local variables in conjunction with the userdef heartbeat script enable the creature when placed by the DM to revert to a Placeable when a PC is not around.

               
               

               


                     Modifié par henesua, 09 octobre 2012 - 08:51 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #1 on: May 22, 2012, 08:02:28 am »


               

henesua wrote...

My first implementation applied the AOE directly to the placeable when it was "spawned" via a NESS script. This didn't function.


Did you figure out why this didn't work? Just curious. I really like this idea by the way.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #2 on: May 22, 2012, 11:04:41 am »


               Nice, I could add this into the community patch probably using the default stone placeable that spawn new one and aoe in its first HB - what you think.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #3 on: May 22, 2012, 03:17:34 pm »


               GOG:
I did not figure out the reason why, but I am fairly confident that it can't be done.

I tried using some standard AOE's from vfx_persistent.2da and those didn't work either. I was certain that Glyph of Warding was cast on an object, but when I looked at the script noticed that its AOE was also applied to a location. So at that point I gave up.

Essentially the AOE (at a location) is an object which has its own type and (3) event scripts. It is annoying to me that the function returns an effect rather than an object. But anyway... I am sure that I have more to learn about these things. This is one of the weird areas of the NWN engine that doesn't make any sense, and may have a few functions that enables one to get the AOE object without having to use a Find method to get it.

CreateAOEAtLocation similar to CreateTrapAtLocation would have been a very nice method to have at one's disposal.

ShaDoOoW:
I'm not sure this would work well in a community patch. It requires a great deal of local variables on an object to configure it, and several scripts. But if you want to include it, feel free. Make sure you go through those script and scrub them of SendMessageToPC... I have a feeling I never cleaned them of all my debug scripts. I am sloppy in my sharing that way. I discovered a few months ago that my death system posted to the vault wasn't working because it had some file name references that I only had in my Arnheim module. I am sloppy. Sorry. '<img'>

I do think it would be worthwhile to add some generic items to vfx_persistent.2da and create the AOE constants for them. That is what I did to make an invisible AOE configurable by script. Here they are posted to pastebin.
               
               

               


                     Modifié par henesua, 22 mai 2012 - 02:21 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #4 on: May 22, 2012, 11:27:13 pm »


               I noticed a potential issue with aa_plcspawn.

I tell the newly created monster to attack the "disturber" if they are enemies. I think it would be better to call DetermineCombatRound. What do you think?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #5 on: May 22, 2012, 11:43:59 pm »


               

henesua wrote...

I noticed a potential issue with aa_plcspawn.

I tell the newly created monster to attack the "disturber" if they are enemies. I think it would be better to call DetermineCombatRound. What do you think?

definitely, the AI might choose different tactic is the placeable would spawned a creature with any special abilities like aura or spell-like
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #6 on: May 22, 2012, 11:53:19 pm »


               Alright then. I'll add the include and switch the function.
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #7 on: May 24, 2012, 04:10:01 pm »


               There is a difference between mobile and immobile AOEs. It could be the case that immobile AOEs cannot be assigned to placeables, only locations. You might want to check that angle. I know mobile ones can be placed on creatures, so I assume they can also be placed on placeables. I forget tho.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #8 on: May 24, 2012, 05:01:20 pm »


               How do you distinguish between a mobile and immobile AOE?

I created some new rows in vfx_persistent.2da  and they are almost empty. I looked at the various columns to determine if there were other differences between AOE types but I couldn't discern anything.

[Edit]
Just thinking... perhaps it has something to do with applying it to a creature? I had not tried to do that. I only tried applying these AOEs to placeables.
               
               

               


                     Modifié par henesua, 24 mai 2012 - 04:02 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #9 on: October 09, 2012, 09:52:26 am »


               I uploaded this project (in an improved form) here for download.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #10 on: October 11, 2012, 12:14:20 pm »


               Updated with a second erf, "a replacing version", so that builders can replace standard gargoyles with AOE versions. All it requires is an import of the erf.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #11 on: October 13, 2012, 04:12:19 pm »


               I originally intended this project as a proof of concept that other developers could build off of. Then I received requests for a replacing package and so made that available for gargoyles.  However, I think it only goes 1/3 of the way towards the purpose of making an existing module more efficient. Would anyone be interested in a replacing package that works for Skeletons, Zombies, and Gargoyles? It would require more resources, but would cut down on CPU drain for those servers that actually put the placeables out by hand.

Secondarily:
For the core package, I don't like the sound in the dust explosion VFX for Gargoyles. I was considering adding a new visualeffects line that combines a different sound with with dust explosion visual. I think in Darkness over Daggerford they used the sound "as_cv_claybreak3", the deepest clay pot breaking sound. I am leaning toward "sff_stonehold". Would this be of any interest? A new line to put in your visualeffects.2da?

Lastly:
At first I thought my way of indicating VFX by local string was user friendly. But the more I think about it... its probably better just to convert this to a local int that represents the index in visualeffects.2da. Which is more useful to people?  The full string is human readable, but requires someone to edit the script to include new VFX. Using the integer value for the VFX is more efficient and extendable, but is not human readable (unless you memorized visualeffects.2da.
               
               

               


                     Modifié par henesua, 13 octobre 2012 - 03:12 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #12 on: October 14, 2012, 06:14:26 am »


               I just incorporated all of these things. VFX can be set by index or string, replacing version improves efficiency for placeable gargoyles skeletons and zombies. added the alt dust explosion visual effects as an option.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #13 on: October 14, 2012, 07:54:33 pm »


               <stirring...>

Is it generic enough morphing system to transform statues in beautiful women, er... people? =)

<...into action>
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AOE powered "Gargoyles" to replace Bioware's heartbeat method
« Reply #14 on: October 14, 2012, 08:32:22 pm »


               That reminds of that 80's movie "Weird Science".