SelfWorkerTime, CanBeAssisted and more

SelfWorkerTime, CanBeAssisted and more

Requests for features in the spring code.

Moderator: Moderators

User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

SelfWorkerTime, CanBeAssisted and more

Post by KDR_11k »

Some tags for constructions that I've found myself and others wanting.

SelfWorkerTime: A unit with this tag >0 will add to its own construction with a WorkerTime equal to SelfWorkerTime. Its construction will not decay even when noone else is working on it (essentially self building like e.g. the UCS stuff in Earth 2150).

SelfWorkingAssist: Default 1, if set to 0 nothing can assist this construction if it's building itself and the constructor that has started the construction will leave immediately after starting it.

CanBeAssisted: Default 1, if set to 0 anything this unit is building cannot be assisted on. This could be used to e.g. prevent con assisting factories (which it seems like every single non-TA mod is trying to do).

RepairMultiplier, ReclaimMultiplier, TerraformMultiplier: The multiplier to the workertime used for repairing, reclaiming and any form of changing the terrain (restoring or levelling before a construction). Currently you have to change all worker and buildtimes in your mod if you want e.g. faster reclaiming of features and you can't e.g. have expensive units that take forever to make but are still repairable in reasonable time.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

This request is relevant to my interest.. +1
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

+1000. This would solve a lot of problems for my current project.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

+1,000,000
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

+1,000,000,000

Hehe
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Post by Peet »

+moar
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

+ infinity
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Post by yuritch »

Separate ResurrectMultiplier and CaptureMultiplier would be good, too.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

ResurrectMultiplier would be better put in the corpse's file, I think
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

I'm for giving the tag to both builders and corpses, multiply both values for the final multiplier.

Corpses could use a set of resurrection cost tags, too, so we can have free resurrections.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

good thinking, +1
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

A patch

Post by yuritch »

I wrote a patch that implements the following FBI tags:

Code: Select all

RepairMult
ReclaimMult
ResurrectMult
CaptureMult
They modify unit's buildspeed when executing corresponding actions. The values are floats. All the tags default to 1 so that existing units are not affected. Values lower than 1 make a unit less effective at a given task, values higher than 1 increase effectiveness (for ex., with CaptureMult=10 enemy units are captured VERY fast :) )
Terraforming seems to be quite different compared to the above tasks, so terraforming multiplier is not included.
Here is the patch itself:

Code: Select all

Index: rts/Sim/Units/UnitDef.h
===================================================================
--- rts/Sim/Units/UnitDef.h	(revision 3637)
+++ rts/Sim/Units/UnitDef.h	(working copy)
@@ -94,6 +94,11 @@
 	float buildSpeed;
 	float buildDistance;
 	float mass;
+
+	float reclaimMult;
+	float repairMult;
+	float captureMult;
+	float resurrectMult;
 	
 	float minCollisionSpeed;
 	float slideTolerance;
Index: rts/Sim/Units/UnitDefHandler.cpp
===================================================================
--- rts/Sim/Units/UnitDefHandler.cpp	(revision 3637)
+++ rts/Sim/Units/UnitDefHandler.cpp	(working copy)
@@ -338,6 +338,10 @@
 	ud.buildSpeed=atof(tdfparser.SGetValueDef("0", "UNITINFO\\WorkerTime").c_str());
 	ud.buildDistance=atof(tdfparser.SGetValueDef("64", "UNITINFO\\Builddistance").c_str());
 	ud.buildDistance=std::max(128.f,ud.buildDistance);
+	ud.repairMult=atof(tdfparser.SGetValueDef("1", "UNITINFO\\RepairMult").c_str());
+	ud.reclaimMult=atof(tdfparser.SGetValueDef("1", "UNITINFO\\ReclaimMult").c_str());
+	ud.captureMult=atof(tdfparser.SGetValueDef("1", "UNITINFO\\CaptureMult").c_str());
+	ud.resurrectMult=atof(tdfparser.SGetValueDef("1", "UNITINFO\\ResurrectMult").c_str());
 	ud.armoredMultiple=atof(tdfparser.SGetValueDef("1", "UNITINFO\\DamageModifier").c_str());
 	ud.armorType=damageArrayHandler->GetTypeFromName(ud.name);
 //	logOutput.Print("unit %s has armor %i",ud.name.c_str(),ud.armorType);
Index: rts/Sim/Units/UnitTypes/Builder.cpp
===================================================================
--- rts/Sim/Units/UnitTypes/Builder.cpp	(revision 3637)
+++ rts/Sim/Units/UnitTypes/Builder.cpp	(working copy)
@@ -31,6 +31,10 @@
 CR_REG_METADATA(CBuilder, (
 				CR_MEMBER(buildSpeed),
 				CR_MEMBER(buildDistance),
+				CR_MEMBER(repairMult),
+				CR_MEMBER(reclaimMult),
+				CR_MEMBER(resurrectMult),
+				CR_MEMBER(captureMult),
 				CR_MEMBER(curResurrect),
 				CR_MEMBER(lastResurrected),
 				CR_MEMBER(curBuild),
@@ -54,6 +58,10 @@
 CBuilder::CBuilder()
 :	buildSpeed(100),
 	buildDistance(16),
+	repairMult(0),
+	reclaimMult(0),
+	resurrectMult(0),
+	captureMult(0),
 	curBuild(0),
 	curReclaim(0),
 	terraforming(false),
@@ -82,6 +90,10 @@
 {
 	buildSpeed=def->buildSpeed/32.0f;
 	buildDistance=def->buildDistance;
+	repairMult=def->repairMult;
+	reclaimMult=def->reclaimMult;
+	resurrectMult=def->resurrectMult;
+	captureMult=def->captureMult;
 
 	CUnit::UnitInit (def, team, position);
 }
@@ -178,11 +190,24 @@
 		if(inBuildStance){
 			isCloaked=false;
 			curCloakTimeout=gs->frameNum+cloakTimeout;
-			if(curBuild->AddBuildPower(buildSpeed,this)){
-				CreateNanoParticle(curBuild->midPos,curBuild->radius*0.5f,false);
+			//Check to see if we are building a new thing or repairing an existing thing
+			if(curBuild->buildProgress<1){
+				//building new thing
+				if(curBuild->AddBuildPower(buildSpeed,this)){
+					CreateNanoParticle(curBuild->midPos,curBuild->radius*0.5f,false);
+				} else {
+					if(!curBuild->beingBuilt && curBuild->health>=curBuild->maxHealth){
+						StopBuild();
+					}
+				}
 			} else {
-				if(!curBuild->beingBuilt && curBuild->health>=curBuild->maxHealth){
-					StopBuild();
+				//repairing something
+				if(curBuild->AddBuildPower(buildSpeed*repairMult,this)){
+					CreateNanoParticle(curBuild->midPos,curBuild->radius*0.5f,false);
+				} else {
+					if(!curBuild->beingBuilt && curBuild->health>=curBuild->maxHealth){
+						StopBuild();
+					}
 				}
 			}
 		} else {
@@ -191,7 +216,7 @@
 	} else if(curReclaim && curReclaim->pos.distance2D(pos)<buildDistance+curReclaim->radius && inBuildStance){
 		isCloaked=false;
 		curCloakTimeout=gs->frameNum+cloakTimeout;
-		if(curReclaim->AddBuildPower(-buildSpeed,this)){
+		if(curReclaim->AddBuildPower(-buildSpeed*reclaimMult,this)){
 			CreateNanoParticle(curReclaim->midPos,curReclaim->radius*0.7f,true);
 		}
 	} else if(curResurrect && curResurrect->pos.distance2D(pos)<buildDistance+curResurrect->radius && inBuildStance){
@@ -201,13 +226,13 @@
 			{
 				// This corpse has been reclaimed a little, need to restore the resources
 				// before we can let the player resurrect it.
-				curResurrect->AddBuildPower(buildSpeed,this);
+				curResurrect->AddBuildPower(buildSpeed*repairMult,this);
 			}
 			else
 			{
 				// Corpse has been restored, begin resurrection
-				if(UseEnergy(ud->energyCost*buildSpeed/ud->buildTime*0.5f)){
-					curResurrect->resurrectProgress+=buildSpeed/ud->buildTime;
+				if(UseEnergy(ud->energyCost*buildSpeed*resurrectMult/ud->buildTime*0.5f)){
+					curResurrect->resurrectProgress+=buildSpeed*resurrectMult/ud->buildTime;
 					CreateNanoParticle(curResurrect->midPos,curResurrect->radius*0.7f,gs->randInt()&1);
 				}
 				if(curResurrect->resurrectProgress>1){		//resurrect finished
@@ -227,7 +252,7 @@
 		}
 	} else if(curCapture && curCapture->pos.distance2D(pos)<buildDistance+curCapture->radius && inBuildStance){
 		if(curCapture->team!=team){
-			curCapture->captureProgress+=1.0f/(150+curCapture->buildTime/buildSpeed*(curCapture->health+curCapture->maxHealth)/curCapture->maxHealth*0.4f);
+			curCapture->captureProgress+=1.0f/(150+curCapture->buildTime/(buildSpeed*captureMult)*(curCapture->health+curCapture->maxHealth)/curCapture->maxHealth*0.4f);
 			CreateNanoParticle(curCapture->midPos,curCapture->radius*0.7f,false);
 			if(curCapture->captureProgress > 1.0f){
 				if (!curCapture->ChangeTeam(team, CUnit::ChangeCaptured)) {
Index: rts/Sim/Units/UnitTypes/Builder.h
===================================================================
--- rts/Sim/Units/UnitTypes/Builder.h	(revision 3637)
+++ rts/Sim/Units/UnitTypes/Builder.h	(working copy)
@@ -36,6 +36,11 @@
 	float buildSpeed;
 	float buildDistance;
 
+	float repairMult;
+	float reclaimMult;
+	float resurrectMult;
+	float captureMult;
+
 	CFeature* curResurrect;
 	int lastResurrected;
 	CUnit* curBuild;
Link to Mantis report
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

Please update Lua bindings, too.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Lua bindings?
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Post by Pxtl »

Interesting concepts - I am looking ahead and considering Smoth's previous "Can'tRepair" request...

Perhaps the "CantRepair" could be exapanded to encompass the CantBeAssisted flag.

That is, have tags for the following:
CantRepair (objects this builder cant repair)
CantAssist (objects this builder cant assist)
CantReclaim (features this builder cant reclaim)
CantRessurect (features this builder cant resurrect)
CantCapture (units this builder cant capture).

Obviously, this is just throwing ideas out there as a tools developer - I've just been mucking through the tag list and I like to keep an eye peeled for redundancy.

Obviously, the self-build and the no-assist-while-self-building features are a different story.

Heheh, with that feature we can have Protoss!
User avatar
Erom
Posts: 1115
Joined: 25 Apr 2006, 05:08

Post by Erom »

And we can almost do a perfect emulation of Command and Conquer style building, as well. The only difference is the base size would be limited to the "nanorange" of the construction hub.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

CantReclaim (units or features this builder cant reclaim)
Fixed.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

KDR_11k wrote:Lua bindings?
Lua exposes UnitDefs in, you guessed it, global UnitDefs table - you can read almost anything that the engine read from .fbis (not sure if changes are possible, but I guess so.) It doesn't happen automatically, you have to add those variables in some Lua/C++ bindings file.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

k.

I'd still like terraforming options though.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Code: Select all

Last modification: Rev 3641 - trepan - 2007-04-19 07:22:38 +0200 (Thu, 19 Apr 2007)

* Added the 'canSelfRepair' FBI tag (defaults to false)
* Added the 'canBeAssisted' FBI tag (defaults to true)
  - disabling assists to factories should work well
  - builders have to die to release their hold on a unit being built,
    and once the unit is released, multiple builders can repair the unit
Post Reply

Return to “Feature Requests”