View unanswered posts | View active topics It is currently Fri Dec 27, 2024 1:28 pm



Reply to topic  [ 3 posts ] 
 Dropping bombs and other stuff. 
Author Message

Joined: Wed Apr 11, 2007 5:34 pm
Posts: 22
Reply with quote
Post 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


Sat Dec 12, 2009 3:31 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post 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


Sat Dec 12, 2009 3:50 pm
Profile

Joined: Wed Apr 11, 2007 5:34 pm
Posts: 22
Reply with quote
Post 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


Sat Dec 12, 2009 4:40 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.043s | 15 Queries | GZIP : Off ]