Jump to content
Sign in to follow this  
x582gr51

vehiclespawn  error>

Recommended Posts

I'm working on a mission using a vehicle spawning script but i get this error:

Error

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

'_gunner = units _group select (count units _group -2)|#|': Error Zero divisor

init

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

init="[this,2,500,sp_2] exec ""vehiclespawn\mechInfSpawnAI.sqs""";

script

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; ***************************************

; mechanized infantry spawn script by Spankmeyer. original script was vehicle.sqs from i think

; General Barron. so most of the code was his! i just tweaked around and made it compatible

; with spawnman-script from Dr Strangelove!

;

; consider this script as part of the Spawnman scripts! without them it wont work!

; THIS ONE WORKS WITH AI. USE ONLY FOR EAST-GROUPS!

;

; easy example: put a group of infantry together with a vehicle a on your map (all must be grouped together!)

; and write in init-field of vehicle: [this, 2, 100] exec "vehicleSpawn\mechInfSpawnAI.sqs"

; the group will be respawned twice at original position of vehicle and will patrol around

; this position with a radius of 100. respawn will occur two times if vehicle was destroyed.

;

; put a group of infantry together with a vehicle a on your map (all must be grouped together!)

; and write e.g. [this,2,150,patrolpos,spawnpos] exec "vehiclespawn\mechInfSpawnAI.sqs" in the

; init field of vehicle.

; it means: this vehicle (and the infantry) will be spawned two times at spawnpos

; and it will patrol around patrolpos at a radius of 150m.; (except they have detected enemys (YOU!).

; then they will hunt them! (again YOU!)

; last parameter (spawnpos) is optional!

; if nothing is written here, they will spawn at original position.

;

; [obj,j,range,patrolpos,spawnpos] exec "vehiclespawn\mechInfSpawnAI.sqs"

; parameters: obj is vehicle (e.g.tank of mechanized infantry squad)

; J is number of respawns

; range is range of patrol around patrolpos.

; patrolpos(optional) is position for randpatrol-script used here.

; spawnpos (optional) position where respawns occur. if empty, original pos is used.

; ***************************************

requiredVersion "1.91"

? not local Server : exit

~(random 1) +0.5

_obj = _this select 0

; j is number of respawns

_j = _this select 1

; the next two parameters are for use in the randpatrol-script.

_range = _this select 2

;the next parameter is the patrolpos(optional) if nothing, then it patrols around its orig pos

;u could use moving or "teleporting" patrolpositions...

?(count _this > 3):_patrolpos = _this select 3

?(count _this <= 3):_patrolpos = _obj

;the next parameter is the respawnpos (optional).u could even use moving or "teleporting" spawnpositions...

?(count _this > 4):_pos = getpos (_this select 4)

?(count _this <= 4):_pos = getpos _obj

; **************define some initvars for later use***********

_dir = getDir _obj

_type = typeOf _obj

_group = group _obj

_teamscale = count units _group;

_spawncount = 0

_crew = []

_inf = []

"_crew = _crew + [typeOf _x]" forEach crew _obj

; **************************build infantry-array*************

_grparray = units _group

_n = count _grparray

_i = 0

#infarray

?(_i >= _n): goto "zeigmal"

_unit = _grparray select _i

?(vehicle _unit != _unit): _i = _i + 1; goto "infarray"

_inf = _inf + [typeof _unit]

_unit exec "spawnman\patroldead.sqs"

_i = _i + 1

goto "infarray"

; ***************************************TEST

#zeigmal

;_zeigmal = count _inf

;hint format ["Number Of inf: %1", _zeigmal]

; ***************************************

"_x addEventHandler [""Killed"", {(_this select 0) removeAllEventHandlers ""Killed""; deleteVehicle (_this select 0)}]" forEach crew _obj

;this is a bit complicated: if a patrolpos-parameter is given, a dummy-parameter ("1") is given to

;randpatrol. this dummy-parameter makes randpatrol updating the patrolpos in every loop. (if one

; wants to "move" the patrolpos for any reason...)

if(count _this > 3)then{[_group,_range,4, _patrolpos,1] exec "spawnman\randpatrolAI.sqs";goto "clear"}

[_group,_range,4, _patrolpos] exec "spawnman\randpatrolAI.sqs"

#clear

_t = 0

#alive

~3

? not alive _obj : _delay = 60; goto "notalive"

; ******************part for remanning guns of vehicle*********************

?!(alive gunner _obj) and (count units _group >= count _crew): goto "mangun"

; **********************test

;_countgrp = count units _group

;hint format ["Number Of grp: %1", _countgrp]

; ***********************

? fuel _obj == 1 : goto "clear"

;? count crew _obj != 0 : goto "clear"

?(alive driver _obj) and (count units _group >= count _crew) : goto "clear"

? _t == 0 : _t = _time + 30

? _t > _time : goto "alive"

"_obj removeMagazine _x" forEach magazines _obj

_obj setFuel 0

_obj setDamage 1

_delay = 10

#notalive

;****update respawnpos (if spawnpos is moving or "teleporting".)

?(count _this > 4):_pos = getpos (_this select 4)

; *******************script will end if j = spawncount***************

? (_spawncount == _j) : EXIT

_spawncount = _spawncount + 1

; ***************************************

~_delay

deleteVehicle _obj

~1

_obj = _type createVehicle _pos

_obj setDir _dir

; ***************************************spawn vehicle-crew******************

? count _crew < 1 : goto "spawninf"

Soldier = []

_crew select 0 createUnit [_pos, _group, "Soldier = this"]

Soldier moveInDriver _obj

Soldier addEventHandler ["Killed", {(_this select 0) removeAllEventHandlers "Killed"; deleteVehicle (_this select 0)}]

? count _crew < 2 : goto "spawninf"

Soldier = []

_crew select 1 createUnit [_pos, _group, "Soldier = this"]

Soldier moveInGunner _obj

Soldier addEventHandler ["Killed", {(_this select 0) removeAllEventHandlers "Killed"; deleteVehicle (_this select 0)}]

? count _crew < 3 : goto "spawninf"

Soldier = []

_crew select 2 createUnit [_pos, _group, "Soldier = this"]

Soldier moveInCommander _obj

Soldier addEventHandler ["Killed", {(_this select 0) removeAllEventHandlers "Killed"; deleteVehicle (_this select 0)}]

; ***************************************spawn infantry ******************

#spawninf

?(count units _group >= _teamscale): goto "clear"

;type of spawned unit will be chosen randomly from _inf-array...

_unit = _inf select 0 + (random(count _inf))

;***********testing**********

;hint format["typ %1", _unit]

;****************************

_unit createUnit[_pos, _group, "this exec {spawnman\patroldead.sqs}"]

~(random 1) + 1

goto "spawninf"

; ***********************part for remanning guns of vehicle(if any)********

#mangun

_gunner = units _group select (count units _group -2)

_gunner assignAsGunner _obj

[_gunner] orderGetIn TRUE

~10

;@(_gunner in _obj) OR !(alive _obj) OR (count units _group == 0)

goto "alive"

it's all infos i can supply for now if you need more then i can send the mission.sqm.

Share this post


Link to post
Share on other sites

nm, after a few hours sleeping, i found the simple error.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×