Item Scripting/Spawn Summon?
Zephirius                
                
                    Member Posts: 419                
            
                    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...
                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"));
  }
}
                0        
            
                                
Comments
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).
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));Darn!
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
//:://///////////////////////////////////////////// //:: 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(); }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.
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.
// 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?
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.