Jump to content

my script, it doesnt work, please help


Recommended Posts

What am I doing wrong please?

Event OnHit (akAggressor)

if (akAggressor) = game.player

int random = Utility. IntRandom (1,20)

if int random <= 10

Debug. Trace "bad"

elseif int random >= 11

Debug. Trace "good"

endif

endif

EndEvent

Edited by MaddDreamer
Link to comment
Share on other sites

What am I doing wrong please?

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \

bool abBashAttack, bool abHitBlocked)

if (akAggressor) == game.getplayer()

int random = Utility.RandomInt (1,20)

if random <= 10

Debug.Trace("bad")

elseif random >= 11

Debug. Trace("good")

endif

endif

EndEvent

Fixed lots of mistakes. You had multiple syntax errors.

Edited by Lisselli
Link to comment
Share on other sites

okay so notification to display on screen. I'm attaching it directly to the actor for now. I will try other ways, but what wouldyou suggest to be the easiest as I would eventually like to have the script affect all other npcs.

Edited by MaddDreamer
Link to comment
Share on other sites

Gotta warn you about OnHit though. In addition to what the event is listening for, it will also run for all other hits as well. This will create issues like stack dumping. So whatever you are trying to accomplish with the NPC, make sure it's only for as long as you need.

Link to comment
Share on other sites

Thats my goal, i want to bring into my game hit chance among other things that i plan to expand from this. nothing seems to work however, neither attatching it directly to the actor, by way of ability or perk. will changing it to the weapons still allow npcs to use the script?

 

edit, misunderstood the first time, how would I get it to only activate when hit with a sword or such martial weapons and ignore spell and ranged?

Edited by MaddDreamer
Link to comment
Share on other sites

OnHit will do its thing you have coded for it to do, but it will still fire under the hood for other things as well. That's what I meant. You can't make it ignore those other things. But you can put it in a state so that it doesn't run at all for as long as its in said state. All you do is take the original code, and place it in a state like this:

Auto State Waiting
; event here
EndState

State Done
; event here but nothing in the event block
EndState

And to change the state you use this in your event code block, people usually place this before all the other code(as your code will still fire prior to changing states)

GoToState("Done")
Auto State Waiting
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
     if (akAggressor) == game.getplayer()
            GoToState("Done")
            int random = Utility.RandomInt (1,20)
                   if random <= 10
                         Debug.Trace("bad")
                   elseif random >= 11
                          Debug. Trace("good")
                   endif
    endif
EndEvent
EndState

State Done
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
; nothing, event thrown out.
EndEvent
EndState

There maybe a more creative way of using this event, but I don't know what that is, and generally people approach this Event with caution.

Edited by Lisselli
Link to comment
Share on other sites

  • Recently Browsing   0 members

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