Home   Help Search Login Register  

Author Topic: answered: random spawning hostages and trigger  (Read 1675 times)

0 Members and 1 Guest are viewing this topic.

Offline smoke52

  • Members
  • *
answered: random spawning hostages and trigger
« on: 14 Aug 2007, 11:46:43 »
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
Code: [Select]
_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?
« Last Edit: 15 Aug 2007, 07:41:16 by smoke52 »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: random spawning hostages and trigger
« Reply #1 on: 14 Aug 2007, 12:10:12 »
just setpos em after dey r spawned (use setpos command :P)

nd samething w/ triger... use da spawning trigs copmmands (check comref...) nd spawn it on top of em (nd add setpos comand 2 make sure :P ;)

more extensive answer after im back from work... if no1 answers b4 me :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: random spawning hostages and trigger
« Reply #2 on: 14 Aug 2007, 12:12:25 »
To spawn units inside buildings use buildingPos command. And yes, roof of the buildings are at height 0, like ground level. Note that to use buildingPos command, the desired building must have defined indexed positions. If this is not the case, you may still spawn them outside, near the door and just a bit above the ground (for example, 10 cm), and push them inside with setVelocity. Another option may be to spawn them with a negative height, than may make them to spawn below the roof of the building.

About the trigger, may you explain a bit more what's its purpose?

Offline smoke52

  • Members
  • *
Re: random spawning hostages and trigger
« Reply #3 on: 14 Aug 2007, 13:40:45 »
this works for me!
Code: [Select]
_hos1 setPos ((nearestbuilding _hos1) buildingPos 1)

the trigger is to detect the player and tell the hostages to enable their ANIM and join the player.

i been trying the setpos command and create trigger commands but its not working, if i keep going at it i might figure it out, but im going to bed.

also for the trigger activation i want to exec a new script called hosrescue.sqs which will have the commands to re-enable their animations and join the player, but i ran into a snag...

how do i give the two hostages names so the hosrescue script can tell them the new commands? will this command work?

_hos1 = name hos1

then in the hosrescue.sqs script i can put
Code: [Select]

hos1 EnableAI "ANIM";
hos2 EnableAI "ANIM";
hos1 joinsilent player;
hos2 joinsilent player;

?

thanks!

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: random spawning hostages and trigger
« Reply #4 on: 14 Aug 2007, 13:49:14 »
Are you creating them with CreateUnit?

nameofunit = Createunit...

Cant remember syntax but put that at the start.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: random spawning hostages and trigger
« Reply #5 on: 14 Aug 2007, 14:07:13 »
create the trigger from the editor like a normal one, group it with the player (select vehicle there) and give a name to the trigger, trg_hostages, for example.
In the script where you place the hostages put trg_hostages setPos (getmarkerpos _spot) and, in the condition field put this && ({alive _x} count [hos1, hos2] > 0) so the player is close to the hostages and at least one of them is still alive.

Offline smoke52

  • Members
  • *
Re: random spawning hostages and trigger
« Reply #6 on: 15 Aug 2007, 05:43:20 »
edit:  thanks guys! all my questions have been answered :good:

i will probably have a couple more soon.
« Last Edit: 15 Aug 2007, 07:40:47 by smoke52 »