CRPL, Totems, and Victory

Started by TrickyDragon, June 26, 2013, 10:42:13 AM

Previous topic - Next topic

TrickyDragon

I was thinking yesterday about the differences between CW1 and CW3...  I feel like in the first game there is more threat, and I wanted to create a map using crpl to replicate this.   It is based on creating a singularity on a location to activate the win phase  Here would be no nullifiers, and the emitters would steadly increase in strength.  You would basically need to hook up to each totem to escape from this world, I imagine using cores to take energy from the totems, and when the last totem stats reviving power it will activate a singularity and destroy all enemies on the map.  Could this all be done with one core( minus the variable emitters)?  If so, how would I go about programming this? (I am a complete noon at programming BTW, I can only write simple programs)
This is Life,  Life happens.

knucracker

I split this post out into its own topic and moved it here so it would not get lost in the topic for a particular build.

TrickyDragon

Ty sir, after I posted I thought "darn, I really should have started a new topic for my post" lol.
This is Life,  Life happens.

J

#3
I can create a script for that as I already can milk totems for energy and count how many are powered. Will be posting it here later.

EDIT: here are the scripts:
You still need to use a core to create the totem because I still need to find out if totem are player units or enemy units. I also haven't tested all parts of the script (grabbed script from the totem and modified it a bit without debugging).
# creates totem, stores UID and destroys itself 4 frames later, allowing another core to take the data
# put this script on a core everywhere where you want a totem being counted for victory
# ------------------------
once
"TOTEM" CurrentCoords CreateUnit ->totemUID
"totem" ->unitName
4 delay self 0 Destroy
endonce

The main script:
# use one core with this script, will blow up all enemy units if totems are powered
# ------------------------------------------
$ammodrain:0.04

once
2 delay
"unitName" "totem" GetCoresWithVar dup ->totemcount 0 do
"totem.crpl" "totemUID" getScriptVar
"totem" I concat ->!
loop
CurrentCoords 500 SetCreeper
endonce

0 ->activecount
<-totemcount 0 do
"totem" I concat <-! dup ->unitUID CONST_AMMO GetUnitAttribute
0 gt if
<-activecount 1 add ->activecount
<-unitUID CONST_AMMO <-unitUID CONST_AMMO GetUnitAttribute <-ammodrain sub SetUnitAttribute
endif
loop

# if all totems are active, blow up all enemy units (insta-win)
<-totemcount <-activecount eq if
0 0 99999 GetEnemyUnitsInRange 0 do
dup Self neq if
2 Destroy
else
pop
endif
loop
Self 2 Destroy
endif

TrickyDragon

so use the first script to make as many totems as i want, then the second will give me my win condition when they are all powered!  thanks a million j!  (the script is small so ill read over it and see if i can get a foot in the door here!)
This is Life,  Life happens.

J

Quote from: TrickyDragon on June 26, 2013, 08:20:43 PM
so use the first script to make as many totems as i want, then the second will give me my win condition when they are all powered!
Yes. If it doesn't work correctly just post it here (or in chat) and I'll fix it. You might want to give the cores a totem custom image to make it look much better the first four frames.
You can also make some 'normal' totems you don't have to power for victory. Just add them the normal way.

Grauniad

A goodnight to all and to all a good night - Goodnight Moon

J

I recreated Tucana and put my scripts in it, but they aren't working correctly yet. Working on it, but it can probably take 2 weeks before I get a chance to fix it.


knucracker

I'm gonna be a noob here and just ask without thinking about it much...
How does this work?


once
"TOTEM" CurrentCoords CreateUnit ->totemUID
"totem" ->unitName
4 delay self 0 Destroy
endonce


It seems like "unitName" is being assigned in a script attached to a unit that is being destroyed.


J

If I want to get the UID of the totem, I need the UID of the core that created it. If I want the UID of the core, I need a variable name+value I can search for. So I simply gave the variable unitName the value "totem". The I can use"unitName" "totem" GetCoresWithVarto get the UID of the core, and"totem.crpl" "totemUID" getScriptVar to get the totem UID (and store it). Note that I use the stack to pass the core UID.

TrickyDragon

Ty J ill update my terror map when I get home tonight.  I spent 2 hours beating that map, careful not to over extend.  It will all be worth it <3
This is Life,  Life happens.

knucracker

Quote from: J on June 28, 2013, 10:32:55 AM
If I want to get the UID of the totem, I need the UID of the core that created it. If I want the UID of the core, I need a variable name+value I can search for. So I simply gave the variable unitName the value "totem". The I can use"unitName" "totem" GetCoresWithVarto get the UID of the core, and"totem.crpl" "totemUID" getScriptVar to get the totem UID (and store it). Note that I use the stack to pass the core UID.

Ahhh...
I wasn't paying attention to the "4 delay".  That keeps the core alive long enough for the other script to look for the var.  I was wondering how the lookup was happening on a dead core, but it is alive and well for 4 frames.