Jump to content

Group spawn randomly in trigger


Go to solution Solved by cfrag,

Recommended Posts

Posted

Hi all. I've tried using Chat GPT to help me out with this one.

Scenario:
I have a trizzer zone called 'SCUDS-spawn'

I have a group of three calld 'Scuds'. I have put them in a bit of a triagle formation.

On mission start I would like the scuds to start somewhere within the trigger zone in a random place inside the trigger zone. I like them to keep their formation though.

I think it would make a good mission if you had to do a SCUD hunt for example but everytime you played the mission the targets would be in a diffewrent place.

This is the script that GPT gave me but it causes an error and I have included the .miz file as well.

-- Get the trigger zone
local zone = trigger.misc.getZone('SCUD-launchers')

-- Get a random point inside the trigger zone
local point = {
  x = zone.point.x + math.random() * zone.radius * 2 - zone.radius,
  y = zone.point.z + math.random() * zone.radius * 2 - zone.radius
}

-- Teleport the SCUDs to the new point
Group.getByName('Scuds'):getController():setOnOff(true)
Group.getByName('Scuds'):getController():resetTask()
Group.getByName('Scuds'):getController():setCommand({
  id = 'SetInvisible',
  params = {
    value = false,
  }
})
Group.getByName('Scuds'):getController():setCommand({
  id = 'SetImmortal',
  params = {
    value = false,
  }
})
Group.getByName('Scuds'):getController():setCommand({
  id = 'Teleport',
  params = {
    x = point.x,
    y = point.y,
    action = 'respawn',
  }
})

 

random-group-spawn.miz

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

  • Solution
Posted
On 5/17/2023 at 3:52 PM, TheTrooper said:

I've tried using Chat GPT to help me out with this one.

Don't. You end up spending more time than trying to do it yourself. These chat bots are party novelties, created to talk to you, unfit for coding.

Below please find what I hope you were looking for. 

 

random-group-spawn DML.miz

Posted
8 hours ago, cfrag said:

Don't. You end up spending more time than trying to do it yourself. These chat bots are party novelties, created to talk to you, unfit for coding.

Below please find what I hope you were looking for. 

 

random-group-spawn DML.miz 153.54 kB · 3 downloads

That is a game change! I can't believe this isn't available in DCS without someone scripting it.It opens up a lot of random options to the game.

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

  • 2 weeks later...
Posted
On 5/19/2023 at 8:31 AM, cfrag said:

Don't. You end up spending more time than trying to do it yourself. These chat bots are party novelties, created to talk to you, unfit for coding.

Below please find what I hope you were looking for. 

 

random-group-spawn DML.miz 153.54 kB · 6 downloads

Couple of issues.

1. There are three messages at the start of the mission. Would be great if they didn't show?
2. If I set a trigger so that the if the group is destroyed then display a message "MISSION COMPLETE". Issue is here the message appears at the start of the mission regardless before they are hunted down.

_DCSFDSAFDFDSAFSFS.JPG

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

Posted
8 hours ago, TheTrooper said:

1. There are three messages at the start of the mission. Would be great if they didn't show?

If you say 'yes' to above question (couldn't resist), simply add a 'Message To All' with a checkmark in 'CLEARVIEW' after the modules load during MISSION START - please also see the attached mission

image.png

8 hours ago, TheTrooper said:

If I set a trigger so that the if the group is destroyed then display a message "MISSION COMPLETE". Issue is here the message appears at the start of the mission regardless before they are hunted down.

That's a consequence of how the cloners work, and can be easily remedies by using a group tracker. In the example I added a tracker, and it changes the flag 'missionComplete' when all groups that the cloner created are destroyed.

Use communications-->Other to kill the scuds on command to test the mission complete detection

 

random-group-spawn DML.miz

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...