diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2017-01-02 19:34:09 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2017-01-02 19:34:09 +0100 |
| commit | 1f280cb06cc579c2a98d215e202dc0642fb40a3d (patch) | |
| tree | 30a19973594d30792947aa624e7bf585eaa0cf40 /System.c4g | |
| download | DTTubeMail.c4d-1f280cb06cc579c2a98d215e202dc0642fb40a3d.tar.gz DTTubeMail.c4d-1f280cb06cc579c2a98d215e202dc0642fb40a3d.zip | |
Initial
Diffstat (limited to 'System.c4g')
| -rw-r--r-- | System.c4g/ClonkAutoBuy.c | 31 | ||||
| -rw-r--r-- | System.c4g/IDs.c | 10 | ||||
| -rw-r--r-- | System.c4g/TestTargets.disabled | 7 | ||||
| -rw-r--r-- | System.c4g/Utility.c | 62 |
4 files changed, 110 insertions, 0 deletions
diff --git a/System.c4g/ClonkAutoBuy.c b/System.c4g/ClonkAutoBuy.c new file mode 100644 index 0000000..70a020a --- /dev/null +++ b/System.c4g/ClonkAutoBuy.c @@ -0,0 +1,31 @@ +#strict 2 +#appendto CLNK + +func ControlCommandAcquire(object target, Tx, int Ty, object target2, id def) +{ // TODO: decide based on distance to AvailableObject/Homebase and Retriever which one to use + if(!target) // TODO: avoid "stealing" + { + var retriever = FindObject2(Find_InRect(-500, -250, 1000, 500), Find_Func("IsRetriever"), Find_Func("CanRetrieveObject", def, false, target2), Find_Exclude(target), Sort_Distance()); + if(retriever) + { + FinishCommand(this, true); + if(retriever->~HowToProduce(this, def, target2)) + { + return true; + } + } + if(!GetAvailableObject (def, target2)) + { + var produceRetriever = FindObject2(Find_InRect(-500, -250, 1000, 500), Find_Func("IsRetriever"), Find_Func("CanRetrieveObject", def, true, target2), Find_Exclude(target), Sort_Distance()); + if(produceRetriever) + { + FinishCommand(this, true); + if(produceRetriever->~HowToProduce(this, def, target2)) + { + return true; + } + } + } + } + return _inherited(target, Tx, Ty, target2, def); +} diff --git a/System.c4g/IDs.c b/System.c4g/IDs.c new file mode 100644 index 0000000..3ddc963 --- /dev/null +++ b/System.c4g/IDs.c @@ -0,0 +1,10 @@ +#strict 2 + +static const DT_TubeMail_Carrier = TC7I; +static const DT_TubeMail_Distributor = DS7I; +static const DT_TubeMail_Extractor = EX7I; +static const DT_TubeMail_Filler = FI7I; +static const DT_TubeMail_Transmitter = TX7I; +static const DT_TubeMail_TubeKit = TK7I; +static const DT_TubeMail_Tube = TU7I; +static const DT_TubeMail_Utility = UT7I; diff --git a/System.c4g/TestTargets.disabled b/System.c4g/TestTargets.disabled new file mode 100644 index 0000000..7e987a7 --- /dev/null +++ b/System.c4g/TestTargets.disabled @@ -0,0 +1,7 @@ +#strict 2 +#appendto HUT1 +#appendto HUT2 +#appendto HUT3 +#appendto WRKS + +func IsTubeTarget() { return true; } diff --git a/System.c4g/Utility.c b/System.c4g/Utility.c new file mode 100644 index 0000000..1d58f8d --- /dev/null +++ b/System.c4g/Utility.c @@ -0,0 +1,62 @@ +#strict 2 + +global func GetLineEnd(object otherEnd, bool second, object line) +{ + line = line || this; + var ret = GetActionTarget(!!second, line); + if(otherEnd && otherEnd == ret) + { + ret = GetActionTarget(!second, line); + } + return ret; +} + +global func Find_Tube(object target) +{ + return Find_Line(TK7I_Tube, target); +} + +global func Find_Line(id type, object target) +{ + target = target || this; + return [C4FO_Func, "Find_LineCheck", type, target]; +} + +global func Find_LineCheck(id type, object target) +{ + return (!type || type == GetID(this)) && GetProcedure() == "CONNECT" && (GetActionTarget(0) == target || GetActionTarget(1) == target); +} + +global func Put(object container, object obj) +{ + obj = obj || this; + if(container->GetOCF() & OCF_Collection) + { + return container->Collect(obj); + } + else + { + return CanCollect(container, obj, GetID(obj)) && obj->Enter(container) && (container->~Collection(obj, !(GetOCF(container) & OCF_Entrance)) || true); + } +} + +global func CanCollect(object container, object obj, id id) +{ + id = id || GetID(obj); + var collectionLimit = GetDefCoreVal("CollectionLimit", "DefCore", GetID(container), 0); + if(!collectionLimit || container->ContentsCount() < collectionLimit) + { + return !container->~RejectCollect(id, obj) && (!obj || !obj->~RejectEntrance(container)); + } + return false; +} + +global func Find_GrabPutGet(int type) +{ + return [C4FO_Func, "Find_GrabPutGetCheck", type]; +} + +global func Find_GrabPutGetCheck(int type) +{ + return GetDefGrabPutGet(GetID()) & type; +} |
