Bots and Delayed FireArms (Bonb Drops)

Ask questions, discuss ideas, get answers
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Bots and Delayed FireArms

Post by Swaffy »

Okay the idea worked! This is what I did:

B17/Objects.con - B17Complex

Code: Select all

ObjectTemplate.addTemplate B17BotAimHelperDummy
ObjectTemplate.setPosition 0/-1.299/50
B17/Weapons.con

Code: Select all

rem *** This helps the bot drop bombs earlier ***
ObjectTemplate.create FireArms B17BotAimHelperDummy
ObjectTemplate.setNetworkableInfo PlaneFireArmInfo
ObjectTemplate.aiTemplate B17Bombs
ObjectTemplate.projectileTemplate B17BotAimDummyBomb
ObjectTemplate.projectilePosition 0/0/0
ObjectTemplate.magSize 1
ObjectTemplate.numOfMag -1
ObjectTemplate.velocity 0
ObjectTemplate.autoReload 1
ObjectTemplate.reloadtime 30
ObjectTemplate.roundOfFire 1
ObjectTemplate.setInputFire c_PIAltFire
ObjectTemplate.addFireArmsPosition -1/-0.1/0 0/0/0
ObjectTemplate.AmmoType	9

ObjectTemplate.create Projectile B17BotAimDummyBomb
ObjectTemplate.createNotInGrid 1
ObjectTemplate.geometry Big_Bomb_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.timeToLive CRD_NONE/20/0/0
ObjectTemplate.damageType 1
ObjectTemplate.radius 0
ObjectTemplate.stopAtEndEffect 1
ObjectTemplate.dieAfterColl 0
ObjectTemplate.hasCollisionEffect 1
ObjectTemplate.mass 250
ObjectTemplate.drag 0.08
ObjectTemplate.setHasPointPhysics 0
ObjectTemplate.invisible 1

ObjectTemplate.addTemplate Bomb_wing
ObjectTemplate.setPosition 0/0/-0.5

ObjectTemplate.addTemplate Bomb_wing
ObjectTemplate.setPosition 0/0/-0.5
ObjectTemplate.setRotation 0/0/-90
It seems to work out great. So far.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
BotHunter
Posts: 480
Joined: Thu Jan 10, 2013 11:22 pm
Contact:

Re: Bots and Delayed FireArms

Post by BotHunter »

genius :D
Walk quietly and carry a sniper rifle
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Re: Bots and Delayed FireArms

Post by freddy »

Swaffy wrote:
freddy wrote:
Swaffy wrote:I have never seen networkinfo on projectiles except exppacks and LandmineProjectile, are you sure it makes any difference to use it on a bomb?

I think the AI uses the bombrackdummy for calculating when to release the bombs or something the like
No, silly. I have 12 FireArms with one bomb each. So I have only one of those 12 FireArms with the networkInfo and AI added.

I might add a 13th bomb rack that acts as the dummy bomb, and I might use that for the networkInfo and AI. Then I'll set it like ... 100 feet in front of the bomber?

Question is, how am I going to set up a dummy projectile that has the same flight characteristics as the real bombs? It can't do any damage, make effects, or have a visual mesh.
Ugh! But then any multiplayer can see only the bomb that falling from the bombrack with networkinfo and the rest of the bombs are invisible?!
User avatar
Apache Thunder
Posts: 1213
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Bots and Delayed FireArms

Post by Apache Thunder »

Network info doesn't serve any useful purpose on most vehicle projectiles. In fact it will cause problems. For example, if the plane dies and it's wreck is removed from the map (the timing of this depends on the vehicle's timeToLiveAfterDeath and the altitude where it died) it could end up with bombs "vanishing" mid-air and never causing damage to it's target.

This is because projectiles are automatically tracked by the server to start with. Added netcode is used to alter how projectiles behave in relation to ammo count (the size the mag command is set to in this case) and the status of the player that spawned it. For example on landmines, network info serves to limit how many projectiles that person can place on the map at any one point. If you rem out the network code, the first thing you'll notice is that you can then place an unlimited amount of mines on the map since then the server no longer tracks how many the player placed. Only their position and their owner is tracked.

Network info is also used on exppacks (aka C4) to allow the detonator to function on it (in conjunction with the limit on how many you can place). If you remove net code from C4, the detonator would cease to work in multiplayer.

That's really the only purpose it has and I would advise against using netcode on other projectiles that don't fit the two above circumstances as you are then only increasing the network overhead of your vehicle(s) and increase the chance of having problems.

Also if you ever decide to use the "isSticky" command, never use it on a projectile with network info added. Unlike BF Vietnam, the command is a little buggy. If used on a networked projectile, game CTDs will occur if the player that placed it dies and their kit vanishes or if they die in a vehicle before the projectile detonates. (I can't recall if server crashes occur in multiplayer or if just the client crashes, but I do know that it causes client CTDs in singleplayers) Another crash could occur on sticky networked projectiles if the object the projectile is stuck to vanishes from the map before it explodes. For example it gets stickied to a vehicle wreck and the wreck vanishes before it explodes or it gets stuck to a object spawned from an effect and is set vanishes from the map. Though this is impossible to occur in multiplayer since wreck effects aren't tracked fully in multiplayer, so the projectile likely can't stick to them since server side, the wreck particles don't exist. (only client side are they visible)

Netcode or not, never create a situation where a sticky projectile can stick to a dropped kit. Most mods won't have to worry about this since usually the mesh the kit uses when it's on the map doesn't have a collision mesh (since it's typically not needed), but if you have one that you enabled mobile physics on and gave it a collision mesh, the game will CTD (and in multiplayer the server will crash with same error) about a "Unknown kit part" error when the projectile attempts to stick to it. That's because the game "addTemplates" the projectile to the object it sticks to and kits have a specific set of allowed child object types and projectiles aren't one of them. (this also explains why sticky projectiles won't stick to the terrain since the heightmap system is hardcoded to never allow child objects on the terrain object) However don't worry about this occurring on kits currently active on a player. Once a player picks up a kit, the mesh you saw when it was on the map is deactivated and whatever collision mesh it had isn't included in any physics calculations.

Which explains some odd quirks like how sticky projectiles can cause the host object to move. When projectile stick to a vehicle, whatever momentum/speed the projectile had prior will be transferred to the host object causing it to move. Thus, don't make fast moving things like bullets have sticky or else you get hilarious results like vehicles vanishing into the sky at super sonic speeds. :P

So the only unfortunate thing about this is you can't have sticky C4 and still have it function like C4 due to the lack of network info. :(

The sticky TNT in my BFH'42 mod is timed and doesn't rely on remote detonation. Landmines can have it just fine, but without the netcode, that means allowing players to place unlimited amounts of them on the map as long as they have way of replenishing their ammo and they'll remain on the map even if the player dies.

Another very interesting quirk I noticed is that normally sticky projectiles can't stick to soldiers because since the 1.4 patch (or an older patch prior, I don't recall exactly when this was patched out) projectiles aren't normally allowed to physically interact with the soldier object aside from dieing on contact. If the projectile isn't set in the damage system to die from hitting a soldier (a landmine or C4 for example) then the soldier will pass through it and won't effect the movement of the soldier or the projectile. But I noticed one rare exception. My sticky TNT in BFH'42 when aimed carefully can still stick to a soldier but only if he's in a vehicle seat! Once he gets out, the sticky TNT remains stuck to him and he lugs it around with him until it explodes. I have a sticky vehicle landmine that might remain on the soldier for longer periods. I had fun sticking them to bots while they were in a vehicle. For some reason the host vehicle won't set off the mine, but it will explode if another vehicle gets close (which can also occur while the soldier is on foot) I basically converted that bot into a walking landmine. Quite interesting indeed. :P

Long story short, remove the network info, it's not needed. :P
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Bots and Delayed FireArms

Post by Vilespring »

I'm gonna have to go delete lots of vehicle network infos...
is the network info correlated to showing how many projectiles are left on the racks, like in the katyusha rocket launcher?
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Apache Thunder
Posts: 1213
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Bots and Delayed FireArms

Post by Apache Thunder »

Not that I'm aware of. That's governed by the FireArms object via the "ObjectTemplate.visibleDummyProjectileTemplate" which defines what object to use as the visible dummy for mounted weapons that make use of this feature.

This command is used in conjunction with "ObjectTemplate.addFireArmsPosition" to define where the dummy projectiles will appear on the host firearm object. (with the ObjectTemplate.projectilePosition command being used to prevent the projectiles from spawning too close to the host vehicle, only the addFireArmsPosition directly impacts the positioning of the visible dummy object)

These "dummy projectiles" aren't actually projectiles. They are just child objects that get displayed on the host vehicle and vanish when ammo used up. What order they vanish in depends on if you have the "ObjectTemplate.setAsynchronyFire" command enabled or not. If it's enabled, every other dummy object vanishes, if not, then they fire off in line left to right (or right to left, not sure how BF1942 handles it, I've made little use of this in my modding career) in the order they were coded in the con file.

The addFireArmsPosition is most commonly used on shotguns and multibarrel weapons to define multiple locations for projectiles to spawn from and the setAsynchronyFire command defines what order they are used (unless used on a shotgun type weapon in which case they would all fire at once and the order is irrelevant practically speaking). Don't hold me to it but I believe at least one addFireArmsPosition command is needed to make the VisibleDummyProjectileTemplate work. Do NOT point the VisibleDummyProjectileTemplate command to a geometry template. It's asking for a object template. Thus a SimpleObject or Bundle can be used.

The only vehicle I directly recall making use of this system in was back with my DCU mod. I made a PCO that fired a RC Lada car bomb and the host PCO was a stationary table with laptop on it. The lada car appears along side the table as the visible dummy projectile and vanishes once the RC Lada car is "fired" which makes it appear that it was that car parked beside the table was the one taken control of. (it's basically a copy of the Lada car but with all the child objects merged to one mesh so I can use it as one object. While I could probably have just made it a bundle instead of merging the geometries, it was probably better this way as it was less code for me to keep track of)

The projectiles being fired have no bearing on how the dummy projectiles tied to the the FireArm appear and don't even have to have the same geometry or even look like what ever is used as the visible dummy projectile.

It's the visibleDummyProjectileTemplate, ammo size, asynchronyfire, and addFireArmsPosition that define the visible dummy projectile behavior and thus the network info of the FireArm object is used to convey this information to clients, not the projectile being fired since that is completely independent. So removing unneeded netcode from projectiles won't have any negative impact on the visibleDummyProjecitle system. ;)

EDIT:

Another thing I just remembered. Network info on a projectile also tells the game whether or not to allow engineers with a wrench to "pick up" the projectiles from the map by crouching near them and using the wrench. For example the landmines (and the exppack, though I can't recall if you can pick those up or not) allow this. However I do know that game CTDs will occur if you have netcode added to a landmine fired from a vehicle and a soldier attempts to pick it up with his wrench. This feature only works properly when used on projectiles fired from handfirearms objects and thus that only is allowed at the soldier level. So that's another reason I recommend against using network info on projectiles being fired from vehicles.

Grenades also have network info. The exact reason escapes me as it's not readily clear why they need it. I never tried using grenades without network info to see the effect. Theoretically if a soldier throws a grenade and managed to get into a vehicle and the vehicle dies before the grenade goes off, then the grenade will vanish. Kits are hardcoded to remain on the map for 20 seconds after player death, so normally this isn't an issue unless the grenade was modded to stay on the map for an unusually long time. I didn't see a point in trying to test grenades without net code, so never found out why they needed it. :P

Also, if you are using a projectile to spawn a vehicle like the sandbag handweapon in DesertCombat, network info would interfere with this. Don't know why this is, but I had noticed this early on when setting up my older APMine system. The dummy projectile I fired to spawn the APMine PCO would fail to spawn the PCO if the dummy projectile had network info. Just another tidbit of coding knowledge I would like to pass along. :D
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Bots and Delayed FireArms

Post by Vilespring »

so THAT'S why it didn't work...
okay, I love your great walls of text, they're so informal!
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Apache Thunder
Posts: 1213
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Bots and Delayed FireArms

Post by Apache Thunder »

Informal? I think you meant informational. Informal is used to described something used outside of a professional context. Without formality. Closely related to the word casual.

:P
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Bots and Delayed FireArms

Post by Vilespring »

I was not aware I said informal!
I meant informational! :lol:
I need to revise my statements!
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
Post Reply