Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-04-2012, 08:11 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Cooldown display.

Looks like this:
Name:  cooldown.gif
Views: 320
Size:  3.1 KB
Imagine that the chest is a skill icon and has the number of seconds left on the cooldown on it.

The code plus example of use (weapon script):
PHP Code:
//#CLIENTSIDE

function onCreated()
{
  
this.skillIconImg findimg(200);
  
with (this.skillIconImg) {
    
this.image "chest.png";
    
this.int(screenwidth 16);
    
this.int(screenheight 16);
    
this.layer 4;
  }
  
  
this.cooldownImg findimg(201);
  
with (this.cooldownImg) {
    
this.red 1;
    
this.green 1;
    
this.blue 1;
    
this.alpha 0.75;
    
this.mode 2;
    
this.layer 5;
  }
  
  
this.trigger("onTimeout"null);
}

function 
onTimeout()
{
  
this.cooldownProgress -= 0.01;
  if (
this.cooldownProgress 0this.cooldownProgress += 1;
  
  
this.cooldownImg.polygon this.getCooldownPolygon(this.cooldownProgress);
  for (
temp.0temp.this.cooldownImg.polygon.size(); temp.+= 2) {
    
this.cooldownImg.polygon[temp.0] *= 32;
    
this.cooldownImg.polygon[temp.0] += this.skillIconImg.x;
    
    
this.cooldownImg.polygon[temp.1] *= 32;
    
this.cooldownImg.polygon[temp.1] += this.skillIconImg.y
  }
  
  
setTimer(0.05);
}

//temp.progress goes from 0.0 to 1.0, where 0.0 is no cooldown and 1.0 is full cooldown.
//Returns an array compatible with TShowImg.polygon with coordinates ranging from (0, 0) to (1, 1).
function getCooldownPolygon(temp.progress)
{
  
temp.angleInDegrees temp.progress 360;
  
  if (
temp.angleInDegrees <= 0) return null;
  if (
temp.angleInDegrees >= 360) return {0.00.01.00.01.01.00.01.0};
  
  
temp.polygon = {
    
0.50.5,
    
0.50.0
  
};
  
  
temp.degtorad(90 temp.angleInDegrees);
  
temp.dx = +cos(temp.a);
  
temp.dy = -sin(temp.a);
  
  if (
temp.angleInDegrees 0) {
    if (
temp.angleInDegrees 45) {
      
temp.polygon.add(0.5 - (temp.dx/temp.dy) * 0.5);
      
temp.polygon.add(0);
    }
    else {
      
temp.polygon.add(0.0);
      
temp.polygon.add(0.0);
    }
  }
  
  if (
temp.angleInDegrees >= 45) {
    if (
temp.angleInDegrees 135) {
      
temp.polygon.add(0.0);
      
temp.polygon.add(0.5 - (temp.dy/temp.dx) * 0.5);
    }
    else {
      
temp.polygon.add(0.0);
      
temp.polygon.add(1.0);
    }
  }
  
  if (
temp.angleInDegrees >= 135) {
    if (
temp.angleInDegrees 225) {
      
temp.polygon.add(0.5 + (temp.dx/temp.dy) * 0.5);
      
temp.polygon.add(1.0);
    }
    else {
      
temp.polygon.add(1.0);
      
temp.polygon.add(1.0);
    }
  }
  
  if (
temp.angleInDegrees >= 225) {
    if (
temp.angleInDegrees 315) {
      
temp.polygon.add(1.0);
      
temp.polygon.add(0.5 + (temp.dy/temp.dx) * 0.5);
    }
    else {
      
temp.polygon.add(1.0);
      
temp.polygon.add(0.0);
    }
  }
  
  if (
temp.angleInDegrees >= 315) {
    if (
temp.angleInDegrees 360) {
      
temp.polygon.add(0.5 - (temp.dx/temp.dy) * 0.5);
      
temp.polygon.add(0.0);
    }
    else {
      
temp.polygon.add(0.5);
      
temp.polygon.add(0.0);
    }
  }
  
  return 
temp.polygon;

The important code with all the math in it is the getCooldownPolygon function.
Assembly required. "Batteries not included."
__________________
Testbed user: I figured since I can never find any scripters it was time to take desperate measures...and...TEACH MYSELF 0.0
Reply With Quote
  #2  
Old 10-04-2012, 09:39 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Tig did something almost identical for Kingdoms iPhone. A neat effect.
__________________
Reply With Quote
  #3  
Old 10-04-2012, 10:39 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
At some point, Blizzard added a very helpful line to this concept, which was being used in WoW before already. Kind of like the hand of a clock. Helps with visibility on some icons/backgrounds. Would work well on this, too, I believe. Nice work regardless, though.
__________________
Reply With Quote
  #4  
Old 10-04-2012, 11:22 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
Lovely.
__________________
Reply With Quote
  #5  
Old 10-05-2012, 12:22 AM
smirt362 smirt362 is offline
Tee Hee
smirt362's Avatar
Join Date: Feb 2005
Location: Texas
Posts: 2,101
smirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant future
Send a message via AIM to smirt362 Send a message via MSN to smirt362
Neato!
__________________

Don Hertzfeldt <3
Reply With Quote
  #6  
Old 10-05-2012, 01:38 AM
Cloven Cloven is offline
Delteria
Cloven's Avatar
Join Date: Dec 2006
Location: Florida, United States
Posts: 542
Cloven has a spectacular aura about
Send a message via AIM to Cloven
Yeah, I dig it. Clean, logical, effective...
Reply With Quote
  #7  
Old 10-05-2012, 03:47 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Nice work.

Quote:
Originally Posted by Crow View Post
At some point, Blizzard added a very helpful line to this concept, which was being used in WoW before already. Kind of like the hand of a clock. Helps with visibility on some icons/backgrounds. Would work well on this, too, I believe. Nice work regardless, though.
Cool idea.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:51 PM.


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