Anklebiter Posted December 5, 2018 Posted December 5, 2018 (edited) Hi folks, Brand new at Moose and LUA scripting. I've gotten Moose to work and have successfully used the spawnfromunit() function. I'd like a bit more control over positioning and was hoping to use spawnfromvec3() after getting the unit position. I came up with the following and doesn't seem to work. I know it is getting the position, because that part is displaying on my screen. Any input? local group = Group.getByName('Player') local unitPos = nil local units = group:getUnits() unitPos = Unit.getByName(units[1]:getName()):getPosition() // isn't this the Vec3 coordinate that needs to go into the SpawnFromVec3 function?? trigger.action.outText("Position is this: "..unitPos.x.y, 5) //Seems to work. I get the y value sent SpawnAirplanes = SPAWN:New("Airplane"):InitLimit( 20, 10 ) SpawnAirplanes:SpawnFromVec3( {unitPos.x.x-40, unitPos.x.y, unitPos.x.z} ) //gotta be something funky with this? I also tried SpawnAirplanes:SpawnFromVec3( unitPos ) just to see if I could get the spawn, even though It would be on top of the other unit. Unfortunately the sample missions take it one step further and don't help a newbie like me with the coordinate system. It gets fancy with zones. Edited December 5, 2018 by Anklebiter
Hardcard Posted December 5, 2018 Posted December 5, 2018 (edited) unitPos = Unit.getByName(units[1]:getName()):getPosition() // isn't this the Vec3 coordinate that needs to go into the SpawnFromVec3 function?? I don't think so, this will return Position3, I believe :SpawnFromVec3 needs Vec3 instead. After some testing, I got it working with the following code: local Group = GROUP:FindByName('Player') local GroupVec3 = Group:GetVec3() [color="Blue"]--Gets Vec3 from the group leader[/color] local SpawnAirplanes = SPAWN:New("Airplane") :InitLimit( 20, 10 ) :SpawnFromVec3(GroupVec3) Now, if you want to get the Vec3 from a unit other than the group leader, you can do this instead: GROUP:GetUnit(Number of the unit):GetVec3() Hope this helps. What is it exactly that you're trying to accomplish, btw? Edited December 5, 2018 by Hardcard [sIGPIC][/sIGPIC]
Anklebiter Posted December 5, 2018 Author Posted December 5, 2018 Thanks! Still working out the coordinate system and hadn't realized there was a difference between Position3 and Vec3. Now if I wanted to slightly edit that would the following work? :spawnFromVec3({GroupVec3.x.x-100, GroupVec3.x.y, GroupVec3.x.z}) I'm working a fantasy scenario where a plane pops into existence right in front of the player, time slows (already worked that out) and a conversation is had. This is for "Time Pilot" campaign, where Hogs and Hornets fight the Nazi's. First time I've mentioned on this forum, as folks here are pretty protective about realism and this is a project with my kids....
Hardcard Posted December 5, 2018 Posted December 5, 2018 (edited) I'm working a fantasy scenario where a plane pops into existence right in front of the player, time slows (already worked that out) and a conversation is had. This is for "Time Pilot" campaign, where Hogs and Hornets fight the Nazi's. I'd definitely play such a campaign, sounds like a great idea! :thumbup: However, pitting hornets and hogs (especially hogs) against BF-109s and FW-190s seems hardly fair :D Based on a GrimReapers' dogfight test I watched on YT, I believe that hornets might struggle in dogfights against WW2 fighters, but hogs perform better, thanks to their tight turn ability (that's what I recall anyway, might be wrong! :doh:). Found the video! (it's both informative and fun to watch) Btw, how did you manage to program the time slowdown? Sounds like a pretty interesting feature, tbh. Now if I wanted to slightly edit that would the following work? :spawnFromVec3({GroupVec3.x.x-100, GroupVec3.x.y, GroupVec3.x.z}) Nah, that doesn't work, it returns the following DCS scripting error: 21: attempt to index field 'x' (a number value) If you want to modify the returned Vec3, here's one possible way of doing it (I've tested it and works for me): local Group = GROUP:FindByName('Player') local GroupPointVec3 = Group:GetPointVec3() --Instead of :GetVec3(), use :GetPointVec3(), that way you'll be working with the MOOSE POINT_VEC3 class, which offers useful functionalities. Also, it works with :SpawnFromVec3 local ModifiedPointVec3 = GroupPointVec3:AddX(-100) --One of the MOOSE functionalities available for POINT_VEC3 class is :AddX(). It allows for X coordinate value modification. local SpawnAirplanes = SPAWN:New("Airplane") :InitLimit( 20, 10 ) :SpawnFromVec3(ModifiedPointVec3) --Simply use the variable containing the modified coordinates and you'll be set. Edited December 5, 2018 by Hardcard [sIGPIC][/sIGPIC]
Anklebiter Posted December 5, 2018 Author Posted December 5, 2018 (edited) I'd definitely play such a campaign, sounds like a great idea! :thumbup: However, pitting hornets and hogs (especially hogs) against BF-109s and FW-190s seems hardly fair :D Good to hear! We are up to mission 8 of 12 on this and it is coming along nicely. It is fully voiced with a nice sci-fi plot. Rouge A.I.s, betrayals, powerups (yes powerups)... with a focus on core gameplay. Killing Natzys and time travel. Time slow is xsetcommand. That is really powerful function allowing you to practically do machinima if you are patient enough. More so than anything, this project has taught me that that SA and pilot skill determine outcome way more than airframe. I've been embarrassingly shot down in my Hornet by 109s plenty of times. Same with the Hog, especially when it is loaded down for Tiger killing goodness. Maybe one Hornet against one 109 isn't fair. But what about against one-hundred 109s, coming in waves of 20? :) Challenge (and satisfaction) is to be had there. We will see how it goes. I suspect many would find it enjoyable, while many would be offended by its "video-game" sensibilities. We've certainly turned everything up to 11 (while paying close attention to frames). We will either try to sell or give it away when complete. Only reason I would sell is to justify all those hours building it to the wife. Currently it features the Tiger, Hog, Hornet, Normandy, Persian Gulf and WW2 assets, so certainly not a cheap price of entry. Thanks for the help. My first foray into Moose... I've been scripting with the built-in api up until now. Edited December 5, 2018 by Anklebiter
Recommended Posts