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 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
  #2  
Old 01-04-2006, 08:06 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
First, you should take care of that whole "you have code outside of event blocks" problem.

Then, you should be able to see part of why it isn't working properly.

I suggest you read this.
Reply With Quote
  #3  
Old 01-04-2006, 08:33 AM
checkmyparanoia checkmyparanoia is offline
Registered User
checkmyparanoia's Avatar
Join Date: Jan 2006
Posts: 37
checkmyparanoia is on a distinguished road
still dont see it.... will you point out what is outside of the blocks?
Reply With Quote
  #4  
Old 01-04-2006, 08:52 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by checkmyparanoia
still dont see it.... will you point out what is outside of the blocks?
Hint: Look at the very first line of actual code.
Reply With Quote
  #5  
Old 01-11-2006, 07:07 AM
checkmyparanoia checkmyparanoia is offline
Registered User
checkmyparanoia's Avatar
Join Date: Jan 2006
Posts: 37
checkmyparanoia is on a distinguished road
i edited that.. thanks.. ah i think the problem might be arrays.
Reply With Quote
  #6  
Old 01-11-2006, 06:55 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
You should also take a look at the rules about posting whole scripts.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 01-11-2006, 10:21 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
...
This script gave me a headache, so I stopped half way down.
It looks like you're basically trying to rescript the shoot command. If this is the case, why don't you just use the shoot command?
Reply With Quote
  #8  
Old 01-19-2006, 10:49 PM
Moondeath_2 Moondeath_2 is offline
"..."
Moondeath_2's Avatar
Join Date: Jan 2006
Location: Far Far Away.
Posts: 238
Moondeath_2 is an unknown quantity at this point
Send a message via AIM to Moondeath_2 Send a message via MSN to Moondeath_2 Send a message via Yahoo to Moondeath_2
It also confuses me why he used toweapons. -_-;
__________________
Aim: DarkFireXZ3
Email: [email protected] or [email protected]
Common Location: Unholy Nation
Gscript, Playerworld Rules, Support Center
Reply With Quote
  #9  
Old 01-19-2006, 10:50 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
That was a script from ShadowDragons.
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 08:55 PM.


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