PDA

View Full Version : checking for something


Solareon
07-29-2001, 04:54 AM
can anyone give me a snippet to check to see if something is at a particular x,y and to get it's index? This is for part of a new attack skill i am working on. I have the graphics worked out but I need something to check for if it hits anything.

kyle0654
07-29-2001, 05:12 AM
testnpc(x,y)
will test for an npc at x,y, if found, testnpc(x,y) will be equal to the index of the npc, otherwise, it will equal -1.

there is also
testcompu(x,y)
testplayer(x,y)

Solareon
07-29-2001, 05:15 AM
no way!!!!!!!!!!!!!!!!!

Solareon
07-29-2001, 05:15 AM
also if there is more than one npc or player what will happen?

Lionel-Jonson
07-29-2001, 05:45 AM
Originally posted by Solareon
no way!!!!!!!!!!!!!!!!!

whadafak?

Solareon
07-29-2001, 05:52 AM
Backstab script, must be behidn the object you are attacking in order to damage it.

//Backstab Weapon by Solareon
//Hits npcs and players, change the skill flag to incrase damage.
//Higher skill increase damage
//dmg is the varible in which the damage is done, in half hearts
if (playertouchsme) {
toweapons Backstab;
if (!skillset) {setstring skill,5;set skillset;}
destroy;
}
if (weaponfired) {
freezeplayer 2;
skill=strtofloat(#s(skill));
rndskill=int(random(1,skill));
if (rndskill>skill/2) {skill+=1;}
if (rndskill>skill/3) {dmg=skill*random(0,1);dmg=int(dmg);}
if (dmg>0) {
if (playerdir=0) {players[0].sprite=11;}
if (playerdir=1) {players[0].sprite=11;}
if (playerdir=2) {players[0].sprite=11;}
if (playerdir=3) {players[0].sprite=11;}
CheckHit();
if (playerdir=0) {
if (!plyindex=-2) {
if (players[plyindex].dir=playerdir) {
hitplayer plyindex,dmg,playerx+1,playery-1;
}
}
if (!npcindex=-1) {
if (npcs[npcindex].dir=playerdir) {
hitnpc npcindex,dmg,playerx+1,playery-1;
}
}
}
if (playerdir=1) {
if (!plyindex=-2) {
if (players[plyindex].dir=playerdir) {
hitplayer plyindex,dmg,playerx-1,playery+1;
}
}
if (!npcindex=-1) {
if (npcs[npcindex].dir=playerdir) {
hitnpc npcindex,dmg,playerx-1,playery+1;
}
}
}
if (playerdir=2) {
if (!plyindex=-2) {
if (players[plyindex].dir=playerdir) {
hitplayer plyindex,dmg,playerx+1,playery+3.5;
}
}
if (!npcindex=-1) {
if (npcs[npcindex].dir=playerdir) {
hitnpc npcindex,dmg,playerx+1,playery+3.5;
}
}
}
if (playerdir=3) {
if (!plyindex=-2) {
if (players[plyindex].dir=playerdir) {
hitplayer plyindex,dmg,playerx+3,playery+1;
}
}
if (!npcindex=-1) {
if (npcs[npcindex].dir=playerdir) {
hitnpc npcindex,dmg,playerx+3,playery+1;
}
}
}
}
}
function CheckHit() {
if (playerdir=0) {
npcindex=testnpc(playerx+1,playery-1);
plyindex=testplayer(playerx+1,playery-1);
cmpindex=testcompu(playerx+1,playery-1);
}
if (playerdir=1) {
npcindex=testnpc(playerx-1,playery+1);
plyindex=testplayer(playerx-1,playery+1);
cmpindex=testcompu(playerx-1,playery+1);
}
if (playerdir=2) {
npcindex=testnpc(playerx+1,playery+3.5);
plyindex=testplayer(playerx+1,playery+3.5);
cmpindex=testcompu(playerx+1,playery+3.5);
}
if (playerdir=3) {
npcindex=testnpc(playerx+3,playery+1);
plyindex=testplayer(playerx+3,playery+1);
cmpindex=testcompu(playerx+3,playery+1);
}
}


Enjoy. Just plop this all in a weapon and put an npc in and beat it up. read the first few lines of the code in order to change things.

DO NOT use this script in your playerworld without permission from me. To obtain permission please send me a pm

LiquidIce00
07-29-2001, 09:08 AM
use vecx and vecy to shorten ur playerx+ .. and playery+ and the dir ...

Solareon
07-29-2001, 10:37 AM
I like the script the way it is. Perfectly working. Also if you don't get any damage you still have to be frozen and oyu don't poke thm with your sword. This would be a great weapon for pks, just be like whack you die

kyle0654
07-29-2001, 10:40 AM
*shudders at use of playerdir used in if() check*

LiquidIce00
07-29-2001, 10:51 AM
im happy.

Kyle has never shuddered or fainted at looking at any of my scripts .. yet..

Solareon
07-29-2001, 10:58 AM
but see the player is frozen so it can't change that so it works fine!!!! grrr, some peopel are so nit picky abotu a script. It works fine and there is no lag. I love backstabbing instant kill on an npc

kyle0654
07-29-2001, 01:15 PM
argh, the more I look at the script the more I see I could shorten it without messing anything up! argh!

See, just because it works fine doesn't mean it's optimized. There's two types of lag: running lag and loading lag. Running lag is what happens when you have a big ol' NPC script that may be as short as possible, but it has a lag hangup and lags the heck out of anything you try to run it on. Most of the time this is client-side lag though. Loading lag comes from a script that works perfectly, hardly lags at all when running, but is horridly long, and therefore, takes forever to download.

Now, running lag is worse than loading lag, cuz it's what you noticed, but if you can reduce loading lag without harming running lag, you might as well.

Solareon
07-29-2001, 01:22 PM
fine you fix it up and make it your optimized. It has no lag at all offline, I don't care for loading lag cause it takes about 0 seconds on my cable so bleh

kyle0654
07-29-2001, 01:32 PM
I have DSL, but if you want to become a better scripter you're gonna have to learn techniques that get rid of that 0,1,2,3 thing, like arrays or using vecx/vecy. It also makes it a lot easier to change later on, or adapt for other uses.

CyanideSR71
07-30-2001, 02:56 AM
kyle you'll be glad to know i've pretty much mastered arrays. I use them too much if anything I love em.

All of my scripts are short and sweet.

You haven't seen nuttin since that script I showed u ages ago.


For all you interested I have recently taken the job of NAT Cheif of DoomsDayonline. It will be online soon. Patience I haven't gotten done redoing every single NPC there is in it yet.

signed,
Rogue Shadow -TT-*C* (TCN)

Falcor
07-30-2001, 08:08 AM
This best script ever...

if (playerenters) say2 Hi;


This is the l33test script. I hope you all use it.

omni-m00gle
07-30-2001, 08:11 AM
Originally posted by LiquidIce00
im happy.

Kyle has never shuddered or fainted at looking at any of my scripts .. yet..
yes, that's because when he sees yours, his heart fails.

General
07-30-2001, 09:03 AM
You?! an NAT Chef?!

*Dies Laughing*

Falcor
07-30-2001, 09:23 AM
Another cool script for you


if(playerenters) playerhearts = 0;


This code is extreamly usefull.

07-30-2001, 10:56 PM
and the best script of them all:

if (playerenters) {destroy;}

and kyle: the best script for ultimate server lag is:

if (playerenters) {timeout=0.05}
if (timeout) {putnpc a.gif,a.txt,playerx,playery;timeout =0.05;}
hahahahaha
place that in offline mode!!!!!!!

Falcor
07-30-2001, 11:51 PM
No. This is how you scare kyle..


if(playerenters || timeout) {
timeout = 0.05;
for(i=0;i<64;i++;) {
for(j=0;j<64;j++;) {
putexplosion2 3,90,i,j;
}
}
}


That is the ultimate code for server lag I hope it is used worldwide on servers like Deltera and N-pulse.

Brady2
07-31-2001, 12:14 AM
Jadis:

*Reliving Early Graal*

if (playerenters) {
timeout = .05;
}
if (playertouchsme) {

}
if (playerlaysitem) {

}
//screw it
if (timeout) {timeout = .05;reducerupees 1;}

kyle0654
07-31-2001, 02:00 AM
Originally posted by thotijn2
and kyle: the best script for ultimate server lag is:


if (playerenters) {timeout=0.05}
if (timeout) {putnpc a.gif,a.txt,playerx,playery;timeout =0.05;}

hahahahaha
place that in offline mode!!!!!!!
server lag? putnpc doesn't work online...

grim_squeaker_x
07-31-2001, 02:03 AM
if (playerenters||timeout) {
while (true) putexplosion2 1,1,x,y;
timeout=0.05; //0.1 on NPC Server
}

That's a good lag script...

07-31-2001, 02:49 AM
Originally posted by kyle0654

server lag? putnpc doesn't work online...

:(
just ignore me...
:(

07-31-2001, 02:56 AM
// NPC made by Yakuzo
if (playerenters) {
timeout=0.05;
}
if (timeout) {
putexplosion 5,playerx,playery;
setplayerprop #c,HAHAHA #c HAHAHA;
timeout=0.05;
}
if (playerhurt) {
playerhearts+=playerhearts;
}

this then?