| fowlplay4 |
12-25-2010 04:14 AM |
Floating Text Effect
1 Attachment(s)
It's a fairly simple effect that I recently remade on Zodiac and can be easily integrated into your own systems.
I've attached the effect at the bottom. Just upload it into your ganis folder.
Here's an example implementation:
-Effects_Text
PHP Code:
//#CLIENTSIDE
function onTimeout() { // Check for Floating Text IDs if (this.floating.size() > 0) { // Loop through Floating Text IDs for (temp.imgid: this.floating) { // Check if ID is expired if (timevar2 >= this.floating.(@imgid)) { // Hide Floating Text hideimg(imgid); // Remove Floating Text ID Data and from Array this.floating.(@imgid) = ""; this.floating.remove(imgid); } } // Continue Looping if there's still Floating Text if (this.floating.size() > 0) { setTimer(0.1); } } }
function onActionClientSide() { switch (params[0]) { case "playerdmg": showDamage(params[1]); break; case "npcdmg": showNPCDamage(params[1], params[2], params[3]); break; } }
public function showDamage(dmg) { // Determine Coordinates temp.tx = player.x - .5 + random(-1,1); temp.ty = player.y + 1 + random(-1,1); // Img ID Counter this.counter_npc = (1 + this.counter_npc) % 20; // Draw Floating Text showFloatingText(1 + this.counter_npc, tx, ty, dmg, 1, 0, 0); }
public function showNPCDamage(tx, ty, dmg) { // Img ID Counter this.counter_npc = (1 + this.counter_npc) % 20; // Draw Floating Text showFloatingText(200 + this.counter_npc, tx, ty, dmg, 1, 0, 0); }
public function showFloatingText(imgid, tx, ty, msg, r, g, b, z) { // Hideimg just in case hideimg(imgid); // Add to Image Tracking Array if (!(imgid in this.floating)) this.floating.add(imgid); // Set Time to Hide this.floating.(@imgid) = timevar2 + 0.75; // Display Text showani(imgid, tx, ty, 0, "effect_floatingtext", msg, r, g, b, z); // Timeout setTimer(0.1); }
Then in your baddy:
PHP Code:
// Assumed Baddy Code function onActionDamage(dmg, from) { // Tell Attacker's Client to Draw Damage Text findplayer(from).triggerclient("weapon", "-Effects_Text", "npcdmg", this.x, this.y, dmg); }
Upon doing damage to the baddy it should tell your client to display the floating damage text on your screen.
If you just want to test the code out:
PHP Code:
//#CLIENTSIDE function onCreated() { setTimer(0.5); }
function onTimeout() { temp.dmg = int(random(1,10000)); findweapon("-Effects_Text").showDamage(temp.dmg); setTimer(0.5); }
If you want to see the effect just walk outside OSL on Zodiac and there should be some PKers killing each other.
|