Home   Help Search Login Register  

Author Topic: Commands not being actioned  (Read 566 times)

0 Members and 1 Guest are viewing this topic.

Offline Roni

  • Members
  • *
  • Play the Game !
Commands not being actioned
« on: 06 Feb 2005, 09:35:39 »
Hello All

This is a general query about a subject that is starting to really bug me.

I am working on a number of missions that use some complex scripting - no probs there, but some of the commands just simply aren't being actioned when they're supposed to.

The most annoying example is my player respawn script.  I have set respawn to Group and have a script running on the character that does the following -

;      Equip player with standard weapons and equipment
# spawnRoutine

removeallweapons _player

_player addmagazine "RevolverMag"
_player addmagazine "RevolverMag"
_player addmagazine "RevolverMag"

_player addweapon "Revolver"
_player addweapon "Binocular"
_player addweapon "NVGoggles"


;      Wait until player is dead
@!alive _player


;      Reduce casualty limit.  If casualty limit reached then show lives remaining
casualtyLimit = casualtyLimit - 1
publicVariable "casualtyLimit"

? casualtyLimit < 1 : titleText ["The last remaining black ops have been rounded up and shot by the occupying forces", "Plain"], endTrigger setpos (getpos _player)


;      Create new group member at first base, equip with standard weapons and equipment
_newMan = "SoldierWSaboteurPipe" createUnit [getPos player, group _this]

removeallweapons _newMan

_newMan addmagazine "RevolverMag"
_newMan addmagazine "RevolverMag"
_newMan addmagazine "RevolverMag"

_newMan addweapon "Revolver"
_newMan addweapon "Binocular"
_newMan addweapon "NVGoggles"


;      Notify number of lives remaining, wait for respawn
hint format ["There are now only %1 other black ops left on the island", casualtyLimit]
@alive _player

goto "spawnRoutine"



The problem is that the new character is not being re-armed - he keeps starting with the equipment that he is listed to start with !  Why isn't the re-arm bit being actioned ?

My guess is that it's because the assignment "_newman = . . . " is not being actioned, which makes the rest useless.  To confirm this i changed the createUnit to a camCreate and a join - when I did that the re-arm part worked but for some reason the join command didn't, no matter what syntax I use (eg [_newMan] join _this, [newMan] join group _this, [newMan] join leader group _this etc.

I tried testing this using a short test mission with another unit called "kenneth" whose init field contained the command "[kenneth] join captain" and it worked no problems.  BTW - Captain is the leader of the group with the player in it.


One last example - I have written an RDF script - it basically uses radio calls Alpha to Foxtrot to give the player find the bearing and rough distance to the nearest unt of a specified type (eg friendly black ops, enemy chopper, enemy officer etc).

Again - the script is failing because a key command is not being actioned (in this case - "_nearestTarget = nearestObject [_caller, _targetObject]").  I know that this is the key bit that fails because I have dissected it a million ways and have isolated this one part.  Simpy put - this part fails, which makes _nearestTarget a null object, which screws the rest.

Has anyone seen this before or know why this is happening ?  I am using version 1.96 with all intermediate patches installed, using a commercially purchased original of both OFP and OFP-R.  The mission sqm is pretty big - it' now up to 96k, but I have tried out the subscripts on another small test mission and got the same results.

All up I have about a dozen scripts running in the mission using around 20-30 variables - nothing too flash and AFAIK not too tough a load for my 2 gig laptop with 708mB of RAM and onboard graphics.

Anyone ?

Thanking all in advance . . .

Roni

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Commands not being actioned
« Reply #1 on: 06 Feb 2005, 10:33:21 »
About the CreateUnit problem:

As far as I know and have experienced this same problem about the CreateUnit command, you can't reference to the unit using a variable like you can with a CreateVehicle command. You have to use something like this:

Code: [Select]
"SoldierWSaboteurPipe" createUnit [getPos player, yourgroup, "dude1 = this"]
And now you can reference to the unit with the name 'dude1'.

EDIT:

And one thing... are you sure it's a good idea to use a '@!alive _player' line in your script? Maybe it could be replaced with a event handler 'killed' and thus reducing CPU load. IMHO you should give the player weapons and equipment in init.sqs or in unit's init field. And then run the respawn script only when a 'killed' event has occurred.

Hmm... and how does the 'respawn=group;' work... hmmm...

 :o
« Last Edit: 06 Feb 2005, 10:59:47 by Baddo »

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Commands not being actioned
« Reply #2 on: 06 Feb 2005, 11:11:41 »
Hi Baddo

Thanks for the input.

I know that @ functions are very heavy on the CPU load but I only use it for the respawn bit and it usually doesn't hurt me noticably.  I usually play 2 player MP so haven't experienced any problems - now that I'm designing misions for up to 6 players I'll change it to check every 4 seconds with a 5 second respawn  ;D

respawn = "GROUP".  People die, they come back as the next man in the same group.  Works for me . . .  :-\

Thanks for the heads up with camcreate vs createUnit  - I'm losing control of the machine now on wfe's orders but I'll try it tomorrow.

Oh and BTW - my snip of my script missed the first few lines.  It should have included the player assignment bit and the bit that sets the player respawn limit -

;      Determine player, set casualty limit
_player = driver _this
casualtyLimit = 9



Cheers !



Roni