summaryrefslogtreecommitdiffstats
path: root/TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c
diff options
context:
space:
mode:
authorJan <>2015-02-02 17:55:29 +0100
committerJan <_>2015-07-10 17:49:45 +0200
commit32a9632fbca3dd7a88bd3154b84a3773af39c276 (patch)
treea226b9404844a73c7229e9d13db993c86b5be2c1 /TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c
parent40fb3e5d61c44886b06d839a35adb0c11a5f918f (diff)
downloadtempelschubsen-32a9632fbca3dd7a88bd3154b84a3773af39c276.tar.gz
tempelschubsen-32a9632fbca3dd7a88bd3154b84a3773af39c276.zip
TemplePush v6.1.7601.18409.c4s
Diffstat (limited to 'TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c')
-rw-r--r--TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c b/TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c
new file mode 100644
index 0000000..380ee86
--- /dev/null
+++ b/TemplePushing.c4s/Misc.c4d/SpawnPointSpawner.c4d/Script.c
@@ -0,0 +1,57 @@
+/*-- Spawn Point Spawner --*/
+
+#strict 2
+
+local locations, definitions, spawnInterval;
+local sumProbability;
+local gamma;
+
+public func CreateSpawnPoints()
+{
+ for (var pos in locations)
+ {
+ var spawnpoint = CreateObject(SNPT, pos[0], pos[1], NO_OWNER);
+ if (gamma) spawnpoint->SetGamma(gamma[0], gamma[1], gamma[2]);
+ spawnpoint->Enable(this);
+ }
+}
+
+// [[x1, y1], [x2, y2], ...]
+public func SetLocations(array locations)
+{
+ LocalN("locations") = locations;
+}
+
+// [[FLNT, 50], [SFLN, 20], ...]
+public func SetDefinitions(array definitions)
+{
+ LocalN("definitions") = definitions;
+
+ sumProbability = 0;
+ for (var def in definitions)
+ {
+ sumProbability += def[1];
+ }
+}
+
+public func SetSpawnpointGamma(int color1, int color2, int color3)
+{
+ gamma = [color1, color2, color3];
+}
+
+public func GetSpawnInterval() { return spawnInterval; }
+
+public func SetSpawnInterval(int spawnInterval)
+{
+ LocalN("spawnInterval") = spawnInterval;
+}
+
+public func GetRandomDefinition()
+{
+ var rnd = Random(sumProbability);
+ for (var def in definitions)
+ {
+ rnd -= def[1];
+ if (rnd < 0) return def[0];
+ }
+}