Jump to content

[LE] Disable Food in Combat


Recommended Posts

I can disable the healing property of food when it is used in combat, but the food is still consumed. Can I disable the use of food in combat and provide a message to the player when they try (i.e. "You cannot use this while in combat.")?

Link to comment
Share on other sites

Try this, maybe it works for you. Make a new quest, create a referencealias for this and set player as unique actor. Attach the script as follow, fill properties and try it out ingame with your esp-file loaded.

 

dacPlayerAliasFoodScript

 

Scriptname dacPlayerAliasFoodScript extends ReferenceAlias
{do not allow food eating during combat}
; https://forums.nexusmods.com/index.php?/topic/7534721-disable-food-in-combat/

; could be useful, but try it out
  Keyword PROPERTY VendorItemIngredient auto    ; use autofill [KYWD:0008CDEB]
  Keyword PROPERTY VendorItemFoodRaw    auto    ; use autofill [KYWD:000A0E56]

  Keyword PROPERTY CraftingCookpot      auto    ; use autofill [KYWD:000A5CB3]


; -- EVENTs --

EVENT OnCombatStateChanged(Actor akTarget, Int aeCombatState)
; is triggered when this actors combat state against the target changes, as follow: 0 - not in combat, 1 - in combat, 2 - searching

IF (aeCombatState == 0)
    gotoState("")                    ; ### STATE ###
ELSE
    gotoState("Waiting")            ; ### STATE ###        player enters combat, or is looking for enemy
ENDIF
ENDEVENT


EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProj, Bool b1, Bool b2, Bool b3, Bool b4)  ; * maybe useful
; received when this object is hit by a source (weapon, spell, explosion) or projectile attack

;IF self.GetActorReference().IsInCombat()
    gotoState("Waiting")            ; ### STATE ###        player was hit by anyone
;ENDIF    
ENDEVENT

EVENT OnEnterBleedout()
; received when an actor enters bleedout. (only if this alias points at an actor)
ENDEVENT


EVENT OnRaceSwitchComplete()
; received when this actor finishes changing its race
ENDEVENT


;============================
state Waiting
;============
EVENT OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
; received when an item is removed from this objects inventory.
; If the item is a persistant reference, akItemReference will point at it - otherwise the parameter will be None

IF (akBaseItem as Ingredient)
;;;    IF akBaseItem.HasKeyword(VendorItemIngredient) || akBaseItem.HasKeyword(VendorItemFoodRaw)
;;;    ELSE
;;;        RETURN    ; - STOP -
;;;    ENDIF
ELSEIF akBaseItem.HasKeyword(CraftingCookpot)
    ; any kind of cooked soup
ELSE
    RETURN    ; - STOP -    valid item like healing or mana potion
ENDIF
;---------------------
    Debug.Notification("You are in combat, eating food is useless!")
    self.GetReference().AddItem(akBaseItem, aiItemCount)
ENDEVENT

EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProj, Bool b1, Bool b2, Bool b3, Bool b4)  ; * maybe useful
;EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    ; keep empty
ENDEVENT
;=======
endState

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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