Author Topic: how to aim at location and do things with item  (Read 755 times)

Legacy_Wulpignon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
how to aim at location and do things with item
« on: January 12, 2011, 04:13:30 pm »


               Okay, I'm just asking this because I don't know how to ':bandit:'

You can add unique power to item and then use the power on location or placeable. Now how could I make it work so that when I use the item's power on specific 'something' -> the script will teleport the user/me to a location, an area actually.

So it's that I have to make it check the location aimed first, then if the location aimed is correct it will teleport me
to somewhere


I actually am making a vermin hole, hehe,  I use the item's power on the vermin hole or the area around it and then it will teleport me inside the vermin hole filled ... with vermin

You know, like a rope? I play a server with ropes in it, but it's not what I want.. Not item use -> create rope that I click and then teleport, but just a teleport.....................


the distance between you and the ho0ole doesn't matter

You know item called rope in you inventory, you aim it at hole and then you start loading a new screen/climb down the rope :DDDDDDDDDDDDDDDDDDDDDDDDDDDDD



ME      -aiming at vermin filled hole with unique power-                  " VERMIN HOLE"


BOOM


.
.
.
.
.
 .
 .
.
.
.
.
 .
  .
 .
.
.
.
.
.
.
.
lol
 I
, ,
               
               

               


                     Modifié par Wulpignon, 12 janvier 2011 - 04:17 .
                     
                  


            

Legacy_Wulpignon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #1 on: January 12, 2011, 04:14:04 pm »


               EEK, VERMIN!
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #2 on: January 12, 2011, 04:27:04 pm »


               ok, there are several ways.



1. If the object you are aiming at is a usable placeable, you will be able to target it specifically. You could perhaps have the tag of the waypoint you wish to teleport stored on that object, then your teleport script simply gets the tag from the target, and uses that as a teleport destination.

2. If you want to target locations around an object, you can still do the above suggestion, but I would recommend using GetNearestObjectByType  and find placeables within 5ft of the targetted location. Loop through all placeables within the 5ft radius, until you get one that has a destination tag.





The result is

You target a spot, near a rat hole, script fires, scans the area around your targetted location, locates the rat hole, gets a local string on the rathole, which equates to a tag, which then gets you a waypoint, which is then what you are teleported to.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #3 on: January 12, 2011, 06:26:18 pm »


               If my thinking cap is working this morning (only 4 hours of sleep) then something like this should work, as Baaleos suggested:


void main()
{
object oPC = GetItemActivator();
//plug in the tag of waypoint to teleport to
object oWP = GetWaypointByTag("TAG OF WAYPOINT HERE");
location lTarg = GetItemActivatedTargetLocation();
int nNth = 1;
object oHole = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, lTarg, nNth);
float fDistance = GetDistanceBetweenLocations(lTarg, GetLocation(oHole));
while (fDistance <= 1.0)
    {
    //plug in the tag of the vermin hole
    if (GetTag(oHole) == "TAG OF HOLE HERE")
        {
        AssignCommand(oPC, ActionJumpToObject(oWP));
        return;
        }
    else
        {
        nNth++;
        oHole = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, lTarg, nNth);
        fDistance = GetDistanceBetweenLocations(lTarg, GetLocation(oHole));
        }
    }
}

And don't forget with tagbased scripts to make sure that the tag of the rope is exactly the same as the name of this script.

Hope it helps.
               
               

               


                     Modifié par GhostOfGod, 12 janvier 2011 - 06:29 .
                     
                  


            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #4 on: January 13, 2011, 10:58:21 am »


               my suggestion would be to use something similar, but kinda more re-usable for more than just this one idea.





string GetScriptToExecuteObject(location lLoc, object oMod)
{

int nNth = 1;
object oHole = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, lTarg, nNth);
float fDistance = GetDistanceBetweenLocations(lTarg, GetLocation(oHole));
while (oHole != OBJECT_INVALID && fDistance <= 5.0)
    {
   string sScript = GetLocalString(oHole,"SCRIPT_TO_RUN");
   if(sScript != "")
   {
      SetLocalObject(oMod,"OBJ_RUNNING",oHole);
      break;
   }
        nNth++;
        oHole = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, lTarg, nNth);
        fDistance = GetDistanceBetweenLocations(lTarg, GetLocation(oHole));
    }

return sScript;


}








void main()
{
object oMod = GetModule();
object oPC = GetItemActivator();
//plug in the tag of waypoint to teleport to
location lTarg = GetItemActivatedTargetLocation();
string sScript = GetScriptToExecuteObject(lTarg,oMod);
SetLocalObject(oMod,"OBJ_USER",oPC);
object oRunningObj = GetLocalObject(oMod,"OBJ_RUNNING");
ExecuteScript(sScript,oRunningObj);
DeleteLocalObject(oMod,"OBJ_RUNNING");
DeleteLocalObject(oMod,"OBJ_USER");
}



This idea will let you fire any script attached to the object in the Local String, then, in the script for the object, you can reference the User, and the Object via the Locally Stored Objects on the Module.



This will let you do things like

Teleport to locations,

Activate Objects,

Lock Doors,

Display Messages etc



Its basically a more re-usable solution.



Note - I also increased the radius, feel free to reduce it from 5.0 to whatever you want.
               
               

               
            

Legacy_Wulpignon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #5 on: March 05, 2014, 10:22:33 pm »


               

Thanks guys '<img'>



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #6 on: March 05, 2014, 10:49:26 pm »


               

Why not make this simple?


 


Set a local string on any object that operates with this ability. The string is the tag of a destination waypoint. If the string is not found on the targeted object simply substitute the location of the target as the destination.



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #7 on: March 06, 2014, 02:19:21 am »


               Why not get ride of the item and just set up two area transition triggers.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #8 on: March 06, 2014, 12:47:49 pm »


               


Why not get ride of the item and just set up two area transition triggers.




 


That;s what I was thinking. It's a lot cleaner than having to create a new item and accompanying script. You could always have the OnEnter for the trigger check if the PC has a rope. If no rope, then abort the script with a message telling them they need a rope to go down the hole..


               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
how to aim at location and do things with item
« Reply #9 on: March 07, 2014, 03:50:38 pm »


               The item probably represents something in game. At least that was my assumption.