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 07-24-2004, 09:55 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Npc attacking doors

NPC Code:

if (created) {
found=0;
hearts=0;

showcharacter;
ap=99;
timeout=.1;

}

if (timeout&&found==0) {
for (this.i=int(random(0,npcscount));found=0;this.i++) {
if (npcs[this.i].hearts>0) found=1;
if (this.i>npcscount) this.i-=npcscount;

}
timeout=.1}
if (timeout&&found==1) {

if (npcs[this.i].hearts<=1) {
found==0;
timeout=.1;
i=0;
}
setcharani walk,;
if (npcs[this.i].x>x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {
dir=3;
}
if (npcs[this.i].x<x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {
dir=1;
}
if (npcs[this.i].y>y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {dir=2;
}
if (npcs[this.i].y<y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {dir=0;
}
tx =npcs[this.i].x - x;
ty = npcs[this.i].y - y;
dist = (tx*tx+ty*ty)^0.5;
nx = (tx/dist)*1.4;
ny = (ty/dist)*1.4;
move nx,ny,1.4,;
if (npcs[this.i].x in |x-2,x+2|&&npcs[this.i].y in |y-2,y+2|) {
setcharani sword,;
npcs[this.i].hearts-=2;
sleep .25;
if (npcs[this.i].hearts<=0) {
found==0;
timeout=.1;
}
}

timeout=.3
}






Ok, this is supposed to find npcs that are enemies with hearts, and destroy them, then retarget, but it not only wont retarget, sometimes the first target will be a door or something. Why the heck does it do this is it my mistake or a bug in graal programming?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!

Last edited by falco10291029; 07-25-2004 at 12:18 AM..
Reply With Quote
  #2  
Old 07-24-2004, 10:07 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Please format your code first.
Reply With Quote
  #3  
Old 07-24-2004, 10:13 PM
VeX_RaT_Boy VeX_RaT_Boy is offline
WannaBe Scripter
VeX_RaT_Boy's Avatar
Join Date: Aug 2002
Location: Norway
Posts: 960
VeX_RaT_Boy is on a distinguished road
Send a message via ICQ to VeX_RaT_Boy Send a message via AIM to VeX_RaT_Boy Send a message via Yahoo to VeX_RaT_Boy
Wtf? did my post get removed?
I'll rewrite it.

Maybe you should break after finding the npc?


NPC Code:
  if (npcs[this.i].x>x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {dir=3}
if (npcs[this.i].x<x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {dir=1}
if (npcs[this.i].y>y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {dir=2}
if (npcs[this.i].y<y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {dir=0}


You can use getdir() or the move option.
NPC Code:
  dir=getdir(npcs[this.i].x-x,npcs[this.i].y-y);



the move look unsmooth. use option 2.
__________________
-Kjetil Valen
Reply With Quote
  #4  
Old 07-24-2004, 10:25 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
1.) Format your code properly
2.) Vex, if you want to help, format your code properly as well.
Reply With Quote
  #5  
Old 07-24-2004, 10:40 PM
VeX_RaT_Boy VeX_RaT_Boy is offline
WannaBe Scripter
VeX_RaT_Boy's Avatar
Join Date: Aug 2002
Location: Norway
Posts: 960
VeX_RaT_Boy is on a distinguished road
Send a message via ICQ to VeX_RaT_Boy Send a message via AIM to VeX_RaT_Boy Send a message via Yahoo to VeX_RaT_Boy
My name is Kjetil, and what in the world was wrong with my formating?
I see nothing wrong in
NPC Code:
dir=getdir(npcs[this.i].x-x,npcs[this.i].y-y);



If you acctuly look, you would see that I posted the same as he, to point out that it was that part I meant...!
__________________
-Kjetil Valen
Reply With Quote
  #6  
Old 07-24-2004, 11:34 PM
Scott Scott is offline
Yoonacorn
Join Date: Oct 2003
Location: Canada
Posts: 3,572
Scott is on a distinguished road
Send a message via MSN to Scott
Quote:
Originally Posted by Python523
1.) Format your code properly
2.) Vex, if you want to help, format your code properly as well.
Ok Python523.
__________________
Acornlique.
Reply With Quote
  #7  
Old 07-24-2004, 11:52 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
whats "properly formatted" I thought it just had to be spaced a bit I hate these rules....
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #8  
Old 07-25-2004, 12:16 AM
Xecutor Xecutor is offline
Former UN Manager
Join Date: Apr 2004
Posts: 117
Xecutor is on a distinguished road
Quote:
Originally Posted by falco10291029
whats "properly formatted" I thought it just had to be spaced a bit I hate these rules....
Line breaks after every command and if check.
Reply With Quote
  #9  
Old 07-25-2004, 12:16 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
K ill do that real quick but please help this happpens on many npcs
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #10  
Old 07-25-2004, 01:33 AM
VeX_RaT_Boy VeX_RaT_Boy is offline
WannaBe Scripter
VeX_RaT_Boy's Avatar
Join Date: Aug 2002
Location: Norway
Posts: 960
VeX_RaT_Boy is on a distinguished road
Send a message via ICQ to VeX_RaT_Boy Send a message via AIM to VeX_RaT_Boy Send a message via Yahoo to VeX_RaT_Boy
Quote:
Originally Posted by Scott
Ok Python523.
Owned


[MADtv Stuart mode]
Pyt, LOOK WHAT I CAN DO!:
[/MADtv Stuart mode]
NPC Code:

if (created) {
found=0;
hearts=0;
showcharacter;
ap=99;
timeout=.1;
}

if (timeout) {
if (found==0) {
for (this.i=int(random(0,npcscount));found=0;this.i++) {
if (npcs[this.i].hearts>0) found=1;
if (this.i>npcscount) this.i-=npcscount;
}
timeout=.1;
}elseif (found==1) {
if (npcs[this.i].hearts<=1) {
found==0;
timeout=.1;
i=0;
}
setcharani walk,;
if (npcs[this.i].x>x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {
dir=3;
}
if (npcs[this.i].x<x&&(abs(npcs[this.i].x-x)>abs(npcs[this.i].y-y))) {
dir=1;
}
if (npcs[this.i].y>y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {
dir=2;
}
if (npcs[this.i].y<y&&(abs(npcs[this.i].x-x)<abs(npcs[this.i].y-y))) {
dir=0;
}
tx =npcs[this.i].x - x;
ty = npcs[this.i].y - y;
dist = (tx*tx+ty*ty)^0.5;
nx = (tx/dist)*1.4;
ny = (ty/dist)*1.4;
move nx,ny,1.4,;
if (npcs[this.i].x in |x-2,x+2|&&npcs[this.i].y in |y-2,y+2|) {
setcharani sword,;
npcs[this.i].hearts-=2;
sleep .25;
if (npcs[this.i].hearts<=0) {
found==0;
timeout=.1;
}
}
timeout=.3;
}
}

__________________
-Kjetil Valen
Reply With Quote
  #11  
Old 07-25-2004, 04:21 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
thanks ill try that asap
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #12  
Old 07-25-2004, 05:05 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
meh didnt seem to make a difference
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #13  
Old 07-25-2004, 05:06 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
is like the players[i].hearts and npcs[i].hearts command bugged? weird
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #14  
Old 07-25-2004, 01:29 PM
VeX_RaT_Boy VeX_RaT_Boy is offline
WannaBe Scripter
VeX_RaT_Boy's Avatar
Join Date: Aug 2002
Location: Norway
Posts: 960
VeX_RaT_Boy is on a distinguished road
Send a message via ICQ to VeX_RaT_Boy Send a message via AIM to VeX_RaT_Boy Send a message via Yahoo to VeX_RaT_Boy
I didn't do anything, I just formated it better.
All the players[i].vars and npcs[i].vars are READ-ONLY.
__________________
-Kjetil Valen
Reply With Quote
  #15  
Old 07-26-2004, 04:15 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
i know wthat but that means
NPC Code:
if (npcs[i].hearts>0) do what i say;

should work, but it ignores that flag
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
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 06:17 AM.


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