Jump to content
Sign in to follow this  
eegore

!alive condition + array = getposATL ?

Recommended Posts

I looked through other threads about this but I am doing something wrong.

I'm creating an array of 6 armor units that when any one of them are killed it will send units towards the player.

I tried a simple Detected by OPFOR trigger but since I am using a laser designator to call in missile strikes it seems the AI doesn't recognize they are under attack.

Array in a game logic init:

aa = [aa1,aa2,aa3,aa4,aa5,aa6];

Condition in Trigger:

{alive _x} count aa == 0

Activation in Trig: (p1 is player name)

BTR1 domove getposATL p1

Nothing happens even if all 6 armor are destroyed. In order to make reinforcements move when only one unit is attacked do I change == 0 to 5?

Really all I want to happen is for AI to react when attacked. Again since its a laser designator calling in a spawned missile strike it seems they just don't care.

Is there a way to cover all OPFOR in an area similar to a detected by trigger so AI reacts when under assault that doesn't involve naming every unit and putting it into an array?

Thanks

Edited by eegore

Share this post


Link to post
Share on other sites

iam not sure how with "domove", but iam using "addWaypoint" and there the "getpos" thingi has to be in [] brackets.

Like this:

waypoint1 = BTR1 addWaypoint [position p1,0 ]; https://community.bistudio.com/wiki/addWaypoint

waypoint1 setWaypointType "something" ; https://community.bistudio.com/wiki/setWaypointType

waypoint1 setWaypointCombatMode "something"; https://community.bistudio.com/wiki/setWaypointCombatMode

waypoint1 setWaypointBehaviour "something"; https://community.bistudio.com/wiki/setWaypointBehaviour

waypoint1 setWaypointSpeed "something"; https://community.bistudio.com/wiki/setWaypointSpeed

Also mission wise and realism wise:

How could the enemy possibly find out the players location? You said yourself, that you are caling missilestrikes so they have no way to find out where you are, so sending them to your possitin upon killing one of them by airstrike doesnt make any sense.

More apropriate would be change theyr behaviour and combatmode to COMBAT and RED and send them searching the area for player, or send them to retreat, than sending them directly to player. They are BTR´s not Wizzards, they cant magicaly find out exact possition of enemy they dont see.

Edited by Mirek

Share this post


Link to post
Share on other sites

I like the waypoint idea but the tutorial only shows how to add it to a group but I'd have to make a separate group for every unit I want to move around. Much easier to just name the units and assign them in an array on a single trigger.

I understand your point regarding realism however with the area of the map being used there's a chance the player can complete the mission without ever being seen. I would like the player to have to change position and not lay in one spot.

As a workaround I have added an MI-8 helo to fly around and drop flares every 20 seconds once the assault starts. After a few minutes units begin to be alerted of player position (from possibly being spotted from the air) and start to move in randomly. Maybe this helps with realism.

Thank you for the reply.

Share this post


Link to post
Share on other sites

Using the trigger method AI should move to your location however they will only move once even if you use a repeating trigger.

Unless the condition changes they won't move again, you can force the condition change but it's not a very good solution for what your doing.

but I'd have to make a separate group for every unit I want to move around.

not really as you can still access a units group even if it's not been given one.

By placing GROUP in front of the unit will make the code think it's a real group.

waypoint1 = group _unitname addWaypoint [position p1,0 ];

Share this post


Link to post
Share on other sites

Ahh yeah the way I get the units to follow the player, somewhat, is to just repeat the getposATL p1 command for every piece of armor that gets destroyed.

I will have to play with this waypoint method and see if I can figure it out.

Share this post


Link to post
Share on other sites

Given the enemy is named red1 and the player is named p1 use this in the trigger:

red1 move getPos player; red1 setCombatMode "RED";

The enemy will move to your current position and attack you.

If you move to a new position, the enemy does not know you have moved so you need the trigger to fire over and over again. My solution is have a independent man on the other side of the map. Have him run up and down a road from A to B and back to A and back to B passing through his trigger area many times. Every time he enters the trigger area he fires the trigger.

This works with enemy on foot, enemy in vehicles and enemy in aircraft. Makes for a very exciting single player mission.

Share this post


Link to post
Share on other sites

I would suggest using while-do in place of a runner, that way the trigger only needs to be fired once.

while {alive p1} do {sleep 60; <code to go to player pos>};

As long as the player's alive it would update every sixty seconds. What I don't know is if using the move command might stack waypoints doing this. Each time move command creates one it makes it the current waypoint, but wiki makes no mention whether the old ones are deleted or are moved down in the queue.

-----------Edit-------------------------

eegore - I used your original setup and got it to work using a trigger for each of the aa vehicles. The BTR moved to player pos each time an aa asset was destroyed, forcing the player to relocate each time before destroying the next aa asset.

Game logic init:

same array as yours

code in the Condition for each of the six triggers:

trigger 1: {alive _x} count aa < 6;

trigger 2: {alive _x} count aa < 5;

trigger 3: {alive _x} count aa < 4;

trigger 4: {alive _x} count aa < 3;

trigger 5: {alive _x} count aa < 2;

trigger 6: {alive _x} count aa < 1;

Activation in each trigger:

same code as yours using the doMove command

Keep testing with the waypoints for realism though. Placing a Search & Destroy waypoint at or near player pos would seem realistic enough IMO. Whenever BTR reached my player's prior position, it just sat there.

Waypoints are a group function; but each single unit placed in editor, not being grouped, gets arrayed as a group of [1] under the Center for that side, which is why the group command does work to create waypoints for singular units. But if the unit is part of a group, the waypoint will be assigned to the entire group.

Edited by OpusFmSPol

Share this post


Link to post
Share on other sites

I had to chance the code to canmove "false" because sometimes the hit would not be direct and the crew would live therefore the trigger would not activate.

I still can't get waypoints to work correctly but at this time for my needs the direct travel for the vehicles to the player is ok. I have some sample missions with spawned units having waypoints that I will probably just copy-paste from and hope it works.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×