PDA

View Full Version : updateboard question


scriptless
10-28-2014, 01:57 AM
Okay, so I am working on a shovel. I am trying to make it place tiles in the level where I dig. I wan't them to wait so long then disappear. The problem is that they only seem to disappear if I replace the tiles for blank grass 2047 I think it is. If I place my tiles over any other tile they do not automatically disappear. Is there any trick to making the tiles revert after a set amount of time? I was thinking I could just re-replace the tiles but then it gets mad ugly when the player leaves the level because then your not in the same level and they don't end up getting reverted back ect.

//#CLIENTSIDE
function onCreated() {
this.x = player.x + 1.0 + vecx(player.dir) * 2;
this.y = player.y + 1.0 + vecy(player.dir) * 2;
for ( this.iy = 0; this.iy < 2; this.iy ++ ) {
for ( this.ix = 0; this.ix < 2; this.ix ++ ) {
this.checkX = this.x+this.ix;
this.checkY = this.y+this.iy;
tiles[this.checkX, this.checkY] = this.replaceTiles[this.ix+this.iy*2];
}
}
updateboard(this.x,this.y,2,2);
}

Jakov_the_Jakovasaur
10-28-2014, 05:00 AM
hello!

you should consider dropping a dirt npc on serverside instead, that way it can be made to either fade or transition out rather than disappear at once, plus there are ways to create the illusion of no lag if you make the player do a showani()/showimg() on clientside when triggering to serverside, then have that display disappear as soon as the npc they are the placer of appears on their client. dirtholes can then be checked for using findareanpcs(); which if it contains other non dirthole npcs you will probably want to trigger an event such as 'onDig' on them anyway

scriptless
10-28-2014, 11:10 AM
hello!

you should consider dropping a dirt npc on serverside instead, that way it can be made to either fade or transition out rather than disappear at once, plus there are ways to create the illusion of no lag if you make the player do a showani()/showimg() on clientside when triggering to serverside, then have that display disappear as soon as the npc they are the placer of appears on their client. dirtholes can then be checked for using findareanpcs(); which if it contains other non dirthole npcs you will probably want to trigger an event such as 'onDig' on them anyway

Does this cause conflict if I use putnpc() twice on the same area? Will the dirt hole ever cover up the item you are digging up? For example, digging up a defaulat gralat using join(); to its default class.

Inari
10-28-2014, 11:37 AM
Well the dirt hole would be draw-under-player?

Crow
10-28-2014, 12:18 PM
Well the dirt hole would be draw-under-player?

This. Also, upon creation, check if there's already a dirt hole at that same position, and just make the NPC destroy itself if that's the case.

Jakov_the_Jakovasaur
10-28-2014, 10:21 PM
Does this cause conflict if I use putnpc() twice on the same area? Will the dirt hole ever cover up the item you are digging up? For example, digging up a defaulat gralat using join(); to its default class.

you can check on both clientside and serverside using findareanpcs() to see if such a dirthole npc already exists, and just avoid placing it if one does

scriptless
10-29-2014, 01:02 AM
you can check on both clientside and serverside using findareanpcs() to see if such a dirthole npc already exists, and just avoid placing it if one does

My question is digging a hole... and an object.. puts 2 putnpc2 in the exact spot.. now on GK this proved my theory that in some cases the putnpc2's show on top of each other in different orders for no apparent reason. It's to my understanding that the only way to persistently show them correctly is in a gang, via gani script so that you can grab the item, before the hole dissapears.

Jakov_the_Jakovasaur
10-29-2014, 05:56 AM
My question is digging a hole... and an object.. puts 2 putnpc2 in the exact spot.. now on GK this proved my theory that in some cases the putnpc2's show on top of each other in different orders for no apparent reason. It's to my understanding that the only way to persistently show them correctly is in a gang, via gani script so that you can grab the item, before the hole dissapears.

putting drawunderplayer() on the dirt hole should work, if you need to use drawunderplayer() on the item as well and it uses a bounce effect similar to default rupees, modify z in a scripted animation rather than y or place it inside a normal gani

MysticalDragon
10-29-2014, 07:57 AM
But you really shouldnt have to draw the item
Under the player, that would just be weird.

xAndrewx
10-29-2014, 04:01 PM
Create a new gani and add a param for the dirt image and one for the item icon.

Jakov_the_Jakovasaur
10-29-2014, 04:45 PM
But you really shouldnt have to draw the item
Under the player, that would just be weird.

i know, it was hypothetical

Inari
10-29-2014, 04:56 PM
My question is digging a hole... and an object.. puts 2 putnpc2 in the exact spot.. now on GK this proved my theory that in some cases the putnpc2's show on top of each other in different orders for no apparent reason. It's to my understanding that the only way to persistently show them correctly is in a gang, via gani script so that you can grab the item, before the hole dissapears.

Shouldn't they be
Dirt hole => under player
Object => same layer as player
?

Cubical
10-29-2014, 05:10 PM
Shouldn't they be
Dirt hole => under player
Object => same layer as player
?

y when u can just use a gani...

Inari
10-29-2014, 05:18 PM
y when u can just use a gani...
Not sure, seems cleaner, since "object" can be a lot of things: a rupee, a bomb (that about to explode), etc.

scriptless
10-30-2014, 01:24 AM
Not sure, seems cleaner, since "object" can be a lot of things: a rupee, a bomb (that about to explode), etc.

Yeah, thats why things are kinda difficult. It would be super cool if I could just have tiles that are not 2047 revert back to normal.. but the only tiles that the whole disappears from are ones that were entirely those tiles. So tiles like 0, and 1 would not be changed back for some reason. Thats the only problem I am having with the method I am using....lag is more like an eh not an issue but the fact it won't change back for some tiles at all even after 18 hours.. yeah thats not lag at all.. =/

Crow
10-30-2014, 07:55 AM
You can check out the "object" class in my Atlantis dump for something like this. I switch out tiles both on the serverside and clientside there to get a smoother experience. It's a bit more restrictive (bushes/stones/... sitting on top of the tiles) and therefore easier to control than your shovel stuff, though, but maybe it'll give you a few ideas. One thing to keep in mind: when using updateboard(), update a region larger than 2 by 2, no matter how many tiles you actually changed. Stefan added some "optimization" to the server at some point that can really **** up your tile handling when you're updating a 2 by 2 region.

Cubical
10-30-2014, 09:07 AM
bro... ganis.. not hard

xAndrewx
10-30-2014, 03:24 PM
Create a new gani and add a param for the dirt image and one for the item icon.

this.

Crow
10-30-2014, 03:34 PM
this.

No need to alienate things.

Inari
10-30-2014, 04:13 PM
this.

So, now you want to make a bomb that explodes?

scriptless
10-31-2014, 02:59 AM
You can check out the "object" class in my Atlantis dump for something like this. I switch out tiles both on the serverside and clientside there to get a smoother experience. It's a bit more restrictive (bushes/stones/... sitting on top of the tiles) and therefore easier to control than your shovel stuff, though, but maybe it'll give you a few ideas. One thing to keep in mind: when using updateboard(), update a region larger than 2 by 2, no matter how many tiles you actually changed. Stefan added some "optimization" to the server at some point that can really **** up your tile handling when you're updating a 2 by 2 region.

I think I did read that he made some optimizations. And he made a command on bush's specifically and being able to regrow them via script or something if I am not mistaken? However on a gmap, how do the x/y work for update board? Are they 0 to 64 or are they 0 to 64 * levels?

Crow
10-31-2014, 06:17 AM
I think I did read that he made some optimizations. And he made a command on bush's specifically and being able to regrow them via script or something if I am not mistaken? However on a gmap, how do the x/y work for update board? Are they 0 to 64 or are they 0 to 64 * levels?

Not sure. I'm just using this.x and this.y in Atlantis' "object" class. Can't remember if that's the global or local coordinates.

Jakov_the_Jakovasaur
10-31-2014, 04:30 PM
use map coordinates

xAndrewx
11-01-2014, 08:29 AM
would be interesting to see your work around

scriptless
11-02-2014, 02:45 AM
would be interesting to see your work around

who's workaround? I figure I'm gonna need to check tiles, and npc's.. this is going to be fun.

scriptless
11-03-2014, 04:00 AM
Okay, so this is giving me problems... more specifically its making npc's a good distance away say "Hit".. It's in the weapon npc... cx/cy are the cordinate x and y that I want to check at.. (top left of the hole dug).. Should be 2x2 tiles. But this seems to affect npc's further away.

for(temp.n : findareanpcs(this.cx, this.cy, this.cx + 1, this.cy + 1)){
temp.n.chat = "Hit!";
}

It's giving it a huge gap between the npc I dug and the ones around it... :x

Edit:

Okay, sorry I guess thats x/y/w/h I needed to just supply 2,2 for the width,height... for some reason I was entering ending x/y cords. My bad, sorry.

However, gralats have not been showing for me on this server or my personal dev server unless I first logon UN... anyone know why this is? I would have thought a newly bought server would be working, is it missing some file?

Jakov_the_Jakovasaur
11-03-2014, 06:08 AM
Okay, so this is giving me problems... more specifically its making npc's a good distance away say "Hit".. It's in the weapon npc... cx/cy are the cordinate x and y that I want to check at.. (top left of the hole dug).. Should be 2x2 tiles. But this seems to affect npc's further away.

for(temp.n : findareanpcs(this.cx, this.cy, this.cx + 1, this.cy + 1)){
temp.n.chat = "Hit!";
}

It's giving it a huge gap between the npc I dug and the ones around it... :x

Edit:

Okay, sorry I guess thats x/y/w/h I needed to just supply 2,2 for the width,height... for some reason I was entering ending x/y cords. My bad, sorry.


looking at the original script:



//#CLIENTSIDE
function onCreated() {
this.x = player.x + 1.0 + vecx(player.dir) * 2;
this.y = player.y + 1.0 + vecy(player.dir) * 2;
for ( this.iy = 0; this.iy < 2; this.iy ++ ) {
for ( this.ix = 0; this.ix < 2; this.ix ++ ) {
this.checkX = this.x+this.ix;
this.checkY = this.y+this.iy;
tiles[this.checkX, this.checkY] = this.replaceTiles[this.ix+this.iy*2];
}
}
updateboard(this.x,this.y,2,2);
}

is there still not a break; for when 4 grass tiles have been detected on clientside?

if not then it could be triggering to the server up to 4 times and ultimately checking a larger region on serverside than necessary

MysticalDragon
11-03-2014, 08:43 AM
Okay, so this is giving me problems... more specifically its making npc's a good distance away say "Hit".. It's in the weapon npc... cx/cy are the cordinate x and y that I want to check at.. (top left of the hole dug).. Should be 2x2 tiles. But this seems to affect npc's further away.

for(temp.n : findareanpcs(this.cx, this.cy, this.cx + 1, this.cy + 1)){
temp.n.chat = "Hit!";
}

It's giving it a huge gap between the npc I dug and the ones around it... :x

Edit:

Okay, sorry I guess thats x/y/w/h I needed to just supply 2,2 for the width,height... for some reason I was entering ending x/y cords. My bad, sorry.

However, gralats have not been showing for me on this server or my personal dev server unless I first logon UN... anyone know why this is? I would have thought a newly bought server would be working, is it missing some file?
Utilize f2 to see if there is any missing files

xXziroXx
11-03-2014, 09:27 AM
findareanpcs(x, y) returns a list of npc id's, not a list of a TServerNPC objects.

scriptless
11-03-2014, 12:04 PM
looking at the original script:



is there still not a break; for when 4 grass tiles have been detected on clientside?

if not then it could be triggering to the server up to 4 times and ultimately checking a larger region on serverside than necessary

Sorry, I should have posted whole script so far.. Instead of using breaks, I used return's from different functions.

Utilize f2 to see if there is any missing files

I didn't see anything in f2, I already checked. Plus I did "/find *gralat*" and it only found the gani. So I uploaded gralats.png but it still didn't work.

Jakov_the_Jakovasaur
11-03-2014, 04:54 PM
findareanpcs(x, y) returns a list of npc id's, not a list of a TServerNPC objects.

this is not true for findareanpcs(), this is however true for getareanpcs()

xXziroXx
11-03-2014, 04:59 PM
this is not true for findareanpcs(), this is however true for getareanpcs()

derp

scriptless
11-12-2014, 02:30 AM
Okay still scratching my head over this. Can someone please help me figure out a more logical way to actually dig a hole because my hole, keeps digging OVER the npc I dig up when it's a block and its getting frustrating.

function onCreated() {
// Tiles that we can dig up, I am using INT not HEX
this.checkTiles = {
0, 1, 680, 695, 696, 2047, 679, 907, 48,
49, 1647, 1734, 2103, 16, 2102, 1767, 1782,
1783, 1405, 3049, 1386, 1387, 3048, 1735,
1751, 1750
};
}
function onActionServerside() {
// We want to dig :)
if ( params[0] == "dig" ) {
if ( DigUp() == false ) {
DigRandomItem();
}

}
}

function DigRandomItem() {
temp.random = int(random(0,100));

if ( temp.random in |0,75| ) {
return "worm";
}

if ( temp.random in |76,100| ) {
return "gralat";
}

return false;
}

function DigUp() {

// Variables
this.digx = player.x + 1.0 + vecx(player.dir) * 2;
this.digy = player.y + 1.0 + vecy(player.dir) * 2;

// Check putnpc2's
for(temp.n : findareanpcs(this.digx, this.digy, 2, 2)){
triggerclient("gui", this.name, "play", "crush.wav");
return true; // cannot dig
}

// Check Tiles
for ( this.iy = 0; this.iy < 2; this.iy ++ ) {
for ( this.ix = 0; this.ix < 2; this.ix ++ ) {
this.checkX = this.digx + this.ix;
this.checkY = this.digy + this.iy;
if ( !(tiles[this.checkX,this.checkY] in this.checkTiles) ) {
triggerclient("gui", this.name, "play", "crush.wav");
return true; // cannot dig
}
}
}

temp.hole = putnpc2(this.digx, this.digy, "");
temp.hole.join("shovel-hole");
temp.hole.drawunderplayer();

temp.item = DigRandomItem();

if ( temp.item == "gralat" ) {
temp.object = putnpc2(this.digx, this.digy, "");
temp.object.join("gralats");
temp.object.rupees = 1;
} else {

if ( temp.item == "worm" ) {
temp.object = putnpc2(this.digx, this.digy, "");
temp.object.join("shovel-item");
temp.object.image = "block.png";
}
}
triggerclient("gui", this.name, "play", "lift.wav");
}

//#CLIENTSIDE
function onWeaponFired() {
// Show player digging
freezeplayer(0.8);
setani("partasti_shovel", "partasti_shovel.png");
triggerserver("gui", this.name, "dig");
}

function onActionClientside() {
if ( params[0] == "play" ) {
play(params[1]);
}
}

And the hole,

// Join to all the hole's dug up by a shovel

function onCreated() {
setimg("partasti_dirthole.png");
dontblock();
drawunderplayer();
sleep(5);
destroy();
}

Inari
11-12-2014, 01:53 PM
Try setting the item layer to 1?

Jakov_the_Jakovasaur
11-12-2014, 04:50 PM
im not sure if this is the case with more recent npc-server versions but it certainly was the case before, an npc needs a setshape() to be found by findareanpcs();

your check should still be improved though, currently it is attempting a loop only to return once it finds any npc, which could be the case for a random non-blocking npc, there should be a check within the loop to determine if the npc is either blocking or is a dirthole

it could also be very unsmooth to be triggering like that in order to play a sound especially given a high latency, if you do these checks on clientside first you can have the sound play in real time (and even put it in a gani for others to see), then you can do the checks again on serverside as a matter of preventing duplication or for security

scriptless
11-12-2014, 10:31 PM
im not sure if this is the case with more recent npc-server versions but it certainly was the case before, an npc needs a setshape() to be found by findareanpcs();

your check should still be improved though, currently it is attempting a loop only to return once it finds any npc, which could be the case for a random non-blocking npc, there should be a check within the loop to determine if the npc is either blocking or is a dirthole

it could also be very unsmooth to be triggering like that in order to play a sound especially given a high latency, if you do these checks on clientside first you can have the sound play in real time (and even put it in a gani for others to see), then you can do the checks again on serverside as a matter of preventing duplication or for security

Good point. However doesn't resolve the fact that sometimes the block shows before the dirt hole making it look like you dug up nothing until the dirt hole vanishes and releases the item that the dirt hole image was covering up. Basically under no circumstance should my dirt hole show above the block yet it does nearly 8 out of 10 times which is a huge critical problem for me and my goal. Like game breaking problem.