Author Topic: MIDDLEWATER – Scripting Questions  (Read 444 times)

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« on: January 09, 2016, 06:59:03 pm »


               

So I’m working on a bunch of stuff that may or may not have been done before in some form.  Rather than spam this forum I’ll leave any questions in this thread.  All advice and support welcome.


 


Please bear in mind that my scripting knowledge is limited and I’m doing all the other work on my mod, but I’m willing to learn as time allows.  I have a mate who is a professional coder but his time is limited and he’s currently unfamiliar with NWscript… he’s agreed to tidy up (or rewrite) stuff but I have to come up with the full spec and some sample code first.


 


Question (and outcome)


 


#2 Quivers & Loose Arrows (in work)


#3 Respawn/Death System (in work)


#4 Fortification AC Bonuses (in work)



               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #1 on: January 09, 2016, 06:59:49 pm »


               

Quivers & Loose Arrows


 


I’m trying to set up VFX Quivers in my mod and decide how to implement the effects.


 


I'm making quivers as separate objects, to gain or lose the visual effect you toggle their unique power.  I thought this was better than OnAcquire/OnEquip for a number of reasons: the PC may be carrying more than one, I want to register the quiver's weight and it also allows me to apply some additional benefit from a well-made or magical quiver.  They will also look cool in the inventory once I've made the icons.  The Quiver VFX will be removed onunaquire if the character forgets to turn it off.


 


The arrows-in-quiver visual effect is only applied if the quiver VFX is running and you then put arrows in the equipment slot. When unequiped (or expended) the arrow VFX is removed.


 


This made me think about what to do if the character has no quiver but has picked up some loose arrows. This is very likely in my mod as capture/kidnapping/losing your stuff is commonplace and I'm also using an ammo preservation script that has a chance of putting missiles in the inventory of the target or on the ground depending on the ammo's durability.


 


My main question therefore would be how to disadvantage a character who has arrows, but no quiver. I want to nerf their number of attacks with a bow - as they fiddle with arrows tucked in a belt, carried in the off-hand, clenched between butt cheeks etc. - but not actually slow their other movement.  Is this even possible?



               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #2 on: January 09, 2016, 07:35:09 pm »


               

Respawn/Death System


 


The following is a basic description of the respawn mechanic in my game world.  I’m looking for the closest approximation in terms of existing scripting to modify this for my purposes, plus any advice on how to implement missing elements.


 


The first opportunity that players have to survive an unfortunate event is the bleeding system.  Characters can never be killed outright by a single blow, rather they stop losing health at zero HPs, fall unconscious and start to bleed at a rate of 1 HP/round.  Death happens at negative CON.  Every round there is a small chance that you will stabilise anyway, in which case you will start to recover HPs at the rate of one per five (game) minutes. 


 


While unconscious anyone can stop the bleeding with certain magic while still in combat, or bandage you with a single application of a heal kit once out of combat.  The AI will usually ignore unconscious enemies if there are still others to fight so when a PC goes down you have a choice… either subdue the remaining enemies quickly or try and lead them away so one party member not in combat can bandage the incapacitated character.  


 


If the party is completely wiped out monsters and beasts will invariably just finish them off, whereas intelligent enemies may elect to take them captive.


 


At the point of death the soul is temporarily housed in the PC’s medicine bundle wherever that may be.  This is a tactical choice.  Players may elect to take the bundle with them, to hide it nearby (persistently stored in a buried location) or even leave it back at the medicine lodge.  In any case if the bundle is destroyed the spirit will return to the medicine lodge.  If stolen, nothing can be done until the medicine bundle is recovered and enemies may choose to do other unpleasant things with your spirit.


 


To be raised, the player needs a healthy host body.  To minimise penalties this should ideally be their original repaired body.  If the body has been destroyed then this is obviously not an option.  If it has not been mutilated at all then it simply needs to be healed back up to 1HP or more.  If mutilated (and there is a whole system for this in Middlewater... I'm using an expansion of THIS) the dismembered parts need to be gathered and a spell used to make them whole again (the ‘scalp’ is not required but its absence will be a matter of great shame and ongoing anxiety).


 


The body must be in the vicinity of the spirit – whether it be in the bundle or the lodge – when the medicine man casts the resurrection magic.  When raised in this fashion the PC loses all but one point of the experience in their current level and a single point of STR, CON or DEX.  There are items in the game that can permanently raise stats so the decline is not necessarily irreversible, although obviously if you die often it will quickly become so.


 


If the original body is destroyed, the spirit may try and possess the body of a captive taken to the Medicine Lodge.  If successful one gains the physical characteristics of the new living host (STR, DEX & CON) while retaining the intellectual stats (INT, WIS & CHR) and most of the skills and experience of the original character.  Some experience is lost (enough to put you midway through the preceding level) whereas a point of WIS, INT or CHR is permanently lost. 


 


The dynamic of this should be obvious.  A warrior or scout who is dependent on physical stats will probably wish to switch bodies after a number of deaths since the loss of intellectual stats is less of a concern.  Conversely a medicine man or sorcerer will wish to retain their original form as long as possible – and so have to put up with a weakened body – to avoid loss of intellectual stats.



               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #3 on: January 09, 2016, 08:17:57 pm »


               

Fortification AC Bonuses


So the village(s) that form the centre of my game world have a particular defensive work described thus:

…a stockade or picket of tall timbers (typically a foot in diameter and some eighteen feet tall) spaced with gaps sufficient to shoot through, yet too narrow to squeeze between. Behind the picket - on the inside - there is a ditch some three or four feet in depth in which the defenders stand to shield all but their upper body whilst they shoot arrows.


So the challenge here is to provide an AC bonus and maybe also percentage elemental damage resistences that are directional. Obviously it is applied when they enter the ditch (covered by a trigger polygon) but it must also take into account where the attacker is relative to the defender.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #4 on: January 09, 2016, 09:08:15 pm »


               

1. Quivers and loose arrows:


 


Decreasing the number of attacks can be done by SetBaseAttackBonus(), which actually sets the APR, instead of the BAB.  This will not reduce bonus attacks, such as those granted from rapid shot.


 


2. Respawn system


This one looks complex.  You might want to try permanent, uncancelable polymorphs for the different bodies and throw an ability decrease onto their skin (for the intelligence/wisdom/charisma lost).  The largest problem with polymorphs is equipment restraints.  Any item you wish for the polymorph to use must be merged into their form.  Nevertheless, polymorphing is the only source of statistic overriding, short of using a plug-in like NWNX.


 


3. Fortification AC


There is no AC vs. direction in the game, however, on-hit abilities can be made to be more powerful by a script check for the direction.  That is the AB vs. AC portion of the combat is hard-coded, but scripts can be employed once the hits are resolved.  If this is a ranged vs. melee comparison, you could provide a concealment effect versus ranged, to leave the defenders more vulnerable to melee.



               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #5 on: January 09, 2016, 09:28:54 pm »


               

Thanks WhiZard that's all fabulous.


 


Regarding the possession stuff I should probably mention that mine is a closed DMed campaign (probably half as many DMs as there are players)... so some of the issues regarding this can involve a player log and LETO fiddling.  The main thing is making it look seamless to the player.  Essencially if they take a new body all that happens is a physcial appearance change, some permanent stat changes and the experience loss.  The bits that can be automated before they log are a bonus.


 


Is there maybe a method of reporting the necessary changes to expedite what the DM would need to do in LETO?



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #6 on: January 09, 2016, 09:49:11 pm »


               

Have you looked at the Amethyst Dragon's VFX Quivers & Arrows?


 


TR



               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #7 on: January 09, 2016, 09:59:13 pm »


               



Yes... subject of post #2


 


It does not include the scripts to apply the effects and I wish to do it in a particular way.  Also led to an additional question given that I'm separating arrows from the quivers.


               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #8 on: January 09, 2016, 10:55:49 pm »


               


1. Quivers and loose arrows:


 


Decreasing the number of attacks can be done by SetBaseAttackBonus(), which actually sets the APR, instead of the BAB.  This will not reduce bonus attacks, such as those granted from rapid shot.




So how best to apply this. Maybe on equipping a bow you get the default penalty, only removed once you have a quiver or if one has already been 'equiped'? Remember nothing is actually being equiped... it's an inventory item that toggles the VFX quiver on and of with a unique power.



               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #9 on: January 09, 2016, 11:25:01 pm »


               


3. Fortification AC


There is no AC vs. direction in the game, however, on-hit abilities can be made to be more powerful by a script check for the direction.  That is the AB vs. AC portion of the combat is hard-coded, but scripts can be employed once the hits are resolved.  If this is a ranged vs. melee comparison, you could provide a concealment effect versus ranged, to leave the defenders more vulnerable to melee.




 


Interesting. By hit events I assume you mean OnDamaged... is damage applied before the contents of the OnDamaged event are resolved? Or are we talking yo-yo health bars and trying to undo death after the event to apply the results we actually wanted?



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #10 on: January 09, 2016, 11:39:45 pm »


               


So how best to apply this. Maybe on equipping a bow you get the default penalty, only removed once you have a quiver or if one has already been 'equiped'? Remember nothing is actually being equiped... it's an inventory item that toggles the VFX quiver on and of with a unique power.




 


SetBaseAttackBonus() is used for the penalty on equipping the bow and when toggling off the quiver through the unique power.  RestoreBaseAttackBonus() is used for removing the penalty, both on unequipping the bow and toggling on the quiver with the unique power.


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #11 on: January 09, 2016, 11:42:47 pm »


               


Interesting. By hit events I assume you mean OnDamaged... is damage applied before the contents of the OnDamaged event are resolved? Or are we talking yo-yo health bars and trying to undo death after the event to apply the results we actually wanted?




 


 


I think you get the idea.  You can always add more damage but removing it gets tricky.


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #12 on: January 12, 2016, 12:48:20 pm »


               

Just my own 2 cents 


If you are using vanilla, then yes the above options are likely the best choices.


 


If you are using, or have access to nwnx


Then damage becomes more fluid and easier to control by handling/hooking the EffectHandler_OnDamageApplied 


 


Eg: You get access to 'real' onDamage events that can let you modify the actual effect from where the damage comes.


Eg: Changing the Owner of the effect, changing the damage type, power, and individual damage numbers associated with the damage.


This event/hook would replace armor / damage calculations - So I think it gives you the ability to disregard immunities afforded by armor etc


Eg: 100% acid immunity? So what.... have 1000 acid damage in your face....


 


This would be good for adding damage mitigation based on direction - Eg: Attacking from behind = Double Damage, Flanking = 1.5x damage, front = 0.75x damage


However I don't think it would be good for simulating a miss or a dodge..


Because when the damage effect is applied, it has basically impacted with the victim.


At most you could set the damage to 0 to not damage the victim. (but then it looks weird- big impact sound, no damage)


               
               

               
            

Legacy_DM Frayne

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #13 on: January 12, 2016, 07:08:01 pm »


               

I’d seen NWNX in passing but have not had the opportunity to really look at it yet.  It does sound like a potential solution to many of the compromises I would otherwise need to make.  The one general question I would have about it is whether it is a pig to add at a later date if you have already been working on a mod for some time?


 


At the moment I’m ploughing through Syrus Greycloak’s Grimoire to see what stuff I can use or adapt.  I've used it before but integrating it this time will be a laborious business. The good news is Syrus has pretty much already done what I needed for curative magic... I just need to tweak a few things and duplicate some spells to make lesser/greater versions.  Hurrah!



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
MIDDLEWATER – Scripting Questions
« Reply #14 on: January 12, 2016, 10:12:44 pm »


               Good thing about nwnx is that it is additive, not suplimentive.

It extends without removing- so you shouldn't lose existing functionality if you implement later.