Home   Help Search Login Register  

Author Topic: melee attack  (Read 2450 times)

0 Members and 1 Guest are viewing this topic.

Offline Ding

  • Contributing Member
  • **
  • Jurassic Park
melee attack
« on: 18 Feb 2005, 21:41:53 »
ok i want to make a melee attack, i need some help with the script

when the action button "attack melee" is selected i want to play an animation and kill the target, i got as far as playing the animation but i do not know how to make the target set its dammage to 1, can i have some help please :D thanks
"If I remain lost and die on a cross, atleast I wasn't born in a manger"

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:melee attack
« Reply #1 on: 18 Feb 2005, 21:48:41 »
ok

unitname setdamage 1


Planck
I know a little about a lot, and a lot about a little.

DBR_ONIX

  • Guest
Re:melee attack
« Reply #2 on: 18 Feb 2005, 21:57:51 »
Theres a script in the editors depot that does this with a trigger that is moved around with the player..
Basicly if it's an enemy, the anim gets played on player, and the person gets killed.
You could maybe "borrow" ideas from this? :P
- Ben

Offline Ding

  • Contributing Member
  • **
  • Jurassic Park
Re:melee attack
« Reply #3 on: 19 Feb 2005, 17:10:19 »
thanks ben, i will try and find it and take a look at it.

Quote
ok

unitname setdamage 1


Planck


if i had wanted to know that i would not have posted in this forum.
"If I remain lost and die on a cross, atleast I wasn't born in a manger"

Bluelikeu

  • Guest
Re:melee attack
« Reply #4 on: 19 Feb 2005, 17:15:13 »
Wouldn't you want to find if the player is facing the unit that it wants to kill?

Wouldn't seem practical for the player to take a swipe at the enemy and kill them without even facing them.

Thanks,
Bluelikeu

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:melee attack
« Reply #5 on: 19 Feb 2005, 17:31:48 »
If that is not what you wanted to know, then I can only suggest you phrase your question better.

Quote
i got as far as playing the animation but i do not know how to make the target set its dammage to 1

Seems pretty straightforward from your question.


Planck
I know a little about a lot, and a lot about a little.

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:melee attack
« Reply #6 on: 23 Feb 2005, 19:34:42 »
It sound like you are trying to do something that cannot be done.
I tried this awhile back and as you had, I had no such luck.

If what you are trying to do is have your unit have an action (ie "Sock em!")
and then in the action you have unit switchmove "Strokefist" even if you are on top of another unit, you will give that unit do dammage because switchmoves do not do anything other than make your unit do a spiffy jig. (such as they take in no external consiquinces)

A different way you could do this is by doing this:

Code: [Select]
_punchingbag = _this select 0

_puncher = player
_puncher switchmove "Strokefist"
?(_puncher distance _punchingbag > 5):goto"Punchthedope"
hint"Dang! I didnt hit anything!!"
exit

#Punchthedope
~0.75
_punchingbag setdammage 1
hint"Ha ha I socked you!!"
exit

And that should work, if you want you to be able to punch more than one person just add more variables and conditions.
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline Roni

  • Members
  • *
  • Play the Game !
Re:melee attack
« Reply #7 on: 09 Mar 2005, 12:34:49 »
I've written a set of scripts that create a dang fine fist fight between an escapee (using strokefist) and a guard (using his empty strokerifle).

The way I implemented it was to run a continuous script on the guard that says "If the prisoner is out of his cage then move twards him.  If you are within 5m of him then turn to face him, play an animation and a custom sound (whiff !).  If you are within 2m of him then play a nice squelching sound (smack !), cause him some damage and knock him to the ground."

The guard also has an addaction on him that basically says "Take a swing at me".  If you do the action then it plays an animation on the attacker and a custom sound (whiff !).  If you are within 2m of the guard then it plays a nice squelching sound (smack !), causes him some damage and knocks him to the ground.

The player has a script on him that allows him to block an enemy attack.  All it does is set a publicvariable flag for 2 seconds which blocks all enemy attacks.  Because this is on the PLAYER it always appearsas the first action on his list.  This means that in a tight fight all you have to do is double click the middle mouse button to block the enemy attacks.

If you watch the guard carefully you can suss when e is about to strike (thanks to a pause in the script between animation and damage check), set up the block then take your own swing at him before he swings again.  Do it right and you can take him down in a few blows no problems, but if you screw up your timing you can get mashed real quick !

As I have posted elsewhere  :-[ I am currently rewriting these scripts so that they can be assigned to any number of attackers and defenders - at the moment theyonly works with the named units.

Rorke's Drift, here I come !



roni



DBR_ONIX

  • Guest
Re:melee attack
« Reply #8 on: 12 Mar 2005, 20:56:32 »
Could something be done with an array of guards, and get the distance to each one, if't is <3, with some trig, you can check the direction, if it's nearly facing them, you attack them?
- Ben

Offline Roni

  • Members
  • *
  • Play the Game !
Re:melee attack
« Reply #9 on: 14 Mar 2005, 22:55:53 »
After much stuffing around and dredging up of my high school trig I finally managed to create a routine that points the attacker at the target as it swings.  My final goal though was not to turn the attacker to face the target but to only allow the attack in the first place if the attacker was facing within (say) 45 degrees of the target.  This is a little bit trickier but not impossible, it's just that my other projects keep intervening !   :P

One little qirk of my script (which I do like !   8) ) is that the attacker will swing even if he is slightly out of range.  That way you get lots of strokes and lots of mise with the occasional hit.  One thing that I want to do is link the swing range vs strike range and the swing delay to some unit variable such as skill or rank.

Any ideas which would be more suitable ?



roni

Loup-Garou

  • Guest
Re:melee attack
« Reply #10 on: 17 Mar 2005, 21:54:53 »
Here's my (basic) solution for a melee attack :

The player's name is CM.
In his init field I put : this addAction ["Hit with rifle butt","Sg.sqs"]

And here's my script (Sg.sqs) :

CM action ["strokegun"]

if (CM distance Enemy1 <=3) then {Enemy1 setDamage 1}
if (CM distance Enemy2 <=3) then {Enemy2 setDamage 1}
if (CM distance Enemy3 <=3) then {Enemy3 setDamage 1}
if (CM distance Enemy4 <=3) then {Enemy4 setDamage 1}
if (CM distance Enemy5 <=3) then {Enemy5 setDamage 1}
if (CM distance Enemy6 <=3) then {Enemy6 setDamage 1}
if (CM distance Enemy7 <=3) then {Enemy7 setDamage 1}
if (CM distance Enemy8 <=3) then {Enemy8 setDamage 1}
if (CM distance Enemy9 <=3) then {Enemy9 setDamage 1}
if (CM distance Enemy10 <=3) then {Enemy10 setDamage 1}
if (CM distance Enemy11 <=3) then {Enemy11 setDamage 1}
if (CM distance Enemy12 <=3) then {Enemy12 setDamage 1}
if (CM distance Enemy13 <=3) then {Enemy13 setDamage 1}
if (CM distance Enemy14 <=3) then {Enemy14 setDamage 1}
if (CM distance Enemy15 <=3) then {Enemy15 setDamage 1}
if (CM distance Enemy16 <=3) then {Enemy16 setDamage 1}
if (CM distance Enemy17 <=3) then {Enemy17 setDamage 1}
if (CM distance Enemy18 <=3) then {Enemy18 setDamage 1}
if (CM distance Enemy19 <=3) then {Enemy19 setDamage 1}
if (CM distance Enemy20 <=3) then {Enemy20 setDamage 1}
if (CM distance Enemy21 <=3) then {Enemy21 setDamage 1}
if (CM distance Enemy22 <=3) then {Enemy22 setDamage 1}
if (CM distance Enemy23 <=3) then {Enemy23 setDamage 1}
if (CM distance Enemy24 <=3) then {Enemy24 setDamage 1}
if (CM distance Enemy25 <=3) then {Enemy25 setDamage 1}
if (CM distance Enemy26 <=3) then {Enemy26 setDamage 1}
if (CM distance Enemy27 <=3) then {Enemy27 setDamage 1}

exit

 ;)

Offline Roni

  • Members
  • *
  • Play the Game !
Re:melee attack
« Reply #11 on: 17 Mar 2005, 22:01:49 »
I was thinking about setting up two triggers, one with East Present (called (eastLoons) and one with West present (called westLoons).

Assuming that I am West, I will then check all eastLoons every (say) 3 seconds to find the nearest member.  If he is within 5m (say) I will run the "turn to face and take a swing" routine.  If he is within hitting range at the end of this animation step then I will go to the "damage target" routine.

The same will gon reverse for East llons attacking West.

This method means that I don't have to name every loon, it also means that I can add or subtract loons on the fly (eg camCreate, createUnit) and have them join in the fight.

Now if only I could find 30 minutes from work to do this !  :(



roni

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:melee attack
« Reply #12 on: 19 Mar 2005, 01:21:31 »
isnt 5 meters a little far, I couldnt imagine even the best karate master, killing sombody from like 17 feet away.

sounds like a good idea though

Offline Roni

  • Members
  • *
  • Play the Game !
Re:melee attack
« Reply #13 on: 19 Mar 2005, 01:43:56 »
The script actually has a slight lag in it between the start of the swing animation and the resolution of the attack which kind of lines up with the time taken for the animation to complete.  In some cases a target will walk in to effective range before the resolution step is determined and get hit, in others he can step back and avoid being hit.

I have been tweeking the numbers though but have always found that a mismatch between swing range and effective range makes the swinger harder to judge - ie "is this an effective swing (should I block?) or should I just stand here and step in for my own swing once he's fully committed ?"  This takes practice and adds to the skill of the melee.

FWIW.



roni

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:melee attack
« Reply #14 on: 20 Mar 2005, 03:39:48 »
maby u should try set dammage like .5 or somthing, its unlikely that one hit with a rifle will kill somebody

Offline Roni

  • Members
  • *
  • Play the Game !
Re:melee attack
« Reply #15 on: 20 Mar 2005, 06:30:40 »
I just threw the script together a few weeks ago and haven't really gone back to it.  When I left it the damage routine was simply

_target setDamage ((getdammage _target) + (random 1))


I agree that this is way to simplistic - I was going to create a "damage" rating for each weapon (fist, knife, riflebutt) and plug that in to the current "random 1" bit.

Give me a few days . . .



roni


Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:melee attack
« Reply #16 on: 27 Mar 2005, 08:09:48 »
well actualy i was talking to the other guy

Quote
Here's my (basic) solution for a melee attack :

The player's name is CM.
In his init field I put : this addAction ["Hit with rifle butt","Sg.sqs"]

And here's my script (Sg.sqs) :

CM action ["strokegun"]

if (CM distance Enemy1 <=3) then {Enemy1 setDamage 1}
if (CM distance Enemy2 <=3) then {Enemy2 setDamage 1}
if (CM distance Enemy3 <=3) then {Enemy3 setDamage 1}
if (CM distance Enemy4 <=3) then {Enemy4 setDamage 1}
if (CM distance Enemy5 <=3) then {Enemy5 setDamage 1}
if (CM distance Enemy6 <=3) then {Enemy6 setDamage 1}
if (CM distance Enemy7 <=3) then {Enemy7 setDamage 1}
if (CM distance Enemy8 <=3) then {Enemy8 setDamage 1}
if (CM distance Enemy9 <=3) then {Enemy9 setDamage 1}
if (CM distance Enemy10 <=3) then {Enemy10 setDamage 1}
if (CM distance Enemy11 <=3) then {Enemy11 setDamage 1}
if (CM distance Enemy12 <=3) then {Enemy12 setDamage 1}
if (CM distance Enemy13 <=3) then {Enemy13 setDamage 1}
if (CM distance Enemy14 <=3) then {Enemy14 setDamage 1}
if (CM distance Enemy15 <=3) then {Enemy15 setDamage 1}
if (CM distance Enemy16 <=3) then {Enemy16 setDamage 1}
if (CM distance Enemy17 <=3) then {Enemy17 setDamage 1}
if (CM distance Enemy18 <=3) then {Enemy18 setDamage 1}
if (CM distance Enemy19 <=3) then {Enemy19 setDamage 1}
if (CM distance Enemy20 <=3) then {Enemy20 setDamage 1}
if (CM distance Enemy21 <=3) then {Enemy21 setDamage 1}
if (CM distance Enemy22 <=3) then {Enemy22 setDamage 1}
if (CM distance Enemy23 <=3) then {Enemy23 setDamage 1}
if (CM distance Enemy24 <=3) then {Enemy24 setDamage 1}
if (CM distance Enemy25 <=3) then {Enemy25 setDamage 1}
if (CM distance Enemy26 <=3) then {Enemy26 setDamage 1}
if (CM distance Enemy27 <=3) then {Enemy27 setDamage 1}

exit


but ok sounds good, id like to beta test for ya

Offline Roni

  • Members
  • *
  • Play the Game !
Re:melee attack
« Reply #17 on: 28 Mar 2005, 06:53:53 »
I'm still working on the sample mission.  There should be no need to name each enemy unit, at the moment I'm working with an East Present trigger to get all East units, then assuming that your target is simply the nearest guy in this list (obtained via  short loop).

I'll post the sample mision when it's finished - I'm aiming for 24-30 unarmed loons with clubs (ie, empty rifles) vs 3-4 stalwart companions with shotguns and ball and their own version of the "club enemy senseless" script.

"Men of Harlech, march to glory,
Victory is hov'ring o'er ye . . ."



roni

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:melee attack
« Reply #18 on: 01 Apr 2005, 04:16:21 »
well, plz hurry, it sounds good.

bdfy1

  • Guest
Re:melee attack
« Reply #19 on: 13 Apr 2005, 13:26:25 »
Have you seen  UKF mod ? Even  its AI units can use bayonets. I depack it  and maybe you'll see a little tiny addon (of course real authors will be mentioned )
but it's not perfect: it looks pretty lubberly when they hit lying enemies without even touching them...
« Last Edit: 13 Apr 2005, 13:29:18 by bdfy1 »

TC

  • Guest
Re:melee attack
« Reply #20 on: 23 Nov 2005, 22:54:44 »
Is there no way to simply get the ai to use the strokefist weapons?