Home   Help Search Login Register  

Author Topic: Set distance for an action.  (Read 894 times)

0 Members and 1 Guest are viewing this topic.

Offline Morglor9

  • Members
  • *
Set distance for an action.
« on: 16 Apr 2005, 23:12:25 »
i am adding an action to search a desk to find the codepaper for Blanco's beta Codepad dialog. i was wondering how to change the distance for the action, because, (as anyone whose ever added an action before would know) actions that are added usually have a range of about 10-15m.

anyone know how to do this?
Cymbaline

Offline Blanco

  • Former Staff
  • ****
Re:Set distance for an action.
« Reply #1 on: 17 Apr 2005, 00:30:36 »
Yes, you can change the distance of the action but it requires a script with a loop. That is what I've used for the planholder in my timebomb script. (modified for your desk-example)

In the init of your desk : [this] exec "thisscript.sqs"

thisscript.sqs
Code: [Select]
_unit = _this select 0
_checkarray = []
_radius = 5

#loop
?!codefound && player == vehicle player && player distance _unit < _radius && !(_unit in _checkarray): act = _unit addaction ["Search desk","codefound.sqs"]; _checkarray = _checkarray + [_unit]
?!codefound && player == vehicle player && (player distance _unit) > _radius && (_unit in _checkarray): _unit removeaction act;_checkarray = _checkarray - [_unit]
~1
?codefound == 1 OR !alive player : exit
goto "loop"

codefound.sqs
Code: [Select]
(_this select 0) removeaction (_this select 2)
(_this select 1) switchmove  "combattoputdown"
~2
codefound = true
hint "You have found a code"
exit

Not tested!
« Last Edit: 17 Apr 2005, 00:43:05 by Blanco »
Search or search or search before you ask.