hawksprite
Member
|
Player combat in the MMO Source code
In the Characters update attack method i've been toying with this funciton:
Code:
if(attack.eventBetween("hit-from", "hit-to"))
{
// check for collision with other players and add damage
REPA(Neighbors)
{
}
}
I've tried using methods for detecting collision from other tutorials but just can't seem to get it to work. Am I on the write path? And how do I check the current player to all there neighbors when It comes to an attack.
|
|
08-08-2012 05:28 PM |
|
TBJokers
Member
|
RE: Player combat in the MMO Source code
do something simple, REPA(Neighbors){if(Dist(Player.pos(),Neighbors[i].pos())<2)File f; f.writemem(IHitYou); f.pos(0); f.datafull(f,f.left);
Then you can do the rest on the server, damage etc, but this is a very simple version of collision
Man, it's always that semicolon...
|
|
08-11-2012 07:08 PM |
|
hawksprite
Member
|
RE: Player combat in the MMO Source code
I'll toy with a little better method of collision, then post my results. Thanks for the idea.
|
|
08-11-2012 09:25 PM |
|
levijgraham
Member
|
RE: Player combat in the MMO Source code
Im trying to setup simple combat aswell but when I put neighbors[i].pos() it says no operator [] matches these operands. Slightly confused by how the attack system really works :|
(This post was last modified: 08-12-2012 08:55 PM by levijgraham.)
|
|
08-12-2012 08:54 PM |
|
hawksprite
Member
|
RE: Player combat in the MMO Source code
I'm getting closer and since there appears to be other members asking i'll post my findings.
So far what i've been going off TBJokers said but making a more in depth collision method.
This is what i'm trying:
Code:
if (Neighbors.lockedData(i).cskel.skeleton())
{
REPA(Neighbors.lockedData(i).cskel.skeleton()->bones)
{
if (Neighbors.lockedData(i).cskel.skeleton()->bones[i].flag){
Shape shape = ShapeBone(Neighbors.lockedData(i).cskel.skeleton()->bones[i]);
shape*=Neighbors.lockedData(i).cskel.bone(i).matrix();
if (Physics.cuts(shape))
{
lolpop = "Collision found!";
}
}
}
}
Now the problem with this is that it crashes every time the player swings. I've narrowed it down to the
Code:
REPA(Neighbors.lockedData(i)cskel.skeleton()->bones)
{
}
My assumption is that there aren't bones in this skeleton? But this doesn't quite make sense either because of the animations.
Any insight would be much appreciated.
|
|
08-13-2012 02:36 AM |
|
hawksprite
Member
|
RE: Player combat in the MMO Source code
On top of things it now breaks my Inventory when I right click, it stops showing items and isn't allowing me to re-open it. But only after right clicking in game.
|
|
08-13-2012 05:43 AM |
|
TBJokers
Member
|
RE: Player combat in the MMO Source code
Code:
if(Neigbors.elms())
{
Neighbors.lock();
REPA(Neighbors)
{
if(Dist(Plr->cskel.findBone("HandBone")->pos,Neighbors.lockedData(i).center())<5)//Keep pretty high so that incase the player hits by the legs it still collides
{
lolpop = "collision found";
}
}
}
Neighbors.unlock();
Man, it's always that semicolon...
|
|
08-14-2012 03:40 AM |
|
hawksprite
Member
|
RE: Player combat in the MMO Source code
I ended up creating a triangle list for the weapon and capsule for the neighbor. Then running a Cuts().
While mine is more accurate do you think the distance method is more optimized?
It's an interesting decision to choice between, I guess if the rest of the game begins to bottle neck you can fall back to distance combat for a few FPS.
|
|
08-14-2012 11:28 PM |
|