Aller au contenu

Photo

Dimension Door Spell


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

#1
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

I know little to nothing about Neverwinter Nights 2 scripting. I am working on a Dimension Door spell script, but it is not working. Basically, I want it to allow the player to teleport to a space within visual range and play the teleportation VFX at the player's location, then destination once they "teleport in".

 

After looking at spell scripts and viewing some lists on the NWN2wiki, I put this script together. I also edited the spells.2da and iprp_spells.2da to include this spell as well. I can cast it, but nothing happens afterwords.

 

 

 

//::///////////////////////////////////////////////

//:: [Dimension Door]

//:: [NW_S0_DimensionDoor.nss]

//:: Copyright © 2000 Nobody.

//:://////////////////////////////////////////////

/*

   Teleports caster to designated location within visual range.

*/

//:://////////////////////////////////////////////

//:: Created By: FaerzressSparkles

//:: Created On: Feb 7, 2015

//:://////////////////////////////////////////////

//:: Last Updated By: FaerzressSparkles, On: Feb 7, 2015

 

 

#include "nwn2_inc_spells"

#include "x2_inc_spellhook"

 

void main()

{

if (!X2PreSpellCastCode())

{

return;

}

object oPC = GetLastSpellCaster();

object oPC = OBJECT_SELF;

object oCaster = oPC;

object oTarget = oPC;

string sName = GetName(oPC);

AssignCommand(oPC, ClearAllActions());

location lTarget = GetSpellTargetLocation();

effect eVis = EffectVisualEffect(VFX_TELEPORT);

 

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oTarget, ActionJumpToLocation(lTarget));

effect eVis = EffectVisualEffect(VFX_TELEPORT);

 

}



#2
kamal_

kamal_
  • Members
  • 5 250 messages

The problem with this idea isn't that it couldn't work, it's that you could have players teleporting over triggers.

 

If you really want to have it, there is a Wand of Teleportation in Wizard's Apprenctice 2 that works this way, you can teleport to wherever you can see.



#3
4760

4760
  • Members
  • 1 207 messages
You define twice object oPC, so the script cannot compile.
Also, OBJECT_SELF will return the PC object if he's the one casting the spell, not if he uses a wand or other item.

#4
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

Thanks 4760!

 

I may take a look at that wand too, Kamal. It will not break anything in my module/PW. I am aware it would wreak havoc on the OC or in many other player modules.



#5
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

Still nothing... hmm...



#6
4760

4760
  • Members
  • 1 207 messages

Here's M. Rider's rod of teleport script:

/*When the user uses the rod of teleportation, this script fires.  It 
should move the player to a location within line of sight when activated*/

void main()
{
object oUser = GetItemActivator();
location lTeleport = GetItemActivatedTargetLocation();
effect eTeleport = EffectNWN2SpecialEffectFile("fx_teleport_new",oUser);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eTeleport,oUser);
AssignCommand(oUser,ActionJumpToLocation(lTeleport));
}

Looking once again at your code, I see two possibilities of the script not firing as intended:

object oPC = OBJECT_SELF;
// let's check if we're getting the right object!
SendMessageToPC(GetFirstPC(), "Teleport requested by " + GetName(oPC) + " (tag: " + GetTag(oPC) +")");

// removed the rest of the code for showing the changes, but keep it!
 
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID)
{
 SendMessageToPC(GetFirstPC(), "Couldn't find the area to teleport to, aborting...");
 return;
}

Also, when you write "I can cast it", do you get the selection icon on the ground?



#7
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

Thanks for helping 4760. To answer your question, yes, I get the selection icon on the ground.



#8
4760

4760
  • Members
  • 1 207 messages

OK, then lTarget shouldn't be invalid.

SendMessageToPC(GetFirstPC(), "Targeted position (" + FloatToString(lTarget.x) + " ; " + FloatToString(lTarget.y) + " ; " + FloatToString(lTarget.z) + ")");

should confirm it anyway (cannot return "Targeted position (0.0 ; 0.0 ; 0.0) as this is out of the walkable area).

 

Did you get any confimation that the PC was actually the caster of the spell, and that the area wasn't invalid?



#9
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

Just recompiled and for some reason it worked this time. I wonder if the first compiling had issues for some reason. Either way, now it works. Thank you for helping, 4760, I appreciate it!

 

I may try to implement some other spells at some point.



#10
4760

4760
  • Members
  • 1 207 messages

AssignCommand(oPC, ClearAllActions());

 

 

 

AssignCommand(oTarget, ActionJumpToLocation(lTarget));

Just wondering, if everything's OK (the SendMessage give the expected information), couldn't it be a timing issue then?

Try to DelayCommand the jump (I've seen cases when the AssignCommand statements weren't fired in the order they were scripted, so maybe ClearAllActions takes place AFTER the call to JumpToLocation, thus cancelling it?)

DelayCommand(0.1, AssignCommand(oTarget, ActionJumpToLocation(lTarget)));


#11
4760

4760
  • Members
  • 1 207 messages

OK then forget the above message (at least for this particular case).



#12
Dann-J

Dann-J
  • Members
  • 3 161 messages

Whenever I use ClearAllActions() before a string of other action functions, I always delay the following actions by a small amount (even if it's 0.1 seconds). Often I'll delay each following command in slightly increasing amounts as well, so as not to induce a "Stooge Effect". A tenth of a second delay here or there won't produce any noticeable effect to the player.



#13
AGhost_7

AGhost_7
  • Members
  • 62 messages

The problem with this idea isn't that it couldn't work, it's that you could have players teleporting over triggers.

 

If you really want to have it, there is a Wand of Teleportation in Wizard's Apprenctice 2 that works this way, you can teleport to wherever you can see.

If I can suggest something here, maybe adding a check to the area to see if teleportation is blocked. That way, if you need to ensure the PC doesn't hop over a trigger in the area, you can just add the set the variable to 1 in the area's properties. Something like this:


// This should handle both spells and items.
void main()
{
    object oPC = GetIsPC(OBJECT_SELF) ? OBJECT_SELF : GetItemActivator();
    object oArea = GetArea(oPC);
    if(GetLocalInt(oArea, "bNoTeleport"))
    {
        SendMessageToPC(oPC, "Your teleportation spell just fizzled!");
    } else 
    {
        location lLoc;
        if(GetSpellId() > 0)
        {
            lLoc = GetSpellTargetObject();
        } else
        {
            lLoc = GetItemActivatedTargetLocation();
        }
        
        AssignCommand(oPC, ActionJumpToLocation(lLoc));
    }
}


#14
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I also have a couple of teleportation items with scripts. They are available on my blog here.

Regards

#15
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

Thanks a bunch for all of the input everyone, I really appreciate you all trying to help!

 

I did manage to get the spell to work. I also created a custom icon and added spell descriptions to a custom tlk file. I may create more spells and feats in the future. Below is a screenshot of the custom icon, name, and description in-game.

 

Capture%20drsquoeacutecran%202015-02-14%


  • rjshae aime ceci