View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:44 am



Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next
 I need help with a script I am making 
Author Message
User avatar

Joined: Sun Aug 09, 2009 9:26 am
Posts: 1633
Reply with quote
Post Re: I need help with a script I am making
Holy crap, that's a lot of explosions. You'll have to work on a way to avoid damage to the Punisher holding the gun. Maybe use a Lua script that detects who fired the original emitter, and get their aim angle for the rounds? I don't know any Lua though, so not sure if this is possible.


Tue Jan 19, 2010 2:26 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: I need help with a script I am making
PhantomAGN wrote:
This is THE best fail ever.

Lua gone ABSOLUTELY RIGHT.


Tue Jan 19, 2010 4:34 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: I need help with a script I am making
Keep the code, make a suicide tool.
Maybe toss in a
Code:
self:SetWhichMOToNotHit(parent,-1)

somewhere.


Tue Jan 19, 2010 4:35 am
Profile
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: I need help with a script I am making
Benpasko wrote:
Maybe use a Lua script that detects who fired the original emitter, and get their aim angle for the rounds? I don't know any Lua though, so not sure if this is possible.
That's exactly what I coded it to do, but it fails.
Still not sure why it's not working.
I'm sending my revisions back in now, I'll return to this later tonight.


Tue Jan 19, 2010 5:31 am
Profile
User avatar

Joined: Sun Aug 09, 2009 9:26 am
Posts: 1633
Reply with quote
Post Re: I need help with a script I am making
Do the subsequent laser blasts also track parent aim angle? Like, maybe the first one is going in the direction you aim, but the rest just switch to horizontal?


Tue Jan 19, 2010 5:38 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: I need help with a script I am making
This should do the trick.

Edit: Made it better.

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.weaponname = "LAZER GUN PRESETNAME";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   local lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   local lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, lazerlength do
   self.lazerpar = CreateMOPixel(self.lazerparname,self.modulename); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


Tue Jan 19, 2010 12:34 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
CaveCricket48 wrote:
This should do the trick.

Edit: Made it better.

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.weaponname = "LAZER GUN PRESETNAME";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   local lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   local lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, lazerlength do
   self.lazerpar = CreateMOPixel(self.lazerparname,self.modulename); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


I can't get it to work :/

Error on line 24 near 'shot'

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.weaponname = "Justice";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   local lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   local lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, lazerlength do
   self.lazerpar = CreateMOPixel(Justice Shot); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


Tue Jan 19, 2010 9:37 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: I need help with a script I am making
That would be "Justice Shot", with the quotation marks. I forgot to change the example name.


Tue Jan 19, 2010 9:43 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
CaveCricket48 wrote:
That would be "Justice Shot", with the quotation marks. I forgot to change the example name.


Well now it gives me "Justice.lua:23: 'for' limit must be a number"


Tue Jan 19, 2010 9:46 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: I need help with a script I am making
Bleh. Try this:

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.weaponname = "Justice";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   local self.lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   local self.lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, self.lazerlength do
   self.lazerpar = CreateMOPixel("Justice Shot"); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


Tue Jan 19, 2010 9:50 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
CaveCricket48 wrote:
Bleh. Try this:

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.weaponname = "Justice";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   local self.lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   local self.lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, self.lazerlength do
   self.lazerpar = CreateMOPixel("Justice Shot"); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


Line 18: unexpected symbol near "." :-(


Tue Jan 19, 2010 9:54 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: I need help with a script I am making
I'm so silly.

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.weaponname = "Justice";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   self.lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   self.lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, self.lazerlength do
   self.lazerpar = CreateMOPixel("Justice Shot"); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


Tue Jan 19, 2010 10:32 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
Awesome, it works perfectly :D

However, could you add a variable to determine how fast they are moving? I want them to be moving forward when fired as well as appearing that distance out.


Tue Jan 19, 2010 10:42 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: I need help with a script I am making
Here.

Code:
function Create(self)
   self.mapwrapx = SceneMan.SceneWrapsX;
   self.maxlazerlength = 500;
   self.parspeed = 10 -- SPEED OF PARTICLE HERE
   self.weaponname = "Justice";

   local curdist = 50;
   for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);

   local terrcheck = Vector(0,0);
   local terrainray = SceneMan:CastStrengthRay(self.parentgun.MuzzlePos,Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true)),0,terrcheck,4,0,true)
      if terrainray == true then
   self.lazerlength = math.floor(SceneMan:ShortestDistance(self.parentgun.MuzzlePos,terrcheck,self.mapwrapx).Magnitude/10)
      else
   self.lazerlength = math.floor(self.maxlazerlength/10);
      end

      for i = 1, self.lazerlength do
   self.lazerpar = CreateMOPixel("Justice Shot"); -- CHANGE THIS TO YOUR PARTICLE
   self.lazerpar.Pos = self.parentgun.MuzzlePos + Vector(i*10,0):RadRotate(self.parent:GetAimAngle(true));
   self.lazerpar.Vel = Vector(self.parspeed,0):RadRotate(self.parent:GetAimAngle(true));
   MovableMan:AddParticle(self.lazerpar);
      end

     end
    end
   end

end


Tue Jan 19, 2010 10:49 pm
Profile
User avatar

Joined: Sat Nov 18, 2006 8:11 pm
Posts: 267
Reply with quote
Post Re: I need help with a script I am making
Awesome, thanks :D

Now I just have to wait for some sprites back from Maxim and I will be ready to release soon

One question though, what part of the script determines how many objects spawn?


Tue Jan 19, 2010 10:57 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 32 posts ]  Go to page Previous  1, 2, 3  Next

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.076s | 13 Queries | GZIP : Off ]