Data Realms Fan Forums
http://45.55.195.193/

Dropping bombs and other stuff.
http://45.55.195.193/viewtopic.php?f=75&t=17354
Page 1 of 1

Author:  minirobot [ Sat Dec 12, 2009 3:31 pm ]
Post subject:  Dropping bombs and other stuff.

I want to make a dropship that can drop stuff beneath it.

I tried looking at the LUA codes from the UAV and Plane mods but I couldn't get it to work :/ (Most likely because I am still a noob with LUA)

If someone can give me a script for a specific bomb or something it would be great, but a template kind of thing that I can edit to make all kinds of bombs/actors drop beneath the ship would be even better.


I need a script that drops an object (TDExplosive and ACRocket) under a dropship when I press a key.
For example, if I press B a bomb appears under the dropship and if I press G a dropcrate appears.

A plus would be if I could edit the X coordinate of where it spawns (bombs on right side crates on left side or something like that).

Thanks

Author:  MaximDude [ Sat Dec 12, 2009 3:50 pm ]
Post subject:  Re: Dropping bombs and other stuff.

I don't know if this works or no, but it should be something like this:

Code:
function Update(self)
   if(UInputMan:KeyHeld(2)) and (self:IsPlayerControlled()) then -- if player controlled and B button is pressed then
      self.dropbomb = 1
   else
      self.dropbomb = 0
   end
   if self.dropbomb == 1 then
      local bomb = nil;
      bomb = CreateTDExplosive("bomb preset name here"); -- creates your TDExplosive
      bomb.Pos.X = self.Pos.X - #; -- '#' is the X value, '+' means to the left, '-' means to the right
      bomb.Pos.Y = self.Pos.Y + #; -- '#' is the Y value, '+' means below the dropship's center, '-' is above it
      MovableMan:AddParticle(bomb); -- add the particle to the scene
   else
      self.dropbomb = nil;
   end
   if(UInputMan:KeyHeld(7)) and (self:IsPlayerControlled()) then -- if player controlled and G button is pressed then
      self.dropcrate = 1
   else
      self.dropcrate = 0
   end
   if self.dropcrate == 1 then
      local crate = nil;
      crate = CreateACRocket("crate preset name here"); -- creates your ACRocket
      crate.Pos.X = self.Pos.X - #; -- '#' is the X value, '+' means to the left, '-' means to the right
      crate.Pos.Y = self.Pos.Y + #; -- '#' is the Y value, '+' means below the dropship's center, '-' is above it
      MovableMan:AddActor(crate); -- add the particle to the scene
   else
      self.dropcrate = nil;
   end
end

Author:  minirobot [ Sat Dec 12, 2009 4:40 pm ]
Post subject:  Re: Dropping bombs and other stuff.

Yay it is working :D

Included my edited codes if anyone else needs it.

Code:
function Create(self)
   self.DropCrateCD = Timer()
   self.BombCD = Timer()
end

function Update(self)
   if(UInputMan:KeyHeld(2)) and (self:IsPlayerControlled()) and self.BombCD:IsPastSimMS(500) then -- if player controlled and B button is pressed then
      self.dropbomb = 1
   else
      self.dropbomb = 0
   end
   if self.dropbomb == 1 then
      local bomb = nil;
      bomb = CreateTDExplosive("Standard Bomb"); -- creates your TDExplosive
      bomb.Pos.X = self.Pos.X - 0; -- '#' is the X value, '+' means to the left, '-' means to the right
      bomb.Pos.Y = self.Pos.Y + 35; -- '#' is the Y value, '+' means below the dropship's center, '-' is above it
      MovableMan:AddParticle(bomb); -- add the particle to the scene
      self.BombCD:Reset()
   else
      self.dropbomb = nil;
   end
   if(UInputMan:KeyHeld(7)) and (self:IsPlayerControlled()) and self.DropCrateCD:IsPastSimMS(10000) then -- if player controlled and G button is pressed then
      self.dropcrate = 1
   else
      self.dropcrate = 0
   end
   if self.dropcrate == 1 then
      local crate = nil;
      crate = CreateACRocket("Drop Crate"); -- creates your ACRocket
   local actor = CreateAHuman("Dummy");
   actor.Team = self.Team
   actor.AIMode = Actor.AIMODE_SENTRY
   actor:AddInventoryItem(CreateHDFirearm("Blaster" , "Dummy.rte"));
      crate:AddInventoryItem(actor);
      crate.Pos.X = self.Pos.X - 0; -- '#' is the X value, '+' means to the left, '-' means to the right
      crate.Pos.Y = self.Pos.Y + 35; -- '#' is the Y value, '+' means below the dropship's center, '-' is above it
      MovableMan:AddActor(crate); -- add the particle to the scene
      self.DropCrateCD:Reset()
   else
      self.dropcrate = nil;
   end
end

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