Aller au contenu

Photo

Creating a teleporter rune (unlimited uses)


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

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I am creating an item Teleporter Rune that can teleport the player up to max 10.0m distance of the target (vector/locations/angles)

 

(this code is used onactivateitem)

if (sItemResRef == "teleporterrune")
    {
        location lTransporter = GetItemActivatedTargetLocation();
        location lPC = GetLocation(oPC);

        if(GetDistanceBetweenLocations(lTransporter, lPC) > 10.0)
        {
        vector vTransporter = GetPositionFromLocation(lTransporter);
        //here I could get the vector, how to calculate PC location +10.0meters from this facing angle?
        }

        effect eVisualEffect = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVisualEffect, lPC);
        DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVisualEffect, lTransporter));
        DelayCommand(1.0, AssignCommand(oPC, JumpToLocation(lTransporter)));
    }

//EDITED

// if new location is a valid location  :o



#2
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I just discovered that is impossible to teleport PC by using a item to a distance greater than 5 meters away, because the distance between oPC and oTarget must be a maximum of 5 feet (or the item can't be activated).



#3
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

One workaround would be to do something like the following...

 

Fireball has a long range.

 

Make an item that casts Fireball.

 

Change the Fireball script so that if the spell is cast by that particular item then the player gets teleported to that location instead.



#4
leo_x

leo_x
  • Members
  • 223 messages

You can use item property Activate Item (Long Range) instead of Unique Power (I'm guessing that is what you're using now) which according to NWNWiki has max range of 40m.


  • Shadooow et WhiteTiger aiment ceci

#5
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

You can use item property Activate Item (Long Range) instead of Unique Power (I'm guessing that is what you're using now) which according to NWNWiki has max range of 40m.

Using "Activate Item (long range)" I could teleport to any visible point on my screen. Very good!



#6
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

Hah.  The irony is that I would have sworn there was something like that but when I looked in the toolset I was looking for "Unique Power (Long Range)" and figured I was just misremembering stuff at 4 AM.



#7
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

is possible to reset the PC round when use an item? so PC dont need to wait next round to active again 



#8
WhiZard

WhiZard
  • Members
  • 1 204 messages

is possible to reset the PC round when use an item? so PC dont need to wait next round to active again 

 

It might be easier to implement this as an "instant feat" rather than a traditional cast spell item property.


  • WhiteTiger aime ceci

#9
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

Easy way to do it is to use the Player Tool feats/script -- they're instant and long range.


  • WhiteTiger aime ceci

#10
WhiteTiger

WhiteTiger
  • Members
  • 479 messages
#include "x0_i0_position"

// Get a random location in a given area based on a given object,
// the specified distance away.
// If no object is given, will use a random object in the area.
// If that is not available, will use the roughly-center point
// of the area.
// If distance is set to 0.0, a random distance will be used.
location GetRandomLocation(object oArea, object oSource=OBJECT_INVALID, float fDist=0.0);
location GetRandomLocation(object oArea, object oSource=OBJECT_INVALID, float fDist=0.0)
{
    location lStart;

    if (!GetIsObjectValid(oSource)) {
        lStart = GetCenterPointOfArea(oArea);
    } else {
        lStart = GetLocation(oSource);
    }

    float fAngle; float fOrient;

    if (fDist == 0.0) {
        int nRoll = Random(3);
        switch (nRoll) {
        case 0:
            fDist = DISTANCE_MEDIUM; break;
        case 1:
            fDist = DISTANCE_LARGE; break;
        case 2:
            fDist = DISTANCE_HUGE; break;
        }
    }

    fAngle = IntToFloat(Random(140) + 40);

    fOrient = IntToFloat(Random(360));

    return GenerateNewLocationFromLocation(lStart,
                                           fDist,
                                           fAngle,
                                           fOrient);
}

For those who are looking for a random teleport code, this is very good

 

It makes no sense with my objective that was to find out how to define a distance of 10 meters from the target if the distance is greater. However I discovered that it would not be possible, could give bug and I still do not know how to teleport 10 meters away from an angle that was chosen by activating item.


Modifié par WhiteTiger, 07 août 2014 - 12:23 .


#11
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

In general...

 

Get the angle between the origin and the destination.

 

Use sin and cos coupled with the 10m to create a new location and teleport the PC to that location (which is 10m in the correct direction).

 

If you need help working out the exact math I can post some code.