Author Topic: Help with logic needed  (Read 5990 times)

0 Members and 1 Guest are viewing this topic.

b.o.k.

  • Guest
Help with logic needed
« on: August 25, 2001, 06:27:01 AM »
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.");
   program.control();
   set.view(ego,27);
   set.loop(ego,1);
   set.cel(ego,0);
   ignore.objs(ego);
   ignore.blocks(ego);
   end.of.loop(ego,f115);
   start.update(ego);
   v46--;
 }
 else {
   print("Your gun is not loaded.");
 }
}

if(isset(f115)) {  
   stop.motion(o9);
   stop.cycling(o9);
   set.view(o9,26);
   set.loop(o9,0);
   set.cel(o9,0);
   force.update(o9);
   observe.objs(ego);
   observe.blocks(ego);
   player.control();
   reset(f115);
}
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »



Offline bokkers

Re: Help with logic needed
« Reply #1 on: August 27, 2001, 01:20:18 AM »
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???
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »

Offline Vonster_D_Monster

Re: Help with logic needed
« Reply #2 on: August 27, 2001, 04:26:47 AM »
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 :)

Vonster.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »

Trapped

  • Guest
Re:Help with logic needed
« Reply #3 on: May 02, 2002, 09:58:09 AM »
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 wrong...so... someone help out an ignorant newbie... or i'm going to sell my computer and take up golf instead!!  ::)

Offline Chris Cromer

Re:Help with logic needed
« Reply #4 on: May 02, 2002, 02:57:34 PM »
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.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Andrew_Baker

Re:Help with logic needed
« Reply #5 on: May 02, 2002, 08:19:32 PM »
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.
I hope you realize that one day I will devour the Earth.

Offline Blacki

Re:Help with logic needed
« Reply #6 on: May 04, 2002, 02:08:09 AM »
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.
« Last Edit: May 04, 2002, 02:10:37 AM by blacki »

Trapped

  • Guest
Re:Help with logic needed
« Reply #7 on: May 04, 2002, 02:53:42 AM »
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:

if(isset(f115)){
reset(f115);

-Trapped

Offline Chris Cromer

Re:Help with logic needed
« Reply #8 on: May 04, 2002, 03:56:55 AM »
... My post had the same thing in it...
if(f100) {
reset(f100);


The only difference was the flag used...
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Trapped

  • Guest
Re:Help with logic needed
« Reply #9 on: May 04, 2002, 06:16:39 AM »
...well... I like 115 better than 100..  ::)

;D

thanks BOTH of you. :)

Offline Blacki

Re:Help with logic needed
« Reply #10 on: May 05, 2002, 06:00:20 PM »
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.

Offline Chris Cromer

Re:Help with logic needed
« Reply #11 on: May 05, 2002, 08:14:58 PM »
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.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Blacki

Re:Help with logic needed
« Reply #12 on: May 06, 2002, 06:36:29 PM »
If that was the case then, this...

if(isset(f115)) {

Offline Nick Sonneveld

Re:Help with logic needed
« Reply #13 on: May 06, 2002, 07:31:34 PM »
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
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Nick Sonneveld

Re:Help with logic needed
« Reply #14 on: May 06, 2002, 07:53:30 PM »
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
Nick Sonneveld  |  AGI Dev  |  NAGI


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.046 seconds with 21 queries.