Home   Help Search Login Register  

Author Topic: Spawned C130 acted weired  (Read 1481 times)

0 Members and 1 Guest are viewing this topic.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Spawned C130 acted weired
« on: 15 Sep 2010, 07:31:45 »
First thing first: in my mission there is a not-spawned C130, who can land without problem. But I need more C130 in the middle of the mission (it's just scenery, but cool), so I created a spawn script... I created the new C130 in the same location and same direction as the original one, but the new one act weired.

I attached the sample (test) mission with the spawn script.
If you just run it, the plane glide (the pilot don't start the engine) to near the airport, but - because he reduce the speed for landing - just fall down a few hundred meters front of the termic.
BUT, if you remove the comment ( ; ) sign before: player moveincargo _plane
and you will be teleported into the new C130, the pilot START the engine and then he can land smoothly.

Can anybody help me to solve this without teleporting the player into the plane?
Fix bayonet!

Offline F2kSel

  • Members
  • *
Re: Spawned C130 acted weired
« Reply #1 on: 15 Sep 2010, 20:20:16 »
Strange I've not seen that before and it didn't happen the first few times I ran it.

There is an easy fix though, or at least it's not happened since.

_pilot action ["engineOn", vehicle _pilot]  placed after the other action command.

I made a few other changes while I was testing which you may or may not want.

I removed the first spawn from the init.  

I then place the call code in the game logic  init  [this] exec "createC130.sqs" and then change a few lines in the script.

What happens now is that every time you create game logic and put the call code in it you get an aircraft spawned.

Code: [Select]
_planspawn = _this select 0

_dropPosX = getPos _planspawn select 0
_dropPosY = getPos _planspawn select 1
_dropPosZ = getPos _planspawn select 2
~0.1
_planespawnpos = [_dropPosX, _dropPosY, _dropPosZ + 1000]
_pilotspawnpos = [_dropPosX, _dropPosY, _dropPosZ + 1000]

;=========CREATE=======================
~0.1
_plane = "C130J_US_EP1" createvehicle _planespawnpos
_plane setpos [(getpos _plane select 0),(getpos _plane select 1),900]
_plane setDir getDir _planspawn

_group = createGroup WEST;
_pilot = _group createUnit ["US_Soldier_Pilot_EP1",getPos player, [], 0, "FLY"];
_pilot setBehaviour "CARELESS";
_pilot setRank "SERGEANT";
_pilot setskill 1;
_group selectLeader _pilot;

_dir = getDir _planspawn
_speed = 100
_plane setVelocity [(sin _dir*_speed),(cos _dir*_speed),1];
_plane allowDamage false

~0.1
_pilot assignAsDriver _plane
_pilot MoveInDriver _plane
_pilot setdamage 0
_pilot setBehaviour "CARELESS"
_pilot action ["gear_up", vehicle _pilot]
_pilot action ["engineOn", vehicle _pilot]

;player moveincargo _plane

_plane FlyInHeight 100
_plane SetSpeedMode "full"
_plane landAt 1

_n = 0;
#loop1
_n=_n+1;
_pilot setBehaviour "CARELESS"
_plane setpos [(getpos _plane select 0),(getpos _plane select 1),100]
_plane setVelocity [(sin _dir*_speed),(cos _dir*_speed),1];
~0.1
?(_n>20) : goto "exit1"
goto "loop1"
#exit1



_plane SetSpeedMode "normal"
_plane flyInHeight 20
_plane landAt 1


  
« Last Edit: 15 Sep 2010, 20:24:00 by F2kSel »

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Spawned C130 acted weired
« Reply #2 on: 16 Sep 2010, 07:40:27 »
Thank you for helping me!

Quote
Strange I've not seen that before and it didn't happen the first few times I ran it.

It's mean: you tried my sample mission and never fall down the C130? Or in the first few try land smootly, but later happened the disaster in your ArmA too?


Quote
_pilot action ["engineOn", vehicle _pilot]  placed after the other action command.

Thanks! I'll try it tonight.

Quote
I made a few other changes while I was testing which you may or may not want.
I removed the first spawn from the init. 
I then place the call code in the game logic  init  [this] exec "createC130.sqs" and then change a few lines in the script.

I don't understand: it works for you, why did you do this changes?


Quote
What happens now is that every time you create game logic and put the call code in it you get an aircraft spawned.


I have to run this script from an other script triggered a trigger in the middle of the mission (several minutes after start - but it depends on player's speed). Do you create that GameLogics in the Editor or by script? I have no chanse to run it from a placed GameLogic's init field.
Fix bayonet!

Offline F2kSel

  • Members
  • *
Re: Spawned C130 acted weired
« Reply #3 on: 16 Sep 2010, 11:53:51 »
The first two or three times I ran your script it worked without any changes but sometimes it does fail to start the engines.

I changed it as I wanted to see if the script would work with multiple aircraft spawning which is easier for me to do from within the editor rather than changing the init all the time.

You can call your script from a trigger instead of a logic, one way would be to just name the trigger and use that name rather than the game logic name and put the exec in the on act box.

You could also still use the game logics if you name them then later in a script or trigger you would use;

if the logics are named planepos1 and planepos2 the code you would use would be.

Code: [Select]
[planpos1] exec "createC130.sqs";[planepos2] exec "createC130.sqs"
Place that in your script trigger or whatever and it  should work but I haven't had time to check it for errors.   

 

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Spawned C130 acted weired
« Reply #4 on: 17 Sep 2010, 10:48:42 »
Thanks! The only line is needed "_pilot action ["engineOn", vehicle _pilot] ". The others works in my way.
Fix bayonet!