Looking for script function

Post » Sat Feb 19, 2011 5:46 am

how do i check if in item is in anvil bay or in the imperial city waterfront? both areas are in the same worldspace but aren't interior cells, so neither GetInCell or GetInWorldSpace work.

EDIT: ok no one's replying, so maybe i need to clarify a little more... I'm making a player owned ship that can travel to and from each of the port cities(as well as a few new world spaces i created). i decided the easiest way to do that would be to just create multiple references of the same ship (one in each port) as activators and throw a script on all of the ship parts that enables or disables them depending on that particular references location and a global variable that gets set to different numbers depending on where the ship is moving to. so if the variable is set to 2 (for imperial city) i want the script to enable the references in the imperial city waterfront.

here is what i've come up with so far:

scn TRlocation;global short SCTideRunnerLocation;1=sea;2=imperial city;3=anvilBegin OnLoad 	if ( SCTideRunnerLocation == 1 )		if ( GetInWorldspace SCseas == 1 )			if ( getdisabled == 1 )				enable			endif		else			if ( getdisabled == 0 )				disable			endif		endif	elseif ( SCTideRunnerLocation == 2 )		if ( GetInWorldspace ICWaterfront04 == 1 )			if ( getdisabled == 1 )				enable			endif		else			if ( getdisabled == 0 )				disable			endif		endif	elseif ( SCTideRunnerLocation == 3 )		if ( GetInWorldspace AnvilBay == 1 )			if ( getdisabled == 1 )				enable			endif		else			if ( getdisabled == 0 )				disable			endif		endif	endifend

the problem is that both AnvilBay and ICWaterfront04 are both part of the Tamriel worldspace so i can't use GetInWorldSpace to determine the location, nor can i use GetInCell because they aren't interior cells. how can i go about determining the location of the reference that i have this script attached to???
User avatar
Beat freak
 
Posts: 3403
Joined: Thu Dec 14, 2006 6:04 am

Post » Sat Feb 19, 2011 11:12 am

Use your travel script to set a quest variable for location. Have the above script check the quest variable to determine location.
User avatar
Darrell Fawcett
 
Posts: 3336
Joined: Tue May 22, 2007 12:16 am

Post » Fri Feb 18, 2011 7:46 pm

isn't that essentially what i did with the global variable? the problem isn't setting or checking the variable, that part works fine. it's figuring out which reference of the ship that the script is attached to is located where. so that when the variable is set to the number that corresponds with the imperial city, the reference of the ship in the imperial waterfront becomes enabled, and all other references become disabled. if the ship is in the imperial waterfront, and i fast travel to anvil i don't want to see the instance of the ship in the anvil bay, i want it disabled. I mean i could enable and disable each reference BY NAME but i thought it would be easier to just have one script attached to the various ship parts that enables or disables them depending on where they are because i plan on having the ship travel to a LOT of different locations. To have to enable and disable each part BY NAME will very quickly make the script become VERY LONG, and i don't want that.
User avatar
Jessica Phoenix
 
Posts: 3420
Joined: Sat Jun 24, 2006 8:49 am

Post » Sat Feb 19, 2011 12:37 am

What you could do is create an Activator and place it in the same cell as the ship you want enabled. Give it a reference id, something like ShipEnablerRef. Also make sure it is persistent and initially disabled. Then your script can use GetInSameCell ShipEnablerRef to see if it should be enabled on not. And when you travel just move the ShipEnablerRef to the position of the next ship you want enabled.

Edit: Nevermind, use reference names and ghastley's suggestion.
User avatar
Sarah Knight
 
Posts: 3416
Joined: Mon Jun 19, 2006 5:02 am

Post » Sat Feb 19, 2011 8:33 am

If the location of the ship has nothing to do with the location of the player, then forget about functions that relate to the location of the player.

If you have a group of objects that need to be enabled and disabled together, you just pick one of them to be the "enable parent", such as each ship's hull, and point all the others to it on that tab.

If you want a single interior to link to multiple exteriors, you need multiple doors in the same place in the interior, each of which links to a separate exterior, and only one door is enabled at any time, by the mechanism above (i.e its parent is the ship it leads out to).

I would assume that the ship travels when the player is in the interior (and asleep?), as that avoids a lot of animation, so it all comes down to a single quest script handling the movement (i.e enable/disable) of the ship(s) and the doors that lead out to them. You'll probably have a menumode block so you can run it when the player uses the sleep menu, using the destination you set in a dialog with the captain. Test if the player's in the ship interior cell, that the new destination is set (and not where you already are!), and do it. Player wakes up in new port.

You'd only need to consider the player's location if you want the ship to be able to move without the player. In that case, just a test on IsInInterior allows the ship to move unseen to its new location.
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am

Post » Sat Feb 19, 2011 10:44 am

the problem with GetInSameCell is that some parts of the ship are in more than one worldspace "cell"

the ship travels when the player is outside the ship on the ship's deck via use of the ship's wheel which is what i have my travel script attached to. the player is then teleported to the corresponding location on another instance of the ship behind the ships wheel there.

i think i may try using GetPos and specifying a range of acceptable x and y coordinates of which all parts of the ship will fall inside for each location.
User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Sat Feb 19, 2011 6:38 am

In that case, just use GetDistance referencing each copy of the Ship's wheel.
User avatar
Josh Trembly
 
Posts: 3381
Joined: Fri Nov 02, 2007 9:25 am

Post » Sat Feb 19, 2011 4:03 am

i would, except that "GetDistance does not return reliably in worldspaces when the target is a non-actor in a different cell" according to http://cs.elderscrolls.com/constwiki/index.php/GetDistance
User avatar
Amie Mccubbing
 
Posts: 3497
Joined: Thu Aug 31, 2006 11:33 pm

Post » Sat Feb 19, 2011 2:29 am

Use a marker rat with your ship. :D
User avatar
Liii BLATES
 
Posts: 3423
Joined: Tue Aug 22, 2006 10:41 am

Post » Sat Feb 19, 2011 9:45 am

the x y coordinate thing works, but marker rat seems like it would be easier. less editing to do every time i add a new location for the ship to dock at. how do i do that?
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Sat Feb 19, 2011 8:38 am

At the bottom of http://cs.elderscrolls.com/constwiki/index.php/Teleport_Recall article, is a recipe for Marker Rat.
User avatar
Kay O'Hara
 
Posts: 3366
Joined: Sun Jan 14, 2007 8:04 pm


Return to IV - Oblivion