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 01-04-2006, 07:45 AM
checkmyparanoia checkmyparanoia is offline
Registered User
checkmyparanoia's Avatar
Join Date: Jan 2006
Posts: 37
checkmyparanoia is on a distinguished road
almost got this npc.. it uses same variables for all arrows!

NPC Code:

// NPC made by Sephroth{ravenfist dynasty} ; edited by xeno
if(playerenters){
show;
if (this.init!=1) { //redundant but whatever
if (this.init!=1) {

this.rateoffire = 100;
this.maxrateoffire = 500;

//this.maxcount is the maximum amount of arrows
//allowed on screen at one time (higher #=more lag)
this.maxcount=30;

//this.life is the amount of time (in seconds)
//an arrow can be on screen (higher #=more lag)
this.life=6;

//this.arrowspeed is the rate at which an arrow
//moves (1=normal arrow's speed)
this.arrowspeed=.1;

//this.arrowdamage is the amount of half hearts
//taken off which each successful hit
this.arrowdamage=3;

//don't edit the following (initalizes the arrays)
setarray this.arrowx,this.maxcount+1;
setarray this.arrowy,this.maxcount+1;
setarray this.arrowdir,this.maxcount+1;
setarray this.arrowtime,this.maxcount+1;
setarray this.arrowact,this.maxcount+1;
this.init=1;
}
}
}

//puts weapon in inventory
if (playertouchsme) {


toweapons pistol;

timeout=.05;
}

if (mouseup) callweapon selectedweapon,weaponfired,nothing;

if(weaponfired&&playerdarts>0&&this.rateoffire<thi s.maxrateoffire){
//freezeplayer .01;
this.rateoffire=this.rateoffire+100;
playersprite=33;
playerdarts--;
//change the gif name below to change
//the gif of the bow the player uses when the weapon
//is fired
setbow medbow.gif;

//dont edit until you see another "//"
sleep .1;
play arrow.wav;

if (mousex>playerx){
sidemod = 1;
sidedis = mousex - playerx;
}
if (mousex<playerx){
sidedis = playerx - mousex;
sidemod = -1;
}
if (mousey>playery){
talldis = mousey - playery;
tallmod = 1;
}
if (mousey<playery){
tallmod = -1;
talldis = playery - mousey;
}
sidedis = sidedis * sidemod;
talldis = talldis * tallmod;
sidedis = sidedis / 8;
talldis = talldis / 8;

if(playerdir==3)
{
this.arrowx[this.out]=playerx;
this.arrowy[this.out]=playery;
this.arrowmodx[this.out] = sidedis;
this.arrowmody[this.out] = talldis;
}
if(playerdir==0){
this.arrowx[this.out]=playerx;
this.arrowy[this.out]=playery;
this.arrowmodx[this.out] = sidedis;
this.arrowmody[this.out] = talldis;
}
if(playerdir==1){
this.arrowx[this.out]=playerx;
this.arrowy[this.out]=playery;
this.arrowmodx[this.out] = sidedis;
this.arrowmody[this.out] = talldis;
}
if(playerdir==2){

this.arrowx[this.out]=playerx;
this.arrowy[this.out]=playery;
// this.arrowmody[this.out] = 0;
// this.arrowmodx[this.out] = -5; //////down
this.arrowmodx[this.out] = sidedis;
this.arrowmody[this.out] = talldis;
}
this.arrowdir[this.out]=playerdir;
this.arrowact[this.out]=0;
this.out++;
timeout=.05;
}
if(timeout){
if(this.rateoffire>0){this.rateoffire=this.rateoff ire-6;}
timeout=.05;
for(e=0;e<this.out;e++){
if(this.arrowact[e]==0){
if(this.arrowdir[e]==3){
this.arrowx[e]+=this.arrowspeed;

//change the gifname below to change the gif
//shown when the arrow travels right
showimg e,magbulletr.gif,this.arrowx[e],this.arrowy[e];
}

if(this.arrowdir[e]==0){
this.arrowy[e]-=this.arrowspeed;

//change the gifname below to change the gif
//shown when the arrow travels up
showimg e,magbulletu.gif,this.arrowx[e],this.arrowy[e];
}

if(this.arrowdir[e]==1){
this.arrowx[e]-=this.arrowspeed;

//change the gifname below to change the gif
//shown when the arrow travels left
showimg e,magbulletl.gif,this.arrowx[e],this.arrowy[e];
}

if(this.arrowdir[e]==2){
this.arrowy[e]+=this.arrowspeed;

//change the gifname below to change the gif
//shown when the arrow travels down
showimg e,magbulletd.gif,this.arrowx[e],this.arrowy[e];

}
this.arrowx[e] = this.arrowx[e] + this.arrowmodx;
this.arrowy[e] = this.arrowy[e] + this.arrowmody;


this.arrowtime[e]++;
}else{
this.arrowtime[e]=this.life*20;
}
for (c=0; c<compuscount; c++) {
if (abs(this.arrowx[e]-compus[c].x)<=2 &&
abs(this.arrowy[e]-(compus[c].y-0.5))<=2 &&
compus[c].mode!=3&&
compus[c].mode!=5){

//EDIT THIS TO HEAL BADDIES
hitcompu c,-1*this.arrowdamage,this.arrowx[e]+0.5,this.arrowy[e]+0.5;
//just delete "-1*" and it'll heal a baddy when they get hit.

this.arrowact[e]=1;
}
}
for (d=1; d<playerscount; d++) {
if (abs((this.arrowx[e]+0.7)-(players[d].x+2))<=1 &&
abs((this.arrowy[e]+0.5)-(players[d].y+2))<=1.5){
hitplayer d,this.arrowdamage,this.arrowx[e],this.arrowy[e];
//SCORE damage here
this.arrowact[e]=1;
}
}
if (this.arrowtime[e] >= (this.life*20)) {
hideimg e;
for (b=e; b<=this.out && b<20; b++) {
this.arrowx[b] = this.arrowx[b+1];
this.arrowy[b] = this.arrowy[b+1];
this.arrowdir[b] = this.arrowdir[b+1];
this.arrowact[b] = this.arrowact[b+1];
this.arrowtime[b] = this.arrowtime[b+1] - 1;
}
this.arrowx[this.out] = -1;
this.arrowy[this.out] = -1;
this.arrowdir[this.out] = -1;
this.arrowtime[this.out] = -1;
this.arrowact[this.out] = -1;
this.out--;
a--;
hideimg this.out;
}
}
timeout=.05;
this.mmx = mousescreenx;
this.mmy = mousescreeny;
players.bombs = mousescreenx;
}

if (playerchats&&isweapon) {
if (strequals(#c,ordinance)) {
//set bootson;
setlevel2 every.nw, 19, 19;
timeout=.05;
}
}



heh.. ok i changed it, it still does it :/

Last edited by checkmyparanoia; 01-04-2006 at 09:59 AM..
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 12:03 PM.


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