Aller au contenu

Photo

OnDamaged Doppelganger script


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
bealzebub

bealzebub
  • Members
  • 352 messages
Hey, I've been working on a script to change a creature into a doppelganger when they get below 10 HP.
It compiles fine, but does nothing in game. can any one spot the problem with this?

#include "nw_i0_generic"
void main()
{
object oPC = GetLastHostileActor();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = OBJECT_SELF;
int nHp;
nHp = GetCurrentHitPoints(oTarget);
if (nHp <10) return;
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), GetLocation(oTarget));
DestroyObject(oTarget, 3.0);
object oSpawn;
location lTarget;
oTarget = oPC;
lTarget = GetLocation(oTarget);
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "bub_doppelganger", lTarget);
oTarget = oSpawn;
SetIsTemporaryEnemy(oPC, oTarget);
AssignCommand(oTarget, ActionAttack(oPC));
AssignCommand(oTarget, DetermineCombatRound(oPC));

nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), oTarget));
else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), GetLocation(oTarget)));
}

#2
Shaughn78

Shaughn78
  • Members
  • 637 messages
One this I noticed is this line "if (nHp <10) return;" You're ending the script when the object gets below the the 10 hitpoints.

Another thing I do with damage scripts is I make sure the default script runs if the conditions aren't met.

if(nHp < 10)
{
Do your code
}
else
{
ExecuteScript("nw_c2_default6",OBJECT_SELF);
}


Here is a section of script I am using for a on damage spawn and destroy, similiar to what you are doing. I have the original creature set to immortal so they can't go below 0 hitpoints.

void main()
{
string sTag = GetTag(OBJECT_SELF);
int nHitPoint = GetCurrentHitPoints(OBJECT_SELF);
location lSelf = GetLocation(OBJECT_SELF);
object oDamage = GetLastDamager();
object oPC;
object oCount = GetNearestObjectByTag("rh_slm_lvl6_counter");//This is an ipoint

if(GetIsPC(oDamage) == TRUE)oPC = oDamage;
else oPC = GetFactionLeader(oDamage);

effect eOoze1 = EffectNWN2SpecialEffectFile("sp_swamp_lung");
effect eOoze2 = EffectNWN2SpecialEffectFile("sp_vitriolic_doom");
effect eOoze3 = EffectNWN2SpecialEffectFile("sp_acid_aoe");

int nOnceA = GetLocalInt(oCount,"rh_slm_lvl6_a");
int nOnceB = GetLocalInt(oCount,"rh_slm_lvl6_b");
int nOnceC = GetLocalInt(oCount,"rh_slm_lvl6_c");

if(nHitPoint == 1)
{
if(sTag == "rh_slm_druidooze_a")//First Death, ancient druid
{
if(nOnceA != 0)return;
if(GetIsObjectValid(GetNearestObjectByTag("rh_slm_druidooze_b")))return;

SetCreatureScriptsToSet(OBJECT_SELF,SCRIPTSET_INVALID);
SetLocalInt(oCount,"rh_slm_lvl6_a",1);
AssignCommand(OBJECT_SELF,ClearAllActions(TRUE));
SetScriptHidden(OBJECT_SELF,TRUE);


object oNew = CreateObject(OBJECT_TYPE_CREATURE,"rh_slm_druidooze_b",lSelf,FALSE,"rh_slm_druidooze_b");

ApplyEffectToObject(DURATION_TYPE_INSTANT,eOoze1,oNew);


DelayCommand(0.25,FloatingTextStringOnCreature("",oNew));
AssignCommand(oNew,ClearAllActions(TRUE));
DelayCommand(0.5,FloatingTextStringOnCreature("",oPC));

ChangeToStandardFaction(oNew,STANDARD_FACTION_HOSTILE);


DelayCommand(1.0,DestroyObject(OBJECT_SELF));
return;
}
}
else
{
ExecuteScript("nw_c2_default6",OBJECT_SELF);
}
}

Modifié par Shaughn78, 09 juin 2011 - 01:00 .


#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Shaughn78 wrote...

One this I noticed is this line "if (nHp <10) return;" You're ending the script when the object gets below the the 10 hitpoints.


Yup, you probably meant to do:
if (nHp >10) return; // If HitPoint are Greater than 10 end script

Though, to add in what Shaughn78 siad:
if (nHp >10)  // If HitPoint are Greater than 10
   {
   ExecuteScript("nw_c2_default6",OBJECT_SELF); return; //Execute default OnDamaged script then end this script
   }
  

#4
bealzebub

bealzebub
  • Members
  • 352 messages
That was it guys, thanks.

#5
bealzebub

bealzebub
  • Members
  • 352 messages
Hey, the script works, but not really how I invisioned. When the creature gets below 10 hp, the doppelganger spawns in, and then the creature slowly fades away. What command would I use to make it happen quickly? I want the creature to dissapear with a splat, and in it's place is the doppelganger.

#6
Shallina

Shallina
  • Members
  • 1 012 messages
check the VFX polymorth for Verewolf, make a new spell and edit the 2DA for a VFX polymorth dopplehanger.

#7
Morbane

Morbane
  • Members
  • 1 883 messages
effectpolymorph has a parameter that prevents the radial option to change back to human form it is a boolean - very useful to keep someone changed until you deem it necessary to change back.

#8
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Or you might be able to just change its appearance and add/equip any creature items it needs (ex. creature skin). Could throw in a VFX for flavor when the change happens.

#9
Shaughn78

Shaughn78
  • Members
  • 637 messages
For my script I use the scripthidden function to make the original creature instantly disappear, then I destroy them later in the script.

Modifié par Shaughn78, 10 juin 2011 - 12:32 .


#10
bealzebub

bealzebub
  • Members
  • 352 messages
I went the "change the appearance" route, and it worked just right. When the creature drops below 10 hp, with a splat of blood, he reveals his true, healed, doppelganger form. Thanks for the help everyone. I just needed some direction.