Home   Help Search Login Register  

Author Topic: cutscene linked to "fired" eh  (Read 1723 times)

0 Members and 1 Guest are viewing this topic.

abomb1508

  • Guest
cutscene linked to "fired" eh
« on: 07 Feb 2004, 12:02:32 »
this code is just the star of a ten second cutscene showing an mgunner shooting at a guy. the cutscene is suppoesed to be triggered by a "fired" eh:

setacctime 0.01

titlecut ["","white out",0.005]

_gunner = _this select 0
_gun2 = _this  select 1
_stu1 = _this select 2
_stu2 = _this select 3
_stu3 = _this select 4

_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

_cam camsettarget _gunner
_cam camsetrelpos [1,.5,.5]
_cam camcommit 0

titlecut ["","white in", 0.005]



there will be more to the cutscene, at the moment i'm focusing on the camera focusing on the gunner. problem is i get the white out, white in, camera created, but the camera's looking at sea and i get this error:

"_cam camsettarget _gunner; error 5 elements provided, 3 expected

what the hell does that mean, and how do i fix it? i haven't used eventhandlers before. but read the tutorial in the depot.

cheers,

A-bomb

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:cutscene linked to "fired" eh
« Reply #1 on: 07 Feb 2004, 13:27:12 »
You could try something like:

_cam camSetTarget getPos _gunner

camSetTarget needs three position parameters (x,z,y)


Planck
I know a little about a lot, and a lot about a little.

PsyWarrior

  • Guest
Re:cutscene linked to "fired" eh
« Reply #2 on: 07 Feb 2004, 18:22:49 »
Greetings a-bomb/ Planck

camSetTarget needs three position parameters (x,z,y)

Are you sure? I've been using camSetTarget with objects instead of 3 position arrays...  ???

As in "_cam camSetTarget player"

Certainly, camSetPos needs a x/y/z position, but AFAIK, camSetTarget can target objects or positions.

a-bomb, what is the contents of the _gunner variable? Put

hint format ["the gunner array is: %1", _gunner]

after setAccTime 0.01. Post up everything that appears after the colon. You should get something like "WEST Alpha Black 1" or "EAST Bravo Red 4".

I haven't actually seen the "x elements provided, y expected" error before for this command, so I'm guessing it's something to do with the contents of _gunner.

-Supreme Commander PsyWarrior
-Psychic Productions

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:cutscene linked to "fired" eh
« Reply #3 on: 08 Feb 2004, 00:52:48 »
You could be right PsyWarrior, but I was merely referring from the Comref........(first format)

Although there are two formats to the command, as I just noticed.

1./

camera camSetTarget position
Operand types:
    camera: Object
    position: Array
Type of returned value:
    Nothing
Description:
    Set camera target as position (format Position). Does not commit changes.

Example:
    _camera camSetTarget getPos player


2./

camera camSetTarget target
Operand types:
    camera: Object
    target: Object
Type of returned value:
    Nothing
Description:
    Set camera target. Does not commit changes.

Example:
    _camera camSetTarget player


So I imagine both work, but it depends what the object is I suppose.


Planck



.
I know a little about a lot, and a lot about a little.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:cutscene linked to "fired" eh
« Reply #4 on: 08 Feb 2004, 01:43:05 »
I spotted this question before anybody replied and did a quick bit of research to see if I could answer it:   I have an eventhandler question of my own kicking around at the moment so I have an interest.   Anyway, I couldn't - met the dead ends you guys have mentioned.

PsyWarrior is right:  we need to know exactly what _gunner is since that seems to be the root of the problem.    

I have seen this error message before, though not in this context.  It means exactly what it says on the tin - wrong number of elements/arguments.
Plenty of reviewed ArmA missions for you to play

DBR_ONIX

  • Guest
Re:cutscene linked to "fired" eh
« Reply #5 on: 10 Feb 2004, 18:52:33 »
Hmm, add _gunner = gunner (Or remove the _)
If the machine gunner is called gunner..
It's trying to target _gunner, when only gunner existis...
Maybe.. :)
- Ben

PsyWarrior

  • Guest
Re:cutscene linked to "fired" eh
« Reply #6 on: 11 Feb 2004, 14:49:52 »
Greetings DBR_ONIX,

_gunner refers to a local variable that a-bomb has created at the top of the script, and should work. I see your point, but a-bomb isn't trying to directly target a unit using his name.  ;)

What we really need to know is what is contained in the _gunner varible.  ???

-Supr. Cmdr. PsyWarrior
-Psychic Productions

abomb1508

  • Guest
Re:cutscene linked to "fired" eh
« Reply #7 on: 12 Feb 2004, 06:29:53 »
ok. i think i know what the problem is from reading your posts, but am not sure how to fix it. thanks for the feedback. this is my first usage of ehs, and after reading the tute on ehs, "this select 0" from the fired eh is "who fired". therefore the information given on "who fired" is obviously different to the information given when a unit's name is called. i will try with the "getpos gunner" call and see what happens. i do not want to simply call the man "gunner", or have to have a bunch of triggers with lots of parameters for each guy i want to use this script on. please keep up the feedback, it's very helpful.

Cheers,

A-Bomb

PsyWarrior

  • Guest
Re:cutscene linked to "fired" eh
« Reply #8 on: 12 Feb 2004, 13:50:32 »
Greetings,

Putting "Gunner" will only work either:
- with a vehicle (I.E. Gunner tank will return the gunner of the unit called tank)
- If there is a unit called "Tank".

You should be able to take the unit straight from the EH by using _this select.

Try putting the following line into your original script, after the titleCut:

hint format ["_gunner = %1", _gunner]

This will tell us what we need to work out your problem, hopefully. Start the mission. when the script executes, a hint should appear - tell us what it says.

Thanks,

-Supr. Cmdr. PsyWarrior
-Psychic Productions

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:cutscene linked to "fired" eh
« Reply #9 on: 13 Feb 2004, 00:04:25 »
We should nib this thing in the butt and ask how do you add the EH? And also when do you remove it? Because if you don't, it'll be going off and firing off this cutscene script at the rate of fire of an M60  ;)

Gunner is a reserved variable btw afaik. _gunner in this case seems to be some 5 element array instead of _this, the unit, in the addEventhandler command... where ever it is written. I can't come up with any such arrays.

An easier EHless way is to just use this line to let the script go on after the guy has fired:
@ (typeOf(nearestObject [m60guy,"m60ammotype"]) == "m60ammotype")
replacing m60ammotype with the actual m60 ammo classname, which I can't be arsed to remember if it indeed isn't M60mag or just bullet7_6 or something like that. Then there is the possibility that it will pick someone elses incoming bullets within 50m, that can be overcome with checking the distance of those to the m60guy. If it decreases after a delay, go back to that @ line. Well not so easy afterall is it  ;D

There's too much guessing here, you really need to give more info. Hmm the _this in this script also has 5 elements.
« Last Edit: 13 Feb 2004, 00:07:33 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

abomb1508

  • Guest
Re:cutscene linked to "fired" eh
« Reply #10 on: 13 Feb 2004, 07:52:05 »
elemants in the _gunner array are "WEST foxtrot red :1". therefore _gunner is being identified correctly. after changing

_cam camsetrelpos _gunner

to

_cam camsetrelpos getpos _gunner

i got part of the script working, didn't get the "3 elements expected" error, mis_fred is right though and i started to get epilepsy from the flashing white ins and white outs. nuts. and when it comes to the _cam camsetrelpos line, i get the error

error getpos: type boolean, expected object

but i guess that was expected. any more ideas? plus can you end the eh from the script? how?

again cheers for your help,

A-Bomb

PsyWarrior

  • Guest
Re:cutscene linked to "fired" eh
« Reply #11 on: 13 Feb 2004, 11:10:23 »
That's very strange...

If _gunner is a unit, then you should be able to setrelpos onto it. A quick note on cam commands:

camSetPos is usually a position

camSetRelPos is usually a unit (what's the point of setting relative position to a position?)

camSetTarget can be either.

What I really don't get is the "error getpos: type boolean..." line. the getPos command should return an xyz array, not a bool...  ???

Something's messed up here.

Let's see your eventHandler code and the entire script, please.
I'm shooting blind here, but what else can you do when the right commands return the wrong errors?  ::)

-PsyWarrior
-PsyProductions

P.S. I believe you can use the removeAllEventHandlers command to clear out EH's from a unit. Not certain, but it's something like that. AFAIK, it can be executed from a script.
« Last Edit: 13 Feb 2004, 11:12:42 by PsyWarrior »

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:cutscene linked to "fired" eh
« Reply #12 on: 13 Feb 2004, 15:26:39 »
Right after you define the 5 elements at the start of the script, put:
_gunner removeEventHandler ["fired",0]
Haven't used it too much, didn't remember that index thingy.

Quote
_cam camsetrelpos getpos _gunner

and when it comes to the _cam camsetrelpos line, i get the error
error getpos: type boolean, expected object
When you use camSetRelPos, first you need to camSetTarget _gunner. Then you camSetRelpos (camerasetrelativeposition), usually something like [5,5,5], 5m to the right, 5 infront, 5 above. I know getPos returns an equivalent array, but it will be something like [5555,5555,0], so that is nuts. CamSetRelPos command returns nothing, not even a boolean. Instead _gunner is now a boolean, not the object passed in. So change it to _gunnerunit or something else than _gunner just for fun.

So stick with your original code:
Quote
_cam camsettarget _gunnerunit
_cam camsetrelpos [1,.5,.5]
_cam camcommit 0

Another guess: the object "camera" is being overwritten by some funked up addon? Or the variable _cam. To be sure setAcctime after defining the 5 elements, maybe the EHs become invalid... Also if you have another camera script running, the camera of that should be terminated when this one is executed.
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

PsyWarrior

  • Guest
Re:cutscene linked to "fired" eh
« Reply #13 on: 13 Feb 2004, 16:31:20 »
:gunman:  :-[

Okay, My mistake (again).

Of course, camSetRelPos is a 3 array (xyz) which attatches the camera to whatever target you have selected with camSetTarget.

using GetPos on camSetRelPos arrays is not recommended, as it returns map co-ordinates (as MI_Fred stated) and not relative positions.

You could also use:
_cam camSetPos getpos _gunner

-or-

_cam camSetPos [(getPos _gunner select 0)+5, (getPos _gunner select 1)+5, (getPos _gunner select 2)+5]

That's if you don't want to target the _gunner.

If you do, camSetRelPos is probably better for you.

-PsyWarrior
-PsyProductions

abomb1508

  • Guest
Re:cutscene linked to "fired" eh
« Reply #14 on: 13 Feb 2004, 23:55:09 »
ok. the whole script is at the top of this topic, but i have removed the setacctime commands and adjusted everything accordingly for simplicity for now. plus the "_stu1" and so on local variables have been removed as they wont be used. the eh is called from the init line of an mgunner which is part of a squad:

this addeventhandler ["fired",{[this] exec "mgshot.sqs"}]

then things turn screwy. here's an update on my script:


titlecut ["","white out",0.5]
~0.5
_gunnerguy = _this select 0
_gun2 = _this  select 1

_gunner removeeventhandler ["fired",0]

_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

_cam camsettarget _gunnerguy
_cam camsetrelpos [1,.5,.5]
_cam camcommit 0

titlecut ["","white in", 0.5]

therefore the screen shot white out, then white in on the machinegunner that fired. hopefully i won't get the epileptic flashing now that the remove eh command is there, but somethings FUBAR.

Cheers,

A-Bomb

P.S i have CE2 running along with UA and several other scripts running in the background but this should do nothing but provide a little lag shouldn't they?