Home   Help Search Login Register  

Author Topic: Sabotagescript (experimental)  (Read 2180 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
Sabotagescript (experimental)
« on: 22 Jul 2005, 12:33:23 »
Some time ago I've made a script to flatten a tire of a vehicle instantly by camcreating bullets at tire's position until canmove = false.
Next step I tried is was adding an action to each tire so the player can click it to flatten each separate tire. I create 4 gamelogics exactly under the tire, to get these positions I've used the Relposcoord function, Relposcoord.sqf  returns the real coordinates (height is not taken into account) of a relative position to an object (on the principle of the camsetrelpos command).
Problem is that the tire positions are different for each vehicle, so I had to make a database based on the typeof command with the right values for each vehicle   :-\
Right now it supports just the jeep, only for a test.

You can click the action to flatten a tire, but when 1 is flat all other actions are removed because I don't have a condition to determine which tire is flat.

The main problem is that I can't make it userfriendly because I can't pass variables through an addaction script. A variable I need is the vehicle, but the actions are attached to the gamelogics under the wheels instead of the vehicle itself, how can I pass that variable in my addaction scripts?

Anyway the script works, but it's experimental, I dunno how I can make it userfriendlier, but maybe someone else is interesting to improve it.
Maybe you can use it in a special ops mission to immobilise enemy cars without firing like the little testmission below (no addons needed)
 
« Last Edit: 22 Jul 2005, 12:37:29 by Blanco »
Search or search or search before you ask.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Sabotagescript (experimental)
« Reply #1 on: 22 Jul 2005, 13:41:25 »
do the gamelogics follow the vehicle? if so, an action will return which gl it's attached to, thus telling you which tyre is which.

Quote
Params passed by an action to the executed script:
[(object action was attached to),(unit that activated action),(index of action)]

Offline Blanco

  • Former Staff
  • ****
Re:Sabotagescript (experimental)
« Reply #2 on: 22 Jul 2005, 20:32:34 »
No, the gamelogics don't follow the vehicle, but they should, it was not nessecary in the testmission.
You can sabotage the vehicle only when it's standing still, so I only have to setpos them on the right spots when speed is 0.

Quote
if so, an action will return which gl it's attached to, thus telling you which tyre is which.

The gl's are not atached to the vehicle, they are setpossed under the wheels. The action return for _this select 0 is the gl, not the vehicle.

The reason I can't know which wire is flatten lays somewhere else...

Code: [Select]
_this select 1 switchmove "combattoputdown"
~1

#loop
?!canmove car :exit
_bullet = "bullet12_7" camcreate getpos (_this select 0)
~0.001
goto "loop"

This is the script to flatten the tire. Bullets are created at gl's position (the tire) until car can't move.
I've used  !canmove car:exit to do that but this means that the other actionsscripts will exit immediate when I click it because that condition was already met when I clicked the first action. See what I mean?
Also I had to type the vehicle's name in the script because I can't pass the variabe through an adaction script.
Maybe I can do something with the nearestobject; the closest vehicle to the gl must be the car, no? :P
Or I can check the GL's dammage to know which tire is flattened, but I don't think thats reliable...


















 

« Last Edit: 22 Jul 2005, 21:55:34 by Blanco »
Search or search or search before you ask.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Sabotagescript (experimental)
« Reply #3 on: 22 Jul 2005, 21:01:48 »
hmmmm... tricksy. so you have four gls, 'front_l', 'front_r', 'rear_l' and 'rear_r'. an action added to each gl. so you know which tyre is flattened, no?

only other suggestion would be to have the loop condition after the bullet, so

Code: [Select]
#loop
_bullet = "bullet12_7" camcreate getpos (_this select 0)
~0.001
_bullet = "bullet12_7" camcreate getpos (_this select 0)
~0.001
_bullet = "bullet12_7" camcreate getpos (_this select 0)
~0.001

? canmove car : goto "loop"

that way at least a few bullets are created before the script exits...
« Last Edit: 22 Jul 2005, 21:02:08 by bedges »

UNN

  • Guest
Re:Sabotagescript (experimental)
« Reply #4 on: 23 Jul 2005, 03:59:44 »
When you create the logics, add them to a global array.

Code: [Select]
VEHICLE_LOGICSARRAY=VEHICLE_LOGICSARRAY+[[_Vehicle,[_Logic1,_Logic2,_Logic3,_Logic4,]]]
Then when an action is called, look for the logic that launched the action and return it's position in the array (the wheel number) and the vehicle assigned to it:

Code: [Select]
_Logic=_This Select 0

_Index=-1
_Counter=0
_vehicle=ObjNull


{If (_Logic In (_x Select 1)) Then {_vehicle=_x Select 0 ; {If (_Logic==_x) Then {_Index=_Counter} ; _Counter=_Counter+1} ForEach (_x Select 1)}} ForEach VEHICLE_LOGICSARRAY

Hint Format ["Vehicle %1 Wheel Num %2",_Vehicle,_Index]

Offline Blanco

  • Former Staff
  • ****
Re:Sabotagescript (experimental)
« Reply #5 on: 23 Jul 2005, 04:44:37 »
Damn, thats a great piece of code :D  

That way I can track the vehicle and tires, downside is that you'll need a new globalarray for each vehicle. But it's experimental anyway and I've learned something today.   :)
The vehicle prob is solved, thx

to quote myself...

Quote
I've used  !canmove car:exit to do that but this means that the other actionsscripts will exit immediate when I click it because that condition was already met when I clicked the first action. See what I mean?

I don't think I can solve that, I can count the flattened tires now but the !canmove command is the real cause.
.








« Last Edit: 23 Jul 2005, 05:32:53 by Blanco »
Search or search or search before you ask.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Sabotagescript (experimental)
« Reply #6 on: 23 Jul 2005, 05:30:19 »
Quote
downside is that you'll need a new globalarray for each vehicle.

nope, look at the code again, each vehicle gets its own array inside the global array

Offline Blanco

  • Former Staff
  • ****
Re:Sabotagescript (experimental)
« Reply #7 on: 23 Jul 2005, 18:43:08 »
Really? I don't get it.
Does this work when I put a second vehicle in the global array?

Code: [Select]
_Logic In (_x Select 1)) Then {_vehicle=_x Select 0...
..for the second vehicle that should be :

Code: [Select]
_logic in (_x select 3) then {_vehicle = _x select 2...
No?

« Last Edit: 23 Jul 2005, 18:44:02 by Blanco »
Search or search or search before you ask.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Sabotagescript (experimental)
« Reply #8 on: 24 Jul 2005, 01:39:44 »
if you are talking about something like the foreach command or something like that... it would be just the first line of code over and over again no matter what

for example, lets say this is your array:
[[v1,[v1_l1,v1_l2,v1_l3,v1_l4]],[v2,[v2_l1,v2_l2,v2_l3,v2_l4]],[v3,[v3_l1,v3_l2,v3_l3,v3_l4]]]

"?_logic in (_x select 1):_vehicle = _x select 0" foreach global_array

_x would take place of each of the main arrays inside the array