diff options
Diffstat (limited to 'TemplePushing.c4s')
| -rw-r--r-- | TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/DefCore.txt | 4 | ||||
| -rw-r--r-- | TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Graphics.png | bin | 0 -> 872 bytes | |||
| -rw-r--r-- | TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Script.c | 42 | ||||
| -rw-r--r-- | TemplePushing.c4s/Script.c | 8 | ||||
| -rw-r--r-- | TemplePushing.c4s/System.c4g/Clonk.c | 25 | ||||
| -rw-r--r-- | TemplePushing.c4s/System.c4g/Helpers.c | 12 |
6 files changed, 82 insertions, 9 deletions
diff --git a/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/DefCore.txt b/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/DefCore.txt new file mode 100644 index 0000000..a6b01b4 --- /dev/null +++ b/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/DefCore.txt @@ -0,0 +1,4 @@ +[DefCore] +Name=Push Executer +id=PUEX +Category=C4D_StaticBack
\ No newline at end of file diff --git a/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Graphics.png b/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Graphics.png Binary files differnew file mode 100644 index 0000000..c640ae4 --- /dev/null +++ b/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Graphics.png diff --git a/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Script.c b/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Script.c new file mode 100644 index 0000000..36ccc5f --- /dev/null +++ b/TemplePushing.c4s/Misc.c4d/PushExecuter.c4d/Script.c @@ -0,0 +1,42 @@ +#strict 2 + +static PushExecuter; + +local requestedPushes; + +func Initialize() +{ + if(PushExecuter) + { + RemoveObject(); + return; + } + + requestedPushes = []; + PushExecuter = this; + + AddEffect("IntExecutePushes", this, 1, 1, this); +} + +func RequestPush(object clonk) +{ + if(GetIndexOf(clonk, requestedPushes) == -1) + { + requestedPushes[GetLength(requestedPushes)] = clonk; + } +} + +func FxIntExecutePushesTimer(object target, int effectNumber) +{ + ShuffleArray(requestedPushes); + + for(var requester in requestedPushes) + { + if(requester) + { + requester->ExecutePush(); + } + } + + requestedPushes = []; +}
\ No newline at end of file diff --git a/TemplePushing.c4s/Script.c b/TemplePushing.c4s/Script.c index 47a1b3b..e185707 100644 --- a/TemplePushing.c4s/Script.c +++ b/TemplePushing.c4s/Script.c @@ -29,7 +29,9 @@ func Initialize() { ShowLobby(); eliminatedPlayers = []; - + + CreateObject(PUEX, 0, 0, NO_OWNER); + // Create Thrones for recreational purposes CreateObject(THRN, 590, 420, NO_OWNER); CreateObject(THRN, 410, 210, NO_OWNER); @@ -196,7 +198,9 @@ func Script0() section = CreateObject(sectionID, 0, 0, NO_OWNER); ambienceSounds = mode->~AmbienceSounds() || section->~SectionAmbienceSounds() || []; mode = CreateObject(mode, 0, 0, NO_OWNER); - + + CreateObject(PUEX, 0, 0, NO_OWNER); + var modeGamma = mode->~Gamma(); if (modeGamma) SetGamma(modeGamma[0], modeGamma[1], modeGamma[2]); diff --git a/TemplePushing.c4s/System.c4g/Clonk.c b/TemplePushing.c4s/System.c4g/Clonk.c index adc3c41..9753271 100644 --- a/TemplePushing.c4s/System.c4g/Clonk.c +++ b/TemplePushing.c4s/System.c4g/Clonk.c @@ -39,11 +39,14 @@ protected func ControlThrow(object byObj) } */ -protected func ControlSpecial() +protected func CanPush() { - [$Push$|Image=CXIV] + return GetAction() == "Walk"; +} - if (GetAction() != "Walk") return 0; +func ExecutePush() +{ + if (!CanPush()) return 0; // Use action "Throw" starting with phase 3 SetAction("Throw"); @@ -52,10 +55,10 @@ protected func ControlSpecial() // Find clonks in range var clonks = FindObjects( Find_ID(CLNK), - Find_InRect(-20 + GetDir() * 29, 0, 12, 10), - Find_OCF(OCF_Alive), - Find_Hostile(GetOwner()), - Find_Not(Find_Action("Tumble"))); + Find_InRect(-20 + GetDir() * 29, 0, 12, 10), + Find_OCF(OCF_Alive), + Find_Hostile(GetOwner()), + Find_Not(Find_Action("Tumble"))); if (GetLength(clonks) == 0) return 0; @@ -71,7 +74,15 @@ protected func ControlSpecial() Fling(target, -1 + GetDir() * 2, -1); target->SetKiller(GetOwner()); } +} + +protected func ControlSpecial() +{ + [$Push$|Image=CXIV|Condition=CanPush] + + if (!CanPush()) return 0; + PushExecuter->RequestPush(this); return 1; } diff --git a/TemplePushing.c4s/System.c4g/Helpers.c b/TemplePushing.c4s/System.c4g/Helpers.c index c89784e..0915376 100644 --- a/TemplePushing.c4s/System.c4g/Helpers.c +++ b/TemplePushing.c4s/System.c4g/Helpers.c @@ -34,3 +34,15 @@ global func Angle360(int angle) CleanAngle(angle); return angle; } + +// Fisher-Yates Shuffle +global func ShuffleArray(array& arr) +{ + for(var i = GetLength(arr); i > 0; --i) + { + var randomIndex = Random(i); + var tmp = arr[i - 1]; + arr[i - 1] = arr[randomIndex]; + arr[randomIndex] = tmp; + } +}
\ No newline at end of file |
