Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Hnefatafl

Avatar / Picture

Registered:
Posts: 15
Reply with quote  #1 
Hello all.  I've just started playing with scripting, and have a question I haven't found an answer to.

Is it possible to create objects with a certain distance of another named object, rather than by x,z coordinates?

Say I want to have a small group of enemy ships suddenly appear just in front of the player ship, but don't know exactly which way player might be headed.  I'm thinking something like an angle and direction from the player object.

Can this be done?



__________________

Commander Hood, 9th Fleet Operations

Commanding Officer, TSN Yale: 9th Fleet Academy Training Vessel
Helmsman, TSN Vanguard

Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 2,404
Reply with quote  #2 
Yes, this is pretty easy to do. Just spawn the enemy ships at some arbitrary X,Z coordinates (the middle or the corner of the map, for instance) then instantly use set_relative_position to orient the enemy fleet in front of the player ship. I believe that set_relative_position requires you to know the player ship's name, nor slot#, so you should probably compel them to call their ship Artemis.
__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
Hnefatafl

Avatar / Picture

Registered:
Posts: 15
Reply with quote  #3 
Ah! I hadn't seen that one yet; I'll play with it. Thanks!
__________________

Commander Hood, 9th Fleet Operations

Commanding Officer, TSN Yale: 9th Fleet Academy Training Vessel
Helmsman, TSN Vanguard

ryleyra

Registered:
Posts: 3,009
Reply with quote  #4 
Yep. You also want to make sure set_relative_position has a certain minimum offset, since often trying to place two objects in the same spot crashes the game. I believe that's NOT the case in 2.7, but who knows if that will continue to hold true in the future.

That's the command you're looking for, though. It will place the enemy ship relative to the facing of the player ship, just like you want, instead of in reference to the sector coordinate plane. It's a heck of a lot easier than trying to calculate sines and cosines. 😃
Hnefatafl

Avatar / Picture

Registered:
Posts: 15
Reply with quote  #5 
That worked perfectly, exactly what I wanted.  Thanks all!

I *did* have to adjust my initial distance as I'd rammed into them at warp 2 before reacting to their appearance. That should really cause damage...

__________________

Commander Hood, 9th Fleet Operations

Commanding Officer, TSN Yale: 9th Fleet Academy Training Vessel
Helmsman, TSN Vanguard

Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 2,404
Reply with quote  #6 
Quote:
Originally Posted by Hnefatafl
That worked perfectly, exactly what I wanted.  Thanks all!

I *did* have to adjust my initial distance as I'd rammed into them at warp 2 before reacting to their appearance. That should really cause damage...


Hah!

If you want collisions to cause damage then you can build damage into the script. Figure out how close an enemy ship is when it's touching the player ship, then write events for all the enemies that cause shield hits and/or internal damage whenever they get that close. You can test the player ship's currentRealSpeed and scale the damage to be more brutal at higher speeds.

__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.