Okay, so basic question: Can you make it so that, under certain circumstances, players can target other perty members/companions for attacks? That's the basic question; here's the reason: yesterday I made a *.sef file that has a stirge attach to a creature to do the "Attach" thing ( http://www.d20srd.or...ters/stirge.htm ). The only problem is that when attached, the stirge cannot be targeted... for the victim I'm okay with it (I have a Grapple script that allows grapple checks, so it runs that every 6 seconds, and ends the effect/unhides the stirge when applicable). Works fine, looks pretty good, the unattach could be better but I'm okay with the results. The problem is there currently is no way to break the grapple other than the grapple check; I was thinking of doing something where if the character takes damage, half goes to the stirge and the grapple is broken... how does one go about doing that? I assume it would be in the ondamage script (and one of the module scripts to handle the player's damage) but how do I allow the player/companion to be targeted by companions/players? Or am I stuck with you just running around with a stirge on your back for 6 seconds?
Conditional PvP Settings...
Débuté par
Darin
, juin 17 2013 12:53
#1
Posté 17 juin 2013 - 12:53
#2
Posté 17 juin 2013 - 10:53
You could remove the afflicted target from the party and set them to a neutral faction (via a custom faction and a 'faction pig'). You could add them back to the party once they're no longer being snacked on (that will automatically set their faction back to 'PC'). Neutral faction creatures can be attacked physically (and won't react), but you couldn't cast hostile spells at them though.
There is an effect type available in the game (EffectShareDamage) that will share a specified percentage of damage with another creature. If the stirge is script-hidden while the VFX is attached to the target, then you could allow it to run it's AI (actually it's heartbeat script) while it is hidden. The stirge's HB script could check how much damage the script-hidden creature has taken (courtesy of EffectShareDamage), and detatch when either dead or when hit points drop below a certain threshold (remove the VFX from the target, unhide the creature, and add the target back to the party).
There is an effect type available in the game (EffectShareDamage) that will share a specified percentage of damage with another creature. If the stirge is script-hidden while the VFX is attached to the target, then you could allow it to run it's AI (actually it's heartbeat script) while it is hidden. The stirge's HB script could check how much damage the script-hidden creature has taken (courtesy of EffectShareDamage), and detatch when either dead or when hit points drop below a certain threshold (remove the VFX from the target, unhide the creature, and add the target back to the party).
#3
Posté 18 juin 2013 - 01:00
That would work for companions, but not for the PC (I'm fairly certain the Player is always Faction Player, but I could be wrong... and switching everyone else's faction means you couldn't control them to attack you to get the batsquito off of you...
...EffectShareDamage was likely the plan, with the effect removal function attached.
...EffectShareDamage was likely the plan, with the effect removal function attached.
#4
Posté 18 juin 2013 - 11:19
You could always incapacitate party members while they were being fed upon, so it wouldn't matter whether they're in the party or not. Some sort of stun or paralysis effect perhaps. For the PC you could skip the part where they're removed temporarily from the party and just incapacitate them.
There's no way your remaining party members could attack the PC though. Not without removing them all from the party and making them hostile, which would mean if you died the game would end (as you would have no other party members still alive).
You could always change the knockdown feat to be able to target allies - and hope at least one party member other than the PC has it. You'd then have to be able to check whether the PC or a party member has actually been targetted successfully by the feat though. If knockdown runs a spell script like some feats (and isn't hardcoded) then it would be possible to build that check into a modified version of the script itself.
There's no way your remaining party members could attack the PC though. Not without removing them all from the party and making them hostile, which would mean if you died the game would end (as you would have no other party members still alive).
You could always change the knockdown feat to be able to target allies - and hope at least one party member other than the PC has it. You'd then have to be able to check whether the PC or a party member has actually been targetted successfully by the feat though. If knockdown runs a spell script like some feats (and isn't hardcoded) then it would be possible to build that check into a modified version of the script itself.
Modifié par DannJ, 18 juin 2013 - 11:33 .
#5
Posté 19 juin 2013 - 12:58
Well, I do plan on giving everyone Knockdown, Disarm, and Feint on spawn (the last two only if they can use non-creature weapons, which implies hands) since, well, these "feats" are not feats in P&P (the improved are). So I could look into that, would likely have to SendMessageToPC(oPC,"You're being drained by a Stirge! Allies can free you by using Knockdown") or some such...
#6
Posté 19 juin 2013 - 01:00
...nope; hardcoded in NWN, so likely same in NWN2.
#7
Posté 19 juin 2013 - 11:05
Whenever you want to change something, that's usually the case!
One way to get companions to attack the PC might be a dominate effect. The PC would then attack the companions as well though - unless you did something to incapacitate them (stun, paralyze, etc). Blinding them should also prevent them initiating combat.
Another approach might be to not script-hide the stirge, but to apply a total invisibility effect to it, blind it to prevent it attacking anything else, and forcing it to follow the target it's feeding on as closely as possible (you can do this via its heartbeat script and a local object stored on the stirge). That way the stirge's red 'hostile' circle would still be visible close to the player, allowing companions to attack the invisibile stirge. The shared damage could be reversed, so damage to the stirge was shared with the victim it's feeding on (rather than targetting the player and sharing the damage with the stirge).
If you successfully detatch the stirge the VFX could be removed from the player, and the complete invisibility effect, blindness effect, and local object could all be removed from the stirge.
One way to get companions to attack the PC might be a dominate effect. The PC would then attack the companions as well though - unless you did something to incapacitate them (stun, paralyze, etc). Blinding them should also prevent them initiating combat.
Another approach might be to not script-hide the stirge, but to apply a total invisibility effect to it, blind it to prevent it attacking anything else, and forcing it to follow the target it's feeding on as closely as possible (you can do this via its heartbeat script and a local object stored on the stirge). That way the stirge's red 'hostile' circle would still be visible close to the player, allowing companions to attack the invisibile stirge. The shared damage could be reversed, so damage to the stirge was shared with the victim it's feeding on (rather than targetting the player and sharing the damage with the stirge).
If you successfully detatch the stirge the VFX could be removed from the player, and the complete invisibility effect, blindness effect, and local object could all be removed from the stirge.
Modifié par DannJ, 19 juin 2013 - 11:22 .
#8
Posté 20 juin 2013 - 02:14
...that could work...i'll look into it and get back to you
#10
Posté 20 juin 2013 - 06:44
Here it is...
First, the on hit code for the stirge bite...(can't get it to not do a point of damage though):
And, here we have the ondamage script (also ondeath, but that may have been uneeded)
With 2 variables on the creature; nStirge = 1 and sWP = (some waypoint tag)
First, the on hit code for the stirge bite...(can't get it to not do a point of damage though):
// i_drl_stirge_bite_hc
/*
If a stirge hits with a touch attack, it uses its eight pincers to latch onto
the opponent’s body. An attached stirge is effectively grappling its prey. The
stirge loses its Dexterity bonus to AC and has an AC of 12, but holds on with
great tenacity. Stirges have a +12 racial bonus on grapple checks (already figured
into the Base Attack/Grapple entry above).
An attached stirge can be struck with a weapon or grappled itself. To remove an
attached stirge through grappling, the opponent must achieve a pin against the stirge.
A stirge drains blood, dealing 1d4 points of Constitution damage in any round when
it begins its turn attached to a victim. Once it has dealt 4 points of Constitution
damage, it detaches and flies off to digest the meal. If its victim dies before the
stirge’s appetite has been sated, the stirge detaches and seeks a new target.
*/
// Darin LaSota on June 16th, 2013
#include "drl_include"
#include "ginc_actions"
void AttachCheck(object oPC, object oStirge, effect eVis, effect eViss)
{
int nDmg = 0;
if(GetLocalInt(oStirge,"nMyTurn"))
{
nDmg = d4(1);
effect eConDmg = EffectAbilityDecrease(ABILITY_CONSTITUTION,nDmg);
effect eDmgC = SupernaturalEffect(eConDmg);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eDmgC,oPC);
SetLocalInt(oStirge,"nMyTurn",1);
}
else
SetLocalInt(oStirge,"nMyTurn",1);
if(GetIsDead(oPC,FALSE) || GrappleCheck(oPC,oStirge,12))
{
RemoveEffect(oPC,eVis);
RemoveEffect(oStirge,eViss);
SetLocalInt(oPC,"nStirge",0);
SetLocalObject(oStirge,"oPC",OBJECT_INVALID);
}
else
{
int nDrain = GetLocalInt(oStirge,"nDrain");
if(nDrain+nDmg>=4)
{
SendMessageToPC(oPC,"Is this the issue?");
RemoveEffect(oPC,eVis);
RemoveEffect(oStirge,eViss);
SetLocalObject(oStirge,"oPC",OBJECT_INVALID);
SetLocalInt(oPC,"nStirge",0);
AssignCommand(oStirge,ClearAllActions(TRUE));
AssignCommand(oStirge,ActionForceExit(GetLocalString(oStirge,"sWP"),TRUE));
}
else
{
SetLocalInt(oStirge,"nDrain",nDrain+nDmg);
DelayCommand(3.0,AttachCheck(oPC,oStirge,eVis,eViss));
AssignCommand(oStirge,ActionForceFollowObject(oPC));
//DelayCommand(5.5,AssignCommand(oStirge,ActionJumpToObject(oPC)));
}
}
}
void Follow(object oPC, object oStirge, effect eViss)
{
if(GetIsEffectValid(eViss))
{
AssignCommand(oStirge,ClearAllActions(FALSE));
AssignCommand(oStirge,ActionForceFollowObject(oPC));
DelayCommand(0.5,Follow(oPC,oStirge,eViss));
}
}
void main()
{
object oItem = GetSpellCastItem(); // The item casting that triggered this spellscript
object oStirge = GetItemPossessor(oItem);
object oPC = GetAttackTarget(oStirge);
if(!GetLocalInt(oPC,"nStirge"))
{
//SetScriptHidden(oStirge,TRUE,FALSE);
effect eVis1 = EffectNWN2SpecialEffectFile("total_invisibility.SEF");
effect eShare = EffectShareDamage(oPC,50,50);
effect eViss = EffectLinkEffects(eVis1,eShare);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eViss,oStirge);
AssignCommand(oStirge,ClearAllActions(FALSE));
AssignCommand(oStirge,ActionForceFollowObject(oPC));
effect eVis = EffectNWN2SpecialEffectFile("stirge_attach_back.SEF");
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,oPC);
SetLocalObject(oStirge,"oPC",oPC);
DelayCommand(3.0,AttachCheck(oPC,oStirge,eVis,eViss));
DelayCommand(0.5,Follow(oPC,oStirge,eViss));
SetLocalInt(oPC,"nStirge",1);
}
else
{
AssignCommand(oStirge,ActionAttack(GetNextFactionMember(oPC,FALSE),FALSE));
}
}And, here we have the ondamage script (also ondeath, but that may have been uneeded)
// Detach the Stirge!
/*
This is part of the Stirge Script...
if damage is taken, it will detach!
*/
if( GetLocalInt(OBJECT_SELF,"nStirge") )
{
effect eVis1 = EffectNWN2SpecialEffectFile("total_invisibility.SEF");
effect eShare = EffectShareDamage(GetLocalObject(OBJECT_SELF,"oPC"),50,50);
effect eViss = EffectLinkEffects(eVis1,eShare);
effect eCheck = GetFirstEffect(OBJECT_SELF);
while (GetIsEffectValid(eCheck))
{
if(eCheck==eViss)
RemoveEffect(OBJECT_SELF,eViss);
else
eCheck = GetNextEffect(OBJECT_SELF);
}
effect eVis = EffectNWN2SpecialEffectFile("stirge_attach_back.SEF");
eCheck = GetFirstEffect(GetLocalObject(OBJECT_SELF,"oPC"));
while (GetIsEffectValid(eCheck))
{
if(eCheck==eVis)
RemoveEffect(GetLocalObject(OBJECT_SELF,"oPC"),eViss);
else
eCheck = GetNextEffect(GetLocalObject(OBJECT_SELF,"oPC"));
}
SetLocalInt(GetLocalObject(OBJECT_SELF,"oPC"),"nStirge",0);
SetLocalObject(OBJECT_SELF,"oPC",OBJECT_INVALID);
}With 2 variables on the creature; nStirge = 1 and sWP = (some waypoint tag)
Modifié par EpicFetus, 20 juin 2013 - 06:47 .
#11
Posté 20 juin 2013 - 06:48
...way to "maintain my whitespace" code-tag...
#12
Posté 21 juin 2013 - 12:57
An easier way to remove specific effects is to use a function in the "nw_i0_spells" include file.
- When applying the effect, use SetEffectSpellID() to give it a unique number. It doesn't have to be a valid spell id - in fact, it's better to use a number that isn't being used in Spells.2da. It's just a unique handle to remove the effect with later.
- When removing the effect, use RemoveEffectsFromSpell in "nw_i0_spells", specifying the same number you assigned to the effect when applying it.
Using this method means you don't have to loop through effects in your own script.
- When applying the effect, use SetEffectSpellID() to give it a unique number. It doesn't have to be a valid spell id - in fact, it's better to use a number that isn't being used in Spells.2da. It's just a unique handle to remove the effect with later.
- When removing the effect, use RemoveEffectsFromSpell in "nw_i0_spells", specifying the same number you assigned to the effect when applying it.
Using this method means you don't have to loop through effects in your own script.
#13
Posté 21 juin 2013 - 12:51
Thanks for the tidbit, useful info.
#14
Posté 01 septembre 2013 - 11:45
It might be easier to keep the stirge targetable, and have attacks against the stirge reflect on the affected pc, rather than make the pc temporarily targetable.





Retour en haut






