| Blockland Forums > Modification Help |
| setRepairRate making it negative |
| << < (2/4) > >> |
| Kiwi:
Yes, I try to get right this effect. Problem is when you remove health from the player onDamage is called again. I just need help with this simple thing because I'm no scripter. |
| phflack:
--- Quote from: Kiwi on February 09, 2011, 12:34:53 AM ---Yes, I try to get right this effect. Problem is when you remove health from the player onDamage is called again. I just need help with this simple thing because I'm no scripter. --- End quote --- oh, i see now, so when they get hit, it triggers an inf loop? |
| Chrono:
I don't think .setDamageLevel calls onDamage |
| Kiwi:
--- Code: ---function Player::onDamage(%this,%obj,%delta) { Parent::onDamage(%this,%obj,%delta); %currentDamage = %obj.getDamageLevel(); if(%delta > 0) { if(%obj.getState() !$= "Dead") { %obj.bleedSched1 = %obj.schedule(1000,setDamageLevel,%currentDamage+3); %obj.bleedSched2 = %obj.schedule(2000,setDamageLevel,%currentDamage+2); %obj.bleedSched3 = %obj.schedule(3000,setDamageLevel,%currentDamage+1); } } } --- End code --- This has a similar effect, loops infinite. Why can't you make setRepairRate negative? |
| Amade:
--- Quote from: Kiwi on February 09, 2011, 02:56:30 AM ---Why can't you make setRepairRate negative? --- End quote --- It wasn't programmed that way A simple way to do this would be as follows: --- Code: ---function Player::bleed(%obj, %damage, %interval, %ticks, %sourceObj, %damageType) { for(%i = 1; %i <= %ticks; %i++) { %obj.schedule(%i * %interval, damage, %sourceObj, %obj.getPosition(), %damage / %ticks, %damageType); } } --- End code --- %obj is the player, %damage is the total damage done over the course of the effect, %interval is the time between each tick, %ticks is the total number of ticks, %sourceObj is the source of the damage, and %damageType is the damage type used to deal the damage. A sample usage would be: %col.bleed(100, 1000, 10, %obj.sourceObject, $DamageType::Gun); This would cause the player %col to bleed for 100 total damage of type $DamageType::Gun from %obj.sourceObject, ticking a total of 10 times, once every 1000 ms. |
| Navigation |
| Message Index |
| Next page |
| Previous page |