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 09-18-2004, 11:45 PM
sparkers sparkers is offline
Yojumisto Online
sparkers's Avatar
Join Date: Jun 2004
Location: Why does anyone care about that?
Posts: 111
sparkers is on a distinguished road
Send a message via AIM to sparkers
Custom monster help.

Ok well i got the monster just can't make it so it won't be able to walk through walls!
Can anyone help?

NPC Code:

if (created) {setcharani popie,;initialize();setcharprop #P(1),hat#v(int(random(0,100))).png;
}
if (timeout&&this.found==0) {
for (i=-1;this.found==0;i+=1) {
this.found=1;
if (i>playerscount) i=-1;
}
timeout=.1;
}
if (timeout&&this.found==1) {
this.wall=0;
this.gani++;
if (abs(players[i].x-x)<=20&&abs(players[i].y-y)<=20) {
tx=players[i].x - x;
ty=players[i].y - y;
dist= (tx*tx+ty*ty)^0.5;
nx= (tx/dist)*.5;
ny= (ty/dist)*.5;
dir=getdir(players[i].x-x,players[i].y-y);
wallcheck();
if (this.wall==0) {
if (this.gani>=3) {
setcharani podies-walk,;
this.gani=0;
}
x+=nx;
y+=ny;
}
} else {setcharani podies,;message ;this.found=0;timeout=.1}
if (players[i].x in |x-2,x+2|&&players[i].y in |y-2,y+2|) {
setcharani podies-attack,;
with(players[i]) {setani hurt,;setstring client.hp,#v(strtofloat(#s(client.hp))-1)};sleep .5;timeout=1;}
timeout=.1;}

if (wa****) {
message ;setcharani podies,;

hearts-=.5;message #v(hearts);sleep 1;
checkdead()}

if (actionprojectile&&hearts>=0) {
message ;setcharani podies-hurt,;
hearts-=strtofloat(#p(1))*2;
showtext 1000,x,y,verdana,r,#v(strtofloat(#p(1))*2);this.nu mber=strtofloat(#p(1))*2;
sleep .1;showtext 1000,x,y-.2,verdana,r,#v(this.number);
sleep .1;showtext 1000,x,y-.4,verdana,r,#v(this.number);
sleep .1;showtext 1000,x,y-.6,verdana,r,#v(this.number);
sleep .1;showtext 1000,x,y-.8,verdana,r,#v(this.number);
sleep .1;showtext 1000,x,y-.6,verdana,r,;





message #v(hearts);sleep 1;
checkdead();}
function initialize() {
setcharani podies,;setshape 1,50,50;
this.found=0;
hearts=6;
setcharani podies,;
timeout=.1;
}
function checkdead() {

if (this.hearts<=0) {

with(getplayer(#p(2))) {
insertstring client.messages,0,You gained EXP;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
if (strlen(#g)>1) {setstring server.account,#a;setstring server.guild,#g}
}

for(i=0;i<allplayerscount;i++) {
with (allplayers[i]) {
if (strequals(#g,#s(server.guild))&&!strequals(#a,#s( server.account))) {
insertstring client.messages,0,You guild/party got you EXP;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
}

}

}


timeout=0;
hide;
sleep 30;
show;

initialize();

}


else {setcharani podies,;timeout=.65}


}

}




function wallcheck() {
for (a=0;a<2;a+=.1){
message ;
if (onwall(x+(vecx(dir)*a),y+(vecy(dir)*a))) {
this.wall=1;
break;
}
}
}

Reply With Quote
  #2  
Old 09-19-2004, 12:51 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Click.
Might help.
Reply With Quote
  #3  
Old 09-19-2004, 04:44 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Hmm... I do recall something about not posting whole scripts and only posting parts that were relevant =x
__________________
Who has time for life these days?
Reply With Quote
  #4  
Old 09-19-2004, 09:21 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
I think he doesn't know whats the problem is with it, PS.

I didn't know you could add +/- in the same for loop? :o
__________________

Last edited by xAndrewx; 09-19-2004 at 09:53 AM..
Reply With Quote
  #5  
Old 09-19-2004, 04:23 PM
sparkers sparkers is offline
Yojumisto Online
sparkers's Avatar
Join Date: Jun 2004
Location: Why does anyone care about that?
Posts: 111
sparkers is on a distinguished road
Send a message via AIM to sparkers
I already went through the movement tutorial, that is how i got the onwall check functioin, but it basically ignores the fact that tyhe wall is there i posted the whole script in case something else may be hindering it...
Reply With Quote
  #6  
Old 09-19-2004, 07:39 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
NPC Code:

function checkdead() {
if (this.hearts<=0) {
with(getplayer(#p(2))) {
insertstring client.messages,0,You gained EXP;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
if (strlen(#g)>1) {
setstring server.account,#a;
setstring server.guild,#g;
}
}
for(i=0;i<allplayerscount;i++) {
with (allplayers[i]) {
if (strequals(#g,#s(server.guild))&&!strequals(#a,#s( server.account))) {
insertstring client.messages,0,You guild/party got you EXP;
setstring client.playerexp,#v(strtofloat(#s(client.playerexp ))+3);
}
}
}
timeout=0;
hide;
sleep 30;
show;
initialize();
}
else {
setcharani podies,;
timeout=.65;
}
}

} <- extra





Style your scripts.
Reply With Quote
  #7  
Old 09-19-2004, 10:42 PM
sparkers sparkers is offline
Yojumisto Online
sparkers's Avatar
Join Date: Jun 2004
Location: Why does anyone care about that?
Posts: 111
sparkers is on a distinguished road
Send a message via AIM to sparkers
Ok that didn't really help at all.....
Reply With Quote
  #8  
Old 09-19-2004, 11:44 PM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
you people arent getting thew problem here, all the onwall checks are done just fine, yet it ignores them, the moivement tutorial doesnt help at all. If you are going to post, make it helpful.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #9  
Old 09-20-2004, 12:17 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Quote:
Originally Posted by ProjectShifter
Hmm... I do recall something about not posting whole scripts and only posting parts that were relevant =x
quite
also, freakin indent, there is no point in using [code ] tags when you don't indent , and use [php ] if you have to post alot of code, since noone is fixing the damn doublespace >:O

I tested the script offline, and it seems to stop at walls alright. Your problem might have something to do with a neworder tileset, check to see if you're serveroption (newtilesets=true/false) is correct and all that stuff. Use this test weapon to make sure wallchecks are working too:
PHP Code:
if (created||timeout) {
  if (
onwall(mousex,mousey)) {
    
setplayerprop #c,Freakin wall!;
  
}else{setplayerprop c,Clear!;}
  
timeout .05;

Quote:
Originally Posted by xAndrewx
I didn't know you could add +/- in the same for loop? :o
yeah, um i=-1 is not the same as i-=1
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #10  
Old 09-20-2004, 12:39 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
i dont see that option so i added it, are there any commands for server options that it doesn't come with?
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #11  
Old 09-20-2004, 12:51 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Quote:
Originally Posted by falco10291029
i dont see that option so i added it, are there any commands for server options that it doesn't come with?
Linkage

Oh yeah, what's up with that for loop in your wallcheck()? If that's supposed to be an increment check you're not doing it right, nor are you actually using it
silly goose
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #12  
Old 09-20-2004, 02:30 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
whats wrong with it? (if ur wondering y im respondin insted of sparkers, he's my brother and we work at the same server trying to fix the bug)
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #13  
Old 09-20-2004, 08:07 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
So your brother actually scripted this? With all your problems why didn't you just ask your brother? :o

I know, Chad.
__________________

Last edited by xAndrewx; 09-20-2004 at 09:15 PM..
Reply With Quote
  #14  
Old 09-20-2004, 08:17 PM
sparkers sparkers is offline
Yojumisto Online
sparkers's Avatar
Join Date: Jun 2004
Location: Why does anyone care about that?
Posts: 111
sparkers is on a distinguished road
Send a message via AIM to sparkers
erm no. falco used the movement tutorial to make that. I just made the gfx and ganis.
We've tried tons of stuff but it just keeps going through walls.
Reply With Quote
  #15  
Old 09-20-2004, 08:27 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Yes, using php blocks would be nicer than code so it doesn't take up a ton of space. Also I like the color coding But anyway, to the matter at hand.
If it works offline, then it could be an issue with clientsiding. If I recall properly, either onwall or onwall2 is strictly clientside or serverside, not sure which. I would suggest doing like a "setplayerprop #c,Checking onwall!;" block of coding where you start your check. Make sure that it is actually getting the proper calls. Next then add checks like setting the chat to something like "Cannot move left!" if you cannot move left etc, make sure that it is getting the calls properly. You should also add such debugging lines when you run into these situations. If you have a message system that works much better than chat. I have a message system that I use where I just do addstring client.messages,New Message; and it will add it. So in that case it would be nice to have it show that you cannot move left, or up, so that if there are multiple messages then it will be visible, allowing more than just having the chat (which only can display 1 real message at a time).
__________________
Who has time for life these days?
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:22 AM.


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