FIVExEYES Posted January 28, 2019 Share Posted January 28, 2019 (edited) Need help porting NV scripts to Fallout 4 from a MGS Alert mod But mostly with understanding why I'm getting the papyrus error noted in the title Note: Im a noob, im sorry for any complications in advance Source Code from Fallout NV (not mine credit goes to Volek)SCRIPTNAME MGSAlertScript int seen int soundplayed ;short team float timer ref EnemyRef ;ref TeamRef Begin GameMode if seen == 0 ; runs while the player is undetected set EnemyRef to GetFirstRef 200 2 0 ; checks an NPC Label 10 if EnemyRef ;if EnemyRef.GetPlayerTeammate == 1 && team == 0 ;set TeamRef to EnemyRef ;set team to 1 ;printc "teammate init" ;endif if EnemyRef.GetDetected player == 1 && EnemyRef.GetCombatTarget == player ; || EnemyRef.GetDetected TeamRef == 1 || EnemyRef.GetCombatTarget == TeamRef ;printc "detected!" if soundplayed == 0 playsound MGSAlertSound MGSAlertMarkRef.moveto EnemyRef 0 0 144 MGSAlertMarkRef.enable ;printc "mark enabled" set timer to 1 set soundplayed to 1 endif set seen to 1 ;printc "alert mode" return endif set EnemyRef to Pencil01 ; Prevent apple bug set EnemyRef to GetNextRef Goto 10 ; check the next NPC in the cell endif endif if seen == 1 ; alert mode, runs while the player is detected if player.IsInCombat != 1 ; && TeamRef.IsInCombat != 1 set soundplayed to 0 ;set team to 0 set seen to 0 ;printc "alert mode reset" endif endif if timer >= 1 set timer to ( timer + GetSecondsPassed ) MGSAlertMarkRef.moveto EnemyRef 0 0 144 ;printc "mark moved" if timer > 2 MGSAlertMarkRef.disable ;printc "mark disabled" set timer to 0 endif endif EndCode I attempted to convert from NV to FO4 SCRIPTNAME MGSAlertScript1 extends ObjectReference int seen int soundplayed int GetDetected ;short team float timer Actor EnemyRef ;ref TeamRef Cell kCell Int CellRefs Int i int j ObjectReference player Actor Function GetClosestActorFromRef(ObjectReference akCenter) Global ; Returns the closest actor to akCenter. akCenter is excluded from the search. ;*1. Check if there is more than 128 actors or only akCenter. ;*2. Iterate through all actors found and record their distances to the player. ;*3. Find the smallest distance from the player and return the actor. ;*4. Valid types for actors: 43 or 62 ; ObjectReference[] kRefs = new ObjectReference[128] Float[] fDistances = new Float[128] kCell = akCenter.GetParentCell() CellRefs = kCell.GetNumRefs(43) Float fLowestValue = 1000000.0 i if (CellRefs >= 129 || CellRefs == 1) return none endif while i < CellRefs ObjectReference kActors = kCell.GetNthRef(i, 43) if kActors != akCenter kRefs[i] = kActors fDistances[i] = kActors.GetDistance(akCenter) Float fCurrentValue = fDistances[i] if fCurrentValue <= fLowestValue fLowestValue = fCurrentValue endif endif i += 1 endWhile Int refIndex = fDistances.Find(fLowestValue) return kRefs[refIndex] as Actor endFunction Function LOSDectection() RegisterForDetectionLOSGain(EnemyRef, player) ; Before we can use OnGainLOS we must register. EndFunction Event OnGainLOS(ObjectReference akViewer, ObjectReference akTarget) ; If other registrations had been done, we would want to check the viewer and target ;But since we only registered for one we know what it is ;Since we only did single los gain well only get this once if(akViewer == EnemyRef && akTarget == player) GetDetected = 1 return GetDetected endif endEvent while j != 0 if seen == 0 ; runs while the player is undetected ;Label 10 while i < CellRefs EnemyRef = GetClosestActorFromRef(Game.GetPlayer()) ;set EnemyRef to GetFirstRef 200 2 0 ; checks an NPC if EnemyRef ;if EnemyRef.GetPlayerTeammate == 1 && team == 0 ;set TeamRef to EnemyRef ;set team to 1 ;printc "teammate init" ;endif LOSDectection() if GetDetected == 1 && EnemyRef.GetCombatTarget == player ; || EnemyRef.GetDetected TeamRef == 1 || EnemyRef.GetCombatTarget == TeamRef ;printc "detected!" if soundplayed == 0 int instanceID = MGSAlertSound.play(self) Sound.setInstanceVolume(instanceID, 1.0) MGSAlertMarkRef.moveto(EnemyRef, 0, 0, 144, true) MGSAlertMarkRef.enable ;printc "mark enabled" timer = 1 soundplayed = 1 endif seen = 1 ;printc "alert mode" return endif ;set EnemyRef to Pencil01 ; Prevent apple bug ;set EnemyRef to GetNextRef i+=1 ;Goto 10 ; check the next NPC in the cell endif endWhile endif if seen == 1 ; alert mode, runs while the player is detected if player.IsInCombat != 1 ; && TeamRef.IsInCombat != 1 soundplayed = 0 ;set team to 0 seen = 0 GetDetected = 0 ;printc "alert mode reset" endif endif if timer >= 1 timer == timer + Utility.GetCurrentRealTime() MGSAlertMarkRef.moveto(EnemyRef, 0, 0, 144, true) ;printc "mark moved" if timer > 2 MGSAlertMarkRef.disable ;printc "mark disabled" timer = 0 endif endif int j = 0 Utility.wait(3) endWhile And the Compilation ErrorC:\Program Files\Notepad++>echo off "====> DEBUG BUILD" Papyrus Compiler Version 2.8.0.4 for Fallout 4 Copyright (C) ZeniMax Media. All rights reserved. Starting 1 compile threads for 1 files... Compiling "C:\Games\Fallout 4\Data\Scripts\Source\User\MGSAlertScript1.psc"... C:\Games\Fallout 4\Data\Scripts\Source\User\MGSAlertScript1.psc(68,0): missing EndOfFile at 'while' No output generated for C:\Games\Fallout 4\Data\Scripts\Source\User\MGSAlertScript1.psc, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on C:\Games\Fallout 4\Data\Scripts\Source\User\MGSAlertScript1.psc Press any key to continue . . . thanks in advance for your help edit: turns out it was a hyphenthough another error appeared regarding missing EOF at while on line 68 how does one declare the ending of a file on the papyrus language and how can a EndOfFile be considered this early in the code? Edited January 28, 2019 by FIVExEYES Link to comment Share on other sites More sharing options...
werr92 Posted January 28, 2019 Share Posted January 28, 2019 (edited) Learn how to code with Papyrus in the first place, it's actually all I can say. There's plenty of information with examples to it on CK wiki (pay attention to Events, States and Functions sections). All tutorials from Skyrim scripting will be valid here as well, so take a look at those too. There's so many things wrong with your code, that I don't want to mention anything in particular. It feels broken Oblivion, but not Papyrus. Edited January 28, 2019 by werr92 Link to comment Share on other sites More sharing options...
FIVExEYES Posted January 28, 2019 Author Share Posted January 28, 2019 Ok thanks Link to comment Share on other sites More sharing options...
Recommended Posts