Jump to content

Script assistance needed


DaemonGrin

Recommended Posts

I am trying to make a second emitter for taming captured creatures that makes them docile to other tamed creature types, easily said. I found one mod that kind of had this effect but it changed the beta wave emitter so you had no choice in the change. Everything is created except the script. I used Champollion to create the source of the DLC02 scripts and copied the affected scripts with new names to leave the vanilla emitter as is. All I needed to do was change the faction names all fine and dandy but I'm guessing it uses some code still not recognized by champollion (love the tool) because the affected scripts are virtually identical just referencing new script names and factions. But using the CK beta (wtf it doesn't have the DLC02 source I don't know) to compile the scripts I get this.

 

 

Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "MyMod01\DLC02TamedActorScript01.psc"...
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,38): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,63): required (...)+ loop did not match anything at input '['
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,39): object variables cannot have documentation strings
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(74,19): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(74,41): required (...)+ loop did not match anything at input '['
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(83,18): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(83,33): required (...)+ loop did not match anything at input 'encDef'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,38): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,63): required (...)+ loop did not match anything at input '['
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,39): object variables cannot have documentation strings
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(74,19): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(74,41): required (...)+ loop did not match anything at input '['
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(83,18): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(83,33): required (...)+ loop did not match anything at input 'encDef'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,38): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,63): required (...)+ loop did not match anything at input '['
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(30,39): object variables cannot have documentation strings
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(74,19): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(74,41): required (...)+ loop did not match anything at input '['
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(83,18): no viable alternative at character '#'
C:\Games\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC02\DLC02WorkshopAttackStarterScript.psc(83,33): required (...)+ loop did not match anything at input 'encDef'
No output generated for MyMod01\DLC02TamedActorScript01.psc, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on MyMod01\DLC02TamedActorScript01.psc

 

 

I added a faction check for my custom faction to DLC02WorkshopAttackStarterScript

 

Faction Property DLC02WorkshopTamedCreatureFaction01 Auto Const mandatory
{ actor value to check for taming captured creatures }
That would be the biggest change I made to any script. So yeah I could use some help to know what it should be finding because I am at at loss. Scripts are below if you wish to look them over.

Scriptname MyMod01:DLC02TamedActorScript01 extends Actor

dlc02:dlc02workshopattackstarterscript Property DLC02WorkshopAttackStarter Auto Const mandatory
bool Property CanBeTamed = True Auto Const
{ false = can never be tamed 
  true = allow taming with taming siren }
float Property SafetyRating = 0 Auto Const
{ Safety rating to set on actor when tamed }
bool Property bIsTamed = False Auto hidden


float fOnLoadTimerSeconds = 3
int iOnLoadTimerID = 1
int originalAggression = -1


bool Function CheckForTame(workshopscript cageWorkshop)
	bool bTameMe = False
	workshopscript workshopRef = cageWorkshop
	If (workshopRef == None)
		workshopnpcscript workshopNPC = (Self as Actor) as workshopnpcscript
		If (workshopNPC)
			int workshopID = workshopNPC.GetWorkshopID()
			If (workshopID > -1)
				workshopRef = workshopNPC.WorkshopParent.GetWorkshop(workshopID)
			EndIf
		EndIf
	EndIf
	If (workshopRef)
		bTameMe = workshopRef.GetValue(DLC02WorkshopAttackStarter.DLC02WorkshopRatingTame) > 0
		If (bTameMe)
			bTameMe = CanBeTamed
		EndIf
	EndIf
	If (cageWorkshop as bool && bTameMe)
		bIsTamed = True
		If ((Self as Actor) is workshopnpcscript)
			workshopRef.WorkshopParent.AddActorToWorkshop((Self as Actor) as workshopnpcscript, workshopRef, True, None)
			If (Self.IsInFaction(DLC02WorkshopAttackStarter.DomesticAnimalFaction) == False)
				Self.RemoveFromFaction(DLC02WorkshopAttackStarter.WorkshopNPCFaction)
			EndIf
		EndIf
	EndIf
	Self.TameMe(bTameMe, workshopRef)
	return bIsTamed
EndFunction

Function TameMe(bool bTameMe, workshopscript workshopRef)
	If (bIsTamed)
		If (bTameMe == False)
			bIsTamed = False
			Self.UnregisterForRemoteEvent(workshopRef as ScriptObject, "OnWorkshopMode")
			workshopRef.WorkshopParent.RemoveActorFromWorkshopPUBLIC((Self as Actor) as workshopnpcscript)
			Self.RemoveFromFaction(DLC02WorkshopAttackStarter.DLC02WorkshopTamedCreatureFaction01)
			Self.SetValue(Game.GetAggressionAV(), originalAggression as float)
			Self.SetValue(DLC02WorkshopAttackStarter.DLC02WorkshopRatingTamedActorCount, 0)
			If (SafetyRating > 0)
				Self.SetValue(DLC02WorkshopAttackStarter.WorkshopParent.WorkshopRatings[DLC02WorkshopAttackStarter.WorkshopParent.WorkshopRatingSafety].resourceValue, 0)
				workshopRef.RecalculateWorkshopResources(True)
			EndIf
		Else
			Self.RegisterForRemoteEvent(workshopRef as ScriptObject, "OnWorkshopMode")
			bIsTamed = True
			Self.SetValue(Game.GetAggressionAV(), 1)
			Self.SetValue(DLC02WorkshopAttackStarter.DLC02WorkshopRatingTamedActorCount, 1)
			If (SafetyRating > 0)
				Self.SetValue(DLC02WorkshopAttackStarter.WorkshopParent.WorkshopRatings[DLC02WorkshopAttackStarter.WorkshopParent.WorkshopRatingSafety].resourceValue, SafetyRating)
				workshopRef.RecalculateWorkshopResources(True)
			EndIf
			DLC02WorkshopAttackStarter.CheckForTamedCreaturesAchievement(workshopRef)
		EndIf
	Else
		Self.RemoveFromFaction(DLC02WorkshopAttackStarter.DLC02WorkshopTamedCreatureFaction01)
	EndIf
EndFunction

Event OnUnload()
	If (CanBeTamed == False || bIsTamed == False)
		Self.UnregisterForAllEvents()
		Self.Delete()
	EndIf
EndEvent

Event ObjectReference.OnWorkshopMode(ObjectReference akSource, bool aStart)
	If (aStart == False)
		Self.CheckForTame(None)
	EndIf
EndEvent

Event OnLoad()
	If (originalAggression == -1)
		originalAggression = Self.GetValue(Game.GetAggressionAV()) as int
	EndIf
EndEvent

 

 

ScriptName DLC02:DLC02WorkshopAttackStarterScript extends Quest

Struct workshopAttackRatingItem
	ActorValue attackRating
	Faction attackFaction
EndStruct


Group AchievementData
	int Property TamedCreaturesForAchievement = 5 Auto Const
	int Property TamedCreaturesAchievementID = 56 Auto Const
	bool Property TamedCreaturesAchievementDone = False Auto
	{ set to true to ignore further checks once achievement is done }
	int Property ArenaFightAchievementID = 57 Auto Const
	int Property CagesAchievementID = 58 Auto Const
	Form[] Property CagesBuilt Auto
	{ array of cages that have been built - base objects - added as player builds cages }
	Furniture[] Property CagesForAchievement Auto Const
	{ array of all cages - when CagesBuilt includes all of these, award achievement }
EndGroup

Group TutorialMessageData
	int Property TutorialMessageStageCage = 10 Auto Const
	int Property TutorialMessageStageArena = 20 Auto Const
	int Property AchievementStageCages = 30 Auto Const
EndGroup

workshopparentscript Property WorkshopParent Auto Const mandatory
{ parent quest - holds most general workshop properties }
dlc02:dlc02workshopattackstarterscript#workshopattackratingitem[] Property WorkshopAttackRatings Auto Const
{ array of workshop attack ratings - if > 0, means there's a filled cage at that workshop }
ActorValue Property DLC02WorkshopRatingTame Auto Const mandatory
{ actor value to check for taming captured creatures }
ActorValue Property DLC02WorkshopRatingTamedActorCount Auto Const mandatory
{ actor value resource from each tamed creature - used to track achievement }
Faction Property DLC02WorkshopTamedCreatureFaction Auto Const mandatory
{ actor value to check for taming captured creatures }
Faction Property DLC02WorkshopTamedCreatureFaction01 Auto Const mandatory
{ actor value to check for taming captured creatures }
Faction Property WorkshopNPCFaction Auto Const mandatory
{ actor value to check for taming captured creatures }
Faction Property DomesticAnimalFaction Auto Const mandatory
{ faction to check for whether to remove WorkshopNPCFaction or not }
ObjectReference Property DLC02CageSpawnMarker Auto Const mandatory
{ marker to holding cell for spawning cage creatures }
EncounterZone Property DLC02PlayerLevelZone Auto Const mandatory
{ used for placing leveled creatures to ensure LVL is based on player's level }


Event OnQuestInit()
	Self.RegisterForCustomEvent(WorkshopParent as ScriptObject, "workshopparentscript_WorkshopDailyUpdate")
	Self.RegisterForCustomEvent(WorkshopParent as ScriptObject, "workshopparentscript_WorkshopObjectBuilt")
EndEvent

Function CheckForTamedCreaturesAchievement(workshopscript workshopRef)
	If (TamedCreaturesAchievementDone == False)
		workshopRef.RecalculateWorkshopResources(True)
		int tamedCount = workshopRef.GetValue(DLC02WorkshopRatingTamedActorCount) as int
		If (tamedCount >= TamedCreaturesForAchievement)
			Game.AddAchievement(TamedCreaturesAchievementID)
			TamedCreaturesAchievementDone = True
		EndIf
	EndIf
EndFunction

Function CheckForUnregister()
	If (Self.GetStageDone(AchievementStageCages) && Self.GetStageDone(TutorialMessageStageCage) && Self.GetStageDone(TutorialMessageStageArena))
		Self.UnregisterForCustomEvent(WorkshopParent as ScriptObject, "workshopparentscript_WorkshopObjectBuilt")
	EndIf
EndFunction

Event WorkshopParentScript.WorkshopDailyUpdate(workshopparentscript akSender, var[] akArgs)
	workshopscript[] Workshops = WorkshopParent.Workshops
	workshopdatascript#workshopratingkeyword[] WorkshopRatings = WorkshopParent.WorkshopRatings
	bool bFoundAttackWorkshop = False
	workshopscript[] attackWorkshops = new workshopscript[0]
	int index = 0
	While (index < Workshops.length)
		workshopscript workshopRef = Workshops[index]
		int ratingIndex = 0
		While (ratingIndex < WorkshopAttackRatings.length)
			float lastAttackDays = workshopRef.GetValue(WorkshopRatings[WorkshopParent.WorkshopRatingLastAttackDaysSince].resourceValue)
			followersscript#encdefinition encDef = followersscript.GetScript().GetEncDefinition(None, None, WorkshopAttackRatings[ratingIndex].attackFaction, None)
			float attackFactionID = -99
			float lastAttackFaction = 0
			If (encDef)
				attackFactionID = encDef.LocEncGlobal.GetValue()
				lastAttackFaction = workshopRef.GetValue(WorkshopRatings[WorkshopParent.WorkshopRatingLastAttackFaction].resourceValue)
			EndIf
			If (workshopRef.GetBaseValue(WorkshopAttackRatings[ratingIndex].attackRating) > 0 && (lastAttackFaction != attackFactionID || lastAttackDays > 7))
				bFoundAttackWorkshop = True
				attackWorkshops.add(workshopRef, 1)
				ratingIndex = WorkshopAttackRatings.length
			EndIf
			ratingIndex += 1
		EndWhile
		index += 1
	EndWhile
	If (bFoundAttackWorkshop == True)
		int randomAttackIndex = Utility.RandomInt(0, attackWorkshops.length - 1)
		workshopscript workshopref = attackWorkshops[randomAttackIndex]
		workshopref.CheckForAttack(True)
	EndIf
EndEvent

Function CheckForCagesBuiltAchievement()
	If (CagesBuilt.length >= CagesForAchievement.length)
		Self.SetStage(AchievementStageCages)
	EndIf
EndFunction

Event WorkshopParentScript.WorkshopObjectBuilt(workshopparentscript akSender, var[] akArgs)
	If (akArgs.length > 0)
		workshopobjectscript newObject = akArgs[0] as workshopobjectscript
		If (newObject)
			If (newObject is dlc02:workshopcagescript)
				Self.SetStage(TutorialMessageStageCage)
				Form baseObject = newObject.GetBaseObject()
				If (CagesBuilt.find(baseObject, 0) == -1)
					CagesBuilt.add(baseObject, 1)
					Self.CheckForCagesBuiltAchievement()
				EndIf
			ElseIf (newObject is dlc02:dlc02workshoparenacombatantscript)
				Self.SetStage(TutorialMessageStageArena)
			EndIf
			Self.CheckForUnregister()
		EndIf
	EndIf
EndEvent

 

Thanks,
Geoff
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...