Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   this.radius, etc. (https://forums.graalonline.com/forums/showthread.php?t=8289)

Shard_IceFire 07-28-2001 04:37 AM

this.radius, etc.
 
Ok I know this is a n00b question, but here goes:
How do you just have something move in a circle repeatedly? I hardly ever need it, but when I do, I get mad that I haven't learned it. I know it uses stuff like this.radius, but I forgot how...

LiquidIce00 07-28-2001 05:09 AM

this.radius is just a made up var..
you dont really need it . I personally use it just to say how far from the player. here is a little code for money that goes in a circle with adding radius(called spiraladd if u notice)..
NPC Code:

//npc made by LiquidIce
if (playertouchsme) {
toweapons Spiral Gold;
}

if (weaponfired) {
this.angle=0;
this.radius = 3;
this.spiraladd = 0;
while (this.angle<10) {
this.x=sin(this.angle);
this.y=cos(this.angle);
this.x*=(this.radius+this.spiraladd);
this.y*=(this.radius+this.spiraladd);
this.x+=(playerx);
this.y+=(playery);
lay2 goldrupee,this.x,this.y;
this.angle+=.2;
this.spiraladd+=.2;
sleep .01;
}
}


Brady2 07-28-2001 05:12 AM

Jadis:
NPC Code:


if (playerenters||timeout) {
timeout = .05;
this.radius = 10;
this.angle+=.314;
this.x = x+sin(this.angle)*this.radius;
this.y = y+cos(this.angle)*this.radius;
showimg 0,@Arial@@hi friend,this.x,this.y;
}


LiquidIce00 07-28-2001 05:17 AM

Quote:

Originally posted by Brady2
Jadis:
NPC Code:


if (playerenters||timeout) {
timeout = .05;
this.radius = 10;
this.angle+=.314;
this.x = x+sin(this.angle)*this.radius;
this.y = y+cos(this.angle)*this.radius;
showimg 0,@Arial@@hi friend,this.x,this.y;
}


I suggest you reset the angle every circle it does , else in minutes it will be a HUGEEEEEEEEEEEEEE variable.

and forgot here is the code
NPC Code:

if (playerenters||timeout) {
timeout = .05;
this.radius = 10;
this.angle+=.314;
if (this.angle>6.28) { this.angle=.314; }
this.x = x+sin(this.angle)*this.radius;
this.y = y+cos(this.angle)*this.radius;
showimg 0,@Arial@@hi friend,this.x,this.y;
}


Shard_IceFire 07-28-2001 05:17 AM

Thanks!

Brady2 07-28-2001 05:24 AM

Jadis:

It does not matter

LiquidIce00 07-28-2001 05:53 AM

Quote:

Originally posted by Brady2
Jadis:

It does not matter

well if i idle in your level for a bit the variable gets hugeeeeee
it matters =(

grim_squeaker_x 07-28-2001 05:59 PM

this.angle=this.angle%6.28
:rolleyes:

LiquidIce00 07-29-2001 03:27 AM

Quote:

Originally posted by grim_squeaker_x
this.angle=this.angle%6.28
:rolleyes:

liek lol . i aint a math magician . im used to if .. but yeah u can just use MOD..
but it would be
this.angle=(this.angle+.324)%6.28;

Brady2 07-29-2001 06:33 AM

Jadis:

you said .324!!!!!!!!!!!!!!!!!

LiquidIce00 07-29-2001 09:06 AM

.314 or .324 .. who cares =)

grim_squeaker_x 07-29-2001 03:32 PM

Quote:

Originally posted by LiquidIce00


liek lol . i aint a math magician . im used to if .. but yeah u can just use MOD..
but it would be
this.angle=(this.angle+.324)%6.28;

Actually in Graal you can just use mod.


All times are GMT +2. The time now is 11:39 AM.

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