Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-25-2010, 04:14 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Floating Text Effect

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.imgidthis.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..5 random(-1,1); 
  
temp.ty player.random(-1,1); 
  
// Img ID Counter 
  
this.counter_npc = (this.counter_npc) % 20
  
// Draw Floating Text 
  
showFloatingText(this.counter_npctxtydmg100); 


public function 
showNPCDamage(txtydmg) { 
  
// Img ID Counter 
  
this.counter_npc = (this.counter_npc) % 20
  
// Draw Floating Text 
  
showFloatingText(200 this.counter_npctxtydmg100); 


public function 
showFloatingText(imgidtxtymsgrgbz) { 
  
// 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(imgidtxty0"effect_floatingtext"msgrgbz); 
  
// Timeout 
  
setTimer(0.1); 

Then in your baddy:

PHP Code:
// Assumed Baddy Code
function onActionDamage(dmgfrom) {
  
// Tell Attacker's Client to Draw Damage Text
  
findplayer(from).triggerclient("weapon""-Effects_Text""npcdmg"this.xthis.ydmg);

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.
Attached Files
File Type: gani effect_floatingtext.gani (1.6 KB, 297 views)
__________________
Quote:

Last edited by Admins; 07-04-2011 at 04:44 PM..
Reply With Quote
  #2  
Old 12-25-2010, 01:21 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
nice work, screenshots?

oh and, didn't you forget a param in the triggerclient baddy part?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #3  
Old 01-05-2011, 03:40 AM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
Nice
Reply With Quote
  #4  
Old 07-03-2011, 07:09 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Made a mistake in this script with the id counter, also added a check for the floating array to prevent duplicates.

If a mod could update the OP would be much appreciated.
__________________
Quote:

Last edited by Tigairius; 07-03-2011 at 07:24 AM..
Reply With Quote
  #5  
Old 07-04-2011, 11:12 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I've fixed the triggerclient and added a //#CLIENTSIDE
Reply With Quote
  #6  
Old 07-04-2011, 03:12 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
The functions were only supposed to be replaced not the whole thing x.x

PHP Code:
//#CLIENTSIDE

function onTimeout() {
  
// Check for Floating Text IDs
  
if (this.floating.size() > 0) {
    
// Loop through Floating Text IDs
    
for (temp.imgidthis.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..5 random(-1,1); 
  
temp.ty player.random(-1,1); 
  
// Img ID Counter 
  
this.counter_npc = (this.counter_npc) % 20
  
// Draw Floating Text 
  
showFloatingText(this.counter_npctxtydmg100); 


public function 
showNPCDamage(txtydmg) { 
  
// Img ID Counter 
  
this.counter_npc = (this.counter_npc) % 20
  
// Draw Floating Text 
  
showFloatingText(200 this.counter_npctxtydmg100); 


public function 
showFloatingText(imgidtxtymsgrgbz) { 
  
// 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(imgidtxty0"effect_floatingtext"msgrgbz); 
  
// Timeout 
  
setTimer(0.1); 

__________________
Quote:
Reply With Quote
  #7  
Old 07-04-2011, 04:45 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I already thought that something is missing, must have been late for Tig
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.