Jump to content

OnTrigEnter throws player away


Recommended Posts

So this is an explosion marker I have to place? In my scenario the player can enter the trigger box from any direction so a placed marker would not be effective, would it?

And the script line should read like this...

ExplosionMarker.PushActorAway(PlayerRef, 10.0)

Link to comment
Share on other sites

"So this is an explosion marker I have to place?"

No, it can be anything from an object to an actor or even an xMarker.



"In my scenario the player can enter the trigger box..."

Example:



Event OnTriggerEnter(ObjectReference triggerRef)
if triggerRef == PlayerREF
Self.PushActorAway(PlayerREF, 10.0)
EndIf
EndEvent



* The "ExplosionMarker" or in this case the "Self = TriggerBox" is the SOURCE from where to apply the force to, it could even be a butterfly.


* Warning: If the targeted actor is executing a "knocked down" animation when/while at the same time a script is "PushActorAway()" on him, 80% of the times it will CTD.


I hope it helps.

Edited by maxarturo
Link to comment
Share on other sites

Ok, got it. While I've got your attention could you help with another issue. I want that when player equips a necklace he/she can't take it off until I 'script it off'. In my case it will actually blow up.

Thanks

 

EDIT: One small issue with PushActorAway. I can't get a sound fx to play while the player is in animation. I want triggered > bang > animation. I get triggered > animation,

Edited by antstubell
Link to comment
Share on other sites

There is a way to lock the item, but there is a problem with this function:

Function EquipItem(Form akItem, bool abPreventRemoval = false, bool abSilent = false) native


abPreventRemoval: If true, prevents the actor (or player) from removing the item


The abPreventRemoval flag does not prevent removal by the functions UnEquipAll and RemoveAllItems. It does prevent removal when using EquipItem(OtherItem).




The only work around i can think is to make a "Fail Safe" script that it will be living on the necklace, an "OnEquip" script with states that it'll also be listening to a global that it will be responsible for the "allow to take off".

Script example, just an idea:



Auto state PreEquipped
Event OnEquipped(Actor akActor)
GoToState("Equipped")
EndEvent
EndState

State Equipped
Event OnUnequipped(Actor akActor)
If ( akActor == Game.GetPlayer() )
If ( MyGlobal.GetValue() == 0 ) ; Global handeling the allow to unequipped, 0 = NOT ALLOW
Utility.Wait(0.1)
akActor.EquipItem(MyNecklace) ;OnUnequipped it'll force re equipped

; Do Nothing
; Or Anything else you might need

Else
; Global is == 1, so you are allow to unequipped
; Do Nothing
; Or Anything else you might need

GoToState(AllDone")
EndIf
EndIf
EndEvent
EndState

State AllDone
;
EndState



"PushActorAway" has the same restrictions as the "Translate" functions, in the case of the sound it must play before the "PushActorAway" and the sound must have either a big radius so that the player can hear it if you are using a force value of 10 which will throw the player quite far from the casting force source, or play the sound at the player's reference.


* "PushActorAway" is running from the time its function executes until the player gets out from the 3d person camera, in this whole time the script can not / it will not execute anything else.

Edited by maxarturo
Link to comment
Share on other sites

Just been experimenting with the sfx. The only way I could just about hear it was using software to amplify the sound 12x, setting a radius of 40,000+ (that's 10x10 cells), setting priority to highest (have multiple sounds playing at same time) and making a new script independent of the PushActorAway script.

Currently checking your equip/unequip script.

Link to comment
Share on other sites

Find your sound in the sound descriptors > create a New Descriptor with that sound > now just edit the "Output Model" to have a wide/big range.

 

 

EDIT: Remove from the script above,
If ( akActor == Game.GetPlayer() )
EndIf
Because if your item gets unequipped by an other object/script it will not be recognize as the unequipped source, the script with that line is only looking to respond to the Player's action.
Sorry...
Edited by maxarturo
Link to comment
Share on other sites

Thank you. One minor typo.

GoToState("AllDone")

 

Yeah... sorry about that, but this was just an example idea that i didn't compile or tested it nor did i saw it until now that you mention it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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