Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   A little help >.> (https://forums.graalonline.com/forums/showthread.php?t=44236)

Chicken_l33t 04-13-2003 02:13 PM

A little help >.>
 
I was mucking around with 360 Rotations and all and I joined all the NPCs with npc[i].x and y and it all worked out fine, then I came across a problem when I added a new one and one went missing and I double checked >.>.

is there a max of npcs that can be on npc[i].x and y?.

Ningnong 04-13-2003 02:59 PM

well, if you do a for loop to index all the npcs, it will include all the npcs. ( I dont know what you mean, 'max' ).

This is an example, of using a for loop with npcs[index]

NPC Code:

//#CLIENTSIDE
if (created) {
speed = 1;
timeout = .05;
}
if (timeout){
for (i=0;i<npcscount;i++){
dx = npcs[i].x - playerx;
dy = npcs[i].y - playery;
dist = (dx*dx+dy*dy);
newx = (dx/dist)*speed;
newy = (dy/dist)*speed;
npcs[i].x += newx;
npcs[i].y += newy;
}
timeout = .05;
}




Thats just an example of how to use it. (npcs move away from player)

help at all?

Ningnong 04-13-2003 03:11 PM

*edited the script*

yea your right heh. I just wasn't sure if he was indexing all the npcs, somehow, but there ya go hehe.

And Chicken, maybie if you posted part of your script we could see why its stopping, or if your doing it correctly :P

Chicken_l33t 04-13-2003 03:17 PM

Yeh exactly what I ment Kai, sorry I wasent clear lol.
I'll try your script soon ning and see if it's what's the problem but i'm sure it's the array and one of the parts in the array have gone missing, maybe it's a spelling mistake (but I don't think it is).

Chicken_l33t 04-13-2003 04:04 PM

I'll just cut it down, wont be to hard lol.

and i'll do some spell checks and all I just wanted to know if there was a max, the scripts fine but yeh it could be a bug.
*goes to sleep*

Ningnong 04-14-2003 11:01 PM

1 Attachment(s)
Quote:

Originally posted by Kaimetsu
It might be a bug in Graal (eg, it might be limited to 256 elements or something), but I'd need to see the script to be sure.
I was thinking, I don't know what you mean by elements, if you mean npcs then It can't be the bug.

Attached is a level with 256 + npcs in.
I also added a "eek get away from me" script for the entertainment value, if you change npcs[i].x/y with playerx/y then you get different movement, more like a "eee come here sexy".

Well anyway, yea.

osrs 04-15-2003 03:09 AM

Quote:

Originally posted by Ningnong


I was thinking, I don't know what you mean by elements, if you mean npcs then It can't be the bug.

Attached is a level with 256 + npcs in.
I also added a "eek get away from me" script for the entertainment value, if you change npcs[i].x/y with playerx/y then you get different movement, more like a "eee come here sexy".

Well anyway, yea.


I added more 70 elements and it's working fine. (Maybe it's a bug as Kai said?)

Ningnong 04-15-2003 12:48 PM

aaah, i see. :grin:


All times are GMT +2. The time now is 06:35 PM.

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