Author Topic: CopyObject  (Read 345 times)

Legacy_WhenTheNightComes

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +0/-0
CopyObject
« on: February 18, 2013, 07:58:45 pm »


               My script:

void main()
{
effect eVFX;
effect eEffect;
int nStackSize=1;
object oPC = GetPCSpeaker();
location lLocation = GetLocation(oPC);
int nDuration = GetLevelByclass(class_TYPE_WIZARD, oPC) + GetLevelByclass(class_TYPE_SORCERER, oPC)*1;
CopyObject(oPC,lLocation,oPC,"ILLUSIONARY_GUARD");
object oGuard = GetNearestObjectByTag("ILLUSIONARY_GUARD");
SetName(oGuard,"Illusionary Guard");
CreateItemOnObject("wswgs002",oGuard, nStackSize, "Illusionary_Greatsword");
AssignCommand(oGuard, ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, "Illusionary_Greatsword"), INVENTORY_SLOT_RIGHTHAND));
AddHenchman(oPC, oGuard);
ChangeToStandardFaction(oGuard, STANDARD_FACTION_DEFENDER);
eEffect = EffectDamageShield(0, DAMAGE_BONUS_1d8, DAMAGE_TYPE_MAGICAL);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oGuard, IntToFloat(nDuration));
        eEffect = EffectDamageReduction(5, DAMAGE_POWER_PLUS_SIX);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oGuard, IntToFloat(nDuration));
        eEffect = EffectHaste();
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oGuard, IntToFloat(nDuration));
        eVFX = SupernaturalEffect(EffectVisualEffect(VFX_DUR_ETHEREAL_VISAGE));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oGuard, IntToFloat(nDuration));


eVFX = EffectVisualEffect(VFX_FNF_SMOKE_PUFF);
        DelayCommand(IntToFloat(nDuration), ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oGuard));
        DelayCommand(IntToFloat(nDuration), DestroyObject(oGuard, 0.2));
}


Problem: Nothing happens. The copied creature does not get the visual effects, delayed destroy, added to the PCs party as a hench, or anything in the script. I looked up CopyObject on lexicon (http://www.nwnlexico....php/CopyObject) and under known bugs it states "There are problems with the new tag as well. Calling GetTag with the
copied object as a parameter works, but calling GetObjectByTag won't
return the copy, or at least it won't all the time. Calling
GetTag(GetObjectByTag("")) will also return the tag of the most recently
copied object."

I believe this may be the root of my problems. Can anyone help solve this?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
CopyObject
« Reply #1 on: February 18, 2013, 11:38:05 pm »


               ok lets look at the two lines here.   

WhenTheNightComes wrote...
CopyObject(oPC,lLocation,oPC,"ILLUSIONARY_GUARD");
object oGuard = GetNearestObjectByTag("ILLUSIONARY_GUARD");


There is really no reason to create the object and then find the object that you just created.   The CopyObject function returns the object it creates. So you can simply replace the two lines above with.   


object oGuard = CopyObject(oPC,lLocation,oPC,"ILLUSIONARY_GUARD");