Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Trouble setting the shape of gralats. (https://forums.graalonline.com/forums/showthread.php?t=134262094)

Jiroxys7 02-14-2011 02:52 AM

Trouble setting the shape of gralats.
 
I altered the gralat class a while back. But I noticed that it's "touch box" extends a few tiles to the left compared to the right. I've tried fixing this with setshape, but it doesn't seem to alter anything. It is still using a gani, and i used the old gralats.gani text file as a template if that matters.
It's kind of annoying really, especially if you drop a gralat to the right of you because then you have to actually "dodge" it's shape or else you'll end up picking it back up.

Any idea what might be causing this?

MrOmega 02-14-2011 04:01 AM

Did you try using setshape2( W, H, ARRAY);

Jiroxys7 02-14-2011 04:38 AM

Quote:

Originally Posted by MrOmega (Post 1630683)
Did you try using setshape2( W, H, ARRAY);

No luck. tried a 2x2 area, a 1x1 area, and a 4x4 area. All 3 had the exact same shape.

MrOmega 02-14-2011 06:12 AM

can you show the part of the script with setshape?

ffcmike 02-14-2011 02:30 PM

Is it using showcharacter();?
This will force a 32 x 32 pixel shape with the x and y of the shape being offset by 0.5 and 1 tiles.

Toxen 02-14-2011 05:15 PM

Try,

setshape(1,16,32);

1 - is the shape and I believe their is still only a rectangle you can use so it's 1.
16 - is the width, 1 tile wide
32 - is the height so 2 tiles high.

Should work for the shape of a gralat.

Crow 02-14-2011 05:33 PM

Ganis + shapes can cause some trouble and confusion. If you don't care about bling, convert this to images instead of ganis. You'll then be happy.

DustyPorViva 02-14-2011 05:45 PM

Quote:

Originally Posted by Crow (Post 1630745)
Ganis + shapes can cause some trouble and confusion. If you don't care about bling, convert this to images instead of ganis. You'll then be happy.

Can they? O.o

Crow 02-14-2011 05:57 PM

Quote:

Originally Posted by DustyPorViva (Post 1630748)
Can they? O.o

Yup, I'd say they can. Same thing happened to me, basically. Using different shapes will change the actual shape, but in a strange way that still seems inaccurate. I have no idea why.

DustyPorViva 02-14-2011 06:17 PM

Quote:

Originally Posted by Crow (Post 1630750)
Yup, I'd say they can. Same thing happened to me, basically. Using different shapes will change the actual shape, but in a strange way that still seems inaccurate. I have no idea why.

Dunno what you're talking about... I've never had a problem using showcharacter + setshape. It sets the shape of the NPC using the blocking specifications of a player(x+.5,y+1). That's where the blocking starts, instead of the normal 0,0. This allows you to easily create blocking NPC's that also draw a portion of the player(like a tree) simply by aligning it correctly in the gani. This is the same method that 2k2 uses on most of their trees and houses.

Crow 02-14-2011 06:22 PM

Quote:

Originally Posted by DustyPorViva (Post 1630758)
Dunno what you're talking about... I've never had a problem using showcharacter + setshape. It sets the shape of the NPC using the blocking specifications of a player(x+.5,y+1). That's where the blocking starts, instead of the normal 0,0. This allows you to easily create blocking NPC's that also draw a portion of the player(like a tree) simply by aligning it correctly in the gani. This is the same method that 2k2 uses on most of their trees and houses.

It works well when you just need **** that blocks, yes. I'm more concerned about the "hitboxes" for the PlayerTouchsMe event when using showcharacter and ganis, because these seem to be friggin strange in every possible aspect.

Fulg0reSama 02-14-2011 06:41 PM

Quote:

Originally Posted by Crow (Post 1630759)
It works well when you just need **** that blocks, yes. I'm more concerned about the "hitboxes" for the PlayerTouchsMe event when using showcharacter and ganis, because these seem to be friggin strange in every possible aspect.

You're friggin strange in every possible aspect

Crow 02-14-2011 07:41 PM

Quote:

Originally Posted by Fulg0reSama (Post 1630762)
You're friggin strange in every possible aspect

Duh.

Jiroxys7 02-15-2011 12:29 AM

showcharacter() and all of that other stuff didn't fix it. The only solution that appears to have worked is Crow's suggestion to show it as an image. For some reason, I guess the ganis refuse to have their shapes altered. Although there doesn't seem to be any good reason on why they should act that way.

DustyPorViva 02-15-2011 12:43 AM

Quote:

Originally Posted by Jiroxys7 (Post 1630798)
showcharacter() and all of that other stuff didn't fix it. The only solution that appears to have worked is Crow's suggestion to show it as an image. For some reason, I guess the ganis refuse to have their shapes altered. Although there doesn't seem to be any good reason on why they should act that way.

You'd get more help if you posted the script. It's hard to help people when you have to take a shot in the dark and guess what the problem could possibly be, if it could even possibly exist. Scripting can be complex, so there's a multitude of things that can be causing problems.

salesman 02-15-2011 12:53 AM

Make sure you position the sprite correctly in the gani. If it's not on the 0,0 spot, then you'll have the problem you're describing.

Jiroxys7 02-15-2011 01:13 AM

Quote:

Originally Posted by DustyPorViva (Post 1630806)
You'd get more help if you posted the script. It's hard to help people when you have to take a shot in the dark and guess what the problem could possibly be, if it could even possibly exist. Scripting can be complex, so there's a multitude of things that can be causing problems.

PHP Code:

function onCreated() {
  
//showcharacter();
  
setgani();
  
scheduleevent(20,"Destroy",NULL);
  
this.dontblock();
  
setshape(1,2,32);
}

function 
setgani(){
  if(
this.amount<=-1temp.type 10;      //(Black)
  
elseif(this.amount==1temp.type 1;    //(Green) 
  
elseif(this.amount<=5temp.type 2;    //(Blue)
  
elseif(this.amount<=10temp.type 3;   //(Yellow)
  
elseif(this.amount<=20temp.type 4;   //(Red)
  
elseif(this.amount<=50temp.type 5;   //(Purple)
  
elseif(this.amount<=100temp.type 6;  //(Orange)
  
elseif(this.amount<=200temp.type 7;  //(Silver)
  
elseif(this.amount<=300temp.type 8;  //(Gold)
  
elseif(this.amount<=500temp.type 9;  //(Crystal)
  
setcharani("j7_rupees"temp.type);
}

function 
onDestroy(){
  
this.destroy();
}


function 
onPlayertouchsme(){
    if(
player.>= this.0.5 && player.<= this.0.5){
      if(
player.rupees == clientr.walletsize){player.chat "I cannot hold any more!"; return;}
      if(
this.aniparams != 10){
        
player.rupees += this.amount;
        
player.chat "I got" SPC this.amount "g!";
        
this.amount 0;
        
this.destroy();
      }
      else{
      
player.chat "Oh, no! I dropped" SPC abs(this.amountSPC "g!";
      
this.destroy();
    }
  }
}

//#CLIENTSIDE
function onCreated(){
  
setshape(1,16,32);
  
this.canplay 1;
  
play("item.wav");
  
setTimer(15);
}
function 
onPlayertouchsme(){
  if(
player.>= this.0.5 && player.<= this.0.5){
    if(
player.rupees == clientr.walletsize){return;}
    if(
this.canplay 1){
      
this.canplay 0;
      
play("extra.wav");
      
this.alpha 0;
    }
  }
}

function 
onTimeout(){
  if(
this.canplay == 1){  
    if(
this.alphaswitch == 0){this.alpha 1;this.alphaswitch 1;}
    elseif(
this.alphaswitch == 1){this.alpha 0;this.alphaswitch 0;}
    
setTimer(0.05);
  }


when I use showcharacter() on it, the box will be far too large. but if I get rid of it, the smaller box seems to be shifted over to the left.


Quote:

Originally Posted by salesman (Post 1630811)
Make sure you position the sprite correctly in the gani. If it's not on the 0,0 spot, then you'll have the problem you're describing.

That did the trick!

edit: nevermind!

DustyPorViva 02-15-2011 01:24 AM

Also:
function onCreated(){
setshape(1,2,32);
this.canplay = 1;
play("item.wav");
setTimer(15);
}
You're setting the shape to 2 pixels. Typo? :P

Jiroxys7 02-15-2011 01:29 AM

Quote:

Originally Posted by DustyPorViva (Post 1630818)
Also:
function onCreated(){
setshape(1,2,32);
this.canplay = 1;
play("item.wav");
setTimer(15);
}
You're setting the shape to 2 pixels. Typo? :P

No typo there. Sorta. I was just testing it right now to make sure the shape is actually being set. It's normally 16. Looks like I forgot to revert it in the post. You see, a lot of the time when I post something like this on the forums, I'm in the middle of messing with various portions of the code. I usually have to clean it all up before I post them. Coulda sworn I fixed that part in the post though. Guess not lol :p

edit: OH right. That was the clientside portion. I remember catching that in my script but neglected to edit my post. That's a different problem I was having where I was picking up the rupee and it was destroying, but no sound was being played about half the time. The canplay stuff was left over when I had it hide and sleep on the serverside after being touched before destroying itself in attempts to give it plenty of time to play the sound in case it was lag. That prevented the sound from playing again when you ran over the spot with the invisible rupee. Didn't fix it though, so I took the serverside portion of the script out. I left the clientside stuff there since I have a jump script that I'm experimenting with. It would play the sound if you jumped over it but didn't actually grab the rupee. On second thought though, I can just put that Z detection there too. Of course, this is all still unrelated to the hitbox problem.


All times are GMT +2. The time now is 08:09 AM.

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