Jump to content

Change Misc item into Activator when dropped


KnightRangersGuild

Recommended Posts

I've created an Activator that i need and created a script to go with it and it works perfectly. The issue i'm having is i need to be able to carry it in inventory and i simply can't figure out how...i guess theres no way to carry or pick up an Activator. I was thinking of adding a script to a Misc item or something along those lines but i can't find any vanilla scrips that do this.

Can any please help with basically droping a Misc item but it drops the Activator instead but still gets removed from players inventory.

Sounds like it would be a very simple script but i can't figure it out. Or if anyone can figure out how to carry the activator even better??

 

Thanks for the help, this is for my quest mod and is very important i figure this out.

Link to comment
Share on other sites

You're right that you need two items. A misc item for the inventory and then the activator for the game world.

Here's a simple script that you would put on the misc item that will replace it with the activator whenever the player drops it into the game world.

ScriptName CDC_InventoryTokenScript extends ObjectReference

Activator Property CDC_WorldItem Auto

Event OnContainerChanged(ObjectReference dest, ObjectReference src)
	if !dest  ; dropped into the game world
		Actor PlayerRef = Game.GetPlayer()
		if src == PlayerRef  ; by the player
			Disable()
			ObjectReference newRef = PlayerRef.PlaceAtMe(CDC_WorldItem, 1, false, true)
			float angle = PlayerRef.GetAngleZ()
			newRef.SetAngle(0, 0, angle + 0) ; change the last zero to 180 to turn it around 
			newRef.MoveTo(PlayerRef, Math.Sin(angle) * 100, Math.Cos(angle) * 100, 0, false)
			newRef.SetActorOwner(PlayerRef.GetBaseObject() as ActorBase) ; player should own it
			newRef.Enable()
			Delete()
		endif
	endif
EndEvent

The item will be placed 100 game units in front of and facing the player but you can adjust a few constants if you need to change that.

And here's the script for the activator which allows the player to pick the it back up by grabbing it.

ScriptName CDC_WorldItemScript extends ObjectReference

MiscObject Property CDC_InventoryToken Auto

Event OnGrab()
	Disable()
	Game.GetPlayer().AddItem(CDC_InventoryToken, 1)
	Delete()
EndEvent

This is code I use for my own portable bedroll mod but with a Furniture type instead of Activator. And I use similar code for portable containers.

Link to comment
Share on other sites

Sweet thanks i think this is exactly what i'm looking for thank you 12 1/2 times and a bow.

I wont be needing the second one because the item i made is a 10 second fuse bomb so it disappears after it explodes but i think it may come in handy in the future. I'm trying it now brb.

This is a large quest mod so i'll be sure to include you in the credits.

Edited by KnightRangersGuild
Link to comment
Share on other sites

Maybe this is a silly question, but why not just use a misc object? They can do everything an activator can.

That's a very good question. If you wanted the bomb to go off after the item is activated you can still have an OnActivate event and if you want it to go off after the item is dropped you have the OnContainerChanged and those first two checks to detect it being placed.

 

 

 

Thanks again this is exactly what i needed. Now i'm just trying to get the angle right. Do i change the angle in the script itself or the nif? When it spawns it spawns under the player.

These two lines are the key to where it will be placed:

newRef.SetAngle(0, 0, angle + 0) ; change the last zero to 180 to turn it around 
newRef.MoveTo(PlayerRef, Math.Sin(angle) * 100, Math.Cos(angle) * 100, 0, false)

Those two values of 100 determine how far from the player it will appear. And if the angle is wrong you want to change that last zero on the first line. It certainly shouldn't end up under the player but it could depend on the particular nif file's concept of item center. I would start by changing that first line to get the item facing the way you want then change the 100s in the second line to get the spacing right. Just to see the differences those make try something like this to get started.

newRef.SetAngle(0, 0, angle + 90)
newRef.MoveTo(PlayerRef, Math.Sin(angle) * 200, Math.Cos(angle) * 200, 0, false)
Link to comment
Share on other sites

Here's the script i made that goes on the activator and with cdcooley's helpful script i put on the misc item it works great, i just have to figure out the angle.

Also i have another issue...as you can see in the pictures i have a unignited bomb and a ignited bomb and i need them to be switched when activated and the ignited bomb to start the countdown. Any more advice??? Thanks a lot for your help friends.

 

 

 

Scriptname ABB_TimedBombScript extends ObjectReference

 

sound property FusedSound auto

FLOAT PROPERTY waitTimer AUTO

EXPLOSION PROPERTY BombExplosion AUTO

explosion property placedExplosion auto

 

bool CANEXPLODE=TRUE

auto STATE WaitingToBeActivated

 

EVENT onActivate(objectReference triggerRef)

FusedSound.play(self)

if(CANEXPLODE)

CANEXPLODE = FALSE

 

utility.wait(waitTimer)

 

CANEXPLODE = TRUE

 

; debug.trace("Light fuse and throw using telekinesis or drop and run")

self.placeAtMe(BombExplosion)

 

endif

 

if placedExplosion

self.placeAtMe(placedExplosion)

 

else

; debug.Trace("Second explosion if you want")

endif

 

Disable()

GoToState("Disabled")

EndEvent

EndState

 

STATE Disabled

;done doing stuff

endSTATE

 

 

http://imagizer.imageshack.us/v2/150x100q90/923/M45bGg.jpg

http://imagizer.imageshack.us/v2/150x100q90/922/vK4aLl.jpg

 

 

P.S. If anyone wants to use this script in there mod it would be cool to give me some credit because i know nothing about scripting and i made this using vanilla scripts and it took two weeks of trial and error. Also make sure to set the sound property to "QSTMiraakDeathBurnMarker" in properties because it's exactly 10 sec fuse burning sound, thanks.

Edited by KnightRangersGuild
Link to comment
Share on other sites

  • Recently Browsing   0 members

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