Jump to content

Photo

Need Help with my Script


  • Please log in to reply
22 replies to this topic

#1
TheSkoomaKing

TheSkoomaKing

    Fan

  • Members
  • PipPipPip
  • 490 posts
here is my script:

Scriptname aaTameBeastScriptEffect01 extends Quest


;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;Properties
Faction Property PlayerFaction Auto

Faction Property TamedBeastFaction Auto

GlobalVariable Property AlreadyTamedGlobal Auto

Faction Property CreatureFaction Auto

Keyword Property Creature Auto

Keyword Property ActorTypeCreature Auto

Faction Property FollowerFaction Auto

Message Property FailMessage01 Auto

Message Property failMessage02 Auto

Message Property SuccessMessage01 Auto

Race Property BearSnow Auto

Race Property BearBlack Auto

Race Property BearBrown Auto

Race Property Goat Auto

Race Property TrollIce Auto

Race Property Deer Auto

Race Property Mammoth Auto

Race Property WolfRace Auto

Race Property CharusRace Auto

Race Property FoxRace Auto

Race Property SpiderRace01 Auto

Race Property SpiderRace02 Auto

Race Property MudcrabRace Auto

Race Property SabreCatRace Auto

Race Property SabreCatSnow Auto

Race Property SprigganRace Auto


Race Property TamedBearBlackRace Auto

Race Property TamedBearBrownRace Auto

Race Property TamedBearSnowRace Auto

Race Property TamedChaurusRace Auto

Race Property TamedElkRace Auto

Race Property TamedFoxRace Auto

Race Property TamedFrostbiteSpiderRace Auto

Race Property TamedFrostBiteSpiderGiant Auto

Race Property TamedGoatRace Auto

Race Property TamedMammothRace Auto

Race Property TamedMudcrabRace Auto

Race Property TamedSabreCatRace Auto

Race Property TamedSabreCatSnowyRace Auto

Race Property TamedSprigganRace Auto

Race Property TamedTrollFrostRace Auto

Race Property TamedTrollRace Auto

Race Property TamedWispRace Auto

Race Property TamedWolfRace Auto

Race Property TamedDeerRace Auto

Race Property CureRace Auto

Faction Property CurrentFollowerFaction Auto

Topic Property FollowMeTopic Auto

Alias Property TamedBeastAlias Auto

;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; Begins here!!

Event OnEffectStart(Actor akTarget, Actor akCaster)
Actor akTarget = TamedBeastAlias.GetActorReference()
AkTarget.StopCombat()
SuccessMessage01.Show()
AkTarget.RemoveFromFaction(CreatureFaction)
AkTarget.AddToFaction(TamedBeastFaction)
AkTarget.AddToFaction(playerFaction)
AkTarget.AddToFaction(FollowerFaction)
AlreadyTamedGlobal.SetValue(1)
AkTarget.SetFactionRank(CurrentFollowerFaction, -1)
SuccessMessage01.Show()

akTarget.GetRace()
If akTargetRace.HasKeyword(ActorTypeCreature) == 1
Debug.Notification("Target is valid for taming")

CureRace = akTarget.GetRace()
if (CureRace == BearSnow)
akTarget.SetRace(TamedBearSnowRace)
elseif (CureRace == BearBrown)
akTarget.SetRace(TamedBearBrownRace)
elseif (CureRace == BearBlack)
akTarget.SetRace(TamedBearBlackRace)
elseif (CureRace == CharusRace)
akTarget.SetRace(TamedChaurusRace)
elseif (CureRace == Goat)
akTarget.SetRace(TamedGoatRace)
elseif (CureRace == TrollIce)
akTarget.SetRace(TamedTrollFrostRace)
elseif (CureRace == Deer)
akTarget.SetRace(TamedDeerRace)
elseif (CureRace == Mammoth)
akTarget.SetRace(TamedMammothRace)
elseif (CureRace == WolfRace)
akTarget.SetRace(TamedWolfRace)
elseif (CureRace == FoxRace)
akTarget.SetRace(TamedFoxRace)
elseif (CureRace == SpiderRace01)
akTarget.SetRace(TamedFrostbiteSpiderRace)
elseif (CureRace == SpiderRace02)
akTarget.SetRace(TamedFrostbiteSpiderGiant)
else
;Debug.Trace("[Dark Gift][Warning] " + akTarget + " is not a known race. Defaulting to Imperial vampire.")

endif
endif
float AlreadyTamed = AlreadyTamedGlobal.GetValue()

if (AlreadyTamed == 1)

FailMessage02.Show()

Debug.Notification("Target is not valid for taming")

Endif

Race akTargetRace = akTarget.GetRace()
If akTargetRace.HasKeyword(ActorTypeCreature) == 0
Debug.Notification("Target is not valid for taming")

FailMessage01.Show()

Endif




Endevent

/////////////////////////////////////////////////////////////////////////////////////////////////

what im trying to do is that you can cast a spell on a random Creature that is stated above in the script. And he will then turn to a same looking Race but modified so
it suits a AnimalFollower. (Edited AllowPCDialog). However to make a animal follower you need a script inside the specific reference/target. And since it is random
i figured I´d set it up with an Alias. But i dont know how to make the game/script know that the "AkTarget" is the "TamedBeastAlias". When i try to Compile all it says is :


Starting 1 compile threads for 1 files...
Compiling "aaTameBeastScriptEffect01"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\aaTameBeastScriptEffect01.psc(12,0): function variable akTarget already defined in the same scope
No output generated for aaTameBeastScriptEffect01, compilation failed.


Anyone who can help me with this? Would be very appreciated!

#2
Eckss

Eckss

    Lord High Executioner

  • Premium Member
  • 1,427 posts
Hi,
I have a few tips for you that might help:

OnEffectStart is an Event in a MagicEffect Script, not a Quest Script. - Choose a different Event or put the Script on the Magic Effect.

AkTarget is the parameter of the Event, you shouldn’t be setting it. – Perhaps you might get what you want with –
If akTarget == TamedBeastAlias.GetActorReference()
;whatever
EndIf

You will at least stop getting that error if you stop trying to set akTarget.

Good luck, and don’t be disheartened by failure; papyrus is an awful programming language and it’s very badly documented. The CK Wiki is useful, but it isn’t always all that clear.
Eck. :)


#3
TheSkoomaKing

TheSkoomaKing

    Fan

  • Members
  • PipPipPip
  • 490 posts
Yes yes, i know Event oneffectstart is not a quest event. But the prev i tried didt work, so i was just mixing around. will try the If akTarget == TamedBeastAlias.GetActorReference() thing thou. I hope it will work. will be back with an answer soon :)



EDIT:

i get this:
Starting 1 compile threads for 1 files...
Compiling "aaTameBeastScriptEffect01"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\aaTameBeastScriptEffect01.psc(12,31): GetActorReference is not a function or does not exist
No output generated for aaTameBeastScriptEffect01, compilation failed.

when i try to compile with the If akTarget == TamedBeastAlias.GetActorReference(). Any other advice?

Edited by TheSkoomaKing, 17 December 2012 - 09:20 PM.


#4
Eckss

Eckss

    Lord High Executioner

  • Premium Member
  • 1,427 posts
Add this before the properties:-
Import ReferenceAlias

The function you're using isn't a Quest function so you have to import the script type it comes from.


#5
TheSkoomaKing

TheSkoomaKing

    Fan

  • Members
  • PipPipPip
  • 490 posts
I tried. It still says :


C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\aaTameBeastScriptEffect01.psc(16,28): GetActorReference is not a function or does not exist
No output generated for aaTameBeastScriptEffect01, compilation failed.

#6
TheSkoomaKing

TheSkoomaKing

    Fan

  • Members
  • PipPipPip
  • 490 posts
I tried to put Import ReferenceAlias before the properties, but it still says :


C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\aaTameBeastScriptEffect01.psc(16,28): GetActorReference is not a function or does not exist
No output generated for aaTameBeastScriptEffect01, compilation failed.




where should i put If akTarget == TamedBeastAlias.GetActorReference() then?

i putted it right after the event starts, like this:

Event OnEffectStart(Actor akTarget, Actor akCaster)
Actor akTarget = TamedBeastAlias.GetActorReference()
AkTarget.StopCombat()
SuccessMessage01.Show()
AkTarget.RemoveFromFaction(CreatureFaction)
AkTarget.AddToFaction(TamedBeastFaction)
AkTarget.AddToFaction(playerFaction)
AkTarget.AddToFaction(FollowerFaction)
AlreadyTamedGlobal.SetValue(1)
AkTarget.SetFactionRank(CurrentFollowerFaction, -1)
SuccessMessage01.Show()




( Sorry for double post btw.. lagspike )

Edited by TheSkoomaKing, 17 December 2012 - 09:50 PM.


#7
Eckss

Eckss

    Lord High Executioner

  • Premium Member
  • 1,427 posts
instead of GetActorReference, try casting it as an actor:-

If akTarget == (TamedBeastAlias as Actor)


#8
TheSkoomaKing

TheSkoomaKing

    Fan

  • Members
  • PipPipPip
  • 490 posts
hehe now another error comes up:


C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\aaTameBeastScriptEffect01.psc(14,32): cannot cast a alias to a actor, types are incompatible
No output generated for aaTameBeastScriptEffect01, compilation failed.


Any other advice?


( btw.. thank you so much for taking your time to figure out what it is, im truly gratefull :) )

#9
Ghaunadaur

Ghaunadaur

    That which lurks

  • Members
  • PipPipPip
  • 738 posts
Change the Alias property to ReferenceAlias property, then try again.


ReferenceAlias Property TamedBeastAlias Auto


BTW,

akTarget = TamedBeastAlias.GetActorReference()
=

akTarget = TamedBeastAlias.GetReference() as Actor


The second one is faster. :thumbsup:

#10
Eckss

Eckss

    Lord High Executioner

  • Premium Member
  • 1,427 posts
Ghaunadaur is right, I didn't notice that you had declared the alias as Alias instead of ReferenceAlias.
Change
Alias Property TamedBeastAlias Auto
To
ReferenceAlias Property TamedBeastAlias Auto
As Ghaunadaur pointed out and then
If akTarget == TamedBeastAlias.GetActorReference()
;whatever
EndIf
Will compile (I checked)





Page loaded in: 0.998 seconds