OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco on 07 Jun 2004, 19:19:12

Title: reload trouble
Post by: Blanco on 07 Jun 2004, 19:19:12
Hello, I'm working on a cover & hold script using those new ICPanims from the VDV2.0 effectpack.
The reason why I want to use them is :

- They look cool.
- Different from all the other custom anims I've seen, AI is able to turn and shoot! (with all respect to all the other animators, but these can be used in a mission and not only for eyecandy)
- You can kill them, A deadly shot is followed by a default death animation.

I could find only one nasty bug : They can't reload while they're in the pose.
So I thought... maybe this can be solved with some scripting, so I did.
You can easily break the animation with _unit switchmove "" but it doesn't look good. So I made it so the animation between look as smooth as possible.
Code: [Select]
;test.sqs
; run it with [this] exec "test.sqs" in the init of your AIunit.

_unit = _this select 0

#start
_wep = (weapons _unit select 0)
_mag = (magazines _unit select 0)
_crposes = ["ICPaim1","ICPaim2","ICPaim5"]
_cc = count _crposes
_cr = random _cc
_cr = _cr - _cr % 1

_unit switchMove (_crposes select _cr)

#ammocheck
;;###DEBUG###
;hint format ["%1",_unit ammo _mag]
?_unit ammo _mag < 1 :goto "Reload"
~1
goto "ammocheck"
 
#Reload
;### DEBUG ###
;player globalchat "reload"

_unit setunitpos "UP"
_unit switchmove "crouchtocombat"
~1
_unit switchmove ""
_unit addmagazine _mag
@_unit ammo _mag > 1
_unit switchmove "Combattocrouch"
~0.5
goto "START"

This works great with the BIS soldiers but not with addons like BAS, MAP,...
When I use addons the script jumps directly to the #reload label, so I guess there's something wrong with the ammocheck loop.
I really want to find this problem so I can use it with every addonsoldier. My final goal is to create a cover & hold script where AI is able to shoot from buildings and even change their position(floor) in a random period. But first I need to solve that nasty reloadbug... :angry:

Any1 knows what wrong with it?

you can find the anims HERE (http://www.edgefiles.com/files/14512.html)
They work with any unit (you don't need VDV2.0) but they look best with the VDV.20 troops.Great stuff!
Title: Re:reload trouble
Post by: Unnamed on 12 Jun 2004, 00:21:58
Glad to see someone has finaly made some fixed crouch anims that work properly. I'm no animator, so I could never work out how to removed the foot prints and foot step sounds from the original BIS crouch anims.

You could try using the SomeAmmo command, as fas as I know this will return true when the AI are getting low on ammo.
Title: Re:reload trouble
Post by: Homefry31464 on 12 Jun 2004, 03:28:47
From the Official Com. Ref.

someAmmo unit
Operand types:

    unit: Object
Type of returned value:
    Boolean
Description:
    Check if unit has some ammo.

Example:
    someAmmo vehicle player
I'm just guessing/rambling, but maybe you could try this:

Code: [Select]
#ammocheck
_shotsleft = _unit ammo _mag
?_shotsleft == 0 : goto "Reload"
~1
goto "ammocheck"

It seem's that using the _mag = (magazines _unit select 0) will make _mag an array.... maybe its including handgun magazines as well.  Not sure why that would effect anything, but try removing their handgun's and the related ammo first.

Good luck.
Title: Re:reload trouble
Post by: Blanco on 14 Jun 2004, 23:08:30
thx 4 replies,

I tried the someammo command, but it seems to work only with vehicles.
Anyway I could fix it with a temporaly EH fired.
Once the unit fires, I store the _muzzle in a variable,
_Muzzle = _this select 2
Once I have it, i remove the EH.

Then I run my ammocheck script with that muzzle variable.
Works great, except for Units with rifles with attached grenadelauchers or mortars...  :P

Code: [Select]
[_muzzle] exec "ammocheck.sqs"

_ammotype = _this select 0


....
#ammocheck
;;###DEBUG###
;hint format ["%1",_unit ammo _ammotype]
?_unit ammo _ammotype < 1 :goto "Reload"
~1
goto "ammocheck"
...

The script is done, right now I making a cool mission with it.

here are some pics btw,

Swifty aiming outta the window (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/SWIFTY2.jpg)
Swifty got contact (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/SWIFTY1.jpg)
Roy (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/ROY.jpg)
Ice and Lester ready to fire (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/ICE-LESTER.jpg)
4Eyes giving the best of himself  (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/FOUREYES.jpg)
Eagle aiming for a headshot  (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/EAGLE_EYE.jpg)
BEAST getting the time of his life (http://img75.photobucket.com/albums/v228/blanco2/COVERANDHOLD/BEAST.jpg)

These are all AI units running the ICPanim with my C&H script.
Very cool to fight against.