Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-07-2013, 12:32 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Rotate Param1 in gani script

I feel stupid because I feel like I should know this, but I can't get it to work and have never done it before. I'm just trying to put a script in a gani to rotate the image set in param1. The below doesn't work.

PHP Code:
function onPlayerEnters() {
    
this.rotationpi*2;

Also tried this, and no go
PHP Code:
SCRIPT
function onPlayerEnters() {

    
this.daImg params[0];

    echo(
this.daImg);
    
doTheRotator();

}


function 
doTheRotator() {

    
this.rotation += 2;
        
//this.rotation = pi*2; tried this too

}
SCRIPTEND 
I'm not gonna lie, because it'd be too obvious if I tried, but I have absolutely no idea what I'm doing lol. I just want the gani to rotate when its set, then entire dang thing, because its only params1 in it. Dunno if its possible and I've never rotated a thing in my life. Just need it to roll over once.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 09-07-2013 at 02:21 AM..
Reply With Quote
  #2  
Old 09-07-2013, 02:39 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Tried ROTATEFFECT? Or are you needing to have it constantly rotate?
__________________
Deep into the Darkness peering...
Reply With Quote
  #3  
Old 09-07-2013, 02:41 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I don't know how rotateeffect works. I had a look at atlantis' sword gani, with

ROTATEEFFECT 301 5.89048622548086

But besides it being the sprite id and some kind of radius/degree??? I don't really understand what's going on. I don't really know what is the starting value for rotateeffect and what the ending value is for a complete rotation (degrees? rad?).

I just need it to roll over once and be done.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #4  
Old 09-07-2013, 03:24 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
It seems I'm using this wrong? I only see the image turn once...

PHP Code:
GANI0001
SPRITE    1          PARAM1    0    0   32   32 Param1

SINGLEDIRECTION
DEFAULTPARAM1 block
.png
DEFAULTPARAM2 item
.wav
DEFAULTHEAD head19
.png
DEFAULTBODY body
.png

ROTATEEFFECT 1 23
ROTATEEFFECT 1 45
ROTATEEFFECT 1 77
ROTATEEFFECT 1 90
ROTATEEFFECT 1 111
ROTATEEFFECT 1 135
ROTATEEFFECT 1 152
ROTATEEFFECT 1 180
ROTATEEFFECT 1 201
ROTATEEFFECT 1 225
ROTATEEFFECT 1 247
ROTATEEFFECT 1 270
ROTATEEFFECT 1 292
ROTATEEFFECT 1 315
ROTATEEFFECT 1 338
ROTATEEFFECT 1 360

ANI
   1  
-8  -8
ANIEND 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #5  
Old 09-07-2013, 05:06 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
ROTATEEFFECT only works once with each sprite number. Also the rotation number is in radians.

To show the rotation you need to script it. You can manipulate sprites by using findImg( <sprite number>).

PHP Code:
GANI0001
SPRITE    1          PARAM1    0    0   32   32 Param1

SINGLEDIRECTION

ANI
   1  
-8  -8
ANIEND
 
SCRIPT 
function onPlayerEnter()
{

  for ( 
findImg(1).rotation 0findImg1).rotation < ( pi); findImg1).rotation += ( pi 8);)
    
sleep0.05);

}
SCRIPTEND 
__________________
Deep into the Darkness peering...

Last edited by Angel_Light; 09-07-2013 at 06:44 AM..
Reply With Quote
  #6  
Old 09-07-2013, 01:43 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
ahhh so you use findimg per the sprite id. Didn't know you could do that.


So my last issue is it seems its doing both if commands in rollImg and it shouldn't be. I'm passing the player.dir through in PARAM3, and in echo before it sets the ani it's correct and only sends once, but when you are dir 2 or 3 it still does 0 and 1 for some reason. If you are 0 and 1 dir, then it only does dir 1 and 2. I can't figure out for the life of me why it's doing 0/1 when the dir is 2 or 3.

PHP Code:
SCRIPT
function onPlayerEnters()
{

  
play(params[1]);

  
this.moveway params[2];
  
rollImg();

}

function 
rollImg() {
echo(
"made it");
  if (
this.moveway <= 1) {
echo(
"left up");
    for (
findImg(1).rotation 0findImg(1).rotation > (-(pi)); findImg(1).rotation -= (pi 4);)

      
sleep(0.05);
  }
  if (
this.moveway >= 2) {
echo(
"down right1");
    for (
findImg(1).rotation 0findImg(1).rotation < (pi); findImg(1).rotation += (pi 4);)

      
sleep(0.05);
  }
}
SCRIPTEND 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 09-07-2013 at 02:58 PM..
Reply With Quote
  #7  
Old 09-07-2013, 04:50 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
This is how I would do it.

Generate the GANI:

PHP Code:
function onCreated() {
  
temp.anim = new TStaticVar();
  
temp.anim.join("gani");
  
temp.anim.setSingleDir(true);
  
temp.anim.setLooped(true);
  
temp.anim.setContinuous(true);
  
temp.frames 20;
  
temp.rinc   = (pi 2) / temp.frames;
  
temp.anim.frames = new[temp.frames];
  for (
temp.1temp.<= temp.framestemp.i++) {
    
temp.anim.addSprite(temp.i"PARAM1"003232"");
    
temp.anim.addRotateEffect(temp.itemp.r);
    
temp.+= temp.rinc;
    
temp.anim.setFrameSprites(temp.i-10, {{temp.i00}});
  }
  
temp.anim.savegani("temp/rotatetest.gani");
  
temp.anim.destroy();

Using: http://forums.graalonline.com/forums...hp?t=134261809

Significantly more reliable than GANI script. Attached the output.
Attached Files
File Type: gani rotatetest.gani (2.2 KB, 165 views)
__________________
Quote:
Reply With Quote
  #8  
Old 09-08-2013, 03:56 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I saw this a few weeks ago, but with how small of a thing I'm doing it's a bit much, and the work to redo all my stuff is a bit cumbersome at this point (I'd rather have one way than 2 separate ones for the same thing in different places), but it is much nicer don't get me wrong.


I went ahead and just dropped the idea I was doing. Keeping this open for the answers though, maybe something will help someone else possibly.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #9  
Old 09-08-2013, 06:03 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by sssssssssss View Post
I saw this a few weeks ago, but with how small of a thing I'm doing it's a bit much, and the work to redo all my stuff is a bit cumbersome at this point (I'd rather have one way than 2 separate ones for the same thing in different places), but it is much nicer don't get me wrong.


I went ahead and just dropped the idea I was doing. Keeping this open for the answers though, maybe something will help someone else possibly.
Can't really test it right now but it looks like you want to do an if/else statement instead of two if statements, try this and see if it works?

PHP Code:
SCRIPT
function onPlayerEnters()
{

  
playparams1]);
  
this.moveway params2];
  
rollImg();

}

function 
rollImg() 
{

  if ( 
this.moveway 2
  {

    echo( 
"left up");
    
    for ( 
findImg1).rotation 0findImg1).rotation > (-(pi)); findImg1).rotation -= (pi 4);)
      
sleep(0.05);
 
  }

  else 
  {

    echo( 
"down right1");
    
    for ( 
findImg1).rotation 0findImg1).rotation < (pi); findImg1).rotation += (pi 4);)
      
sleep(0.05);
  
  }
}
SCRIPTEND 
__________________
Deep into the Darkness peering...

Last edited by Angel_Light; 09-08-2013 at 06:15 AM..
Reply With Quote
  #10  
Old 09-08-2013, 01:18 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I tried an else as well, and else if, but it seemed to always call both when it did down right.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #11  
Old 09-08-2013, 01:24 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Did you try the script I posted? I just tested it and it worked for me.
__________________
Deep into the Darkness peering...
Reply With Quote
  #12  
Old 09-10-2013, 11:11 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I completely dropped the scripted and already changed things.

I did try basically that (if I remember right) and it didn't work for whatever reason.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


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 08:22 PM.


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