Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

No viable alternative at input 'new'


majistik
 Share

Recommended Posts

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

Edited by majistik
Link to comment
Share on other sites

Well i have fixed the error with the array. Now the code is complied but it does nothing.

This is the only trace that is being called


Event OnEquipped(Actor akActor)

	 Debug.Trace("The player equipped the random bow")

EndEvent

all other traces even in OnInit() doesnt show up.. 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

Ammo Property ABArrowBigGreenhead Auto

Ammo Property ABArrowBlack Auto

Ammo Property ABArrowBlackexp Auto

Ammo Property ABArrowBlackexpbig Auto

Ammo Property ABArrowblue Auto

Ammo Property ABArrowGreen Auto

Ammo Property ABArrowIce Auto

Ammo Property ABArrowIceExpL Auto

Ammo Property ABArrowIceExpS Auto

Ammo Property ABArrowOrange Auto

Ammo Property ABArrowOrangebaloon Auto

Ammo Property ABArrowOrangebaloontimer Auto

Ammo Property ABArrowRed Auto

Ammo Property ABArrowSmallRed Auto

Ammo Property ABArrowWhite Auto

Ammo Property ABArrowYellow Auto

Ammo Property ABArrowYellowfast Auto

Ammo[] BirdsInInentoryArray

int RandomX

int NumOfBirdsNow

string BirdsString

EVENT OnInit()

Debug.Trace("onint")

NumOfBirdsNow = 0

BirdsInInentoryArray = new Ammo[18]

EndEVENT


int 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

return NumOfBirdsNow

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

Event OnEquipped(Actor akActor)

	 Debug.Trace("The player equipped the random bow")

EndEvent


I have also made a post on

http://forums.nexusm...ever-triggered/

Thanks :)

Edited by majistik
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...