Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Baddy bugged on gmap (https://forums.graalonline.com/forums/showthread.php?t=76532)

DustyPorViva 08-27-2007 10:59 PM

Baddy bugged on gmap
 
3 Attachment(s)
I made a baddy(ala zora's in Zelda), and it works fine in regular levels, but once it's put on gmap it completely bugs out. It doesn't show at all, it doesn't echo anything if I put an echo in it, and I can't figure out what's wrong with it. Here's the code, I'll attach the image as well for anyone who wants to mess with it hands on. What I want is it to randomly pop up in the level it originates in, not around the gmap.

Grrr... apparently I'll have to attach the script as well because the forums are being dumb!

Admins 08-28-2007 10:58 AM

Hmmm eventually use onPlayerEnters() instead of onCreated()

PrinceOfKenshin 08-28-2007 01:12 PM

Quote:

Originally Posted by Stefan (Post 1344114)
Hmmm eventually use onPlayerEnters() instead of onCreated()

Woot i was right. I was going to say that but when i hit reply it said bad request.
Because gmaps kinda run all scripts at once and if you have onCreated it will appear once

DustyPorViva 08-28-2007 01:42 PM

Well, I changed that and it didn't help anything. This shows up in F2:
GraalScript: Loop limit exceeded in script of (in level vs_world-a3.nw at pos (35, 32))
And still not showing anything, and not executing the scripts.

Angel_Light 08-28-2007 01:56 PM

havent looked at the script but did your try that % thing?

Chompy 08-28-2007 02:50 PM

Could easier with a onwater2() ;o

Admins 08-28-2007 03:16 PM

Do something like this to prevent endless loop:
PHP Code:

  for (i=0i<4i++) {
    
this.this.gmapo[0]*64 int(random(0,62));
    
this.this.gmapo[1]*64 int(random(0,62));
    if (
onwater(this.x-1+(i%2), this.y-1+int(i/2)))
      break;
  } 


DustyPorViva 08-28-2007 03:33 PM

Quote:

Originally Posted by Chompy (Post 1344157)
Could easier with a onwater2() ;o

I did that at first, but for some reason it wasn't working right. It'd find water, but half the time it appear half-way off the water for some reason, so I ditched it.

Chompy 08-28-2007 03:38 PM

Quote:

Originally Posted by DustyPorViva (Post 1344163)
I did that at first, but for some reason it wasn't working right. It'd find water, but half the time it appear half-way off the water for some reason, so I ditched it.

Tried Stefan's method/correction?

oh, and at onwater2:

!onwater2(this.x - 1, this.y - 1, 64, 64)

DustyPorViva 08-28-2007 10:51 PM

Hmm, Stefan's method doesn't actually force the NPC to spawn in water.
It works... but it'll spawn on land and such. So it's obvious the problem is the loop limit, although I dunno why it doesn't work on gmap's when it works fine on .nw's

coreys 08-29-2007 12:24 AM

Hm, I generally prefer baddies to be serverside, because it makes it more like a true MMO, and less like a single player game where other players happen to be there, but still, nice work. But, unfortunately I believe this.level will return the gmap name, you'd have to script it to figure out the level name based on the x/y on the GMAP, which I believe the default profiles in Graal do when you look at your own profile. There's probably a few ways you could do it.

DustyPorViva 08-29-2007 12:33 AM

I was going to do it serverside, but there's too many complications with that. Also, shootball() doesn't work serverside, and I can't use projectiles for that(I originally did, but they disappeared on wall collision, defeating the purpose of this baddy).
And I've deducted that it's the loop causing the problem(see above post), because when the loop was removed, it works fine... except of course it spawns on land because it's not checking for water.

DustyPorViva 08-31-2007 06:55 AM

I think I've finally 'fixed' the problem. Instead of finding water every time it warps, I'm simply going to have a 256 loop when it's created, and check every 4x4 square, and if it's water, add it to an array, and when it's time to warp, pick it's position from the array.

EDIT: seems this is not working...
PHP Code:

  this.gmapo={int(thiso.x/64),int(thiso.y/64)};
  
this.waterspots = new[256];
  for (
i=0;i<256;i++) {
    
this.waterspots[i]=i;
    if (!
onwater2((this.gmapo[0]*64)+((i%16)*4),(this.gmapo[1]*64)+(int(i/16)*4),4,4)) {
      
this.waterspots[i]=-1;
      
showimg(i+500,"door.png",(this.gmapo[0]*64)+((i%16)*4),(this.gmapo[1]*64)+(int(i/16)*4));
    }
  } 

The point of this is to run through the level and whatever is NOT water, erase it from the array. Now, even besides that, check out the showimg bit. It should show a door at ever 4x4 square that is NOT water. It shows doors throughout the whole level, even where there is water. It makes absolutely no sense!


All times are GMT +2. The time now is 08:29 PM.

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