Home   Help Search Login Register  

Author Topic: Playing Possum  (Read 2314 times)

0 Members and 1 Guest are viewing this topic.

Javito

  • Guest
Playing Possum
« on: 15 Aug 2006, 04:06:21 »
Here's what I want to do. I have an option for the player to play dead if all else is lost and he's about to be killed. So what I want is for the game to check that he A) Drops his gun, B) Goes prone, and C) Does not move and if he meets those 3 requirements then the game will setcaptive true. I'm thinking that you need to create a #loop  of some sorts to check that his speed is less than .001, make sure he's prone, and is unarmed but I get pretty foggy on the possible syntax for that (new to scripting still). Then as soon as the player grabs his gun, stands up or crouches, or moves he will be setcaptive false (and better he'd better hope the enemy is no longer in the area). Could someone help me out?

Offline Razorwings18

  • Contributing Member
  • **
  • I'm NOT a llama. I checked.
Re: Playing Possum
« Reply #1 on: 15 Aug 2006, 08:13:07 »
here's a better idea.

Make three script files in your mission folder with the following code:

INIT.SQS
Code: [Select]
;add "PLAY DEAD" to your action menu
deadaction = player addAction ["Play dead", "playdead.sqs"]

PLAYDEAD.SQS
Code: [Select]
;MAKE PLAYER CAPTIVE
player setcaptive true

;SET PLAYER IN "DEAD" POSITION
player switchmove "CombatDead"

;REMOVE ACTION "PLAY DEAD". (_this select 2) IS THE ID ASSIGNED TO THE ACTION,
;IT'S PASSED TO THIS SCRIPT WHEN IT'S CALLED FROM THE ACTION MENU
player removeAction (_this select 2)

;ADD ACTION "STOP PLAYING DEAD" TO YOUR ACTION MENU
deadAction = player addAction ["Stop playing dead", "playalive.sqs"]

PLAYALIVE.SQS
Code: [Select]
;SET PLAYER TO NO LONGER BE CAPTIVE
player setCaptive false

;CLEAR THE DEAD POSITION
player switchmove ""

;REMOVE ACTION "STOP PLAYING DEAD"
player removeAction (_this select 2)

;ADD ACTION "PLAY DEAD"
player addAction ["Play dead", "playdead.sqs"]

Enjoy.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Playing Possum
« Reply #2 on: 15 Aug 2006, 09:06:10 »
Quote
A) Drops his gun, B) Goes prone, and C) Does not move
To answer your questions:
A) and C) are possible:
The condition would be something like:
((primaryWeapon player = "") and (speed player < 0.1))
Syntax not guaranteed

B) Is impossible I'm afraid.  There is no sensible way to find out if the player (or any other unit is prone)

I have not tested Razorwings suggestion but in principle it is very neat.  It gives the player an action (bottom right menu) that makes the player go to the required state.  You would need to modify it to get the player to drop his weapon and you should probably test to see if the player moves while playing dead, but it is a good start.

Javito

  • Guest
Re: Playing Possum
« Reply #3 on: 15 Aug 2006, 09:28:07 »
Really?! There's no way to check if a posture is set to "down"? That's just... shocking.  ??? There's no condition that if the player hits the z button he is instantly setcaptive to false and blown away? That's bizarre. Guess I got used to you being able to do -everything- in this game :-). Since that's the case I suppose I'll have to go with Razorwing's great suggestion. It would be pretty silly for the player to be "playing dead" but be perfectly able to stand upright.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: Playing Possum
« Reply #4 on: 15 Aug 2006, 10:44:56 »
It's bizarre but true.     There are lots of strange gaps like this in the OFP scripting language.   The reason is simply a matter of history.   

When the game was originally created it shipped with a mission editor.   It was unusual, even unique, in that the mission editor was very powerful.   Within a very short space of time the community was able to examine and edit the original BIS missions, with BIS's tacit agreement.   However, the mission editor and associated scripting language had been created specifically to make Cold War Crisis.    If the programmers wanted a command to make that original campaign, they created it.   However, not thinking that anybody much would make use of this scirpting language or mission editor, they did not set out to create a comprehensive scripting language.   

Over the years and versions of OFP some of the more critical "missing" commands and some entirely new commands were created.   BIS quite deliberately did not attempt to make the scripting langauge comprehensive - they preferred to spend their time on VBS, OFP Elite, ArmA and the unnamed future game.    I haven't studied the list of ArmA scripting commands, and I know it hasn't been finalised yet, but it it is much longer than the OFP list and I suspect it will be more or less comprehensive in the sense that if you can make a unit do something, either human or AI, then you can also check whether he has done it.
Plenty of reviewed ArmA missions for you to play

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: Playing Possum
« Reply #5 on: 15 Aug 2006, 11:54:39 »
I remember reading something in these forums not so long ago (darn cannot find it right now) about somebody trying to check a units position (prone, up...) using a camerascript?
Maybe someonelse can dig up that topic?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Playing Possum
« Reply #6 on: 15 Aug 2006, 12:16:10 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Playing Possum
« Reply #7 on: 15 Aug 2006, 13:08:01 »
Quote
There's no condition that if the player hits the z button he is instantly setcaptive to false and blown away?
There are many ways to skin a cat.  I have a mission where the player has to stand still for a period of time otherwise he gets shot.  I did that using the speed command.  I noticed during testing that if I was prone and I stood up I got shot.

Razorwings suggestion will put the player into a prone position, maybe you just need to monitor his speed thereafter.

Offline Kyle

  • Members
  • *
Re: Playing Possum
« Reply #8 on: 15 Aug 2006, 16:08:21 »
i have a sort of off-the-topic question here, but anyways, is the speed function just finding the "moving forward" value of the velocity function?  Or is it actually finding a different value completely?

Javito

  • Guest
Re: Playing Possum
« Reply #9 on: 15 Aug 2006, 18:03:43 »
Quote
There's no condition that if the player hits the z button he is instantly setcaptive to false and blown away?
There are many ways to skin a cat.  I have a mission where the player has to stand still for a period of time otherwise he gets shot.  I did that using the speed command.  I noticed during testing that if I was prone and I stood up I got shot.

Razorwings suggestion will put the player into a prone position, maybe you just need to monitor his speed thereafter.


According to the thread on Bedges' link, there are actual speed values for changng your position. --0.147613 for moving from a prone to standing position, so if you have (speed unit)== 0 then this variable will become false and you will be detected. In theory at least. My question to you is how you acccomplished it because I have a parameter checking if the unit's speed is less than 0 in this case (but I've also tested if it was greater than 0) and it has not worked at all. As far as I can tell the trigger will only activate if you move -forward- (and the < 0 trigger will only activate if you move backwards) and the position of the unit has no bearing on its speed.

Yet that contradicts both your finding and -several- results in the other thread. So what's the deal?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Playing Possum
« Reply #10 on: 15 Aug 2006, 18:54:23 »
Kyle:  I have not tested this, I have not needed to.  I assumed (always dangerous) that speed returned the scalar value of the velocity vector.  In other words it should always be >=0 and have no defined direction.  But the post on the end of bedges link shows that speed is negative when going from prone to standing.

Javito:  It may be my memory then.  I was testing the mission some time ago and I didn't care if the player was sitting lying or standing on his head so long as he was not moving.  I may have got shot once when going prone, instead of the other way around.  On your other point I don't see a negative value for speed as representing a backwards movement, rather I see it as a 'feature' of OFP that provides a neat solution to your problem.  I would do a few tests though if I were you - what is speed when standing up while crawling forwards/backwards/sideways etc.

Bye the way as speed is a real number not an integer I would avoid using ==0.  This test could fail simply because of the inherent inaccuracy of real arithmetic.  I would use something like:

((speed player < -0.05) or (speed player > 0.05))

Javito

  • Guest
Re: Playing Possum
« Reply #11 on: 15 Aug 2006, 19:56:13 »
I've done some testing, here are the results.

The speed values for going prone or standing do exist and you -can- use them as a check what position a unit is in. So that's very useful information for all to know.

The catch is that they only seem to work with vanilla OFP units. As they speculated in the other thread, once the mod teams begin altering the animations then all bets are off. I have successfully tested this with vanilla OFP and FDFMod... FFUR and Liberation 1941 do not work. I might go over to the Lib '41 thread on the BIS forums and ask if there may be a work around. Unfortunately, Lib '41 is what I'm working with.

It's odd though because the only reason (and please correct me if I'm wrong) that I can think of for it not to work in those two mods is if they set speed to 0 when a unit stands or goes prone. Which leaves another test for me to do, just don't know the syntax. How can I enter into a script to check if a unit's speed is anything BUT 0?



EDIT - Nevermind question, figured it out on my own (should try that more often  ;) ). I am happy to announce.... SCORE!. Successful checking of a unit's position has been made with Liberation '41 and FFUR. The speed values were altered with the new animations and apparently they're very very small (less than .005) but -not- 0, hence it is perfectly possible to check if a unit in a prone position stands up or visa versa.

Since I'm going to be working with Liberation '41 a lot, I'd like to try and find out the exact speed these actions take place at. Dmakatra did it in the other thread with vanilla OFP so there must be a way.
« Last Edit: 15 Aug 2006, 20:01:15 by Javito1986 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Playing Possum
« Reply #12 on: 15 Aug 2006, 21:41:31 »
Yes testing is the best way to solve tricky problems. 

Quote
hence it is perfectly possible to check if a unit in a prone position stands up or visa versa.
Note sure of this.  I think you have found a way to detect a transition from one state to another, providing the unit is not moving at the time.  Or have I misunderstood? 

To check if something is not = 0 use

not (something == 0)

but do you really want to do that with speed.  As I have mentioned this is a real value not an integer

EDIT:

Just noticed this: 

http://www.ofpec.com/forum/index.php?topic=27808.0
« Last Edit: 15 Aug 2006, 22:16:52 by THobson »

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: Playing Possum
« Reply #13 on: 15 Aug 2006, 22:35:19 »
EDIT:

Just noticed this: 

http://www.ofpec.com/forum/index.php?topic=27808.0

Sorry Bedges, Thobson wins the Hi-Fi Stereo here; that's the one I was talking about  :D