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



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

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Lua based map objects, help! (BW related)
piipu wrote:
You could cut half the code off just by using _teleporter[math.rand(1,#_teleporter)] as the target. I'll see about that after school, I don't have time right now.


If you don't mind accidentally warping back to the same teleporter(you might telefrag your self).

Actually, just state that the teleporter is unreliable.


Tue Apr 21, 2009 7:46 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)
Just say it teleports a bit at a time with slight continued momentum, therefore spawning part of you inside part of you, destroying you...
anyway, you could also say that in order to teleport more safely momentum is dampened, thus explaining why you wouldn't persist momentum when using one...


Tue Apr 21, 2009 8:15 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)
Mmm no thanks, telefragging yourself would be very annoying in a deathmatch where youre either just wanting to teleport to find someone or escaping from death. You run at the teleport thinking "Soon I'll be safe!" but all you get is some fudge goresplatter.

Maybe the telefragging might be unnecesary after all, no?

It already risky to use a teleport when you must wait for 3 seconds it to teleport you and the fact you'll be teleported to a random teleport so there might be another player ready fire his rocket launcher if you land in the "wrong" teleport.

I say we forget about the telefragging part, and make sure it simply teleports the actor to random teleport after a 3 second delay.


EDIT: I just made a new item: A killzone!

Image

It works well with actors, but items seem unaffected.
Is there something wrong with this code:

Code:
function Create(self)
    x = self;
end

function Destroy(self)

end

function Update(self)
    --First checks whether an actor or an item is within the box and then gibs them.
   for actor in MovableMan.Actors do
       if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then
      actor:GibThis() ;
       end
   end
   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) then
      item:GibThis() ;
       end
   end
end


It says that the line "item:GibThis() ;" is wrong for some reason. Is this statement even valid?

Besides that, I was thinking of making 2 more killzones. One only destroys items, and the second one destroys only actors. this could make some interesting maps and tactics.


Tue Apr 21, 2009 8:15 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)
Interesting...
Would a killzone for MOSRotatings or other particles be possible? That would lead to some even more interesting tactics... not to mention the ability to make a zone where body parts disappear immediately...


Tue Apr 21, 2009 10:04 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)
Another new item! Regenerator!

Image

If your guy is damaged, this thing will super charge your hp to 200!
But... the point was to make it heal damaged limbs. TLB made that by respawning the entire actor and re-assigning all his equipment from scratch.(The coalition base mission made by TLB) This needs a much more simple method of doing that.

Right now it just checks if an actor inside it has less than 100 hp and the recharge timer has already passed 10 seconds. then it will simply assign him 200hp points.

Heres the code on what I did with a little copypasta from here and there:

Code:
function Create(self)
   x = self;
   regenchargetimer = Timer()
   regencharge = 15000 --10 sec recharge per healing
end

function Destroy(self)

end



function Update(self)
   --First checks whether an actor or an item is within the box and then heals them.
   --NOTE: This wont heal busted limbs or wounds. Only the health count. Gibbing may be imminent even if the player got charged to 100 hp.
   for actor in MovableMan.Actors do
      if (regenchargetimer:IsPastSimMS(regencharge)) and (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.Health < 100) then
         actor.Health = 200;
         regenchargetimer:Reset()


      end
   end
end



It needs to respawn the actor so its totally fresh with 100hp and all wounds and limbs healed, but also let him keep his equipment he had with him. How do you code that?


Tue Apr 21, 2009 12:06 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)
K, no fancy telefragging and shorter. Hopefully this will work. Debugging stuff via the forums is damn slow :c
Code:
function Create(self)
    if (not_teleporters) then
         _teleporters = {self}
    else
        table.insert(_teleporters,self)
    end
    self.teledelaytimer = Timer();
   self.teleactivate = nil;
end

function Destroy(self)
    table.remove(_teleporters,self)
end


function Update(self)
   if(#_teleporters > 1) then
    for actor in MovableMan.Actors do
      if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then
         if MovableMan:IsParticle(self.teleactivate) == false then
            self.teleactivate = CreateAEmitter("Teleport Activation");
            self.teleactivate:EnableEmission(true);
            self.teleactivate.Pos = Vector(0,0);
            MovableMan:AddParticle(self.teleactivate);
         else
          if self.teledelaytimer:IsPastSimMS(3000) then
         --TELEPORTATION HAPPENS HERE
                    local i = math.rand(1,#_teleporters)
           actor.Pos = _teleporters[i].Pos
           self.teledelaytimer:Reset();
           self.teleactivate.Lifetime = 1;
          end
         end
      end   
   end
end

Also, whatever:GibThis() works only on actors, so you can't make killzones for other stuff as far as I know. Can't think of any way of saving the actor's inventory either. You could gib the actor and set all particles' lifetimes to 1 in the area so that the gibs would disappear and respawn the actor so that his gear would be on the ground, but that's pretty hacky.
edit: added else and an end there.


Tue Apr 21, 2009 2:35 pm
Profile
User avatar

Joined: Thu Feb 12, 2009 1:47 am
Posts: 1182
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Use the IRC then.
Its much faster than the forums.


Tue Apr 21, 2009 2:52 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Lua based map objects, help! (BW related)
numgun wrote:
Another new item! Regenerator!

If your guy is damaged, this thing will super charge your hp to 200!
But... the point was to make it heal damaged limbs. TLB made that by respawning the entire actor and re-assigning all his equipment from scratch.(The coalition base mission made by TLB) This needs a much more simple method of doing that.

Right now it just checks if an actor inside it has less than 100 hp and the recharge timer has already passed 10 seconds. then it will simply assign him 200hp points.

Heres the code on what I did with a little copypasta from here and there:

It needs to respawn the actor so its totally fresh with 100hp and all wounds and limbs healed, but also let him keep his equipment he had with him. How do you code that?


You quite simply can't do that without making a new actor.


Tue Apr 21, 2009 3:14 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Really good looking stuff Numgun.
I just got this idea, a platform you can jump trough when you're under it, and walk on it when on top. (Like in all of those old platformers)


Tue Apr 21, 2009 4:14 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)
Dont work, error on line.

Code:
                local i = math.rand(1,#_teleporters)


"attempt to call field "rand" (a nil value)"


Code:
function Create(self)
    if (_teleporters == nil) then
         _teleporters = {self}
    else
        table.insert(_teleporters,self)
    end
    self.teledelaytimer = Timer();
   self.teleactivate = nil;
end

function Destroy(self)
    table.remove(_teleporters,self)
end


function Update(self)
   if(#_teleporters > 1) then
      for actor in MovableMan.Actors do
      if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then
         if MovableMan:IsParticle(self.teleactivate) == false then
            self.teleactivate = CreateAEmitter("Teleport Activation");
            self.teleactivate:EnableEmission(true);
            self.teleactivate.Pos = Vector(0,0);
            MovableMan:AddParticle(self.teleactivate);
         end
      else
         if self.teledelaytimer:IsPastSimMS(3000) then
         --TELEPORTATION HAPPENS HERE
                local i = math.rand(1,#_teleporters)
            actor.Pos = _teleporters[i].Pos
            self.teledelaytimer:Reset();
            self.teleactivate.Lifetime = 1;
         end
      end
      end   
   end
end



EDIT: Btw, what if the teleporter would simply teleport the actor randomly at any point in the map. That would be simple and very random. What would be the code for that?


Tue Apr 21, 2009 7:42 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)
Whoops, that's supposed to be math.random
For the all-round teleporter replace actor.Pos = whatever from the teleporting part to actor.Pos = Vector(SceneMan.Scene.Width * PosRand(), SceneMan.Scene.Height * PosRand());
The actor could end up underground though.
Edit: code update, that old version wouldn't really work :D
Code:
function Create(self)
    if (_teleporters == nil) then
         _teleporters = {self}
    else
        table.insert(_teleporters,self)
    end
    self.teledelaytimer = Timer();
   self.teleactivate = nil;
end

function Destroy(self)
    table.remove(_teleporters,self)
end


function Update(self)
   if(#_teleporters > 1) then
      for actor in MovableMan.Actors do
      if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then
         if not self.teleactivated then
            self.teleactivate = CreateAEmitter("Teleport Activation");
            self.teleactivate:EnableEmission(true);
            self.teleactivate.Pos = Vector(0,0); //shouldn't this be self.Pos?
            MovableMan:AddParticle(self.teleactivate);
            self.teledelaytimer:Reset();
            self.teleactivated = 1
         else
         if self.teledelaytimer:IsPastSimMS(3000) then
         --TELEPORTATION HAPPENS HERE
                local i = math.random(1,#_teleporters)
            actor.Pos = _teleporters[i].Pos
            self.teledelaytimer:Reset();
            self.teleactivate.Lifetime = 1;
            self.teleactivated = 0
         end
         end
      end
      end   
   end
end


Tue Apr 21, 2009 8:16 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Lua based map objects, help! (BW related)
Holysh*t! It works! IT WORKS!!! :D

Image

The teleporters work well! Except the "teleactivate" effect fails to show after a few times, but thats minor. And after playing a bit with them teleporting back to the teleport you came from is not fun. Is there a way to make it not teleport on the tele you left from?

Anyways heres the latest code:

Code:
function Create(self)
    if (_teleporters == nil) then
         _teleporters = {self}
    else
        table.insert(_teleporters,self)
    end
   self.teledelaytimer = Timer();
   self.teleactivate = nil;
end

function Destroy(self)
    table.remove(_teleporters,self)
end


function Update(self)
   if(#_teleporters > 1) then
      for actor in MovableMan.Actors do
      if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then
         if not self.teleactivated then
            self.teleactivate = CreateAEmitter("Teleport Activation");
         self.teleactivate.Lifetime = 2000;
         self.teleactivate.Pos = self.Pos;
            self.teleactivate:EnableEmission(true);
            MovableMan:AddParticle(self.teleactivate);
            self.teledelaytimer:Reset();
            self.teleactivated = 1
         else
         if self.teledelaytimer:IsPastSimMS(2000) then
        --TELEPORTATION HAPPENS HERE
                local i = math.random(1,#_teleporters)
            actor.Pos = _teleporters[i].Pos
            self.teledelaytimer:Reset();
            self.teleactivate.Lifetime = 2000;
            self.teleactivated = 0
         end
         end
      end
      end   
   end
end




Otherwise, Piipu, you made fudge history. :grin:

Also I made another small thing. But this one doesnt work properly.
Its a "Bunker Build" module. By sacrificing an actor into it, you will activate the bunker building menu. Now think how fun that might be in the middle of a skirmish battle! You could repair the entire bunker and even expand it during the game!


Heres the code I made, but it fails.

Code:
function Create(self)

end

function Destroy(self)

end

function Update(self)
    --First checks whether an actor or an item is within the box and then activates the bunker editor and gibs them. them.
   for actor in MovableMan.Actors do
       if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then
      ActivityMan:GetActivity().ActivityState = Activity.EDITING ;
      actor:GibThis() ;
       end
   end
end


The thing is, the bunker building mode must activate after inserting an actor in the area of the module and then gib the actor as a "sacrifice". Returning to game happens with the old "Done building" thing like you usually do.

What my code does it activate the while the actor is inside the thing.
Since the thing gibs the actor right away, it leaves the bunker build mode instantly. How would the code work on this?


Tue Apr 21, 2009 9:40 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)
Just thought of something, might not work to fix self teleort glitch:
Code:
local i = math.random(1,#_teleporters)
while i == self.thistele
do
i = math.random(1,#_teleporters)
end

And change Create to:
Code:
function Create(self)
    if (_teleporters == nil) then
         _teleporters = {self}
    else
        table.insert(_teleporters,self)
    end
   self.teledelaytimer = Timer();
   self.teleactivate = nil;
self.thistele = #_teleporters;
end

Don't forget to add tabs.


Wed Apr 22, 2009 1:59 am
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)
Now all I need is a B23 to test my stuff D:
Anyway, bunker build module:
Code:
function Create(self)

end

function Destroy(self)

end

function Update(self)
    --First checks whether an actor or an item is within the box and then activates the bunker editor and gibs them. them.
   for actor in MovableMan.Actors do
     if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then
        self.editing = 1
        actor:GibThis();
      end
     if not(actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then
       if not(ActivityMan:GetActivity().ActivityState == Activity.EDITING) then
         self.editing = 0
       end
     end
   end

  if self.editing == 1 then
    ActivityMan:GetActivity().ActivityState = Activity.EDITING;
  end

end

That may or may not work.
Also, mail's way of preventing selfteleing should work fine.


Wed Apr 22, 2009 1:48 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)
Finaly implemented anti-self tele with telefrag.
Code:
function Create(self)
    if (_teleporters == nil) then
        _teleporters = {self}
    else
        table.insert(_teleporters,self)
    end
   self.teledelaytimer = Timer();
   self.teleactivate = nil;
   self.thistele = #_teleporters;
end

function Destroy(self)
    table.remove(_teleporters,self)
end

function Update(self)
   if(#_teleporters > 1) then
      for actor in MovableMan.Actors do
      if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then
         if not self.teleactivated then
            self.teleactivate = CreateAEmitter("Teleport Activation");
         self.teleactivate.Lifetime = 2000;
         self.teleactivate.Pos = self.Pos;
            self.teleactivate:EnableEmission(true);
            MovableMan:AddParticle(self.teleactivate);
            self.teledelaytimer:Reset();
            self.teleactivated = 1
         else
         if self.teledelaytimer:IsPastSimMS(2000) then
        --TELEPORTATION HAPPENS HERE
            local i = math.random(1,#_teleporters)
            while i == self.thistele
            do
            i = math.random(1,#_teleporters)
            end
            for oactor in MovableMan.Actors
            if (oactor.Pos.X >= _teleporters[i].Pos.X - 24) and (oactor.Pos.X <= _teleporters[i].Pos.X + 24) and (oactor.Pos.Y >= _teleporters[i].Pos.Y - 25) and (oactor.Pos.Y <= _teleporters[i].Pos.Y + 25)
            then
            oactor:GibThis();
            end
            end
            actor.Pos = _teleporters[i].Pos
            self.teledelaytimer:Reset();
            self.teleactivate.Lifetime = 2000;
            self.teleactivated = 0
         end
         end
      end
      end   
   end
end



Thu Apr 23, 2009 2:02 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 134 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.033s | 14 Queries | GZIP : Off ]