Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-06-2006, 11:04 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
well im not good at explaining but here:
NPC Code:

function onCreated(){

this.cur_target=-1; // reset current target

this.walkgani="hex-metalspider-walk"; // set the walk

this.idlegani="hex-metalspider-idle"; //idle

this.hitgani="hex-metalspider-attack"; //and hit gani

showcharacter(); //well lol

setCharAni(this.idlegani,""); // set the current gani to the idlegani

setTimer(0.05); // start the timeout

}

function onTimeout(){

//chat=playerscount;

if(playerscount>0){ //when there still are players in the room

if(this.cur_target==-1){ //if no target is set

this.pindexes=getnearestplayers(x,y); // get the indexes of the players

thiso.newdistance=10; // set the newdistance to 10 so everything under a distance of 10 gets targeted

thiso.newtarget=-1; // set the new target to -1

thiso.baddy_x=x; // store baddy

thiso.baddy_y=y; // & y

for(i: this.pindexes){ // loop through the indexes

with(players[i]){ //get the player

this.ddb_dx=player.x-thiso.baddy_x; //calculate dx

this.ddb_dy=player.y-thiso.baddy_y; // & dy

this.dist=(this.ddb_dx*this.ddb_dx+this.ddb_dy*thi s.ddb_dy)^.5; //calculate distance

if(this.dist<thiso.newdistance){ //when the distance is smaller than the newdistance

thiso.newtarget=player.account; //set new target to the players account

thiso.newdistance=this.dist; //set newdistance to the current distance(to target the players, whos nearest at the baddie)

player.chat="targeted"; //debug help

}

}

}

chat=thiso.newtarget; // tel the newtarget

if(thiso.newtarget!=-1)this.cur_target=thiso.newtarget; //when newtarget is not -1 then set current target to the newtarget

chat=this.cur_target; // tell the current target

}else{

this.tmp_plr=findplayer(this.target); //get targeted player
if(this.tmp_plr.level==level){ // if player is in baddie level
//to be done later
}else{ // if not



this.cur_target=-1; //reset target

this.tmp_plr=null; // delete the temp player object

}

}

setTimer(0.05); // start timeout again

}

}

function onPlayerEnters(){

setTimer(0.05); (restart the timeout if an player enters)

}

function onPlayerChats(){

if(player.chat="/dbb")

destroy(); //to destroy them (only temp until its finished)

}

//#CLIENTSIDE

function onCreated(){

// chat="test";

}

__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:09 PM.


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