Skip to content

Item Scripting/Spawn Summon?

I have a little amulet that is supposed to summon a wraith to fight at your side. Only problem is that after I summon him, he's not associated to my group. How do I make him a true summon with it's picture hanging out in the upper right hand corner of my screen?
Also, I'm wholly uncertain on how to spawn the wraith where I click at on the screen? I just spawns next to the PC, PC = lLoc...
Anyway hope your all having a great day, and any help, even a nudge in the proper direction would be awsome. :)

Little bit of code I have...
object oUsed = GetItemActivated();

  // The following section is for the Amulet of the Dead
  // The amulet summons a wraith.
  if (GetTag(oUsed) == "AMULET_DEAD")
  {
    // Get the PC, first.
    object oPC = GetItemActivator();

    location lLoc = GetLocation(oPC);

    effect eSummon = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eSummon, lLoc);
    DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "wraith", lLoc));

 //object oMaster = GetMaster(GetObjectByTag("WRAITH"));



  }
}

Comments

  • QuilistanQuilistan Member Posts: 177
    what script set is your summon using?
    I did this with a rod that summons a Golem for wizard's to use as body guards.

    I simply use the special ability on the rod to spawn it like you did, but the Golem is using the hechman script set (found on the characters listed in the "Standard/Other" list).

  • ZephiriusZephirius Member Posts: 411
    So if I load up the henchman Ai's it will serve as a true summon?
  • ForSeriousForSerious Member Posts: 446
    // Create a Summon Creature effect.  The creature is created and placed into the
    // caller's party/faction.
    // - sCreatureResref: Identifies the creature to be summoned
    // - nVisualEffectId: VFX_*
    // - fDelaySeconds: There can be delay between the visual effect being played, and the
    //   creature being added to the area
    // - nUseAppearAnimation: should this creature play it's "appear" animation when it is
    //   summoned. If zero, it will just fade in somewhere near the target.  If the value is 1
    //   it will use the appear animation, and if it's 2 it will use appear2 (which doesn't exist for most creatures)
    effect EffectSummonCreature(string sCreatureResref, int nVisualEffectId=VFX_NONE, float fDelaySeconds=0.0f, int nUseAppearAnimation=0)
    
    Can be used like in the below code. You just have to define nDuration and use the above code to make eSummon.
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(nDuration));
    
  • ZephiriusZephirius Member Posts: 411
    Thanks for the heads up ForSerious. It was GetSpellTargetLocation() that I needed to use.
  • ZephiriusZephirius Member Posts: 411
    Hmmm... not sure what's wrong, but nothing happens.
    object oUsed = GetItemActivated();
    
      // The following section is for the Amulet of the Dead
      // The amulet summons a wraith.
      if (GetTag(oUsed) == "AMULET_DEAD")
      {
        // Get the PC, first.
        object oPC = GetItemActivator();
    
        effect eSummon = EffectSummonCreature("wraith", VFX_FNF_SUMMON_UNDEAD, 0.5, 0);
    
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eSummon, GetSpellTargetLocation(), HoursToSeconds(10));
    
  • ForSeriousForSerious Member Posts: 446
    DURATION_TYPE_INSTANT should probably be DURATION_TYPE_TEMPORARY.
  • ZephiriusZephirius Member Posts: 411
    Still nothing. Double checked the resref and the tag of the amulet. That's not it.
    Darn! ;)
  • ForSeriousForSerious Member Posts: 446
    ResRef of the wraith?
  • ZephiriusZephirius Member Posts: 411
    Yeah
  • ZephiriusZephirius Member Posts: 411
    I've tried the resrefs of several critters just to be sure, but still no summon.
  • QuilistanQuilistan Member Posts: 177
    edited October 2021
    void main()
    {
        // Declare major variables
        object oMaster = GetItemActivator();
        // Replace "CREATURERESREF" with the sCreatureResref of whichever monster you wish to summon.
        // Note that sCreatureResref is *not* the same as it's Tag.
        //  You can also replace the _3 with 1-3 for different summon effects.
        effect eSummon = EffectSummonCreature ("grelen_golem", VFX_FNF_SUMMON_MONSTER_3 );
        // Apply the VFX impact and summon effect
        // Adjust the TurnsToSections(10) to reflect how long you want it to last.
        // You can use HoursToSeconds(), RoundsToSeconds() or TurnsToSeconds().
        ApplyEffectToObject (DURATION_TYPE_TEMPORARY, eSummon, oMaster, TurnsToSeconds(20));
    }
    

    that is the code for my item, then I have the ai from the henchmen characters running on the summoned golem.

    Of course I never know if I do it the best way, but it does work.....

    My Summon is a custom creature
  • QuilistanQuilistan Member Posts: 177
    My onSpawn script is different also (just noticed), honestly can't remember why. Here is it though.
    //::///////////////////////////////////////////////
    //:: Associate: On Spawn In
    //:: NW_CH_AC9
    //:: Copyright (c) 2001 Bioware Corp.
    //:://////////////////////////////////////////////
    /*
    
    This must support the OC henchmen and all summoned/companion
    creatures.
    
    */
    //:://////////////////////////////////////////////
    //:: Created By: Preston Watamaniuk
    //:: Created On: Nov 19, 2001
    //:://////////////////////////////////////////////
    //:: Updated By: Georg Zoeller, 2003-08-20: Added variable check for spawn in animation
    
    
    #include "X0_INC_HENAI"
    #include "x2_inc_switches"
    void main()
    {
         //Sets up the special henchmen listening patterns
        SetAssociateListenPatterns();
    
        // Set additional henchman listening patterns
        bkSetListeningPatterns();
    
        // Default behavior for henchmen at start
        SetAssociateState(NW_ASC_POWER_CASTING);
        SetAssociateState(NW_ASC_HEAL_AT_50);
        SetAssociateState(NW_ASC_RETRY_OPEN_LOCKS);
        SetAssociateState(NW_ASC_DISARM_TRAPS);
        SetAssociateState(NW_ASC_MODE_DEFEND_MASTER, FALSE);
    
        //Use melee weapons by default
        SetAssociateState(NW_ASC_USE_RANGED_WEAPON, FALSE);
    
        // Distance: make henchmen stick closer
        SetAssociateState(NW_ASC_DISTANCE_4_METERS);
        if (GetAssociate(ASSOCIATE_TYPE_HENCHMAN, GetMaster()) == OBJECT_SELF) {
        SetAssociateState(NW_ASC_DISTANCE_2_METERS);
        }
    
        // * If Incorporeal, apply changes
        if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_IS_INCORPOREAL) == TRUE)
        {
            effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
            eConceal = ExtraordinaryEffect(eConceal);
            effect eGhost = EffectCutsceneGhost();
            eGhost = ExtraordinaryEffect(eGhost);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eConceal, OBJECT_SELF);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGhost, OBJECT_SELF);
        }
    
    
        // Set starting location
        SetAssociateStartLocation();
    }
    
  • ForSeriousForSerious Member Posts: 446
    Humm, it worked first try for me.
    So, I have the OnActivate setup to just redirect:
    // Simple on activate redirect.
    void main()
    {
        object oItem = GetItemActivated();
        object oPC = GetItemActivator();
        if(GetIsObjectValid(oItem))
        {
            //SendMessageToPC(GetFirstPC(), GetTag(oItem));
            ExecuteScript(GetTag(oItem), oPC);
        }
    }
    

    Then I tried this code:
    void main()
    {
        object oTarget = GetSpellTargetObject();
        if(GetIsObjectValid(oTarget))
        {
            SendMessageToPC(OBJECT_SELF, "Cannot target there.");
            return;
        }
        location lLoc = GetSpellTargetLocation();
        effect eSummon = EffectSummonCreature("wraith001", VFX_FNF_SUMMON_UNDEAD, 0.5);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, lLoc, HoursToSeconds(10));
    }
    
    (I made wraith001 in the pallet beforehand, but tried wraith as well. It summoned a dwarf...)
    It made a Wraith, but it had no AI. So you'll have to figure out how to add that to it. I'm sure you can just copy the script set from a standard summon creature resref.
  • QuilistanQuilistan Member Posts: 177
    oh like like the tag base active item script.... always forget you can do that to cut down on number of scripts.
  • ZephiriusZephirius Member Posts: 411
    Yeah, I can't even get it to spawn
  • ZephiriusZephirius Member Posts: 411
    If I use CreateObject I can get a spawn, but I'm not getting anything with EffectSummonCreature()?
  • ForSeriousForSerious Member Posts: 446
    Maybe try our scripts in a new module. It's probably something small you're missing.
  • ZephiriusZephirius Member Posts: 411
    Thanks guys. I'll try your suggestions...
  • ZephiriusZephirius Member Posts: 411
    I'm at a total loss. Tried it in a new module. That didn't work. I'm using unique power, not unique power (self only) so I can target the effect. Gotta be something small like Serious said, but I can't figure it out for the life of me...
  • ZephiriusZephirius Member Posts: 411
    ForSerious wrote: »
    Humm, it worked first try for me.
    So, I have the OnActivate setup to just redirect:
    // Simple on activate redirect.
    void main()
    {
        object oItem = GetItemActivated();
        object oPC = GetItemActivator();
        if(GetIsObjectValid(oItem))
        {
            //SendMessageToPC(GetFirstPC(), GetTag(oItem));
            ExecuteScript(GetTag(oItem), oPC);
        }
    }
    

    Then I tried this code:
    void main()
    {
        object oTarget = GetSpellTargetObject();
        if(GetIsObjectValid(oTarget))
        {
            SendMessageToPC(OBJECT_SELF, "Cannot target there.");
            return;
        }
        location lLoc = GetSpellTargetLocation();
        effect eSummon = EffectSummonCreature("wraith001", VFX_FNF_SUMMON_UNDEAD, 0.5);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, lLoc, HoursToSeconds(10));
    }
    
    (I made wraith001 in the pallet beforehand, but tried wraith as well. It summoned a dwarf...)
    It made a Wraith, but it had no AI. So you'll have to figure out how to add that to it. I'm sure you can just copy the script set from a standard summon creature resref.

  • ZephiriusZephirius Member Posts: 411
    Yeah, what's up with the Dwarf? Some 2DA woes?
  • ForSeriousForSerious Member Posts: 446
    The dwarf also appears if I leave the ResRef blank (""). So, he must be some creature with no resref in my module.
    Even though copying a standard pallet creature like wraith creates a new creature with a resref of wraith001, the actual bluprint resref of the original is nw_wraith. Maybe that's what you're missing... Though you'd still need to make a custom creature so that it would have the right AI.
  • ZephiriusZephirius Member Posts: 411
    The only thing I can think of is GetItemActivator(); How it's being used or lack thereof.
    // General Initialization:  Find what item was used
         object oUsed = GetItemActivated();
    
       
         if (GetTag(oUsed) == "AMULET_DEAD")
         {
         // Get the PC, first.
         object oPC = GetItemActivator();
    
    
    
        location lLoc = GetSpellTargetLocation();
        effect eSummon = EffectSummonCreature("allip002", VFX_FNF_SUMMON_UNDEAD, 0.5, 0);
        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, lLoc, TurnsToSeconds(60));
        }
    

    How do I plug oPC into the the remaining script so that oPC is recongnized as GetItemActivator();

    oPC is only being called once to identify as GetItemActivator(); Does oPC need to be referenced at any other time in the remaining script?

  • ForSeriousForSerious Member Posts: 446
    Looks like you can't have them both with this approach.
    You are correct about GetItemActivator().
    You define oPC but never use it.
    In order to use it, you have to change ApplyEffectAtLocation to ApplyEffectToObject and put oPC in as the target object. This removes the ability to target where the summon appears.
    To keep that, you need to go the ExecuteScript route. Pretty easy:
    // General Initialization:  Find what item was used
         object oUsed = GetItemActivated();
    
       
         if (GetTag(oUsed) == "AMULET_DEAD")
         {
         // Get the PC, first.
         object oPC = GetItemActivator();
         ExecuteScript("summon_script", oPC);
        }
    
    'summon_script' can be what I put earlier, I should just mention that the if(GetIsObjectValid(oTarget)) statement is there to block the user from targeting objects. That way they can only target locations on the ground. You can remove that, of course.
  • ZephiriusZephirius Member Posts: 411
    Using ApplyEffectToObject(); Works. But you can't target a location. Mabey that's were the fault lies, is the location? Perhaps that's messign with the spawn... I don't know...
  • QuilistanQuilistan Member Posts: 177
    I remember the dwarf thing from way way back early 2000's things defaulted there for some reason.
Sign In or Register to comment.