SelfWorkerTime, CanBeAssisted and more
Moderator: Moderators
SelfWorkerTime, CanBeAssisted and more
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.
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.
- Guessmyname
- Posts: 3301
- Joined: 28 Apr 2005, 21:07
A patch
I wrote a patch that implements the following FBI tags:
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:
Link to Mantis report
Code: Select all
RepairMult
ReclaimMult
ResurrectMult
CaptureMult
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;
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!
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!
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.KDR_11k wrote:Lua bindings?
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