Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   2 Questions (https://forums.graalonline.com/forums/showthread.php?t=23800)

lordhelmut 02-15-2002 11:00 AM

2 Questions
 
One is...Say I wanted to script a gun or something. What would be the best way to do the bullets? also...Can someone explain how to use the board command

Androk2k1 02-15-2002 11:23 AM

1. I guess you could either use putnpc or showimg, I am not sure which one is better, but I would use... showimg, it's less trouble and all scripting is withing one NPC...

2. I dunno...

lordhelmut 02-15-2002 12:04 PM

no way am i using putnpc, maybe arrays to keep track of showimg accept i dont know how to use arrays in graal

Saga2001 02-15-2002 01:52 PM

I would use arrays.
array example:
NPC Code:

// to make an array do this:
// setarray arrayname,size;
// as in this example:
setarray this.values,10;
/*
to set values in an array do this:
arrayname[indexnumber] = value;
the first index in every array is 0.
so if you have an array that you set to size 100
than its 0-99.
as in this example:
*/
this.values[0] = 1;
this.values[9] = 5;
/*
that is the hard way to do it though,
this is easier:
*/
this.values = {1,0,0,0,1,2,3};
/*
that will set an array with 7 values (0-6)
and can be called as so:
*/
this.newnumber = this.values[5];
/*
Meaning that this.newnumber would equal 2
*/
Mostly with big arrays you put them thru a for loop,
like in this rain example:
*/
// Rain script:
if (created) {
setarray this.rainx,100;
setarray this.rainy,100;
for (i=0;i<arraylen(this.rainx);i++;) {
/* arraylen(arrayname) <-- gives you the amount of indexes in the array.*/
this.rainx[i] = random(0,64);
this.rainy[i] = random(0,64);
}
}
if (playerenters||timeout) {
for (i=0;i<arraylen(this.rainx);i++;) {
// Shows rain:
showimg i+500,@.,this.rainx[i],this.rainy;
// Puts the rain above the player:
changeimgvis i+500,3;
// If the rain reaches the end of the screen it will repeat:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
this.rainy[i]+=(this.rainy[i]>64 ? -64 : 0);
/*
if this:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
looks weird, what it is, is a condition, if you look, the syntax is this:
(condition ? a : b)
if the condition is true than it goes to a otherwise it goes to b.
If it doesn't make sence im me we can talk about it.
*/
}
timeout=.05;
}


hope I typed that right and I also hope it helps.

neomaximus2k 02-15-2002 02:52 PM

Quote:

Originally posted by Saga2001
I would use arrays.
array example:
NPC Code:

// to make an array do this:
// setarray arrayname,size;
// as in this example:
setarray this.values,10;
/*
to set values in an array do this:
arrayname[indexnumber] = value;
the first index in every array is 0.
so if you have an array that you set to size 100
than its 0-99.
as in this example:
*/
this.values[0] = 1;
this.values[9] = 5;
/*
that is the hard way to do it though,
this is easier:
*/
this.values = {1,0,0,0,1,2,3};
/*
that will set an array with 7 values (0-6)
and can be called as so:
*/
this.newnumber = this.values[5];
/*
Meaning that this.newnumber would equal 2
*/
Mostly with big arrays you put them thru a for loop,
like in this rain example:
*/
// Rain script:
if (created) {
setarray this.rainx,100;
setarray this.rainy,100;
for (i=0;i<arraylen(this.rainx);i++;) {
/* arraylen(arrayname) <-- gives you the amount of indexes in the array.*/
this.rainx[i] = random(0,64);
this.rainy[i] = random(0,64);
}
}
if (playerenters||timeout) {
for (i=0;i<arraylen(this.rainx);i++;) {
// Shows rain:
showimg i+500,@.,this.rainx[i],this.rainy;
// Puts the rain above the player:
changeimgvis i+500,3;
// If the rain reaches the end of the screen it will repeat:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
this.rainy[i]+=(this.rainy[i]>64 ? -64 : 0);
/*
if this:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
looks weird, what it is, is a condition, if you look, the syntax is this:
(condition ? a : b)
if the condition is true than it goes to a otherwise it goes to b.
If it doesn't make sence im me we can talk about it.
*/
}
timeout=.05;
}


hope I typed that right and I also hope it helps.


*ZOOOOOOOOOM OVER MY HEAD*

Ultima_P2P 02-15-2002 04:52 PM

Quote:

Originally posted by neomaximus2k



*ZOOOOOOOOOM OVER MY HEAD*

Yeah, me too :(

Saga2001 02-15-2002 04:56 PM

Really? :-/ im me (PastAustin) and I can explain it better.

lordhelmut 02-15-2002 06:56 PM

forget second part, Supersonic is teaching me

02-15-2002 07:43 PM

if (playertouchsme) {
setstring Ammo,15;
toweapons name;
}

if (weaponfired) {
i = strtofloat(#s(Ammo)) - 1;
play fire.wav;
if (i == 0) {
setstring Ammo,;
destroy;
}
setstring Ammo,#v(i);
}


If you where smart, you would look on the npc scripting page first ;/

http://www.graal2001.com/levelsnpc/npc-guide.php

TDK_RC6 02-15-2002 07:55 PM

the new varialble tile[x,y] is a lot better

TDK_RC6 02-15-2002 08:24 PM

Quote:

Originally posted by Kaimetsu


And if you were smart, you wouldn't have typed "where".

Besides, your code doesn't deal with the actual handling of the fired bullets in the slightest. It just decrements an ammo count.

silly kai

TDK_RC6 02-15-2002 09:36 PM

you are just funny

TDK_RC6 02-15-2002 09:49 PM

Quote:

Originally posted by Kaimetsu


I'm wondering how to take that :-/

take it as a good thing

neomaximus2k 02-16-2002 02:09 AM

Quote:

Originally posted by TDK_RC6
the new varialble tile[x,y] is a lot better
how do you use the tile command, i never understood how to read a certain tile
(example snow)

TDK_RC6 02-16-2002 02:27 AM

kai is totally right, not a command, its a variable

anways you use it to set the tile at x,y to a certain tile

NPC Code:

if (playerchats) {
tokenize #c;
if (strequals(#t(0),changetile)&&tokenscount==4) {
if (strtofloat(#t(1)) in |0,64|&&strtofloat(#t(2)) in |0,64|) {
tiles[strtofloat(#t(1)),strtofloat(#t(2))]=strtofloat(#t(3));
setplayerprop #c, ;
}
}
}


TDK_RC6 02-16-2002 05:43 AM

forgot to mention what you need to do to get this to work


just say changetile xcoordinate ycoordinate tilenumber

Saga2001 02-16-2002 05:27 PM

Quote:

Originally posted by Kaimetsu
Board is not a command.
Board[]? where did that come from?

Quote:

Originally posted by TDK_RC6
forgot to mention what you need to do to get this to work


just say changetile xcoordinate ycoordinate tilenumber

yeah board[] is useless with changetile...

neomaximus2k 02-16-2002 06:22 PM

My question wasn't worded correctly.
ok say that i am on the sand. i want the player to move slower but if he was on grass he would move normally.
now how would i get it to check when he is on sand and when he is on grass

Saga2001 02-16-2002 07:35 PM

purely because i haven't used tile i'll use board.
NPC Code:

while (true) {
this.tile = board[playerx+1.5+64*playery+2];
for(i=0;i<3;i++;) {
if (this.tile==511&&keydown(i)) {
playerx+=vecx(playerdir);
playery+=vecy(playerdir);
}
}
sleep .05;
}



thats just a rough draft, but kinda like that.

Saga2001 02-16-2002 08:25 PM

Quote:

Originally posted by Kaimetsu


From here:

now i see, i guess i missed that...

neomaximus2k 02-17-2002 02:32 AM

Quote:

Originally posted by Kaimetsu


Neo, you need to take the tile at the point where the player is and check if its index is within the ranges that would make it a sand tile.

Yes however an example would have been nice. because again i have never scripted anything like this before and dont know where to get the tile values from, it may be somewhere stupid but i aint seen it :(

neomaximus2k 02-17-2002 06:27 PM

Quote:

Originally posted by Kaimetsu


Swoosh your pointer over the tileset in the editor and look at the coords on the status bar.

Oh now i get ya!!!!!!
thanks dude that has just made a lot of my scripts a lot easier now :)

TDK_RC6 02-17-2002 09:58 PM

Quote:

Originally posted by neomaximus2k


Oh now i get ya!!!!!!
thanks dude that has just made a lot of my scripts a lot easier now :)

lol


All times are GMT +2. The time now is 02:31 PM.

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