Home   Help Search Login Register  

Author Topic: Beating A victim  (Read 1138 times)

0 Members and 1 Guest are viewing this topic.

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Beating A victim
« on: 10 Feb 2004, 13:57:03 »
im tryin 2 make a script that beats a victim for my GTA: Everon campaign.

im trying 2 use nearestObject in my script to define the target you are attacking

ive got da rest of the script, but what is the type for a man in OFP?

"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Beating A victim
« Reply #1 on: 10 Feb 2004, 16:22:27 »
"Man"
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Beating A victim
« Reply #2 on: 11 Feb 2004, 08:30:15 »
Nah, the type you need for "nearestobject" will depend on the unit. For example, if it is a default west soldier, it would be "soldierWB". A default east soldier will be "soldierEB". Don't use nearestobject. Use a trigger (covering the whole map, activated by east or west present, depending on enemy side), and put "enemyArray = thisList". Now you have an array called "enemyArray" that contains every enemy on the map, and you can use that in your script. Sorry for no specifics, but I'm kinda tired now  :P
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Beating A victim
« Reply #3 on: 11 Feb 2004, 13:55:46 »
how do i use the array?

im not very good with arrays, never really lernd 'bout em :-\

but 2 not use nearestObject maks sense cause id hav 2 mak a script for each class...



"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Beating A victim
« Reply #4 on: 11 Feb 2004, 14:00:19 »
Quick and dirty guide to arrays.
Plenty of reviewed ArmA missions for you to play

Offline Marvin

  • Members
  • *
  • One day they will come
Re:Beating A victim
« Reply #5 on: 11 Feb 2004, 14:05:24 »
_count = count units enemyarray
_who = 0

#lop
?(enemyarray select _who == "soldierwb") : dosomething


_who = _who + 1
?(_who ==  _count) : goto "out"
goto "lop"

#out
exit





something like that?

also if you want that the person is close to you you can use
?(enemyarray select _who distance player < 6) : dosomething
« Last Edit: 11 Feb 2004, 14:07:15 by Marvin »
Is there any games than Flashpoint?

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Beating A victim
« Reply #6 on: 12 Feb 2004, 09:04:25 »
Here's a function I wrote to basically do what you want. You pass it an array of units, and it returns an array of all units within the specified number of meters to a center unit. The instructions are at the top of the code. If you don't know how to use functions, don't be afraid of them! They are quite easy to use: check out the introduction to functions here:
http://www.ofpec.com/editors/funcref.php

findUnits.sqf

Code: [Select]
/*findUnits.sqf
By General Barron
aw_barron@hotmail.com
11/15/03

This script returns an array of all units within a specified distance
of another unit that are in the passed array. The result is sorted
in acsending order of distance to the calling unit. Will never return the
unit originally passed to the function. To call:

[unit, range, [unit array]] call findUnits

Usage example: make a trigger, covering entire map, activation = once, "east present". On activation = "east_units = thisList"
Make another trigger. Condition = "count ([player, 50, east_units] call findUnits) > 0". On activation = "hint "the enemy is near" "
The hint will appear once the player comes within 50 meters of an east unit.
*/

private ["_unit", "_range", "_list", "_found", "_numArray","_j","_k","_tempVal","_tempNum","_element"];

_unit = _this select 0;
_range = _this select 1;
_list = _this select 2;
_found = [];

{if (_x distance _unit <= _range && _x != _unit) then {_found = _found + [_x]}} foreach _list;

/*-----------------------------------------------------------------------------------
Start bubble sort (sort units from closest to farthest)
Code taken from sortBubble.sqf
By bn880 2/24/2003
(slightly modified to fit in this function)
-----------------------------------------------------------------------------------*/

_count = count _found;
_numArray = [];
_numArray resize _count;

// ACQUIRE NUMERIC VALUES FROM EVALUATION
_j = 0;
while {_j < _count} do
{
   _element = _found select _j;
   _numArray set [_j,_element distance _unit];
   _j = _j + 1;
};

_j = 0;
// SORT
while {_j < _count -1} do
{
   _k = _j + 1;
   while {_k < _count} do
   {
      if (_numArray select _j > _numArray select _k) then
      {
         _tempNum = _numArray select _j;
         _numArray set [_j,(_numArray select _k)];
         _numArray set [_k,_tempNum];
         
         _tempVal = _found select _j;
         _found set [_j,(_found select _k)];
         _found set [_k,_tempVal];
      };
      _k = _k + 1;
   };
   _j = _j + 1;
};

_found
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Beating A victim
« Reply #7 on: 12 Feb 2004, 13:57:18 »
well, thanx for tryn G.B., but ive only got ver. 1.46

never did get arround 2 gettin OFPR
someone else migh wanna use it though...

cheers :cheers:

Tyger
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Beating A victim
« Reply #8 on: 12 Feb 2004, 22:20:26 »
1st off, GET OFPR!!!! It makes ofp five times as great, and opens up a world of addons and missions. It is WELL worth the 20 bucks or so.  ;D

Even with v1.46, you can still get by. Here is a simplified way to do it. Place this line of code where you need to find a unit to beat:

Code: [Select]
{if (_x distance _unit <= _range && _x != _unit) then {_found = _found + [_x]}} foreach _list
Make _range something small like 4 meters or so. The other parameters are explained in the big long code I posted. This will give you an array that holds all units from _list that are 5 meters from _unit. Then just get the first guy in that array, with _found select 0. If there is only one guy near you, that will always return that guy. If there is more than one within 4 meters or whatever, you'll basically be striking a random guy out of that group in range.

It would be possible to convert the whole function into v1.46 and plop it into your script, but for now that should work. It also would be possible to do things like check if the target is in front of the player, so he can't hit guys behind him. All of this would be easier to do with OFP:R and functions, but it is still possible in 1.46  :)
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!