How to expand the range of defense
On my server we are developing a new weapon, the Shield. The idea of the weapon, do not allow much mobility, but have completely blocked. Well, we had trouble with this last part, we do not know how to add range on defense.
This is the configuration of zitem:
Code:
<ITEM id="102006" name="STR:ZITEM_NAME_502006" mesh_name="katana18" totalpoint="0" type="melee"
res_sex="a" res_level="40" slot="melee" weapon="katana" weight="11" bt_price="500000"
delay="450" damage="26" ctrl_ability="0" magazine="0" reloadtime="0" slug_output="false"
gadget_id="0" hp="0" ap="0" maxwt="0" sf="0" fr="0" cr="0" pr="0" lr="0" color="#FFFFFFFF"
image_id="0" bullet_image_id="0" magazine_image_id="0" iscashitem="false" desc="STR:ZITEM_DESC_502006"/>
We have used the "Wooden Sword" to test this item.
I'm sorry if my English is bad, but it is not my native language. Thank you very much.
Re: How to expand the range of defense
Defense range can't be done by XML.
It's client side.
What I mean by client side is ASM'ing your runnable I guess.
Re: How to expand the range of defense
Guard distance.. I can't even think of the function that would belong in. Neat tip you could make guns have block if you wanted to and have say, a shield with a machine gun on it to make it balanced, so that you can still get shot in the feet/back.
That is manipulated via a very simple function
ZClient::ProcessGuard(Not sure THINK thats it just off the top of my head) there's littearly a check on it if it's != Melee , just make that return true for your custom item. That's really all I can propose atm tbh, you can poke around process guard see where else it leads to maybe you'll find a guard distance.
Re: How to expand the range of defense
Detour ZMyCharacter, ZCharacter, AddSwordDefenceEffect,GetEquipedItemUID.
Inside character detours check if he has the item uid eqquiped if he has, damage / 2.
If you do (damage = 0) he would never lose hp, but you can fix it
by checking his position to check if he was shot by the behind, using
Code:
float *result, *pointer;
float *GetDirection(unsigned long ZCharacter)
{
return(float*)(ZCharacter + 0x5C);
}
float *GetPosition(unsigned long ZCharacter)
{
_asm
{
mov ecx, ZCharacter
mov eax, dword ptr ds:[ecx + 0x58]
mov ecx, dword ptr ds:[eax + 0x20]
mov edx, dword ptr ds:[eax + 0xC]
mov eax, dword ptr ds:[edx + ecx * 0x4]
mov result, eax
}
return result;
}
bool IsCharacterInMyFront()
{
float mypos[3]; //a vector containing xyz
float laidpos[3];
unsigned long lid = GetLAID(ZCharacter()); //GetLastAttackerID
memcpy(laidpos,GetPosition(GetZCharacter(laid)), sizeof(laidpos));
memcpy(mypos,GetPosistion(ZCharacter()), sizeof(mypos));
if(mypos[1] > laidpos[1])
return true;
return false;
}
No need to check if the float pointer is < zero because the bool autommaticaly returns false
Code:
Detour ZCharacter(...)
{
(...)
if(!IsCharacterInMyFront)
sentdamage=0;
(...)
}
It is just a little snippet code, but hope it may help you
Hum, since I'm helping and I'll do it right, so I'll explain how this works so anyone can understand, i took my time to it.
http://img691.imageshack.us/img691/107/explanatione.jpg
float mypos[3] & float laidpos[3] are a vector containing x, y and z
coordinates which can be represented above, (mypos[1] represent x, mypos[2] y, mypos[3] z)
we are comparing the X pointer from the attacker character and my character,
if he is behind me the his X point will be lower than mine, if he is in my front the X point will be bigger than mine.
Hope it help
Re: How to expand the range of defense
@Above: Whilst that works, it's not the most elegant solution. The best way to do it would be to find where GunZ determines whether it blocks or not and edit that function accordingly.
Also, I'm not sure that some of your code is correct? The IsMyCharacterInFront() function seems to only work if the person is at a greater y value than you are. This creates some odd cases:
http://i54.tinypic.com/1zq61r7.png
To fix that function, you could do several things. For example, if you can see the player, block against it. Or, if the player is within a certain angle and elevation from you, block the hit (which is probably better, and can be accomplished by also using the player's directional vector).
EDIT: I realized that's not exactly what your function does, by my logic still stands :P. You'd need a better function for checking whether the hit should register or not.
Re: How to expand the range of defense
Yes, my code is very incorrect, it is a base idea of how to do it, and now that I analyze it I see that both of our ideas are incorrect, for a moment we forgot that a facing point is the X, because it is not 2d, and we are talking about matrix and vectors.
There is no way to draw an arrow to express where it was shot from, because the matrix (Z) always point to FRONT, it's like in real life, we are always GOING IN, we are not moving in Y or X, which is called vector.
What should be calculated is all of the three points X, Y, Z, I do not mind to code something because the idea is up to how you want to do it, and how you think it is correctly.
Re: How to expand the range of defense
I'm not incorrect. Whilst the Z axis was not drawn on these diagrams, I was only using a similar diagram to show why your programming was in error.
As I suggested at the bottom, a good way to do it is if the enemy is in a certain area in front of the player, then block it. Otherwise, don't. This takes into account for the third axis.
This can be accomplished by either using the x, y and z components, or by using the position vector of the enemy, your own position vector and your directional vector.
My only point was that you posted incorrect code, and I thought I would help out and point out where you was wrong.
Re: How to expand the range of defense
Thanks Sofynha, your code gives me an idea of what I have to do.
What I had thought was float plane based on the player, but I do not know if it's possible.
Well, I'll see what I do with this, and then I will publishes another topic.
Re: How to expand the range of defense
Quote:
Originally Posted by
Aristrum
I'm not incorrect. Whilst the Z axis was not drawn on these diagrams, I was only using a similar diagram to show why your programming was in error.
As I suggested at the bottom, a good way to do it is if the enemy is in a certain area in front of the player, then block it. Otherwise, don't. This takes into account for the third axis.
This can be accomplished by either using the x, y and z components, or by using the position vector of the enemy, your own position vector and your directional vector.
My only point was that you posted incorrect code, and I thought I would help out and point out where you was wrong.
Hey calm down man, I thank you for pointing that my code is incorrect, but I made it up in here, it's not like something I have compiled and I see the big mistake I did, to be more honest the % of me doing something I never did before correctly is 40% average, no need to be so aggressive, yes I'm wrong.
Look, what you did in there pointing the arrows, can be described with only X & Y, (you pointed to somewhere else (the enemy), and that position can be represented only by X&Y, and if something doesn't takes Z, then it's just 2d, your idea is also good, but you see, the Z point is the 3d pointing forward/backward as represented in the image below
http://www.jnoodle.com/Blitz3D/xyz.gif
imagine that the +Y is the head of the character and the -Y is the feet, the -X is the left arm and the +X is the right arm, the +Z(or -Z it depends) is where he is pointing to(facing to).
The arrows you have represented are not the +Z or the -Z position, its an 2d pointer.
That is why both of our ideas are incorrect, you don't need to be angry, I apologize for the wrong code but it is just an idea you see
oh, and you're always welcome cosito!
Re: How to expand the range of defense
Quote:
Originally Posted by
Sofynha
Hey calm down man, I thank you for pointing that my code is incorrect, but I made it up in here, it's not like something I have compiled and I see the big mistake I did, to be more honest the % of me doing something I never did before correctly is 40% average, no need to be so aggressive, yes I'm wrong.
Look, what you did in there pointing the arrows, can be described with only X & Y, (you pointed to somewhere else (the enemy), and that position can be represented only by X&Y, and if something doesn't takes Z, then it's just 2d, your idea is also good, but you see, the Z point is the 3d pointing forward/backward as represented in the image below
http://www.jnoodle.com/Blitz3D/xyz.gif
imagine that the +Y is the head of the character and the -Y is the feet, the -X is the left arm and the +X is the right arm, the +Z(or -Z it depends) is where he is pointing to(facing to).
The arrows you have represented are not the +Z or the -Z position, its an 2d pointer.
That is why both of our ideas are incorrect, you don't need to be angry, I apologize for the wrong code but it is just an idea you see
oh, and you're always welcome cosito!
I'm not angry at all. I was just helping, and you said I was wrong.
The fact is we was simplifying to explain. It's a lot harder to draw 3d diagrams, so I settled on 2d diagrams from an over the head perspective, and arbitrarily chose x and y (as is normal in 2d graphs) as the axis names.
If I were using the image you posted, they should be the named z and x axis instead.
Sometimes it's best to look at the problem from a different angle. Since the problem is checking if people are in "front" of the character, you don't really need to consider the 3rd dimension at all - just imagine it as 2d and the problem becomes a lot easier to solve.
Then, once you have a solution for 2d, you can apply the same logic on the third dimension to come up with another solution.
I wasn't using the 3rd dimension because it's more convenient to describe the problem in 2 dimensions. That's all. I'm not an idiot, I understand what x, y and z coordinates are.
Like I said again my friend: I'm not angry at all :). Sorry if it came across that way - but I just originally wanted to help out somebody who looked as if they had a very bad sense of the code involved.
Maybe next time, just use pseudo-code, or code it properly ;).