|
Page 1 of 1
|
[ 12 posts ] |
|
how do I make a character heal over time?
Author |
Message |
salt_1219
Joined: Tue Jan 12, 2010 8:25 pm Posts: 400 Location: mukilteo, wa
|
how do I make a character heal over time?
I've seen this done, and looked at the code of characters with it, but I'm at a loss as to what makes this work. Is this some sort of special bleed?
If anyone can provide a sample of code, it would be greatly appreciated.
|
Tue Feb 09, 2010 2:08 am |
|
|
dragonxp
Joined: Wed Sep 09, 2009 3:16 am Posts: 3032 Location: Somewhere in the universe
|
Re: how do I make a character heal over time?
i'm sure its lua. I think its a improvisation of the healing drone lua script.
|
Tue Feb 09, 2010 2:46 am |
|
|
salt_1219
Joined: Tue Jan 12, 2010 8:25 pm Posts: 400 Location: mukilteo, wa
|
Re: how do I make a character heal over time?
I will take a look at that thanks *update* Code: function Create(self) --Keep track of how long it should be before healing people. healTimer = Timer(); --Interval between healings, in milliseconds. healInterval = 100; --Heal counter. self.healnum = 0; end
function Update(self) --Heal every interval. if healTimer:IsPastSimMS(healInterval) then --Cycle through all actors. for actor in MovableMan.Actors do --If the actor is on the right team, has less than 100 health and is not the healer, continue with code. if actor.Team == self.Team and actor.Health < 100 and actor.ID ~= self.ID then --Trigonometry to find how far the actor is. 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 < 100 then --If the actor is fairly close, heal them! actor.Health = actor.Health + 1; --Every 8 health healed, put a little icon above the actor's head to show that it is indeed healing. if self.healnum == 8 then --Create the particle. local part = CreateMOSParticle("Particle Heal Effect"); --Set the particle's position to just over the actor's head. part.Pos = actor.AboveHUDPos + Vector(0,4); --Add the particle to the world. MovableMan:AddParticle(part); end end end end --Reset the healing timer. healTimer:Reset(); --Increment the heal counter. self.healnum = self.healnum + 1; --Reset it if it's gone too far. if self.healnum > 8 then self.healnum = 0; end end end I messed with this a bunch and I can't figure out how to make it just heal me.
|
Tue Feb 09, 2010 3:11 am |
|
|
findude
Joined: Tue Dec 12, 2006 3:10 pm Posts: 495 Location: Uncertain quantum state
|
Re: how do I make a character heal over time?
Either set EmissionDamage of your wounds to negative, or use Lua. Code: Function Update(self) if self.Health<100 then self:AddHealth(1) end if self.Health > 100 then self.Health = 100 end end That should do it. Note that it now heals stupidly fast with this script, so you might want to add in some timer or random chance there to dampen it.
|
Tue Feb 09, 2010 10:31 am |
|
|
salt_1219
Joined: Tue Jan 12, 2010 8:25 pm Posts: 400 Location: mukilteo, wa
|
Re: how do I make a character heal over time?
Thank you the emission damage trick worked ! Now I'm reworking his wounds so he doesn't look like he has cancerous growths, if he takes a lot of damage.
This is for my werewolf, and so far the heals make him scary lol.
|
Tue Feb 09, 2010 8:23 pm |
|
|
Camalaio
Joined: Fri Apr 06, 2007 10:11 pm Posts: 45
|
Re: how do I make a character heal over time?
As said, Emission Damage is the way to go. I'd say emission damage is better for a few reasons, the first being very important,. Emission damage is hard-coded into CC already. It seems to have been forgotten that Lua is not as efficient as INI coding (while continuously running code). One small Lua script won't kill the game, but when multiple running mods are using Lua method on Update, there is a small performance loss. Also, emission damage actually offers a neat bit of control. You can calculate (or do guess work, for the less mathematical INI coder) the amount of health to restore over time, how much to restore, and how fast to restore it. This is not all easily possible in Lua without timers, conditionals, and some form of linear function. My next point relates to the fact that Lua would require a linear function for the same results. As an example, you have a soldier that has just been hit. By emissions, we'll say that the emission damage is 0.05 every 200 milliseconds. This, mathematically, restores 1 health every 4 seconds. If you were to simply have a timer that incremented actor.Health by 0.05 every 200 millisecond, it does not work. By my testing, Health is an integer (for those that understand an int, no, I do not know how many bits. I have assumed it is somehow insanely high with some earlier screenshots around build 18), which means that it has no decimals. Adding 0.99 will not even raise it; whole numbers are required. Somehow CC accounts for this in the actual code. One idea I have is that Lua only reveals the upper-level health: What os graphically displayed above the actor as an integer. Another thought is that Data uses calculated timers to achieve the effect. In summary, use INI coding wherever possible, then use Lua as a last resort. Most of these "new, revolutionary weapons" are using excess Lua to replicate exactly what INI coding already allows. Even things for actors (hello, health regeneration) are needlessly using Lua. Now, you are slightly more educated
|
Fri Feb 12, 2010 6:37 am |
|
|
salt_1219
Joined: Tue Jan 12, 2010 8:25 pm Posts: 400 Location: mukilteo, wa
|
Re: how do I make a character heal over time?
Camalaio wrote: As said, Emission Damage is the way to go. I'd say emission damage is better for a few reasons, the first being very important,. Emission damage is hard-coded into CC already. It seems to have been forgotten that Lua is not as efficient as INI coding (while continuously running code). One small Lua script won't kill the game, but when multiple running mods are using Lua method on Update, there is a small performance loss. Also, emission damage actually offers a neat bit of control. You can calculate (or do guess work, for the less mathematical INI coder) the amount of health to restore over time, how much to restore, and how fast to restore it. This is not all easily possible in Lua without timers, conditionals, and some form of linear function. My next point relates to the fact that Lua would require a linear function for the same results. As an example, you have a soldier that has just been hit. By emissions, we'll say that the emission damage is 0.05 every 200 milliseconds. This, mathematically, restores 1 health every 4 seconds. If you were to simply have a timer that incremented actor.Health by 0.05 every 200 millisecond, it does not work. By my testing, Health is an integer (for those that understand an int, no, I do not know how many bits. I have assumed it is somehow insanely high with some earlier screenshots around build 18), which means that it has no decimals. Adding 0.99 will not even raise it; whole numbers are required. Somehow CC accounts for this in the actual code. One idea I have is that Lua only reveals the upper-level health: What os graphically displayed above the actor as an integer. Another thought is that Data uses calculated timers to achieve the effect. In summary, use INI coding wherever possible, then use Lua as a last resort. Most of these "new, revolutionary weapons" are using excess Lua to replicate exactly what INI coding already allows. Even things for actors (hello, health regeneration) are needlessly using Lua. Now, you are slightly more educated Thank you vary much that was a vary well thought out argument. Also I did end up using ini over lua, mostly due to I couldn't get the lua to work for me. (I know how to spell it that's about it for my lua skills) But now that I have tweaked it I'm happy with the ini fix.
|
Fri Feb 12, 2010 6:48 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: how do I make a character heal over time?
health is an automatically floored long unsigned int
actors automatically die at 0 health or less
|
Fri Feb 12, 2010 7:01 am |
|
|
Camalaio
Joined: Fri Apr 06, 2007 10:11 pm Posts: 45
|
Re: how do I make a character heal over time?
I wouldn't be too sure about it being unsigned. They can still display negative values after they get shot. Also, there is no agreed standard for "long" anymore. Could be 16, 32, or even 64 bit, though I'm doubting 64. FYI, the very nature of int's is to floor all numbers. Just a note I'd actually love to see how Data works out this whole health management thing. EDIT: I retract my statement for long types. There are apparently some language specific standards I did not know about. The minimum (and probably most likely) for C and C++ is 32 bits.
|
Fri Feb 12, 2010 7:33 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: how do I make a character heal over time?
the behaviour of both the health display and the internal health system changed from build 18 to build 19
in build 18, you could make an actor with 0.9 health, which would display as 0, but still be alive
starting from build 19, actual health would round down as well as display health, meaning that the variable management changed
|
Fri Feb 12, 2010 7:43 am |
|
|
Sushichef0
Joined: Sat Jan 02, 2010 6:52 pm Posts: 5
|
Re: how do I make a character heal over time?
*head explodes* I cannot locate emission damage anywhere in my actors ini. Please help me E: THANK YOUUUUUU!!! *hug*
Last edited by Sushichef0 on Thu May 06, 2010 4:21 pm, edited 1 time in total.
|
Thu May 06, 2010 3:55 pm |
|
|
Petethegoat
Joined: Mon Jun 15, 2009 4:02 pm Posts: 905
|
Re: how do I make a character heal over time?
You'd be looking for Base.rte/Effects/Wounds/Wounds.ini, then copy the wounds your actor uses and modify those.
|
Thu May 06, 2010 4:01 pm |
|
|
|
|
Page 1 of 1
|
[ 12 posts ] |
|
Who is online |
Users browsing this forum: Google [Bot] |
|
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
|
|