Data Realms Fan Forums
http://45.55.195.193/

How to create a script to spawn a dropship?
http://45.55.195.193/viewtopic.php?f=73&t=45116
Page 1 of 1

Author:  nubbles [ Thu Feb 07, 2013 6:34 am ]
Post subject:  How to create a script to spawn a dropship?

I'm attempting to make a grenade that when thrown spawns a dropship loaded with two actors in it above it. I can't get it to do anything, at all, though.

Here's what i have so far...

Code:
function Update(self)
   if self.Fuze then
      if self.Fuze:IsPastSimMS(2000) then
         local Dropship = CreateACDropShip("Drop Ship MK1")
         local soldiera = CreateAHuman("Coalition Light", "Coalition.rte")
         soldiera:AddInventoryItem(CreateHDFirearm("Assault Rifle", "Coalition.rte"));
         soldiera:AddInventoryItem(CreateHDFirearm("Auto Pistol", Coalition.rte"));
         Dropship:AddInventoryItem(soldiera)
         local soldierb = CreateAHuman("Coalition Light", "Coalition.rte")
         soldierb:AddInventoryItem(RandomHDFirearm("Assault Rifle", "Coalition.rte"));
         soldierb:AddInventoryItem(RandomHDFirearm("Auto Pistol", "Coalition.rte"));
         Dropship:AddInventoryItem(soldierb)
         if Dropship then
            Dropship.Pos = Vector(self.Pos.X,0)
            MovableMan:AddActor(Dropship)
         end
         
         self:GibThis()
      end
   elseif self:IsActivated() then
      self.Fuze = Timer()
   end
end

Author:  Grimmcrypt [ Thu Feb 07, 2013 8:58 pm ]
Post subject:  Re: How to create a script to spawn a dropship?

. :skull: .

nubbles wrote:
I'm attempting to make a grenade that when thrown spawns a dropship loaded with two actors in it above it. I can't get it to do anything, at all, though.

Here's what i have so far...

Code:
function Update(self)
   if self.Fuze then
      if self.Fuze:IsPastSimMS(2000) then
         local Dropship = CreateACDropShip("Drop Ship MK1")
         local soldiera = CreateAHuman("Coalition Light", "Coalition.rte")
         soldiera:AddInventoryItem(CreateHDFirearm("Assault Rifle", "Coalition.rte"));
         soldiera:AddInventoryItem(CreateHDFirearm("Auto Pistol", Coalition.rte"));
         Dropship:AddInventoryItem(soldiera)
         local soldierb = CreateAHuman("Coalition Light", "Coalition.rte")
         soldierb:AddInventoryItem(RandomHDFirearm("Assault Rifle", "Coalition.rte"));
         soldierb:AddInventoryItem(RandomHDFirearm("Auto Pistol", "Coalition.rte"));
         Dropship:AddInventoryItem(soldierb)
         if Dropship then
            Dropship.Pos = Vector(self.Pos.X,0)
            MovableMan:AddActor(Dropship)
         end
         
         self:GibThis()
      end
   elseif self:IsActivated() then
      self.Fuze = Timer()
   end
end


I'm not to sure about the .lua but I believe that the actors can be added to the dropship in the .ini if you created a copy of the dropship that is not buyable. it should make coding it easier. cause all you would need to create would be the dropship. again i'm not to sure about lua but I think that you need to set the Y vector. cause if not the ship would spawn directly on your grenade.( I can't tell if its that peace of code you got there Dropship.Pos = Vector(self.Pos.X,0))

Also I believe there is a faction called Oni corps or tech(I think thats the name, I know there red and look like duke nukem pigs) that has a grenade beacon that spawns a drop-pod with a actor in it. You should take a look at it.

. :skull: .

Author:  nubbles [ Sun Feb 10, 2013 5:05 am ]
Post subject:  Re: How to create a script to spawn a dropship?

I got it working. Here's the finished script.
Code:
function Update(self)
   local theHolder = MovableMan:GetMOFromID(self.RootID)
   if MovableMan:IsActor(theHolder) then
      self.holder = theHolder;
   end
   if self.Fuze then
      if self.Fuze:IsPastSimMS(2000) then
         local Dropship = CreateACDropShip("Drop Ship MK1")
         local soldierb = CreateAHuman("Soldier Light", "Coalition.rte")
         soldierb:AddInventoryItem(CreateHDFirearm("Assault Rifle", "Coalition.rte"));
         soldierb:AddInventoryItem(CreateHDFirearm("Auto Pistol", "Coalition.rte"));
         Dropship:AddInventoryItem(soldierb)
         local secondsoldier = CreateAHuman("Soldier Light", "Coalition.rte")
         secondsoldier:AddInventoryItem(CreateHDFirearm("Assault Rifle", "Coalition.rte"));
         secondsoldier:AddInventoryItem(CreateHDFirearm("Auto Pistol", "Coalition.rte"));
         Dropship:AddInventoryItem(secondsoldier)
         if Dropship then
            Dropship.Pos = Vector(self.Pos.X,0)
            Dropship.Team = self.holder.Team
            MovableMan:AddActor(Dropship)
         end

         self:GibThis()
      end
   elseif self:IsActivated() then
      self.Fuze = Timer()
   end
end

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/