Game Development Community

Quick "::create" function question

by Stephen Lujan · in Torque Game Engine · 03/30/2007 (8:59 am) · 3 replies

I'm trying to come up with a new mission marker and I didn't want to use the MissionMarkerData::create function the way I plan on developing my spawning system. However when I try to place it in the editor its still using the MissionMarkerData::create instead of my new AISpawnSphere::create function. I'm kind of confused here because I thought my new create function would take precedence.

datablock MissionMarkerData(AISpawnSphere)
{
   category = "Misc";//"AI Spawners";
   shapeFile = "~/data/shapes/markers/octahedron.dts";
   test = true;
};

// - serveral marker types may share MissionMarker datablock type
function AISpawnSphere::create(%block)
{
	echo("trying to create AISpawnSphere");
	%groupName = "MissionGroup/AISpawnPoints";
	%group = nameToID(%groupName);
	if (%group != -1)
		new SimGroup(AISpawnPoints);

	 %obj = new SpawnSphere() {
        datablock = %block;
     };
	 %group.add(%obj);
}

#1
03/30/2007 (9:49 am)
I'm pretty sure MissionMarkerData will always take precedence, same with other classes:

datablock ProjectileData(crossbowProjData){...}

function ProjectileData::onCollision(...) {...} <== Has precedence over the following.

function crossbowProjData(...){...}

You'll either have to choose a different name for your function, or modify the existing MissionMarkerData::create.
#2
03/31/2007 (12:02 am)
Thank you Michael. I'll keep an eye out for other instances of this.
Well... i wanted to inherit from the missionmarkerdata datablock, but I wanted to add new variables to store what gets spawned and how at the mission loading and that's way to complicated to fit in the scope of missionmarkerdata functions that can't be overridden in my opinion. I guess this will require engine code changes.
Edit: I've looked at the code and made a new object but nothing about my problem jumps out at me. What would I need to change in missionmarker.cc to be able to override functions in missionmarkerdata new datablocks in the script side?
#3
04/01/2007 (10:07 pm)
Ok I gave up and used MissionMarkerData::create after all. It didn't complicate things too much yet.

I posted a resource for it here.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=12641
This should give you much greater control over how stuff spawns and let you do a lot of stuff like spawning random enemies or items.