OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Artak on 25 Mar 2003, 22:33:33

Title: Createunit Trouble
Post by: Artak on 25 Mar 2003, 22:33:33
Hello folks  :)

I've been having this problem for a while (no it's not the fungus thing)

I'm trying to decrease lag in a huge mission by creating units as the mission goes and have made this amongst others:

Code: [Select]
"OfficerE" createunit [getpos attack1, attackgrp2, "eo800 = this", 1, "LIEUTENANT"]
   ~0.5
"SoldierEB" createunit [getpos attack1, attackgrp2, "e3600 = this"]
   ~0.5
"SoldierEB" createunit [getpos attack1, attackgrp2, "e3700 = this"]
   ~0.5
"SoldierELAW" createunit [getpos attack1, attackgrp2, "e3800 = this"]
   ~0.5
"SoldierEMG" createunit [getpos attack1, attackgrp2, "e3900 = this"]
   ~0.5
"SoldierEMedic" createunit [getpos attack1, attackgrp2, "e4000 = this"]
   ~0.5
"SoldierEG" createunit [getpos attack1, attackgrp2, "e4100 = this"]
   ~0.5
"SoldierEB" createunit [getpos attack1, attackgrp2, "e4200 = this"]
   ~0.5
"SoldierEB" createunit [getpos attack1, attackgrp2, "e4300 = this"]
   ~0.5
"SoldierELAW" createunit [getpos attack1, attackgrp2, "e4400 = this"]
   ~0.5
"SoldierELAW" createunit [getpos attack1, attackgrp2, "e4500 = this"]

      [attackofficer1] join grpnull

exit

For some reason the script only creates the 6 first units. Why?

I've got this other script that I'm using too and it works just fine with 9 units:

Code: [Select]
etank6 = "t72" createVehicle getpos attack2

   ~1

etank7 = "t80" createVehicle getpos attack2

   ~1

etank8 = "t80" createVehicle getpos attack2


"SoldierECrew" createunit [getpos attack2, attackgrp2, "et16 = this", 1,"Lieutenant"]
"SoldierECrew" createunit [getpos attack2, attackgrp2, "et17 = this"]
"SoldierECrew" createunit [getpos attack2, attackgrp2, "et18 = this"]

"SoldierECrew" createunit [getpos attack2, attackgrp2, "et19 = this", 1,"Lieutenant"]
"SoldierECrew" createunit [getpos attack2, attackgrp2, "et20 = this"]
"SoldierECrew" createunit [getpos attack2, attackgrp2, "et21 = this"]

"SoldierECrew" createunit [getpos attack2, attackgrp2, "et22 = this", 1,"Lieutenant"]
"SoldierECrew" createunit [getpos attack2, attackgrp2, "et23 = this"]
"SoldierECrew" createunit [getpos attack2, attackgrp2, "et24 = this"]

      [attackofficer2] join grpnull

   ~3

et16 moveincommander etank6
et17 moveingunner etank6
et18 moveindriver etank6

   ~1

et19 moveincommander etank7
et20 moveingunner etank7
et21 moveindriver etank7

   ~1

et22 moveincommander etank8
et23 moveingunner etank8
et24 moveindriver etank8

exit

As you can see the seconds script creates 9 units and 3 tanks and it works just fine.

Come on, give me your best shot!  :D
Title: Re:Createunit Trouble
Post by: macguba on 26 Mar 2003, 14:44:31
Have you tried re-sorting the order of the loons, to see if it really is the first 6 or something to do with the individual units?    And I'm almost embarrassed to say this, but you're not trying to put more than 12 loons in a group are you?     I suppose it could be something to do with the exact location, maybe there isn't space for the rest, or they are being created inside a closed building or something.

Sorry, I'm just rambling ......
Title: Re:Createunit Trouble
Post by: Artak on 26 Mar 2003, 17:22:51
Better rambling then nothing at all, I apriciate the effort  :)

Yes it's the 6 first units on that list, no matter what units they are..

there's plenty of room in the group (only 1 loon to begin with) and yes, you should be embarrased about asking something like this  :D ;)

umm..

The location is not the problem either, because the other script up there creates 3 tanks and 9 men on a spot just like this script is trying to do with 6 men. It's a wide open space.


If I loop the script and kill a soldier from the group it creates a random (based on what part the script is running at that time) soldier to replace the killed one, but never goes above 6 units in the group.  >:(
Title: Re:Createunit Trouble
Post by: macguba on 26 Mar 2003, 17:29:08
try changing the group name.    yes I know it shouldn't work, but whoever said OFP was logical?    it it replaces a dead unit it does sound as if the game thinks the group is full.
Title: Re:Createunit Trouble
Post by: Artak on 26 Mar 2003, 17:41:49
 :o OMG macguba your a genius!!!  :wow:

ok, so the changing group name didn't work obviously but because you said ofp wasn't logical ( ;D I knew that already) I started thinking what else weird things I could try to make the script work.

So first I increased the delay between each row from ~0.5 to ~2.5 and noticed that now I only had 3 units created.

 :hmm:

Slowly my brain started to show signs of some action and I removed the delays totally resulting 11 soldiers in my group  :D :thumbsup:


So, to sum it up, the 0.5 second delays were messing up the script. Don't know why, don't really care as long as it works.
The only downside in this is that I inserted the delays to decrease lag. Creating 11 sildiers at once causes the game to lag for about 0.3 seconds and even more in MP.  :P
Title: Re:Createunit Trouble
Post by: Artak on 26 Mar 2003, 20:18:39
.. this is why I left the topic unsolved. I knew something was about to come up  ::)

Now the trouble is in the seconds script. The one which creates 1 t72 and 2 t80 tanks and the crew.

I editor everything works fine but when I test it in mp with my friends there's 3 t72 tanks and 6 t80.
I'm also using different scripts in different towns which do basicly the same thing but with different units like a bmp for example and they have the same problem.

Also it not just creates everything in 3*whatIwant but also doesn't create the crew at all.


I'm making a huge mission, so the use of createunit and createvehicle is essential.  :-[
Title: Re:Createunit Trouble
Post by: asmodeus on 26 Mar 2003, 22:28:10
This is some very interesting stuff!

I'm wondering..  With your MP test, did you have a total of 3 players? (seems like the script was creating the tanks for each person playing?)

About the crew, is it possible to seperate that into a different script, activated a couple seconds later?  (random ideas)

I dunno..  but I'm very interested to know!   8)

I'll think about it some more..   ;)

Asmo
Title: Re:Createunit Trouble
Post by: Artak on 27 Mar 2003, 07:24:13
No, the scripts create units for the enemy AI. (I had 4 players in that MP test, which I think matters not.)

Indeed it is possible to separate the script into two, and I'm going to try that and see how it acts then. Post some news about how it went later.
Title: Re:Createunit Trouble
Post by: Artak on 27 Mar 2003, 18:55:25
Separating the creation of tanks and their crew worked not   :P

The problem seems to be somehow connected to either lag or mp playing in general because in the editor or with single player the problem does not exist.  ???
Title: Re:Createunit Trouble
Post by: Artak on 02 Apr 2003, 08:07:09
..Still not solved..

G'daum! This is the only thing keeping me from world domination!  ;D


So I'm still having the same problem. I have separated the scripts into tiny bits and pieces with no result.
When I'm creating 1 bmp I find 4 on the battlefield or something like that.

Please help  :-[
Title: Re:Createunit Trouble
Post by: asmodeus on 02 Apr 2003, 09:12:30
That sucks!   :-\

*rattles his skull around.. wonders why there's no rattle..*   ::)

Uhhh....   How about we narrow it down more if we can...

Is it the same equation no matter how many players there are?  

Or have you always tested it with 4 players?

Does the same thing happen with choppers, planes?

Could you use the knowledge of the fact that it multiplies it and plan on using the extra tanks?  (if they're in the same group)

hrm..  That's all the dust that came out of my brain..   ;)

Asmo
Title: Re:Createunit Trouble
Post by: Artak on 02 Apr 2003, 15:16:34
hehe, thanks for the input (sawdust) *cough* Asmo.

If I play the mission alone it's fine. If I play it with a friend of mine there can be from 2-4 bmp's when there's only supposed to be 1. Because I'm creating cwer for only 1 bmp it results to 3 empty bmp's and 1 manned.

I have a buttfeeling that the problem is worse when there are more players in game. Dunno why my butt is feeling things like this..

The problem occurs with every possible unit, vehicle or man.

Maybe I should somehow localize the script to execute it only on server or something, but I know nothing of these kinds of things  :-\

[edit]

at this point a nice enough moderator might want to move this to multiplayer editing  :D

[/edit]
Title: Re:Createunit Trouble
Post by: Artak on 05 Apr 2003, 11:07:31
ffs no-one knows?  :)

It's pretty clear to me now that my butt feeling was correct. I've tested the mission further and it seems that I can't localize a script no matter what I try.

The createunit and screatevehicle scripts are executed via a gamelogic [glname] exec "script.sqs" and I have in the beginning of every scrtipt ?!(local Server): exit which gives me no error but does me no good either.

Also I made a little arty script which camcreates 1 bomb in about every 7-12 seconds. So it does.. IF I play alone. Otherwise it creates as much bombs as there are players.  :P


I'm even beginning to think it's my computers fault or that I should reinstall ofp  :'(
Title: Re:Createunit Trouble
Post by: Igor Drukov on 05 Apr 2003, 16:30:13
I'm not much into MP editing, but shouldn't you try to create variables using the "publicvariable" command ?
Something like :
publicvariable "attackgrp2" ; that way, all computers should have the same "attackgrp2", rather than their own each.
Just a suggestion  :-\.
Title: Re:Createunit Trouble
Post by: Artak on 05 Apr 2003, 18:33:45
hmm..   :hmm:

 :wow: Oh yeah! Maybe I was thinking it the wrong way. Gonna go try it out  :)
Title: Re:Createunit Trouble
Post by: Artak on 17 Apr 2003, 15:53:34
It's been a while since last post but I wanted to tell you guys that I got the problem sorted.. both of them.

here's a fraction of my script now.
Code: [Select]
~0.5
   ?(local server): "SoldierEMG" createunit [getmarkerpos "vernon2", vernongrp2, "e9 = this"]
~0.5
   ?(local server): "SoldierEMedic" createunit [getmarkerpos "vernon2", vernongrp2, "e10 = this"]

      [vernonofficer2] join grpnull
~2

   ?(local server): etank2 = "bmp" createVehicle getmarkerpos "vernon2"
~1
   ?(local server): "SoldierECrew" createunit [getmarkerpos "vernon2", vernongrp2, "et4 = this"]

   ?(local server): "SoldierECrew" createunit [getmarkerpos "vernon2", vernongrp2, "et5 = this"]

   ?(local server): "SoldierECrew" createunit [getmarkerpos "vernon2", vernongrp2, "et6 = this"]

et4 moveincommander etank2
et5 moveingunner etank2

the ?(local server) in front of every command makes sure that that particular command is executed only on the server.  server is just a gamelogic, as gamelogics are always local on the server machine.

If no-one has anything to add to this I'll hit the solve button in a day or two.
Title: Re:Createunit Trouble
Post by: DrStrangelove on 17 Apr 2003, 16:30:24
How about your lag ? If i remember correctly the game loads textures & stuff into memory when a special unit is created the first time.

So spawning 3 tanks of same type should only lag when the 1st tank is created and almost no lag for the other 2 spawns. Did you recognize this ?

If so, it helps to place the units you'll need for all spawns in the editor somewhere and then delete them with a script or with deletevehicle in the init string. When the mission is started everything is loaded into memory at once, so no spawns will cause any lag because the units are already in memory.

comments / ideas ?
Title: Re:Createunit Trouble
Post by: Artak on 17 Apr 2003, 21:17:34
 :o omg is that what it is?!  :D

I have noticed the lag caused by the create commands, but I really hadn't gotten my finger on it.

I'm creating about 15 tanks and 100 soldiers in my mission with a script. They are pretty much the same types after the first few have been spawned. So after that it won't cause that annoying lag that it does when spawning the first ones.
I used a short time delay to 'smoothen' the lag. If I created 10 units I would put a short delay between all commands.

Now I know how to get rid of the bugger.

Great little tip DrStrangelove. Thanks  ;) :thumbsup:
Title: Re:Createunit Trouble
Post by: asmodeus on 18 Apr 2003, 00:59:00
Cool!   8)

Thanks!  This is very cool info to have!

Thanks Artak for posting your solution and thanks DrStrangeLove for that tip!

*Goes off to fix his mission using createunit tricks*

 8)

Asmo