thanks alot for this as well man, probably I will need ton tuse it, still nice scriptBlichew wrote:I think I found a solution to have multiple scrolls, each with different target:
1. Changed your object definition a bit to send ID of scroll which was used:2. Place script_entity with name teleportTarget (doesn't matter where) and put inside:Code: Select all
defineObject{ name = "teleport_scroll", baseObject = "tome_wisdom", components = { { class = "Model", model = "assets/models/items/scroll.fbx", castShadow = true, }, { class = "Item", uiName = "Teleportation Scroll", gfxIndex = 112, description = "Reading this will warp you to another location.", weight = 0.3, }, { class = "UsableItem", sound = "teleport", onUseItem = function(self) teleportTarget.script.validateTarget(self.go.id) -- name the script entity "teleportTarget" end }, }, }
This one actually works, my previous entry in this thread was rather messyCode: Select all
teleport_scroll_targets = {"teleport_scroll_1",1,25,12,0, -- {scrollID,level,X,Y,elevation} "teleport_scroll_2",1,27,12,0} function validateTarget(sender) for i = 1,#teleport_scroll_targets do if teleport_scroll_targets[i] == sender then local targetL = teleport_scroll_targets[i+1] local targetX = teleport_scroll_targets[i+2] local targetY = teleport_scroll_targets[i+3] local targetE = teleport_scroll_targets[i+4] moveToTarget(targetL,targetX,targetY,targetE) end end end function moveToTarget(L,X,Y,E) local tp = spawn("teleporter", party.level, party.x, party.y, 0, party.elevation) tp.teleporter:setTeleportTarget(L,X,Y,E) tp:destroyDelayed(1) end
--
Blichew
Teleportation scroll request
Re: Teleportation scroll request
Re: Teleportation scroll request
Hey folks, hoping this an appropriate thread to ask...
I have a dagger that teleports you to a new position when you equip it in hand - it calls a script in dungeon
I can equip the weapon, and get teleported to the new position and when I unequip the item, I am returned to my original position
BUT!! I fall about 2-3 levels of elevation (as if I have just fallen down a pit)
I figured if I used getWorldPosition that it would include the correct elevation, but it doesnt seem to be working that way for me...
Any thoughts?
Akroma
I have a dagger that teleports you to a new position when you equip it in hand - it calls a script in dungeon
SpoilerShow
Code: Select all
function dagger1000StingsCursedEquip(self,champion,slot)
local ordinal = champion:getOrdinal()
local skill = champion:getSkillLevel("light_weapons")
local name = champion:getName()
local t = findEntity("stingTimer")
local db = findEntity("daggerblocker1")
local sb = findEntity("stings1000blocker1")
local hb = findEntity("hiveBlocker")
local position = hb:getWorldPosition()
if db then
db.go:destroy()
end
if sb then
sb.go:destroy()
end
if slot == 1 or slot == 2 then
if skill >= 5 then
if not daggerblocker1 and not stings1000blocker1 then
spawn("blocker", party.level, party.x, party.y, party.elevation, party.facing, "stings1000blocker1")
party:setWorldPosition(position)
hudPrint("The 1000 Stings Curse takes you into the middle of a Shrakk Torr hive!!!")
end
else
champion:removeItemFromSlot(slot)
spawn( "dagger_1000_stings_cursed",party.level,party.x,party.y,party.elevation,party.facing)
playSound("item_drop")
hudPrint("You are not skillful enough to weild the exotic dagger....")
end
return true
else
playSound("item_drop")
hudPrint(""..name..": This thing looks dangerous... be careful about holding it....")
end
end
function dagger1000StingsCursedUnequip(self,champion, slot)
local skill = champion:getSkillLevel("light_weapons")
local name = champion:getName()
local db = findEntity("daggerblocker1")
local sb = findEntity("stings1000blocker1")
local t = findEntity("stingTimer")
local position = sb:getWorldPosition()
if slot == 1 or slot == 2 then
if t then
t.go:destroy()
end
if sb then
party:setWorldPosition(position)
hudPrint("The 1000 Stings Curse returns you to your world....")
sb:destroy()
end
return true
else
playSound("item_drop")
hudPrint(""..name..": This thing looks dangerous... be careful about holding it....")
end
end
BUT!! I fall about 2-3 levels of elevation (as if I have just fallen down a pit)
I figured if I used getWorldPosition that it would include the correct elevation, but it doesnt seem to be working that way for me...
Any thoughts?
Akroma
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Teleportation scroll request
I'd suggest using spawn ("teleporter") at party location (and then setting up the target, etc) because that way you set point to exact location, not using an offset (like setworldpos. does)
If yku want to use get/set position instead of setWorldPosition you could try setPosition, maybe it'll work
If yku want to use get/set position instead of setWorldPosition you could try setPosition, maybe it'll work
Re: Teleportation scroll request
that dagger seems quite interesting ! nice addition to your weapon arsenal Akroma
Re: Teleportation scroll request
@Bilchew - thanks! Teleporter was a good idea, this works fine now
@Drakkan - haha thanks! One of the more complicated items im trying to convert over (its cursed - and teleports you into the middle of a shrakk torr hive on equip - you need to kill all the shrakk torr to uncurse the item)
... which brings me to my next problem...
I know this is a bit off-topic but it is fairly simple fix I think (I am having trouble adapting to the new component system obviously)
I have this code in the same script... it checks to see if there are any shrakk torr in the area
the script returns false if there is, if there isnt - you have killed them all - then I simply want to get rid of the cursed item and put the uncursed version back into the same slot
I have played around with the code in so many ways, cant seem to get it right
SpoilerShow
Code: Select all
function dagger1000StingsCursedEquip(self,champion,slot)
local ordinal = champion:getOrdinal()
local skill = champion:getSkillLevel("light_weapons")
local name = champion:getName()
local t = findEntity("stingTimer")
local st = findEntity("stingsTeleportBack")
local sb = findEntity("stings1000blocker1")
local hb = findEntity("hiveBlocker")
local position = hb:getWorldPosition()
if st then
st:destroy()
end
if sb then
sb:destroy()
end
if slot == 1 or slot == 2 then
if skill >= 5 then
if not stings1000blocker1 then
spawn("blocker", party.level, party.x, party.y, party.elevation, party.facing, "stings1000blocker1")
party:setWorldPosition(position)
hudPrint("The 1000 Stings Curse takes you into the middle of a Shrakk Torr hive!!!")
end
else
champion:removeItemFromSlot(slot)
spawn( "dagger_1000_stings_cursed",party.level,party.x,party.y,party.elevation,party.facing)
playSound("item_drop")
hudPrint("You are not skillful enough to weild the exotic dagger....")
end
return true
else
playSound("item_drop")
hudPrint(""..name..": This thing looks dangerous... be careful about holding it....")
end
end
function dagger1000StingsCursedUnequip(self,champion, slot)
local skill = champion:getSkillLevel("light_weapons")
local name = champion:getName()
local st = findEntity("stingsTeleportBack")
local sb = findEntity("stings1000blocker1")
local t = findEntity("stingTimer")
local position = sb:getWorldPosition()
if slot == 1 or slot == 2 then
if t then
t:destroy()
end
if st then
st:destroy()
end
if sb then
spawn("teleporter", party.level, party.x, party.y, 0, party.elevation, "stingsTeleportBack")
stingsTeleportBack.teleporter:setTeleportTarget(sb.level, sb.x, sb.y, 0)
hudPrint("The 1000 Stings Curse returns you to your world....")
sb:destroy()
end
return true
else
playSound("item_drop")
hudPrint(""..name..": This thing looks dangerous... be careful about holding it....")
end
end
... which brings me to my next problem...
I know this is a bit off-topic but it is fairly simple fix I think (I am having trouble adapting to the new component system obviously)
I have this code in the same script... it checks to see if there are any shrakk torr in the area
the script returns false if there is, if there isnt - you have killed them all - then I simply want to get rid of the cursed item and put the uncursed version back into the same slot
SpoilerShow
Code: Select all
function checkForThings(thing,xMin,xMax,yMin,yMax)
for x = xMin,xMax do
for y = yMin,yMax do
for entity in self.go.map:entitiesAt(x,y) do
if entity.name == "shrakk_torr" then
return true
end
end
end
end
return false
end
function checkSting()
local itemFound = false
local stingchamp = nil
local stingslot = nil
if checkForThings("shrakk_torr",1,3,11,13) then
return false
else
for champ = 1,4 do
for slot = 1,2 do
local c = party.party:getChampion(champ)
local item = c:getItem(slot)
if item.go ~= nil and item.go.name == "dagger_1000_stings_cursed" then
itemFound = true
stingchamp = champ
stingslot = slot
end
end
end
if itemFound == true then
local c = party.party:getChampion(stingchamp)
c:removeItemFromSlot(stingslot)
c:insertItem("dagger_1000_stings",stingslot)
local timer = findEntity("stingHiveTimer")
if timer then
timer.go:destroy()
end
hudPrint("You have beaten back the stinging Shrakk Torr hordes!! ... and as such, lifted the curse on the dagger!!")
return true
end
end
end
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
- Mysterious
- Posts: 226
- Joined: Wed Nov 06, 2013 8:31 am
Re: Teleportation scroll request
Hi Akroama. With you code I assume you have the following Entities:
Timer: stingTimer
teleport: stingsTeleportBack
blocker: stings1000blocker
hb: hiveBlocke
I don't understand how to connect any of these thing together with your code or the dagger object runs which script. I don't know if this is for your Mod only but if it is not can you show me what to do as this is awesome idea.
Timer: stingTimer
teleport: stingsTeleportBack
blocker: stings1000blocker
hb: hiveBlocke
I don't understand how to connect any of these thing together with your code or the dagger object runs which script. I don't know if this is for your Mod only but if it is not can you show me what to do as this is awesome idea.
Re: Teleportation scroll request
Hey Mysterious!
Yes it's my mod dagger (from Labyrinth o Lies) - trying to convert it over to LoG2
Dagger (cursed and uncursed) definition
And it calls cursedItemScript with these functions-
If you are testing you will need to paste 3x3 tiles into coords 1x 11y - 3x 13y (this is where the function checkForThings checks for shrakk torr
It all works except the bit where I go and check for the cursed item, remove it and replace it with the uncursed version (which should be the easy part, right!! )
Ultimately, the dagger works like this... https://www.youtube.com/watch?v=zY1Pt-Loc80 (watch from 17:30)
except i am going to spawn the dagger into a hand slot instead of a floating invisible alcove (havent converted that yet)
EDIT - have just commented out the custom sounds you may not have
Yes it's my mod dagger (from Labyrinth o Lies) - trying to convert it over to LoG2
Dagger (cursed and uncursed) definition
SpoilerShow
Code: Select all
defineObject{
name = "dagger_1000_stings_cursed",
baseObject = "dagger",
components = {
{
class = "Model",
model = "assets/models/items/fist_dagger.fbx",
},
{
class ="Item",
uiName = "Dagger of 1000 Stings",
gfxAtlas = "mod_assets/textures/akroma_icons11.tga",
gfxIndex = 49,
weight = 1.0,
impactSound = "impact_blade",
traits = { "dagger", "light_weapon" },
gameEffect = "*CURSED*",
secondaryAction = "flurry_of_stings1",
description = "Many heroes and sell swords have tried to weild the dagger... but all disappear upon picking it up... only one man ever returned and he was mutilated beyond recognition... where does this dagger take people??",
weight = 1.2,
onEquipItem = function(self,champion, slot)
return cursedItemScript.script.dagger1000StingsCursedEquip(self,champion,slot)
end,
onUnequipItem = function(self,champion, slot)
return cursedItemScript.script.dagger1000StingsCursedUnequip(self,champion,slot)
end,
},
{
class = "MeleeAttack",
attackPower = 24,
accuracy = 10,
swipe = "thrust",
attackSound = "swipe",
cooldown = 1.6,
baseDamageStat = "dexterity",
requirements = {"light_weapons" ,5},
},
{
class = "MeleeAttack",
name = "flurry_of_stings1",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings2",
chainActionDelay = 0.1,
repeatCount = 7,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
cooldown = 2.8,
energyCost = 40,
gameEffect = "A series of piercing strikes focusing on speed and repetition rather than power.",
requirements = { "accuracy", 3},
},
{
class = "MeleeAttack",
name = "flurry_of_stings2",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings3",
chainActionDelay = 0.1,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
{
class = "MeleeAttack",
name = "flurry_of_stings3",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings4",
chainActionDelay = 0.1,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
{
class = "MeleeAttack",
name = "flurry_of_stings4",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings5",
chainActionDelay = 0.1,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
{
class = "MeleeAttack",
name = "flurry_of_stings5",
uiName = "Flurry of Stings",
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
}
}
defineObject{
name = "dagger_1000_stings",
baseObject = "dagger",
components = {
{
class = "Model",
model = "assets/models/items/fist_dagger.fbx",
},
{
class ="Item",
uiName = "Dagger of 1000 Stings",
gfxAtlas = "mod_assets/textures/akroma_icons11.tga",
gfxIndex = 49,
weight = 1.0,
impactSound = "impact_blade",
traits = { "dagger", "light_weapon" },
gameEffect = "*CURSED*",
secondaryAction = "flurry_of_stings1",
description = "Many heroes and sell swords have tried to weild the dagger... but only you have lifted the 1000 Sting Curse... as it's name suggests, the dagger is fast and deadly.",
weight = 1.2,
onEquipItem = function(self,champion,slot)
return itemEquipScript.script.dagger1000StingsEquip(self,champion,slot)
end,
onUnequipItem = function(self,champion, slot)
return itemEquipScript.script.dagger1000StingsEquip(self,champion,slot)
end,
},
{
class = "MeleeAttack",
attackPower = 24,
accuracy = 10,
swipe = "thrust",
attackSound = "swipe",
cooldown = 1.8,
baseDamageStat = "dexterity",
requirements = {"light_weapons" ,5},
},
{
class = "MeleeAttack",
name = "flurry_of_stings1",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings2",
chainActionDelay = 0.1,
repeatCount = 7,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
cooldown = 2.8,
energyCost = 40,
gameEffect = "A series of piercing strikes focusing on speed and repetition rather than power.",
requirements = { "accuracy", 3},
},
{
class = "MeleeAttack",
name = "flurry_of_stings2",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings3",
chainActionDelay = 0.1,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
{
class = "MeleeAttack",
name = "flurry_of_stings3",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings4",
chainActionDelay = 0.1,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
{
class = "MeleeAttack",
name = "flurry_of_stings4",
uiName = "Flurry of Stings",
chainAction = "flurry_of_stings5",
chainActionDelay = 0.1,
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
{
class = "MeleeAttack",
name = "flurry_of_stings5",
uiName = "Flurry of Stings",
attackPower = 18,
swipe = "thrust",
attackSound = "swipe",
baseDamageStat = "dexterity",
},
}
}
SpoilerShow
Code: Select all
function dagger1000StingsCursedEquip(self,champion,slot)
local ordinal = champion:getOrdinal()
local skill = champion:getSkillLevel("light_weapons")
local name = champion:getName()
local t = findEntity("stingTimer")
local st = findEntity("stingsTeleportBack")
local sb = findEntity("stings1000blocker1")
local hb = findEntity("hiveBlocker")
local position = hb:getWorldPosition()
if st then
st:destroy()
end
if sb then
sb:destroy()
end
if slot == 1 or slot == 2 then
if skill >= 1 then
if not stings1000blocker1 then
spawn("blocker", party.level, party.x, party.y, party.elevation, party.facing, "stings1000blocker1")
party:setWorldPosition(position)
--party:playScreenEffect("teleport_screen")
hudPrint("The 1000 Stings Curse takes you into the middle of a Shrakk Torr hive!!!")
--playSound("blinkgate2")
spawn("timer",party.level,party.x,party.y,party.elevation,party.facing,"stingTimer")
stingTimer.timer:setTimerInterval(1)
stingTimer.timer:addConnector("onActivate", "cursedItemScript", "checkSting")
stingTimer.timer:start()
end
else
champion:removeItemFromSlot(slot)
spawn( "dagger_1000_stings_cursed",party.level,party.x,party.y,party.elevation,party.facing)
playSound("item_drop")
hudPrint("You are not skillful enough to weild the exotic dagger....")
end
return true
else
playSound("item_drop")
hudPrint(""..name..": This thing looks dangerous... be careful about holding it....")
end
end
function dagger1000StingsCursedUnequip(self,champion, slot)
local skill = champion:getSkillLevel("light_weapons")
local name = champion:getName()
local st = findEntity("stingsTeleportBack")
local sb = findEntity("stings1000blocker1")
local t = findEntity("stingTimer")
local position = sb:getWorldPosition()
if slot == 1 or slot == 2 then
if t then
t:destroy()
end
if st then
st:destroy()
end
if sb then
spawn("teleporter", party.level, party.x, party.y, 0, party.elevation, "stingsTeleportBack")
stingsTeleportBack.teleporter:setTeleportTarget(sb.level, sb.x, sb.y, 0)
--party:playScreenEffect("teleport_screen")
hudPrint("The 1000 Stings Curse returns you to your world....")
--playSound("guardianstave_summon")
sb:destroy()
end
return true
else
playSound("item_drop")
hudPrint(""..name..": This thing looks dangerous... be careful about holding it....")
end
end
function stings1000CurseStop()
setMouseItem(nil)
setMouseItem(spawn("dagger_1000_stings").item)
--playSound("singingbowl_chime")
hudPrint("You have survived the Cursed Hive... and the curse is lifted so that you may keep the Dagger and revisit the Hive (equip in right hand).")
return true
end
function checkForThings(thing,xMin,xMax,yMin,yMax)
for x = xMin,xMax do
for y = yMin,yMax do
for entity in self.go.map:entitiesAt(x,y) do
if entity.name == "shrakk_torr" then
return true
end
end
end
end
return false
end
function checkSting()
local itemFound = false
local stingchamp = nil
local stingslot = nil
if checkForThings("shrakk_torr",1,3,11,13) then
return false
else
for champ = 1,4 do
for slot = 1,2 do
local c = party.party:getChampion(champ)
local item = c:getItem(slot)
if item.go ~= nil and item.go.name == "dagger_1000_stings_cursed" then
itemFound = true
stingchamp = champ
stingslot = slot
end
end
end
if itemFound == true then
local c = party.party:getChampion(stingchamp)
c:removeItemFromSlot(stingslot)
c:insertItem("dagger_1000_stings",stingslot)
local timer = findEntity("stingHiveTimer")
if timer then
timer.go:destroy()
end
hudPrint("You have beaten back the stinging Shrakk Torr hordes!! ... and as such, lifted the curse on the dagger!!")
--playSound("ressurect")
return true
end
end
end
It all works except the bit where I go and check for the cursed item, remove it and replace it with the uncursed version (which should be the easy part, right!! )
SpoilerShow
Code: Select all
for champ = 1,4 do
for slot = 1,2 do
local c = party.party:getChampion(champ)
local item = c:getItem(slot)
if item.go ~= nil and item.go.name == "dagger_1000_stings_cursed" then
itemFound = true
stingchamp = champ
stingslot = slot
end
end
end
if itemFound == true then
local c = party.party:getChampion(stingchamp)
c:removeItemFromSlot(stingslot)
c:insertItem("dagger_1000_stings",stingslot)
local timer = findEntity("stingHiveTimer")
if timer then
timer.go:destroy()
end
hudPrint("You have beaten back the stinging Shrakk Torr hordes!! ... and as such, lifted the curse on the dagger!!")
--playSound("ressurect")
return true
end
except i am going to spawn the dagger into a hand slot instead of a floating invisible alcove (havent converted that yet)
EDIT - have just commented out the custom sounds you may not have
Last edited by akroma222 on Mon Nov 10, 2014 2:24 pm, edited 3 times in total.
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Teleportation scroll request
Nice going Akroma. Keep up the great work!
Re: Teleportation scroll request
@Grimfan - thanks! To be honest I am tearing my hair out trying to convert stuff over (Quite confused, I am)
Still trying to get a grip on the new way of doing things.
@Mysterious - NOT for my mod only. Anyone can use this!
This is the last thing I need to sort before I can release the daggers pack I have been working on
Although I may wait till the swords and axes are finished too and release them all together
Still trying to get a grip on the new way of doing things.
@Mysterious - NOT for my mod only. Anyone can use this!
This is the last thing I need to sort before I can release the daggers pack I have been working on
Although I may wait till the swords and axes are finished too and release them all together
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Teleportation scroll request
Just looking over the code i can't really see anything that stands out as wrong... What exactly is happening, and what isn't working?
Also. You are aware of the bug with "insertItem" that was fixed in one of the recent betas? (if you're on .13 you still have it)
Edit: rewrote your check-loop a bit. there were a few issues.
Also. You are aware of the bug with "insertItem" that was fixed in one of the recent betas? (if you're on .13 you still have it)
Edit: rewrote your check-loop a bit. there were a few issues.
Code: Select all
for champ = 1,4 do
for slot = 1,2 do
local c = party.party:getChampion(champ)
if c then
local item = c:getItem(slot)
print(c,item)
if item and item.go.name == "dagger_1000_stings_cursed" then
c:removeItemFromSlot(slot)
c:insertItem(slot,spawn("dagger_1000_stings").item)
local timer = findEntity("stingHiveTimer")
if timer then
timer.go:destroy()
end
hudPrint("You have beaten back the stinging Shrakk Torr hordes!! ... and as such, lifted the curse on the dagger!!")
--playSound("ressurect")
return true
end
end
end
end
Links to my YouTube playlist of "tutorials" and to my forum thread.