Duion Posted February 26, 2015 Share Posted February 26, 2015 I'm trying to create an item that can be picked up that adds ammo to the proxymine, but somehow it does not work, this is my Datablock: datablock ItemData(ProxMineAmmo) { // Mission editor category category = "Ammo"; // Add the Ammo namespace as a parent. The ammo namespace provides // common ammo related functions and hooks into the inventory system. className = "Ammo"; // Basic Item properties shapeFile = "art/shapes/weapons/ProxMine/TP_ProxMine.DAE"; mass = 1; elasticity = 0.2; friction = 0.6; // Dynamic properties defined by the scripts pickUpName = "Proxy Mine"; maxInventory = 4; }; I also added below: ammo = ProxMineAmmo; The player datablock also has maxInventory = 4 allowed.I can place the ammo-item, but I cannot pick it up, any ideas? Quote Link to comment Share on other sites More sharing options...
Nils Posted February 26, 2015 Share Posted February 26, 2015 Strange to add ammo to a Proxmine, the ProximityMine class doesn't support ammo out of the box.Anyway, does: class = "Ammo"; perhaps work? Quote Link to comment Share on other sites More sharing options...
Duion Posted February 26, 2015 Author Share Posted February 26, 2015 Where to add? In the proxyMine itself it does not work. The other weapons are also "WeaponImage" and have separate ammo items.For example the lurker: // Add the WeaponImage namespace as a parent, WeaponImage namespace // provides some hooks into the inventory system. class = "WeaponImage"; className = "WeaponImage"; // Projectiles and Ammo. item = Lurker; ammo = LurkerAmmo; clip = LurkerClip; Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted February 26, 2015 Share Posted February 26, 2015 In the datablock editor I created a new ItemData and used LurkerGrenadeAmmo as the copied from values. In the dynamic variables I changed pickupName to "a proximity mine" and it seemed to work.Here's the managed datablock. datablock ItemData(proxAmmo : LurkerGrenadeAmmo) { elasticity = "0.198436"; pickupName = "a proximity mine"; shapeFile = "art/shapes/weapons/ProxMine/TP_ProxMine.cached.dts"; }; Quote Link to comment Share on other sites More sharing options...
Duion Posted February 26, 2015 Author Share Posted February 26, 2015 Your datablock displays a shape, but has no functionality, it cannot be picked up or anything. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted February 26, 2015 Share Posted February 26, 2015 I haven't had a chance to create a proper all in code datablock but you used the datablock editor and created a new itemData datablock and copied the values from lurkergrenadeammo?The above snippet is from managedDataBlocks.cs not a full datablock. Quote Link to comment Share on other sites More sharing options...
Duion Posted February 26, 2015 Author Share Posted February 26, 2015 I posted the datablock I used in the first post. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted February 27, 2015 Share Posted February 27, 2015 I can't seem to figure out how to change it in code but if you place your scripted Ammo(ProxMineAmmo) into the scene then in the properties under Game change the dataBlock pulldown to ProxMine and it works but changing your script to: datablock ItemData(ProxMineAmmo : ProxMine)does not accomplish this. I suppose you can just manually change each Ammo item once added or copy it.Perhaps there is a way to change this in script? Quote Link to comment Share on other sites More sharing options...
Duion Posted February 27, 2015 Author Share Posted February 27, 2015 What do you mean all the time with "it works" ? Nothing works until you post a working code. Quote Link to comment Share on other sites More sharing options...
Nils Posted February 27, 2015 Share Posted February 27, 2015 How does the code in the player datablock look like?maxInv[ProxMineAmmo] = 4;ormaxInvProxMineAmmo = "4";The proximitymine class doesn't work with ammo. It only works with states (deployed, triggered, etc.), that's all. The proxmine as a weapon image is a method to get it into the inventory (it's more like a hack if you ask me). So if you would be able to pick up your new created item, you'd still need to modify the proximitymine class and add a ammo system. Another option would be to create a function ProxMineAmmo::onPickup to add a proximity mine to the inventory instead of the ammo. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted February 27, 2015 Share Posted February 27, 2015 Okay, I used your code and made a file in datablocks called proxyMineAmmo.cs Of course I opened datablockExec.cs and added:exec("./proxyMineAmmo.cs");Started up T3D.Went to Library - Scripted -Ammo and added your item - ProxMineAmmoOnce it was in the scene I selected it and went into the properties.Under Game - DataBlock: I changed it to ProxMine (see image below) and:It works.I'm just trying to figure out how to use that dataBlock in script, so far I can't. Quote Link to comment Share on other sites More sharing options...
Duion Posted February 27, 2015 Author Share Posted February 27, 2015 You are right, this really works, the weird thing is, if I set it to use "ProxMine" in the code it does not work, only if you change it in the properties tab after you placed it. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted February 27, 2015 Share Posted February 27, 2015 Exactly, it's a bit maddening. I guess ItemData cannot inherit ShapeBaseImageData but I just don't get why it isn't like picking up an actual weapon? Like the Lurker script. Quote Link to comment Share on other sites More sharing options...
Duion Posted February 27, 2015 Author Share Posted February 27, 2015 You can place it as a weapon, but then it blows up and kills you if you move close, but if you make an item and set it to use the same datablock that killed you before you can pick it up.If you look at the code itself, the proxymine itself already seems to be set up as item that can be picked up, since it has pickup name, maxInventory etc: https://github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/art/datablocks/weapons/ProxMine.cs#L44But I would still like an option to define this in code, so that you don't have to change the datablock properties for each item, this can be confusing, for example people try to place it and don't know about it and then they complain, so best solution would be to have it in code. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted February 27, 2015 Share Posted February 27, 2015 I agree. It has to be possible and I haven't given up. Quote Link to comment Share on other sites More sharing options...
Duion Posted March 2, 2015 Author Share Posted March 2, 2015 Take your time, I believe in you now. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted March 13, 2015 Share Posted March 13, 2015 Alright, I been thinking on this. The code below works to a certain extent. You can place the item and pick it up. It will increment the ProxMine by 1 if you do not have max amount. It plays the correct sound. The problem is that the item will disappear even when you have max amount of mines. Also I can't get the respawn to work. I will work on this more but I'm on the right track. Basically we have to rewrite Item code. If anyone else could look it over and give some input, that would be great. datablock ItemData(ProxMineAmmo) { // Mission editor category category = "Ammo"; // Add the Ammo namespace as a parent. The ammo namespace provides // common ammo related functions and hooks into the inventory system. className = "Weapon"; item = ProxMine; // Basic Item properties shapeFile = "art/shapes/weapons/ProxMine/TP_ProxMine.cached.dts"; mass = 1; elasticity = 0.2; friction = 0.6; count = 1; // Dynamic properties defined by the scripts pickUpName = "a proximity mine"; maxInventory = 5; }; function ProxMineAmmo::respawn(%this) { // This method is used to respawn static ammo and weapon items // and is usually called when the item is picked up. // Instant fade... %this.startFade(0, 0, true); %this.setHidden(true); // Shedule a reapearance %this.schedule($Item::RespawnTime, "setHidden", false); %this.schedule($Item::RespawnTime + 100, "startFade", 1000, 0, false); } function ProxMineAmmo::onCollision(%this, %obj, %col) { echo(%obj); if(%col.getClassName() $= "Player") { //%currentAmmo = %col.getFieldValue( ProxMine ); if (%obj.getInventory( ProxMine) < ProxMine.maxInventory ) { %obj.delete(); serverPlay3D(AmmoPickupSound, %col.getTransform()); %col.incInventory(ProxMine, 1); %this.respawn(); } } } Quote Link to comment Share on other sites More sharing options...
Duion Posted March 13, 2015 Author Share Posted March 13, 2015 How about a workaround that automatically selects the correct datablock like you did on your first solution? I am using this at the moment, the only drawback is, that you have to know to set it to use the proxy mine datablock in the properties editor, could be confusing for people who do not know this and just want to place some items. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.