OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Seven on 10 Jun 2006, 20:41:06
-
Hi,
I'm working on a little fun CTF where none should be able to camp.
I had in mind that when someone is standing still for more then 10 sec AND doesn't fire his gun, he simply gets blown up.
Dunno how to do this really.
I tried a few things with getpos and then compare it with the command distance but none worked out.
Could somebody help me with this?
Thx 8)
-
_unit = _this select 0
_oldx = 0
_oldy = 0
#loop
_x = getpos _unit select 0
_y = getpos _unit select 1
~10
? (sqrt (((_x-_oldx)^2)+(_y-_oldy)^2) <= 10) : goto "boom"
_oldx = _x
_oldy = _y
goto "loop"
#boom
"shell73" camcreate (getpos _unit)
exit
something like that. Just a quick thingy before I go watch more footy... ;D Probably won't work, but shouldn't take much work getting it to work. But you should, IMO, let the guy stay at one position more than 10 seconds...
Oh, and I forgot to put in the check to see if he's fireing or not...but I can't remember any quick solution to that anyway :-\
-
Thx Garcia that worked fine :)
Maybe to check if one fires I could check the ammo that unit has & compare whether it changes?
-
Wouldn't work, except if the guy shot a whole mag :-\ You can only count the amount of mags a unit got, not the amount of bullets. The only solution I can think of ATM (and I can't think much, just got up) is using a fired eventhandler, but that'll be a crappy solution. It will cause more problems than this script is worth, since you'll need a fired EH on every unit at all times :-\ Though, else than a fired EH I can't think of any other way to check if a unit is fireing :-\
-
rgr thx alot anyway :)
It didn't work indeed...
I'll just take it up to 15 seconds instead :)
I also have another prob: I put panels against both sides of a bridge that's over a canyon; had to setpos their hights to get it done but I was very plzed my efforts showed a nice result. I did that in order units not being able to shoot from besides the bridge at possible flagrunner on that bridge. Now problem is that when you shoot on such a panel, it just flies away :s
Tried the same with big containers but the result is the same.
So I tried this
~1
_panel = _this select 0
_x = getpos _panel select 0
_y = getpos _panel select 1
_z = getpos _panel select 2
#loop
? (getdammage _panel > 0) : goto "put"
~1
goto "loop"
#put
_panel setdammage 0
_panel setpos [(_x),(_y),(_z)]
goto "loop"
I don't get any errors but it just wont work :s
the panels are not being put back on the same spot they were.
Anybody got ideas come to the rescue ::)
-
the only thing i could imagine is, it wont work because you putted the coordinates in brackets
[(_x),(_y),(_z)]
imo it should look like this
[_x, _y, _z]
theoretically your version should work also, but i heard OFP can sometimes be very pitty with brackets.
and there's another tweaking possibility for your script. No error by your side just a few lines saved.
the
_x = getpos _panel select 0
_y = getpos _panel select 1
_z = getpos _panel select 2
you can siply replace with
_pos = getpos _panel
since this will give you a complete array with x, y and z coordinates
therefore the
_panel setpos [(_x),(_y),(_z)]
simply replace with
_panel setpos _pos
maybe it helps
:edit:
might be i found something...dunno but try it
imo there's a missing = there:
? (getdammage _panel > 0) : goto "put"
shouldn't it be
? (getdammage _panel >= 0.1) : goto "put"
-
the only thing i could imagine is, it wont work because you putted the coordinates in brackets
[(_x),(_y),(_z)]
imo it should look like this
[_x, _y, _z]
theoretically your version should work also, but i heard OFP can sometimes be very pitty with brackets.
afaik it shouldn't be a problem. When I script I usually add a lot of brackets to make sure the it all goes right, and I've never had problems with it. Though, you don't really need brackets there...
:edit:
might be i found something...dunno but try it
imo there's a missing = there:
? (getdammage _panel > 0) : goto "put"
shouldn't it be
? (getdammage _panel >= 0.1) : goto "put"
Not really...
? (getdammage _panel > 0) : goto "put"
That line checks if the damage is more than 0, and if it is the script goes to "put".
? (getdammage _panel >= 0.1) : goto "put"
While this line checks if the damage is equal or more than 0.1, and if it is, it goes to "put".
Only thing I can think of that's wrong is that either the panels simply doesn't get damaged enough, or the script isn't executed at all :-\
-
Oh great to see replies here I already gave up on it :s
Although I tried tonight picking it back up by trying to add a hit eventhandler which didn't work.
So I'll try some of this tomorrow myke & come back at you.
got a question: can you also check for dammage like
? (getdammage _panel >= 0.01) : goto "put"
I understand that might be a problem the panel not taking enough dammage for the script to execute
Any shot fired on it should have the panel taking dammage I figure
edit:
Well I tried without the braces; no luck... :-\
This is really buggy stuff :s
Tried this:
~1
_panel = _this select 0
_x = getpos _panel select 0
_y = getpos _panel select 1
_z = getpos _panel select 2
#loop
? (getdammage _panel > 0) : goto "put"
~1
goto "loop"
#put
_panel setdammage 0
_panel setpos [_x,_y,_z]
goto "loop"
-
The panel should take damage when shot at, but it may be that the panel doesn't take enough damage for the game to notice. Try shooting the panel with a LAW... :P
Though, to check if the script do notice the damage by the bullet you can add a hint like this:
~1
_panel = _this select 0
_x = getpos _panel select 0
_y = getpos _panel select 1
_z = getpos _panel select 2
#loop
? (getdammage _panel > 0) : goto "put"
~1
goto "loop"
#put
hint "mwahahahahah"
_panel setdammage 0
_panel setpos [_x,_y,_z]
goto "loop"
So, what you should do is first use that script and see if you get that hint when you shoot a bullet on the panel. If you don't get the hint, try shooting it with a LAW.
-
ok, i got this version of the script which works, at least it worked with my editor placed radio.
_object = _this select 0
_pos = getpos _object
_dir = getdir _object
#loop
? (getdammage _object) > 0: goto "putback"
~1
goto "loop"
#putback
_object setvelocity [0, 0, 0]
~2
_object setdammage 0
_object setpos _pos
_object setdir _dir
goto "loop"
there were 2 problems i encountered:
if you setpos a object which is actually moving, a setpos command will not stop it's movement. you have to setvelocity it to 0
and second, once a object flies away, it also changes it's heading. so u have to use getdir and setdir it back to it's initial heading.
and last problem i encountered, depending on weapon used (i say LAW or other explosives), if you setpos it too early back to its pos, there might be an "explosion in progress" which will dammage the panel again.
So you have to play around with the wait lines i inserted, but this now should basically work now
-
hm thought that was good thinking Mike but again no luck ???
I'll PM you a link where you can download this & look at it if you feel like like it; it needs BAS addons (tonali1)
Cheers