Game Development Community

T3D 1.1 Beta 3 - Health.cs and ItemData::Create() Only In Tools Build w/FIX! - RESOLVED

by Steve Acaster · in Torque 3D Professional · 12/06/2010 (1:40 am) · 6 replies

T3D 1.1 beta 3

Win7 32bit

Target
stock healthpack tossPatch() script/creating an item

Issue
Healthpack toss uses "ItemData::create(%data)" which is in ObjectBuilderGui.ed.gui - and this gets cut when you compile a "Player Build" (for shipping), thus meaning that healthpack tossPatch() can't find the function.

Repeat
Compile a build with "Player build" defined (rather than tools build), kill an ai or player, see no healthpack tossed, check console for errors (don't make it a shipping build or console will keep quiet).

Suggest
Edit health.cs and item.cs and create a new function.

in (scripts) item.cs
//yorks new function needed here as stock is in tools - no good for a player build
function ItemData::createNew(%data)
{
   %obj = new Item()
   {
      dataBlock = %data;
    //  parentGroup = shouldnotneedthis;//add to missioncleanup on tosspatch()
      static = false;
      rotate = false;
   };
   return %obj;
}

in (scripts) health.cs and for any future use
function ShapeBase::tossPatch(%this)
{
   //error("ShapeBase::tossPatch(" SPC %this.client.nameBase SPC ")");
   if(!isObject(%this))
      return;

   %item = ItemData::createNew(HealthKitPatch);//change here
   %item.sourceObject = %this;
   %item.static = false;
   MissionCleanup.add(%item);

   %vec = (-1.0 + getRandom() * 2.0) SPC (-1.0 + getRandom() * 2.0) SPC getRandom();
   %vec = vectorScale(%vec, 10);
   %eye = %this.getEyeVector();
   %dot = vectorDot("0 0 1", %eye);
   if (%dot < 0)
      %dot = -%dot;
   %vec = vectorAdd(%vec, vectorScale("0 0 8", 1 - %dot));
   %vec = vectorAdd(%vec, %this.getVelocity());
   %pos = getBoxCenter(%this.getWorldBox());

   %item.setTransform(%pos);
   %item.applyImpulse(%pos, %vec);
   %item.setCollisionTimeout(%this);
   //serverPlay3D(%item.getDataBlock().throwSound, %item.getTransform());
   %item.schedulePop();

   return %item;
}

And now all should work fine when tools have been ripped out for shipping.


08 april 2011 FIXED IN 1.1 PREVIEW

#1
12/21/2010 (10:33 pm)
Thanks Steve.
#2
12/21/2010 (10:34 pm)
Double post... deleted.
#3
01/07/2011 (11:27 pm)
Logged as THREED-1306.
#4
01/07/2011 (11:34 pm)
Ray Batts ... the man who never updates his website ...

Getting very close to James Ford website territory ... (last update April)
#5
02/18/2011 (1:39 pm)
Thanks Steve. Fixed in 1.1 Final.

- Dave
#6
04/24/2011 (5:18 pm)
Fixed in 1.1 Final and Preview.