Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
Drop Pod AI/Scripting
Anyone got any decent drop pod scripts laying around? I need one that will actually try to deploy/deliver its cargo using hatches rather than deploying via gibbing, but the drop crate doesn't really try to do this, and the rocket AI is obviously not useful either since it tries (fruitlessly) to return to orbit after deployment.
Thu Oct 30, 2014 3:52 am
clunatic
Joined: Fri Nov 23, 2012 5:42 am Posts: 143
Re: Drop Pod AI/Scripting
What exactly are you trying to do? If all you want is for the drop pod to drop, land, open its door to deliver cargo and then close doors, I happen to know (through an unfortunate copy/paste error) that giving the dropcrate a blank lua file, will do just that. But then you do end up with a drop pod just sitting there, so you might want to throw in some sort of check to gib it after a while.
Thu Oct 30, 2014 9:13 pm
Arcalane
Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
Re: Drop Pod AI/Scripting
Essentially, yes. The problem is that by default it has a script to gib it after X amount of time, but it won't seem to open the doors, or it does so somewhat unpredictably. If they are opened manually, it instantly closes them again (though it does at least spit the actor out).
It may be an issue with the craft itself, as the drop crate seems to be doing fine normally.
In the create function, make a variable self.flag or whatever and set it to false.
In the update function, add in:
Code:
if self:GetAltitude(###, ###) < ### and self.flag == false then self.flag = true; self:GetController():SetState(Controller.PRESS_FACEBUTTON, true); end --whatever other stuff you have
To know what to fill in the numbers with, look here: http://wiki.datarealms.com/LuaDocs/Mova ... etAltitude Basically you probably want 0 for the first, something like 5 for the second and something like 5 or 10 for the third.
self.velIntegrator = 0 ---------------- AI variables end ---------------- end
function UpdateAI(self)
if self.PlayerInterferedTimer:IsPastSimTimeLimit() then self.StuckTimer:Reset() end
self.PlayerInterferedTimer:Reset()
-- Reset StableTimer if not in a stable state self.velIntegrator = self.velIntegrator * 0.8 + self.Vel.Magnitude * 0.2 if self.velIntegrator > 3 then self.StableTimer:Reset() else if self.DeliveryState == ACraft.FALL then --stable, so start unloading self.DeliveryState = ACraft.UNLOAD end end
-- Delivery Sequence logic if self.DeliveryState == ACraft.FALL then --left over from RocketAI elseif self.DeliveryState == ACraft.UNLOAD then if self:IsInventoryEmpty() then -- close doors if empty if self.DoorTimer:IsPastSimMS(750) then -- pause before closing if self.HatchState == ACraft.OPEN then self:CloseHatch() self.DeliveryState = ACraft.LAUNCH -- empty and doors closed self.GibTimer:Reset() end end elseif self.StableTimer:IsPastSimMS(400) and self.HatchState == ACraft.CLOSED then self:OpenHatch() self.DoorTimer:Reset() end elseif self.DeliveryState == ACraft.LAUNCH then --crate is empty and doors closed, so gib it after a slight delay if self:IsInventoryEmpty() and self.GibTimer:IsPastSimMS(1000) and self.StableTimer:IsPastSimMS(400) then self:GibThis() end end
-- If we are hopelessly stuck, self destruct if self.Vel.Largest > 3 or self.AIMode == Actor.AIMODE_STAY then self.StuckTimer:Reset() elseif self.AIMode == Actor.AIMODE_SCUTTLE or self.StuckTimer:IsPastSimMS(40000) then --40000 seems a bit much for a stuck timer on a crate, probably change this to 5 sec or so? self:GibThis() end end
Fri Oct 31, 2014 9:23 pm
Arcalane
Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum