Home   Help Search Login Register  

Author Topic: Unit replication script: Its going out of control.  (Read 4531 times)

0 Members and 1 Guest are viewing this topic.

Baphomet

  • Guest
Unit replication script: Its going out of control.
« on: 19 Oct 2002, 03:41:47 »
Well. I've made this script. I sort of don't know what I'm doing so if something doesn't make sense its my fault =P. Basically I want to make a script wherein a marker named "manmake" spawns the unit civilian7 until there are six of them then stops (It currently creates them indefinitely). I plan on doing something else with it after that point however I can't even get this to work so I'm going to take baby steps here.


Heres the atrocity in question

_marker = "manmake"



#man
?(civilian7>6):goto"noman" //I don't know how to specify that if there are more than 6 of "Civilian7" then goto"noman"
~2
_theman="civilian7" createvehicle getmarkerpos _marker
goto"man"



#noman
?!(civilian7>6):goto"man"
~6
goto"noman"

A5hley

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #1 on: 19 Oct 2002, 04:05:05 »
Ok this wont check that there is 6 units but it will only create 6.

Code: [Select]
_marker = "manmake"
_c1 = 0

goto "start"

#reset

_c1 = _c1 + 1
? _c1 > 6 : goto "end"

#start

_theman="civilian7" createvehicle getmarkerpos _marker

goto"reset"

#end

Exit


What this does is create a varible (or somthing like that) called c1 with 0, then it is redircted to the start of the script where u add the man. Then after u added the unit,  it is directed to reset, it then adds 1 to the c1 so now it has the value of 1.
The script then checks if c1 is not greater than 6 and continues with the script.
If the script checks ad finds c1 is greater than 6 it will end the script.

Hope that helps, if u dont understand the script i used say so and ill explain it further, bit l8 now lol




« Last Edit: 19 Oct 2002, 04:05:58 by A5hley »

Baphomet

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #2 on: 19 Oct 2002, 04:16:25 »
Hm. Yeah, see I need this script to run continuously. It will end up becoming a script that spawns six guys. Checks for the maximum amount of guys alloted '6' then makes 6 more when there is no longer 6. For a multiplayer map I'm making. You make money various ways. One of which moving into a town, and leading these civilians into a specific location and then converting them into cash. I dunno what I'm going to call it. It sounds like a death camp of some sort, now that I think about it. Although that certainly wasn't the idea. Just an interesting way to make money.

Imagine all the fights players would get into trying to secure these civilians for themselves. Heh.
« Last Edit: 19 Oct 2002, 04:52:31 by Baphomet »

A5hley

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #3 on: 19 Oct 2002, 04:25:36 »
Well u could use a trigger that activates this script everytime the 6 guys are dead, so then it respawns six more, but that would only work if u want all six to be dead beofre respawning another 6.

Baphomet

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #4 on: 19 Oct 2002, 05:03:02 »
Just out of curiousity what does _c1 represent? Aside from an integer '0'. How would the script differentiate between whether there was 6 soldiers or six civilians?

Offline KTottE

  • Former Staff
  • ****
Re:Unit replication script: Its going out of control.
« Reply #5 on: 19 Oct 2002, 09:24:34 »
The only part which controls what kind of unit is spawned is this here line:

_theman="civilian7" createvehicle getmarkerpos _marker


If you want a different unit type, you put something other than "civilian7".
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Unit replication script: Its going out of control.
« Reply #6 on: 19 Oct 2002, 10:05:09 »
i think u beter use da createunit command - cuz units dat r created wid createvehicle dont have AI

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline KTottE

  • Former Staff
  • ****
Re:Unit replication script: Its going out of control.
« Reply #7 on: 19 Oct 2002, 10:15:00 »
*slaps his forehead*

Yeah, didn't even think about that LCD. Good point.

"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Baphomet

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #8 on: 19 Oct 2002, 21:39:19 »
Hm. Okay well use createunit instead of createvehicle. That helps. I still don't know how to script something that tests for how many civilian7 units have been spawned and then jump to another part of the script. Test again and if the value is beneath six, jump back.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Unit replication script: Its going out of control.
« Reply #9 on: 20 Oct 2002, 00:56:32 »
if u r usin da createunit command it can b like dat

Code: [Select]
_marker = _this select 0
_unittype = _this select 1
_groupname = _this select 2
_side = _this select 3

#loop
_unittype createunit [getmarkerpos _marker, _groupname]
? _side countside units _groupname > 5 : goto "check"
~0.5
goto "loop"

#check
? _side countside units _groupname < 6 : goto "loop"
~0.01
goto "check"

exec it like dat

["MarkerName","UnitType",GroupName,UnitsSide] exec "nameofscript.sqs"

- just 4 example - in da case u r giving here

["manmake","civilian7",GroupName,civilian] exec "nameofscript.sqs"

cuz of da limits of da createunit command u have 2 have a group dats da created units r spawned into - so @ da start dere should b 1 unit of da type u want wid da next init

groupname = group this

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Baphomet

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #10 on: 20 Oct 2002, 02:55:41 »
I think I sort of understood and then I was completely lost when _marker changed from _marker=manmake. To _marker= _this select 0. _marker=manmake indicated that the marker referred to in the script was one in the map called "manmake". I have no idea what it means now. I don't know what the _this select x stuff does let alone the values that follow it.

This: ["MarkerName","UnitType",GroupName,UnitsSide] exec "nameofscript.sqs" Seems like more work than is necessary. I don't know why you can't just exec the script in the init.sqs file and forego all that?

I don't even know where in that script it says anything about spawning a civilian7 unit... Fuck. Something that originally started as simple has now become impossibly convoluted.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Unit replication script: Its going out of control.
« Reply #11 on: 20 Oct 2002, 03:49:19 »
:wow:
LOL

if u donno wat _this select 0 means - its bout time u learn  ;D  ;)

in myscript u can use da same script on every situation u wil need it - but in ur way u wil need 2 create a new script each time - wen u give parameters 2 da script in da array like [man,car,etc] exec "nameofscript" - da script can read em - da first parameter u give is _this select 0 da second is _this select 1 nd continuing  ;D

so wat i do is get parameters from ur exec line nd make da script work wid em  ;D

Code: [Select]
; geting parameters from exec line
_marker = _this select 0 <----first parameter in exec line
_unittype = _this select 1 <---- second parameter in exec line
_groupname = _this select 2 <---- third parameter in exec line
_side = _this select 3 <---- fourth parameter in exec line

#loop
_unittype createunit [getmarkerpos _marker, _groupname] <---- Creates unit in da position of da first parameter nd join it 2 da group
? _side countside units _groupname > 5 : goto "check" <---- checks if da group have more dan 6 members - if so goes out of loop
~0.5 <---- waits 0.5 seconds
goto "loop" <---- loops

#check <---- breaks from da main loop, enters secondry loop
? _side countside units _groupname < 6 : goto "loop" <---- checks if da group have less dan 6 units, if so goes 2 main loop
~0.01 <----waits 0.01 seconds
goto "check" <----- continue wid secodry loop

nd dis is a simple script  :P  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Baphomet

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #12 on: 20 Oct 2002, 04:19:06 »
Aaaand, I still don't get the purpose of _this select 0. What it does or why it needs to be there. I'd look at the comref regarding that, however flashpoint1985's page is usually so unreliabe I can't access it half the time.

I understand a little more as to why you use this  ["MarkerName","UnitType",GroupName,UnitsSide] exec "nameofscript.sqs" to exec the script

However, my way is simpler in terms of undertsanding, It may not be functional. However for the most part I understand what each and every part does (or is intended to do). I think I'm already way in past over my head. Creating multiple scripts suits me fine so long as they're at the elementary level of scripting, which is all I can understand right now.  All I wanted was a way to test if there was a particular unit was in a certain quantity. Now I'm left with more questions than answers...



Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Unit replication script: Its going out of control.
« Reply #13 on: 20 Oct 2002, 04:43:47 »
k i can make it simpeler  :P

Code: [Select]
#loop
"civilian7" createunit [getmarkerpos "manmake"
, groupname]
? civilian countside units groupname > 5 : goto "check"
~0.5
goto "loop"

#check
?  civilian countside units groupname < 6 : goto "loop"
~0.01
goto "check"

u stil have 2 create group nd name it groupname (or nything else - as long as u change da script  ;D)

dats it

LCD OUT

P.S - if ny1 who do understand my previous script can try explainin wat i did - PLZ explain  ;D
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Baphomet

  • Guest
Re:Unit replication script: Its going out of control.
« Reply #14 on: 20 Oct 2002, 05:50:20 »
Sounds easy enough. Only thing is. Aside from making groups using the groups tab in the editor. I wouldn't know how to create a group, let alone being able to name it.

This must be a lot of work you guys trying to explain all this to me. However in all fairness a lot of this I've been shown is the first time I've really seen it. So my apolgies if I'm a bit dumbfounded at all this information being crammed into my head at once.