Jump to content

Need Scripting Help


TheChan

Recommended Posts

I'm trying to make it so when a switch is activated, it electrocutes an NPC, but it doesn't do anything when I activate the switch.

 

scn TestShock

Short DoOnce

begin OnActivate
if ( DoOnce == 0 )
scientisttest.AddSpell ElectrocuteSpell
Set DoOnce to -1
endif
end

 

I made a new actor effect (ElectrocuteSpell) with this effect:

Shock Damage

Magnitude:9999999

Area:0

Duration:1 s

Range:Self

 

It does not do anything.

Link to comment
Share on other sites

If you've got the Operation Anchorage DLC, it comes with one for Jingwei's Shocksword.

No I don't.

 

 

I've got another problem.

 

Here is my script, which works fine, but the light model fades in, and I don't want it to.

scn AALIGHTSWITCH

short DoOnce
short lightison

Begin GameMode
if ( DoOnce == 0 )
	lightOFF.Disable
	set DoOnce to -1
	set lightison to 1
endif
End

Begin OnActivate
if  ( lightison == 1 )
	lightON.Disable
	lightLIGHT.Disable
	lightOFF.Enable
	set lightison to 0
	setOpenState 0
else
	lightON.Enable
	lightOFF.Disable
	lightLIGHT.Enable 
	set lightison to 1
	setOpenState 1
endif
End

 

What do I put after "enable" and "disable" to get rid of the fade?

 

Here, it provides a completely useless example of how to enter it.

Link to comment
Share on other sites

That example is only useless if you don't understand the syntactical example given above, which you can have explained to you in more detail by clicking on the "help" link next to its heading. As stated there, you can prevent an object from fading in by setting the "FadeIn" parameter to 0:

lightOn.Enable 0

When I wrote that particular example I wanted to show the effect of not including a value for the "FadeIn" parameter, as that is the most common way of calling Enable. I was hoping that the added description would help to explain the function of the parameter. If you think a different example or more detailed explanation of the parameter is necessary, please don't hesitate to add it. After all, it is a wiki.

 

Looking at your code and your EditorRefIDs, I think you should also be able to shorten and simplify your code by using Enable Parenting.

 

In order to change the outcome of an OnActivate block depending on the reference that triggered it, you can use GetActionRef or IsActionRef:

ScriptName AALIGHTSWITCH

short DoOnce
short LightIsOn

Begin GameMode
if DoOnce
else
	lightOFF.Disable
	set DoOnce to -1
	set LightIsOn to 1
endif
End

Begin OnActivate
if IsActionRef player
	Activate
elseif  LightIsOn
	lightON.Disable
	lightLIGHT.Disable
	lightOFF.Enable 0
	set LightIsOn to 0
	SetOpenState 0
else
	lightON.Enable 0
	lightOFF.Disable
	lightLIGHT.Enable 0
	set LightIsOn to 1
	SetOpenState 1
endif
End

You may need to use a scripted base effect in order to apply the sound and effect properly. Have a look at the scripts that control things like plasma gooification for some idea on how to do this. You'll want to use PlayMagicShaderVisuals and possibly StopMagicShaderVisuals.

 

Cipscis

Link to comment
Share on other sites

Okay, I got the ElectrocuteSpell to kill the NPC, but there is no shock effect.

 

Here are the settings I have on the shock effect:

http://s106.photobucket.com/albums/m245/A_User_Name_That_Isnt_Taken/th_temp-18.jpg

 

When I pull the lever, the NPC just dies. There is no sound and no "computer sparks" effect.

Since there's no resources from the DLC used, it should be okay to post the data for how Beth did it in OA. Here's a screencap I took of the relevant effects.

http://img189.imageshack.us/img189/6994/shader.th.jpg

That should at least take care of your electrocution effect, though it'll look like the actor has a blue shock-ey forcefield around them rather than sparks coming off. No clue about the sound, though.

Link to comment
Share on other sites

Okay, I got the ElectrocuteSpell to kill the NPC, but there is no shock effect.

 

Here are the settings I have on the shock effect:

http://s106.photobucket.com/albums/m245/A_User_Name_That_Isnt_Taken/th_temp-18.jpg

 

When I pull the lever, the NPC just dies. There is no sound and no "computer sparks" effect.

Since there's no resources from the DLC used, it should be okay to post the data for how Beth did it in OA. Here's a screencap I took of the relevant effects.

http://img189.imageshack.us/img189/6994/shader.th.jpg

That should at least take care of your electrocution effect, though it'll look like the actor has a blue shock-ey forcefield around them rather than sparks coming off. No clue about the sound, though.

I've figured out something that works, and I like it.

 

Here's the code.

 

Basically what happens is the player has the option the turn on the power while an enemy worker is fiddling some wires, and it kills the worker. However if the player is detected, the opportunity is lost and the worker makes an attempt to kill the player.

 

scn aaTestShock

Short DoOnce
Short Next
Short PlayerDetected
Float Timer
Ref EyeExpNP

begin OnActivate
if ( DoOnce == 0 )
if ( PlayerDetected == 0 )
	SetOpenState 1
	Set DoOnce to -1
	Set Next to 1
else
	SetOpenState 1
endif
endif

end

;adds a delay for the lever to go down

begin GameMode
if ( scientisttest.GetDetected player == 1 )
set PlayerDetected to 1
endif

if ( Next == 1)
Set Timer to Timer + GetSecondsPassed
	if ( Timer >= 1 )
		scientisttest.PlaceAtMe FXComputerSparks 1
		scientisttest.PlaceAtMe FXSmoke 1
		scientisttest.PlaceAtMe ElectrocutionExplosion 1, 128, 0
		set Timer to 0
		set Next to 2
	endif
endif

end

 

 

Thanks for the help Cipscis. Do you have any kind of instant messenger or something in case I have a quick scripting question?

Link to comment
Share on other sites

Sounds like a pretty cool sequence, I'm glad you've got it working! If you want to ask me a scripting question or something, feel free to contact me via MSN. I won't post my address in this thread, but you can find it in the "Contact Information" at the bottom of my profile here, or on the Contact Me page on my website.

 

Cipscis

Link to comment
Share on other sites

  • Recently Browsing   0 members

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