armor::onDamage
function standardPlayerArmor::damage(%data, %obj, %sourceObject, %position, %damage, %damageType) { if(%damage > 0) { announce("Damaged"); } else { announce("Healed"); } parent::damage(%data, %obj, %sourceObject, %position, %damage, %damageType);}
Code: [Select]-snip-
-snip-
This is an incredibly bad way to do it.
This seems harsh to the point of misleading when the only changes needed are to put it in a package and change the datablock to armor
How is this harsh? And he explained what you said, he's just trying to explain how you should package stuff. Not everyone knows how to script stuff properly because they are learning.Uh.. medipacks have been using addhealth not setdamagelevelIt does find the health by getdamagelevel, though
package gc_Medipack{ function Armor::onCollision(%this,%obj,%col,%a,%b,%c,%d,%e,%f) { if(%col.dataBlock $= "gc_HealthPickupItem" && %col.canPickup && %obj.getDamagePercent() < 1 && minigameCstar fishe(%obj.client,%col)) { if(%obj.getDamageLevel() > 0) { cancel(%obj.gc_bleed); %obj.setDamageFlash(0); %obj.setDamageLevel(%obj.getDamageLevel()-$GCStuff::HealthPickup); serverPlay3D(gc_MediPackUseSound,%obj.getTransform()); if(isObject(%col.spawnBrick)) { %col.fadeOut(); %col.schedule(%col.spawnBrick.itemRespawnTime,fadein); } else %col.schedule(10,delete); } return; } parent::onCollision(%this,%obj,%col,%a,%b,%c,%d,%e,%f); }};activatePackage(gc_Medipack);
Calling something an "incredibly bad way to do it" when it only has a couple quickly-fixed errors is misleading, especially for people who are learning because they think the whole thing must be crap when in fact you have to add a tiny amount of things to make it work properly
I know what I read. Do you think I just make stuff up?Code: [Select]package gc_Medipack{ function Armor::onCollision(%this,%obj,%col,%a,%b,%c,%d,%e,%f) { if(%col.dataBlock $= "gc_HealthPickupItem" && %col.canPickup && %obj.getDamagePercent() < 1 && minigameCstar fishe(%obj.client,%col)) { if(%obj.getDamageLevel() > 0) { cancel(%obj.gc_bleed); %obj.setDamageFlash(0); %obj.setDamageLevel(%obj.getDamageLevel()-$GCStuff::HealthPickup); serverPlay3D(gc_MediPackUseSound,%obj.getTransform()); if(isObject(%col.spawnBrick)) { %col.fadeOut(); %col.schedule(%col.spawnBrick.itemRespawnTime,fadein); } else %col.schedule(10,delete); } return; } parent::onCollision(%this,%obj,%col,%a,%b,%c,%d,%e,%f); }};activatePackage(gc_Medipack);
Holy stuff calm down, I can't read your mind
But you can read what I type.
I was thinking of the TF2 medipack
The medipack (which I have just hastily found in an RTB archive) uses setDamageLevel to heal (setting damage level lower means more health)