Home   Help Search Login Register  

Author Topic: Distance from object in MP  (Read 2047 times)

0 Members and 1 Guest are viewing this topic.

GavinP

  • Guest
Distance from object in MP
« on: 29 Sep 2006, 23:49:53 »
Hi, not really sure about MP scripting of triggers. I've a trigger set up to monitor when a vehicle gets within 15 of the player, and it then camcreates a shell125 at the vehicles position provided the driver is still alive. If the driver is dead obviously the player is safe from teh explosion, but to make things more realistic i've put an additional trigger monitoring when the player gets within 4 of the vehicle to allow "disable of bomb". These work perfectly well in SP but do I need to do anything in MP? I don't want a shell per player within 15 for example. I will have a named group for the playable positions, and each will be individually named also so can I use some sort of array? ???

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Distance from object in MP
« Reply #1 on: 30 Sep 2006, 05:20:43 »
Easy solution. In your bomb trigger Condition use count  for your distance check and add a switch variable.
Code: [Select]
({(BoomBus distance _x) < 15} count units myGroup) > 0 and alive driver BoomBus and not GoBoomand in its OnActivation
Code: [Select]
GoBoom = TRUE ; publicVariable "GoBoom"
Another trigger. Condition:
Code: [Select]
GoBoomand in its OnActivation
Code: [Select]
"SHELL125" createVehicle (getPos BoomBus)
Instead of camCreate use createVehicle to make your shell.  The trigger should then only fire once on the machine of the first player who gets too close.  Since the shell is createVehicled it will be created once on all machines.

Similarly, in your trigger to disable the bomb in Condition:
Code: [Select]
({(BoomBus distance _x) < 4} count units myGroup) > 0 and not alive driver BoomBus and not GoBoomand in its OnActivation
Code: [Select]
BoomDisabled = TRUE ; publicVariable "BoomDisabled"
One more trigger. Condition:
Code: [Select]
BoomDisabledand in its OnActivation
Code: [Select]
hint "Bomb disabled"

I may have dropped a bracket or two...
« Last Edit: 30 Sep 2006, 05:44:39 by Mr.Peanut »
urp!

GavinP

  • Guest
Re: Distance from object in MP
« Reply #2 on: 30 Sep 2006, 23:20:28 »
Thanks for that. I have one question though. How does the addaction bit work in terms of MP. Obviously you've changed my "player" for the count units Mygroup method, but that won't work for the addaction, removeaction bits will it?

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Distance from object in MP
« Reply #3 on: 01 Oct 2006, 14:44:43 »
You want an action to appear when the unit is within 4m of the bomb bus?
In the second trigger where it currently says:
Code: [Select]
BoomDisabled = TRUE ; publicVariable "BoomDisabled"try putting the following
Code: [Select]
disarmaction = player addaction ["Disarm Bomb","disarm.sqs"
Then in disarm.sqs put the following:

Code: [Select]
player removeaction "disarmaction"
~0.5
;maybe replace this with some sort of disarm looking animation using playmove..
~0.5
BoomDisabled = TRUE
publicVariable "BoomDisabled"
exit

Can someone else check what I put out? Ive only just woken up >:(

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Distance from object in MP
« Reply #4 on: 01 Oct 2006, 17:26:15 »
Okay, I thought you wanted the truck to disarm automatically once the players got near...

Jason O is almost correct, except for removing the action. There is also one other problem.  Once a player is gets an addaction it will stick with him until the truck is disarmed, no matter where he is. A better solution is to add the action to the truck.

Trigger to disable the bomb in Condition:
Code: [Select]
({(BoomBus distance _x) < 4} count units myGroup) > 0 and not alive driver BoomBus and not GoBoom and not BoomDisabledIn OnActivation:
Code: [Select]
truck addaction ["Disarm Bomb","disarm.sqs"]
addAction, I recently learned myself, (see the comments in the comref) passes its own ID to the script it calls. So:

disarm.sqs
Code: [Select]
_truck = _this select 0
_actionid = _this select 2
_truck removeaction _actionid
; move the next 2 lines to the top so that no one else gets the "Defuse Bomb" action.
BoomDisabled = TRUE
publicVariable "BoomDisabled"
;must use switchmove for all players to see anim in MP
;maybe replace this with some sort of disarm looking animation using switchmove..
exit

For completeness add this to the Init for the truck (I am assuming the players are WEST):
Code: [Select]
this addEventHandler["GETIN", {_this exec "boombuscheck.sqs"}]
boombuscheck.sqs
Code: [Select]
_truck = _this select 0
_unit = _this select 2
if (side _unit == WEST) then {if (not BoomDisabled) then {GoBoom = TRUE ; publicVariable "GoBoom"} else {_truck removeEventHandler "GETIN"}}
exit

Now the truck will blow up if the players get in before disarming it. I gotta run so I don't have a chance to double check. Check this space again later for possible edits...
« Last Edit: 05 Oct 2006, 04:39:50 by Mr.Peanut »
urp!

GavinP

  • Guest
Re: Distance from object in MP
« Reply #5 on: 04 Oct 2006, 22:41:02 »
Thanks for that Mr Peanut. I have one further question. Would it be possible to change the activation from group w1 to any west unit? I'm thniking along the lines of count units side== "west"?

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Distance from object in MP
« Reply #6 on: 05 Oct 2006, 04:38:52 »
I don't understand your question. What do you want to change?
urp!

GavinP

  • Guest
Re: Distance from object in MP
« Reply #7 on: 05 Oct 2006, 22:00:42 »
Sorry. At present the boombus as you put it  :clap: explodes when within a given distance of a unit from west group W1. What i want it to do is go boom when it gets within a given distance from any west unit. (My mission has changed itself, and i now need more than 1 west unit)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Distance from object in MP
« Reply #8 on: 06 Oct 2006, 02:43:29 »
Okay,
In your init.sqs you need to make an array of all west units you want to include.
Code: [Select]
westUnitArray = [w1,w2,w3,w4,w5...]
Then everywhere in the code I've given you replace:
Code: [Select]
units myGroupwith:
Code: [Select]
westUnitArray
I have only thought of one hitch.... if the bus drives near a dead west soldier, it is still going to blow up. IF this is a possible problem then replace:
Code: [Select]
({(BoomBus distance _x) < 15} count westUnitArray) > 0with
Code: [Select]
({(BoomBus distance _x) < 15 and alive _x} count westUnitArray) > 0Make this change also for the less then 4 metres check.

urp!