Page 1 of 1

Setting up a heli spawn/patrol from task on_init?

Posted: 21 Jan 2018, 22:02
by sLoPpYdOtBiGhOlE
Hi,
I'm setting up a simple custom one time task in CoC 1.5, but I'm unsure of how to handle the helicopter side of the task.

It's a custom fetch task in outskirts/cop pripyat.
The player shoots down a helcopter and retrieves a helicopter blackbox and a pda from the dead pilots body.
Then returns to the task giver to hand in the blackbox and pda.

I have added a dead pilot and blackbox that is spawned when the helicopter is destroyed.
Shooting down any helicopter will drop a dead pilot and blackbox (I've added a info check so the dead pilot will only spawn for my task, blackbox will spawn with any heli kill).
So I have the task_functor, task_status_functor, xr_condition, xr_effects functions implemented to handle monitoring the actor has the 2 fetch items in their inventory.
Currently as a test I have the task not target any specific helicopter, just monitor for when the player has the 2 items.

What I'm absolutely lacking is the method to spawn a helicopter and have it patrol between 2 or 3 close together smarts when task on_init is fired.
Any pointers for this last step are welcomed.

Off topic:
The good part of what I've already written it allows me to easily setup generic multi individual item fetch tasks.
Example;
"Hey stalker I'm going on a journey and I'm unprepared, can you bring me a wood stove, bag of charcoal, sleeping bag?"
"Ok, I'll bring you those items, no worries."
or
Hey stalker the boys each need a type of gun can you bring me: SVD Sniper Rifle, Avalance, Eliminator, RP-74?"
"No problem, be back soon with what your after."

Makes more sense to me then the vanilla Find "# x item" (# = count and item = being just one type).

Re: Setting up a heli spawn/patrol from task on_init?

Posted: 23 Jan 2018, 22:03
by luppolo
to spawn an helicopter you can look at the stpk_utils.spawn_heli() code to spawn it at a given position instead than at the player's, how to make it patrol i have no idea, should check the bind_heli and heli_combat scripts for clues how to do it

Re: Setting up a heli spawn/patrol from task on_init?

Posted: 24 Jan 2018, 04:27
by sLoPpYdOtBiGhOlE
Thank you luppolo,

That did the trick nicely, just re-purposed the spawn_heli function by pointing to a smart_terrain and added some height to the position vector.
So when I take the task the heli spawns and hovers peacefully above the smart and once I start shooting at it kicks into life..
So my task now works as I intended it to, all good.

Off topic:
When seeing my Heli up at Pripyat I had a small flashback to the ending of CoP...lol

Cheers

Re: Setting up a heli spawn/patrol from task on_init?

Posted: 24 Jan 2018, 16:48
by luppolo
sLoPpYdOtBiGhOlE wrote: once I start shooting at it kicks into life..

you can actually "shoot" it with code so you can activate it without actually shooting yourself

Code: Select all

local helicopter_object = alife():object(helicopter_id)
local h = hit()
         h.type = hit.fire_wound
         h.power = 0.0
         h.impulse = 0.0
         h.direction = vector():set(0,1,0)
         h.draftsman = db.actor
         helicopter_object:hit(h)
         

this works on regular npc, no idea if it's the same with helicopter though, and of course i think it works only if you are on the same map

Re: Setting up a heli spawn/patrol from task on_init?

Posted: 24 Jan 2018, 22:00
by sLoPpYdOtBiGhOlE
Thank you for the heads up about hit().

For the moment I actually like that it hovers on the spot till I shoot at it.

But tripping it off with a hit when the player is a certain distance from the heli so the heli will look lively when the player sees it, that's gotta be pretty sweet.

Hmm, back to the scripts...

Cheers