Game Development Community

Melee Combat

by Brian Lococo · in Technical Issues · 06/30/2004 (10:12 am) · 29 replies

I am currently doing the AI part of a game project based on Gladitorial combat. I am having a hard time finding a place to start in order to implement a melee style bot. Any suggestions would be appreciated.
Thanks.

About the author

Recent Threads

  • Strings as arrays?
  • Page«First 1 2 Next»
    #21
    01/13/2008 (3:52 am)
    This is where those advanced trig classes finally come in handy.... Too bad I never took them.

    Regardless lets jump in head first.

    Lets call the line between the start and end the Damage Segment.

    We want a damage segment that is always positioned around our player's location as well as facing the same direction as the player.

    Lets use a segment that is one meter in front of the player, one meter above the player's feet and extends one half of a meter out to either side. Below is a side and top view of what I mean.

    www.geocities.com/kyberteknik/forum_pics/melee.jpg
    Our offsets will become:
    // adjust these to reposition the damage segment
    %startOffset = "0.5 1 1";
    %endOffset = "-0.5 1 1";

    We then need to rotate these offsets to face the same direction as the player.
    // get player's transform
    %trans = %player.getTransform();
    
    %localStartOffset = MatrixMulPoint(%trans, %startOffset);
    %localEndOffset = MatrixMulPoint(%trans, %endOffset);
    
    // get player's position
    %pos = %player.getPosition();
    
    // here are our final values
    %startOffset = VectorAdd(%pos, %localStartOffset);
    %endOffset = VectorAdd(%pos, %localEndOffset);

    Good Luck!
    #22
    01/13/2008 (6:02 am)
    In most implementations the start/end points are actually dummy nodes on the weapon object itself. You can then raycast down that line while the weapon swing is animating, checking to see if it intersects a player's bounding box.

    Of course this works really well if it's a simple weapon such as a sword...and you don't need incredibly accurate collisions for blood splatter or whatnot. A hammer, sickle or a myriad of other non 'stick' shaped weapons and it falls somewhat short.
    #23
    01/13/2008 (4:16 pm)
    @Jacobin: I already mentioned that but he doesn't have an engine license so we can't do all that.
    #24
    01/13/2008 (6:57 pm)
    @ Brian
    ------------

    I understand that the player must face the other player when attacking. But i am not clear about the
    %startOffSet and %endOffSet. I mean where do i implement it? And those 2 variable is not the values fot %damageStart and %damageEnd right, where it is use for the input for containerRayCast?

    I played around with containerRayCast method. Theres a time where i managed to sense the other player but wherever i go, it still detect.
    #25
    01/14/2008 (6:11 am)
    Yes, %startOffet and %endOffset are the values you use for %damageStart and %damageEnd (I still don't know where you got those names from but whatever you wanna call them is fine).

    You do that code right before doing the ray cast.

    You will have to post examples of what you are trying and point out what part doesn't work. We can tell you all day long what to do, but not having any idea if you are doing it right we can't really help.

    Post the codes that are not working, we will help try to fix them.
    #26
    01/14/2008 (9:07 am)
    I put it this way..

    function RodImage::onFire( %this, %obj, %slot )
    {
    
    
    	%obj.playSwingAnimation();
    
    
    
    	%startOffset = "0.5 1 1";
    
    	%endOffset = "-0.5 1 1";
    
    	
    
    	%trans = localclientconnection.player.getTransform();
    
    	%localStartOffset = MatrixMulPoint(%trans, %startOffset);
    
    	%localEndOffset = MatrixMulPoint(%trans, %endOffset);
    
    
    	%pos = localclientconnection.player.getPosition();
    
    	
    
    	%startOffset = VectorAdd(%pos, %localStartOffset);
    
    	%endOffset = VectorAdd(%pos, %localEndOffset);
    
    
    	%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::StaticShapeObjectType;
    
    	
    
    	%scanTarg = ContainerRayCast(%startOffset, %endOffset, %searchMasks, localclientconnection.player);
    
    	echo("%scanTarg:" @ %scanTarg);
    
    	
    }

    I end up getting 0 for %scanTarg. Even though the AI is right in front of me.
    #27
    01/15/2008 (1:22 am)
    Its hard to visualize where the segment is being drawn within the engine. The offsets you want to use really depend on the size of your characters.

    Maybe I gave the wrong offsets. Does it ever return a scan target? Try spinning around and jumping and such while the AI is near and see if it ever returns. If it does then I just got the offsets wrong. It might be that they are not far enough out.

    I'm unsure of the best way to draw/display this line for better visualization.

    Anybody else see any problems here?
    #28
    01/15/2008 (9:40 am)
    Thanks for the help along the way...i found other resources....maybe working...will try...if theres any problem i get back here again...
    #29
    01/30/2008 (2:40 pm)
    Please disregard my previous comments. I got most of it figured out.
    Page«First 1 2 Next»