Jump to content

Scripting question


dimedius

Recommended Posts

Can you pause the original script and add your own function to run?

 

I have never scripted before. I am reading through many many wikis and tutorials to see if what I want can be done.

 

Lets look at the frag mine. I want to be able to add a function to it where instead of beeping and blowing up, it plays the audio "click" and then checks player position to see if player is standing on the mine. This would give the player the option to disarm or if the player moves away, it blows up instantly.

 

Now, reading through all the tutorials, it looks like I need to create a object in a scene with an activator. Again, I'm not too familiar with the extent of scripting but this approach seems like I may need to create a new formid for a new mine with a new set of scripts that have the same "code" as the original with some modified lines (if thats even possible).

 

Can this even be done, and if so, how (best approach advice and tutorials if you know of some)?

Link to comment
Share on other sites

Well, you would have to either edit all existing mines and replace the existing script, which means actual formid changes, or edit the existing script to behave differently if you don't want to create entirely new objects. Though if you edit the existing one, and add new properties, you'll be updating the mines anyhow.

Link to comment
Share on other sites

I understand the concept of changing/creating new formid's.

 

Am I to understand by your reply, I would need to scour through all of the world spaces to find the mines and attach the new script? There wouldn't be any easier method of finding the base object and any objects that share those properties would update?

Link to comment
Share on other sites

the TrapBase script shows what I think would be the function to start the countdown

Event OnTimer(int aiTimerID)
    If (Self.getState() != "Disarm" && Self.getState() != "Disarmed" && Self.getState() != "TrapFired")
        If (aiTimerID == WarnTimerNumber)
            Self.FireTrap()
        EndIf
    EndIf
    Self.LocalOnTimer(aiTimerID)
EndEvent

Function StartWarn()
    Self.ResolveLeveledDamage()
    If (UseWarnTimer)
        Self.PlayAnimation(WarnAnim)
        Self.StartTimer(WarnTime, WarnTimerNumber)
    Else
        Self.PlayAnimationAndWait(WarnAnim, WarnAnimEndEvent)
        Self.FireTrap()
    EndIf
EndFunction

I'm not sure if I can grab this event and tell it to wait for player input.

From what I can gather from the Event, its looking to check if its not in the disarmed state and hasn't been fired to wait until timer is finished and then fire.

 

Would I want to get into the Event code itself to add this pause or add it to the startwarn() function? Is that even possible. This is the part I can't understand (I see people saying you can overwrite the original script but it may have undesired effects).

Link to comment
Share on other sites

That looks about right, I'm assuming there'd be an activator of some sort either on the base object or in that script that would cancel the timer as well. If you can find what actually starts the timer, I'm assuming maybe a trigger volume?, you can replace the timer with maybe a OnDistanceGreaterThan event to see if the player moved too far away and blow up instead, with the activate unregistering that event.

Link to comment
Share on other sites

I'm doing some research on trigger volume. Is that the same as a trigger event (because I'm not really coming across anything that would explain it otherwise)?

 

Edit: Then I ran across OnTrigger and OnTriggerEnter (the latter reacting to volume trigger). I take it that is sort of the "proximity" setting. Follow up question would be, where would I generally find these volumes?

Edited by dimedius
Link to comment
Share on other sites

Yep, it's the same as a trigger event. I've looked closer at that trapbase, I'm not 100% sure that's what fires off with mines, however I can't really find anything that explains how mines work. I'm more familiar with scripting rather than editor objects though so someone else may be able to answer that?

Link to comment
Share on other sites

Here's a pastebin of the entire TrapBase. I'm fairly convinced this is the script that handles mines. I think if it is possible to capture the event that triggers the check to explode, to then cancel/disable it and then write a new "mine" code that is similar to the original one with the check for player distance etc.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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