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 08-30-2001, 02:48 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Non-linear random movement

Hey guys, does anyone know how to make NPCs move in a curved form, but randomly throughout the level? The onwall would also be helpful for that too... If anyone can help, thanks!
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #2  
Old 08-30-2001, 02:50 AM
AlexH AlexH is offline
Have A Drink On Me
AlexH's Avatar
Join Date: Jun 2001
Location: Somewhere In Time
Posts: 7,442
AlexH is on a distinguished road
Send a message via AIM to AlexH Send a message via MSN to AlexH
so you wat an NPC that moves around a level in a wavey form and it also has to have onwall
what exactly do you need this for?
__________________
QUICK LOOK BUSY JESUS IS COMING!
Reply With Quote
  #3  
Old 08-30-2001, 03:07 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
just do random angle and do sine + cosine .. not hard
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #4  
Old 08-30-2001, 03:15 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Bosses and baddies, Alex...

LiquidIce, could you show me a bit more? I haven't learned geometry yet, so I don't even really know how any of that works...
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #5  
Old 08-30-2001, 03:52 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Damnit Kai! You say a lot of stuff that almost never helps... Why not trying to teach something about it?
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #6  
Old 08-30-2001, 06:49 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Well... I'm pretty sure you don't wanna waste all that time (if you are, I'll willing to learn), so could you teach me a little something that might help, or point out a site to teach?
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #7  
Old 08-30-2001, 07:21 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
Quote:
Originally posted by Kaimetsu
LiquidIce's is the standard way, but it won't be truly random and it'll look strange at certain angles. But without delving into more advanced maths, it's probably the best way.
if it was me ..
I would do an array of next movements.. like I would randomize an angle then I would check prolly 5 steps more with that same angle (or angle -1 for each step or whatever)
then I would do onwall check to make everything is fine and walk it thru the array.
so you would do curves..
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #8  
Old 08-30-2001, 08:52 AM
Vinvect Vinvect is offline
Registered User
Join Date: Aug 2001
Location: U.S.A,California,Milpitas,In A House,In Room,On A Seat,On a Computer
Posts: 157
Vinvect is on a distinguished road
Send a message via ICQ to Vinvect Send a message via Yahoo to Vinvect
yea mee too

i saw like this.blah=cos blah blah
this.blah=sin blahblahblahi need help too
what cos and sin is
:grrr: :grrr: :grrr:
oh yeah heres a pic (Really good)
Attached Thumbnails
Click image for larger version

Name:	graal.png
Views:	228
Size:	20.3 KB
ID:	3747  
__________________
==========================
I Script Really Good
&
Looking For A NAT Job
==========================
Quote:
That's like a big lugee!
-Evolution The Movie
Quote:
Ha Ha Ha Give It Up!
-Cyrus From Bomberman
I'm not a Bomy anymore.
I'm a MUTATED BROCLI MONSTER!
(or SIGN MONSTER)
If you make me angry,
I'LL EAT YOU WHOLE!
ME, MUTATED BROCLI MONSTER MASTER
(or SIGN MONSTER)
WILL EAT YOU ALL UP!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Quest Valley Owner
Looking For Staff
Pm Me
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
O.o Still Have My Braen Damaegd o.O


Thanks To Esiah, He Made This For Me!
Thanks Esiah!

Last edited by Vinvect; 08-30-2001 at 08:55 AM..
Reply With Quote
  #9  
Old 08-30-2001, 08:57 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Bah, I know that Vinvect... I just don't understand what LiquidIce is talking about.
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #10  
Old 08-30-2001, 04:25 PM
Slaktmaster Slaktmaster is offline
man with the mastahplan
Slaktmaster's Avatar
Join Date: Apr 2001
Location: Half-way over the river styx
Posts: 4,422
Slaktmaster is an unknown quantity at this point
Send a message via ICQ to Slaktmaster Send a message via AIM to Slaktmaster
Hmm it shouldn't be that hard, i could help you cyanide if you do the onwall stuff... Or more like maybe I could help you.
Reply With Quote
  #11  
Old 08-30-2001, 09:11 PM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
I know that Kai... But can't you point out where I could learn, or at least start off? Or a script you've made that includes this that I can study from?

Damn you British and you big words...

incredulous (adj) - skeptical
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #12  
Old 08-30-2001, 11:24 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
It's not really simple math

NPC Code:

radangle = random(0,2*3.14);
dx = cos(radangle);
dy = -sin(radangle);

move dx*5,dy*5,5,16;



3.14 = pi
It's dy = -sin(radangle) because when
the angle is pi/2 (90 degrees) then it should
move up, so sin(90) = 1 needs to move the
npc up which means y needs to be decreased
Reply With Quote
  #13  
Old 08-30-2001, 11:37 PM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Thank you so much Stefan! =D

And Kai, never say that I can't do something... Then I'm forced to defy it .
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #14  
Old 08-31-2001, 02:19 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Hehe, I learned algebra 6 years before I should have... Calculus shouldn't be too hard.

Hmmm... Stefan's script wasn't exactly what I was hoping for (but I have to say it's the shortest version of that script I've ever seen). I'm looking for something similar to the movement system of the spade boss Flagr made for Antago (not the one online, the one that was on Antago Press), as I recall from ages ago.... Anyone got that? It might be in Antago's hard drive...
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #15  
Old 08-31-2001, 02:38 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
just get random angles then use stefans script but array every single movement . so your creature walks in an actual curve not like diagonally but not really a curve.. and of course dont forget onwall^_^
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #16  
Old 08-31-2001, 05:29 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
Quote:
Originally posted by Kaimetsu


What do mean by "array every single movement"?
like if the npc is at 30,30 then you random the next 5 steps he will take using sine/cosine so its curved.. and you check for onwall of course
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #17  
Old 09-01-2001, 12:24 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Quote:
Originally posted by Kaimetsu
draw the thing towards it in a fashion akin to gravitational pull.
How would this happen?
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #18  
Old 09-01-2001, 04:06 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
Quote:
Originally posted by Kaimetsu


Urgh, that won't be very efficient. And it might not look very curvy. And it might be difficult to control in general.
no..
you get a base angle for 5 steps
like for example its 1.07 then you random out value between
-.2,.2 so if it gets a 0 then it just walks diagonally .. if u get a -.2 then it will walk a up curve or whatever or a positive a down curve. would work fine
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #19  
Old 09-01-2001, 04:38 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
here i didnt actually test this i just put on graal and clicked style and test to debug it but its just a base of what I was saying (prolly buggy) and i didnt do it using showcharacter either..
NPC Code:

// NPC by LiquidIce

this.maxstep = 5; //step length

if (playerenters&&isleader) {
init();
timeout=.1;
}

function init() {
setarray stepx,this.maxstep+1;
setarray stepy,this.maxstep+1;
for (this.i=0;this.i<this.maxstep;this.i++) {
stepx[this.i]=x;
stepy[this.i]=y;
}
}

if (timeout) {
if (stepx[0]=0||stepy[0]=0) {
randomstep();
}
else {
move();
movearray();
}
timeout=.1;
}

function move() {
x=stepx[0];
y=stepy[0];
}

function movearray() {
for (this.i=this.maxlength;this.i>=0;this.i=this.i-1) {
stepx[this.i]=stepx[this.i-1];
stepy[this.i]=stepy[this.i-1];
}
}

function randomstep() {
this.angle=random(0,6.28);
this.effect=random(-.2,.2);
for (this.i=0;this.i<this.maxstep;this.i++) {
this.x=sin(this.angle);
this.y=cos(this.angle);
if (this.i=0) { this.x+=x-.5;this.y+=y-.5; }
else {
this.x+=stepx[this.i-1]-.5;
this.y+=stepy[this.i-1]-.5;
}
if (onwall(this.x,this.y)) {
break;
}
stepx[this.i]=this.x;
stepy[this.i]=this.y;
this.angle+=this.effect;
}
}

__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)

Last edited by LiquidIce00; 09-01-2001 at 10:03 AM..
Reply With Quote
  #20  
Old 09-02-2001, 05:49 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Wow, that was really helpful for other things, but still not quite what I need =(. Someone gimme Antago's hard drive, please...
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
  #21  
Old 09-02-2001, 01:03 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
If memory serves, all the nonlinear motion scripts he had came from me anyway, particularly the bird...

The trick is to modify this.xspeed and this.yspeed instead of x and y directly. So
if(dir=0) this.yspeed-=random(0.5,1); //try to go up - if you're going down, slow down some
//etc
while(abs(this.yspeed)>1) this.yspeed*=0.9; //maximum speed=1 tile per call
//etc
this.testy=y+this.yspeed;
//all the usual onwall: if it hits the wall, this.testy=y; this.testx=x;
y=this.testy;

You can get it from there easy. If you can't, give up, you're scripting out of your league.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #22  
Old 09-03-2001, 05:21 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
Quote:
Originally posted by Tyhm
If memory serves, all the nonlinear motion scripts he had came from me anyway, particularly the bird...

The trick is to modify this.xspeed and this.yspeed instead of x and y directly. So
if(dir=0) this.yspeed-=random(0.5,1); //try to go up - if you're going down, slow down some
//etc
while(abs(this.yspeed)>1) this.yspeed*=0.9; //maximum speed=1 tile per call
//etc
this.testy=y+this.yspeed;
//all the usual onwall: if it hits the wall, this.testy=y; this.testx=x;
y=this.testy;

You can get it from there easy. If you can't, give up, you're scripting out of your league.
well .. my idea for nonlinear was more of a real curve instead of just moving diagonally randomly..
if thats what u ment ;\
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #23  
Old 09-03-2001, 05:50 AM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
But that didn't look like a curve, LiquidIce.
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
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 12:45 AM.


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