floating script?

Post » Wed Jun 20, 2012 4:32 pm

You have done, beautiful sails. That's one of the things I'm yet to do (not much a graphical designer myself :) ) as well as implementing a proper collision detection, moving the player seamlessly and fixing a problem with certain angles while travelling.
User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm

Post » Wed Jun 20, 2012 10:54 pm

Your ship makes me jealous. :drool:

I'm just using the vanilla ships because I have no ability in modelling/texturing. And it looks really weird for a ship to sail without sails!
User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am

Post » Wed Jun 20, 2012 6:26 pm

Your ship makes me jealous. :drool:

I'm just using the vanilla ships because I have no ability in modelling/texturing. And it looks really weird for a ship to sail without sails!

I can make one with sails like that for you since I'm making one for myself anyway, if Prometheus doesn't want to share.
User avatar
Sheila Reyes
 
Posts: 3386
Joined: Thu Dec 28, 2006 7:40 am

Post » Thu Jun 21, 2012 12:00 am

I can make one with sails like that for you since I'm making one for myself anyway, if Prometheus doesn't want to share.

Thanks, that'd be great! Just a warning though, I don't know if I'll be using it at all. Once I got past the scripting part of my mod, I've barely done any work on it...
User avatar
Thema
 
Posts: 3461
Joined: Thu Sep 21, 2006 2:36 am

Post » Wed Jun 20, 2012 5:52 pm

I can share but that is specifically designed for Issgard , with the Issgard flag colors , the Frontal figurehead and vertex colors ... Actually the vertex colors where quite a Pain in the.... couse I manually edited every single vertex in the Nifscope ... then got bored and had to do other work in 3dsmax but seems my version of 3dsmax can't import the ship models and so had to use lot of nif work arounds... I was actually trying to implement an animation inside the other like aflag over the ship but couln't make them work .... may be if I could be able to import the animations and bones too I could animate a bit even the sails ... so far no luck and the time required to experiment compared to the possible gains for now are too unbalanced and I am finely settled with this kind of ship that at least rolls and looks like the ship I wanted ....
User avatar
Matthew Warren
 
Posts: 3463
Joined: Fri Oct 19, 2007 11:37 pm

Post » Wed Jun 20, 2012 4:43 pm

If I could get you a basic model of a hull shape, could you add sails and rigging to it, oh most excellent modelling person?

(I came up with a basic catamaran-style hull I'd like to sue for an Altmeri Dominion ship in blender, but I know that I svck rear at making realistic sails, etc...I envision the Altmeri as using http://en.wikipedia.org/wiki/Lateen as opposed to the square-rigged Imperial/Nord designs...
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am

Post » Thu Jun 21, 2012 12:40 am

actually I took the sail model in the nif files of the bethesda vanilla model ,they are set to invisible so u don't see , I have removed the closed sails , I have exported uvmapped and retextured the sails and set into the the nif back ... but I slightly modified the shape couse they clpped with the ropes , seems bethesda didn't check that the ropes they put all around woudl have gone thorught the sails when opened so I had to redo those too ...
User avatar
Joey Bel
 
Posts: 3487
Joined: Sun Jan 07, 2007 9:44 am

Post » Wed Jun 20, 2012 11:34 pm

Thanks, that'd be great! Just a warning though, I don't know if I'll be using it at all. Once I got past the scripting part of my mod, I've barely done any work on it...

Haha, same for me.
Building a worldspace is so boring.
User avatar
lucy chadwick
 
Posts: 3412
Joined: Mon Jul 10, 2006 2:43 am

Post » Thu Jun 21, 2012 2:09 am

How much more difficult would it be to set it up so that the boat would also turn back in the direction it came from repeatedly? From A to B to A to B again.
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Thu Jun 21, 2012 2:11 am

How much more difficult would it be to set it up so that the boat would also turn back in the direction it came from repeatedly? From A to B to A to B again.

You mean to make a boat sail in a circle? Well I could do it with scripting, but I still don't know a good way to check for collision, so it might clip through rocks, walls, the ground, etc.
User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am

Post » Wed Jun 20, 2012 9:01 pm

Not so worried about the clipping part, since it'd be more along the lines of moving in the air from one floating island to another.

Would you be willing to teach me the scripting needed to do something like that?
User avatar
Lady Shocka
 
Posts: 3452
Joined: Mon Aug 21, 2006 10:59 pm

Post » Wed Jun 20, 2012 9:40 pm

This is the script I've been using:

Spoiler
Scriptname fg109SMShipScript extends ObjectReference{Script controlling the sea merchants' ship.};;;;;;;;;;;;;;;;;; Properties ;;;;;;;;;;;;;;;;;;FormList property RouteA auto{FormList of navigation markers between Solitude and Dawnstar.}FormList property RouteB auto{FormList of navigation markers between Dawnstar and Winterhold.}FormList property RouteC auto{FormList of navigation markers between Winterhold and Windhelm.}Int property Speed = 250 auto{Speed at which the ship sails.}Int property MaxRotation = 5 auto{Maximum rotation speed in degrees per second.};;;;;;;;;;;;;;;;; Variables ;;;;;;;;;;;;;;;;;FormList CurrentRouteInt TargetIndexBool AtPort = TrueBool Anchored = TrueBool InvertRoute;;;;;;;;;;;;;;;;; Functions ;;;;;;;;;;;;;;;;;;Function to convert local rotation to global rotation, and vice versaFloat[] Function ConvertRotation(Float AngleX, Float AngleY, Float AngleZ, Bool FromLocal = True)    Float NewX    Float NewY    if (FromLocal)        NewX = AngleX * Math.Cos(AngleZ) + AngleY * Math.Sin(AngleZ)        NewY = AngleY * Math.Cos(AngleZ) - AngleX * Math.Sin(AngleZ)    else        NewX = AngleX * Math.Cos(AngleZ) - AngleY * Math.Sin(AngleZ)        NewY = AngleY * Math.Cos(AngleZ) + AngleX * Math.Sin(AngleZ)    endif    Float[] Angles = new Float[3]    Angles[0] = NewX    Angles[1] = NewY    Angles[2] = AngleZ    Return AnglesEndFunction;Function to set which route we're using, and if we should reverse-iterate through the routeBool Function SetRoute(Int Route = 0, Bool Reverse = False)    if (Route == 0)        Debug.Trace(self + "[fg109SMShipScript] SetRoute() received invalid 'Route' parameter.")        Return False    endif    if (Route == 1)        CurrentRoute = RouteA    elseif (Route == 2)        CurrentRoute = RouteB    elseif (Route == 3)        CurrentRoute = RouteC    endif    InvertRoute = Reverse    if (Reverse)        TargetIndex = CurrentRoute.GetSize() - 2    else        TargetIndex = 1    endif    Return TrueEndFunction;Function to move the shipBool Function Sail()    ObjectReference Target = GetTargetMarker(CurrentRoute, TargetIndex, InvertRoute)    if !Target        Debug.Trace(self + "[fg109SMShipScript] Sail() failed to locate navigation target.")        Return False    endif    float OffsetAngle = GetHeadingAngle(Target)    if (Math.Abs(OffsetAngle) > (MaxRotation / 2))        GoToState("Curved")        Curve(OffsetAngle)    elseif (GetState() == "Curved")        GoToState("Straight")        Settle(OffsetAngle)    else        Target.SetAngle(0, 0, GetAngleZ() + OffsetAngle)        TranslateToRef(Target, Speed, MaxRotation)    endif    Return TrueEndFunction;Function to have the ship curve towards the target markerFunction Curve(Float Yaw)    if (Yaw < -MaxRotation)        Yaw = -MaxRotation    elseif (Yaw > MaxRotation)        Yaw = MaxRotation    endif    float AngleZ = GetAngleZ() + Yaw    Float[] Angles = ConvertRotation(0, -Yaw, AngleZ)    float OffsetX = Speed * Math.Sin(AngleZ)    float OffsetY = Speed * Math.Cos(AngleZ)    TranslateTo(X + OffsetX, Y + OffsetY, Z, Angles[0], Angles[1], Angles[2], Speed, 0)EndFunction;Function to have the ship settle after curvingFunction Settle(Float Yaw)    if (InvertRoute)        TargetIndex += 1    else        TargetIndex -= 1    endif    float AngleZ = GetAngleZ() + Yaw    float OffsetX = Speed * Math.Sin(AngleZ)    float OffsetY = Speed * Math.Cos(AngleZ)    TranslateTo(X + OffsetX, Y + OffsetY, Z, 0, 0, AngleZ, Speed, 0)EndFunction;Function to get the target markerObjectReference Function GetTargetMarker(Formlist Markers = None, Int Index = 0, Bool Reverse = False)    if (Markers == None)        Debug.Trace(self + "[fg109SMShipScript] GetTargetMarker() missing 'Markers' parameter.")        Return None    endif    if (Reverse)        if (Index - 1 < 0)            Debug.Trace(self + "[fg109SMShipScript] GetTargetMarker() received invalid 'Index' parameter.")            Return None        endif        Return Markers.GetAt(Index - 1) as ObjectReference    else        if (Index + 1 >= Markers.GetSize())            Debug.Trace(self + "[fg109SMShipScript] GetTargetMarker() received invalid 'Index' parameter.")            Return None        endif        Return Markers.GetAt(Index + 1) as ObjectReference    endifEndFunction;;;;;;;;;;;;;; Events ;;;;;;;;;;;;;;;Purely for testing purposesEvent OnActivate(ObjectReference akActionRef)    Anchored = !Anchored    if (AtPort)        AtPort = False        SetRoute(1)    endif    if (Anchored)        StopTranslation()    else        Sail()    endifEndEventAuto State Straight    Event OnTranslationAlmostComplete()        if (InvertRoute)            if (TargetIndex <= 0)                Return            endif            TargetIndex -=1        elseif (TargetIndex >= CurrentRoute.GetSize())            Return        else            TargetIndex += 1        endif        Sail()    EndEvent    Event OnTranslationComplete()        if (TargetIndex == 0) || (TargetIndex + 1 == CurrentRoute.GetSize())            StopTranslation()            AtPort = True            Anchored = True        endif    EndEventEndStateState Curved    Event OnTranslationAlmostComplete()        Sail()    EndEventEndState

The ship sails along a set route defined by a formlist of markers. Once it reaches a marker on the list, it will sail to the next marker. If the next marker requires the ship to turn more than some set angle (2.5 degrees according to the default values in the script above) then the ship make a curve instead of heading directly towards it.

I haven't scripted in a way to turn a ship around once it reaches a port though. There isn't enough room in the ports for the ship to actually make a 180 degree turn while constrained to only turning 5 degrees per second. I might have to settle for just putting a mage on the ship and saying that she's using magic to rotate the ship while it's in place. (I'm already going to have to use that explanation to get past all the ice around Winterhold.)
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Wed Jun 20, 2012 12:01 pm

Can make a video of how it works?
User avatar
Star Dunkels Macmillan
 
Posts: 3421
Joined: Thu Aug 31, 2006 4:00 pm

Post » Wed Jun 20, 2012 4:17 pm

This is the script I've been using:

Spoiler
Scriptname fg109SMShipScript extends ObjectReference{Script controlling the sea merchants' ship.};;;;;;;;;;;;;;;;;; Properties ;;;;;;;;;;;;;;;;;;FormList property RouteA auto{FormList of navigation markers between Solitude and Dawnstar.}FormList property RouteB auto{FormList of navigation markers between Dawnstar and Winterhold.}FormList property RouteC auto{FormList of navigation markers between Winterhold and Windhelm.}Int property Speed = 250 auto{Speed at which the ship sails.}Int property MaxRotation = 5 auto{Maximum rotation speed in degrees per second.};;;;;;;;;;;;;;;;; Variables ;;;;;;;;;;;;;;;;;FormList CurrentRouteInt TargetIndexBool AtPort = TrueBool Anchored = TrueBool InvertRoute;;;;;;;;;;;;;;;;; Functions ;;;;;;;;;;;;;;;;;;Function to convert local rotation to global rotation, and vice versaFloat[] Function ConvertRotation(Float AngleX, Float AngleY, Float AngleZ, Bool FromLocal = True)	Float NewX	Float NewY	if (FromLocal)		NewX = AngleX * Math.Cos(AngleZ) + AngleY * Math.Sin(AngleZ)		NewY = AngleY * Math.Cos(AngleZ) - AngleX * Math.Sin(AngleZ)	else		NewX = AngleX * Math.Cos(AngleZ) - AngleY * Math.Sin(AngleZ)		NewY = AngleY * Math.Cos(AngleZ) + AngleX * Math.Sin(AngleZ)	endif	Float[] Angles = new Float[3]	Angles[0] = NewX	Angles[1] = NewY	Angles[2] = AngleZ	Return AnglesEndFunction;Function to set which route we're using, and if we should reverse-iterate through the routeBool Function SetRoute(Int Route = 0, Bool Reverse = False)	if (Route == 0)		Debug.Trace(self + "[fg109SMShipScript] SetRoute() received invalid 'Route' parameter.")		Return False	endif	if (Route == 1)		CurrentRoute = RouteA	elseif (Route == 2)		CurrentRoute = RouteB	elseif (Route == 3)		CurrentRoute = RouteC	endif	InvertRoute = Reverse	if (Reverse)		TargetIndex = CurrentRoute.GetSize() - 2	else		TargetIndex = 1	endif	Return TrueEndFunction;Function to move the shipBool Function Sail()	ObjectReference Target = GetTargetMarker(CurrentRoute, TargetIndex, InvertRoute)	if !Target		Debug.Trace(self + "[fg109SMShipScript] Sail() failed to locate navigation target.")		Return False	endif	float OffsetAngle = GetHeadingAngle(Target)	if (Math.Abs(OffsetAngle) > (MaxRotation / 2))		GoToState("Curved")		Curve(OffsetAngle)	elseif (GetState() == "Curved")		GoToState("Straight")		Settle(OffsetAngle)	else		Target.SetAngle(0, 0, GetAngleZ() + OffsetAngle)		TranslateToRef(Target, Speed, MaxRotation)	endif	Return TrueEndFunction;Function to have the ship curve towards the target markerFunction Curve(Float Yaw)	if (Yaw < -MaxRotation)		Yaw = -MaxRotation	elseif (Yaw > MaxRotation)		Yaw = MaxRotation	endif	float AngleZ = GetAngleZ() + Yaw	Float[] Angles = ConvertRotation(0, -Yaw, AngleZ)	float OffsetX = Speed * Math.Sin(AngleZ)	float OffsetY = Speed * Math.Cos(AngleZ)	TranslateTo(X + OffsetX, Y + OffsetY, Z, Angles[0], Angles[1], Angles[2], Speed, 0)EndFunction;Function to have the ship settle after curvingFunction Settle(Float Yaw)	if (InvertRoute)		TargetIndex += 1	else		TargetIndex -= 1	endif	float AngleZ = GetAngleZ() + Yaw	float OffsetX = Speed * Math.Sin(AngleZ)	float OffsetY = Speed * Math.Cos(AngleZ)	TranslateTo(X + OffsetX, Y + OffsetY, Z, 0, 0, AngleZ, Speed, 0)EndFunction;Function to get the target markerObjectReference Function GetTargetMarker(Formlist Markers = None, Int Index = 0, Bool Reverse = False)	if (Markers == None)		Debug.Trace(self + "[fg109SMShipScript] GetTargetMarker() missing 'Markers' parameter.")		Return None	endif	if (Reverse)		if (Index - 1 < 0)			Debug.Trace(self + "[fg109SMShipScript] GetTargetMarker() received invalid 'Index' parameter.")			Return None		endif		Return Markers.GetAt(Index - 1) as ObjectReference	else		if (Index + 1 >= Markers.GetSize())			Debug.Trace(self + "[fg109SMShipScript] GetTargetMarker() received invalid 'Index' parameter.")			Return None		endif		Return Markers.GetAt(Index + 1) as ObjectReference	endifEndFunction;;;;;;;;;;;;;; Events ;;;;;;;;;;;;;;;Purely for testing purposesEvent OnActivate(ObjectReference akActionRef)	Anchored = !Anchored	if (AtPort)		AtPort = False		SetRoute(1)	endif	if (Anchored)		StopTranslation()	else		Sail()	endifEndEventAuto State Straight	Event OnTranslationAlmostComplete()		if (InvertRoute)			if (TargetIndex <= 0)				Return			endif			TargetIndex -=1		elseif (TargetIndex >= CurrentRoute.GetSize())			Return		else			TargetIndex += 1		endif		Sail()	EndEvent	Event OnTranslationComplete()		if (TargetIndex == 0) || (TargetIndex + 1 == CurrentRoute.GetSize())			StopTranslation()			AtPort = True			Anchored = True		endif	EndEventEndStateState Curved	Event OnTranslationAlmostComplete()		Sail()	EndEventEndState

The ship sails along a set route defined by a formlist of markers. Once it reaches a marker on the list, it will sail to the next marker. If the next marker requires the ship to turn more than some set angle (2.5 degrees according to the default values in the script above) then the ship make a curve instead of heading directly towards it.

I haven't scripted in a way to turn a ship around once it reaches a port though. There isn't enough room in the ports for the ship to actually make a 180 degree turn while constrained to only turning 5 degrees per second. I might have to settle for just putting a mage on the ship and saying that she's using magic to rotate the ship while it's in place. (I'm already going to have to use that explanation to get past all the ice around Winterhold.)

Please add that to the Wiki so this thread doesn't disappear one day and that awesome script becomes extremely hard to find. Pretty please!
User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am

Post » Wed Jun 20, 2012 3:27 pm

actually I took the sail model in the nif files of the bethesda vanilla model ,they are set to invisible so u don't see , I have removed the closed sails , I have exported uvmapped and retextured the sails and set into the the nif back ... but I slightly modified the shape couse they clpped with the ropes , seems bethesda didn't check that the ropes they put all around woudl have gone thorught the sails when opened so I had to redo those too ...
Bethesda actually place the sails? That is excelent news !!! :D a less problem for my mod :)
User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am

Post » Wed Jun 20, 2012 1:36 pm

Can make a video of how it works?

OK, it took me a while but I managed to make a http://youtu.be/rJCa9zCahWY. I don't know why there's no audio, but it doesn't matter since the point of this is to see the script at work, right?

I sped up the ship halfway through in order to try and cut down on the video size. The trip from Solitude to Dawnstar would have taken ~12 minutes originally.
User avatar
Deon Knight
 
Posts: 3363
Joined: Thu Sep 13, 2007 1:44 am

Post » Wed Jun 20, 2012 8:49 pm

thats really cool , are u releaseing this as a resource? may be with a tuto on how to setup ?

It woudl be cool to also have some animations like on the NPCs on the boat like doing something cleaning , fixing the ship , budy governing it etc.....

even a rowboat actually woudl be pretty cool ....
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Wed Jun 20, 2012 10:39 pm

I don't see how anyone would need a tutorial to do that. All you have to do is attach the script I posted to a ship, and create a formlist of markers for it to follow.

I don't think it's possible to move navmesh around, and I'm certainly not going to try and navmesh the whole route. I only put navmesh at the spots that the ship will be anchoring at.
User avatar
jasminε
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am

Post » Wed Jun 20, 2012 2:10 pm

whats a formlist?
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm

Post » Wed Jun 20, 2012 11:11 pm

I don't see how anyone would need a tutorial to do that. All you have to do is attach the script I posted to a ship, and create a formlist of markers for it to follow.

I don't think it's possible to move navmesh around, and I'm certainly not going to try and navmesh the whole route. I only put navmesh at the spots that the ship will be anchoring at.
There is no need to navmeshing. The ship mesh is enough aparently. I had made NPCs follow my character while my ship was moving and they can even fight each other. Didn't add any navmesh and below was only water.
whats a formlist?
Is a list of base IDs. Similar to a leveled list, but only stores objects didn't aply any randomization and you can place different type of objects in the same list.
User avatar
Gemma Flanagan
 
Posts: 3432
Joined: Sun Aug 13, 2006 6:34 pm

Post » Thu Jun 21, 2012 2:32 am

That is awesome. Beyond awesome, really. I just wish I knew what even half the coding meant.

How would you create a formlist of xmarkers?
User avatar
Céline Rémy
 
Posts: 3443
Joined: Sat Apr 07, 2007 12:45 am

Post » Wed Jun 20, 2012 6:13 pm

and can I put other items on the ship?

will they follow the ship movement?

did u use an animated boat or static one?
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am

Post » Wed Jun 20, 2012 10:02 pm

and can I put other items on the ship?

will they follow the ship movement?

did u use an animated boat or static one?

Havok items might, but you can forget doors or other statics. Each one of them would have to be moved individually, and there's no way you could make them track the right spot relative to the hull.
User avatar
AnDres MeZa
 
Posts: 3349
Joined: Thu Aug 16, 2007 1:39 pm

Post » Thu Jun 21, 2012 2:22 am

I placed a door on the ship but is part of the mesh , I was thinking to use a NPC as door or a autoload door eventually but I do not need actually a door for my purpouse .. what I wanted was to have some small random encounters after the player exit the cabin , and then after the encounter talks to the captain and keeps the travel ongoing ....

http://www.youtube.com/watch?v=rEm5MY737Is&context=C4d6d31bADvjVQa1PpcFMV3OtMudt8HHg1QmwO9qYTsoPHlJXte4o=
User avatar
Far'ed K.G.h.m
 
Posts: 3464
Joined: Sat Jul 14, 2007 11:03 pm

Post » Thu Jun 21, 2012 3:01 am

TranslateTo has rotation as well.

I'm also assuming the movement speed is in units/second, since the wiki page says a speed of 1 is almost imperceptible. that could be determined with some testing, and then you could know exactly how long to wait until starting the next idle movement.

Edit: If you want it to be a easier to code, you can move it on fixed paths (like just up and down) without using random numbers.

There is a note on one of the Translate functions in the Wiki that confirms that movement speed is units per second and rotation speed is degrees per second.
User avatar
Amy Smith
 
Posts: 3339
Joined: Mon Feb 05, 2007 10:04 pm

PreviousNext

Return to V - Skyrim