Using a UREG to make an onscreen points counter

To make a points counter that goes up when you find gold/money for
example you could do something like this , what you would have to do is
make your gold/money as animations that dissappear and add a value to a
universe register when the player is close , to make the value of that
register appear on screen you would make an entry in your console text
something like this

[begin object]
Name: UNIV_REG ;universe register display
Enabled: 1 ;enabled
Attribute: 12 ;univ. reg. 12 (Gold)
Transparent: -1 ;transparent
Draw-flag: -1 ;unused
Scale-flag: -1 ;unused
X-orig: 32 ;x screen pos.
Y-orig: 140 ;y screen pos.
X-size: -1 ;unused
Y-size: -1 ;unused
Key-toggle: -1 ;no key toggle
Key-sound: -1 ;no key sound
Color: 215 ;text color
String: DEFAULT ;unused
[end object]

This object displays the selected Universe Register value on screen . The
Universe Register displayed is determined by the number entered in the
Attribute: field , for this example I have used ureg 12 but you can use any
available ureg you want , the color of the display is derived from a palette
index number set in the Color: field and the x and y origin values are the
position on the screen .

The animation would be something like this and the object for your frames
would be your gold/money

Frame 0 skip if close see player 100
Frame 1 sym obj gold go to 0
Frame 2 Univreg add 12 100
Frame 3 Play sound ( sound number )
Frame 4 Delete myself

Frames 0 and 1 will keep the animation in a loop until the player touches it
.
Frame 2 will add 100 to ureg 12 and put that value in the display created in
the console text .
Frame 3 is optional and will play a sound when you get some gold if you
want it to .
Frame 4 deletes the anim so the counter doesn't keep going up .

You can place as many of the animations as you want in you level and each
time you find one the counter will go up by the amount you set in frame 2 .

If you want to reset the counter to zero for each level you will have to
make an invisible animation at the start of each level that sets the
Universe reg back to zero then deletes itself .




Make a UREG ask the player a Y/N question

This example is for playing or not playing looped music when asked by a
text message but you can change it to any event you want .

First off is to put a string in your pstr.txt like the one below

string 84
Do you want to turn on the radio ?
Press Y or N
~yu43=1~nu43=2
sdone

The text message is number 84 and the Ureg that triggers the event is
number 43 , so if you press key Y ureg 43 is set to value 1 and if you press
key N the value is set to 2 , now you need an animation that will check for
Ureg 43 and meet a condition when the ureg is at the values set ,
something like the one below .

EG
Frame 0 Branch if close to frame 2
Frame 1 Unconditional branch to frame 0
Frame 2 Display text message 84
Frame 3 Skip if Ureg 34=1
Frame 4 Remove this animation
Frame 5 Play sound ( sound number )
Frame 6 No operation just a delay the length of the sound file
Frame 7 Unconditional branch to frame 5

You would put the animation near to a radio and mark it as invisible , then
when the player approaches the message will appear asking you for an
input , if you press Y the music will play , if you press N it won't .






Universe registers are very versatile and are used to make the whole game
more interactive for the player, at first they can be quite daunting but when
you understand them you can use them to do just about anything, here are
some examples of how versatile they can be.


Event trigger

Lets say your way is blocked by a mine that is tripped if the player touches it
thus killing the player , above it there is a crate suspended on a crane so to
safely trigger the mine you want to drop the crate on it .

You will need three animations , one for the crate , one for the mine and one
for the switch , for this example I will use UREG 5.

The crate animation is set so that the sym objects for the frames are
overriden by a crate MD2

0 symobj crate.vgr skip if UReg=Value ureg# 5 uvalue 1
1 symobj crate.vgr goto 0
2 symobj crate.vgr delete myself

frames 0 and 1 keep it in a loop until UREG 5 = 1 .


The mine animation is of an animated MD2 that overrides a sym object and
cycles through 2 skins that make a light flash to show that it is armed .

0 Sym obj mine.vgr jump if close frame 3
1 Sym obj mine.vgr Skip if UReg=value 5 uvalue 1
2 Sym obj mine.vgr goto 0
3 Sym obj mine.vgr Make blast with sound radius 600
4 Sym obj mine.vgr Univreg Add Ureg 187 100
5 Sym obj mine.vgr Univreg Add Ureg 175 50
6 Sym obj mine.vgr Set Univ Reg ureg 228 4
7 Sym obj bcrate.vgr goto8
8 Sym obj bcrate.vgr goto7

frames 0 to 2 hold the animation in a loop until either the player gets close or
UReg 5 = 1 , frame 3 makes the blast and plays the explosion sound , frames
4,5 and 6 take care of the particle explosion and the ground shake , frames 7
and 8 replace the mine MD2 with an MD2 of a broken crate with a scorched
skin and hold it in a loop

The switch animation is an MD2 of a switch which is actually 2 MD2's , one
that is off and one that is on .

0 SHP WALL SwtOff.vgr Skip if close/See plyr 100cm
1 SHP WALL SwtOff.vgr goto 0
2 SHP WALL SwtOn.vgr Play Sound 15
3 SHP WALL SwtOn.vgr Display TextMessage 10
4 SHP WALL SwtOn.vgr Set Univ Reg 5 1
5 SHP WALL SwtOn.vgr goto 6
6 SHP WALL SwtOn.vgr goto 5

Frame 0 and 1 keep the switch in a loop until the player touches the switch ,
when touched frame 0 jumps to frame 2 which triggers a sound , a text
message and sets the ureg which removes the mine and the crate , frames 5
and 6 keep the animation in a loop that displayes the swich in its activated
state .

Note:- when making animations that are overriden with MD2's mark them as
no draw so only the MD2 is visible and not the .vgr , also if you are making a
switch that needs the player to touch it mark it as no bump or the player
might not be able to get close enough to trigger the animation .



Object removal or placement via UREG

A quick example of how to use a universe register to remove a wall from a
game using a platform trigger , you can use any free UReg number you
choose I just used 8 for this example .

Use the wall image you want to remove for each frame .

frame0 Skip if UReg=value ureg#8 uvalue 1
frame1 Goto frame 0
frame2 Delete myself

Now lay a platform and select "Platform sets a Universe Register" , put 8 in
the Universe register Number box and 1 in the Number to place in this
register box

That's it , when you step on the platform the wall will disappear , you can use
this method to remove any objects including MD2's .
You can also put objects into levels by having frames 0 and 1 have no objects
in them then have 2 more frames that loop to each other that have the
wall/object defined in them .



Using a UREG to make a timer

This example displays an onscreen timer that leads to an explosion.

You will have to make a ureg object in the console text that displays a value
for the ureg you choose to trigger your explosion, what you would have to do
is make an animation where it sits in a loop and is triggered by an event that
starts the timer and each subsequent frame of the animation will set the ureg
to a value, start at the highest value of your timer then make each frame
reduce the uvalue by one until you get to one , it's up to you what delay value
you want to use. The animation would look something like this ( I used ureg
10 for this example )


frame 0 jump if close/see player 100
frame 1 goto frame 0
frame 2 set univ reg 10 uvalue 100 dly 2
frame 3 set univ reg 10 uvalue 99 dly 2
frame 4 set univ reg 10 uvalue 98 dly 2

etc. down to univ reg 10 uvalue 1 dly 2

( don't use value zero because the default ureg value is zero and the
explosion will be triggered when the level loads )

you would also have the explosion animation set to be triggered when Ureg
10 = uvalue 1

The console text entry would look like this

[begin object]
Name: UNIV_REG ;universe register display
Enabled: 0 ;enabled
Attribute: 10 ;univ. reg. 10 (timer)
Transparent: -1 ;transparent
Draw-flag: 10 ; display only if univ.reg 10 > 0
Scale-flag: -1 ;unused
X-orig: 90 ;x screen pos.
Y-orig: 20 ;y screen pos.
X-size: -1 ;unused
Y-size: -1 ;unused
Key-toggle: -1 ;no key toggle
Key-sound: -1 ;no key sound
Color: 212 ;text color
String: DEFAULT ;unused


( Printer friendly version click here )