Posted By: Ruben
Rolling portal always getting faster - 07/31/16 09:23
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:
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?
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?