Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OdysseySWFWrapper extends GFxMoviePlayer;
- //Create a Health Cache variable
- var float LastHealthpc;
- var float healthUpdateCooldown;
- var float messageCooldown;
- // Create cache variables for firing effect
- var float xPos;
- var float yPos;
- var bool storyBoardFlag;
- var float alpha;
- //Create variables to hold references to the Flash MovieClips
- //and Text Fields that will be modified
- var GFxObject HealthMC, HealthBarMC, BeltMC, TrimMC;
- //var GFxObject HealthTF;
- //var GFxObject AmmoMC, AmmoTF;
- var GFxObject CenterTextTF1, CenterTextMC1, ReticleMC, ReticleMC1;
- var GFxObject Crystal_Jump, Crystal_Glide, Crystal_AirBlade, Crystal_HeatTolerance, Crystal_Contextual, Crystal_LavaMine, Crystal_WaterWalking, Crystal_LightningPulse;
- var GFxObject GC_A, GC_B, GC_X, GC_Y;
- var bool bLastFrameInterpActor;
- //tracking for "ghost controller" pop-up functionality
- var int lastGhostControllerCount[6]; //0: hasn't been picked up yet - 1: been picked up, displaying - 2: been picked up, displayed
- var float ghostControllerAlpha;
- var float ghostControllerAlphaVelocity;
- //0=jump, 1=glide, 2=air blast, 3=terraforming?, 4=lava mine, 5=lightning
- var bool bShowHUD;
- // Function to round a float value to an int
- function int roundNum(float NumIn)
- {
- local int iNum;
- local float fNum;
- fNum = NumIn;
- iNum = int(fNum);
- fNum -= iNum;
- if (fNum >= 0.5f)
- {
- return (iNum + 1);
- }
- else
- {
- return iNum;
- }
- }
- // Function to return a percentage from a value and a maximum
- function int getpercent(int val, int max)
- {
- return roundNum((float(val) / float(max)) * 100.0f);
- }
- function Init(optional LocalPlayer PC )
- {
- //Start and load the SWF Movie
- super.Start();
- Advance(0.f);
- //Set the cahce value so that it will get updated on the first Tick
- LastHealthpc = -201;
- //Load the references with pointers to the movieClips and text fields in the .swf
- HealthBarMC = GetVariableObject("_root.healthBar");
- HealthMC = GetVariableObject("_root.HealthBarOutline");
- BeltMC = GetVariableObject("_root.Belt");
- TrimMC = GetVariableObject("_root.Trim");
- //CenterTextMC1 = GetVariableObject("_root.messageMC");
- CenterTextTF1 = GetVariableObject("_root.messages");
- ReticleMC = GetVariableObject("_root.reticle");
- ReticleMC1 = GetVariableObject("_root.reticleOther");
- alpha = GetVariableNumber("_root.fade");
- ReticleMC1.SetVisible(false);
- Crystal_Jump = GetVariableObject("_root.Crystal_Jump");
- Crystal_Glide = GetVariableObject("_root.Crystal_Glide");
- Crystal_AirBlade = GetVariableObject("_root.Crystal_AirBlade");
- Crystal_HeatTolerance = GetVariableObject("_root.Crystal_HeatTolerance");
- Crystal_Contextual = GetVariableObject("_root.Crystal_Contextual");
- Crystal_LavaMine = GetVariableObject("_root.Crystal_LavaMine");
- Crystal_WaterWalking = GetVariableObject("_root.Crystal_WaterWalking");
- Crystal_LightningPulse = GetVariableObject("_root.Crystal_LightningPulse");
- ActionScriptVoid("setMessageOff");
- messageCooldown = 0.0;
- lastGhostControllerCount[0] = 0;
- lastGhostControllerCount[1] = 0;
- lastGhostControllerCount[2] = 0;
- lastGhostControllerCount[3] = 0;
- lastGhostControllerCount[4] = 0;
- lastGhostControllerCount[5] = 0;
- //hide X Y B A
- GC_X = GetVariableObject("_root.ghostController_X");
- GC_Y = GetVariableObject("_root.ghostController_Y");
- GC_B = GetVariableObject("_root.ghostController_B");
- GC_A = GetVariableObject("_root.ghostController_A");
- ghostControllerAlpha = GetVariableNumber("_root.ghostControllerFade");
- ActionScriptVoid("setControllerFade");
- GC_X.setVisible(false);
- GC_Y.setVisible(false);
- GC_B.setVisible(false);
- GC_A.setVisible(false);
- super.Init(PC);
- }
- //Called every update Tick
- function TickHUD( float dt )
- {
- local UTPawn UTP;
- local Odyssey_PlayerController OPC;
- local int i;
- OPC = Odyssey_PlayerController(GetPC());
- if (OPC.IsDead())
- {
- HealthBarMC.SetFloat("_xscale",0);
- SetCenterText("Press 'A' to Respawn");
- messageCooldown = 0.1;
- }
- //We need to talk to the Pawn, so create a reference and check the Pawn exists
- UTP = UTPawn(OPC.Pawn);
- if (UTP == None)
- {
- LastHealthpc = -201; //force it to a value so it'll update on the first tick, similar to how it's done in Init()
- return;
- }
- //If the cached value for Health percentage isn't equal to the current...
- if (LastHealthpc != getpercent(UTP.Health, UTP.HealthMax))
- {
- //...Make it so...
- //LastHealthpc = getpercent(UTP.Health, UTP.HealthMax);
- LastHealthpc = (( getpercent(UTP.Health, UTP.HealthMax) - LastHealthpc ) * 0.1f) + LastHealthpc;
- //...Update the bar's xscale (but don't let it go over 100)...
- if (LastHealthpc <= 0)
- {
- HealthBarMC.SetFloat("_xscale",0);
- }
- else
- {
- HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
- }
- }
- if(messageCooldown < 0){
- ActionScriptVoid("setMessageOff");
- }
- else{
- messageCooldown -= dt;
- }
- if(OPC != none)
- {
- if(bShowHud)
- {
- for( i = 0; i < 6; i++)
- {
- //check if it's different, show/hide
- if(lastGhostControllerCount[i] == 0 && OPC.ghostControllerCount[i] == 1)
- {
- //Text is placeholder - replace with hide/show commands later on
- //show
- switch(i)
- {
- case 0:
- GC_A.setVisible(true);
- SetCenterText("Press A to jump.");
- break;
- case 1:
- GC_A.setVisible(true);
- SetCenterText("Hold A in midair to glide.");
- break;
- case 2:
- GC_X.setVisible(true);
- SetCenterText("Press X to shoot an air blast.");
- break;
- case 3:
- GC_X.setVisible(true);
- SetCenterText("Look directly at a pillar and press X to raise it.");
- break;
- case 4:
- GC_B.setVisible(true);
- SetCenterText("Press B to lay a lava mine.");
- break;
- case 5:
- GC_Y.setVisible(true);
- SetCenterText("Press Y to cause a magnetic field.");
- break;
- }
- messageCooldown = 1000.0;
- ghostControllerAlpha = 0.f;
- ghostControllerAlphaVelocity = 0.01;
- }
- else if(lastGhostControllerCount[i] == 1 && OPC.ghostControllerCount[i] == 2)
- {
- /*switch(i)
- {
- case 0:
- //hide a
- break;
- case 1:
- //hide a
- break;
- case 2:
- //hide x
- break;
- case 3:
- //hide x
- break;
- case 4:
- //hide b
- break;
- case 5:
- //hide y
- break;
- }*/
- //hide
- RemoveText();
- ghostControllerAlpha = 1.f;
- ghostControllerAlphaVelocity = -0.01; //will hide appropriately when alpha hits 0
- }
- //increment
- lastGhostControllerCount[i] = OPC.ghostControllerCount[i];
- }
- if(ghostControllerAlpha <= 1.f && ghostControllerAlpha >= 0.f)
- {
- ghostControllerAlpha += ghostControllerAlphaVelocity;
- SetVariableNumber("_root.ghostControllerFade", ghostControllerAlpha * 100);
- ActionScriptVoid("setControllerFade");
- //hide appropriately
- if(ghostControllerAlpha + ghostControllerAlphaVelocity < 0.f)
- {
- GC_X.setVisible(false);
- GC_Y.setVisible(false);
- GC_B.setVisible(false);
- GC_A.setVisible(false);
- }
- }
- //setting reticle to be contextual or not
- if(OPC.CurrentInterpActor != none && bLastFrameInterpActor == false)
- {
- bLastFrameInterpActor = true;
- //change from default to contextual
- ////`log("changing to contextual reticle");
- ReticleMC.SetVisible(false);
- ReticleMC1.SetVisible(true);
- }
- if(OPC.CurrentInterpActor == none && bLastFrameInterpActor == true)
- {
- bLastFrameInterpActor = false;
- //change from contextual to default
- ////`log("changing to normal reticle");
- ReticleMC.SetVisible(true);
- ReticleMC1.SetVisible(false);
- }
- //displaying unlocked abilities
- if( Crystal_AirBlade != none )
- {
- if(OPC.IsAbilityEnabled(PA_AirBlade))
- {
- Crystal_AirBlade.SetVisible(true);
- Crystal_Glide.SetVisible(false);
- Crystal_Jump.SetVisible(false);
- }
- else if( Crystal_Glide != none )
- {
- Crystal_AirBlade.SetVisible(false);
- if(OPC.IsAbilityEnabled(PA_Glide))
- {
- Crystal_Glide.SetVisible(true);
- Crystal_Jump.SetVisible(false);
- }
- else if( Crystal_Jump != none )
- {
- Crystal_Glide.SetVisible(false);
- if(OPC.IsAbilityEnabled(PA_Jump))
- {
- Crystal_Jump.SetVisible(true);
- }
- else
- {
- Crystal_Jump.SetVisible(false);
- }
- }
- }
- }
- if( Crystal_LavaMine != none )
- {
- if(OPC.IsAbilityEnabled(PA_LavaMine))
- {
- Crystal_LavaMine.SetVisible(true);
- Crystal_Contextual.SetVisible(false);
- Crystal_HeatTolerance.SetVisible(false);
- }
- else if( Crystal_Contextual != none )
- {
- Crystal_LavaMine.SetVisible(false);
- if(OPC.IsAbilityEnabled(PA_Contextual))
- {
- Crystal_Contextual.SetVisible(true);
- Crystal_HeatTolerance.SetVisible(false);
- }
- else if( Crystal_HeatTolerance != none )
- {
- Crystal_Contextual.SetVisible(false);
- if(OPC.IsAbilityEnabled(PA_HeatTolerance))
- {
- Crystal_HeatTolerance.SetVisible(true);
- }
- else
- {
- Crystal_HeatTolerance.SetVisible(false);
- }
- }
- }
- }
- if( Crystal_LightningPulse != none )
- {
- if(OPC.IsAbilityEnabled(PA_LightningPulse))
- {
- Crystal_LightningPulse.SetVisible(true);
- Crystal_WaterWalking.SetVisible(false);
- }
- else if( Crystal_WaterWalking != none )
- {
- Crystal_LightningPulse.SetVisible(false);
- if(OPC.IsAbilityEnabled(PA_WaterWalking))
- {
- Crystal_WaterWalking.SetVisible(true);
- }
- else
- {
- Crystal_WaterWalking.SetVisible(false);
- }
- }
- }
- }
- else
- {
- Crystal_Jump.SetVisible(false);
- Crystal_Glide.SetVisible(false);
- Crystal_AirBlade.SetVisible(false);
- Crystal_HeatTolerance.SetVisible(false);
- Crystal_Contextual.SetVisible(false);
- Crystal_LavaMine.SetVisible(false);
- Crystal_WaterWalking.SetVisible(false);
- Crystal_LightningPulse.SetVisible(false);
- }
- }
- }
- function SetCenterText(string text)
- {
- CenterTextTF1.SetText(text);
- ActionScriptVoid("setMessageOn");
- if (storyBoardFlag == true)
- {
- messageCooldown = 0.1;
- storyBoardFlag = false;
- }
- else
- {
- messageCooldown = 3.0;
- ActionScriptVoid("ResetFade");
- }
- }
- function RemoveText()
- {
- ActionScriptVoid("setMessageOff");
- }
- function ToggleHUD(bool showHud)
- {
- bShowHUD = showHud;
- if(bShowHud == false)
- {
- ReticleMC.SetVisible(false);
- HealthBarMC.SetVisible(false);
- HealthMC.SetVisible(false);
- BeltMC.SetVisible(false);
- TrimMC.SetVisible(false);
- }
- else
- {
- ReticleMC.SetVisible(true);
- HealthBarMC.SetVisible(true);
- HealthMC.SetVisible(true);
- BeltMC.SetVisible(true);
- TrimMC.SetVisible(true);
- }
- }
- defaultproperties
- {
- //this is the HUD. If the HUD is off, then this should be off
- bDisplayWithHudOff=false
- //The path to the swf asset we will create later
- MovieInfo=SwfMovie'Odyssey_MenuHUD.OdyHUD'
- //Just put it in...
- //bGammaCorrection = false
- bLastFrameInterpActor=false;
- healthUpdateCooldown=0.0;
- ghostControllerAlpha = 0.0;
- ghostControllerAlphaVelocity = 0.0;
- bShowHUD = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement