v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"itemName" : "dronecontroller",
|
||||
"level" : 1,
|
||||
"rarity" : "rare",
|
||||
"description" : "Some kinda weird and janky thing.",
|
||||
"shortdescription" : "Drone Controller",
|
||||
"twoHanded" : true,
|
||||
|
||||
"inventoryIcon" : "dronecontroller.png",
|
||||
"animation" : "dronecontroller.animation",
|
||||
"scripts" : ["dronecontroller.lua"]
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"animatedParts" : {
|
||||
"stateTypes" : {
|
||||
"heldItem" : {
|
||||
"default" : "drone",
|
||||
"states" : {
|
||||
"drone" : { },
|
||||
"controller" : { }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"parts" : {
|
||||
"heldItem" : {
|
||||
"properties" : {
|
||||
"centered" : true
|
||||
},
|
||||
|
||||
"partStates" : {
|
||||
"heldItem" : {
|
||||
"drone" : {
|
||||
"properties" : {
|
||||
"image" : "/projectiles/activeitems/drone/drone.png:0",
|
||||
"offset" : [0.0, 0.0]
|
||||
}
|
||||
},
|
||||
"controller" : {
|
||||
"properties" : {
|
||||
"image" : "dronecontroller.png",
|
||||
"offset" : [0.5, 0.5]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
110
assets/devel/items/active/dronecontroller/dronecontroller.lua
Normal file
110
assets/devel/items/active/dronecontroller/dronecontroller.lua
Normal file
|
@ -0,0 +1,110 @@
|
|||
require "/scripts/vec2.lua"
|
||||
|
||||
function init()
|
||||
updateDrone()
|
||||
end
|
||||
|
||||
function uninit()
|
||||
-- sb.logInfo("Uninitializing metagun")
|
||||
end
|
||||
|
||||
function update(dt, fireMode, shiftHeld)
|
||||
-- sb.logInfo("Updating metagun with fireMode %s and shiftHeld %s", fireMode, shiftHeld)
|
||||
|
||||
updateDrone()
|
||||
updateAim()
|
||||
updateControl(fireMode)
|
||||
end
|
||||
|
||||
function activate(fireMode, shiftHeld)
|
||||
if storage.droneId == nil then
|
||||
launchDrone()
|
||||
else
|
||||
self.controlPosition = world.distance(activeItem.ownerAimPosition(), mcontroller.position())
|
||||
self.droneControlPosition = world.entityPosition(storage.droneId)
|
||||
end
|
||||
end
|
||||
|
||||
function launchDrone()
|
||||
local launchAngle = vec2.rotate({1, 0}, self.aimAngle)
|
||||
launchAngle[1] = launchAngle[1] * self.aimDirection
|
||||
storage.droneId = world.spawnProjectile(
|
||||
"drone",
|
||||
mcontroller.position(),
|
||||
activeItem.ownerEntityId(),
|
||||
launchAngle,
|
||||
false,
|
||||
{}
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function updateDrone()
|
||||
if storage.droneId and not (world.entityExists(storage.droneId) and world.callScriptedEntity(storage.droneId, "isDrone")) then
|
||||
storage.droneId = nil
|
||||
end
|
||||
|
||||
activeItem.setCameraFocusEntity(storage.droneId)
|
||||
|
||||
if storage.droneId then
|
||||
animator.setAnimationState("heldItem", "controller")
|
||||
else
|
||||
animator.setAnimationState("heldItem", "drone")
|
||||
activeItem.setCursor(nil)
|
||||
end
|
||||
end
|
||||
|
||||
function updateAim()
|
||||
self.aimAngle, self.aimDirection = activeItem.aimAngleAndDirection(0, activeItem.ownerAimPosition())
|
||||
if storage.droneId then
|
||||
activeItem.setArmAngle(0)
|
||||
else
|
||||
activeItem.setArmAngle(self.aimAngle)
|
||||
end
|
||||
activeItem.setFacingDirection(self.aimDirection)
|
||||
end
|
||||
|
||||
function updateControl(fireMode)
|
||||
if fireMode ~= "primary" then
|
||||
self.controlPosition = nil
|
||||
end
|
||||
|
||||
if storage.droneId and self.controlPosition then
|
||||
local newControlPosition = world.distance(activeItem.ownerAimPosition(), mcontroller.position())
|
||||
world.callScriptedEntity(storage.droneId, "controlTo", vec2.add(self.droneControlPosition, vec2.sub(newControlPosition, self.controlPosition)))
|
||||
end
|
||||
|
||||
-- if storage.droneId and self.controlPosition then
|
||||
-- local newControlPosition = world.distance(activeItem.ownerAimPosition(), mcontroller.position())
|
||||
-- world.callScriptedEntity(storage.droneId, "control", vec2.sub(newControlPosition, self.controlPosition))
|
||||
-- self.controlPosition = newControlPosition
|
||||
-- end
|
||||
|
||||
-- if storage.droneId and self.controlPosition then
|
||||
-- local newControlPosition = world.distance(activeItem.ownerAimPosition(), mcontroller.position())
|
||||
-- local controlOffset = vec2.sub(newControlPosition, self.controlPosition)
|
||||
-- if vec2.mag(controlOffset) > 1 then
|
||||
-- if math.abs(controlOffset[1]) > math.abs(controlOffset[2]) then
|
||||
-- if controlOffset[1] > 0 then
|
||||
-- world.callScriptedEntity(storage.droneId, "control", {1, 0})
|
||||
-- activeItem.setCursor("/cursors/joystickright.cursor")
|
||||
-- else
|
||||
-- world.callScriptedEntity(storage.droneId, "control", {-1, 0})
|
||||
-- activeItem.setCursor("/cursors/joystickleft.cursor")
|
||||
-- end
|
||||
-- else
|
||||
-- if controlOffset[2] > 0 then
|
||||
-- world.callScriptedEntity(storage.droneId, "control", {0, 1})
|
||||
-- activeItem.setCursor("/cursors/joystickup.cursor")
|
||||
-- else
|
||||
-- world.callScriptedEntity(storage.droneId, "control", {0, -1})
|
||||
-- activeItem.setCursor("/cursors/joystickdown.cursor")
|
||||
-- end
|
||||
-- end
|
||||
-- else
|
||||
-- activeItem.setCursor("/cursors/joystick.cursor")
|
||||
-- end
|
||||
-- elseif storage.droneId then
|
||||
-- activeItem.setCursor("/cursors/joystick.cursor")
|
||||
-- end
|
||||
end
|
BIN
assets/devel/items/active/dronecontroller/dronecontroller.png
Normal file
BIN
assets/devel/items/active/dronecontroller/dronecontroller.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 309 B |
Loading…
Add table
Add a link
Reference in a new issue