Hi there,
Im new to papyrus scriptiing and i made my first script today
I get a compile error of:
\temp\ABrandomArrow.psc(7,32): no viable alternative at input 'new'
In the ck when i try to save it.
Im new to skyrim scripting so i probably made some mistakes.
My code is written in a new script i created and called "ABrandomArrow" and added it to a new bow called "GlassBowABRandom"
This code wait for event that is being called when the player fired a bow and equips the player arrows with random arrows from the inventory (from a list), Its also recalculate the random range and reset the array if an arrow have "0" count.
Scriptname ABrandomArrow extends ObjectReference
Weapon property GlassBowABRandom auto
int RandomX
int NumOfBirdsNow = 0
string[] BirdsInInentoryArray = new string[18]
Function GetNowCountAB()
NumOfBirdsNow = 0
if (Game.GetPlayer().GetItemCount(ABArrowBigGreenhead) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowBigGreenhead"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowBlack) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowBlack"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowBlackexp) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowBlackexp"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowBlackexpbig) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowBlackexpbig"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowblue) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowblue"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowGreen) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowGreen"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowIce) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowIce"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowIceExpL) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowIceExpL"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowIceExpS) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowIceExpS"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowOrange) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowOrange"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowOrangebaloon) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowOrangebaloon"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowOrangebaloontimer) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowOrangebaloontimer"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowRed) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowRed"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowSmallRed) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowSmallRed"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowWhite) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowWhite"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowYellow) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowYellow"
endIf
if (Game.GetPlayer().GetItemCount(ABArrowYellowfast) > 0)
NumOfBirdsNow = NumOfBirdsNow+1
BirdsInInentoryArray[NumOfBirdsNow]="ABArrowYellowfast"
endIf
EndFunction
Event OnPlayerBowShot(Weapon akWeapon, Ammo akAmmo, float afPower, bool abSunGazing)
if (akWeapon == GlassBowABRandom)
Debug.Trace("The player fired a shot from my bow!")
RandomX = Utility.RandomInt(0, NumOfBirdsNow)+1
if (Game.GetPlayer().GetItemCount(BirdsInInentoryArray[RandomX]) == 0)
NumOfBirdsNow=GetNowCountAB()
RandomX = Utility.RandomInt(0, NumOfBirdsNow)+1
endIf
if (NumOfBirdsNow > 1)
Game.GetPlayer().EquipItem(BirdsInInentoryArray[RandomX])
Debug.Trace("The player equipped a random arrow")
endIf
endIf
endEvent