Home   Help Search Login Register  

Author Topic: Identifying players ai units in a script  (Read 1932 times)

0 Members and 1 Guest are viewing this topic.

Mr.Pibb

  • Guest
Identifying players ai units in a script
« on: 27 Jan 2005, 23:55:34 »

 Hi

 I got a script that runs for each player and does a series of checks for each player. I would like to include these checks for ai units of each player also, but I dont know what command is used to identify a players ai units, I have only read that a players ai units are local to his machine.

 Is there a script command or method to identify a players ai units in a script that runs on each players computer?

 Thanks

 Pibb

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Identifying players ai units in a script
« Reply #1 on: 28 Jan 2005, 00:58:26 »
?!(local Player): exit

the above line will exit the script if it is not on a players machine

or if its a line in a globally run script and the unitname is W1 try

?(local  W1) && (W1 != Player): do whatever
« Last Edit: 28 Jan 2005, 01:03:52 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #2 on: 28 Jan 2005, 05:40:35 »
 Ok, Dont mind all the junk here, what I need to know is then in the areas where 'player' is referenced, will it reference the players ai to 'player' also? As you can see the part you have typed was already in the script, its not a Global script, so would this entire script run properly for a players ai?(using 'player' as a reference to the players ai)



Code: [Select]
?!(local player):exit
_center = _this select 0
_radius = _this select 1
_town = _this select 2
_Grudge = false

#checkIn
_driver = false
_gunner = false
_commander = false
_cargo = false
#loop
_RatingChange = 0
?player distance _center <= _radius:goto "checkFriendlyKills"
~2
goto "loop"

#checkFriendlyKills
?(player == shooterplayer):shooterplayer = objNull
?_Grudge:goto "LowRating"
_EntryRating = rating player
#CheckRatingDrop
?rating player != _EntryRating:_RatingChange = (_EntryRating - (rating player))
?rating player < _EntryRating:_Grudge = true;goto "AssignGlobalToPlayer"
?player distance _center > _radius:goto "CheckIn"
~2
goto "CheckRatingDrop"

#LowRating
?(player == shooterplayer): hint format ["%1  has been referenced in Townsqs", shooterplayer];_RatingChange = (_EntryRating - (rating player));player addrating _RatingChange;_Grudge = false;shooterplayer = objNull;goto "checkFriendlyKills"
player addrating -100000
#WhileIn
?rating player != (_EntryRating - _RatingChange):_RatingChange = (_EntryRating - (rating player))
?player distance _center > _radius:player addrating _RatingChange;goto "vehicleBugFix"
~2
goto "WhileIn"

#vehicleBugFix
?(player == shooterplayer): hint format ["%1  has been referenced in Townsqs", shooterplayer]
?vehicle player == player:goto "checkin"
_vehicle = vehicle player
?player == driver _vehicle:_driver = true;goto "reassign"
?player == gunner _vehicle:_gunner = true;goto "reassign"
?player == commander _vehicle:_commander = true;goto "reassign"
_cargo = true

#reassign
player setpos getpos _vehicle
?_driver:player assignasdriver _vehicle;player moveindriver _vehicle;goto "checkin"
?_gunner:player assignasgunner _vehicle;player moveingunner _vehicle;goto "checkin"
?_commander:player assignascommander _vehicle;player moveincommander _vehicle;goto "checkin"
?_cargo:player assignascargo _vehicle;player moveincargo _vehicle;goto "checkin"
goto "checkin"

#AssignGlobalToPlayer
?_town == (clantown0 select 0):clantown0 = clantown0 + [player];hint format ["stupid thing finally works"]
?_town == (clantown2 select 0):clantown2 = clantown2 + [player]
?_town == (clantown3 select 0):clantown3 = clantown3 + [player]
?_town == (clantown4 select 0):clantown4 = clantown4 + [player]
?_town == (clantown5 select 0):clantown5 = clantown5 + [player]
?_town == (clantown6 select 0):clantown6 = clantown6 + [player]
?_town == (clantown8 select 0):clantown8  = clantown8 + [player]
?_town == (clantown9 select 0):clantown9  = clantown9 + [player]
?_town == (clantown10 select 0):clantown10  = clantown10 + [player]
?_town == (clantown11 select 0):clantown11  = clantown11 + [player]
?_town == (clantown13 select 0):clantown13  = clantown13 + [player]
?_town == (clantown14 select 0):clantown14  = clantown14 + [player]
?_town == (clantown16 select 0):clantown16  = clantown16 + [player]
?_town == (clantown18 select 0):clantown18  = clantown18 + [player]
?_town == (clantown19 select 0):clantown19  = clantown19 + [player]
?player in clantown0: hint format ["global assigned"]
goto "LowRating"
 


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Identifying players ai units in a script
« Reply #3 on: 28 Jan 2005, 19:57:55 »
? !(local  Player): exit
This as you are aware, will end the script if it is run on a machine that hasn't got a real human player, eg a dedicated server

If the script then goes on to state

?(local  W1) && (W1 != Player): W1 do whatever

what it's actually saying is

If unit W1 is local to this machine
and
unit W1 is not a player
then
W1 do something

it will only run a command on W1 if it isnt the player but is an ai unit controlled by the player
« Last Edit: 28 Jan 2005, 19:58:58 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #4 on: 29 Jan 2005, 02:12:15 »
 Ok, I understand completely now. So you are implying that each actual unit name must be used to reference that ai unit, there is no way of just generally checking if the unit that the script is running on is merely an ai, rather then having to figure out how to have 20 different unit names for each player in the script(which would be too much for it anyhow).

 Thanks Terox

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #5 on: 29 Jan 2005, 17:28:20 »
 Heres another question, suppose I do add the second line to the script, which it seems according to Terox I need the exact name of  the ai units, is there a way I can make a reference at ALL the ai units under the players, with a variable? Therefore I only would need to check on that reference, and if the script then does checks and adds actions for that reference it would only apply to the ai unit the that activated the script(not all of the ai units in the reference)

 Pibb
« Last Edit: 29 Jan 2005, 17:29:20 by Mr.Pibb »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Identifying players ai units in a script
« Reply #6 on: 29 Jan 2005, 20:07:48 »
if the ai's are in groups, then instead of checking each individual ai, you can issue commands to each ai in a group
?(Player in group _this):{_x Setdammage 1} forEach Group _this

or you could create arrays for each group

eg
group1array = [w1,w2,w3,w4,w5,w6]
group2array = [w7,w8,w9,w10,w11,w12]

?(Player in group1array):{_x Setdammage 1} forEach group1array
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #7 on: 29 Jan 2005, 21:44:41 »
 Thanks Terox,

 I am just realizing something here, in the script I provided, as it is it WILL run on a players computer IF its an ai unit for that player(and if its the player too), - therefore - all the references currently are 'player' for doing checks and whatnot, what if instead of having 'player', changing that to a command that will just reference the unit that the script is running on? :) Now I am not sure what command that would be, would it be 'thislist'?

 I will try some variations, but if the 'player' commands in the script can be changed to just referencing the unit the script is running on, this may do the trick in one simple change over.

 Look forward to hearing on this

 Pibb
« Last Edit: 29 Jan 2005, 21:45:43 by Mr.Pibb »

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #8 on: 30 Jan 2005, 00:33:50 »
 Well I have but exausted every means of getting this to work, here is a simplified modification that although is the only modification that brings up no errors still does not function at all on any unit (the previous version did function with 'player')





Code: [Select]
?!(local player):exit
_center = _this select 0
_radius = _this select 1
_town = _this select 2
_unit = _this select 3
_Grudge = false

#checkIn
_RatingChange = 0
?"_x distance _center <= _radius" count thislist > 0:goto "checkFriendlyKills"
~2
goto "checkIn"

#checkFriendlyKills
?_Grudge:goto "LowRating"
"_EntryRating = rating _x" foreach thislist
#CheckRatingDrop
?"rating _x != _EntryRating" count thislist > 0:_RatingChange = (_EntryRating - ("rating _x" foreach thislist))
?"rating _x < _EntryRating" count thislist > 0:_Grudge = true; goto "LowRating"
?"_x distance _center > _radius" count thislist > 0:goto "CheckIn"
~2
goto "CheckRatingDrop"

#LowRating
"_x addrating -100000" foreach thislist
#WhileIn
?_x distance _center > _radius:_x addrating _RatingChange; goto "checkIn"
?_x player != (_EntryRating - _RatingChange):_RatingChange = (_EntryRating - (_x player))
~2
goto "WhileIn"  


you can see I tried to use count thislist and foreach thislist in the beginning of the script lines, and it wouldnt respond. The rest beyond that is irrelevant, I hadnt finished converting the _x references, but nonetheless I cant find a way to reference who the script is running for in one general command ???

 Pibb
« Last Edit: 30 Jan 2005, 00:47:50 by Mr.Pibb »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Identifying players ai units in a script
« Reply #9 on: 01 Feb 2005, 16:37:40 »
"_x addrating -100000" foreach thislist

shouldnt that be
{_x addrating -100000} foreach thislist

anything within speech marks is seen as a string

there are quite a few lines in your code that does this.

Maybe you should simply explain what you are actually trying to do m8
and then we can rebuild everything from scratch
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #10 on: 03 Feb 2005, 03:25:36 »
 Thanks terox for the response

 There is no need tho to rebuild everything from scratch buddy ;), the first script I posted works perfectly :), but it only works on each player, it does NOT work on players ai.

 The script runs off of a gamelogic, to put it simply, it checks if a player within the indicated radius of the gamelogic has lost rating, therefore it will remember that player and will then turn the player into renegade status(by dropping his rating to -100000) and every time he returns to the gamelogic area it will drop his rating, and will return the players rating to normal when he leaves the gamelogic area. This is all for freindly town areas in the mission, so that the townies of each town will hold a 'grudge' against a player that commits a hostile act in their town. As I said, this all works great.

 OK. Now the problem: Players can use their ai to 'cheat' and commit kills in the towns without any consequences.
 
 Solution? : Easiest solution is to not allow ai in freindly towns, worst solution tho.
                   Best solution is to get the script to work on both players and their ai.

 And thats what I have been attempting to do. Was attempting to change the command 'player' in the script to something that would not only reference the player but players ai also. But as I think about it now, I dont know if the gamelogics will even activate on any unit other than players anyhow, but I do know that a players ai are local to his machine, so the inital ?!(local player):exit should exit unless the unit the script is running on is local to the player.

 You indicated that I improperly inputed the new attempted change to the 'player' commands and should be:{_x addrating -100000} foreach thislist (and similiar commands), so, then should the new commands:?"_x distance _center <= _radius" count thislist > 0 and similiar be :?{_x distance _center <= _radius} count this list > 0  ?

 I can make the changes and test the results (will be a lil while to test, am in the middle of working schedule right now)

 Thanks

Christian

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Identifying players ai units in a script
« Reply #11 on: 03 Feb 2005, 18:05:51 »
Ok from what i understand, you want to penalise the player if an ai in his group kills civilians in a certain location or if the player does likewise
(I assume the Player is always a group leader, otherise he wouldnt have control of the ai)

so all you actually need to find out is
1) Is the renegade a player
or
2) Is the renegade ai in the players group,

and if so punish the player



Quote
?!(local Player): exit
_unit = _this select 3
?(group player != group _unit):exit

//anything after the BLUE line will be run, if either the _unit is in the same group as the player or the _unit is the player

Overall your script can be dramatically reduced
and a more efficient way would be to use either
kill or hit eventhandlers on the town civilian units
and if required run the distance commands between the shooter and the victim with the eventhandler attached, hence no need for triggers
« Last Edit: 03 Feb 2005, 18:28:39 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Mr.Pibb

  • Guest
Re:Identifying players ai units in a script
« Reply #12 on: 04 Feb 2005, 01:28:24 »
 Thanks Terox

 Looks good, what you got there will prolly do the trick.

 The only thing about using the event handlers is that there is like 11 towns where each town has its own gamelogic that runs for each player, and there will be anywheres from like 15 to 40 resistance and civies in the towns, thats ALOT of event handlers. Although I have been informed that event handlers do not cause lag, regardless of how many, so its a possibility, but thats alot of scripting. Interesting tho. The script was actually initially written by Triggerhappy, and I altered it some afterwards, my abilities in scripting are not so great at this time.

 Thanks for the help, guess I'll solve this.

 Pibb