Jump to content
Sign in to follow this  
smoke52

random spawning hostages and trigger

Recommended Posts

i have two questions (read the bottom for question 2)...anyway for my mission i am making the port area in Corazol a hostage and bomb situation. the hostages are supposed to spawn in one of 3 warehouse buildings in the port.

im using a script that spawns two guys in a random location. the script works fine but I am having trouble with the hostages spawning on the outside of the building when they get created.

i think its because the game is trying to spawn them on the roof but the game doesnt allow that and spawns them outside around it...

what do i need to add to get them to spawn inside somewhere?

heres the script

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_hostages = createGroup west;

_locations = ["hostage1", "hostage2", "hostage3"]

_rndloc = (random (count _locations)) - 0.5

_spot = _locations select _rndloc

_hos1 = _hostages createUnit ["SoldierWB", (getmarkerpos _spot), [] ,0 ,"corporal"];

removeallweapons _hos1

_hos1 setcaptive true

_hos1 setDir random 360;

_hos1 allowfleeing 0;

_hos1 setBehaviour "AWARE";

_hostages selectLeader _hos1;

_hos1 switchmove "testsurrender";

_hos1 DisableAI "ANIM";

~1

_hos2 = _hostages createUnit ["SoldierWB", (getmarkerpos _spot), [] ,0 ,"private"];

removeallweapons _hos2

_hos2 setcaptive true

_hos2 setDir random 360;

_hos2 allowfleeing 0;

_hos2 setBehaviour "AWARE";

_hos2 switchmove "testsurrender";

_hos2 DisableAI "ANIM";

also how do i get a trigger to spawn in the same area that the hostages are in?

Share this post


Link to post
Share on other sites

1. You need to use something like buildingPos for proper internal building placement.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_soldier setPos (_house buildingPos _i);

Do a search for the keyword "buildingPos" and you'll find a ton of threads, since this topic was heavily discussed early on in the year.

2. What do you mean "spawn a trigger"? Do you mean how to create a trigger? To create one in a script, it looks something like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> G_UnitsInitTrig = createTrigger ["EmptyDetector", getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")];

G_UnitsInitTrig setTriggerArea [22000, 22000, 0, true];

G_UnitsInitTrig setTriggerActivation ["ANY", "PRESENT", false];

G_UnitsInitTrig setTriggerStatements [

"this",

"{ [_x] call fn_UnitInit } forEach thisList;",

"" ];

Share this post


Link to post
Share on other sites

thanks alot i found out how to get them inside the building with this line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_hos1 setPos ((nearestbuilding _hos1) buildingPos 1)

as for my trigger spawn question that has been answered as well. what i was shown to do was make a trigger and group it to the player. select VEHICLE, in the script where i place the hostages i put

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

trg_hostages setPos (getmarkerpos _spot)

and, in the condition field put

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

this && ({alive _x} count [hos1, hos2] > 0)

so the player is close to the hostages and at least one of them is still alive.

heres the hostage spawn script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_hostages = createGroup west;

_locations = ["hostage1", "hostage2", "hostage3"]

_rndloc = (random (count _locations)) - 0.5

_spot = _locations select _rndloc

trg_hostages setPos (getmarkerpos _spot);

~1

hos1 = _hostages createUnit ["SoldierWB", (getmarkerpos _spot), [] ,0 ,"corporal"];

hos1 setPos ((nearestbuilding hos1) buildingPos 1);

removeallweapons hos1;

hos1 setcaptive true;

hos1 setDir random 360;

hos1 allowfleeing 0;

hos1 setBehaviour "AWARE";

hos1 switchmove "testsurrender"

hos1 DisableAI "ANIM"

_hostages selectLeader hos1;

~1

hos2 = _hostages createUnit ["SoldierWB", (getmarkerpos _spot), [] ,0 ,"private"];

hos2 setPos ((nearestbuilding hos2) buildingPos 1);

removeallweapons hos2;

hos2 setcaptive true;

hos2 setDir random 360;

hos2 allowfleeing 0;

hos2 setBehaviour "AWARE";

hos2 switchmove "testsurrender"

hos2 DisableAI "ANIM"

and the script thats triggered to tell the hostages to join your squad:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

hos1 setcaptive false;

hos2 setcaptive false;

hos1 switchmove ""

hos1 EnableAI "ANIM"

hos2 switchmove ""

hos2 EnableAI "ANIM"

[hos1,hos2] joinsilent player;

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  

×