dmarkwick 261 Posted September 6, 2009 Currently to broadcast some custom effects when a vehicle is destroyed I use this method: _MPInit=Format ["[This,%1,%2,%3,%4,%5] ExecVM ""JTD_FireAndSmoke\Scripts\SmokeMain.sqf""",_SmokeStyle,_PrimaryLifetime,_SecondaryLifetime,_thisTime,_VehicleScale]; _Vehicle SetVehicleInit _MPInit; ProcessInitCommands; With "_vehicle" being the vehicle destroyed. When destroying nearby trees, I use the same method but use a custom object and set the init on that: _thisTreeMarker = "firemarkerinv" createVehicle _FirePos; _MPInit=Format ["[_x,%1,%2,%3,%4] ExecVM ""JTD_FireAndSmoke\Scripts\ForestFireTree.sqf""",_SmokeStyle,_PrimaryLifetime,_SecondaryLifetime,_thisTime]; _thisTreeMarker SetVehicleInit _MPInit; ProcessInitCommands; where, as you can see, "_thisTreeMarker" is the "vehicle" having the init set this time. I need to use a custom object because I cannot set an init on a map object like a tree. All the above works fine in SP, and I see all effects. In MP, it's reported to me that the vehicle effects are seen by all clients, but that the tree effects are only seen by the client on which the code is executed. Can anyone see why this would be from the examples provided? I'm tempted to think that maybe the vehicles aren't being created on any other machine. They're just small invisible cubes. Does createVehicle really create vehicles on ALL machines when used? Share this post Link to post Share on other sites
UNN 0 Posted September 6, 2009 (edited) When destroying nearby trees, I use the same method but use a custom object and set the init on that What class are you inheriting from for your custom object, it's not something static like a building is it? Also your not showing the source of your variables or scripts? What's used to populate _thisTime for example and what does it determine? Edited September 6, 2009 by UNN Share this post Link to post Share on other sites
dmarkwick 261 Posted September 6, 2009 What class are you inheriting from for your custom object, it's not something static like a building is it? Umm, yes :) building is exactly the base class. I figure that it works locally, it should work. What does "static" mean in this context? Also your not showing the source of your variables or scripts?What's used to populate _thisTime for example and what does it determine? Apart from the first parameter(s), which is an object (either a vehicle or a tree), the others are just numerical parameters to shape and time the effects. _thisTime for example transmits the current time to the init of the object, in order that JIP clients don't get inappropriate effects long after they've actually happened. Share this post Link to post Share on other sites
UNN 0 Posted September 6, 2009 (edited) _thisTime for example transmits the current time to the init of the object, in order that JIP clients don't get inappropriate effects long after they've actually happened. Just covering my bases, I'm not unfamiliar with the concept. Umm, yes building is exactly the base class. If my memory serves me right. That isn't broadcast the same way as other object classes. You could try another class like "logic". But I suspect anything will be ok as long as it isn't static. Edited September 6, 2009 by UNN Share this post Link to post Share on other sites
dmarkwick 261 Posted September 7, 2009 (edited) I'll use "logic", see if that makes a difference. Thanks :) ---------- Post added at 02:25 AM ---------- Previous post was at 01:10 AM ---------- Hmm they were set to "strategic" but I know for a fact they showed up on nearestObjects "buildings" searches, because I specifically had to exclude them on those searches. I changed them to "thing" now. They still work (at least in SP testing) so now to test them in MP. *edit* "Logic"s cannot be createVehicled as nothing with a "brain" can be createVehicled :) (although I guess it could be createUnited...). Edited September 7, 2009 by DMarkwick Share this post Link to post Share on other sites
VictorFarbau 0 Posted September 7, 2009 In general this shows again that you simply can't blindly trust those scripting commands in MP. Unless a BIS programmer looks at this for you you simply won't know what is being broadcasted and what is not. The comref specifies that the 1st parameter of "SetVehicleInit" needs to be an object. If you follow the link to the "Object" specification it reads that there are certain subtypes, one of which is BuildingWhen used in the command reference, this 'Object' specifically refers to a non ai type model, such as a house, such as, a rock. Bottom line: trust nobody, do some MP testing yourself and find out what is being really being broadcasted :) Kinda stupid though but it is like that since the days of OFP. VictorFarbau Share this post Link to post Share on other sites
UNN 0 Posted September 7, 2009 (edited) I changed them to "thing" now. They still work (at least in SP testing) so now to test them in MP. So did class "thing" work ok for you? In general this shows again that you simply can't blindly trust those scripting commands in MP. Class building type objects used to work in Arma1 the same way. It suddenly changed during one of the Arma1 patches, I suspect it was becuase so many people complained about setpos'ing Ammo boxes, but thats just speculation based on the timing. Class thing works fine with JIP, thats why all the Cargo system objects were changed from class static to class thing. Edited September 7, 2009 by UNN Share this post Link to post Share on other sites
dmarkwick 261 Posted September 8, 2009 The comref specifies that the 1st parameter of "SetVehicleInit" needs to be an object. I don't see that info at the comref, does it specify that the object needs to be THE object? As in, the same object that the init is attached to? At the moment the above example for the tree effects, the object the init is attached to is a custom cube object, but the 1st parameter is the tree object. ---------- Post added at 10:28 AM ---------- Previous post was at 10:26 AM ---------- So did class "thing" work ok for you? Well, it works just as well as it did before :D I wonder if there's a restriction on what class of objects can have inits? Trees for example don't seem to accept init commands. Or, I should say, map trees. Share this post Link to post Share on other sites
VictorFarbau 0 Posted September 8, 2009 Did I say comref? I mean the Biki. Anyway, the vehicle you attach it to is your cube, not the tree. Comref and Biki are a bit generic in defining what objects this command can be used on. Biki object definition: An Object in the scripting (sqs) language is a generic reference for a soldier, vehicle or building.Such an object can be animated (a house, a tank), can have ai associated with it (a soldier), or, simply be a 'Rock' Comref object definition: A game object (like a soldier, vehicle or building). This won't help you any further; it's certainly not meant to address such specific problems like yours now. As UNN already indicated the problem could be the object parent class of your cube - have you changed this to be a "thing" class already? In theory this should work then. Too bad tree objects don't accept that command. But how would you run this then? Constantly check all tree objects for damage, create a cube when damaged and then attach a fire to it? Sounds a bit mad in terms of CPU cycles to me :) VictorFarbau Share this post Link to post Share on other sites
dmarkwick 261 Posted September 8, 2009 As UNN already indicated the problem could be the object parent class of your cube - have you changed this to be a "thing" class already? In theory this should work then. Too bad tree objects don't accept that command. Yes the objects are now "thing" class. According to MP test reports I've received, nothing has changed. But how would you run this then? Constantly check all tree objects for damage, create a cube when damaged and then attach a fire to it? Sounds a bit mad in terms of CPU cycles to me :) Well even identifying trees is a task unto itself :) but I have that part licked. A fire will do its propagation check, and any returned trees are checked against an array of previously burned trees (an array of map ID numbers basically) and then if all checks are passed the cube is spawned with an attached init string, hopefully identifying the tree to be affected. Then I add that tree's ID to the array. I have to do it this way because of the tree not having init possibilities. It's not too bad CPU wise, as there's no real rush to get the trees propagating & burning etc. so there's no real reason to do everything all at once. Share this post Link to post Share on other sites
UNN 0 Posted September 8, 2009 (edited) Trees for example don't seem to accept init commands. Or, I should say, map trees. I see, Map objects never had an init event. So your essentially trying to keep track of damaged or destroyed map objects, for all JIP's? If your keeping track of all damaged trees using the objectID's then cpu time shouldn't be the main problem. But when a JIP client connects or you update the list, communicating all those ID's to the JIP and any existing client will take time. If you could somehow cordon off the objects you want to burn, then that would save time and traffic. For example, if you could determine that a fire started at XYZ burnt all the trees within a 500m radius, for example lets say that was 100 trees. Then all you have to communicate to the JIP client is [[X,Y,X],500]. Instead of an array of [10025,10026,10027..10125] broadcast using something like publicVariable. But given that most of the time a map object ID will be sequential. i.e 100 trees could also be represented as map objectID [10025,10125] that could turn out to be a better way? If not a little bit more complicated to implement. If you want to stick with setVehicleInit then you could do it this way: Create an object to indicate a tree burnt. Find the first trees position, then broadcast this to a script for JIP's and MP clients: //The script can only be run on either the server or a single client if isServer then { _SetFireObject="SetFireObj" createVehicle [0,0,0]; While {Loop for how many trees} do { _nextTree=nearestObject...blah...blah; //In this case broadcast the trees position or you could extract the objectID and broadcast that _SetFireObject setVehicleInit format ["%1 execVM ""burnATreeToday.sqf""",getPos _nextTree]; processInitCommands; }; }; But all that will do is create a very long list of burnt tree positions. It's better to avoid the idea of logging each individual object and go with an area effect. Edited September 8, 2009 by UNN Share this post Link to post Share on other sites
dmarkwick 261 Posted September 9, 2009 I'm not worried about logging destroyed trees for JIP, as I assume the game looks after transmitting all the map's destroyed stuff atomagically. The custom objects only live for as long as there's an effect applied to the tree, so that JIP clients get the correct effect at the correct time. Once the effect is over, the object is destroyed and the tree is knocked down, so further JIP clients from that point on just get the destroyed tree info from the game's inherent JIP function. The tree array is simply to stop old, burnt down trees from burning a second time. It's a little unreliable using getDammage because trees only knocked down by a tank should still burn :) Share this post Link to post Share on other sites
UNN 0 Posted September 10, 2009 I'm not worried about logging destroyed trees for JIP, as I assume the game looks after transmitting all the map's destroyed stuff atomagically. Perhaps, but the principle is the same. The custom objects only live for as long as there's an effect applied to the tree, so that JIP clients get the correct effect at the correct time. There's no need to do that. The object only has to exist long enough to broadcast all the trees that are currently burning, along with their start time. If that's what you want? Share this post Link to post Share on other sites
dmarkwick 261 Posted September 10, 2009 There's no need to do that. The object only has to exist long enough to broadcast all the trees that are currently burning, along with their start time. If that's what you want? Well actually UNN I've had to (at least temporarily) abandon the whole "spawn object, apply init" method for fire logic as it was simply not working out. It seemed, to me, that the objects were probably spawning on remote machines, but that the init code was not being executed, or at least executed as intended :) Instead I've implemented a CBA function that simply executes passed code on all machines. It won't do much for JIP, but it gets the addon released. The vehicles, which have long lasting smoke effects (20-40 minutes), are JIP compliant, and that's good enough for an initial beta release I think. The fires are effects that last 3-6 minutes, plus diminishing smoke effects, not too bad for JIP clients to deal with. As I mentioned, as long as the destroyed trees are updated that's a reasonable compromise for the time being. Share this post Link to post Share on other sites
UNN 0 Posted September 10, 2009 I've implemented a CBA function that simply executes passed code on all machines. It won't do much for JIP, but it gets the addon released. Well as long as you have it working, thats the main thing. You can always refine the process with some proper MP code later on. Share this post Link to post Share on other sites
dmarkwick 261 Posted September 10, 2009 Well as long as you have it working, thats the main thing. You can always refine the process with some proper MP code later on. I should offer you a special thanks for your help BTW, you've often (in the past and not just recently) helped me out enormously with the various problems and questions I've had :) You're credited in the readme of course, but I thought I'd mention it here too :) Share this post Link to post Share on other sites