OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: CptBravo on 05 Jan 2003, 02:39:48
-
Hi everyone,
I checked for scripts for creating(respawning) groups and they work perfectly except for ..
I need one with:
a) a limited number of respawns (say will respawn only 5 times)
and
b)leave the dead bodies on the field instead of deleting them!
Now I know I could take those scripts and modify them, if I was a script guru that is which I am NOT!!!
So please any script gurus shed some light on how to limit number of respawns and leave the dead on the ground!!
Your help is greatly appreciated!! :)
-
try this script instead. You can use this single script to create soldiers for different groupnames and call it with triggers as many or as few times as you want. It won't delete dead bodies either. If you want it to run 5 times, simply trigger it 5 times.
-
Hi Crash,
At the risk of sounding not so bright, I had little sucess! lol
I did as you said but it kept me giving error msg "0 elements prodided 3 expected"
I am sure its something very stupid I have left out I just can't think what it is!
I have attached the mission if you should have time to look at it and tell me where I have gone I'd be super appreciative.
Thanks in advance :)
-
You gave the gamelogic a name gamelogic1, but in the trigger, you used the name logic1. It has to be the same. Also, you used an editor update I dont have so I just opened the sqm file with wordpad to find your error. You need to inform me of addons you are using so I can help you without getting errors when I try to open your mission. NP, easily solved...cheers.
-
hey Crash,
I feel like a fool! lol
It worked fine after I fixed my name mistake!
The only thing I need to ask iswhat is the best way to set the triggers ?
- Should I use 5 different logic names? use same one?
- Any simple way of say group 2 respawning ONLY after group one is all dead? As you see in the mission they respawned almost same time as 1.
I have included the mission this time with no addons.
Thank you very much for your help. I am in your debt :)
-
It depends on what you're trying to accomplish. I need to know more about the mission in order to figure the best way to set things up. You can create the same group over 5 times and forget the other groups if you want. Let me know what you have in mind.
-
Hey Crash,
what I am attempting to do with this script is reduce the lag. I wanted to have the west side defend a city against a huge attacking force of approx 500 men. As you can imagin the lag without using an AI respawn script.
The enemy will attack in waves. Say 5 groups a time.and when a group gets killed they are replaced with a new group and when the new group gets killed they get replaced with another one till all men are used.
The other quick question was, I saw how you added the group in the script. Now how do you add another group so you can have 2 different groups respawning Say AT group and infantry one? Do you use two seperate scripts for each group?
Thank you very much for you help.
-
I use this script for respawn AI ennemy units.
;[[E1,E2,E3,E4],100,2,10] exec "Respawn\RespawnUnits.sqs"
; [[array of your groups to respawn], number of total respawn, number mini of the group for start respawn, max number of the squad]
_ArrayGroup = _This select 0
? count _ArrayGroup ==0 : exit
_MaxOfRespawn = _This select 1
? _MaxOfRespawn == 0 : exit
_MiniNumberForRespawn = _This select 2
?_MiniNumberForRespawn > 12 : exit
_SquadDimension = _This select 3
? ((_SquadDimension > 12) or (_SquadDimension == 0)) : exit
_CurrentNumberOfRespawn = 0
#LoopOfRespawn
_i =0
#Ingroup
~.2
_NumberOfCreate = 1
#RespawnUnit
? count units ( _ArrayGroup select _i) >= _SquadDimension : goto "SkipRespawn"
_pos = getPos leader ( _ArrayGroup select _i)
_dir = getDir leader ( _ArrayGroup select _i)
~.5
_dist = -30
_x = (_pos select 0) + _dist * sin _dir
_y = (_pos select 1) + _dist * cos _dir
;nobody globalchat format ["%1, %2,%3",_CurrentNumberOfRespawn,_ArrayGroup select _i, count units ( _ArrayGroup select _i) ]
? _NumberOfCreate ==1 : "SoldierEMG" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate ==2 : "SoldierELAW" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate ==3 : "SoldierEMedic" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate ==4 : "SoldierEG" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate > 4 : "SoldierEB" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
NouvelleUnité addEventHandler ["Killed", "[_this select 0] exec ""Respawn\RemoveKill.sqs"""]
_CurrentNumberOfRespawn = _CurrentNumberOfRespawn +1
? _CurrentNumberOfRespawn >_MaxOfRespawn : exit
_NumberOfCreate = _NumberOfCreate +1
? count units ( _ArrayGroup select _i) < _SquadDimension : goto "RespawnUnit"
#SkipRespawn
_i = _i + 1
? _i < count _ArrayGroup : goto "Ingroup"
? _CurrentNumberOfRespawn <_MaxOfRespawn : goto "LoopOfRespawn"
-
I don't think you can do that many units without deleting dead bodies. If the attacking force is going to be 500, then the defending force will have to be a very large number also. After a hundred dead units are littering the city, lag is going to grind the mission to a halt. Regardless of how you setup the creation of the units, you're going to have to delete dead bodies. Maybe you should use something like my original tutorial, and just set the mission to run a certain length of time ?
-
NouvelleUnité addEventHandler ["Killed", "[_this select 0] exec ""RemoveKill.sqs"""]
Script removeKill.sqs
_Remove = _this select 0
_Remove removeAllEventHandlers "Killed"
@ RemoveKill
deleteVehicle _Remove
For the global variable removeKill you can manage with time or number of unit
-
Hey Crash,
You're right! The game does start laaaaaging after 200-300 dead units depending on size of map. So I guess I'll have to use the delete.
Two questions regading delete:
a) Can I use the delete with the limited respawn I have now. For example like the script I have now, respawn the squad once but have them deleted when dead.
b) Can you use it, say with 200 units? Have two scripts, the one without the delete for the 1st 200 then the delete one for over 200?
c) finally, how do you respawn different groups? Such as AT squad, infantry or AA squad?
Thank you for your great help.
Hi uiox, I didn't get a chance to test your script. I'll do it tonight.
Thank you very much.
-
Here's a couple different scripts that create different groups and deletes the bodies when all are dead. Call the scripts same as before using [gamelogicname, groupname] exec "scriptname.sqs". Try these and let me know if you need anything else.
-
Hey Crash,
I have got it!! :)
I have finsihed my mission and it works PERFECTLY!!
I have used both of your scripts, the one without delete at first for the first 100 units or so for realism then I switched to the one with the delete to reduce lag. So now I have my huge battle with enough dead bodies, lots of soldiers and fire power to put to shame all of the Rambo movies!! :)
So thank you for your help!
Just a quick question, is there any way to umm .. make the enemy soldiers less skilled? It seems the one respawned are too good at taking me out from 400-500 meters distance!!
In the editor you usually can play with the skill slider. Is there any line to add to the script to control how good of a shot the enemy will be?
Again thanks!
-
Hey uiox,
Your script seems impressive but honestly as you can tell, I am no scripting guru :(
I have tried to use it but was not sure how or what is does exactly.
Maybe an example mission might good :)
Thanks.
-
When you are creating a unit with the createUnit command you can set the initial skill of the unit, so you can create units with lesser skills
-
Hi,
The question I had was how to set the initial skill of the unit in the first place? What line do I need to add to the script to change the skill level?
Thanks
-
How can you make it to make the group respawn after the group is eliminated?
Ottie change the number from 1 in the script to .1 . That makes them less experienced.
-
CptBravo, and Chills
I don't know which script you are using but I changed the following script;
It has lesser skills and respawn when al units have died
_pos = _this select 0
_grp = _this select 1
#Begin
"OfficerE" createunit [getpos _pos,_grp,"",0.5,"LIEUTENANT"]
"SoldierEMG" createunit [getpos _pos,_grp,"",0.5,"SERGEANT"]
"SoldierEG" createunit [getpos _pos,_grp,"",0.5,"CORPORAL"]
"SoldierEB" createunit [getpos _pos,_grp,"",0.5,"CORPORAL"]
"SoldierEB" createunit [getpos _pos,_grp,"",0.5,"PRIVATE"]
"SoldierEMedic" createunit [getpos _pos,_grp,"",0.5,"PRIVATE"]
~1
_units = units _grp
_grp setformation "LINE"
"_x allowfleeing 0" foreach _units
#loop
?(("Alive _x" count _units) == 0): "deletevehicle _x" foreach _units; goto "Begin"
~random(10) + 10
goto "loop"
-
How can you make it to make the group respawn after the group is eliminated?
If you respawning units of a group and avoid complete destruction use Ottie's scripts before the complete destruction.
-
Thanks Ottie! That is exactly what I was looking for. I always wonderd what that '1" stood for!! :)
Hey Chills, I'm using CrashnBurn respawn script.Great script for keeping the enemy coming for more!! :)
You can download it from this site. If you can't find it let me know and I'll attach it.
Thanks
-
I cant seem to find it. Do you get the lag when they respawn? And did you notice in multiplayer that after a while it stops respawning?
-
here you go, the CrashnBurn script to respawn AI and delete them after death.
I have not had any lag with this script and I respawned over 400 enemy units in my mission! And that was a MP mission and it seemed to work as it is supposed to.
Thanks
-
Thank you! This is great! Is there a script like this for Vehicles? I need it for my Dynamic Battles!
-
I think you can use the same script for vehicles. Just change the soldiers with whatever unit you need. I have not tried it but I think it would work.
-
You can call the scripts without using gamelogics as a spawn position if you want. Just use the trigger that you are calling the script with by giving it a name in its name box, and use that as the position for spawning the units. Remember the centermost point of the trigger is where the units will spawn so place the trigger carefully. It just lets you skip having to place gamelogics around the map. The less things you place in the editor, the quicker the mission loads. example-
[triggername, groupname] exec "create.sqs"
You can use a script like this for vehicles and create new ones when they can no longer fire or move depending on what kind of vehicle it is.
example- assumes group name is east1, and triggername is used as spawn location.
[trigger1, east1] exec "createvehicle.sqs"
;-----------------------------------------------------------------------
#start
_pos = _this select 0
_grp = _this select 1
_crew = units _grp
"_x allowfleeing 0" foreach _crew
#loop
?(("Alive _x" count _crew) < 3): goto "create"
? NOT(canfire _tank): goto "create"
? NOT(canmove _tank): goto "create"
~random(5)
goto "loop"
#create
? NOT(alive player): exit
_tank setdammage 1
~1
"deletevehicle _x" foreach _crew
;wait 75 seconds for smoke to stop
~75
deletevehicle _tank
~random(10)
_tank = "T80" createvehicle getpos _pos
~1
"SoldierECrew" createunit [getpos _pos, _grp, "c1 = this", 1, "SERGEANT"]
"SoldierECrew" createunit [getpos _pos, _grp, "c2 = this", 1, "CORPORAL"]
"SoldierECrew" createunit [getpos _pos, _grp, "c3 = this", 1, "PRIVATE"]
~1
c1 moveincommander _tank
c2 moveingunner _tank
c3 moveindriver _tank
goto "start"
;-----------------------------------------------------------------------
-
Thank you! Im off to try it!
-
It works! Great one!
-
A tip for really creates new groupS.
If a group is destroy you need a predefined group for creates it.
Something like that :
"logic" createUnit [ PosUwant ,PreCreateGroup ,"NewUnit = this"]
After U join NewUnit to a group null
[NewUnit] join grpNull
And create a new group
_NewGroup = group NewUnit
After You can do that for build the new group
"logic" createUnit [ PosUwant ,_NewGroup ,"NewUnit = this"]
Note: I'm working on scripts for "restart" system:
Part 1 : infantry
Transition : delete infantry, create armored
Part 2 : armored
With this I can design a mini campaign in a mission.
-
uiox,
maybe this is a better solution, (I haven't tried it)
"logic" createUnit [ PosUwant , grpNull ,"NewUnit = this"]
-
Not work, I have test different solutions during 4 hours. It's one of the first I have try.
But sometime you don't do the good sequence.
It's hard to test cause OFP when you are wrong it does nothing (no error ans no unit creates).
Maybe a solution with grpnull...