Home   Help Search Login Register  

Author Topic: Getdir  (Read 1821 times)

0 Members and 1 Guest are viewing this topic.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Getdir
« on: 04 Oct 2003, 16:48:34 »
OK. I understand this command rating:

0/10

Totally blank.

I'm trying to make this arrest script, including morale, wounds, ammo, sneakiness(pick up weapon again). I know how to all this, except one thing: How the **** do I check where the player is facing so he won't capture a guy he doesn't know about! Can any1 make a small tute about getdir and submit it to ed depot or something? Or some1 could teach me how to use getdir and I could write the tute. That would be great!

:beat: *Gets Shot* :beat:

KyleSarnik

  • Guest
Re:Getdir
« Reply #1 on: 04 Oct 2003, 17:24:05 »
Armstrong, getdir works just like getpos, for example: (getdir unit1)

You can also use setdir to set the direction of a unit but it seems that you only need getdir. Well just like I said you can use getdir just like getpos and pretty much anything with "get" infront of it works the same way.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Getdir
« Reply #2 on: 04 Oct 2003, 17:30:51 »
How exactly? How would I check if a unit is, say from -15 to +15 in front of a placer? :-*

:beat: *Gets Shot* :beat:

KyleSarnik

  • Guest
Re:Getdir
« Reply #3 on: 04 Oct 2003, 18:02:16 »
hmm lol I was hoping you would figure it out.... You see I use "get" command to get a number, I use them only with "set" comands, unless its getdammage, but still I dont know armstrong.....

Oskar

  • Guest
Re:Getdir
« Reply #4 on: 04 Oct 2003, 22:37:18 »
getdir unit1 = direction
setpos unit2 direction

or

setpos unit2 getpos unit1

it was along time ago i was around in the scripting community.. but im trying to make my comeback ;)
« Last Edit: 04 Oct 2003, 22:37:31 by Oskar »

KyleSarnik

  • Guest
Re:Getdir
« Reply #5 on: 04 Oct 2003, 22:54:03 »
Hmmm how does getdir affect setpos?? And shouldn't it be unit2 setpos? Or setdir?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Getdir
« Reply #6 on: 05 Oct 2003, 23:38:32 »
Don't quite follow ... what do you mean "-15 to +15m" in front of the player?

Well anyway .... to check on the distance you need the command distance.    Which you probably know anyway.

If you care that the loon is in front of the player that's a little more difficult.

1)  You have to define the moment very carefully.   The player can turn a 360 in a couple of seconds so when the loon is in front of the player is very important.

2)  How to discover which way the player is facing?   This is the easy part, just use the command getDir.   You don't need a tute, it does exactly what it says on the tin.   It returns a number between 0 and 360, which is the bearing in degrees that the object is facing.   North is 0 (or 360, they are the same), East is 90, South is 180, West is 270, etc..

3)  What tolerance will you allow?    5 degrees?   10 degrees either side?  Doesn't really matter, but you will have to decide.

4)   The final part is to discover the bearing from the player to the loon.   Once you know it you have to compare it to the bearing the player is facing and also add in your distance and tolerance.    But how do you discover the bearing?

The answer my friend is trigonometry.    If you are not familar with this simple and useful branch of mathematics then a little homework will be required.      I'm not going to give the exact answer here because it has already been well covered by Sui (I think) who is our resident expert on this question, which comes up every few months.    Have a good search of the forums, it's there.    I seem to remember that there is some trig at the end of the unofficial command ref as well.


Having said all that, you should also check out the command knowsabout which might solve the problem in a more elegant manner.
« Last Edit: 05 Oct 2003, 23:40:40 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Getdir
« Reply #7 on: 06 Oct 2003, 09:23:22 »
just check da function library 4 ma function (or even check all da direction funcs der :P) i think its wat u need ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Getdir
« Reply #8 on: 06 Oct 2003, 18:24:23 »
Cheers guys, I'll check your hints out.

:beat: *Gets Shot* :beat:

EDIT: LCD's function is exactly what I'm lookin for, I'll use this along with knowsabout and distance.
Thanks guys!

:beat: *Gets Shot* :beat:
« Last Edit: 06 Oct 2003, 18:31:39 by The real Armstrong »

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Getdir
« Reply #9 on: 06 Oct 2003, 18:49:57 »
OK, this is my first time using a function so be kind OK? :P :-*

Code: [Select]
_badman = _this select 0

_angle = [AP, _badman] call AngleFacingDiff

#startover

_badman setcaptive false

_morale = random 100 + 30
_morale2 = 0

#loop
~0.000001
? _angle > 30.0001 : goto "loop"
? _angle < 30 : goto "cont"
hint "Error! Error! How the fuck did this happen, ya punk?!"
#cont
; Morale Negative
? handshit _badman : goto "handsup"
_damage = getdammage _badman
_damage = _damage * 30
_morale = _morale - _damage
; Morale Boosts
_damagep = getdammage player
_damagep = _damagep * 2
_morale = _morale + _damage
? _morale < 1 : goto "handsup"
~5
goto "loop"

#handsup
_badman switchmove "FXWomanSur"
_badman setcaptive true
_morale2 = _morale2 + (player distance _badman)
? _morale2 > 1000 : goto "startover"
~5
goto "handsup"

I keep gettin the error message. What am I doing wrong?
« Last Edit: 06 Oct 2003, 19:40:09 by The real Armstrong »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Getdir
« Reply #10 on: 07 Oct 2003, 00:25:12 »
use da hint 2 check wat it _angle nd post ur mision here so i can look :P

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Getdir
« Reply #11 on: 07 Oct 2003, 07:46:14 »
It's NPD Deluxe Ed ;D . I'll post it here after school, I only have 10 mins then I have to go.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Getdir
« Reply #12 on: 07 Oct 2003, 18:29:29 »
EDIT:
http://upl.mine.nu/uplfolders/upload8/NPD.noe.zip
There it is. Any1 see what's wrong with it?
« Last Edit: 08 Oct 2003, 18:41:26 by The real Armstrong »

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Getdir
« Reply #13 on: 08 Oct 2003, 21:33:41 »
WTF is this?! :wow:

I just discovered, that if I removed my "testguy" the script worked fine on the ones that actually should be affected by it... WTF? :P

#Locked

:beat: *Gets Shot* :beat:

EDIT: Oh maen... new prob... ::)

At least now I don't get the error message but the script won't continue to #handsup

Code: [Select]
_badman = _this select 0

_angle = [player, _badman] call AngleFacingDiff

#startover

_badman setcaptive false

_morale = random 100 + 30
_morale2 = 0

#loop
~0.000001
? _angle > 60.0001 : goto "loop"
? _angle < 60 : goto "cont"
hint "Error! Error! How the fuck did this happen, ya punk?!"
#cont
; Morale Negative
? handshit _badman > 0.1 : goto "handsup"
_damage = getdammage _badman
_damage = _damage * 3
_morale = _morale - _damage
; Morale Boosts
_damagep = getdammage player
_damagep = _damagep * 5
_morale = _morale + _damage
? _morale < 1 : goto "handsup"
~1
goto "loop"

#handsup
removeallweapons _badman
_badman switchmove "FXWomanSur"
_badman setcaptive true
_morale2 = _morale2 + (player distance _badman)
? _morale2 > 1000 : goto "startover"
~5
goto "handsup"

:beat: *Gets Shot* :beat:
« Last Edit: 08 Oct 2003, 21:49:27 by The real Armstrong »

Gameer_77

  • Guest
Re:Getdir
« Reply #14 on: 09 Oct 2003, 22:10:25 »
You need to learn how to debug Armsty.

Stick a hint around each line where the error is appearing (What is the error btw?) and put a hint before you goto "handshit" to see if it really is going to handshit.

Gameer