Author Topic: Figurine of Wondrous Power Script  (Read 949 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« on: October 01, 2013, 04:09:50 pm »


               Hey all,

Does anyone have a script to do this? I know it would be a unique item.

I have searched the forums and the Net to no avail.


Thanks!
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #1 on: October 01, 2013, 09:08:03 pm »


               Not hard to do. What you need is an on-activation script that summons a creature, and destroys the item. Thats about it right?

Some stuff out there:
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #2 on: October 05, 2013, 03:04:53 pm »


               Okay, here is a script I made using LilacSoul's Script Generator, v. TK.0. This script is not attached anywhere and I have double checked that the name of the script (smnbaristhenes) is the same as the item I made.

/*  *  Script generated by LS Script Generator, v.TK.0 * *  For download info, please visit: *  http://nwvault.ign.c...tail&id=1502 */
//Created On: 10/03/2013
void OnActivate(object oEventItem, object oActTarget, location lActTarget, object oActivator){    object oSpawn;    effect eVFX;    object oPC = oActivator;
    // This item must target a location (not an object).    if ( GetIsObjectValid(oActTarget) )    {        SendMessageToPC(oActivator, "Improper use of this item!");        return;    }
    // Spawn "baristhenes".    eVFX = EffectVisualEffect(471);    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "baristhenes", lActTarget);    DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSpawn));}

When testing the PC makes the motions like he is activating the item but nothing happens. I just tested my My Stone of Recall and works without any problem (and it is using tab-based scripting to work). Because the Stone of Recall works this leads me to believe the problem is in the script I posted above.

What is supposed to happen is that upon activation, the PC summons a creature named Baristhenes. Once I get the summoning part working I'll add in the scripting to make the summond creature join the PC's party.

Any help to fix my script would be appreciated. By the way, how do you properly post scripting code on these forums so it shows correctly?

Thanks!


Here is the script that is in the OnActivate event handler on my module:

#include "69_hench_lib"void main()//******************************************//Added in ExecuteScript( "x2_mod_def_act", OBJECT_SELF); to activate tag-based scripting//*******************************************{ExecuteScript( "x2_mod_def_act", OBJECT_SELF); object oPC = GetItemActivator(); object oTarget = GetItemActivatedTarget(); string sTag = GetTag(oTarget); object oItem = GetItemActivated(); string sItem = GetTag(oItem); object oArea = GetArea(oTarget);
 if(sItem == "HenchmanHealKit") {  if(GetIsHenchmanDying(oTarget))  {   SendMessageToPC(oPC, "Healing Kit Used");   ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_S, FALSE), oTarget);   SetLocalInt(oArea, "nCHP" +sTag, 2);  }  else   SendMessageToPC(oPC, "This henchman is not dying"); }
 if(sItem == "HenchmanLevelupTool") {  if(HenchmanCheck69(oTarget, oPC))  {   int nHenchXP = GetLocalInt(oTarget, "HENCH_XP");   SetLocalInt(oTarget, "HENCH_XP", nHenchXP + 2000);   nHenchXP = GetLocalInt(oTarget, "HENCH_XP");   string sHenchXP = IntToString(nHenchXP);   string sHenchName = GetName(oTarget);   SendMessageToPC(oPC, sHenchName + " received 2000 experience points.");   SendMessageToPC(oPC, sHenchName + " has " + sHenchXP + " experience points.");   if(HenchXPCheck69(oTarget))   {     LevelUpHenchman69(oTarget, oPC);   }  }  else   SendMessageToPC(oPC, "This is not your henchman."); }
}
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #3 on: October 07, 2013, 07:38:36 pm »


                Hey all:

In a topic under Custom Content Lightfoot8 posted a script that uses tag-based scripting to have an item summon a specific creature by its resref. I used this script to try and make a Figurine of Wondrous Power. When I tested it the PC makes the animation of using the item and the visual effect fires but no creature is summoned. Below is the script. Do you all mind taking a look and see if there is anything I might be doing wrong?

Thanks!

 #include "x2_inc_switches"
void main()
{
    if (GetUserDefinedItemEventNumber()!= X2_ITEM_EVENT_ACTIVATE) return;
    object oPC = GetItemActivator();
    int nDuration = GetCasterLevel(oPC);
    effect eSummon = EffectSummonCreature("NW_S_badgerdire");
    effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);

    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, GetItemActivatedTargetLocation());
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetItemActivatedTargetLocation(), TurnsToSeconds(nDuration));
}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #4 on: October 07, 2013, 09:04:20 pm »


               Hmm. Just glancing quickly before i leave for work here but the script looks fine. Is it just this item that you are having problems with for "tag-based" scripting? A couple things to double check: Make sure your OnModuleLoad script has the line "SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);". Also triple check to make sure the TAG of the item matches exactly the name of the script.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #5 on: October 07, 2013, 10:12:47 pm »


               Hey GoG,

Thanks for the reply. Yep, tag based scripting is set because my Stone of Recall works.

I will triple check the name of the item though, and make sure it matches the name of the script.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #6 on: October 08, 2013, 12:38:56 am »


                Here is the script I am using. I have the resref of a basic skeleton in the script. The PC animation fires and the visual effect fires but no skeleton appears.

Thoughts?

#include "x2_inc_switches"

void main()
{
    if (GetUserDefinedItemEventNumber()!= X2_ITEM_EVENT_ACTIVATE) return;   
    object oPC = GetItemActivator();
    int nDuration = GetCasterLevel(oPC);
    effect eSummon = EffectSummonCreature("skeleton006");
    effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);

    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, GetItemActivatedTargetLocation());
   ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetItemActivatedTargetLocation(), TurnsToSeconds(nDuration));

}
               
               

               


                     Modifié par UnrealJedi, 07 octobre 2013 - 11:41 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #7 on: October 08, 2013, 08:22:51 am »


               Since you are seeing the visual effect then we know your "tag-based" script is working. I'm pretty sure the problem is that you need to "AssignCommand" the effect of summoning a creature since only PCs or NPCs are able to do it. One other thing is that the EffectSummonCreature already has a visual effect attached to it so you don't need to add an extra one. I changed your script a bit and commented out what you didn't need to show the difference.


#include "x2_inc_switches"

void main()
{
    if (GetUserDefinedItemEventNumber()!= X2_ITEM_EVENT_ACTIVATE) return;
    object oPC = GetItemActivator();
    int nDuration = GetCasterLevel(oPC);
    //effect eSummon = EffectSummonCreature("skeleton006", VFX_FNF_SUMMON_MONSTER_1, 0.0, 1);
    //effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);

    //ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, GetItemActivatedTargetLocation());
    AssignCommand(oPC, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectSummonCreature("nw_skeleton", VFX_FNF_SUMMON_MONSTER_1, 0.0, 1), GetItemActivatedTargetLocation(), TurnsToSeconds(nDuration)));

}


Tested and working.

P.S. you will need to change the res ref of the creature again. I just did standard skeleton for testing.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #8 on: October 08, 2013, 01:53:45 pm »


               Thanks GoG. I can't wait to try it out. Hopefully, I can puzzle out how to modify the script so that after being summoned the creature is added as a henchman to the PC's party. Hmmm...unless that happens automatically as a result of being summoned....

Do you know how long the summoned creature will stick around, since the duration is set to temporary?

Thanks again.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #9 on: October 08, 2013, 06:35:45 pm »


               Okay, the script worked and I can see I do not have to add scripting to add it to the PC's party, as it is added automatically. However, my summoned creature does not obey any commands from the radial menu. I tried telling him to follow but he just stands there. Any suggestions?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #10 on: October 08, 2013, 08:09:32 pm »


               If you want a creature to be a henchman/associate it needs to have specific scripts attached to it. So in the creatures blueprint go in and change/add the following:

  • OnBlocked: nw_ch_ace
  • OnCombatRoundEnd: nw_ch_ac3
  • OnConversation: nw_ch_ac4
  • OnDamaged: nw_ch_ac6
  • OnDeath: nw_ch_ac7
  • OnDisturbed: nw_ch_ac8
  • OnHeartbeat: nw_ch_ac1
  • OnPerception: nw_ch_ac2
  • OnPhysicalAttacked: nw_ch_ac5
  • OnRested: Leave Blank
  • OnSpawn: nw_ch_ac9
  • OnSpellCastAt: nw_ch_acb
  • OnUserDefined: nw_ch_acd
You might also need to add a generic associate conversation but I don't remember what that is off the top of my head. Maybe "x2_associate"?

There are a few tutorials on the Lexicon if you want to get more in depth: Link
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #11 on: October 09, 2013, 12:20:23 pm »


               Well, I feel stupid. It has been so long since I have made a henchman I didn't even think about the needed scripts. Thanks for the reminder, GoG.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #12 on: October 11, 2013, 06:52:17 pm »


               Okay, the script works great. However, I am not exactly thrilled about my summoned creature flying down from out of the sky, especially if they aren't supposed to fly. Is it possible to write a tag-based script that simply spawns in a creature instead of using the summoning effect?
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #13 on: October 11, 2013, 08:17:00 pm »


                The flying down from the sky is the appear animation as far as I am aware. When the creature is created do not trigger the appear animation. You'll need to create the creature then establish that it is a summon. Then set it to be destroyed after a certain amount of time.

object CreateObject(
    int nObjectType,
    string sTemplate,
    location lLocation,
    int bUseAppearAnimation = FALSE,
    string sNewTag = ""
);

The name of the function to add an NPC to your party a sa particular type of associate escapes me at the moment. You'll have to do some hunting.

Read more at NWN Lexicon.
               
               

               


                     Modifié par henesua, 11 octobre 2013 - 08:01 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Figurine of Wondrous Power Script
« Reply #14 on: October 12, 2013, 12:41:21 pm »


               The last parameter of the EffectSummonCreature is missing from the Lexicon but it is in the function description in the toolset:

// 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)


In the script you already have from above just change that last 1 to a 0:

AssignCommand(oPC, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,
EffectSummonCreature("nw_skeleton", VFX_FNF_SUMMON_MONSTER_1, 0.0, 0),
GetItemActivatedTargetLocation(), TurnsToSeconds(nDuration)));