Home   Help Search Login Register  

Author Topic: Wire Cutting Script  (Read 1287 times)

0 Members and 1 Guest are viewing this topic.

Offline Pathy

  • Former Staff
  • ****
  • I'm not a F***in llama!
    • Volcbat.
Wire Cutting Script
« on: 26 Jun 2005, 02:59:12 »
Hi guys.

I dont have a single ounce of scripting knowledge, therefore, seeking some help.

What i want to do is give a unit the ability to take down wire fences with a "Use Bolt Cutters" or whatever action.

This is for a co-op im making so i also need MP compatable. At one point in this mission you will have to cross a border, which i will fence off on either side with standard BI wire fencing.

So, i was wondering if it would be possible to detect when a unit is next to a fence section and give them the option to "cut" it, which would result in the section being destroyed. The thing is, i could easily do this for a specific section but i want it to be doable for any bit of the border the player deems best to cross.

One thing that springs to mind is: The border will be in straight bits. Therefore, i could add a thin trigger that runs along the fence, and when a specific unit is in that trigger, he gets the action menu option. Then using a getnearest thingy whatever it is, i could surely destroy the nearest bit of fencing? I see 1 problem in that if he destroys the fencing infront of him, the option to destroy others, even if hes not next to them, will be there.....

....so....would it be possible to make this action a one time thing only?

If anyone would be willing to help me write this, or give me the impression that im writing it while giving me subtle nudges in the right direction constantly then iÂ'd be very grateful.

Thanks.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Wire Cutting Script
« Reply #1 on: 26 Jun 2005, 08:18:46 »
if you have any specific questions about scripting, this is the board to post on.

if you're looking for someone to do the work for you, this belongs in the recruitment lounge.

if you want an action to be activated only once, name your triggers. when the action is activated, within the script that is called use 'deletvehicle trigger_name' to get rid of all fence triggers, and 'player removeaction action_name' to get rid of the wirecutters. not sure if that is MP compatible.

otherwise the idea is sound, using nearestobject.

good luck ;)

Offline Pathy

  • Former Staff
  • ****
  • I'm not a F***in llama!
    • Volcbat.
Re:Wire Cutting Script
« Reply #2 on: 26 Jun 2005, 19:45:17 »
Thanks, no im not looking for someone to do this for me, i was just asking if maybe someone could help someone who doesnt know that much about scripting language write it for himself, giving him nudges in the right direction  :) But this was just an afterthought after my main post.

The main purpose of this thread was to sound out that idea and see if anyone has any ideas on how better to do it.

If you think the idea of using triggers with a nearestobject command is sound then i guess iÂ'll try it that way  :)

Thanks for the help on making it a one time only action.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Wire Cutting Script
« Reply #3 on: 02 Jul 2005, 00:50:41 »
an idea, untested (i don't have ofp anymore)

place triggers over the fences (only the fences, anything else and it won't work. also they can't overlap AT ALL)

trigger condition: true
activation: "_x addaction ["Cut the fence!","wirecut.sqs"]" foreach thislist

and the script would just be a simple delete script:
deletevehicle _this select 0

it may not work though, like i said i don't have ofp on my comp anymore, and haven't been around for a long time.

Offline Blanco

  • Former Staff
  • ****
Re:Wire Cutting Script
« Reply #4 on: 02 Jul 2005, 03:24:53 »
Quote
The main purpose of this thread was to sound out that idea and see if anyone has any ideas on how better to do it.

If you don't mind to use editorupgrade102...
Instead of deleting the fences, replace it with a torned version of the fence  

The actions part of your story is an another problem...
I was working on the same idea actually :)
Your trigger methode should work, but it could be a lot of work I guess
I did some tests with lots of repeatable triggers and I was surprised how less lag ot causes. Another idea was to to add the cut-actions only when they are needed : when the player is close, but I don't think that's MP compatible.
Right now OFP is not installed, sometimes that happens, I'll give it a try when I'm in again.

The nearestbuilding or nearestobject methode would be even better but I was never good in that command.
Can it detect  the presence of a certain type of object within a 50m radius?


« Last Edit: 02 Jul 2005, 03:33:57 by Blanco »
Search or search or search before you ask.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Wire Cutting Script
« Reply #5 on: 02 Jul 2005, 10:02:52 »
Dont use a trigger, its a waste of cpu power

Best to  have a slow looping script, say every 5 seconds, which runs on the player, this would check to see how many objects are within X range of the player of a specific type and then , if he hasn't already got an action attached to him, add one

alternatively, if he has an action but is more than X distance away from any objects, it removes the action.

Something like
1) See how many objects are close enough to the player to be able to cut
2) then if he hasn't already got an action, give him one (tx_Noactions control this)
3) If there are no fence objects close enough to him, then remove any action he may have and tell the script he hasnt got asny actions (tx_Noactions control this)

If you try and remove an action from a unit that doesnt have the action, it will not generate an error


NB>>> to get the classname of the fence type you want, simply do the following
name one of the fence sections "fence1"

and run a simple debug line to find out
hint format ["Object  classname = \n\n %1", _obj]


the system below will simply use the object class of the fence you named "fence1"

INIT.sqs
[] exec "loop.sqs"


LOOP.sqs
Quote
~2
_obj = [typeof fence1]
tx_Noactions = true

#START
~ 4 + (random 1)
if(((nearestobject [Player,_obj]) distance <3) &&( tx_Noactions)) then{tx_Cut = Player addaction ["Cut Fence section","Cut.sqs"];tx_Noactions = false}else{tx_Noactions = true;Player removeaction tx_Cut}
goto "START"


CUT.sqs
Quote
_obj = nearestobject [Player, (typeof Fence1)
hint "Cutting fence"
~3
deletevehicle _obj
;; or do a createvehicle at getpos _obj for the broken fence section
;; or try a  _obj setdammage 1... that may cause the fence to fall flat to the floor

exit

I havent roadtested the script, however if you have a problem, it will be in the following statement

((nearestobject [Player,_obj]) distance <3)
« Last Edit: 02 Jul 2005, 10:08:56 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Wire Cutting Script
« Reply #6 on: 02 Jul 2005, 10:09:41 »
m'kay. take a look at the attached missionette. you'll need general barron's editorupdate.

what it does is this:

it runs a fairly fast loop to find the nearestobject of the type of fence you want, in this case the one with a 'ripped' counterpart ;) it then measures the distance to that object, and if it's less than 2 meters, it adds the wirecutting action to the player. if the distance gets more than 3 meters, it takes the action away.

the action calls a script which, as blanco suggested, replaces the fence in question with a torn one. you may have to play about with the height setting. it's fine for normal terrain detail, but may screw up on other settings, dunno. it then removes the wire cut action.

hope it helps :)

edit - beaten to it - great minds think alike, terox ;)
« Last Edit: 02 Jul 2005, 10:13:37 by bedges »

Offline Blanco

  • Former Staff
  • ****
Re:Wire Cutting Script
« Reply #7 on: 02 Jul 2005, 11:26:44 »
Quite nice both of you :)

One question... you are using a bolean as condition, can't you use isnull _fence instead, because you remove _fence anyway when you click the action.
 
Search or search or search before you ask.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Wire Cutting Script
« Reply #8 on: 03 Jul 2005, 11:58:02 »
the boolean stops an additional action from being added if you have more than 1 fence within the search area, which is possible, eg where two sections join


If you want the system to work with ai in a players control as well as the player himself, eg send an ai forward and order him via its action command menu), then instead of using a boolean to see if the unit has an action attached, you would place the unit in an array and then use the
If (_unit in _array)then........


reason, boolean is global to any local unit on a clients machine, whereas placing the individual unit in an array, is a local control only to the unit
« Last Edit: 03 Jul 2005, 11:58:45 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Pathy

  • Former Staff
  • ****
  • I'm not a F***in llama!
    • Volcbat.
Re:Wire Cutting Script
« Reply #9 on: 10 Jul 2005, 00:01:54 »
Thanks very much for the help guys much appreciated.  ;)