Home   Help Search Login Register  

Author Topic: No camping allowed  (Read 2637 times)

0 Members and 1 Guest are viewing this topic.

Offline Seven

  • Members
  • *
  • Am I a llama?
No camping allowed
« 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)

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: No camping allowed
« Reply #1 on: 10 Jun 2006, 20:54:03 »
Code: [Select]
_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 :-\

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: No camping allowed
« Reply #2 on: 11 Jun 2006, 03:50:36 »
Thx Garcia that worked fine :)
Maybe to check if one fires I could check the ammo that unit has & compare whether it changes?

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: No camping allowed
« Reply #3 on: 11 Jun 2006, 14:24:52 »
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 :-\

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: No camping allowed
« Reply #4 on: 11 Jun 2006, 14:52:46 »
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

Code: [Select]
~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  ::)

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: No camping allowed
« Reply #5 on: 20 Jun 2006, 21:14:46 »
the only thing i could imagine is, it wont work because you putted the coordinates in brackets

Code: [Select]
[(_x),(_y),(_z)]

imo it should look like this

Code: [Select]
[_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
Code: [Select]
_x = getpos _panel select 0
_y = getpos _panel select 1
_z = getpos _panel select 2
you can siply replace with
Code: [Select]
_pos = getpos _panel
since this will give you a complete array with x, y and z coordinates

therefore the
Code: [Select]
_panel setpos [(_x),(_y),(_z)]
simply replace with
Code: [Select]
_panel setpos _pos

maybe it helps


:edit:

might be i found something...dunno but try it

imo there's a missing = there:
Code: [Select]
? (getdammage _panel > 0) : goto "put"

shouldn't it be
Code: [Select]
? (getdammage _panel >= 0.1) : goto "put"
« Last Edit: 20 Jun 2006, 21:32:09 by myke13021 »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: No camping allowed
« Reply #6 on: 20 Jun 2006, 23:03:45 »
the only thing i could imagine is, it wont work because you putted the coordinates in brackets

Code: [Select]
[(_x),(_y),(_z)]

imo it should look like this

Code: [Select]
[_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...

Quote
:edit:

might be i found something...dunno but try it

imo there's a missing = there:
Code: [Select]
? (getdammage _panel > 0) : goto "put"

shouldn't it be
Code: [Select]
? (getdammage _panel >= 0.1) : goto "put"

Not really...

Code: [Select]
? (getdammage _panel > 0) : goto "put"
That line checks if the damage is more than 0, and if it is the script goes to "put".

Code: [Select]
? (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 :-\

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: No camping allowed
« Reply #7 on: 21 Jun 2006, 01:54:51 »
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:
Quote
~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"
« Last Edit: 21 Jun 2006, 02:05:09 by Seven »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: No camping allowed
« Reply #8 on: 21 Jun 2006, 16:15:34 »
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:

Code: [Select]
~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.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: No camping allowed
« Reply #9 on: 21 Jun 2006, 19:02:09 »
ok, i got this version of the script which works, at least it worked with my editor placed radio.

Code: [Select]
_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

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: No camping allowed
« Reply #10 on: 22 Jun 2006, 01:36:08 »
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