Jump to content

NPC script advice please


Eukatae

Recommended Posts

The scripting is meant in part to facilitate changing clothes/armor for a specific task.

 

I make use of AI packages and three scripts to facilitate it.

 

Main script example:

scn EukScpt20IdunMain1


int slot
ref item
int hlth

ref self 
short SC;Swap Clothing
short CPack ;clothing package

begin OnActivate 

set self to GetSelf
if (SC) 
set CPack to 0
AddScriptPackage EukPac92IdunUseWardrobe 
EvaluatePackage EukPac92IdunUseWardrobe 
set IdunWardrobeRef.CPack to CPack 
set CPack to 0 
set SC to 0 
else 
activate 
endif 

end



begin OnPackageChange EukPac92IdunUseWardrobe 

RemoveScriptPackage EukPac92IdunUseWardrobe 
IdunWardrobeRef.activate self 1 

end


begin OnPackageChange EukPac91IdunEquipClothes
  RemoveScriptPackage EukPac91IdunEquipClothes 
end

begin OnPackagestart EukPac25IdunPractice
  set self to GetSelf
  set CPack to 0
  AddScriptPackage EukPac92IdunUseWardrobe 
  EvaluatePackage EukPac92IdunUseWardrobe 
set IdunWardrobeRef.CPack to CPack
set CPack to 0 
end

 

When the NPC starts package EukPac25IdunPractice the NPC has to cross 3 cells (or 2 cells and one worldspace) to useitemat. the package "EukPac92IdunUseWardrobe" call the NPC to active a container which has this script:

 

scn EukScpt22IdunClosetScript

ref actionRef
short init
short CPack

begin OnActivate
 set actionRef to GetActionRef
     	 if actionRef.getincell EukHeimBC
 actionRef.RemoveAllItems
actionRef.AddItem EukLL04Armor 1
actionRef.Additem EukAmmo01 200
actionRef.Additem EukWep02 1
actionRef.Additem EukWep03 1
actionRef.Additem Book4RareFiveSongsofKingWulfharth 1
actionRef.Additem Beef 1
actionRef.Additem PotionRestoreHealthS 10
   endif
  elseif (CPack == 1)
     ;Breakfast
     IduneatCont.activate actionRef 1
     set CPack to 0

The problem I am having is when the NPC crosses cells if often triggers the script added package again causing the NPC to pingpong between the container and the next cell in line to arive at the final location. As the Container script uses "removeallitems" the NPC is regerable in the buff half the time. I added the "if actionRef.getincell EukHeimBC" to at least prevent the NPC from being stripped even if it pingpongs but it does nothing. I added a condition on the container script "get in cell x == 1" that does nothing. Ive tried adding an if to check for getincell to the packagestart code:

begin OnPackagestart EukPac25IdunPractice
     	 if actionRef.getincell EukHeimBC
  set self to GetSelf
  set CPack to 0
  AddScriptPackage EukPac92IdunUseWardrobe 
  EvaluatePackage EukPac92IdunUseWardrobe 
set IdunWardrobeRef.CPack to CPack
set CPack to 0 
end

 

But it does nothing. I am certain it is some simple thing that I just cannot see with my pea brain; please to confirm my dumbocity.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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