Author Topic: Creating a teleporter rune (unlimited uses)  (Read 426 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« on: August 06, 2014, 07:00:57 am »


               

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  '<img'>



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #1 on: August 06, 2014, 07:22:57 am »


               

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



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #2 on: August 06, 2014, 10:19:25 am »


               

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.



               
               

               
            

Legacy_leo_x

  • Sr. Member
  • ****
  • Posts: 403
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #3 on: August 06, 2014, 10:36:13 am »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #4 on: August 06, 2014, 04:49:53 pm »


               


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!



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #5 on: August 06, 2014, 07:12:18 pm »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #6 on: August 06, 2014, 07:56:09 pm »


               

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



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #7 on: August 06, 2014, 08:06:20 pm »


               


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.


               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #8 on: August 06, 2014, 08:23:05 pm »


               

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



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #9 on: August 07, 2014, 01:06:17 am »


               

#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 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Creating a teleporter rune (unlimited uses)
« Reply #10 on: August 07, 2014, 01:35:11 am »


               

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.