[Help/Advice] Creating Ships and Sending them to War

Freeform discussion about anything related to modding Transcendence.
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Your problem is: (objGetPosition ...) is not a function, you want (objGetPos ...)

Whenever something spawns on the sun, the position is returning Nil.
Sun = Nil (In vector position terms)

'Attack = "Attack"
They are interchangeable in many circumstances.

Anything within double quotes is recognized as a string.
A single quote ' is a special character in Lisp that means "The following is Read-only, do not evaluate"

Finally, this won't work:

Code: Select all

(setq theTarget (sysFindObject gSource "tA+HellAresOutpost"))
sysFindObject returns a list and you can't order a ship to attack a list.

You can change to "tAN+HellAresOutpost"
the N limits it to the nearest, therefore a list of one object is a valid target.
you can use (random (sysFindObject ...))
or you can get more in depth with your target selection using filters or switches.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

Prophet wrote:Your problem is: (objGetPosition ...) is not a function, you want (objGetPos ...)

Whenever something spawns on the sun, the position is returning Nil.
Sun = Nil (In vector position terms)

'Attack = "Attack"
They are interchangeable in many circumstances.

Anything within double quotes is recognized as a string.
A single quote ' is a special character in Lisp that means "The following is Read-only, do not evaluate"

Finally, this won't work:

Code: Select all

(setq theTarget (sysFindObject gSource "tA+HellAresOutpost"))
sysFindObject returns a list and you can't order a ship to attack a list.

You can change to "tAN+HellAresOutpost"
the N limits it to the nearest, therefore a list of one object is a valid target.
you can use (random (sysFindObject ...))
or you can get more in depth with your target selection using filters or switches.
<3

I love you prophet! :mrgreen:

I followed your instructions and it WORKS! :D :D :D :D

final code is:

Code: Select all

<Events>
      <OnCreate>
	  (block Nil
       (sysAddObjRecurringTimerEvent 100 gSource 'Attack)
       )
      </OnCreate>
      <Attack>
      (block Nil
       (setq theShip (sysCreateShip &scCenturionX; (objGetPos gSource) &svCommonwealth;))
       (setq theTarget (random(sysFindObject gSource "tAN+HellAresOutpost")))
       (shpOrder theShip 'attack theTarget)
       (shpOrder theShip 'guard gSource)
         )
      </Attack>
</Events>
Thanks SOOOOOOOOOOO much! Expect to see this really abused in Hell's Trinity Beta! :D
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Looking forward to it!
:mrgreen:
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

I just want to check I'm doing this correctly here -- how would I send out multiple ships in a squadron formation to go attack things? I have:

Code: Select all

<Events>
      <OnCreate>
	  (block Nil
	   'Attack
       (sysAddObjRecurringTimerEvent 1500 gSource 'Attack)
       )
      </OnCreate>
      <Attack>
      (block Nil
	 ;;Set three ships
       (setq theShip1 (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
	   (setq theShip2 (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
	   (setq theShip3 (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
	   ;;Set their common target to a random Ares station nearby
       (setq theTarget (random(sysFindObject gSource "tAN+HellAresOutpost")))
	   ;;Attack!
       (shpOrder theShip1 'attack theTarget)
	   (shpOrder theShip2 'attack theTarget)
	   (shpOrder theShip3 'attack theTarget)
	   ;;The Ships shouldn't return, but if they do...go kill something else...
	   (setq theTarget (random(sysFindObject gSource "tAN+HellAresOutpost")))
	   (shpOrder theShip1 'attack theTarget)
	   (shpOrder theShip2 'attack theTarget)
	   (shpOrder theShip3 'attack theTarget)
	   ;;If they survive THAT...return home.
       (shpOrder theShip1 'guard gSource)
	   (shpOrder theShip2 'guard gSource)
	   (shpOrder theShip3 'guard gSource)
         )
      </Attack>
	</Events>
That sends out three ships, gives them an attack command, then another one if they succeed and lets them go home. But that seems a bit unwieldy to work with -- what if I needed to send out a dozen ships (which I want later on). And how do I get them to be led by another ship?

Also, how would I check to see if an Ares Outpost exists before sending out a fleet? Else if all Outposts are down, what will happen?
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

I'm not sure about the second part, but a kind of cheating, easy way to make multiple ships is to go into the code for &scLincolnAlpha; to have

Code: Select all

<Escorts>
<Ship count="howevermanyyouwant" class="Whatever" orders="escort"/>
</Escorts
That makes the ships you spawn inherently have escorts. I'm sure there's a script way to do it, but personally I prefer to not use script. Be careful not to have the ships escorted by others of themselves.

*remembers the horror*

The poor ships don't even have a chance... Their whole universe crashes because of them...
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

Drako Slyith wrote:I'm not sure about the second part, but a kind of cheating, easy way to make multiple ships is to go into the code for &scLincolnAlpha; to have

Code: Select all

<Escorts>
<Ship count="howevermanyyouwant" class="Whatever" orders="escort"/>
</Escorts
That makes the ships you spawn inherently have escorts. I'm sure there's a script way to do it, but personally I prefer to not use script. Be careful not to have the ships escorted by others of themselves.

*remembers the horror*

The poor ships don't even have a chance... Their whole universe crashes because of them...
Um thanks. Why can't I use other LincolnAlphas? Just wondering...

Edit *after trying* : Oh. That's why. -_-

Thanks for the coding anyhow -- I'll just make a LincolnBeta (a leader). Thanks! :D
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

Ok, so using <escort> the coding is much neater and works like a charm. Now that I've got that worked out, I need something else (yes I'm a needy person aren't I? >.< )

How would I assign an infinite loop to the ships, so they always check for an ares outpost then go destroy, check again and if there is one, go destroy it, or else wander the system?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

In your Attack event, where you spawn the initial ship, do something like this:

Code: Select all

(shpSetCommandCode theShip (block nil
  ;; search for an outpost, and attack it
))
the command code will be executed the moment the ship has no other orders.
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

alterecco wrote:In your Attack event, where you spawn the initial ship, do something like this:

Code: Select all

(shpSetCommandCode theShip (block nil
  ;; search for an outpost, and attack it
))
the command code will be executed the moment the ship has no other orders.
So, if there is no outpost will the ship do whatever is after that command?

eg

Code: Select all

<Event>
(block nil
(setq theShip (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
(shpSetCommandCode theShip
    (block nil
        (setq theTarget (random(sysFindObject gSource "tAN+HellAresOutpost"))
        (shpOrder theShip1 'attack theTarget)  
     )
)
 (shpOrder theShip1 'guard gSource)
)
</Event>
In the above, will theShip return home if there is no Ares Outpost left? And if there are more OUtposts left, will it continue to find them?
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

I think this code should find all enemy ares stations.

Code: Select all

								(setq allEnemyStations (sysFindObject gSource "TAE +Ares"))
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

ThePrivateer wrote: So, if there is no outpost will the ship do whatever is after that command?
No. You need to tell it what to do inside the command code... basically, if you don't find any targets, then tell it to go home instead of attacking.
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

alterecco wrote:
ThePrivateer wrote: So, if there is no outpost will the ship do whatever is after that command?
No. You need to tell it what to do inside the command code... basically, if you don't find any targets, then tell it to go home instead of attacking.
I think everyone is underestimating something here - I have no knowledge of TLisp. zip, zilch, nada. :|

However I cobbled together this but am yet to try it:

Code: Select all

(block Nil
	  ;;Set ship
      (setq theShip (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
	  (shpSetCommandCode theShip
		(block nil
                    (if (eq (sysFindObject gSource "tAN+HellAresOutpost"))
                        (setq theTarget (random(sysFindObject gSource "tAN+HellAresOutpost"))) (shpOrder theShip 'attack theTarget) 
                        (shpOrder theShip 'guard gSource)  
			
                      )	)) )

I don't think that will work because (if only returns two things - Xelerus. And I need my (if to do two things -- if there is an Ares oupost to be found, set it and then order the ship to attack, else go back home.

any help please?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Code: Select all

(block Nil
  ;;Set ship
  (setq theShip (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
  (shpSetCommandCode theShip
    (block (target)
      (setq target (sysFindObject gSource "tAN +HellAresOutpost;"))
      (if target
        ;; found a target, attack it
        (shpOrder theShip 'attack target)
        ;; found no target, go home on guard duty
        (shpOrder theShip 'guard gSource)
      )
    )
  )
)
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

alterecco wrote:

Code: Select all

(block Nil
  ;;Set ship
  (setq theShip (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
  (shpSetCommandCode theShip
    (block (target)
      (setq target (sysFindObject gSource "tAN +HellAresOutpost;"))
      (if target
        ;; found a target, attack it
        (shpOrder theShip 'attack target)
        ;; found no target, go home on guard duty
        (shpOrder theShip 'guard gSource)
      )
    )
  )
)
Thanks a bunch alterecco -- that works absoultely wonderfully! :mrgreen:
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I forgot... theShip should be local to the block (otherwise it will be set globally)

Code: Select all

(block (theShip)
  ;; Set ship
  (setq theShip (sysCreateShip &scLincolnAlpha; (objGetPos gSource) &svCommonwealth;))
  (shpSetCommandCode theShip
    (block (target)
      (setq target (sysFindObject gSource "tAN +HellAresOutpost;"))
      (if target
        ;; found a target, attack it
        (shpOrder theShip 'attack target)
        ;; found no target, go home on guard duty
        (shpOrder theShip 'guard gSource)
      )
    )
  )
)
Glad it works... if you look at the code a bit it should also be quite easy to read. It always helps to separate things into small steps.
Post Reply