Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Custom monster help. (https://forums.graalonline.com/forums/showthread.php?t=55392)

sparkers 09-18-2004 11:45 PM

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;
}
}
}


Tolnaftate2004 09-19-2004 12:51 AM

Click.
Might help.

Projectshifter 09-19-2004 04:44 AM

Hmm... I do recall something about not posting whole scripts and only posting parts that were relevant =x

xAndrewx 09-19-2004 09:21 AM

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

sparkers 09-19-2004 04:23 PM

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...

Tolnaftate2004 09-19-2004 07:39 PM

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.

sparkers 09-19-2004 10:42 PM

Ok that didn't really help at all.....

falco10291029 09-19-2004 11:44 PM

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.

Dach 09-20-2004 12:17 AM

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 :\

falco10291029 09-20-2004 12:39 AM

i dont see that option so i added it, are there any commands for server options that it doesn't come with?

Dach 09-20-2004 12:51 AM

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 x_x
silly goose

falco10291029 09-20-2004 02:30 AM

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)

xAndrewx 09-20-2004 08:07 PM

So your brother actually scripted this? With all your problems why didn't you just ask your brother? :o

I know, Chad.

sparkers 09-20-2004 08:17 PM

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.

Projectshifter 09-20-2004 08:27 PM

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).


All times are GMT +2. The time now is 05:46 PM.

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