Opinions on luckytime

05/07/2014 02:22 CptSky#16
As most servers already store the accessibility as a boolean, just change it as a bitfield in a 8 bits integer, and bam, you have access to 7 new flags without increasing the memory pressure. The bit field comparison operations will be negligible.

Thinking of it, it's clearly the best solution to have a flag.
05/07/2014 02:37 InsomniacPro#17
Flagging tiles is the way I decided to go, working wonderfully without any issues whatsoever.
05/07/2014 02:51 { Angelius }#18
Quote:
Originally Posted by InsomniacPro View Post
So, I would like some opinions on how I should handle luckytime.
For example, I can either enumerate through players within a screen, and check for distance and check for llucky time. If a player is within range for luckytime, they start luckabsorb.

Now option B tht I have. When a player starts luckytime, its in a 7x7 grid. Now the tiles within that 7x7 grid, get an attribute declaring them luckytime tiles, a blessed tile if you will. When player is standing still on a blessed tile, they start gaining luckytime.

Which of these would be the smarter more efficient route. Or if you have another, better way, I would love to hear.

Code:
int base_X = 10, base_Y = 10;

int lowerX= base_X - 3, lowerY= base_Y - 3;// Lowest possible coordinate value.

for (int x = lowerX; i < lowerX + 6; x++)//Enumerate through all possible X values.
{
    for (int y = lowerY; j < lowerY + 6; y++)//Enumerating through all possible Y values.
    {
         map.SetBlessedTile(x, y);
    }
}
So if i am casting luckytime and a player decides to walk right up to me to pray, You are gonna loop 36 times and call map.IsBlessed(x,y) each block that player walks just to check if i am casting luckytime? I think its a stupid idea and i don't blame you.. I blame the first responders...

That ^ is a waste of time and resources.

You are over complicating things here...
Quote:
class Hero
{
public bool CastingLuckytime;// = false
public Dictionary<int, Hero> or List<Hero> LuckyTimeLeechers;
}
Assume that Hero A is standing at 10X 10Y.
Hero A casts the Luckytime spell and goes afk... His mother she's been yelling at him to go to bed for hours or something....
Hero B jumps into Hero A screen.
Here you are gonna have to spawn Hero A to B and B to A so they can see each other.

if (A.CastingLuckytime && B.CastingLuckytime)
do nothing
if(A.CastingLuckytime && !B.CastingLuckytime)
A.LuckyTimeLeechers.Add(B);
if(!A.CastingLuckytime && B.CastingLuckytime)
B.LuckyTimeLeechers.Add(A);

LuckyTimeLeechers will be your reference later on because you are gonna have to Add/Remove status flags from not only the Hero that is casting Luckytime but from the Luckytime Leechers as will since they cant keep the Praying flag once they/the caster move(s).


Good luck.. I only had like 4 min to spare so please excuse my sloppy reply.

@Everyone else
I am sorry but i couldn't leave the house before i say... Why the fuck would you need to LOOP through lists or whatever the heck you guys are talking about for such a simple feature... You are spawning players to each other with or without checking for luckytime casters so why not take advantage of that...
05/07/2014 04:01 InsomniacPro#19
Quote:
Originally Posted by { Angelius } View Post
Code:
int base_X = 10, base_Y = 10;

int lowerX= base_X - 3, lowerY= base_Y - 3;// Lowest possible coordinate value.

for (int x = lowerX; i < lowerX + 6; x++)//Enumerate through all possible X values.
{
    for (int y = lowerY; j < lowerY + 6; y++)//Enumerating through all possible Y values.
    {
         map.SetBlessedTile(x, y);
    }
}
So if i am casting luckytime and a player decides to walk right up to me to pray, You are gonna loop 36 times and call map.IsBlessed(x,y) each block that player walks just to check if i am casting luckytime? I think its a stupid idea and i don't blame you.. I blame the first responders...

That ^ is a waste of time and resources.

You are over complicating things here...
You are over complicating things

public bool BlessedTile(ushort x, ushort y)
{
return (Tile[x,y].Flags & TileFlags.Blessed) == TileFlags.Blessed;
}
05/07/2014 06:57 { Angelius }#20
Quote:
Originally Posted by InsomniacPro View Post
You are over complicating things

public bool BlessedTile(ushort x, ushort y)
{
return (Tile[x,y].Flags & TileFlags.Blessed) == TileFlags.Blessed;
}
That's what i get for helping idiots... What a waste of time.
05/07/2014 07:30 InsomniacPro#21
Quote:
Originally Posted by { Angelius } View Post
That's what i get for helping idiots... What a waste of time.
Idiots? This is a very good way to handle luckytime, which uses less time/resources than enumerating through clients within the screen.

You were making it sound like players are enumerating through tiles just to check if they can pray. Which no, it's a simple check on 1 tile.

So tell me Mr. ProfessionalCoder, what takes more work to do. Enumerating through clients within a screen, or doing an if check?
05/07/2014 09:00 Korvacs#22
Quote:
Originally Posted by { Angelius } View Post
That's what i get for helping idiots... What a waste of time.
If you don't understand why looping once to set the flag and then checking for the flag (which you should be doing anyway) is better than looping and doing a distance check every single time an entity moves, then I guess there's no helping you.
05/07/2014 09:47 KraHen#23
Quote:
Originally Posted by InsomniacPro View Post
You are over complicating things

public bool BlessedTile(ushort x, ushort y)
{
return (Tile[x,y].Flags & TileFlags.Blessed) == TileFlags.Blessed;
}
He was showing you how to set it up, not the check.

@Fang : Yes, I do realize that, but you can`t do it without comparisions anyways, and you can simplify most of them with bit operations as well (something like a Karnaugh map - actually not but that`s the closest example I could come up with right now).
05/07/2014 10:43 InsomniacPro#24
Quote:
Originally Posted by KraHen View Post
He was showing you how to set it up, not the check.

@Fang : Yes, I do realize that, but you can`t do it without comparisions anyways, and you can simplify most of them with bit operations as well (something like a Karnaugh map - actually not but that`s the closest example I could come up with right now).
He was under the impression that I would be looping for a simple check. I was correcting him and telling him why he was wrong.
05/07/2014 12:30 -impulse-#25
Quote:
Originally Posted by InsomniacPro View Post
You are over complicating things

public bool BlessedTile(ushort x, ushort y)
{
return (Tile[x,y].Flags & TileFlags.Blessed) == TileFlags.Blessed;
}
This would work fine if you do it correctly like:
When one uses lucky time you do a circle around him and put the flag Blessed.
When one moves around or just stands, check every 5 seconds (or less) if one is standing on a blessed tile.

That way you do not waste resources. You don't have to check the area around you, just the tile you are sitting on.

Even like this there is still an issue. Collisions. If two players are close to each other and both use lucky time, when one leaves, you will have to mark the area not blessed which might cut from the other's blessed area. In this case you'll have to go through your screen's players and remake all the tiles.
05/07/2014 12:59 Y u k i#26
With flags the error checking seems to be harder: Imagine 3 players on the screen.
A B and C.

A casts luckytime, sets the tile flags to "StartPraying" or whatever, player B jumps in, Tilecheck returns StartPraying, so he does. Now C jumps in and activates luckytime, wich again sets the flag "StartPraying" but this time, C also jumps out of the screen imediatelly. Now, since Flags are static, the tiles will not have the flag "StartPraying" and once a new player (D) jumps into the screen, he wont be able to receive luckytime.
05/07/2014 13:10 Korvacs#27
Quote:
Originally Posted by Y u k i View Post
With flags the error checking seems to be harder: Imagine 3 players on the screen.
A B and C.

A casts luckytime, sets the tile flags to "StartPraying" or whatever, player B jumps in, Tilecheck returns StartPraying, so he does. Now C jumps in and activates luckytime, wich again sets the flag "StartPraying" but this time, C also jumps out of the screen imediatelly. Now, since Flags are static, the tiles will not have the flag "StartPraying" and once a new player (D) jumps into the screen, he wont be able to receive luckytime.
On removal of the flag you can just do a check to see if the flag should remain or not, problem solved.
05/07/2014 20:48 InsomniacPro#28
Quote:
Originally Posted by -impulse- View Post
This would work fine if you do it correctly like:
When one uses lucky time you do a circle around him and put the flag Blessed.
When one moves around or just stands, check every 5 seconds (or less) if one is standing on a blessed tile.

That way you do not waste resources. You don't have to check the area around you, just the tile you are sitting on.

Even like this there is still an issue. Collisions. If two players are close to each other and both use lucky time, when one leaves, you will have to mark the area not blessed which might cut from the other's blessed area. In this case you'll have to go through your screen's players and remake all the tiles.
I have it checking every 1500 ms if a player is standing on a blessed tile.
And regarding the collision:

Quote:
Originally Posted by Korvacs View Post
On removal of the flag you can just do a check to see if the flag should remain or not, problem solved.
Is exactly what I'm doing.
05/08/2014 02:24 { Angelius }#29
Quote:
Originally Posted by InsomniacPro View Post
I have it checking every 1500 ms if a player is standing on a blessed tile.
And regarding the collision:
Is exactly what I'm doing.
Checking a collection that will hardly contain 10 references every X ms removing any reference that is > X distance and removing its pray status flag. awarding all whats left in that collection with whatever you like. updating the luckytime onscreen timer for each reference. all at the same time.

Bad stuff yeah?
05/08/2014 02:33 InsomniacPro#30
So I'm still waiting for you to tell me how using a dictionary, which you'd have to enumerate through, is more efficient and smarter than making a tile as blessed, then doing a simple if check.

Quote:
Originally Posted by { Angelius } View Post


Checking a collection that will hardly contain 10 references every X ms removing any reference that is > X distance and removing its pray status flag. awarding all whats left in that collection with whatever you like. updating the luckytime onscreen timer for each reference. all at the same time.

Bad stuff yeah?
Sure, you'd only enumerate about 10 entities within the collection probably. And then do whatever needs be with each entry. But still, what is faster? Enumerating through a collection of the prayer, or doing ONE IF CHECK on a single tile in a timed manner. Plz.