View Single Post
Old 12-08-10, 15:32   #4
Join Date: Nov 2007
Posts: 1,689

The reusable puzzle item

Letīs start with this. With the normal puzzle hole slot you can only insert a puzzle item and trigger things by it. But why you shouldnīt be able to take the puzzle item back and use again?
You wonīt be able to use the puzzlehole-slot to accomplish this, because the hardcoded stuff interferes with our idea. This also means, that you canīt use the usual trigger setup with the switch-trigger. So I place the puzzle hole/puzzle done-objects in "blank" animating mip-slots. Both objects area placed on the same square on the same place. The puzzle done-object is made invisible with the action trigger "Perform (E) flipeffect on <#>object; (E) : 21: Hide object. Makes #ANIMATING invisible" before Lara approaches the puzzle hole.
So what we have to do, so that Lara does the same stuff, as she would do on a normal puzzle hole: First on pressing action in front of it, the inventory pops up at the puzzle item, she aligns itself to an ideal position and the inserting animation is played? Then second at the appropriate frame all, what has to be triggered, is triggered: the puzzle-done object appears, the puzzle item is removed from the inventory, doors are opened or whatever else you want to trigger. You have to study especially Paolones animation tutorial project to understand all of this. The Animation-script command together with TestPosition-command is needed to accomplish the first part, and the use of an animcommand gives us the means to accomplish the triggering. There are always more than one solution to a problem, but this solution is relatively effective and works for sure.

And now the script entries. Iīll add later on more and more explanations!

;reusable puzzle item

;1.part: Inserting the Puzzleitem

Very important to understand the Animation-command above is, that I use the Fan-flag FAN_PERFORM_TRIGGER_GROUP. So the first argument 59 isnīt a number of an animation here, but itīs the number of a triggergroup (TG). This TG will be executed under the conditions given in the Animation command. First you have to press the Action-key. Some more conditions are given in the multiple environmental condition with the number 12 (see below). The last condition given by the last argument is, that Lara has stateID 2 (standing).
The Fan-flag FAN_ALIGN_TO_ENV_POS causes the alignment of Lara in front of the puzzle hole to an ideal position, in which she can execute the animation.

Triggergroup= 59,$2000, 306, $101,$2000, 77, $86;pop up inventory on puzzleitem2, perform animation 134
This is the TG, which is exexcuted under the conditions given in the Animation-command. It causes the popup of the inventoy at the puzzle item and the execution of the animation.

Used triggers:
Inventory-Item. Pop up inventory to select the <&>Item in (E)way
; <&> : PUZZLE_ITEM2 Slot=176
; (E) : If item si missing play LARA_SAY_NO sound

Lara. (Animation) Force <&>Animation (0-255) of (E)slot for Lara
; <&> : 134 Animation
; (E) : SLOT_000 LARA

This is the multiple environmental condition used in the Animation-command. It consist of three part: first, that Lara is in a position given by TestPosition-command 4 (see below), second that she has free hands and third that she fulfills some more conditions, stored in the Condition-TG 60.

TestPosition= 4, IGNORE, Animating8_Mip,-300,+300,-100,+100,200-200,200+200,-$1000,$1000,-$1000,$1000,-$1000,$1000
In this command the position of Lara relative to the puzzle hole in the Animating8_Mip-slot is defined. It conatains three room-coordinates and three facing-coordinates. Basically it defines a box of possible positions in the room, fromwhere lara is aligned to the ideal position and then the animation (or here the TG 59) is then executed. The given coordinates can be used for every puzzle hole-situation.

Triggergroup= 60,$8000, 0, $2D,$8000, 176, $2; GBA1 bit0 clear?,puzzleitem2 present?
In this condition-TG there are two conditions stored, which are used in the MultEnvCondition 12 above. In the first condition it checks, if in variable GlobalByteAlpha1 the bit0 is clear. This is a sign for the engine, that the puzzle hole is currently unused. In the second condition is checks, if the Puzzle Item2 is present in the inventory.

Used triggers:
Global Byte Alfa1
; <&> : Variables. The <#>Numeric Variable has the (E)Bit clear

; (E) : Bit 0 ($00000001 ; 1)
; <&> : Inventory. Present <#>inventory_item.

Triggergroup= 62,$9000, 117, $236,$5000, 116, $160D,$5000, 117, $150D,$2000, 234, $0,$2000, 47, $1, ....
; TG 62 (exported Animcommandtrigger): animating8mip 117 closer then 2 clicks?,116 visible, 117 invisible,set gba1 bit 0, remove puzzleitem2 from inventory...- add the exported triggers for the stuff you want to trigger

The execution of TG 62 is exported as an animcommand to frame 76 of animation 134:
Add a SetPosition anim command with following values:

Set Position [-24500] [118] [62]

Infos about exported trigger
Exporting: TRIGGER(62:0) for FLIPEFFECT(118)
<#> : TriggerGroup. Perform <&>TriggerGroup from script.dat in (E)way
<&> : TriggerGroup= 62
(E) : Mutiple performing (to use when in TriggerGroup there is some condition)

AnimCommand: Frame=76
You go then to wadmerger, open animation 134 of Lara in the AnimationEditor in insert the Animcommand Set Position [-24500] [118] [62] to this animation of Lara, which is the puzzle-insert-animation.

The TG 62 contains the following triggers:
The first one is a condition which checks for the distance of Lara relative to the puzzle hole. So we are sure, that the triggers are only executed in front of this puzzle hole and not at other times, if Lara executes the animation.
Lara. Distance. Lara is distant by <#>Moveable less or even than (E)Clicks
; (E) : Value= 2

The next to triggers make the puzzle hole invisible and the puzzle done visible.
Perform (E) flipeffect on <#>object
; (E) : 21: Hide object. Makes #ANIMATING invisible

Perform (E) flipeffect on <#>object
; (E) : 22: Show object. Makes #ANIMATING visible

Then we have the flipeffect Variables. Numeric. Set in <&>Variable the (E)bit; <&> : Global Byte Alfa1; (E) : Bit 0 ($00000001 ; 1). This bit is set to give the engine a sign, that the puzzle hole is currently used.

We have to remove the puzzle item from the inventory, too:
Inventory-Item. Remove <&>inventory-item from inventory
; <&> : PUZZLE_ITEM2 Slot=176

Finally you would add your exported triggers for the things, which you want to achieve by all the action, like opening doors etc..

;2.part: Getting back the puzzle item


This time the animation command trigges animation 469, the puzzle item take away-animation. I only mirrored animation 134 to create this one. It works good enough.


In this case we use three environmental conditions, which are stored in this MultEnvCondition-command as conditions, inder which animations 469 should be executed. Again we have another condition-TG 58, which contains the condition, if the bit in GlobalByteAlpha1 is set as a sign, that the puzzle item is inserted and can be taken out (see also below). As second condition we have again the TestPosition. Itīs the same as above for the inserting of the puzzle item, of course. As third condition Lara mus have free hands.

Triggergroup= 58,$8000, 0, $2C; gba1 bit0 set?

see above

Triggergroup= 61,$9000, 117, $236,$2000, 48, $101,$5000, 116, $150D,$5000, 117, $160D,$2000, 235, $0, ...
; TG 61 (exported Animcommandtrigger): animating8mip 117 closer then 2 clicks?, Add puzzleitem2 to inventory,116 invisible, 117 visible,clear gba1 bit 0,...- add the exported trigger, if you want to trigger something

The execution of this TG is exorted as animcommand (Set Position -24552,118,61) into animation 469, frame 32.
In this TG we have triggers to add puzzle item2 to the inventory again, making puzzle done invisble and puzzle hole visible, clearing bit 0 in the variable GlobalByteAlpha1 as a sign for the engine, that we have a free puzzle hole again and then you should add your triggers for what you want to achieve like closing the door again or whatever else.

Last edited by Raymond; 12-08-10 at 19:26.
Raymond is offline