Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Quad, VoroneTZ, 1 invisible), 852 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rolling portal always getting faster #461271
07/31/16 09:23
07/31/16 09:23
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I have a magic portal that appears once a wizard summons it, and it slowly rotates, to add an air of mystery, using the "roll" feature. If the player walks into the portal, the player will warp from Location #1 to Location #2, upon impact, using EVENT_IMPACT . Once the player goes to Location #2, and looks behind, it will see the magic portal is behind its back, that leads back to Location #1, the location that the player just traveled from.

If the player walks back through the portal to return to Location #1, and looks back at the portal again once it reaches Location #1, the portal will be rotating at a slightly faster rate than before the player left Location #1 in the first place to go to Location #2. Every time the player travels through the portal to go to Location #2, and back again to Location #1, the portal will be rotating a little faster each time, in Location #1.

I am trying to make it so that the portal in Location #1 rotates the same speed each and every time the player decides to come back to it.

This is the function that is called , which summons the portal, once the wizard waves its arms about to summon it:

Code:
void wizardPortal()
{ 
   wizPortal = ent_create ( "wizard_portal.mdl", vector(476, 
      -254, 2571), lair_from_wizRoom_a ); 
	
   wizPortal.pan = 150;
	
   wizPortal.ambient = 100;
   wizPortal.lightrange = 300;
	
   if(portalOpened == 0) // IF PORTAL HAS NOT BEEN OPENED YET
      //    BY THE WIZARD, MAKE PORTAL START OFF AS REALLY
      //    REALLY SMALL IN SIZE.
   {
      wizPortal.scale_x = 0.0001;
      wizPortal.scale_y = 0.0001;
      wizPortal.scale_z = 0.0001;
   }
	
   if(portalOpened == 1) // IF PORTAL HAS ALREADY BEEN OPENED,
      //    (i.e. RETURNING FROM LOCATION #2 BACK TO LOCATION 
      //    #1 AGAIN), MAKE PORTAL FULL REGULAR SIZE, SINCE IT
      //    HAS ALREADY BEEN OPENED.
   {
      wizPortal.scale_x = 1;
      wizPortal.scale_y = 1;
      wizPortal.scale_z = 1;
   }

   while(1)
   {
      if(portalOpened == 0) // IF PORTAL HAS NOT BEEN OPENED
                            //    YET BY WIZARD.
      {
         while(1)
	 {
            // IF PORTAL HAS NOT BEEN OPENED, MAKE PORTAL 
            //    GROW IN SIZE AFTER BEING SUMMONED BY THE 
            //    WIZARD.

	    wizPortal.scale_x += 0.01*time_step;
	    wizPortal.scale_y += 0.01*time_step;
	    wizPortal.scale_z += 0.01*time_step;
				
	    if(wizPortal.scale_y >= 1) // IF PORTAL GREW TO
               //    REGULAR NORMAL SIZE, KEEP THE PORTAL AT
               //    NORMAL SIZE.
	    {
	       wizPortal.scale_x = 1;
	       wizPortal.scale_y = 1;
	       wizPortal.scale_z = 1;
					
	       portalOpened = 1;
					
	       break;
            }
				
            wait(1);
         }
      }		
	
      wizPortal.roll += 1*time_step; // ALLOWS PORTAL TO ROLL,
         //    GIVING A SPOOKY AND MYSTERIOUS EFFECT.  THIS
         //    KEEPS GETTING A LITTLE FASTER EVERY TIME THE 
         //    PLAYER RETURNS TO LOCATION #1 FROM LOCATION 
         //    #2
		
      wait(1);
   }
}



As I said, every time the player comes back to Location #1, the portal's roll keeps getting a little faster, like the wizPortal.roll is saving and incrementing on itself every time the player returns to Location #1. It is like the game saves the last wizPortal.roll , and adds it to the next wizPortal.roll once the player returns to Location #1, which speeds up the portal's roll. If you return to Location #1 from Location #2 enough times, the portal will be rotating super fast.

Is there a way to keep the roll from incrementing (speeding up) every time the player returns to Location #1 from Location #2, and have it rotate the same speed as its first iteration, every time the player returns to Location #1?

Last edited by Ruben; 07/31/16 15:40.
Re: Rolling portal always getting faster [Re: Ruben] #461281
07/31/16 17:56
07/31/16 17:56
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I put in 2 DEBUG_VAR()'s in the while(1) loop, one for "wizPortal.roll", and another for "time_step". I do not see "time_step" changing at all every time I return to Location #1. I do notice that "wizPortal.roll" is incrementing faster while the portal spins faster, every time I return to Location #1. I am not sure why wizPortal.roll is incrementing faster each time I return to Location #1 from Location #2.

Somehow, it seems like the game is saving the previous instance of Location #1 "wizPortal.roll", and adding it to the next instance of Location #1 "wizPortal.roll", and this repeats each time the player returns to Location #1 from Location #2, making the portal roll faster and faster every time I return to Location #1 from Location #2. I do not want the portal to roll faster. I want it to stay at the same speed.

Re: Rolling portal always getting faster [Re: Ruben] #461282
07/31/16 18:04
07/31/16 18:04
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Never mind. I solved it. Its kind of complicated to explain how I did it.

Re: Rolling portal always getting faster [Re: Ruben] #461283
07/31/16 18:12
07/31/16 18:12
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Basically, I put the wizPortal.roll while(1) loop in the same function calling on the EVENT_IMPACT to bring forth the portal, rather than placing it in the function that is called which creates the portal itself.

Last edited by Ruben; 07/31/16 18:12.
Re: Rolling portal always getting faster [Re: Ruben] #461292
08/01/16 04:28
08/01/16 04:28

M
Malice
Unregistered
Malice
Unregistered
M



Ruban please I've noticed over time, study - programming 'instancing of functions' you lack understanding here. You code is a blueprint - how many cars are built from it.

Also Event system is 'instance' reaction in same thread - manual

Re: Rolling portal always getting faster [Re: ] #461330
08/01/16 19:50
08/01/16 19:50
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Where in the manual does it talk about "instancing of functions"? I am not getting anything in the search results in the Help manual.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1