Jump to content
Sign in to follow this  
SevenBEF

3 in 1

Recommended Posts

Hello!

I wondered if anyone would like to review my little tryout here. Didn't test it though cause I bet there must be some errors in there anyway & maybe someone even knows better ways to do this.

I have 4 Cobra's in a mission, so for helipads (pad1,pad2,pad3&pad4).

In their init field I would put [this] exec "repscript.sqs"

Meaning of the script would be repair, then refuel, then rearm.

Can someone correct my script? whistle.gif

Quote[/b] ]_chop = _this select 0

#loop

?(_chop distance "pad1" < 10):goto "repair"

?(_chop distance "pad2" < 10):goto "repair"

?(_chop distance "pad3" < 10):goto "repair"

?(_chop distance "pad4" < 10):goto "repair"

~10

goto "loop"

#repair

hint "repairing!"

?(getdammage _chop) == 0:goto "refuel"

hint "repairing"

_chop setdammage (getdammage _chop) -0.1

~3

goto "repair"

#refuel

hint "refueling!"

_chop setfuel (fuel _chop)+0.1

?((fuel _chop)==1):goto "rearm"

~2

goto "refuel"

#rearm

#step1

hint "rearming!"

?(_chop ammo "Bullet30" == 500): goto "step2"

_chop AddMagazineCargo ["MachineGun30", 5]

~0.2

goto "step1"

#step2

?(_chop ammo "Rocket57" == 38): goto "step3"

_chop addMagazineCargo ["MaverickLauncher", 2]

~1

goto "step2"

#step3

?(_chop ammo "TOW" == 8): goto "loop"

_chop addMagazineCargo ["HellfireLauncherCobra", 1]

~5

goto "step3"

ps: I'm not sure about the ammo used in the cobra's so if you can correct me there plz do so smile_o.gif as for the addMagazineCargo I based on the comref but dunno if that's a correct approach either :/

Any help appreciated!

Greetz notworthy.gif

Share this post


Link to post
Share on other sites

You only need to stay stay near the pad until the script starts, you might then take off and repair&refue&rearm while you're already en route to your objective because there's no further checks of distance to the pad. It's addmagazine, not addmagazinecargo. Clip of MachineGun30 is 500 rounds. unit ammo "MachineGun30"; returns the number of rounds left in the current magazine, not the total number of rounds. magazines unit; returns array of all the magazines unit has, including one empty one if it's out of ammo, you can use command 'count' to count them. I don't think that it's possible to fill empty magazine from a script. If it's the purpose to only have one mag you could do just removemagazine & addamagazine when you rearm.

I'm not sure but the script might get stuck on the repair bit if the setdammage allows negative values for vehicle damage. Like if it had damage of 0.123456 and you start to subtract 0.1 from that you don't end up to 0 but -0.023456 and the script would be stuck on a loop subtracting 0.1 forever. At least infantry units can have negative damage value.

Share this post


Link to post
Share on other sites

Any updates on this? (I know, I know, probably not).

I was looking for an auto repair script like this, but could not find one. I checked out OPF Editing Center, and have crawled the BAS_repair, USN Tarawa and LST54 addons. The scripts there are either not suitable for my mission, or they I simply can not find the auto service part.

What I would like to have as a helipad script is this:

If a Helicopter (it can also be a specific one) lands at Helipad or is very close to it, Refueling, Repairs and Rearming is processed sequentially at a given speed.

Regards,

wuschel

Share this post


Link to post
Share on other sites

where does this script fail for you?

It looks ok for fuel and repair.

What I see:

#step1

hint "rearming!"

?(_chop ammo "Bullet30" == 500): goto "step2"

_chop AddMagazineCargo ["MachineGun30", 5]

~0.2

goto "step1"

Problem with your script - is the ammo - has to equal max ammo for magazine to exit loop. Ammo - does not go down unless you squeeze off rounds or reload another magazine. So your doomed to loop.

Been away from scripting for a bit.

But below was something I was working on.

I had a version that worked - not sure if this is it or not...

oooops another function was needed to kick it off..

Well at least you can see what I did to get ammo reload.

;Script made for WH40K MOD Ver. 3

;Edited by WW2Weasel

;This script will count and replenish primary secondary weapon Mags for a unit.

;This will keep player stocked with 2 mags until the player exhausts number of mag allowance in ammopouch...

;[unit name,number of mags to put in ammo pouch script]exec "ammopouch.sqs"

;Be sure to preprocessFile the Function - important as the function needs to be handled differently then a script...

;Example: getmag=preprocessFile "getmag";[unitname,10] exec "ammopouch";

;Permission to modify granted... As long as you give some credit to WH40K mod.

_unit = _this select 0

_ammopouch = _this select 1

_ammopouch2 = 3

_mags={}

_mags2={}

#start

_primary_weapon = primaryWeapon _unit

_magcount = count magazines _unit

_magazines = magazines _unit

;hint format["%1,%2",player hasWeapon _primary_weapon,count magazines player]

?_ammopouch==0 || !alive _unit:exit

[_unit]call getmag

~5

?_unit==player:hint format ["%1",_mags]

_totalMags=("_x == _mags" count magazines _unit)

_totalMags2=(count magazines _unit)

?(_plysund &&(_totalMags <= 2 && _ammopouch >= 1)&&(_unit hasWeapon _primary_weapon && _totalMags2 <= 5)):_unit groupChat "Rummaging in Ammopouch for spare Mag.",playSound "rummagepouch",_unit addMagazine _mags, _ammopouch = (_ammopouch - 1)

~15

_plysund=true

?secondaryWeapon _unit != "":goto "start2"

goto "start"

#start2

?_ammopouch2==0 || !alive _unit:exit

_secondary_weapon = secondaryWeapon _unit

_magcount = count magazines _unit

_magazines = magazines _unit

[_unit]call getmag

~10

?_unit==player:hint format ["%1",_mags2]

_totalMags2=("_x == _mags2" count magazines _unit)

?(_plysund &&(_totalMags <= 1 && _ammopouch2 >= 1)&&(_unit hasWeapon _secondary_weapon && _totalMags2 <= 5)):_unit groupChat "Rummaging in Ammopouch for spare Missile.",playSound "rummagepouch",_unit addMagazine _mags2, _ammopouch2 = (_ammopouch2 - 1)

goto "start"

On the road traveling so might be awhile before I can reply again.

Edited by WW2Weasel

Share this post


Link to post
Share on other sites

Hello WW2Weasel,

thanks for Your help in that matter. I am going to try to implement these scripts in the mission I am currently making. Certainly, I will come back to You on that matter!

You have my thanks!

Cheers,

wuschel

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  

×