Home   Help Search Login Register  

Author Topic: CreateUnit not showing units  (Read 680 times)

0 Members and 1 Guest are viewing this topic.

Offline Arctic

  • Members
  • *
  • In Utero
CreateUnit not showing units
« on: 14 Jun 2003, 15:14:07 »
I'm trying to simulate an ambush with Resistance soldiers attacking an East convoy (with the player and team mates as West soldiers, captive in the East trucks!). I wanted to use the CreateUnit command so that there wouldnt be much lag while being there, and the East soldiers wouldn't attack the Resistance soldiers while they were waiting for the convoy to arrive.

 
Code: [Select]
;resspawn.sqs

#Limbo
?spawnres1: goto "spawn"

goto "Limbo"

#spawn
_u1 = "OfficerG" CreateUnit [getpos resSPAWN, groupBravo]
_u2 = "SoldierGG" CreateUnit [getpos resSPAWN, groupBravo]
_u3 = "SoldierMG" CreateUnit [getpos resSPAWN, groupBravo]

~0.05
_u4 = "SoldierGG" CreateUnit [getpos resSPAWN, groupBRAVO]
_u5 = "SoldierGLAW" CreateUnit [getpos resSPAWN, groupBravo]
_u6 = "SoldierGB" CreateUnit [getpos resSPAWN, groupBravo]
_u7 = "SoldierGMedic" CreateUnit [getpos resSPAWN, groupBravo]

~0.5
#group
[_u2,_u3,_u4,_u5,_u6,_u7] join _u1
#Attack

group _u1 setbehaviour "Combat"
group _u1 setcombatMode "RED"

group _u1 move getpos urak1
#Group2

~2.5
_u8 = "OfficerG" CreateUnit [getpos resSPAWN, groupCharlie]
_u9 = "SoldierGG" CreateUnit [getpos resSPAWN, groupCharlie]
_u10 = "SoldierMG" CreateUnit [getpos resSPAWN, groupCharlie]

~0.05
_u11= "SoldierGG" CreateUnit [getpos resSPAWN, groupCharlie]
_u12 = "SoldierGLAW" CreateUnit [getpos resSPAWN, groupCharlie]
_u13 = "SoldierGB" CreateUnit [getpos resSPAWN, groupCharlie]
_u14 = "SoldierGMedic" CreateUnit [getpos resSPAWN, groupCharlie]

~0.5
#group2
[_u9,_u10,_u11,_u12,_u13,_u14] join _u8
#Attack

group _u8 setbehaviour "Combat"
group _u8 setcombatmode "RED"

group _u8 move getpos urer

spawnres1 = false
exit

I don't get any errors, but none of the soldiers will appear. resSPAWN is the gamelogic that I used to mark where they will spawn.

The variable at the beginning is to keep the units from being created too early. (Couldn't I use the @ command? I think i might try that.)  It is activated in another script.

Is there an error in my script?

Here is the other script, just in case the error is in there.

Code: [Select]
;uralmove.sqs

ur move getpos urakw1

~0.75
urer move getpos ura1

urak setspeedmode "NORMAL"
urer setspeedmode "FULL"

#limbo
?(((ur distance urakw1) <= 7)): goto "shelling"

~1.5
goto "limbo"

#shelling
this exec "resspawn.sqs"

_s1x = getpos dgt select 0
_s1y = getpos dgt select 1
_s1z = getpos dgt select 2
_s2x = getpos fx1 select 0
_s2y = getpos fx1 select 1
_s2z = getpos fx1 select 2
_s3x = getpos fx2 select 0
_s3y = getpos fx2 select 1
_s3z = getpos fx2 select 2

~0.05
_shell1 = "SHELL105" CamCreate [(_s1x + 0),(_s1y + 0),(_s1z + 0)]

~0.35
_shell2 = "HEAT105" CamCreate [(_s2x + 0),(_s2y + 0),(_s2z + 0)]

~0.7
_shell3 = "HEAT105" CamCreate [(_s3x + 0),(_s3y + 0),(_s3z + 0)]

spawnres1 = true

#strike
rusup action ["eject", vehicle urer]
r1 action ["eject", vehicle urer]
r2 action ["eject", vehicle urer]
r3 action ["eject", vehicle urer]
r4 action ["eject", vehicle urer]
r5 action ["eject", vehicle urer]
r6 action ["eject", vehicle urer]
r7 action ["eject", vehicle urer]
r8 action ["eject", vehicle urer]

unassignVehicle rusup
unassignVehicle r1
unassignVehicle r2
unassignVehicle r3
unassignVehicle r4
unassignVehicle r5
unassignVehicle r6
unassignVehicle r7
unassignVehicle r8

group rusup setcombatmode "RED"
group rusup setbehaviour "Combat"

rusup reveal reop
rusup doTarget reop
r1 doTarget reop
r2 doTarget reop
r3 doTarget reop
r4 doTarget reop
r5 doTarget reop
r6 doTarget reop
r7 doTarget reop
r8 doTarget reop

~1.05
spawnRES = true
r1 doMove getpos resSPAWN
r2 doMove getpos resSPAWN
r3 doMove getpos resSPAWN
r4 doMove getpos resSPAWN
r5 doMove getpos resSPAWN
r6 doMove getpos resSPAWN
r7 doMove getpos resSPAWN
r8 doMove getpos resSPAWN

;this exec "rein1.sqs"
this exec "escape1.sqs"
exit

Everything in this script scomes out fine. The shells camcreate perfectly, and the East units all leave the Ural and move to the right location. There's just a chance that there might be an error with the variable.

deaddog

  • Guest
Re:CreateUnit not showing units
« Reply #1 on: 14 Jun 2003, 15:45:56 »
Groupbravo and gourpcharlie have to actually exists as a valid group name before the createunit will work.

Place a unit and in the init field type this:
groupbravo=group this;deletevehicle this

Do the same for groupcharlie.


You also don't need this:
[_u2,_u3,_u4,_u5,_u6,_u7] join _u1

The createunit command takes care of that for you, that's why you give it a group name to begin with.  you are telling it which group to add the unit to.

Hope that helps.  :)

Offline Arctic

  • Members
  • *
  • In Utero
Re:CreateUnit not showing units
« Reply #2 on: 14 Jun 2003, 15:59:53 »
Sweet! I'll give it a shot.

Offline Arctic

  • Members
  • *
  • In Utero
Re:CreateUnit not showing units
« Reply #3 on: 14 Jun 2003, 16:46:50 »
Erm.... they still dont show up...  are those units Resistance?

deaddog

  • Guest
Re:CreateUnit not showing units
« Reply #4 on: 14 Jun 2003, 17:29:00 »
Is the script even executing?

Insert this line after #Spawn:

hint "respawn now"

Is the variable spawnres1 a boolean?

Put spawnres1=false in your init.sqs file,just to make sure it is initialized properly.

Also, replace this:
this exec "resspawn.sqs"

with this:

[] exec "resspawn.sqs"

Give that a shot.  :)

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:CreateUnit not showing units
« Reply #5 on: 14 Jun 2003, 17:43:08 »
I am 99% sure this is why the units are not created in the first place:
Quote
_u1 = "OfficerG" CreateUnit [getpos resSPAWN, groupBravo]
you can't give him a name with a local variable. The unit must be global... instead do this:
Code: [Select]
"OfficerG" CreateUnit [getpos resSPAWN, groupBravo,"u1=this"]

And then
Code: [Select]
#Limbo
?spawnres1: goto "spawn"

goto "Limbo"
Looks like an infinite death loop from hell to ofp  ;D so atleast put a ~3 there cuz you prolly don't need it to be anally precise timed.

Other than that it looks pretty well written...
« Last Edit: 14 Jun 2003, 17:44:30 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Offline Arctic

  • Members
  • *
  • In Utero
Re:CreateUnit not showing units
« Reply #6 on: 14 Jun 2003, 21:18:45 »
That helps, but they still aren't appearing...

deaddog

  • Guest
Re:CreateUnit not showing units
« Reply #7 on: 14 Jun 2003, 22:09:15 »
Quote
Is the script even executing?

Insert this line after #Spawn:

hint "respawn now"


Did you do this?  Does the hint appear?

Offline Arctic

  • Members
  • *
  • In Utero
Re:CreateUnit not showing units
« Reply #8 on: 14 Jun 2003, 22:46:18 »
Ya, i did hints throughout the whole thing... and got rid of the variable. Here is how the script looks now:

Code: [Select]
;resspawn.sqs

#delete

#getpos
_rSx = getpos spack select 0
_rSy = getpos spack select 1
_rSz = getpos spack select 2

_randXY = random 5

#spawn
hint "respawn"

"OfficerG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u1 = this"]
"SoldierGG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u2 = this"]
"SoldierGMG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u3 = this"]

~0.05
"SoldierGG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u4 = ths"]
"SoldierGLAW" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u5 = this"]
"SoldierGB" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u6 = this"]
"SoldierGMedic" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupBravo, "u7 = this"]

~0.5
#group1
[u1,u2,u3,u4,u5,u6,7] join ul
#Attack
hint "attack"

player reveal u1

groupbravo setbehaviour "Combat"
groupbravo setcombatMode "RED"

groupbravo move getpos urak1
#Group2

~2.5
"OfficerG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u8 = this"]

"SoldierGG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u9 = this"]

"SoldierGMG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u10 = this"]


~0.05
"SoldierGG" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u11 = this"]

"SoldierGLAW" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u12 = this"]

"SoldierGB" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u13 = this"]

"SoldierGMedic" CreateUnit [[(_rSx + +randXY),(_rSz + _randXY),(_rSz + 0.5)], groupCharlie, "u14 = this"]


~0.5
#group2
[u8,u9,u10,u11,u12,u14] join ul2
#Attack

groupcharlie setbehaviour "Combat"
groupCharlie setcombatmode "RED"

groupCharlie move getpos player

spawnres1 = false
exit

ul and ul2 are the units that make groupBravo and groupCharlie active.

The script appears to be behaving like it should, it just wont get the units to appear!

McHale

  • Guest
Re:CreateUnit not showing units
« Reply #9 on: 14 Jun 2003, 23:29:03 »
Forget the whole complex script for a minute.

Is it possible to get Units to spawn at all? I've tried and I can't do it either...
« Last Edit: 14 Jun 2003, 23:29:26 by McHale »

McHale

  • Guest
Re:CreateUnit not showing units
« Reply #10 on: 14 Jun 2003, 23:43:52 »
Okay, I did a little searching and found this post helpful.

Quote
Place a soldier on the map and give it a groupname and delete it. alpha = group this; deletevehicle this. Now you have a groupname to work with and the soldier is deleted at mission start and won't be on the map. You can even give it waypoints and the created units will follow them.


Now to create soldiers you'd use this syntax.
"SoldierEMG" CreateUnit [getmarkerpos "blahblah", alpha, "soldier1 = this", 0.7, "CORPORAL"]


Now you have the position, groupname, init which gives the units name, his skill, and rank. All your created units need that. You need to use the quotation marks also. If you only use position and groupname it will work, but then you can't move them into vehicles since you don't have a soldier name to work with, so you want to use the init part. Also the default skill is 0.1 (total idiot) so using 0.7 gives him a little brains. You can use any groupname you dream up, it doesn't have to be alpha or bravo etc...Remember that you can only create 12 soldiers for a group, so if you're making a bunch, then make several dummy soldiers with different groupnames to work with. Obviously, you want different groupnames to make units for tanks and other vehicles.

I noticed you're creating units to put in a Mi24, but the Mi24 won't hold that many in its cargo as you're creating. You need to check the editing depot for vehicle capacity values.
« Last Edit: 14 Jun 2003, 23:45:13 by McHale »