Can you find the mistake?

Post » Fri Apr 30, 2010 5:36 am

I made an npc that has a package called "NPCHunting7x3" that orders it to Ambush a creature at a spesific siastance.
Anyway... I wanted to make a script that it will give the npc a bow and some arrows when the hunting will start.
I made the following script but it doesnt work... i can find the mistake (sorry i m new on scripting).
I tried changing the "GetSelf" to GetActionRef" etc but nothing...

ScriptName PC21Misc

ref target
string_var name

Begin OnPackageStart NPCHunting7x3

Set target to GetSelf
Set name to target.GetName

MessageEX "%z goes on hunting" name

target.additem WeapIronBow 1
target.additem Arrow1Iron 50
target.additem f 100

end


Can you plz tell me why the items are not added to my npc?
Thanks
User avatar
Matthew Barrows
 
Posts: 3388
Joined: Thu Jun 28, 2007 11:24 pm

Post » Fri Apr 30, 2010 5:12 am

OMG It worked!!! :P
Anyway... that can help some friends around.

You dont want your companion or npc to go around stealing food, items, books etc heh?
But you want your packages to run properly.
I think i made it :P

A small example....

ScriptName PC21Misc2

ref target
string_var name

begin Gamemode

; Sunday 8:00 - 11:00 Watching preaching in the chappel
; Above all packages to eliminate them if it is sunday
if getIsCurrentPackage NPCWatchingPreachBench2Sunday08x3 == 1
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Sunday Preaching" name
endif

; Everyday 5:00 - 6:00 Personal prayer in the chappel
if getIsCurrentPackage NPCPraying5x1 == 1
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Praying" name
endif

; Everyday 6:00 - 7:00 Training with melee weapons
;Always spawn an iron dagger to avoid stealing weapons and causing trouble
if getIsCurrentPackage NPCTrainingA6x1 == 1
if target.GetItemCount WeapIronDagger == 0
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Training" name
target.additem WeapIronDagger 1
endif
endif

; Everyday 6:00 - 7:00 Training with melee weapons
;Always delete an iron dagger to clear the package item
if getIsCurrentPackage NPCTrainingA6x1 == 0
if target.GetItemCount WeapIronDagger > 0
Set target to GetSelf
Set name to target.GetName
target.removeitem WeapIronDagger 1
endif
endif

; Everyday 12:00 - 13:00 Reading a book “Guide to Skingrad”
;Always spawn the book to avoid stealing books and causing trouble
if getIsCurrentPackage NPCReading12x1 == 1
if target.GetItemCount Book1CheapGuideSkingrad == 0
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Reading" name
target.additem Book1CheapGuideSkingrad 1
endif
endif

; Everyday 12:00 - 13:00 Reading a book “Guide to Skingrad”
;Always delete the book to clear the package item
if getIsCurrentPackage NPCReading12x1 == 0
if target.GetItemCount Book1CheapGuideSkingrad > 0
Set target to GetSelf
Set name to target.GetName
target.removeitem Book1CheapGuideSkingrad 1
endif
endif

; Everyday 14:00 - 18:00 Using a hoe in the small garden
;Always spawn a hoe to avoid stealing hoe and causing trouble
if getIsCurrentPackage NPCGardening14x2 == 1
if target.GetItemCount Hoe01 == 0
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Gardening" name
target.additem Hoe01 1
endif
endif

; Everyday 14:00 - 18:00 Using a hoe in the small garden
;Always delete the hoe to clear the package item
if getIsCurrentPackage NPCGardening14x2 == 0
if target.GetItemCount Hoe01 > 0
Set target to GetSelf
Set name to target.GetName
target.removeitem Hoe01 1
endif
endif

; Everyday 10:00 - 12:00 Eating a food ingredient
;Always spawn a bread loaf to avoid stealing food and causing trouble
if getIsCurrentPackage NPCEat10x2 == 1
if target.GetItemCount Breadloaf == 0
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Eating" name
target.additem Breadloaf 1
endif
endif

; Everyday 10:00 - 12:00 Eating a food ingredient
;Always delete the food to clear the package item (not actually need this)
if getIsCurrentPackage NPCEat10x2 == 0
if target.GetItemCount Breadloaf > 0
Set target to GetSelf
Set name to target.GetName
target.removeitem Breadloaf 1
endif
endif

; Everyday 18:00 - 20:00 Eating a food ingredient
;Always spawn a bread loaf to avoid stealing food and causing trouble
if getIsCurrentPackage NPCEat18x2 == 1
if target.GetItemCount Breadloaf == 0
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Eating" name
target.additem Breadloaf 1
endif
endif

; Everyday 18:00 - 20:00 Eating a food ingredient
;Always delete the food to clear the package item (not actually need this)
if getIsCurrentPackage NPCEat18x2 == 0
if target.GetItemCount Breadloaf > 0
Set target to GetSelf
Set name to target.GetName
target.removeitem Breadloaf 1
endif
endif

; Everyday 20:00 - 4:00 Sleeping if any bed is in short distance.
if getIsCurrentPackage NPCSleep20x8 == 1
Set target to GetSelf
Set name to target.GetName
MessageEX "%z = Sleeping" name
endif

end

User avatar
{Richies Mommy}
 
Posts: 3398
Joined: Wed Jun 21, 2006 2:40 pm


Return to IV - Oblivion