OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: The-Architect on 11 Nov 2005, 05:36:45
-
How do you convert the following script so that it makes steam come from the player's breath like it's cold?
;===MIF CIGGY v0.7===;
; [unitname] exec "ciggy.sqs"
; in order to stop smoking, the units behaviour needs to be else than "safe"
; the script uses 1 sound, it's only a dummy for the unit to move his lips.
; copy the lines from the description.ext and the sound folder.
;====================;
_smoka = _this select 0
_anims = ["","FXFromKneel","FXshow2","FXshow4","","FXCivilLookaround","FXCivilLookaround2","FXCivilLookback", "FXCivilFoldOnesArms","FXCivilArmsAkimboR","FXCivilArmsAkimboL", "","FXFromHand",""]
#init
? (! alive _smoka) : exit
? (_smoka != vehicle _smoka) : goto "wait"
? (speed _smoka > 0.1) : goto "wait"
? (behaviour _smoka != "SAFE") : goto "wait"
_dur = 0
_p = 0
_vz = 0
_rdp = 0
_rdi = 0
_fsize = 0.3
_rb = 0
_smoka playMove "FXCivilHandMouth"
~3.8
#prepuff
#puff
;puff
drop ["cl_basic", "", "SpaceObject", 2.5, _dur, [(getPos _smoka select 0) - 0.1 *(sin(getDir _smoka)), (getPos _smoka select 1) - 0.1 *(cos(getDir _smoka)),(getPos _smoka select 2) + 1.58], [0.3*(sin(getDir _smoka)),0.3*(cos(getDir _smoka)),_vz], 1, 0.00574, 0.0045, _rb, [0.016,0.15,_fsize], [[1,1,1,0.01], [1,1,1,0.25], [1,1,1,0.01], [1,1,1,0]], [0,1,0,1,0,1], _rdp, _rdi, "", "", ""]
;secondary
? _p < 15 : drop ["cl_basic", "", "SpaceObject", 2.5, _dur/2, [(getPos _smoka select 0)-0.001 *(sin(getDir _smoka)), (getPos _smoka select 1)-0.001 *(cos(getDir _smoka)),(getPos _smoka select 2) + 1.58], [0.03*(sin(getDir _smoka)),0.03*(cos(getDir _smoka)),0.3+_vz], 1, 0.00578, 0.0045, _rb, [0.046,0.15,_fsize], [[1,1,1,0.01], [1,1,1,0.25], [1,1,1,0.01], [1,1,1,0]], [0,1,0,1,0,1], 5*_rdp, 5*_rdi, "", "", ""]
_p = _p + 1
~0.01
? _dur > 6 = _dur = _dur - 1
? _dur < 5.9 : _dur = _dur + 1
? _p > 2 : _fsize = _fsize + 0.03
? _p > 5 : _rb = _rb + 0.003
? _p > 10 : _vz = _vz + 0.008; _rdp = _rdp + 0.01; _rdi = _rdi + 0.0015
? _p > 20 : goto "anim"
goto "puff"
#anim
~3+(random 2)
_an = random (count _anims)
_an = _an - ( _an mod 1 )
_smoka Playmove (_anims select _an)
~6+(random 5)
_smoka playMove "FXCivilHandMouth"
~3.8
goto "init"
#wait
~1
goto "init"
#edited to sort page formatting going off the edge...
-
Does it really even need that much changing?
Other than removing the animation stuff (#anim, etc..)...
You won't be able to make that effect very good because there's no way you can detect which way the unit's face is.. well.. facing...
So the breath 'fumes' will always 'shoot' forwards even if the unit was looking as much on either side as possible...
Same goes with this cigarette smoking stuff..
-
I tried removing all the anim stuff but it didn't work. I can't script so that might have had something to do with it.
Anyone help with the conversion? The facing bit shouldn't matter I don't think. If you're looking to the side you won't see the mist going the wrong way unless you're in external view. I think It's acceptable.
-
ok i messed around with this some, this is what i got. put the pbo in your missions folder
yes its on desrit island, but lets keep this simple right?
i will work on this some more
-
Looks good on AI. It doesn't seem to work when the unit is kneeling or laying down. The mist still comes out, but from a place wheer the unit's head would be if he were standing.
A couple of questions.
How do I make it so that there is about half the mist?
How can I make it work better on the player?
-
Oh yeah, totally forgot to 'put down' this idea ;D :P ::) with another BISd OFP feature:
You can't detect the units stance so you can't have the 'breath fumes' come out of the head position automatically... :(
The original smoking script uses a fixed height which is selected according to the units stance it uses with the smoking animation..
-
i am not all the way sure how to use the drop command :P so, this is as good as it gets from me ;D, it would be very hard to make it so it comes out when he is laying down......yeah. half the mist? i have no idea...maybe fool around with the numbers here and there and watch...
-
give me a few minutes, and I think I can tweak the mist down to about half...
anyway, i read a thread (hehe, rhymes) about how to detect if a unit is standing/kneeling/prone. You find the height of the unit, and certain values of the unit's height tell you in what stance he's in or something. Anyway test it. ;)
-
drop ["cl_basic", "", "SpaceObject", 2.5, _dur, [(getPos _smoka select 0) - 0.1 *(sin(getDir _smoka)), (getPos _smoka select 1) - 0.1 *(cos(getDir _smoka)),(getPos _smoka select 2) + 1.58], [0.3*(sin(getDir _smoka)),0.3*(cos(getDir _smoka)),_vz], 1, 0.00574, 0.0045 , _rb, [0.016,0.15,_fsize] , [1,1,1,0.01], [1,1,1,0.25], [1,1,1,0.01], [1,1,1,0], [0,1,0,1,0,1], _rdp, _rdi, "", "", ""]
The two bold things are the volume and size. Try tweaking those, as well as the value for _fsize to make the smoke/breath smaller.
-
Can you check the height of the weapon he's carrying?
-
No.
Only when the unit fires...
You could make a script/addon combo to make the unit fire a dummy bullet/muzzle and check the height of that, but the drawback is that there would always be the muzzle flash which would look silly....
Dunno how .fab has done it as it seems quite clear that WWIIEC has some sort of getStance function judging from their some time ago released loading animation video...
You find the height of the unit, and certain values of the unit's height tell you in what stance he's in or something. Anyway test it.
And what exactly you mean by 'certain values of units height'?
I have tried everything I can think of, from trying to compare named selection (in the soldier model) positions and distances to various objects, to trying to use cameras etc. and nothing as produced even remotely promising results...
I would be intersted to see what you have found..
-
Ok, ive had a go msyself and have created a winter mission, with snow etc, and thought this would be perfect for extra atmosphere!
I personnally think the smoke effect like the one ECP used for their gun fire smoke would be a subtle but suitable effect. How could we use this effect?
-
I would also be in need of this kind of script...
But, the bad thing is that as far as I know you can't get the unit's stance unless it fires a weapon (which the ECP effect you mentioned relies on) so to get the 'fumes' to come out of the correct height the unit would need to fire a weapon...
-
and you say that if he "constantly fires a weapon" from his head or something, we could see a flash? i was thinking, silenced weapons dont have any muzzle flash.
-
why do you need them to fire to tell what height the gun is at?
could you not just use primaryweapon player ?
even if its on his back, it will still be at a different height than when he crouches and prones. with a little testing you could find the heighest it gets when crouching/proning and the lowest when standing/crouching, and see which range its between, could you not?
-
Won't work, primaryweapon returns the weapon as a string, and getpos requires an object. :-\
-Pilot
-
oh yeah *slaps forehead* :P
edit: or maybe it will work...
untested, but may work:
;ranges for height of the gun when standing and crouching (lowest point, so prone not needed) *these are not the correct values, only estimates*
_s = 1
_c = .4
_gun = nearestobject [player,(primaryweapon player)]
#loop
?(getpos _gun select 2) < _c:goto "prone"
?(getpos _gun select 2) < _s:goto "crouch"
;if neither default to standing
;make the cold breath stuff for standing
~3
goto "loop"
#crouch
;same thing except for crouch
#prone
;and again
yes? no? worth a try at least?
-
thats a no, just tried it and it always returns 0
-
and you say that if he "constantly fires a weapon" from his head or something, we could see a flash? i was thinking, silenced weapons dont have any muzzle flash.
Ach, long time no see in this thread.. ::)
What I mean is the light flash that is visible always when you fire a weapon (even the silenced ones)...
And yes, like some of you have 'proved' you can not detect the weapons, I don't think you can even detect a weapon that has been put down on the ground..
-
There must be some way of doing it. We are supposedly the great mind of the Flashpoint community, we must be able to fugure it out.
-
aside from camcreating bullets at different heights to see if they hit... i've got nothing
-
Well, if its a player cant you just detect how many times he has hit the z key?
cant you use the buttonsetaction comand and have it run a script that counts how many times it is pressed, so like, 0 times unit is up, 1 time the unit is down, 2 times he is up, 3 down, 4 up so on.
as for AI i dont know
-
Hmmm......buttonSetAction is for dialog buttons and active texts.
It doesn't refer to the keyboard.....I hope. ;D
Planck
-
I did some experimenting with this a couple of months back, and found out that it is very possible to detect the unit's stance. I'll just go make a small script and submit it to the ed depot. Just gonna get myself something to eat first. ;D
-
StanceDetect.sqs ........ version 1.0????
btw.....I'll have a cheese and pickle sandwich. 8)
Planck
-
Cool.
-
now about AI,
When a unit is lying down, it gives his position as somewhere in his stomach area right? as opposed to right where his feet are when he is standing.( humans are taller then they are wide, unless lyin down) this prevents his position from changing, as he goes from lying to standing.
If I am wrong then you have found the awnser::
If a units position changes when he goes from standing to lying, then just do a little test. place a unit, make sure he cant move, and just getpos him standing and hint format it and then do it again while he is lying down, and then find the distance between the 2 points, and in a script wait until a unit changes position, if he does, measure how much. you will be looking for the exact same value as in the little test. if they are equal, you will know he has changed stance.
BUT!!
if I was right, and it does change to the position in his stomach, it may be harder. I will think about it a little more.
thanks
-
won't work (and i'm sure many have tried the same thing you're talking about)
the position is the same
-
ok, I thought it would be like that. Im sure theres a way to do it using the fact that a unit is longer on the ground then when he is standing, maby just create a smoke 1/2 a meter in front of a unit and 1/5 a meter off the ground maby. it may be easier that trying to do one above him.
-
What about Armsty's solution? When we get to hear it of course.
-
i'm very interested in seeing how he succeeded where everyone else has failed so far...
-
hmm, im pretty sure he was just going to make a script for the player only, using the setbuttonaction thing that I thought of.
EDIT:
now that I look at his post again, he may be doing it for all units. and thus not using setbuttonaction :-[
-
I have had some success detecting a unit's stance by dropping an object from a height above the unit and seeing how long it takes to hit him. It's not a good long term solution to the problem, but it might be food for thought.
I thought about detecting the height of a fired bullet, but this gave misleading results if the gun was aimed up or down.
-
I think just create a steam drop at both the point where he is standing and lying. I doubt anybody would notice and why waste time?
-
That's not really good enough is it.
I want to hear what Armsty has to say. Where is he?
-
hmmm, has he already submitted it and forgot to tell us, forgot about it, or is he still eating that sandwich,
-
Makes you wonder whether he was just pulling your leg.. ;)
-
we have news from armsty!
Armsty here. I'm writing through Trigs 'cause I can't log in at the moment (I've mailed Sui). Anyway, I'm not pulling your leg. I know the answer and I've known it for a long time. The reason I haven't told anyone is 'cause I am an apathic lil' bugger. And that's a bleeding fact. Anyway, you'll have the answer within 24h. If Sui fixes my log in, that is. Now, I'm going to run off and get shot.
lets see if he pulls through
-
lol
That's why I used the ;) at the end..
To draw him out of the shadows :D
-
...Now, I'm going to run off and get shot.
We don't mind if you go get shot, just don't start eating another of those huge 1/2 year sandwiches.
-
haha..those taste good [/off topic]
-
Uh huh.........off-topic........this is bad guys.......I might have to get serious here.
Seriously we are attempting to get dmakatra back......whether this is a good thing or not is debateable.
Planck
-
First of all, I'm back. Yay. Huzzah. Go eat a cat if you'd like.
Second, as far as detecting this 'ere stance thingy it's actually very simple. It's painfully simple actually, I have no idea why no-one has ever figure it out these past five years. And not only is the method of detecting the stance very simple, there are even two ways of doing it. It's so simple that anyone can figure it out. In fact, you'll probably hate me for not saying such a simple thing these 10-12 months that I've known about it. I don't really have an excuse for that. Well, I have, but that'd mean I have to tell you my whole bloody life story (seriously) and we don't want that.
Notice how I sort of delay the whole thing by writing loads of stuff nobody cares about? This is to create tension for the big climax. Also, it makes the post looks long and that makes me look cool.
Here it comes.
The big climax that is.
The answer is the animation itself, and how it effects the unit. There are two noticable effects to the unit, hence the two different methods of detection. These are angle (getDir, doesn't work on human players) and velocity (speed). See, when a unit goes prone/crouched he is still moving in some direction and his angle is tilted slightly. What's great is that these values are consistent. Even if you go prone/crouch a hundred times, as long as you use the same animation, the speed value is going to show up exactly the same all hundred times, and the angle will tilt with the exact same value every time, wether you check the values in the start of the animation or the end of the animation.
Both methods have a slight, slight chance of failing because these exact values can be reached (however extremely, extremely unlikely) by other means. Speed is the most reliable one but if you wanna be on the safe side I'd recommend you use both.
Here's a list of the speed values with the official animations:
Standing-To-Prone: 2.26923
Crouched-To-Prone: 1.05517
Running-To-Prone: 6.64739
Crouched-To-Standing: 0.386415
Prone-To-Standing: -0.147613
Crawling-To-Standing: 4.25231
While testing these values while I wrote this I discovered that the values change while not on flat ground. Sorry to disappoint you, it came as a suprise to me as well, 'cause I had tested this on that pesky flat ground on Desert Island like loads of times. Whoa, do I feel stupid, but now at least we have something to work on. I personally haven't done some serious scripting in like a year or so (this discovery was about the last thing I did before I retired), but I am confident someone can perfect this method.
There is still one possibility that I can think about, although it's not a nice one. It's an extreme workaround. That would be to setdammage the unit while standing still (if player, during a cutscene or something) to 0.8, see if the speed value changes even slightly. If it does, the unit is either standing or crouched. Then setdammage him back to whatever.
Humm...
Guess Trigs won the bet. Do you want 'em sent via the mail or should come and collect them personally?
-
this only lets you know if you're prone or standing... what about crouched?
-
This all sounds a bit wild, like a goose chase.
i have my doubts, and il keep them to myself, but i want to see it proooven. so far it has never been done before. the question is, can you make somthing plausable out of this.
-
I have my doubts, and I will galdly post them ;D :P :
the question is, can you make somthing plausable out of this.
You really can't :(
At least not in a form a function, which would be the optimal way..
I mean, if someone has gone prone like 56 minutes ago and you want to check whether he is still prone?
No can do with this method, not with the optimal way..
And still the crouched stance would be missing...
You can easily detect if a unit goes/is going prone with this and I'm sure many have found out this in the past but realised it's not usable in any other way...
Basicly you would need a @ sqs loop, one for each stance running on one soldier, which means like 6 @ loops (9 is the crouch stance would be included) per soldier running constantly (good bye MP with this method ;) ), you do the maths when there are several groups going on the map... ;)
standing_to_prone.sqs (pseudo code)
_unit = _this select 0
#detect
call format ["%1_isProne=%2",_unit,false]
publicVariable format ["%1",(call format ["%1_isProne",_unit])]
@(speed _unit)==2.26923
~.01
call format ["%1_isProne=%2",_unit,true]
publicVariable format ["%1",(call format ["%1_isProne",_unit])]
@(speed _unit)>0
goto "detect"
-
this only lets you know if you're prone or standing... what about crouched?
That's possible, although I aborted the checking of my values while I found out that the values where not consisted on non-flat ground.
HateR_Kint: Quite. But if you can find a better way, I'm all ears. Anything is better than nothing, right? :)
-
@hater
you're taking the hard route. I worked up a beta script to get the stance using this, with only one loop per unit. the problem, however, is that in my long absence i've slipped up on my skills and i keep getting an error "|#|?(_this in _x):TRG_units = TRG_units - [_x]" foreach TRG_units: error invalid number in expression
which doesn't make much sense to me...
i've attached the test mission i'm using and you can take a look at it, maybe figure out what i screwed up... :-\
i think the problem has to do with subtracting arrays but i'm not sure...
-
And even if you do get this thing working, you will have to tell people not to use any 3rd party animation packs.
what if this whole time, there really was a get stance comand, but BIS just forgot to put it in the comref. like
stance player
-
Well there isn't. Bummer. And 3rd party anims are no problem, as we can always get the values for those as well, do a check which pack the player is using and use the corresponding loop.
That still won't solve the problem about flat surface, which is the main concern at the moment - not how the loop should be designed. ;)
-
Anything is better than nothing, right?
True..
I'm not saying that this could not be used in some way or form, I'm merely pointing out why this is not the best method.. ;)
do a check which pack the player is using and use the corresponding loop.
How are you planning to do that check ???
I have not used any anims packs so do they come with something that you can use in that checking process..?
I worked up a beta script to get the stance using this
The error is caused by the '?'..
I'm pretty sure you can't use if-then "inside" forEach..
EDIT:
you're taking the hard route.
Pseudo code being the key words.. ;)
And why use global variables instead of an array?
You can't publicVariable an array unless you do it one element at a time..
Global arrays/variables are not exactly global in MP..
Also, the forEach route can get hard if the array gets hundreds of elements big.. forEach scans the array from the start to finish element by element..
-
ECP uses particles for their ejected shell casings, and these particles come out at the correct height
You sure they don't use the "fired" eventHandler to get the bullets height (among other needed data ) to get the casing to fly out from the right spot? ;)
I tried to make a casing script once that would simulate bolt action rifle and the casing would fly out of the weapon when the rifle was 'bolted' but the main feature killer was the fact that you can't return the unit's stance and weapon direction in any other way than using the fired EH, and obviously as the 'bolting' takes time the weapon could point in some other direction and/or the player to change the stance which made the casing to fly out from a completely wrong place..
EDIT:
In the latter case, an invisible particle could be created at the player's position with zero velocity, rubbing, and nuetral buoyancy.
I mention this method in earlier posts in this thread, and it did not work...
If you drop a particle to some selection the height of the particle does not change with the unit's stance :(
And what good would creating the particle on the player's position do?
After all the position does not change with the stance..
And as ArmA will feature functions to detect stance why we even discuss this anymore :P
-
We could try creating a weak bullet at a given height where it will intersect the unit, and using the dammaged event handler to see which selection it hits.
I'll screw with it after work.
-
How I just love to be the partypooper ;D :P
A few things that are going to be an annoyance:
- You need an addon (for the bullet)
- There will be the flying sound of the bullet, the *whack* when you get hit, the red 'flash' and the random scream by the unit (tested)
- Not just one function (you need at least two different scripts, afaik) (tested)
But the most annoying thing is that it seems the bullet needs to be pretty powerful so that it actually triggers the dammaged EH (with hit=3 it takes a few shots before the EH gets triggered)...
Which means trouble as different units have different armor; civilians, different soldier AddOns..
Maybe you get better results..
-
Thought of all that. Just figured I would put the idea out there to see if someone had workarounds.
-
Yeh, I've tried that as well. And it ain't that reliable either, should you get it working. If the unit is running or strafing or something it could hit something that we didn't calculate and thus give the incorrect results. Not good.
Not the mention that you can accidentally kill the unit. Not good either.