Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-23-2011, 07:40 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Gani Generator (360 degrees)

Here's an example on how to make ganis via script, it's alot easier than you think (if you're interested in learning it)

This script generates the Era iPhone car ganis (Including other passengers)
PHP Code:
function onCreated() {
  
generateCarGani();
}

function 
generateCarGani() {
  
temp.framecount 64;

  echo(
"GANI0001");
  echo(
"SPRITE  100                HEAD  0    0   32   32 head up");
  echo(
"SPRITE  101                HEAD  0   32   32   32 head left");
  echo(
"SPRITE  102                HEAD  0   64   32   32 head down");
  echo(
"SPRITE  103                HEAD  0   96   32   32 head right");

  for (
temp.i=0temp.i<=temp.framecounttemp.i++)
    echo(
format("SPRITE  %3d               ATTR2  0    0   64  106 car"500+temp.i));
  for (
temp.i=0temp.i<=temp.framecounttemp.i++)
    echo(
format("SPRITE  %3d era_spotlight_1.png  0    0   64  128 spot light"600+temp.i));

  for (
temp.i=0temp.i<=temp.framecounttemp.i++) {
    
temp.angle = (pi/2*pi temp.i/temp.framecount) % (2*pi);
    echo(
format("ROTATEEFFECT %3d %f"500+temp.itemp.angle));
    echo(
format("ROTATEEFFECT %3d %f"600+temp.itemp.angle));
    echo(
format("EFFECTMODE %3d 0"600+temp.i));
    echo(
format("COLOREFFECT %3d 1 1 0.8 0.6"600+temp.i));
  }

  echo(
"CONTINUOUS");
  echo(
"SINGLEDIRECTION");
  echo(
"DEFAULTATTR1 era_car0_0.png");
  echo(
"DEFAULTHEAD head19.png");
  echo(
"DEFAULTBODY body.png");

  echo(
"ANI");
  for (
temp.i=0temp.i<=temp.framecounttemp.i++)
    
generateGaniFrame(temp.itemp.framecount);
  echo(
"ANIEND");
}

function 
generateGaniFrame(curframemaxframe) {
//   car  -8 -21, light  -32 -128, light   13 -128, playerhead 9 20
// Head: 100-103
// Car: 500+
// Light: 600+

  
temp.angle 2*pi curframe/maxframe;
  
temp.str "";
  
  
// Car sprite
  
temp.str @= format("%4d %4d %4d"500+curframe, -8, -21);
  
  
// Left light
  
temp.lightsvec = {-1.455.95};
  
temp.1.5 2;
  
temp.2   4;
  
temp.+= cos(temp.angle)*temp.lightsvec[1] + sin(temp.angle)*temp.lightsvec[0];
  
temp.+= cos(temp.angle)*temp.lightsvec[0] - sin(temp.angle)*temp.lightsvec[1];
  
temp.str @= format(", %4d %4d %4d"600+curframeint(temp.x*16), int(temp.y*16));

  
// Right light
  
temp.lightsvec = {1.355.95};
  
temp.1.5 2;
  
temp.2   4;
  
temp.+= cos(temp.angle)*temp.lightsvec[1] + sin(temp.angle)*temp.lightsvec[0];
  
temp.+= cos(temp.angle)*temp.lightsvec[0] - sin(temp.angle)*temp.lightsvec[1];
  
temp.str @= format(", %4d %4d %4d"600+curframeint(temp.x*16), int(temp.y*16));
  
  
// Player head and npc head
  
temp.dir getdir(cos(temp.angle), -sin(temp.angle));
  
temp.playerstr format(", %4d %4d %4d"100+temp.dir88);
  
temp.headx 0;
  
temp.heady = -2;
  
temp.temp.heady*cos(temp.angle) + temp.headx*sin(temp.angle);
  
temp.temp.headx*cos(temp.angle) - temp.heady*sin(temp.angle);
  
temp.npcstr format(", %4d %4d %4d"104+temp.dir8+int(temp.x*16), 8+int(temp.y*16));
  if (
temp.>= 0) {
    
temp.str @= temp.playerstr;
    
temp.str @= temp.npcstr;
  } else {
    
temp.str @= temp.npcstr;
    
temp.str @= temp.playerstr;
  }

  echo(
temp.str);  

__________________
Reply With Quote
 


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 02:12 PM.


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