1.0
06 Aug 2018 01:36
const uint NumberOfBitsDevotedToSyncParameter = 3; //this should correspond to the number of bits you assign to the Sync parameter in your JCS.ini (or MLLE equivalent) entry for Swinging Vine. So for example if you give it a parameter Sync:2, this variable should ALSO equal 2.
void onLevelLoad() {
jjObjectPresets[OBJECT::SWINGINGVINE].behavior = SyncedVine;
}
void SyncedVine(jjOBJ@ obj) {
obj.var[1] = 128; //vine length--set this in whatever way appeals to you, but a constant 128 is the value that normal swinging vines use.
if (lastSwingingVineLUTLength != obj.var[1]) { //need to generate LUT (LookUp Table) by doing the same math swinging vine objects do
lastSwingingVineLUTLength = obj.var[1];
PossibleVineVariableConfigurations = array<array<int>> = {{obj.var[1] * 256, 0}};
while (true) {
const array<int>@ oldConfiguration = @PossibleVineVariableConfigurations[PossibleVineVariableConfigurations.length-1];
array<int> newConfiguration(2);
newConfiguration[1] = oldConfiguration[1] + ((oldConfiguration[0] > 0) ? -32 : 32);
newConfiguration[0] = oldConfiguration[0] + newConfiguration[1];
if (newConfiguration[1] == 0 && newConfiguration[0] == obj.var[1] * 256) //gone full circle
break;
PossibleVineVariableConfigurations.insertLast(newConfiguration);
}
}
const array<int>@ syncedConfiguration = PossibleVineVariableConfigurations[(jjGameTicks + (jjParameterGet(uint(obj.xOrg) >> 5, uint(obj.yOrg) >> 5, 0, NumberOfBitsDevotedToSyncParameter) * (PossibleVineVariableConfigurations.length / (1 << NumberOfBitsDevotedToSyncParameter)))) % PossibleVineVariableConfigurations.length];
for (uint i = 0; i < 2; ++i)
obj.var[2 + i] = syncedConfiguration[i];
//clean up:
obj.state = STATE::ACTION;
obj.behavior = BEHAVIOR::SWINGINGVINE;
obj.behave();
}
int lastSwingingVineLUTLength = -1;
array<array<int>> PossibleVineVariableConfigurations;
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.