

Igneous01
Members-
Posts
130 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by Igneous01
-
From my experience using this, this event does not fire in single player (but I would need to confirm if that's still the case). This fires when you have selected a slot in multiplayer, and have clicked the button where you are physically put into an airframe. If you need this mission to work both in SP and MP, I think you'll need to handle the S_EVENT_BIRTH in SP and call your code above. Otherwise use S_EVENT_PLAYER_ENTER_UNIT in MP. I don't think there is a way to check using DCS script if current mission is Multiplayer or not (you can do this in a mod however).
-
BUG - weapon:getCategory always returns '2'
Igneous01 replied to Igneous01's topic in Mission Editor
Yeah I figured it was related to that one but wasn't sure - should I report these in the bug reports forum instead? -
I think there's something wrong with getCategory for weapons - it always returns 2 for me no matter which weapon I try. Here is the code I am using to test: GameEventHandler = {} function GameEventHandler:onEvent(event) env.info("GameEventHandler:onEvent(event) called") if not event.initiator then return end local playerName = nil if event.initiator.getPlayerName then playerName = event.initiator:getPlayerName() or nil end -- catch all forms of shooting events from a player if (event.id == world.event.S_EVENT_SHOT or event.id == world.event.S_EVENT_SHOOTING_START or event.id == world.event.S_EVENT_SHOOTING_END or event.id == world.event.S_EVENT_HIT) and playerName then if event.weapon then local weaponName = event.weapon:getDesc()["displayName"] local weaponCategory = event.weapon:getCategory() env.info("GameEventHandler:onEvent (WeaponName: " .. weaponName .. ", WeaponCategory: " .. weaponCategory .. ")") end end end world.addEventHandler(GameEventHandler) Tests with KA-50 00276.606 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: S-8KOM, WeaponCategory: 2) 00276.612 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: S-8KOM, WeaponCategory: 2) 00286.205 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 00288.646 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 00288.646 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 00428.197 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Kh-25ML, WeaponCategory: 2) 00429.644 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Kh-25ML, WeaponCategory: 2) Tests with SU-25T 00741.420 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Kh-25ML, WeaponCategory: 2) 00822.614 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Kh-25ML, WeaponCategory: 2) 00833.316 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 00857.711 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 00860.214 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 00860.215 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: Vikhr M, WeaponCategory: 2) 01067.562 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: R-73, WeaponCategory: 2) 01070.735 INFO SCRIPTING: GameEventHandler:onEvent (WeaponName: R-73, WeaponCategory: 2) I uploaded a sample mission demonstrating it not working - just start firing weapons and you'll see in DCS log all of them return 2 as category. This is tested against latest stable release. weapon_getCategory_Bug.miz
-
add function for adding/removing equip/fuel/munitions from a base
Igneous01 replied to Drexx's topic in Mission Editor
I think he means the warehouse component was written in such a way that makes it very hard to incorporate into the mission scripting lua environment without rewriting a ton of code. -
MOOSE - !!! Walk your LUA mission code using LDT debugger !!!
Igneous01 replied to FlightControl's topic in Mission Editor
Awesome thank you so much for this, I have a massive project im working on with many files and many things going on at once, being able to debug in game when the logging fails is such a great feature to have. Do you know if this also lets you step into the DCS libraries? Like what happens if you try to step into coalition.addGroup() for example? -
MOOSE - !!! Walk your LUA mission code using LDT debugger !!!
Igneous01 replied to FlightControl's topic in Mission Editor
This is fantastic - is there a link i can download and try this out? How does this fare with scheduled functions setup with timer.scheduleFunction()? Often times I find any errors that happen here are not reported in dcs log. -
Is anyone else able to get this working? I've tried this on helicopters, fighters, ground units... all of them return '1'.
-
There are some issues with destroying newly created cargo objects when using coalition.addStaticObject, as well as destroying existing objects in the game ie. local myObj = coalition.addStaticObject(cargo_table) myObj:destroy() myObj:isExist() -- true I think the problem here is that the Scripting Engine doesn't recognize the cargo as destroyed until after your script has run. IE. In my log I tried 2 test cases: First Case: 03713.586 INFO SCRIPTING: Creating StaticObject Instance 'TESTCARGO' 03713.587 ERROR DCS: The file with cargo parameters doesn't exist. Please, add it in (the folder with DCS)/Data and name it as the cargo 3d-model ammo_cargo 03713.587 INFO DCS: CargoManager::addCargo16805376 03713.587 INFO SCRIPTING: 5117( 13)/E: EVENT00000.onEvent({[1]="S_EVENT_BIRTH",[2]={["id"]=15,["IniObjectCategory"]=6,["time"]=0,["initiator"]={["id_"]=16805376,},},[5]=1,}) 03713.587 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="DATABASE#000000003",}) 03713.587 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="DATABASE#000000003",[3]=1,}) 03713.587 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000285",}) 03713.587 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000285",[3]=5,}) 03713.587 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000284",}) 03713.587 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000284",[3]=5,}) 03713.587 INFO SCRIPTING: TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : true 03713.587 INFO SCRIPTING: TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : true 03713.587 INFO SCRIPTING: Destroying Crate TESTCARGO (using obj:destroy()) 03713.587 INFO SCRIPTING: TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : true 03713.588 INFO SCRIPTING: TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : true 03713.588 INFO SCRIPTING: Destroying Crate TESTCARGO (StaticObject.getByName():destroy() 03713.588 INFO SCRIPTING: TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : true 03713.588 INFO SCRIPTING: TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : true 03713.588 INFO DCS: cargoCrashed:16805376 03713.588 INFO SCRIPTING: 5117( 13)/E: EVENT00000.onEvent({[1]="S_EVENT_DEAD",[2]={["id"]=8,["IniObjectCategory"]=6,["time"]=45883.901,["initiator"]={["id_"]=16805376,},},[5]=-1,}) 03713.588 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000285",}) 03713.588 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000285",[3]=5,}) 03713.588 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000284",}) 03713.588 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000284",[3]=5,}) 03713.588 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="DATABASE#000000003",}) 03713.588 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="DATABASE#000000003",[3]=1,}) Second Case: 04061.584 INFO SCRIPTING: Creating StaticObject Instance 'TESTCARGO' 04061.585 INFO DCS: CargoManager::addCargo16805632 04061.585 INFO SCRIPTING: 5117( 13)/E: EVENT00000.onEvent({[1]="S_EVENT_BIRTH",[2]={["id"]=15,["IniObjectCategory"]=6,["time"]=0,["initiator"]={["id_"]=16805632,},},[5]=1,}) 04061.585 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="DATABASE#000000003",}) 04061.585 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="DATABASE#000000003",[3]=1,}) 04061.585 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000285",}) 04061.585 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000285",[3]=5,}) 04061.585 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000284",}) 04061.585 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000284",[3]=5,}) 04061.586 INFO SCRIPTING: TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : true 04061.586 INFO SCRIPTING: TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : true 04061.586 INFO SCRIPTING: Destroying Crate TESTCARGO (using obj:destroy()) 04061.586 INFO SCRIPTING: TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : true 04061.586 INFO SCRIPTING: TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : true 04061.586 INFO DCS: cargoCrashed:16805632 04061.586 INFO SCRIPTING: 5117( 13)/E: EVENT00000.onEvent({[1]="S_EVENT_DEAD",[2]={["id"]=8,["IniObjectCategory"]=6,["time"]=46231.901,["initiator"]={["id_"]=16805632,},},[5]=-1,}) 04061.586 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000285",}) 04061.586 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000285",[3]=5,}) 04061.586 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="SPAWN#000000284",}) 04061.586 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="SPAWN#000000284",[3]=5,}) 04061.586 INFO SCRIPTING: 5127( 13)/E: EVENT00000.onEvent({[1]="Evaluating: ",[2]="DATABASE#000000003",}) 04061.586 INFO SCRIPTING: 5240( 13)/E: EVENT00000.onEvent({[1]="Calling EventFunction for Class ",[2]="DATABASE#000000003",[3]=1,}) You can see that the EVENT_DEATH isn't called for the cargo object until long after my script has finished executing, yet when I try to check :isExist it still thinks it's alive (because the mission hasn't destroyed it yet for some reason). Is this a known bug? It's been around since the last 3 patches (Being an issue since August 2017 for me). This is the test code I was using to confirm all of this: env.info("Creating StaticObject Instance 'TESTCARGO'") local function PositionAt12Oclock(_unit, _offset) local _position = _unit:getPosition() local _angle = math.atan2(_position.x.z, _position.x.x) local _xOffset = math.cos(_angle) * _offset local _yOffset = math.sin(_angle) * _offset local _point = _unit:getPoint() return { x = _point.x + _xOffset, z = _point.z + _yOffset, y = _point.y } end local pos = PositionAt12Oclock(Unit.getByName("SLCPilot1"), 30) local test_cargo_obj = coalition.addStaticObject(country.id.RUSSIA, { country = "Russia", category = "Cargos", x = pos.x, y = pos.z, type = "ammo_cargo", name = "TESTCARGO", mass = 1000, canCargo = true }) env.info("TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : " .. tostring(StaticObject.getByName("TESTCARGO"):isExist())) env.info("TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : " .. tostring(test_cargo_obj:isExist())) env.info("Destroying Crate TESTCARGO (using obj:destroy())") test_cargo_obj:destroy() env.info("TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : " .. tostring(test_cargo_obj:isExist())) env.info("TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : " .. tostring(StaticObject.getByName("TESTCARGO"):isExist())) --env.info("Destroying Crate TESTCARGO (StaticObject.getByName():destroy()") --StaticObject.getByName("TESTCARGO"):destroy() --env.info("TESTCARGO - Is ALIVE? (test_cargo_obj:isExist()) : " .. tostring(test_cargo_obj:isExist())) --env.info("TESTCARGO - Is ALIVE? (StaticObject.getByName():isExist()) : " .. tostring(StaticObject.getByName("TESTCARGO"):isExist()))
-
Sockets and DCS.onPlayerTryConnect performance
Igneous01 replied to Igneous01's topic in How To Mod for DCS World
Thanks CiriBob! I went with what you suggested using dostring_in to set and get flags, it all loads up and syncs up like a charm. -
I found out the issue - in case anyone else is interested: You have to make sure your script file contains the text 'GameGUI' at the end of the filename, before the .lua I had MyScript.lua, which DCS doesn't recognize or load. Once I Renamed it to MyScriptGameGUI.lua - DCS automatically loaded it on startup. Hope this helps some other poor souls who are trying to wrap their heads around this stuff.
-
I'm having problems getting a server side mod I wrote to work. I added a net.log statement at the very top of it and moved the file to my Saved Games\DCS\Scripts folder. But when I start up DCS I dont see any log messages in the dcs.log file from my mod, and my code to create a new log file doesn't run, which makes me believe DCS is not even loading it. I don't see any errors in my log file either, so I'm really confused as to why DCS isn't loading my mod. Is there something else I need to do?
-
I think it's one of those items that was implemented as 'cool idea, lets try it' but once people starting giving their feedback about needing more flexibility, it went on the back burner. I ended up writing my own warehousing script (minus the ability to replenish ammunition) for my needs. Hopefully they'll give us a lua function to add ammo to a warehouse or airport/helipad, but for now I'm happy with just managing things like tanks and equipment.
-
I worked around this by just respawning the group when it died using moose. There would be a few minutes where there would be nothing happening (because the spawned troops are moving to the engagement zone) but for the most part you saw consistent tracer rounds and a firefight from above.
-
Sockets and DCS.onPlayerTryConnect performance
Igneous01 replied to Igneous01's topic in How To Mod for DCS World
Thanks CiriBob, originally i had planned to have the TCP message pumping be done on the mission side, but I've since moved it over to the server mod using the onSimulationFrame handler and checking every few hundred frames or so. I got around the tcp blocking on read by setting a very low timeout so that the read is instant. The TCP sends are done in other handlers (like onConnect, onDisconnect) and the reads are done in the main loop when available - so far nothing is blocking and performance looks good. I did run into something else however - I want to have the server mod call the database to get the ServerID and SessionID just as the mission is starting (one time call), and then send this data over via UDP to the mission script side to sync up. When I try this out - if the server mod loads first, it will call the DB, get the data back, then immediately send a UDP message to the Mission. If the mission has not initialized at this point, then when the UDPreceiver on the mission side is created, that message the ServerMod sent is lost. This only works if the Missions UDP socket is initialized first on that port before the ServerMod sends the UDP response - would you happen to know the order in which things get initialized? Is the Server Mod initialized first, or the mission? I have this one time call done during the onSimulationFrame when the simulation time > 0. -
Sockets and DCS.onPlayerTryConnect performance
Igneous01 replied to Igneous01's topic in How To Mod for DCS World
Thanks a lot Ciribob for the info! I'm using UDP sockets to send/receive from the mission script layer, and the TCP socket is for send/receive to the database (which might be on a different server) - this is mostly so that when the player connects I can fetch the record to determine if they are banned from the server for example (or if they've run out of lives and cant slot in anymore). Good to know that onPlayerTryConnect needs to return quickly - i may need to retrieve the banlist on mission load and just check if the player is in that list instead of in a loop or something. Should I avoid TCP sockets in the server mod, and handle that stuff in the mission script layer in a scheduled function? -
I'm working on a small server mod that talks to a database using luasockets to send messages to a tcp server, which calls the database and sends back the data results. I have some logic right now in the onPlayerTryConnect, that if this is a new player connecting, to go to the database to either create a player record, or retrieve the existing one. This works fine when I'm testing outside of DCS (using mock DCS objects to simulate running the game). I noticed that if I set the timeout too small, the socket:receive will timeout almost every time, failing to get back player information from the database. If I set it to 5 seconds for example I get the information back. Will this cause any performance impacts on the server or in the multiplayer game for others? I want to avoid the case where multiple people connecting at the same time causes the server to lag or freeze. Is it safe to block/wait on server event calls?
-
Just to point out that script does not work well anymore as some of the config names for sams has changed over the years. I reported my findings in that thread, not sure if they've been resolved.
-
There was a survey put out by ED regarding peoples play style in DCS - so it's not to say they wont ever considering fixing or addressing these issues. I think they're trying to do some market analysis right now to understand what are the largest groups of players (single player, multiplayer, coop, etc) and from then on they'll decide what the product road map for DCS should look like.
-
I'm looking to setup some unit tests for a mission im working on but im having a tough time with rolling my own. I'd prefer to use something like busted but with all the dependencies it has i have no idea how to load it into DCS. Has anyone used any external frameworks before in DCS? How does the setup work?
-
Are Events for Cargo Hook and Unhook supported? Cant seem to find any info.
-
I dont think it's working correctly - I tried the example mission, was within close lethal range of hawk system - it never fired on me. Was inside firing envelope of 2 sa-8 sites - they did not turn on or fire. The only sam that fired at me was an sa-3 (which i did not see coming, but evaded successfully). I was able to fire off all my missiles and kill all my targets, was fired on 6 times by the same sam system, was inside multiple killzones of multiple sam systems, and nothing happened to me. It was way too easy, so I think the script is not working as intended.
-
unit respawn bugged? or did i create a loop?
Igneous01 replied to JG52fldrms's topic in Mission Editor
The problem with doing this in the trigger is that is assumes when you respawn 'Plane 1' you are actually respawning the exact same group, which is not the case - it spawns a new group 'Plane 1 #001' that has most of the information cloned from the first group, but it's not the same group. I dont think there is a way to revive a dead group (except maybe by deactivate/activate) You would probably be better off creating a scheduled function that checks every few seconds if a plane has died, respawn a new one, and change the check to the new group on the next iteration. This is some pseudo code, it probably will not compile: MyGroupsToCheck = { Group.GetByName('Plane 1'), Group.GetByName('Plane 2') } timer.scheduleFunction(function(args, time) local GroupsToRemove = {} for i, grp in pairs(MyGroupsToCheck) do if grp:getLife() == 0 then -- respawn group _myGrp = Mist.Spawn(--etc) table.insert(GroupsToRemove , {Index = i, NewGroup = _myGrp}) end end -- iterate through GroupToRemove, remove the old dead group, and insert newly respawned groups to be checked for i, grp in pairs(GroupsToRemove) do table.remove(MyGroupsToCheck, grp.Index) table.insert(MyGroupsToCheck, grp.NewGroup) end return time + 10 -- rerun this function again in the next 10 seconds end, MyGroupsToCheck, timer.getTime + 30) -
Complete Transport and Logistics Deployment - CTLD
Igneous01 replied to Ciribob's topic in Scripting Tips, Tricks & Issues
I'm having problems spawning crates with CTLD, I've setup a logistic unit and named the unit so that it matches the name inside the logistics array, and I'm inside the zone when I try to use the action, but I keep getting 'You are not close enough to friendly logistics to get a crate!' - is there something else I need to do besides setup the logistic unit + be inside it's zone? -
Thread safe way to remove items from a table
Igneous01 replied to Igneous01's topic in Mission Editor
It's not so much errors, but my experience when trying to iterate and remove items from a collection with threads in other languages like c++ or c#. You wouldn't necessarily get an error, but your data might be corrupted if say index 12 was being updated with new data, but index 12 was deleted at same time, now the updates are partially applies to the next item that is in index 12 because table was resized.