# Custom item spawner template by Chaobrother. You are free to use and modify it!
# It is HIGHLY reccomended NOT to use this template if you are willing to use 
# game modifying, Lua in your mod.
# Items will always be picked up regardless if the player already has an item.
# A new thing will need to be made for each custom item spawner.
# DO NOT use the default states, objects, or Thing number of this object in order
# to prevent conflicts. 


# You MUST change the state and object names to prevent conflicts.
#
# You should modify/add to S_ITEM_MINE_SPAWNER to change the objects non pickedup behavior.
#
# You will change S_SPAWNED_ITEM_MINE__SET and S_SPAWNED_ITEM_MINE__QUANTIFY to change object
# type and quantity
#
# You will change the duration of S_ITEM_MINE__CREATE8 to change the respawn preiod.
# There are 35 tics in 1 Second.

Freeslot
MT_ITEM_MINE_SPAWNER
S_ITEM_MINE_SPAWNER
S_ITEM_MINE__CREATE
S_ITEM_MINE__CREATE2
S_ITEM_MINE__CREATE3
S_ITEM_MINE__CREATE4
S_ITEM_MINE__CREATE5
S_ITEM_MINE__CREATE6
S_ITEM_MINE__CREATE7
S_ITEM_MINE__CREATE8
S_ITEM_MINE__SPAWNER_RESPAWN
S_SPAWNED_ITEM_MINE__SET
S_SPAWNED_ITEM_MINE__TARGET
S_SPAWNED_ITEM_MINE__TARGET1
S_SPAWNED_ITEM_MINE__QUANTIFY
S_SPAWNED_ITEM_MINE__PULL

#Generic item Idle state. Change/add states here to set what you want the item to do
#before it is picked up.
State S_ITEM_MINE_SPAWNER
SpriteName = RNDM
SpriteFrame = FF_ANIMATE|A
Duration = -1
Next = S_ITEM_MINE_SPAWNER
Action = none
Var1 = 23
Var2 = 1

#Death state: this and the targeting/remote action states will not need to be modified.

State S_ITEM_MINE__CREATE
SpriteName = NULL
SpriteFrame = A
Var1 = 0
Var2 = MT_FLOATINGITEM
Duration = 0
Next = S_ITEM_MINE__CREATE2
Action = A_SpawnObjectRelative

#The spawned item needs to be targeted to work with it.
#This may cause issues if too many items are spawned by
#this thing and are left laying close to it.
State S_ITEM_MINE__CREATE2
SpriteName = NULL
SpriteFrame = A
Var1 = MT_FLOATINGITEM
Var2 = 0
Duration = 0
Next = S_ITEM_MINE__CREATE3
Action = A_FindTarget

State S_ITEM_MINE__CREATE3
SpriteName = NULL
SpriteFrame = A
Var1 = -1
Var2 = S_SPAWNED_ITEM_MINE__TARGET
Duration = 0
Next = S_ITEM_MINE__CREATE4
Action = A_RemoteAction

State S_ITEM_MINE__CREATE4
SpriteName = NULL
SpriteFrame = A
Var1 = -1
Var2 = S_SPAWNED_ITEM_MINE__TARGET1
Duration = 0
Next = S_ITEM_MINE__CREATE5
Action = A_RemoteAction

State S_ITEM_MINE__CREATE5
SpriteName = NULL
SpriteFrame = A
Var1 = -1
Var2 = S_SPAWNED_ITEM_MINE__SET
Duration = 0
Next = S_ITEM_MINE__CREATE6
Action = A_RemoteAction

State S_ITEM_MINE__CREATE6
SpriteName = NULL
SpriteFrame = A
Var1 = -1
Var2 = S_SPAWNED_ITEM_MINE__QUANTIFY
Duration = 0
Next = S_ITEM_MINE__CREATE7
Action = A_RemoteAction

State S_ITEM_MINE__CREATE7
SpriteName = NULL
SpriteFrame = A
Var1 = -1
Var2 = S_SPAWNED_ITEM_MINE__PULL
Duration = 5
Next = S_ITEM_MINE__CREATE8
Action = A_RemoteAction

#Removes an item if it was not picked up close to instantly.
State S_ITEM_MINE__CREATE8
SpriteName = NULL
SpriteFrame = A
Var1 = 1
Var2 = 2
#Respawn Period
Duration = 105
Next = S_ITEM_MINE__SPAWNER_RESPAWN
Action = A_RemoteDamage

State S_SPAWNED_ITEM_MINE__TARGET
SpriteName = NULL
SpriteFrame = A
Var1 = MT_PLAYER
Var2 = 0
Duration = 1
Next = S_NULL
Action = A_FindTarget

State S_SPAWNED_ITEM_MINE__TARGET1
SpriteName = NULL
SpriteFrame = A
Var1 = MT_PLAYER
Var2 = 0
Duration = 1
Next = S_NULL
Action = A_FindTracer

#The threshold value of MT_FLOATINGITEM determines what it is.
#A_BuzzFly can set the threshold value using var2. 
#1: sneaker
#2: Rocket Sneaker
#3: Invincibility
#4: Banana
#5: Eggman Box
#6: MINEnaut
#7: Jawz
#8: Mine
#9: Ballhog
#10: SPB
#11: Grow
#12: Shrink
#13: Thunder Shield
#14: HYUDORO
#15: Pogo MINE
#16: Sink

State S_SPAWNED_ITEM_MINE__SET
SpriteName = NULL
SpriteFrame = A
#Set this sound and the object's Deathsound to your pickup sound
Var1 = sfx_kc2e
Var2 = 8
Duration = 0
Next = S_NULL
Action = A_BuzzFly

#The amount of item given is defined by MT_FLOATINGITEM's movecount.
#Var1 of A_Boss2TakeDamage determines movecount.
State S_SPAWNED_ITEM_MINE__QUANTIFY
SpriteName = NULL
SpriteFrame = A
Var1 = 1
Var2 = 0
Duration = 1
Next = S_NULL
Action = A_Boss2TakeDamage

State S_SPAWNED_ITEM_MINE__PULL
SpriteName = NULL
SpriteFrame = A
Var1 = MF2_NIGHTSPULL
Var2 = 2
Duration = 0
Next = S_NULL
Action = A_SetObjectFlags2

State S_ITEM_MINE__SPAWNER_RESPAWN
SpriteName = NULL
SpriteFrame = A
Var1 = 0
Var2 = 0
Duration = 1
Action = A_SpawnFreshCopy
Next = NULL

#This is a generic item which gives 2 invicibilities and 
#respawns after 3 seconds. Change it to spawn what you want
#and fit your needs!
#You will need to change the thingnum to avoid conflicts.
Object MT_ITEM_MINE_SPAWNER
#$Name Special Item Spawner MINE
#$Sprite RNDMA0
#$Category Community Resources
MapThingNum = 3668
SpawnState = S_ITEM_MINE_SPAWNER
SpawnHealth = 1000
SeeState = S_NULL
SeeSound = sfx_None
ReactionTime = 8
AttackSound = sfx_None
PainState = S_NULL
PainChance = MT_THOK
PainSound = sfx_None
MeleeState = S_NULL
MissileState = S_NULL
DeathState = S_ITEM_MINE__CREATE
XDeathState = S_NULL
DeathSound = sfx_kc2e
Speed = 1
Radius = 32*FRACUNIT
Height = 32*FRACUNIT
DispOffset = 0
Mass = 0
Damage = 0
ActiveSound = sfx_None
Flags = MF_SLIDEME|MF_SPECIAL|MF_NOGRAVITY|MF_NOCLIPHEIGHT|MF_DONTENCOREMAP
RaiseState = MT_FLOATINGITEM
