From fa5403dccd986022b2a849e2078f043c3225348a Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Mon, 2 Jan 2017 19:33:41 +0100 Subject: Initial --- Items.c4d/Sensors.c4d/ObjectSensor.c4d/ActMap.txt | 3 + Items.c4d/Sensors.c4d/ObjectSensor.c4d/DefCore.txt | 19 ++ .../Sensors.c4d/ObjectSensor.c4d/Graphics.png | Bin 0 -> 4295 bytes Items.c4d/Sensors.c4d/ObjectSensor.c4d/Names.txt | 2 + Items.c4d/Sensors.c4d/ObjectSensor.c4d/Script.c | 292 +++++++++++++++++++++ .../Sensors.c4d/ObjectSensor.c4d/StringTblDE.txt | 17 ++ .../Sensors.c4d/ObjectSensor.c4d/StringTblUS.txt | 15 ++ 7 files changed, 348 insertions(+) create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/ActMap.txt create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/DefCore.txt create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/Graphics.png create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/Names.txt create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/Script.c create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblDE.txt create mode 100644 Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblUS.txt (limited to 'Items.c4d/Sensors.c4d/ObjectSensor.c4d') diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/ActMap.txt b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/ActMap.txt new file mode 100644 index 0000000..6f9738a --- /dev/null +++ b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/ActMap.txt @@ -0,0 +1,3 @@ +[Action] +Name=Wall +Facet=0,4,10,10 diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/DefCore.txt b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/DefCore.txt new file mode 100644 index 0000000..af1dbd5 --- /dev/null +++ b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/DefCore.txt @@ -0,0 +1,19 @@ +[DefCore] +id=OS7I +Name=Object sensor +Category=C4D_Object|C4D_SelectMaterial|C4D_SelectKnowledge|C4D_SelectHomebase +Width=10 +Height=4 +Offset=-5,-2 +Mass=10 +Value=5 +Components=METL=1; +Picture=10,0,64,64 +Vertices=1 +VertexFriction=100 +VertexY=-2 +Grab=2 +Collectible=1 +MaxUserSelect=10 +Rebuy=1 +NoPushEnter=1 diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Graphics.png b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Graphics.png new file mode 100644 index 0000000..6a87007 Binary files /dev/null and b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Graphics.png differ diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Names.txt b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Names.txt new file mode 100644 index 0000000..0cb612c --- /dev/null +++ b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Names.txt @@ -0,0 +1,2 @@ +DE:Objektsensor +US:Object sensor diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Script.c b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Script.c new file mode 100644 index 0000000..a27a398 --- /dev/null +++ b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/Script.c @@ -0,0 +1,292 @@ +#strict 2 +#include LS7I + +local detectIDs, exceptIDs, denyIDs, detectCats, denyCats, hostility; + +func Init() +{ + detectCats = C4D_Living | C4D_Object | C4D_Vehicle; + denyCats = 0; + detectIDs = [C4FO_Or]; + exceptIDs = [C4FO_Or]; + denyIDs = [C4FO_Or]; + return _inherited(...); +} + +func ControlUp(object caller) +{ + if(!Attached() && caller) + { + caller->Collect(this); + } +} + +func Attach(object caller, object contained) +{ + if(contained && GetProcedure(contained) == "WALK") + { + return SetPosition(GetX(), GetY() + 10); + } +} + +func Triggers() { return [["$ObjectTrigger$"], ["$NoObjectTrigger$"], ["$DeniedObjectTrigger$"]]; } + +func Setup(object caller, int &menuIndex) +{ + selectCaller = caller; + AddMenuItem("$SetupDetection$", "SetupDetection", RSR1, caller, 0, caller, 0, C4MN_Add_ForceNoDesc); + ++menuIndex; + return true; +} + +func SetupDetection(id id, object caller, int selection) +{ + if(CreateMenu(RSR1, caller, this, C4MN_Extra_None, "$SetupDetection$", 0, C4MN_Style_Context, 0)) + { + var menuIndex = 0; + AddMenuItem("$AddType$", "AddType", GetID(), caller, 0, caller, 0, C4MN_Add_ForceNoDesc); + ++menuIndex; + AddMenuItem(Format("$TargetOwner$", ["$All$", "$Allied$", "$Hostile$", 0, "$DenyHostile$", "$DenyAllied$"][hostility]), "ChangeHostility", GetID(), caller, 0, caller, 0, C4MN_Add_ForceNoDesc); + ++menuIndex; + + for(var part in [["$DetectDef$", detectCats], ["$DetectDenial$", denyCats]]) + { + for(var cat in [[C4D_Vehicle, "$Vehicle$", LORY], [C4D_Living, "$Living$", WIPF], [C4D_Object, "$Object$", ROCK]]) + { + if(part[1] & cat[0]) + { + AddMenuItem(Format(part[0], cat[1]), "RemoveCat", cat[2], caller, 0, cat[0], 0, C4MN_Add_ForceNoDesc); + ++menuIndex; + } + } + } + + for(var part in [["$DetectDef$", detectIDs], ["$DetectException$", exceptIDs], ["$DetectDenial$", denyIDs]]) + { + for(var i = 1; i < GetLength(part[1]); ++i) + { + AddMenuItem(Format(part[0], GetName(0, part[1][i][1])), "RemoveDef", part[1][i][1], caller, 0, ++menuIndex, 0, C4MN_Add_ForceNoDesc); + } + } + SelectMenuItem(selection - 1, caller); + SelectMenuItem(selection, caller); + } +} + +func RemoveCat(id id, int cat, bool right) +{ + var denial = detectCats & cat; + detectCats &= ~cat; + denyCats &= ~cat; + if(right) + { + if(denial) + { + denyCats |= cat; + } + else + { + detectCats |= cat; + } + } + SetupDetection(0, selectCaller, 3); +} + +func RemoveDef(id id, int indexPO, bool right) +{ + var part = [C4FO_ID, id], exception, denial; + if(right) + { + exception = GetIndexOf2(part, detectIDs) == -1; + denial = GetIndexOf2(part, denyIDs) == -1; + } + ArrayEraseItem(detectIDs, part); + ArrayEraseItem(exceptIDs, part); + ArrayEraseItem(denyIDs, part); + if(right) + { + if(exception) + { + if(denial) + { + denyIDs[GetLength(denyIDs)] = part; + } + else + { + detectIDs[GetLength(detectIDs)] = part; + } + } + else + { + exceptIDs[GetLength(exceptIDs)] = part; + } + } + SetupDetection(0, selectCaller, indexPO - 1); +} + +func AddType(id id, object caller, int selection) +{ + var menuIndex = 0; + if(CreateMenu(RSR1, caller, this, C4MN_Extra_None, "$AddType$", 0, C4MN_Style_Context, 0)) + { + for(var cat in [[C4D_Vehicle, "$Vehicle$", LORY], [C4D_Living, "$Living$", WIPF], [C4D_Object, "$Object$", ROCK]]) + { + if(!(detectCats & cat[0])) + { + AddMenuItem(cat[1], "AddCat", cat[2], caller, 0, cat[0], 0, C4MN_Add_ForceNoDesc); + ++menuIndex; + } + } + var defs = []; + for(var obj in FindObjects(Find_Exclude(this), (caller || this)->Find_AtPoint(), IgnoreSensorIgnored(), Find_Category(C4D_Living | C4D_Object | C4D_Vehicle))) + { + var def = GetID(obj); + if(GetIndexOf(def, defs) == -1 && GetIndexOf2([C4FO_ID, def], detectIDs) == -1 && GetIndexOf2([C4FO_ID, def], exceptIDs) == -1) + { + defs[GetLength(defs)] = def; + } + } + + for(def in defs) + { + AddMenuItem(GetName(0, def), "AddDef", def, caller, 0, ++menuIndex, 0, C4MN_Add_ForceNoDesc); + } + + SelectMenuItem(selection - 1, caller); + SelectMenuItem(selection, caller); + } +} + +func AddCat(id id, int cat, bool right) +{ + if(right) + { + denyCats |= cat; + } + else + { + detectCats |= cat; + } + AddType(0, selectCaller, 1); +} + +func AddDef(id id, int indexPO, bool right) +{ + if(right) + { + exceptIDs[GetLength(exceptIDs)] = [C4FO_ID, id]; + } + else + { + detectIDs[GetLength(detectIDs)] = [C4FO_ID, id]; + } + AddType(0, selectCaller, indexPO - 1); +} + +func ChangeHostility(id id, object caller, bool right) +{ + if(right) + { + if(hostility) + { + if(hostility > 2) + { + hostility -= 3; + } + else + { + hostility += 3; + } + } + else + { + hostility = 4; + } + } + else + { + var denyOther = (hostility > 2) * 4; + ++hostility; + if((!denyOther && hostility > 2) || (denyOther && hostility > 5)) + { + hostility = denyOther; + } + } + + SetupDetection(0, caller, 1); +} + +func Check(bool retrigger) +{ + var posCond; + if(Attached() && !GBackSemiSolid(0, 2)) + { + SetCategory(C4D_Structure); + SetAction("Wall"); + SetSolidMask(); + posCond = Find_AtRect(-3, 0, 8, 8); + } + else + { + SetCategory(C4D_Object); + SetAction("Idle"); + posCond = Find_AtPoint(0, -3); + if(!Contained() && GetSpeed() < 5) + { + SetSolidMask(0, 0, 10, 1); + } + else + { + SetSolidMask(); + } + } + var obj; + var additionalConds = [C4FO_And]; + var hostilityCond = [0, Find_Not(Find_Hostile(GetOwner(this))), Find_Hostile(GetOwner(this))][hostility % 3]; + var hostilityDenyCond = [0, Find_Hostile(GetOwner(this)), Find_Not(Find_Hostile(GetOwner(this)))][hostility - 3]; + if(GetLength(exceptIDs) > 1) + { + additionalConds[GetLength(additionalConds)] = Find_Not(exceptIDs); + } + if(hostilityCond) + { + additionalConds[GetLength(additionalConds)] = hostilityCond; + } + var additionalDenyConds = [C4FO_Or]; + if(denyIDs) + { + additionalDenyConds[GetLength(additionalDenyConds)] = denyIDs; + } + if(denyCats) + { + additionalDenyConds[GetLength(additionalDenyConds)] = Find_Category(denyCats); + } + if(hostilityDenyCond) + { + additionalDenyConds[GetLength(additionalDenyConds)] = Find_And(Find_Or(detectIDs, detectCats && Find_Category(detectCats)), hostilityDenyCond); + } + ClearParticles("PSpark", this); + if(GetLength(additionalDenyConds) > 1 && (obj = FindObject2(Find_Exclude(this), posCond, Find_NoContainer(), Find_Category(C4D_Living | C4D_Object | C4D_Vehicle), IgnoreSensorIgnored(), additionalDenyConds))) + { + CreateParticle("PSpark", 0, 0, 0, 0, 50, RGB(192, 0, 0), this); + if(triggered != 2 || retrigger) + { + triggered = 2; + return Trigger(2, obj); + } + } + else if(obj = FindObject2(Find_Exclude(this), posCond, Find_NoContainer(), IgnoreSensorIgnored(), Find_Or(detectIDs, detectCats && Find_Category(detectCats)), additionalConds)) + { + CreateParticle("PSpark", 0, 0, 0, 0, 50, RGB(0, 192, 0), this); + if(!triggered || retrigger) + { + triggered = true; + return Trigger(0, obj); + } + } + else if(triggered || retrigger) + { + triggered = false; + return Trigger(1); + } +} diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblDE.txt b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblDE.txt new file mode 100644 index 0000000..68388c2 --- /dev/null +++ b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblDE.txt @@ -0,0 +1,17 @@ +ObjectTrigger=Objekt erkannt +NoObjectTrigger=Objekt entfernt +DeniedObjectTrigger=Verbotenes Objekt erkannt +SetupDetection=Erkennung einstellen +DetectException=Ausnahme: %s +DetectDef=%s +DetectDenial=Verbot: %s +AddType=Erkennungstyp hinzufügen +Vehicle=Fahrzeuge +Living=Lebewesen +Object=Objekte +TargetOwner=Zielbesitzer: %s +All=Alle +Allied=Verbündet +Hostile=Feindlich +DenyHostile=Verbündet, Feindlich verboten +DenyAllied=Feindlich, Verbündet verboten diff --git a/Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblUS.txt b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblUS.txt new file mode 100644 index 0000000..814bd4f --- /dev/null +++ b/Items.c4d/Sensors.c4d/ObjectSensor.c4d/StringTblUS.txt @@ -0,0 +1,15 @@ +ObjectTrigger=Object detected +NoObjectTrigger=Object removed +DeniedObjectTrigger=Denied Object detected +SetupDetection=Setup detection +DetectException=Exception: %s +DetectDef=%s +DetectDenial=Denial: %s +AddType=Add detection type +Vehicle=Vehicles +Living=Living +Object=Objects +TargetOwner=Target owner: %s +All=All +Allied=Allied +Hostile=Hostile -- cgit v1.2.3-54-g00ecf