Jump to content

[LE] Make player responsible for actor death.


xWilburCobbx

Recommended Posts

about your last version of AAAxWCxWeapCorruptingDoomEnchApply

 

 

 

Scriptname AAAxWCxWeapCorruptingDoomEnchApply extends ObjectReference 

Spell property CloakSpell auto
Spell property DoomSpell auto

Actor property PlayerRef auto

Weapon property CorDoom auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) ;OnEquipped will not fire if equipped right out of a container, it needs 2 checks.
        CheckIfEqByPlayer() ;SideNote You dont have to cast Actors as an ObjectReference
endEvent ;they are already an extension of an ObjRef

Event OnEquipped(Actor akActor) ;This checks if equipped normally
        CheckIfEqByPlayer()
endEvent

Event OnUnequipped(Actor akActor)
    if akActor == PlayerRef
        PlayerRef.RemoveSpell(CloakSpell)
    endif
endEvent

Function CheckIfEqByPlayer()
    if PlayerRef.IsEquipped(CorDoom)
        PlayerRef.AddSpell(CloakSpell, false)
    endif
endFunction 

 

 

 

- try to avoid PlayerRef it does not make sense to store this as property, use Game.GetPlayer() instead

- the "Weapon property CorDoom auto" is surely the same as self, you don't need this property here

- the "Spell property DoomSpell auto" is unused by script, can be removed here

Link to comment
Share on other sites

about your last version of AAAxWCxWeapCorruptingDoomScript

EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool pA, bool sA, bool abBashAttack, bool hB)

IF (akSource == CorDoom as Form) 
   RETURN   ; use return here to shrink stack size
ENDIF

;        if (pA || sA) && !hB ;I wanted this to be conditional to recreate a sort of normalish combat calculation system
;            TheResult(0.02) ;Max is 2000 damage if its a sneak or power attack
;        elseif hB && !pA
;            TheResult(0.005) ;Max is 500 damage if its a blocked regular hit
;        elseif !hB || (hB && pA)
;            TheResult(0.01) ;Max is 1000 if its a regular hit or a blocked power attack
;        endif

IF ( hB )       ; blocked
    IF (pA)
        TheResult(0.01)  ;Max damage is 1000, its a blocked power attack
    ELSE
        TheResult(0.005) ;Max damage is 500, its a blocked regular hit
    ENDIF
ELSE
    IF (pA) || (sA)     ;I wanted this to be conditional to recreate a sort of normalish combat calculation system
        TheResult(0.02) ;Max damage is 2000, its a sneak or power attack
    ELSE
        TheResult(0.01) ;Max damage is 1000, its a regular hit
    ENDIF
ENDIF

ENDEVENT
Edited by ReDragon2013
Link to comment
Share on other sites

You asked: "My only real question here, is how does return work exactly? Does return stop the current function where it is at, and move on to the next?"

"return" does the same as "endevent" or "endfunction", but within the event or function body.

Exception is a function with return value, you need "return" here followed by number or variable or False/TRUE (depends on type of function return)

 

basic, which do nothing

Thanks for clearing that up! Seems I ended up figuring that out, which is why I came to my final version of the AAAxWCxWeapCorruptingDoomScript.

 

about your last version of AAAxWCxWeapCorruptingDoomEnchApply

 

- try to avoid PlayerRef it does not make sense to store this as property, use Game.GetPlayer() instead

- the "Weapon property CorDoom auto" is surely the same as self, you don't need this property here

- the "Spell property DoomSpell auto" is unused by script, can be removed here

- I use a player ref property when the player is referred to more than once. According to my research, Game.GetPlayer() takes process time, and if used multiple times it will have to reprocess it each time. Assigning PlayerRef should cut down latency.

 

- Technically yes, but self is an object reference. When an item is in an inventory/container, it no longer exist, so not even self will work. You have to check if it matches a Form instead.

 

- That was just left in error, it was omitted in the actual final script.

 

 

about your last version of AAAxWCxWeapCorruptingDoomScript

Using IF with a return shrinks stack size during run time? From what I have seen when an IF doesn't check out it already ignores whats in the stack entirely. It shouldn't have any of it's contents in the thread, this why I organized it the way I did, because it ignores the code block as soon the condition isn't met. So when akSource != CorDoom it should already return without even acknowledging whats in the code block.

 

I can see how your revision of my IF chain though would be easier on the memory. Since that way if its one version or another, the most it could run is 1 IF check.

 

Also, just as a side note, (akSource == CorDoom as Form) I don't see a reason to cast a Weapon to a form, since all these base objects are already extensions of Forms. (akSource as Weapon == CorDoom), this specifies a Form as a Weapon. There is no need for this either, since any function that runs on Forms won't care what the form extension might be during compile time. I might see using casting akSource as a Weapon if it reduces memory usage in some way, but I have no current reason to believe that.

 

Example from a new script I just wrote today.

Armor eqShield = mySelf.GetEquippedShield() ;This can only run on Armor forms
Weapon rWeap = mySelf.GetEquippedWeapon()   ;This can only run on Weapon forms

;You can also do this

Form eqShield = mySelf.GetEquippedShield()
Form rWeap = mySelf.GetEquippedWeapon()

;Both are still Forms, so there is no need to specify what extension eqShield or rWeap is, as long as eqShield is assigned to an Armor form, and rWeap to a Weapon form

;If you are still concerned that it wont get the right form, then think about this, casting a Weapon as an Armor form will still return errors anyways.

;In my script I just used the first example, either way it doesnt matter.

;----Another Example----
Form eqShield = myActor.GetEquippedShield()

eqShield.GetWarmthRating() ;Can only run on Armor forms

You can always refer to this awesome Script Objects map to see what extends what.

 

If you have more to add, or wish to explain somethings, please do. Your info is most helpful, thanks a bunch!

 

Hopefully, I helped you too, it's always good to question each others knowledge to get the best possible understanding.

Edited by smashballsx88
Link to comment
Share on other sites

  • Recently Browsing   0 members

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