help.. again please.

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

help.. again please.

Post by incarn » Wed, 9. Feb 11, 11:30

I am spawning in a ship purely with the desire of having it fire a single missile and then disappear.

This is the spawning script

Code: Select all

$enemy = [PLAYERSHIP]->find nearest enemy ship: max.dist=1000000
$curtarget = get player tracking aim

if $enemy->exists
  if not $enemy == $curtarget
    set player tracking aim to $enemy
  end
end

$victim = [PLAYERSHIP]->find nearest enemy ship: max.dist=10000

$victim=$curtarget

if $victim->exists
  
  $pmissile = [PLAYERSHIP]->find best missile for target $victim
  skip if not $pmissile == {Boarding Pod}
    $pmissile = null
  
  if $pmissile
    $sector=[PLAYERSHIP]->get sector
    
    $px=[PLAYERSHIP]-> get x position
    $py=[PLAYERSHIP]-> get y position
    $pz=[PLAYERSHIP]-> get z position
    
    $ex=$victim-> get x position
    $ey=$victim-> get y position
    $ez=$victim-> get z position
    
    $x=$px+($ex-$px)/5
    $y=$py+($ey-$py)/5
    $z=$pz+($ez-$pz)/5
    
    $drone= create ship: type={Argon Buster Vanguard} owner={player} addto= $sector x=$x y=$y z=$z
    $drone->ignore collisions:[TRUE]
    $drone -> force position: x=$x y=$y z=$z
    
    * FIRE AND REFILL MISSILE
    *if [PLAYERSHIP]->is missile $pmissile ready to fire
    *end
    
    
    = $drone->add 1 units of $pmissile
    $drone->set local variable: name='missile' value=$pmissile
    $drone->set local variable: name='victim' value=$victim
    =$drone->call script 'jr.missilearm' :
    
  end
  
end

return null

And this is the firing script

Code: Select all


$missile=[THIS]->get local variable: name='missile'
$victim=[THIS]->get local variable: name='victim'

=[THIS]->fire missile $missile on $victim

$text = 'Firing ' + $missile + ' on ' + $victim
display subtitle text: text=$text duration=1000 ms

return null

I tried doing it in one script but that didn't make any difference.
the subtitle shows the missile to be used and the correct target, but the drone never actually fires a missile.

I have modified the Buster Vanguard to be able to mount any/every missle.

I can jump out of my ship and into one of the drones, and manually fire the missile fine.

BTW, I have deliberately over-ridden the closest enemy detection in favour of the current target for testing only, as well as the bit of the script that removes the drone afterwards.

ideas?

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Wed, 9. Feb 11, 11:38

Its possible that 'missile' is set to an object type of "SSTYPE_MISSILE" insted of "SSTYPE_W_*"(Probably SSTYPE_W_TECH in this case), in witch case it needs to be converted first before the fire command is given as it expects a "Ware" to be given and not a "Missile"

try this:

Code: Select all


$missile=[THIS]->get local variable: name='missile'
$victim=[THIS]->get local variable: name='victim'

*Convert "$missile" from "Missile" to "Ware"
$missile = $missile -> get ware type code of object


=[THIS]->fire missile $missile on $victim 

This is just off the top of my head, ive had similar issues in the past - i haven't had any time to test the theory however
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Wed, 9. Feb 11, 11:55

Thanks for the attempt jack, I tried your suggestion but no good.

I have even modified it such

Code: Select all

$victim=[THIS]->get local variable: name='victim'
$missile = [THIS]->find best missile for target $victim
=[THIS]->fire missile $missile on $victim

$text = 'Firing ' + $missile + ' on ' + $victim
display subtitle text: text=$text duration=1000 ms

return null
And again it reports that is selected the correct (and only) missile but still it is not firing it.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Wed, 9. Feb 11, 12:22

Try the START tag with the call script instruction or replace it with the "Start script on task (0)" instruction.
A script call usually puts the script on the stack on top of the curent script and on the exact same object.

Your debug message does not say which object is trying to fire the missile.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Wed, 9. Feb 11, 12:28

The script is firing as the subtitle text shows the correct target and missile.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Wed, 9. Feb 11, 16:43

Gazz wrote:Your debug message does not say which object is trying to fire the missile.
It's important.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Wed, 9. Feb 11, 23:01

Hmm, that is true, but.

Code: Select all

=[THIS]->fire missile $missile on $victim 

$text = 'Firing ' + $missile + ' on ' + $victim 
display subtitle text: text=$text duration=1000 ms
The '[THIS]' that is running this script is the $drone.
If it were not, after all it could not get the correct $victim to report as it is pulling it from

Code: Select all

$victim=[THIS]->get local variable: name='victim'
I will however add $drone to my debug message anyway when I get home today.

User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Wed, 9. Feb 11, 23:22

I think there's two fire missile commands. One specifies a turret. You might want to give that a go as well, firing from turret 0.

The second thing I'd try is setting the active missile first. But I'd doubt that would make a difference.

I don't think START should make a difference here, but I'd do it anyway, so your playership can return control ASAP.

Get a read out of [THIS] on your debug flag. Just as a precaution.

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Wed, 9. Feb 11, 23:28

When I jump into one of the drones the missile is selected and ready to fire, as I can just use missile fire key and it fires fine.

The other missile command is something like check, select and fire at $victim. No turret selection, not that it should be firing from a turret though?

On the playership I don't seem to need to set the missile as active, but I would like to, what is the command to set the active missile?

User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Wed, 9. Feb 11, 23:33

Code: Select all

<RetVar/IF> <RefObj> -> fire missile <Var/Ware> from turret <Var/Number> on <Value>

I lied about setting the active missile. Buy an install command would do it. I'd ignore this little bit of advice for now, however. It shouldn't be required.

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Thu, 10. Feb 11, 07:27

Well I tried Gazz's suggestion.
It is definitely the created drone 'saying' it is about to fire the right missile on the right target.
But yet, no missile is fired.

Anyone else got an idea?

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Thu, 10. Feb 11, 08:36

Try to do
$ship -> set missile firing time difference to 0
Just before you fire


(Recharge time for missile essentially) (This is from my memory, so I could be spelling it incorrectly)



Also one minor suggestion

Rather then doing
if exists
..
..huge block of code
..
end
return null


Consider doing

if not exists
return
end
..
huge block of code
..

(Makes debugging easier when your code becomes larger and more complex)

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Thu, 10. Feb 11, 08:58

Thanks for that suggestion s9ilent and the formatting pointer (both of which I have now used).
Unfortunately still no missile firing. :(

Any other good ideas?

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Thu, 10. Feb 11, 09:08

So just to confirm, your firing script now looks something like:


$missile=[THIS]->get local variable: name='missile'
$victim=[THIS]->get local variable: name='victim'


[this] -> set missile firing time difference
=[THIS]->fire missile $missile on $victim

$text = 'Firing ' + $missile + ' on ' + $victim
display subtitle text: text=$text duration=1000 ms

return null



And you get the subtitle, (the missile and the victim are both non null)
And are you doing the START as gazz had mentioned?

(Perhaps update your OP with your new scripts)

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Thu, 10. Feb 11, 09:14

yeppers, been taking on the suggestions as they come.

Code: Select all

START = $drone->call script 'jr.missilearm' :

Code: Select all

$victim = [THIS]->get local variable: name='victim'
$missile = [THIS]->find best missile for target $victim

[THIS] -> set fire missile time difference to 0ms

= [THIS]->fire missile $missile on $victim

$text = [THIS] +' is Firing a ' + $missile + ' at ' + $victim
display subtitle text: text=$text duration=1000 ms

return null

debug text showing exactly what should be happening, ie buster etc firing a beluga on currect target.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Thu, 10. Feb 11, 12:06

The refire duration was already mentioned but it might take a wait after creation and installing the missile for the ship to become "ready to fire".
Freshly installed lasers start in the ready state. Missiles... I dunno.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Thu, 10. Feb 11, 12:11

Lit's solution of fire missile from turret did the trick.

Thanks very much everyone for your help.

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Thu, 10. Feb 11, 12:21

Just one more quick question:

The missile that it chose, is the argon buster capable of

1) holding onto the missile (xl,l,m,s, etc.)
2) Is it capable of firing it?


Otherwise I'm completely stumped :S

*Edit, count fail*
And by one.. I meant two

incarn
Posts: 38
Joined: Sat, 11. Sep 10, 03:51

Post by incarn » Thu, 10. Feb 11, 12:28

Thanks for your help s9ilent, apparently i just needed to use the fire from turret command.
Btw, i modified the buster vanguard to be able to mount any missile.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”