View unanswered posts | View active topics It is currently Sun Apr 28, 2024 4:26 pm



Reply to topic  [ 134 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9  Next
 Lua based map objects, help! (BW related) 
Author Message
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Lua based map objects, help! (BW related)
I thought that bullets inherited holder velocity....
Meh, people will just have to get used to doing their barrel rolls carefully...


Wed Apr 29, 2009 1:11 pm
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Hmm, looks like function Update was not capitalized. Hopefully this works.
Code:
function Update(self)
   for actor in MovableMan.Actors do
   local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))
   if diff < 10 then
     diff = 10
         end
           if diff < 1300 then
             local diffx = actor.Pos.X - self.Pos.X
             local diffy = actor.Pos.Y - self.Pos.Y
            local ang2 = math.atan2(self.Vel.Y , self.Vel.X)
            local ang = math.atan2(diffy , diffx)
             if math.abs(ang - ang2) < (math.pi / 2) then
               self.Vel.Y = (self.Vel.Y + (150 / diff * math.sin(ang)))
               self.Vel.X = (self.Vel.X + (150 / diff * math.cos(ang)))
             end
           end
         end
end

It should suck into actors within 600 pixels of it if they are in a 180 degree area in front of the chaser. The shield thing did work I think, it just made the bullets be sucked into it :D
It should now push anything away with a lot of speed, adjust the gravitymultiplier to a smaller value until it's balanced.
Code:
function Update(self)

    for actor in MovableMan.Items do
         local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))
         if diff < 40 then  -- the smaller the value the sharper the bullets turn when they are close
            diff = 40
         end
         if diff < 200 then    --maximum range
            local gravitymultiplier = 200  -- use this to adjust gravity to a fitting value
            local diffx = actor.Pos.X - self.Pos.X
            local diffy = actor.Pos.Y - self.Pos.Y
            local ang = math.atan2(diffy,diffx)
            actor.Vel.Y = -(actor.Vel.Y + ((gravitymultiplier / math.pow(diff,2)) * math.sin(ang)))
            actor.Vel.X = -(actor.Vel.X + ((gravitymultiplier / math.pow(diff,2)) * math.cos(ang)))
         end
   end

    for actor in MovableMan.Particles do
       if (actor.HitsMOs == 1) and ( not(actor.PresetName == "Mercenary Jet Particle 1")) and ( not(actor.PresetName == "Mercenary Jet Particle 2")) and ( not(actor.PresetName == "Mercenary Jet Particle 3")) then
         local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))
         if diff < 40 then  -- the smaller the value the sharper the bullets turn when they are close
            diff = 40
         end
         if diff < 200 then    --maximum range
            local gravitymultiplier = 200  -- use this to adjust gravity to a fitting value
            local diffx = actor.Pos.X - self.Pos.X
            local diffy = actor.Pos.Y - self.Pos.Y
            local ang = math.atan2(diffy,diffx)
            actor.Vel.Y = -(actor.Vel.Y - ((gravitymultiplier / math.pow(diff,2)) * math.sin(ang)))
            actor.Vel.X = -(actor.Vel.X - ((gravitymultiplier / math.pow(diff,2)) * math.cos(ang)))
         end
      end
   end

end


Wed Apr 29, 2009 1:54 pm
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Yeah, I thought that the old code just set the velocity to reverse... well I got it right... yeah...
Anyway, I thought of another thing, how about a field that just teleports rounds to the other side of it?


Wed Apr 29, 2009 2:00 pm
Profile WWW

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
I managed to test the new code out and the chasing plasma balls work, but I dont like how their angle of vision is limited to 180 degrees. They are balls of plasma so its alright if they see always full 360. And then they are quite sluggish while flying. Is there a way to make them home on to something more accurately?

Also I made a new bomb: Blackhole bomb!
It uses to Lua to drag people to it like the vortex bomb and when they enter the blackhole, they are removed from the game.
However, its lagging abnormally alot. It works fine with the following code, but its lagging quite much. Its ment to drag only actors and delete anything that reaches the black hole. Why does it lag so much? D :
Also it doesnt lag constantly, but every other second as slowdown and a brief moment of normal play.

Code:
function Create(self)
end

function Destroy(self)
end

function Update(self)
   --Blackhole. Simply anything that enters into it, is gone for good.
   for particle in MovableMan.Particles do
      if (particle.Pos.X >= self.Pos.X - 75) and (particle.Pos.X <= self.Pos.X + 75) and (particle.Pos.Y >= self.Pos.Y - 76) and (particle.Pos.Y <= self.Pos.Y + 76) and (particle.PinStrength <= 0) then
         particle.Lifetime = 1;
      end
   end
   for actor in MovableMan.Actors do
       if (actor.Pos.X >= self.Pos.X - 75) and (actor.Pos.X <= self.Pos.X + 75) and (actor.Pos.Y >= self.Pos.Y - 76) and (actor.Pos.Y <= self.Pos.Y + 76) then
      actor.Lifetime = 1;
       end
   end
   for item in MovableMan.Items do
      if (item.Pos.X >= self.Pos.X - 75) and (item.Pos.X <= self.Pos.X + 75) and (item.Pos.Y >= self.Pos.Y - 76) and (item.Pos.Y <= self.Pos.Y + 76) then
       item.Lifetime = 1;
      end
   end

   --This next bit sucks in people within a certain range into the center of the hole.
   for actor in MovableMan.Actors do
      local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))
      if diff < 30 then
         diff = 30
      end
      if diff < 400 then
         local diffx = actor.Pos.X - self.Pos.X
         local diffy = actor.Pos.Y - self.Pos.Y
         local ang = math.atan2(diffy,diffx)
         actor.Vel.Y = actor.Vel.Y - (50 / diff * math.sin(ang))
         actor.Vel.X = actor.Vel.X - (100 / diff * math.cos(ang))
      end
   end

end


Wed Apr 29, 2009 5:34 pm
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Lua based map objects, help! (BW related)
To make it home more accuratedly, changing the field of view from 180 to 90 works. The problem is that instead of actually homing, they are gravitated towards actors. So if there are two actors a hundred pixels apart, it will home between them, not towards one or the other. Having a smaller angle means the other is likely to be ignored and it will hit the other.
If the plasmaballs are destroyed on impact you could have the create function save an actor presetname that's within it's range and then have it gravitate towards actors with that presetname only, but that would be kinda hacky.
Another method is to tweak the gravitating code so that the gravity will get smaller more quickly and you would have a more accurate plasmathing which would home very little if the distance is longer. I'll try this since it's easy to do with scene lua.

Edit: After some fiddling I noticed that having the plasmaballs have a drunken path and a field of view of 90 degrees causes them to wander around aimlessly until they see a target and smash it. Gif:Image


Wed Apr 29, 2009 7:46 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Gravitate? No wonder they were so wierd on locking on the target.

I was thinking something along the lines of "slowly move to nearest actor within 600 pixels from the plasma ball".

The plasma balls are invincible emitters that constantly emit deadly particles. They cant be shot at and they cant hit anyone. They do however, explode when their time runs out, but thats another thing. So these emitters can move into an actor, tear him up and then find a next nearest guy and continue to them. "Them" includes you too, so you must know when to use this grenade.

So how the plasma chaser grenade supposed to work:
1. After 100 ms(Timer) has passed, begin moving towards the nearest actor within 600 pixels. The delay is for the balls to allow to spread a little.
2. Continue chasing nearest actors in 600px. Speed can be a preset to something slow like 15.
3. At 6500ms, gib self.


Wed Apr 29, 2009 8:54 pm
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Lua based map objects, help! (BW related)
numgun wrote:
nearest actor

That's the problem. If there was some other ID than presetname to actors this wouldn't be hard. Maybe I could do it with some table fiddling, dunno.


Wed Apr 29, 2009 9:37 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
piipu wrote:
numgun wrote:
nearest actor

That's the problem. If there was some other ID than presetname to actors this wouldn't be hard. Maybe I could do it with some table fiddling, dunno.


Eh what? Cant one just make it fly at something that is an actor? It would check any actor within the range and randomly just home on to one of them if there are many.

EDIT: Btw good news, I managed to make the blackhole lagless.
It appears I had the blackhole and its area of effect way too large.
So looks like its a good idea to keep the radius small.


Wed Apr 29, 2009 10:07 pm
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Lua based map objects, help! (BW related)
numgun wrote:
No they shouldnt. I usually place the muzzleoffset a couple pixels forward where the actual barrel is and then adjust the flash with that. I'm just thinking if youre moving too fast or youre rolling barrels which you'll be doing suprisingly often in a deathmatch you might accidently shoot at your foot.

mmn, that is really annoying when that happens, so id prefer it if it didnt. if it was only for a few weapons that would be okay i suppose..
for the blackhole, you should make it pump all of the mass it sucked in back out again after the effect has vanished, everything just vanishing would be a little underwhelming.. also, would it be possible for you to add a black MOSP effect of a ball shrinking down to nothing when something was sucked in, for some visual fun? make the MOSP move towards the singularity (center of the black hole) as well, if possible..
glad self.GibThis() works, im going to be making some good proxy mines next build by the look of it.


Thu Apr 30, 2009 1:09 am
Profile WWW

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Hmm yes, good suggestion, I'll make it blast out a large black shockwave and a large white glow flash upon end of the blackhole. The whole bomb is pretty much classified a superweapon btw.
Its pretty hilarious if you drop it in a very open place where the enemy usually lands, all the dropships get sucked in and go poof.

Also after further playtesting, the repeller just didnt seem right since theres already the slowmo field bomb that pretty much stops things and has a larger range. So I talked with TLB and we came up with a funny switching teleport bomb.
It takes a random actor on the scene and teleports it near or even inside another random actor.

Except that wasnt intended, the real idea of it was to make it switch places between 2 random actors. Any idea how to achieve that?
Just find 2 random actors on the scene and switch their locations.

Code:
function Destroy(self)
    local list = {};
    for actor in MovableMan.Actors do
   list[#list+1] = actor;
    end
    local a = list[math.random(#list)];
    local b = list[math.random(#list)];
    while b.ID == a.ID do
   b = list[math.random(#list)];
    end
    if MovableMan:IsActor(a) and MovableMan:IsActor(b) then
   local posA = a.Pos;
   local posB = b.Pos;
   a.Pos = posB;
   b.Pos = posA;
    end
end


Thu Apr 30, 2009 8:35 am
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Would that do it fast enough for there to be no issues with the two actors being in exactly the same place?

Also, I have another idea: a weapon that, when it hits an actor, causes any particlese in the vicinity gravitate to them. It'd make them easier to hit, take the brunt of explosions and increase the damage of well aimed shots.


Thu Apr 30, 2009 8:48 am
Profile WWW
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Lua based map objects, help! (BW related)
numgun wrote:
Hmm yes, good suggestion, I'll make it blast out a large black shockwave and a large white glow flash upon end of the blackhole. The whole bomb is pretty much classified a superweapon btw.
Its pretty hilarious if you drop it in a very open place where the enemy usually lands, all the dropships get sucked in and go poof.

Also after further playtesting, the repeller just didnt seem right since theres already the slowmo field bomb that pretty much stops things and has a larger range. So I talked with TLB and we came up with a funny switching teleport bomb.
It takes a random actor on the scene and teleports it near or even inside another random actor.

Except that wasnt intended, the real idea of it was to make it switch places between 2 random actors. Any idea how to achieve that?
Just find 2 random actors on the scene and switch their locations.

Code:
function Destroy(self)
    local list = {};
    for actor in MovableMan.Actors do
   list[#list+1] = actor;
    end
    local a = list[math.random(#list)];
    local b = list[math.random(#list)];
    while b.ID == a.ID do
   b = list[math.random(#list)];
    end
    if MovableMan:IsActor(a) and MovableMan:IsActor(b) then
   local posA = a.Pos;
   local posB = b.Pos;
   a.Pos = posB;
   b.Pos = posA;
    end
end


I think it has to do with how everything in lua is a pointer.
So I have it make a new vector position.
Try:
Code:
function Destroy(self)
    local list = {};
    for actor in MovableMan.Actors do
   list[#list+1] = actor;
    end
    local a = list[math.random(#list)];
    local b = list[math.random(#list)];
    while b.ID == a.ID do
   b = list[math.random(#list)];
    end
    if MovableMan:IsActor(a) and MovableMan:IsActor(b) then
   local posA = Vector(a.Pos.X,a.Pos.Y);
   local posB = Vector(b.Pos.X,b.Pos.Y);
   a.Pos = posB;
   b.Pos = posA;
    end
end


Thu Apr 30, 2009 9:15 am
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
The script crashes the game if there is only 1 actor on the scene. :-(
Aka if nothing to teleport, it goes bananas.


Thu Apr 30, 2009 3:45 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Oh, I forgot:
Code:
function Destroy(self)
    local list = {};
    for actor in MovableMan.Actors do
   list[#list+1] = actor;
    end
    if #list > 1
    then
    local a = list[math.random(#list)];
    local b = list[math.random(#list)];
    while b.ID == a.ID do
   b = list[math.random(#list)];
    end
    if MovableMan:IsActor(a) and MovableMan:IsActor(b) then
   local posA = Vector(a.Pos.X,a.Pos.Y);
   local posB = Vector(b.Pos.X,b.Pos.Y);
   a.Pos = posB;
   b.Pos = posA;
   end
    end


Fri May 01, 2009 6:12 am
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Alright, everything works like it should but a couple problems have arisen:

The accelerator device which is ment to accelerate particles like bullets and bomb/missiles(for increased damage) is affecting terrain particles too. How to prevent it from affecting terrain debris?

See the following picture to see what I mean. I shoot and the terrain debris that are knocked loose start accelerating and bouncing like there's no tommorow:

Image

Code:

Code:
function Create(self)
end

function Destroy(self)
end

function Update(self)
   --Particle accelerator.
    --Any particle or item traveling through this module gets its velocity multiplied by 6. :D
   --for item in MovableMan.Items do
   --   if (item.Pos.X >= self.Pos.X - 24) and (item.Pos.X <= self.Pos.X + 24) and (item.Pos.Y >= self.Pos.Y - 25) and (item.Pos.Y <= self.Pos.Y + 25) and (item.PinStrength <= 0) then
   --   item.Vel.Y = (item.Vel.Y * 1.4);
   --   item.Vel.X = (item.Vel.X * 1.4);
   --   end
   --end
   for particle in MovableMan.Particles do
      if (particle.Pos.X >= self.Pos.X - 24) and (particle.Pos.X <= self.Pos.X + 24) and (particle.Pos.Y >= self.Pos.Y - 25) and (particle.Pos.Y <= self.Pos.Y + 25) and (particle.PinStrength <= 0) and (particle.HitsMOs == 1) then
      particle.Vel.Y = (particle.Vel.Y * 6);
      particle.Vel.X = (particle.Vel.X * 6);
      end
   end
end




Then another small thing, how do I make the intensity of the pull more powerful on the blackhole grenade?
Which of these variables control the power of pull?

Code:
   --This next bit sucks in people within a certain range into the center of the hole.
   for actor in MovableMan.Actors do
      local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))
      if diff < 30 then
         diff = 30
      end
      if diff < 700 then
         local diffx = actor.Pos.X - self.Pos.X
         local diffy = actor.Pos.Y - self.Pos.Y
         local ang = math.atan2(diffy,diffx)
         actor.Vel.Y = actor.Vel.Y - (50 / diff * math.sin(ang))
         actor.Vel.X = actor.Vel.X - (100 / diff * math.cos(ang))
      end
   end
   if self.LTimer:IsPastSimMS(24000) then
      self:GibThis() ;
   end


Mon May 04, 2009 12:33 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 134 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9  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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.067s | 15 Queries | GZIP : Off ]