View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:32 pm



Reply to topic  [ 15 posts ] 
 how to deal damage over time after being hit by a MOPixel 
Author Message
User avatar

Joined: Fri Oct 16, 2009 7:45 pm
Posts: 72
Reply with quote
Post how to deal damage over time after being hit by a MOPixel
so basicly i have a TerrainObject with a AEmitter emitting a MOPixel, my best guess would be to attach a script to the mopixel ,then check for proximity with actor / device with low tolarance i.e. low magnatude etc , then use a timer with something like victim.health = victim.health - 10
this is probably not the best method , does anyone has a better solution ?


Sun Sep 05, 2010 12:28 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
That's pretty much the way to do it. You could make it fancier by making larger actors lose health slower than smaller actors, but you have the basic idea down.


Sun Sep 05, 2010 5:48 pm
Profile
User avatar

Joined: Fri Oct 16, 2009 7:45 pm
Posts: 72
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
this is what i have so far , but its not working
also gave me no error's
Code:
function Create(self)
--The timer that will measure out events.
    self.LTimer = Timer();

--The Victim, currently set to nothing.

   Victim = nil;

   end

function Update(self)
    if self.LTimer:IsPastSimMS(100) then
   --Get the victim.  Go for the closest actor within 5 pixels.
   if MovableMan:IsActor(Victim) == false then
       local curdist = 5;
       for actor in MovableMan.Actors do
      local avgx = actor.Pos.X - self.Pos.X;
      local avgy = actor.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist then
          curdist = dist;
          Victim = actor;
      end
       end
   end
   end

   --If the target still exists...
   if MovableMan:IsActor(Victim) then
     Victim.Health = Victim.Health - 5;
   end
   
   end


Sun Sep 05, 2010 8:11 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
You know, 5 pixels is a very, very short distance.


Sun Sep 05, 2010 9:28 pm
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
Why not make it 9999? The loop finds the closest actor, so it doesn't really matter what curdist is, as long as it isn't too small, right?


Sun Sep 05, 2010 10:31 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
It does not find the closest actor.


Mon Sep 06, 2010 4:40 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
CaveCricket48 wrote:
It does not find the closest actor.


Hmm?

Take a look at the curdist and dist code.

It loops through the entire table of actors and takes the shortest distance value.


Mon Sep 06, 2010 6:02 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
Probably not a good idea to make it a huge value though, otherwise that little pixel would be sapping the health of the next-nearest actor every time it kills one.


Mon Sep 06, 2010 6:03 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
Grif wrote:
CaveCricket48 wrote:
It does not find the closest actor.


Hmm?

Take a look at the curdist and dist code.

It loops through the entire table of actors and takes the shortest distance value.

Ah, I didn't see that "curdist = dist"..

Oh, and the way your script works, dutchsmoker, once an actor is within range and becomes the "victim," it will remain the victim untill it dies, even if it moves out of range. Unless if I over-looked something.


Mon Sep 06, 2010 6:47 am
Profile
User avatar

Joined: Fri Oct 16, 2009 7:45 pm
Posts: 72
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
The effect should remain untill the actor is dead ,and i only want actors that actually get hit by my mopixel to get there health sapped away, thus the low distance.
5pixel's is not mutch ill try to up that number and see what happens
This script will be used in my nano spikes , basicly spikes that do damage
When a actor escapes from the spikes the "nanobots" should still harm him.


Mon Sep 06, 2010 5:28 pm
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
You could give the actor a wound that had the hurt script attached when the actor got too close, that way the wound would only have to find the closest actor once and then hurt that actor in the update.


Mon Sep 06, 2010 9:28 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: how to deal damage over time after being hit by a MOPixel
So where does the wound go exactly?


Tue Sep 07, 2010 7:35 am
Profile WWW
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
What do you mean?


Tue Sep 07, 2010 11:50 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: how to deal damage over time after being hit by a MOPixel
I am clarifying the method you spoke of.


Wed Sep 08, 2010 5:59 am
Profile WWW
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: how to deal damage over time after being hit by a MOPixel
I'm assuming awesomeness isn't aware of the limitations of attachables and their derivatives in CC's current build.


Wed Sep 08, 2010 6:19 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 15 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.142s | 15 Queries | GZIP : Off ]