Help with logic needed

b.o.k. Hi folks,
I have a problem with a room where the player is supposed to shoot someone. I have an animation with 5 cels (view 27) for the shooting ego and the amount of shots left v46. No matter where I position the ego in the room (far away from other objects or control lines, the animation doesnt work. The ego gets updated with cel 2 or 3 of the shooting-animation and flag115 is not set. thus the game can't continue. Why?
This is the code:

if ((said("shoot") || said("use","gun","rol"))) {
 if(v46>0) {
   print("Good idea. You draw your gun, aim and shoot.");
 else {
   print("Your gun is not loaded.");

if(isset(f115)) {  
bokkers Hi,
the problem seems to have something to do with the object being o0/ego. With other objects, the end.of.loop-thins works perfectly. Why???
Vonster_D_Monster [color=Red]I think you need to set f31, for ego to cycle while not moving :)

Then reset it after you use the end.of.loop command.

I'll take a look at it :)

Trapped This is a REEEEEEAAAALY old thread... so pardon my ignorace, but i've been doing this for what... three days tops!? ;D

The problem seems to be that the object is o0/ego... The best thing to do is erase ego, and put another object (say... uh... o7?) with the shoot animation loaded in ego's place... then after that is done erase o7 and put o0 back in the right place.

It's damn messy... and i seem to do something wrong, and the o7 animation gets skipped, and goes straight on to o0, and i spend hours and hours trying to see what i am doing so someone help out an ignorant newbie... or i'm going to sell my computer and take up golf instead!! ::)
AGI1122 Well use a flag to see which specific view needs to be draw:

if (f100) { // If f100 is set
reset(f100); // reset f100
erase(ego); // erase ego
animate.obj(o7); // animate object 7
set.view(o7,2); //set view of object 7 to 2
draw(o7); // draw object 7
end.of.loop(o7,f101); // when the view reaches the end of the loop set f101

if (f101) {
reset(f101); // reset f101
erase(o7); // erase the second animation
draw(ego); // draw the regular ego view

Hope this helps, tell me if you need any help.
Andrew_Baker Strange, but I can't get if (done_flag) conditionals to work. I have to use a timer to make sure the animation completes itself.

I also substitute another object for the ego when I'm doing a special character animation. It seems to yield less buggy results.

I'm going to be doing a special room in VDG that will have the characteristics of Flashback or Oddworld, and it uses a lot of this kind of ego-substitution animation.

Personally, I'm having trouble with reverse.loop for some reason.
blacki Without reading too much into it, I'd try if(isset(f115)){ reset(f115); then the rest... for some reason that made a difference in my wear balaclava animation.
Trapped hey blacki... That worked... :o

How strange is that? ... and anyway, shouldn't that be a paradox?? Enabling a flag... then disabling the flag when the flag has been enabled, so no flag was ever enabled in the first place?? ;D

he he.

Thanks... It works, so that's all that matters.

all hail:


AGI1122 ... My post had the same thing in it...
if(f100) {

The only difference was the flag used...
Trapped ...well... I like 115 better than 100.. ::)


thanks BOTH of you. :)
blacki I think it has something to do with AGI being multi-threaded. It will just run your IF statement (because the flag is set) until the next thread comes along and it restarts the IF statement again. Thats why you need to reset the flag straight away.
AGI1122 Actually this happens because AGI runs in cycles, every cycle it sees that the flag was still set and would run everything inside of that block of code. But when you reset it the interpreter knows not to run that block of code.
blacki If that was the case then, this...
b.o.k. wrote:

if(isset(f115)) {
sonneveld As somebody who's disassembled the interpreter and knows how it works.. I can safely say it doesn't have any "virtual processors" embedded in it.

It processes one command at a time. Sure, you can jump from one logic to another.. but the interpreter only concentrates on that one logic before returning to the original.

The cycle goes like this:

Read input -> parse logic -> update graphics -> loop

Also, the interpreter was written for the original ibm pc and pcjr. it would have been VERY hard, not just confusing, to write logic for it.

- Nick
sonneveld ok... flags via sound are changed in the "background" because it butts in periodically to update the sound.. but that's it. :)

So I'd recommend going through the source and making sure you don't use flag 115 for anything else.

Also, try calling fix.loop on the ego. This will prevent the interpreter automatically setting the loop if the ego is moving. (if step-count == 1)

Another thing.. try printing out the values of the flags at the start of each logic. or getting the current loop of the object with current.loop().

Are you meant to change the settings of o9 or did you mean ego? is this the thing that gets shot?

Like Vonster says, there's a few other flags that define the cycling of the ego right near the end of logic 0. Make sure always_animate_ego (flag 31) is set or else the code in logic.0 will stop the cycling if the ego isn't in motion.

- Nick
blacki I'm assuming AGI is multi-threaded because otherwise the logic would have worked in the first place.

The only thing that was done to make it work was moving the reset command from the bottom to the top.
So for some reason before it gets to the reset command it restarts the IF statement. It's the only explanation I can come up with.

(The "virtual processor" thing was only hypothetical. I'm not saying there is such a thing, I'm just using the term to try to explain how the multi-threading works.)
sonneveld perhaps the flag affects the other commands that are called in the statement.. i would check that first before assuming multi-threaded code.

- Nick
sonneveld ok.. just checked.. not that. I know it's not just jumping around code though.

- Nic
sonneveld All I know is that you're assuming too much here.. I would check other factors before assuming there's support for code that isn't there.

- Nick
Nick Sonneveld wrote:

perhaps the flag affects the other commands that are called in the statement.. i would check that first before assuming multi-threaded code.

- Nick

I think the way the interpreter executes commands (changing flags, animates objects, etc) could use some clarification. From what I understand about execution, flag settings, and WHEN you set them, more than anything else, are responsible for how your code gets executed at run-time. At times I find myself scratching my head about when I should initialize my flags.. after that, it's a matter of tracing where your code is executing (a rather familiar habit)

blacki Can anyone explain what has happened then??
VvTG (Joel) Most likely, the cause is somewhere else in the code. Something that we can't see (or something more simple that we're overlooking). AGI is definitely not multi-threaded in the sense of executing more than one AGI command at the same time. That would make things extremely difficult because you would not be able to make any assumptions about the order of execution at all.

Besides, typically when there's a concurrency issue, it wouldn't show up every time the program was run. Also, in a typical implementation of threads, you're only guaranteed that your thread won't be preempted at the atomic level (one machine instruction). Even the simple if-statement:

if (f115)

is not atomic (your thread might be preempted right after the test "isset(f115)"), so if this were a concurrency issue there really wouldn't be any way to solve it at all, especially since AGI logic lacks typical thread synchronization mechanisms such as critical sections, etc.
Robin_Gravel if (isset(f115))

Robin Gravel

VvTG (Joel) if (isset(f115)) and if (f115) are equivalent.
Andrew_Baker Ultimately, the AGI interpreter is not the best game engine in the world. It is very, very simple to use the make simple games, but it was never designed for this level of complexity.

Additionally, I also agree with substituting an object for an ego when doing ego animations, but that's just because it makes my code less kludgy.
AGI1122 Shesh, this topic was started back in August. I wonder how long it will take for it to die. ::)
sonneveld I didn't think topics "died" as such. That's kinda suggesting that whenever somebody posts a new topic, we all try to bludgeon it to death with our replies until we don't hear anything from the original author. :)

- Nick
AGI1122 Well I don't think Bjoern is haveing any problem with V in the rooms with shooting... ::)

This topic just took a life of it's own about something completely different.