Page 3 of 3

Re: Teleportation scroll request

Posted: Mon Nov 10, 2014 3:08 pm
by akroma222
Ah huh!!
Thanks Prozail!! Your fix does exactly what I was after... kill the cursed item and insert the uncursed version! :D
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)
            --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()
        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 t = findEntity("stingTimer")
       
    
    if t then
        t:destroy()
    end
    if st then
        st:destroy()
    end
	if slot == 1 or slot == 2 then
		local sb = findEntity("stings1000blocker1")
        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
       
    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)
          		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
	end
end

		
^Above code also fixes the issue of the unequip hook going off and not being able to find 'stings1000blocker1' if the item is removed due to lack of skill in light weapons
strangely though.. when the item is removed and respawned
SpoilerShow

Code: Select all

 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....")
it is respawned facing behind the party instead of facing the same direction as the party... hmm

I have found, also, using the 'spawn teleport' on the party space allows you to equip and move forward at the same time > which then creates a teleporter in the space you just moved from (and therefore not teleporting the party to the designated area) this kind of disrupts the whole show....
Is there a way we can use setWorldPosition properly? without the party having to 'fall from a pit' when they teleport back?
I tried using setWorldPosition to do the teleporting but kept getting moved to a high elevation... and then falling :cry:

EDIT - Yes indeed, I have the latest beta version (2.1.17) ;)

Re: Teleportation scroll request

Posted: Mon Nov 10, 2014 3:33 pm
by Prozail
Have you tried it with the setPosition? Can be applied to the party. (is uses normal coordinates instead of world coordinates)

---GameObject:setPosition(x, y, facing, elevation, level)


Edit: (I have too little to do at work today :))
There were a few other things i found odd, maybe i fixed something, but this is untested, so compare it to your own code first.
I got rid of some redundant stuff though.

Code: Select all

function dagger1000StingsCursedEquip(self,champion,slot)
    local skill = champion:getSkillLevel("light_weapons")
    local name = champion:getName()
    local hb = findEntity("hiveBlocker")

   if slot == 1 or slot == 2 then
        if skill >= 5 then
			local p = findEntity("teleportReturn")
			if not p then 			
            	spawn("blocker", party.level, party.x, party.y, party.facing, party.elevation, "teleportReturn")
			end
            party:setPosition(hb.x,hb.y,hb.facing,hb.elevation,hb.level)
            --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.facing, party.elevation,"stingTimer")
            stingTimer.timer:setTimerInterval(1)
            stingTimer.timer:addConnector("onActivate", "cursedItemScript", "checkSting")
            stingTimer.timer:start()
        else
            champion:removeItemFromSlot(slot)
            spawn("dagger_1000_stings_cursed",party.level,party.x,party.y,party.facing, party.elevation)
            playSound("item_drop")
            hudPrint("You are not skillful enough to weild the exotic dagger....")
        end
    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()
   
	if slot == 1 or slot == 2 then
	local p = findEntity("teleportReturn")
		if p then
			party:setPosition(p.x,p.y,p.facing,p.elevation,p.level)
			--party:playScreenEffect("teleport_screen")
			hudPrint("The 1000 Stings Curse returns you to your world....")
			--playSound("guardianstave_summon")
			p:destroy()
			local t = findEntity("stingTimer")
			if t then t:destroy() end
		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 == thing then
                   return true
                end
            end
        end
    end
    return false
end

function checkSting()
	local itemFound = false
	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)
                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
   end
end

      

Re: Teleportation scroll request

Posted: Mon Nov 10, 2014 5:34 pm
by akroma222
Prozail - Your code for the weapon works perfectly!! THANK YOU :D
I had tried just the normal setPosition but I think I was trying to run -
party.party:setPosition(p.x,p.y,p.facing,p.elevation,p.level) instead of just
party:setPosition(p.x,p.y,p.facing,p.elevation,p.level) .... (still getting a grip on the new system) :oops:

You are right about removing redundant stuff - that was probably part of the problem

Thankyou again, this was one of the more complicated weapons I had to convert
I have learned a lot today :D

Re: Teleportation scroll request

Posted: Mon Jan 12, 2015 12:02 am
by bongobeat
awesome job, thanks for this! :)