Jump to content

How to make Toggle items/activator items.


ghostfc3s

Recommended Posts

I am curious on how these items work, like Aft command item, or the gas mask clean item. They are defined as consumables but return to, or I am assuming a new version is placed in the players inventory.

 

Anyone have a tutorial on how those items work?

Edited by ghostfc3s
Link to comment
Share on other sites

Use a potion and attach a magic effect to it. The magic effect has a script attached. Use the OnEffectStart event and re-add the potion to the players inventory first. Then do the stuff you want to do with the toggle. Ideally check first whether the actor consuming the activator is the player just to be sure nothing weird happens when someone else got their hands on the toggle.

 

 

An example script for your magic effect.

Scriptname YourToggleMagicEffect extends ActiveMagicEffect
{Does some stuff and gives the used potion back to the player}

Potion Property TheToggleItem Auto Const Mandatory 
{The potion to give back to the player}


; ===========================================================================================================================
; Check whether the player used the item and give a potion back to his/her inventory.
; ===========================================================================================================================
Event OnEffectStart( Actor akTarget, Actor akCaster )
	If( Game.GetPlayer() != akTarget )
		return
	EndIf
	
	Game.GetPlayer().AddItem(TheToggleItem , 1, True)
 
        ;Do your stuff here...
EndEvent
Link to comment
Share on other sites

I added the item, added the construction receipt so I can craft it. When activating it item does what I want however the activator still wont return to the player.

 

The script is identical to your script just the item name is changed.

 

Event OnEffectStart( Actor akTarget, Actor akCaster )

If( Game.GetPlayer() != akTarget )

return

EndIf

 

Game.GetPlayer().AddItem(DontbeaPyscho , 1, True)

 

 

EndEvent

 

The script is attached to the magic effect named Taunt

 

Property name = playerconsumetaunt

type = keyword

Value = playerconsumetaunt

 

That's is the same setup as the psycho

 

Not sure what I'm doing wrong here.

Edited by ghostfc3s
Link to comment
Share on other sites

You also need to fill in the properties in CK for that script in your magic effect. This is needed to tell the game which Form you actually mean with "DontbeaPyscho". The name in your script doesn't need to be equal to the name of the object.

Link to comment
Share on other sites

Under magic effect, right hand lower is script name, included is Taunt, click on that opens up properties for script taunt attached

 

I click add properties and I get a whole wack of options, Using AFT as an example I attempted type Potion flag const name taunt in documentation included the script

 

I received error mismatched "event" expecting script name

 

And error script taunt:object reference not set to an instance of an object.

 

I dont do any coding so this all chinese to me.

Link to comment
Share on other sites

No. there should be a list of properties. You have to click on the property with the name "DontbeaPyscho" and on the right, you have to select the item you want to assign to this property. In this case it's the toggle item. You don't want to create a new property.

Link to comment
Share on other sites

You forgot a part of my script. The like that stars with âžPropertyâ this declares it. You have to declare properties before you can use them. Your script also shouldnât compile without.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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