Page 1 of 2
Helicopter
Posted: 07 Dec 2017, 20:51
by Lobby
Since version 385 you're able to define helicopter spawners, therefore it now also makes sense to define your own ones. Everything you need are frames for the heli. For example these

- heli.png (1.93 KiB) Viewed 23023 times
Each has a size of 38x18. The helicopter definition looks now like
Code: Select all
{
"id":"$my_heli00",
"type":"helicopter",
"frames":[{"bmp":"heli.png","w":38,"h":18,"count":4,"handle x":18,"handle y":16}], // 4 frames for the helicopter, handle defined the pivot point
"animation":[{
"id":"$rotor00","x":0,"y":-10
}]
}
Notice how is uses a predefined animation called "$rotor00". It just contains 8 images, 4 for slow rotation, 4 for fast rotation. In most cases you won't need to come up with your own rotor frames.
For reference it's defined by
Code: Select all
{
"id":"$rotor00",
"type":"animation",
"frames":[
{"x":360,"y":526,"w":38,"h":9,"count":4,"handle x":18,"handle y":5},
{"x":360,"y":512,"w":38,"h":13,"count":4,"handle x":18,"handle y":6}
]
}
For the helicopter spawner let's define a decoration tile

- heliport.png (976 Bytes) Viewed 23023 times
It's code contains the helicopter spawner
Code: Select all
{
"id":"$heliplaza00",
"type":"decoration",
"width":1,
"height":1,
"frames":[{"bmp":"heliport.png"}],
"build height":0, // Ensure correct building height so that helicopter will start at right height (zero = ground level)
"helicopter spawner":{ // Helicopter spawner object
"id":"$my_heli00", // Id of the helicopter to spawn
"radius":16 // Radius where they helicopter will fly randomly. Is 16 by default
}
}
Note that the id provided in a helicopter spawner doesn't have to be defined yet. However, if it's still not defined when the game tries to use it, it will crash. So always test your own plugins
In conclusion, the complete code for this sample plugin
Code: Select all
[
{
"id":"$my_heli00",
"type":"helicopter",
"frames":[{"bmp":"heli.png","w":38,"h":18,"count":4,"handle x":18,"handle y":16}],
"animation":[{
"id":"$rotor00","x":0,"y":-10
}]
},
{
"id":"$heliplaza00",
"type":"decoration",
"width":1,
"height":1,
"frames":[{"bmp":"heliport.png"}],
"build height":0,
"helicopter spawner":{
"id":"$my_heli00",
"radius":16
}
}
]
Re: [385]Helicopter
Posted: 07 Dec 2017, 20:57
by Lobby
Re: [385]Helicopter
Posted: 07 Dec 2017, 23:39
by JustAnyone
My life is working once again.
Re: [385]Helicopter
Posted: 08 Dec 2017, 02:11
by TheFennekin
Time to create a fighter heli

Re: [385]Helicopter
Posted: 08 Dec 2017, 09:49
by THEMAX
The new STQAE combat helicopters will take off soon
Re: [385]Helicopter
Posted: 20 Dec 2017, 18:53
by -LeoLeo-
Lobby wrote: ↑07 Dec 2017, 20:51
Note that the id provided in a helicopter spawner doesn't have to be defined yet. However, if it's still not defined when the game tries to use it, it will crash. So always test your own plugins
Excuse me... What does this means? I already spent 4½ hours doing a pad and this is my last problem to solve
finally..., the game crashed when the game tried to use it. Can someone give more explanation?
I gave my aircraft It's own ID in the code, and put the same ID in the heli-spawner part code. I checked everything. But... Yeah
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:08
by Lobby
May you show your code? I assume there's something wrong in it that's not that obvious.
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:23
by -LeoLeo-
Well.... I use JsonGenie, so there could be a 99%chance of me screwing up. I didn't watchany tutorials too, just try to make sense of your code and fix the game's syntax errors til i got it to work to this stage. quite proud of myself, actually. lol
By the way. Can you make 1 helipad spawn diferrent kinds of helicopters? I assume you can, right? just expand more of the same code?? What a code to set 'destination' to the chopper? "destination":(building id)???
And, yes, it's a flying car. Because why not?!
To anyone who would download this... I just wanna say it doesn't work.
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:29
by JustAnyone
-LeoLeo- wrote: ↑20 Dec 2017, 19:23
Well.... I use JsonGenie, so there could be a 99%chance of me screwing up. I didn't watchany tutorials too, just try to make sense of your code and fix the game's syntax errors til i got it to work to this stage.
quite proud of myself, actually. lol
By the way. Can you make 1 helipad spawn diferrent kinds of helicopters? I assume you can, right? just expand more of the same code?? What a code to set 'destination' to the chopper?
"destination":(building id)???
And, yes, it's a flying car. Because why not?!
I don't think you can define more than one helicopter.
Maybe.
Lobby am I right?
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:40
by CommanderABab
Is probably what crashes your game!
You have to give the spawner the id of the helicopter you defined.
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:47
by Lobby
@JustAnyone is right, multiple helicopters for one building is not supported.
@CommanderABab is right, too. You have to provide the id of your helicopter to the spawner.
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:48
by CommanderABab
You didn't see this coming did you?
@Lobby
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:53
by -LeoLeo-
CommanderABab wrote: ↑20 Dec 2017, 19:40
Is probably what crashes your game!
You have to give the spawner the id of the helicopter you defined.
I thought i did.
So i didn't...
Thank you very very much!!
is there anything other thing wrong with the code?
Re: [385]Helicopter
Posted: 20 Dec 2017, 19:57
by Lobby
Yes, looks fine to me

Re: [385]Helicopter
Posted: 20 Dec 2017, 19:58
by CommanderABab
Besides the lack of rotors?
No, didn't see anything off hand.
Re: [385]Helicopter
Posted: 20 Dec 2017, 20:04
by Lobby
That's a good point, you probably should add
Code: Select all
"animation":[{
"id":"$rotor00","x":0,"y":-10
}]
to your helicopter. If you don't want to have a rotor, that's possible by using an animation of 8 frames that contain nothing.
Re: [385]Helicopter
Posted: 20 Dec 2017, 20:33
by -LeoLeo-
OMG IT WORKS!!!!!!
FLYYY!!! MY MATIES!!
I liturally almost tearup inside.
I didn't though animation matters.
Now I know what's wrong. I can make it even better. Thankyou!!!, Everyone!!
Here's a snowflake for you guys.
Re: Helicopter
Posted: 04 Feb 2020, 02:21
by hihihihi
Umm.....how to define "handle x" and "handle y" code...? And about $rotor00 animation..?
Re: Helicopter
Posted: 04 Feb 2020, 02:56
by CommanderABab
handle defined the pivot point < see comment in code above.
$rotor00 is a prdefined animation. Much easier to use than trying to make my own animation was.

Re: Helicopter
Posted: 04 Aug 2020, 09:19
by Lakan Haraya
Light animations for helicopters, please
