Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 08-23-2010, 07:54 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Live Demo: Testbed Server Weapon: Shared/AniTextDemo
Alternate Demo: Repeats player's chat, showing it on the bottom of the screen. Weapon: Public/adam/AniText
If somebody could try it in opengl mode, and with v6 and tell me how it performs that'd be great. Remember it's my birthday, do it.

Sorry no video this time, wasn't ready to do another one of those o.O
Still a few things to add, but just about every animation possible is added now.
The demo script wasn't meant to be pretty, just randomly animates everything possible. Although it is fun to watch. I suggest trying it out in opengl mode if you can, if you run V6 please let me know how it works too.

PHP Code:
//NPC Created by Rogue Shadow (TCN)
//AIM: RogueTCN
//FORUM PM: adam
// Special messaging prototype 4

//#CLIENTSIDE

// Actions format {"var", time, newvalue}
// string these blocks together for simultanous actions
// add them in succession for sequences.
// or any combination thereof
function onCreated(){
  
this.join("personal_adam_anitext");
  
sleep(.01);// class seems to need just a moment.
  
this.newText(this200screenwidth/3screenheight/3"Testing Text"true);
  
this.m.A( {{"alpha"11}} );
  
this.m.A( {{"delay"1}});
  for (
temp.i=0;temp.i<20;temp.i++){
    
this.m.A( {{"alpha",1,random(0,1)},{"x",1,random(0,screenwidth)},{"y",1,random(0,screenheight)},{"zoom",1,random(.1,5)},{"bgPadding",1,random(2,50)},{"outline",.5,random(1,50)},{"oBlue"1random(0,1)},{"oRed"1random(0,1)},{"oGreen",1,random(0,1)},{"tBlue"1random(0,1)},{"tRed"1random(0,1)},{"tGreen",1,random(0,1)},{"bBlue"1random(0,1)},{"bRed"1random(0,1)},{"bGreen",1,random(0,1)}});
  }
  
this.m.A( {{"alpha",1,1},{"x",1,screenwidth/2},{"y",1,screenheight/2},{"zoom",1,1},{"bgPadding",1,2},{"outline"11},{"tRed"11},{"tGreen",1,1},{"tBlue",1,1},{"bRed",1,0},{"bGreen",1,0},{"bBlue",1,0},{"oRed",1,1},{"oBlue",1,1},{"oGreen",1,1}});
  
this.m.start();

PHP Code:
//#CLIENTSIDE

function newText(temp.scopetemp.start_itemp.xtemp.ytemp.texttemp.useBackground){
  
// Various Declarations to start with.
  
temp.= new TStaticVar();
  
temp.t.global = temp.scope
  
temp.t.start_i temp.start_i;
  
temp.t.temp.xtemp.t.temp.y
  
temp.t.tRed 1temp.t.tGreen 1temp.t.tBlue 1;
  
temp.t.alpha 0;
  
temp.t.layer 10*temp.start_i
  
temp.t.font "Comic Sans MS"temp.t.style ""
  
temp.t.zoom 1
  
temp.t.text temp.text;
  
temp.t.width gettextwidth(temp.t.zoomtemp.t.font""temp.t.text); 
  
temp.t.height gettextheight(temp.t.zoomtemp.t.font"");
  
temp.t.delay true;
  
temp.t.animatable = {"delay","x","y","zoom","alpha","bgPadding","outline","tRed","tBlue","tGreen","bRed","bBlue","bGreen","oRed","oGreen","oBlue"};
  
temp.t.queue = {};
  if (
temp.useBackground != null){    
    
temp.t.background useBackground;  
    
temp.t.bgPadding 2
    
temp.t.outline 2
    
temp.t.bRed 0temp.t.bGreen 0temp.t.bBlue 0;
    
temp.t.oRed 1temp.t.oGreen 1temp.t.oBlue 1;
  }
  
  
temp.t.start = function () {
    
this.started true;
    
this.onUpdate();
  };
  
  
temp.t.stop = function () {
    
this.started false;
  };
  
  
temp.t.= function ( temp.actions ) {
    
this.queue.addtemp.actions );
    
this.count++;
  };

  
temp.t.onUpdate = function () {
    if (!
this.started)return;
    
    for (
temp.actionthis.queue[0]){
      if (
temp.action[0in {"NewText"}){
        if (
this.(@temp.action[0])(temp.action)){
          
this.queue[0].remove(temp.action);
        }
      }elseif(
temp.action[0in this.animatable){
        if (
this.doValue(temp.action)){
          
this.queue[0].remove(temp.action);
        }
      }else 
this.queue[0].remove(temp.action);
    }
    
    if (
this.queue[0].size() == && this.queue.size() > 0this.queue.delete(0);
    
this.draw();
    
this.scheduleevent(0.05"Update"null);
  };

  
temp.t.doValue = function (action) {
    
temp.value temp.action[0];
    
temp.time temp.action[1];
    
temp.newvalue temp.action[2];
    if (
temp.time == 0){
      
this.(@value) = temp.newvalue;
      return 
true;
    }
    if (
this.(@value).dist == null){
      
this.(@value).dist temp.newvalue this.(@value);
      
this.(@value).step this.(@value).dist / (temp.time*20);
    }
    if (
abs temp.newvalue this.(@value)) <= this.(@value).step){
      
this.(@value) = temp.newvalue;
    }else 
this.(@value) += this.(@value).step;
    
    if (
temp.value == "zoom")this.NewText({"NewText",this.text});
    
    if (
this.(@value) == temp.newvalue){
      
this.(@value).dist null;
      
this.(@value).step null;
      
this.delay true;
      return 
true;
    }else return 
false;
  };

  
temp.t.NewText = function (action) {
    
this.text temp.action[1];
    
this.width gettextwidth(this.zoomthis.font""this.text); 
    
this.height gettextheight(this.zoomthis.font"");
    return 
true;
  };

  
temp.t.draw = function (){
    
temp.this.start_i;
    
with (this.global.findimg(temp.i)){
      
thiso.x;  thiso.y;
      
text thiso.text;
      
red thiso.tRed;  green thiso.tGreen;  blue thiso.tBlue;
      
zoom thiso.zoom;
      
font thiso.fontstyle thiso.style;
      
layer thiso.layer;
      
alpha thiso.alpha;
      
mode 1;
    }
    
temp.i++;
    if (!
this.background) return temp.i;
    
with (this.global.findimg(temp.i)){
      
temp.xx=thiso.x;temp.yy=thiso.y;temp.w=thiso.width;temp.h=thiso.height;temp.p=thiso.bgPadding;
      
polygon = {xx-p,yy-p,
                 
xx+w+p,yy-p,
                 
xx+w+p,yy+h+p,
                 
xx-p,yy+h+p};
      
temp.p2 temp.p+thiso.outline;
      
temp.poly2 = {xx-p2,yy-p2,
                 
xx+w+p2,yy-p2,
                 
xx+w+p2,yy+h+p2,
                 
xx-p2,yy+h+p2};

                 
      
layer thiso.layer 1;
      
red thiso.bRed;  green thiso.bGreen;  blue thiso.bBlue;
      
alpha thiso.alphamode 1;
    }
    
temp.i++;
    
with (this.global.findimg(temp.i)){
      
polygon temp.poly2;
      
layer thiso.layer -2;
      
red thiso.oRed;  green thiso.oGreen;  blue thiso.oBlue;
      
alpha thiso.alphamode 1;
    }
    
temp.i++;
    
this.lasti temp.i;
    return 
temp.i;
  };
  
  return 
temp.t;

__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly

Last edited by adam; 08-24-2010 at 05:33 AM..
Reply With Quote
 

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 11:48 AM.


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