Home   Help Search Login Register  

Author Topic: Sun of a botch! (DIFFICULT QUESTION)  (Read 2699 times)

0 Members and 1 Guest are viewing this topic.

dreaming_adam

  • Guest
Sun of a botch! (DIFFICULT QUESTION)
« on: 12 Nov 2002, 20:40:30 »
:help:!
Im working on a rather heavily scripted MP mission that includes AI respawning, BUT Ive run into some difficulties (and I have looked through all the posts in this forum so its not a standard question).

For background to the problem, aside from everything else in the mission - at preset intervals a random EMPTY vehicle is spawned on an island remote to the players. This is spawned using CREATE VEHICLE.

After a 10 second delay (for some reason you cant get in empty vehicles immediatley) THREE west machinegun soldiers are spawned next to it using the CREATEUNIT command.

From then there is a 20 second delay - afterwhich an ATONOV (big 72 passenger freight plane) spawns at (0,0,0) and flys towards a RANDOM location on the map. When it reaches this destination the previously created tank is SETPOS'ed to the planes position, and then is parachuted to the ground (i.e it seems like the plane just paradropped the tank). The plane then flies out to sea and is DELETEVEHICLE'd.

#####-THE PROBLEM-#####
The three AI that were spawned are supposed to get into the tank, one as commander, one as gunner, one as driver. I am using the ASSIGNASDRIVER (for the driver anyways) AND the MOVEINDRIVER command referencing to the tank, yet the AI simply REFUSE to board the tank!

BTW for those of you wondering how I am issuing commands to the spawned AI when their object name isnt returned - the CREATEUNIT command allows you to put commands in the INIT field of the spawned unit...

Here is that particular module of code for reference:

Code: [Select]
; spawn_point
; An-124Troop
#tart
hint "Enemy Vehicle Created"
_tank = "BMP" createVehicle getmarkerpos "spawn_point"
~10
"SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),"this assignasgunner _tank; this moveingunner _tank"]
"SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),"this assignascommander _tank; this moveincommander _tank"]
"SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),"this assignasdriver _tank; this moveindriver _tank"]
[sargent_nwaps] join grpNull
~40
[_tank, getpos a, 200, 0.1, 0, 0, 0] exec "Para.sqs"
~2
goto "tart"
exit

Sargent_nwaps is a WEST AI hidden from the players in the game... Just because I dont know how to dynamically add a group mid mission.


The SECOND problem is the lag that the mission generates. To aleviate this I made a script that scans the map for destroyed units (such as tanks, bodies, etc) and upon finding one, transports it to a remote location before DELETEVEHICLE'ing it. This script works correctly, when a person dies there is a 10 second delay before they are deleted and respawned.. Same with tanks and choppers. The problem however is not that the script doesnt function, but rather it leaves an annoying error message (division by zero error) in the corner of the screen for the entire duration of the mission, refering to this line "?(!alive (_body select _f)): [_body select _f]"

Here is the code:
Code: [Select]
_f=0
#loop
_body = list kam
_f=0
?(!alive (_body select _f)): [_body select _f] exec "killtimer.sqs"
#funk
_f=_f + 1
?(!alive (_body select _f)): [_body select _f] exec "killtimer.sqs"
?(_f <= count _body):goto "funk"
goto "loop"

kam in the above code is a trigger activated by ANYBODY, with a=11111, b=11111 (covers the whole map)
The code for killtimer is:
Code: [Select]
~5
(_this select 0) setpos [99999,99999,99999]
deletevehicle (_this select 0)

exit

Any help would be greatly appreciated

-Adam

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #1 on: 12 Nov 2002, 20:58:32 »
I'm not sure how to help you with all of your questions, but I have an idea for part of it.

Quote
"SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),"this assignasgunner _tank; this moveingunner _tank"]
"SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),"this assignascommander _tank; this moveincommander _tank"]
"SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),"this assignasdriver _tank; this moveindriver _tank"]

For this part, try using the following code instead:

Code: [Select]
_tempObj = "SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),""]

_tempObj assignasgunner _tank
_tempObj moveingunner _tank

_tempObj = "SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),""]

_tempObj assignascommander _tank
_tempObj moveincommander _tank

_tempObj = "SoldierWB" createUnit [getMarkerPos "spawn_point",(group sargent_nwaps),""]

_tempObj assignasdriver _tank
_tempObj moveindriver _tank

I don't know if this will help, but give it a try.

Quote
Sargent_nwaps is a WEST AI hidden from the players in the game... Just because I dont know how to dynamically add a group mid mission.

For this, you can modify the above code. For example:

Code: [Select]
_tempObj = "SoldierWB" createUnit [getMarkerPos "spawn_point"]

_tempObj assignasgunner _tank
_tempObj moveingunner _tank

[b]group1 = group _tempObj[/b]

_tempObj = "SoldierWB" createUnit [getMarkerPos "spawn_point",group1,""]

_tempObj assignascommander _tank
_tempObj moveincommander _tank

_tempObj = "SoldierWB" createUnit [getMarkerPos "spawn_point",group1,""]

_tempObj assignasdriver _tank
_tempObj moveindriver _tank

That should do it.
« Last Edit: 12 Nov 2002, 21:02:11 by Ranger »
Ranger

dreaming_adam

  • Guest
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #2 on: 12 Nov 2002, 21:05:52 »
my gawd that makes things infinitley easier... I wanted to do that from the first place but according to the official command references CREATEUNIT doesnt return an objectname. Im going to try out what you suggested immediatley and if it works im in your debt! lol

Cheers and many thanks

Adam

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #3 on: 12 Nov 2002, 21:55:20 »
Heh, I'm happy to help.  I just hope it works. :)

If you want to give your newly spawned tank crewmembers names, you can change _tempObj to 3 different global variables instead.

Code: [Select]
gunner1 = "SoldierWB" createUnit [getMarkerPos "spawn_point"]

gunner1 assignasgunner _tank
gunner1 moveingunner _tank

group1 = group gunner1

commander1 = "SoldierWB" createUnit [getMarkerPos "spawn_point",group1]

commander1 assignascommander _tank
commander1 moveincommander _tank

driver1 = "SoldierWB" createUnit [getMarkerPos "spawn_point",group1]

driver1 assignasdriver _tank
driver1 moveindriver _tank

I think this is exactly the same thing as setting a name in a unit's name field.  Even if not, it can still be used the same way.
« Last Edit: 12 Nov 2002, 22:03:27 by Ranger »
Ranger

dreaming_adam

  • Guest
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #4 on: 12 Nov 2002, 22:03:53 »
Yeah thanks for your help :) The units references dont need to take up global variable space (I have a habbit of using non-instrinsic variable names so this becomes rather critical) and seeing as once they are in the tank thats all they will ever be called upon in this mission :)

Many thanks again!

Adam

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #5 on: 12 Nov 2002, 22:08:05 »
Hmm.  I just read how the createUnit command works.  Apparently, it does not return any value, so my idea probably won't work.  That's really strange, seeing how createVehicle and camCreate both return the object.  I don't see why they didn't make createUnit return the object.

In any case, did you get to try it yet, and if so, did it work anyway?

It also seems that you have to specify a group, but in my example code, I didn't specify one for the gunner.  What happens if you specify a group that doesn't exist?  That is, will it create that group?  Since I don't have access to the game right now, I can't test any of this for you.
Ranger

dreaming_adam

  • Guest
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #6 on: 12 Nov 2002, 22:17:47 »
Hmmmm dang I thought you found an exception to the comref... Ill try it out anyways (I cant at the second) but if createunit doesnt return an objectname BIS can expect a rather 'friendly' email from me expressing my frustration! lol

I mean... why not friggin make the function return an objectname in the first place? Talk about lazy...

Anyways as helpful as your reply is (well should be if BIS was more uniform with their coding) the original two problems remain :S. Anybody got any ideas?

Thanx

Adam

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #7 on: 13 Nov 2002, 01:59:00 »
Ok... first off a couple of points.

If you're going to use moveindriver then you don't need to use assignasdriver. Moving the guy into the driver's seat will probably give him a pretty good idea as to where he's supposed to be ;)

Secondly, if you want to give a created unit a name, you do so thusly:

"SoldierWB" createunit [ position, group, "PrinceCharles = this" ]

Lastly, for createunit to work you must specify an existing group. So the first createunit command a couple of posts up won't create the unit for you (as there is no group specified) ;)

dreaming_adam

  • Guest
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #8 on: 13 Nov 2002, 04:51:12 »
Thanks for your help Sui :) The reason I was using both assignasdriver and moveindriver was because neither of them was working.. I kinda thought that id experiment using them both. I shall only use MOVEINDRIVER now tho.

As for using an already spawned group, I have a unit on a remote island (sargent_nwaps) who I am using for the group. the three guys are spawned into nwaps group, then nwaps changes to grpnull.

Maybe you will be able to help with the original question tho, do you know how to place createunit's into a createvehicle vehicle? I know it should work in theory but for some reason it doesnt.. If anybody has successfully done this please reply :)

Ciao Ciao

Adam

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #9 on: 13 Nov 2002, 05:01:40 »
That's not working?

Here's a snippet from the scene script in one of my missions:
Code: [Select]
b1lite = "UAZ" createvehicle [(getpos b1hpad select 0) - 43, (getpos b1hpad select 1) + 1, 0]
b1lite setdir 090
"SoldierEB" createunit [getpos b1lite, newgrp,"b1liteman = this"]
[b1liteman] join grpnull
b1liteman moveindriver b1lite

That creates a UAZ, then a unit to be the driver. It places the driver in the vehicle no problems. At least I've never had any issues with it... ;)

CareyBear

  • Guest
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #10 on: 15 Nov 2002, 14:28:33 »
Oh, and you can't create groups mid-mission. If u specify a group that doesn't exist in createUnit, nothin happens.

Or, that's the way it was in 1.75. Haven't tried it in 1.85.

There's a lil tut thingy I wrote on getting dynamic groups in the Ed Depot.

U also can't use 'grpNull' as the startin group, as far as I am aware (again, I tried it in 1.75 and it didn't work). grpNull makes the AI even stupider, btw.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Sun of a botch! (DIFFICULT QUESTION)
« Reply #11 on: 15 Nov 2002, 23:43:06 »
Oh, and you can't create groups mid-mission. If u specify a group that doesn't exist in createUnit, nothin happens.

The second part of that statement is correct, the first part isn't ;)

To specify a group at any time, you just need to use the statement:

groupname = group unit

So you can create completely new groups full of created units, provided you spawn the first one into a pre-existing group (then have it join groupnull, then name a group using that unit).

Also, GrpNull has no effect on AI. It's simply a group assignment ::)