| Author | Message | 
        
			| dutchsmoker 
					Joined: Fri Oct 16, 2009 7:45 pm
 Posts: 72
   |   how to deal damage over time after being hit by a MOPixelso 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 | 
					
					   | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: how to deal damage over time after being hit by a MOPixelThat'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 | 
					
					   | 
	
	
		|  | 
	
			| dutchsmoker 
					Joined: Fri Oct 16, 2009 7:45 pm
 Posts: 72
   |   Re: how to deal damage over time after being hit by a MOPixelthis 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 | 
					
					   | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: how to deal damage over time after being hit by a MOPixelYou know, 5 pixels is a very, very short distance. 
 
 | 
		
			| Sun Sep 05, 2010 9:28 pm | 
					
					   | 
	
	
		|  | 
	
			| Awesomeness 
					Joined: Sat Jun 19, 2010 5:02 pm
 Posts: 331
 Location: Mekkan
   |   Re: how to deal damage over time after being hit by a MOPixelWhy 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 | 
					
					   | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: how to deal damage over time after being hit by a MOPixelIt does not find the closest actor. 
 
 | 
		
			| Mon Sep 06, 2010 4:40 am | 
					
					   | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: how to deal damage over time after being hit by a MOPixelCaveCricket48 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 | 
					
					   | 
	
	
		|  | 
	
			| Duh102 happy carebear mom 
					Joined: Tue Mar 04, 2008 1:40 am
 Posts: 7096
 Location: b8bbd5
   |   Re: how to deal damage over time after being hit by a MOPixelProbably 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 | 
					
					   | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: how to deal damage over time after being hit by a MOPixelGrif 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 | 
					
					   | 
	
	
		|  | 
	
			| dutchsmoker 
					Joined: Fri Oct 16, 2009 7:45 pm
 Posts: 72
   |   Re: how to deal damage over time after being hit by a MOPixelThe 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 | 
					
					   | 
	
	
		|  | 
	
			| Awesomeness 
					Joined: Sat Jun 19, 2010 5:02 pm
 Posts: 331
 Location: Mekkan
   |   Re: how to deal damage over time after being hit by a MOPixelYou 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 | 
					
					   | 
	
	
		|  | 
	
			| 411570N3 
					Joined: Wed Jan 07, 2009 10:26 am
 Posts: 4074
 Location: That quaint little British colony down south
   |   Re: how to deal damage over time after being hit by a MOPixelSo where does the wound go exactly? 
 
 | 
		
			| Tue Sep 07, 2010 7:35 am | 
					
					     | 
	
	
		|  | 
	
			| Awesomeness 
					Joined: Sat Jun 19, 2010 5:02 pm
 Posts: 331
 Location: Mekkan
   |   Re: how to deal damage over time after being hit by a MOPixelWhat do you mean? 
 
 | 
		
			| Tue Sep 07, 2010 11:50 pm | 
					
					   | 
	
	
		|  | 
	
			| 411570N3 
					Joined: Wed Jan 07, 2009 10:26 am
 Posts: 4074
 Location: That quaint little British colony down south
   |   Re: how to deal damage over time after being hit by a MOPixelI am clarifying the method you spoke of. 
 
 | 
		
			| Wed Sep 08, 2010 5:59 am | 
					
					     | 
	
	
		|  | 
	
			| Geti 
					Joined: Sun Jul 13, 2008 9:57 am
 Posts: 4886
 Location: some compy
   |   Re: how to deal damage over time after being hit by a MOPixelI'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 | 
					
					     | 
	
	
		|  | 
	
	
		|  |