Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2014-05-31 06:25        
     
Hello all, I've been trying to get a trigger to follow a group of soldiers. The trigger I have currently follows the soldier I select initially but if he is killed, the trigger will remain with his body.

Currently my code is "Trigger 1 attachTo [Soldier1,[0,0,0]]"

I've tried adding "if... then" and "while... else" loops to move it to the second and subsequent soldier, but that hasn't worked for me.

I'd appreciate any help.


Author Message


Posts: 317
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name: BrotherhoodOfHam

 
#2 Posted at 2014-05-31 12:31        
     
You could try something like this?

soldier_group = group soldier1;
soldier1 addEventHandler
[
	"killed",
	{
		_unit = ((units soldier_group) - [soldier1]) call BIS_fnc_selectRandom;
		detach trigger;
		trigger attachTo [_unit, [0,0,0]];
	}
];

It might help to know what you plan on doing with this trigger

Some delicious stuff:
3D marker script
Some WIP delicious stuff:
Modular Customization Interface

Advertisement


Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#3 Posted at 2014-06-01 14:44        
     
oh cool would you be able to use something like this to play music when enemy get in range of the trigger to play music when in combat i know it would need another script to call the music and only fire once on first contact then again latter so the music doesn't keep playing every a new unit steps into the trigger zone. how to do that i don't know but i would like to figure it out lol.

u could also use this to follow a certain group and let you know when they are in "danger" or in combat with an enemy force it would be good if your using High command controlling AI or player groups all over the place. you could make a hint or sidechat command to notify the players of the threat,

it would be cool if someone could figure out how to set up a script that calls out the grid of that unit automatically within the hint. i know the game does it automatically if your in the same group but if your using 4 or 5 different groups you have no idea whats going on around them till you find there bodes somewhere lol.

but thanks for posing the script BrotherHoodHam im gonna try it out and see what i can come up with. if i get something cool ill repost it


Author Message


Posts: 2
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2014-06-02 20:58        
     
Thanks for the advice Brotherhoodofham. Unfortunately I've still had trouble getting the marker to move from the dead soldier. Your code has offered some insight regardless and I'll keep tweaking it. To answer your question, I'm looking to have the objective marker follow a group of allied soldiers. They'll be stuck in an enemy city and the objective is to go in and save them before they get axed.

Shadowmarine578, yeah you can definitely set this up to play music based on enemies near you. Don't know if there is an easier way to do this and your idea hadn't occurred to me until you said it.


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 35
In-game name: Tajin

 
#5 Posted at 2014-06-03 15:46        
     
You have several options different there.

1. Always attach/move the trigger to the position of the current groupleader
2. Move the trigger to the average position in the middle of the group (problematic if the group is spread out too far)
3. The most precise solution would be to create several triggers (attach one to every groupmember) and compare them

... what exactly do you need it for?



Is the trigger supposed to allow "rescuing" them, by making them join your group when you get close enough? You could do that in a similar way with "addAction". Or you could use a scriptloop instead of a triggerarea. A script that counts the amount of players in a certain radius around the groupleader.

So instead of attaching your trigger, put this in its "condition" line:
{ isPlayer _x } count ( position (leader myGroup) nearObjects ["Man",20] ) 
Also, in the init of one of your soldiers, include this:
myGroup = group this;

That way your trigger will activate as soon as a player gets closer than 20 meters to the leader of your group. (note that the regular trigger conditions, size, shape etc don't matter anymore)

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.