Jump to content

killing spawned ships won't get rid of them

Recommended Posts

Hi , I have spawned a couple of ships using MOOSE engine. 

I kill the ships off and a message comes up saying they are 70% 80% 90% and then it says the ship is destroyed.  So after finding out the ship is still there after the message!!  All of it works fine until I kill one off.  Anyhow, here is the code that I use to spawn the ships .




redShipAsciiChrIndex = randmathORos(3, 2)
redShipSpawnName = "RedShipSpawn" ..string.char(64+redShipAsciiChrIndex) 
Spawn_VehicleTemp = SPAWN:New(redShipSpawnName) 
      :InitLimit( 1, 5 )
      :InitRandomizeRoute( 1, 11, 550 )
      :InitRandomizeTemplate(redShipTemplateTbl) -- the other choice is  --:InitRandomizeZones( ZoneTable )
      :SpawnScheduled( 3 + ii, .5 )





 I Now  am trying to destroy the ship using a Handler to the unit . here is my code based on the examples I found based on Handlers. 


-- here we are creating handlers to some enemy ships  --needs to be declared ahead of their handler functions??
-- code below this came from eds forums, it is setup first for UNIT SET 
RedShip1 = UNIT:FindByName( "RedShipSpawnA" )  

RedShip2 = UNIT:FindByName( "RedShipSpawnB" )

RedShip3 = UNIT:FindByName( "RedShipSpawnC" )  


 -- and Here we subscribe to the Dead events. So, if one of these Ships dies, the RedShip1 or RedShip2 objects will be notified.
 RedShip1:HandleEvent( EVENTS.Dead )

RedShip2:HandleEvent( EVENTS.Dead )

 RedShip3:HandleEvent( EVENTS.Dead )

-- the functions to kill of the ship  are here (off the sample at ed forums)

--- This function is an Event Handling function that will be called when Ship1 is Dead.
 -- @param Wrapper.Unit#UNIT self  

-- @param Core.Event#EVENTDATA EventData
 function RedShip1:OnEventDead( EventData )


 --- function that will be called when Ship2 is Dead.
 -- @param Wrapper.Unit#UNIT self  -- @param Core.Event#EVENTDATA EventData
 function RedShip2:OnEventDead( EventData )


 --- function that will be called when Ship3 is Dead.
function RedShip3:OnEventDead( EventData )

   self:Destroy() --die die die go away !!!!!



So what did I do wrong ,why aren't the ships being removed from the map after they are killed. I know I keep telling 'em to...!!!




Edited by Lineaxe
Link to post
Share on other sites

I had been wondering if I am killing of the Spawn template and should be killing off the actual ship , by name,  or something else?? 


Now the ship objects that Tacview shows are very strange as well. You see, Tacview shows the others ships from the table that did not get selected-- and they are moving along some pathways. They even go through the mountains. hehehe. So , is that some kinda bug somewhere as well. But they do not show up while playing the game , so that doesn't really bother me , it's just something to note.      


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...