Spawnable items?

Ask questions, discuss ideas, get answers

Re: Spawnable items?

Postby Apache Thunder » Tue Sep 23, 2014 4:47 am

You need to attach a dummy engine to the kit before holdObject will work correctly on it. You can't add one directly to the kit but you can add a dummy engine to one of the kit parts and that will be enough. (You can create a dummy kitpart for this purpose if you need to. Just make sure you set up the object correctly.)

Unlike PCOs however don't expect the kit to "rotate" to keep it's orientation with the vehicle during online play, but it will stay on the vehicle though.

There is no way around this issue that I know of unfortunately. You might have to enable mobile physics on the kit. (but by doing so the kit will not appear on the map when a soldier using it dies, unless you give it a collision mesh. The mesh the main kit uses (the one visible on the map when it spawns) is the mesh you would need to add a collision mesh to. This would also mean that if you forgo a collision mesh, any spawners set up to spawn it on the map will also need the holdObject command to prevent it from falling through the terrain mesh where it will become unreachable. (as would also occur when a soldier drops it when they die.) You might not need mobile physics. Just be sure to test it in a online server to make sure it behaves correctly in multiplayer. ;)

Also, if you have projectiles with the sticky property enabled in your mod, it would be a good idea to prevent them from interacting with kits. If a projectile (like sticky TNT for example) with the sticky property enabled collides with a kit and tries to stick to it, the game will crash with a "Unknown kit part" type error. This is due to how the sticky command works. The projectile actually "addTemplates" itself to the host object it collides with. The only objects it won't stick to are soldiers (but they will stick to soldiers if they are in a vehicle seat however. :P ) and the terrain object. (since the terrain object is hardcoded never to allow child objects on it).

Projectiles aren't allowed on kits as child objects thus the error when it attempts to stick to it. Thus if you do have any thing that might try to stick to a kit on the map with a collision mesh then you'll need to add this command to the kit:

Code: Select all
ObjectTemplate.addToCollisionGroup c_CGProjectiles


Otherwise it's likely not something you have to worry about. The dummy engine and mobile physics is the important part. ;)

As for how to code the dummy engine, it can be very simple. The engine is best set as a car engine so you have no chance of it producing any thrust that would effect the kit:
(since it won't have any spring objects (wheels) attached to it, there is zero chance of it ever impacting movement physics of the kit or the soldier using the kit.)

Code: Select all
ObjectTemplate.create Engine KitDummyEngine
ObjectTemplate.setNetworkableInfo KitDummyEngine_Info
ObjectTemplate.setAttachToListener 1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
rem -------------------------------------
ObjectTemplate.setMinRotation 0/0/-100
ObjectTemplate.setMaxRotation 0/0/100
ObjectTemplate.setMaxSpeed 0/0/100
ObjectTemplate.setAcceleration 0/0/1000
ObjectTemplate.setInputToRoll c_PIThrottle
ObjectTemplate.setAutomaticReset 1
ObjectTemplate.setEngineType c_ETCar
ObjectTemplate.setTorque 0.1
ObjectTemplate.setDifferential 0.1
ObjectTemplate.setNumberOfGears 1


Also you might need to also create a network template for the engine. Look at existing network templates used on engines as an example. Makes sure the network template you created matches the name used in the "setNetworkableInfo" command. The command is case sensitive by the way, so if there are capital letters and such, they need to be that way in both the network template name and the name on the command. ;)
ImageImageImage

I have cameras in your head!
User avatar
Apache Thunder
 
Posts: 1199
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA

Re: Spawnable items?

Postby Swaffy » Tue Sep 23, 2014 5:25 pm

That is one thing that annoys me about BF1942, the lack of more in-depth functionality in the code.

I mean ... not even conditional statements like IF. "If player's health is below 50% then _"
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Swaffy
 
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Spawnable items?

Postby Diamondback » Thu Mar 07, 2019 3:38 pm

Swaffy wrote:That is one thing that annoys me about BF1942, the lack of more in-depth functionality in the code.

I mean ... not even conditional statements like IF. "If player's health is below 50% then _"


Your second sentence might be possible to do, at least for vehicles. Not sure about soldiers though.
See my Strasbourg map project here.
Diamondback
 
Posts: 517
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada

Re: Spawnable items?

Postby Crash42modder » Fri Feb 07, 2020 5:08 am

You can actually get the players to place objects in a map as its playing.
Crash42modder
 
Posts: 16
Joined: Mon Feb 03, 2020 7:15 am

Previous

Return to 1942 Modding Discussion

Who is online

Users browsing this forum: Google [Bot] and 39 guests

cron