Jump to content

Dynamically adding a death item to certain faction via script?


Recommended Posts

scn QstOnDeathNPCScript
;Quest called QstOnDeathNPC, priority 100, Start Game Enabled ticked.

float fQuestDelayTime

Begin GameMode
    if GetGameLoaded
        let fQuestDelayTime := 0.1
    endif

    call FnDeadActorAddItem 35 ;NPC
    call FnDeadActorAddItem 36 ;Creature
    ;call FnDeadActorAddItem 37 NO LeveledCreature is instantiated as 36
End

scn FnDeadActorAddItem

int iFormTypeID
ref refActor

Begin Function { iFormTypeID }
    
    if PlayerRef.IsInInterior
        let refActor := GetFirstRef iFormTypeID
    else
    ;___GetFirstRef FormTypeID, CellDepth - 1 resulting in local + 8 surrounding
        let refActor := GetFirstRef iFormTypeID, 1
    endif

    while refActor != 0
        if refActor.GetDead
        ;___NonAcumulation armor: Playable unticked, player can't loot ensuring bonus item(s) added once only
            if refActor.GetItemCount NonAccumulation == 0
                refActor.AddItem NonAccumulation, 1
                if refActor.GetInFaction ConjurerFaction || refActor.GetInFaction DaedraFaction
                    refActor.AddItem LL2NPCStaff100 1
                elseif refActor.GetInFaction DremoraFaction || refActor.GetInFaction BanditFaction
                    refActor.AddItem BonusDaedricHelmet, 1
                elseif refActor.GetInFaction CreatureFaction || refActor.GetInFaction VampireFaction
                    refActor.AddItem Gem4SapphireBonus 1
                endif
            endif
        endif
        let refActor := GetNextRef
    loop

End

 

Excellent approach! I made a few changes to appease the stealthy pickpocket, along with using an array instead of a long list of elseifs. Very happy with the result and I learned a few things too. Thanks again.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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