Data Realms Fan Forums http://45.55.195.193/ |
|
how to deal damage over time after being hit by a MOPixel http://45.55.195.193/viewtopic.php?f=73&t=19682 |
Page 1 of 1 |
Author: | dutchsmoker [ Sun Sep 05, 2010 12:28 pm ] |
Post subject: | 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 ? |
Author: | CaveCricket48 [ Sun Sep 05, 2010 5:48 pm ] |
Post subject: | 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. |
Author: | dutchsmoker [ Sun Sep 05, 2010 8:11 pm ] |
Post subject: | 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 |
Author: | CaveCricket48 [ Sun Sep 05, 2010 9:28 pm ] |
Post subject: | Re: how to deal damage over time after being hit by a MOPixel |
You know, 5 pixels is a very, very short distance. |
Author: | Awesomeness [ Sun Sep 05, 2010 10:31 pm ] |
Post subject: | 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? |
Author: | CaveCricket48 [ Mon Sep 06, 2010 4:40 am ] |
Post subject: | Re: how to deal damage over time after being hit by a MOPixel |
It does not find the closest actor. |
Author: | Grif [ Mon Sep 06, 2010 6:02 am ] |
Post subject: | 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. |
Author: | Duh102 [ Mon Sep 06, 2010 6:03 am ] |
Post subject: | 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. |
Author: | CaveCricket48 [ Mon Sep 06, 2010 6:47 am ] |
Post subject: | 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. |
Author: | dutchsmoker [ Mon Sep 06, 2010 5:28 pm ] |
Post subject: | 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. |
Author: | Awesomeness [ Mon Sep 06, 2010 9:28 pm ] |
Post subject: | 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. |
Author: | 411570N3 [ Tue Sep 07, 2010 7:35 am ] |
Post subject: | Re: how to deal damage over time after being hit by a MOPixel |
So where does the wound go exactly? |
Author: | Awesomeness [ Tue Sep 07, 2010 11:50 pm ] |
Post subject: | Re: how to deal damage over time after being hit by a MOPixel |
What do you mean? |
Author: | 411570N3 [ Wed Sep 08, 2010 5:59 am ] |
Post subject: | Re: how to deal damage over time after being hit by a MOPixel |
I am clarifying the method you spoke of. |
Author: | Geti [ Wed Sep 08, 2010 6:19 am ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |