Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 04:26 AM.


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