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.
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...
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'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.
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 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.
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.
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.
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.
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
On removal of the flag you can just do a check to see if the flag should remain or not, problem solved.
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.
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 }
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.
[LuckyTime]FireFlow 04/10/2010 - CO2 Weapon, Armor, Effects & Interface edits - 14 Replies heya here a nice luckytime edit, press thanks if u like it^^
http://zoconquer.synthasite.com/resources/fireflo w1.JPG
download here
[help]luckytime 09/29/2009 - CO2 Private Server - 2 Replies hi does anyone have a guide/release how to add the skill bless (luckytime) into a 5017 source like mine (Powerco Source) ty
luckytime 09/22/2009 - CO2 Private Server - 0 Replies case 9876:
{
#region LuckyTime
Dictionary<int, int> Targets = new Dictionary<int, int>();
Targets.Add(CSocket.Client.ID, 0);
CSocket.Client.LuckyTiming = DateTime.Now;
ConquerPacket.ToLocal(ConquerPacket.MagicAttack(CS ocket.Client.ID, Spell.ID, 0, Targets, CSocket.Client.X, CSocket.Client.Y), CSocket.Client.X, CSocket.Client.Y,...
LuckyTime Bug! 01/27/2007 - Conquer Online 2 - 4 Replies Hey you guys MAY you know the luckytime bug if the owner of luckytime casts it and 3 ppl sit on him (stackin) the first 2 on him will still get luckytime..
BUTTTTTT theres another bug .. you can cast luckytime in TG just use luckytime and press fastly sit (hotkey it) YOU can make lvl 80- fire taos stop attacking stakes^^ i did it many times buhaha enemy guilds ;D
(YOU CAN ONLY MAKE EM STOP IF THEY GOT LVL 2- FIRECIRCLE AND USIN IT)
enjoy~~
(i jus wanna share with u guys ok^^?)