Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2015
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. dofile('data/libs/TWD/towerDefenseLib.lua')
  2.  
  3. function onStepIn(creature, item, position, fromPosition)
  4.         if item.uid == 3333 then
  5.                 if not creature:isMonster() then
  6.                         return false
  7.                 end
  8.  
  9.                 local maxHealthDmg = creature:getMaxHealth()
  10.                 doTargetCombatHealth(0, creature, COMBAT_PHYSICALDAMAGE, -maxHealthDmg, -maxHealthDmg, CONST_ME_FIREAREA)
  11.  
  12.                 local player = getPlayerInEvent(40, 40)
  13.                 if not player then -- Make sure that the players exsist in the arena, to prevent errors
  14.                         return true
  15.                 end
  16.  
  17.         if player:getCondition(CONDITION_MANASHIELD, CONDITIONID_COMBAT) then
  18.             player:removeCondition(CONDITION_MANASHIELD, CONDITIONID_COMBAT)
  19.         end
  20.  
  21.                 local calcHealthDmg = (player:getMaxHealth() * twdConfig.loseHealth) / 100
  22.                 doTargetCombatHealth(0, player:getId(), COMBAT_PHYSICALDAMAGE, -calcHealthDmg, -calcHealthDmg, CONST_ME_DRAWBLOOD)
  23.         else
  24.                 if not creature:isPlayer() then
  25.                         return false
  26.                 end
  27.  
  28.                 -- Let's make sure none is playing, before entrance
  29.                 if getWaveLevel() > 0 then
  30.                         creature:teleportTo(fromPosition, true)
  31.                         fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
  32.                         creature:sendTextMessage(MESSAGE_INFO_DESCR, "There is someone already in the event.")
  33.                         return true
  34.                 end
  35.  
  36.                 -- Prepare Player
  37.                 creature:teleportTo(eventRoomPosition)
  38.                 creature:addHealth(creature:getMaxHealth())
  39.                 creature:setStorageValue(playingGameStorage, 1)
  40.                 creature:addCoins(twdConfig.startingCoins)
  41.                 creature:addItem(2557, 1)
  42.  
  43.                 -- Setup Game
  44.                 setWaveLevel(1)
  45.                 startNextWave(1, twdConfig.eventStartTime)
  46.                 Game.setStorageValue(totalMonsterKillCountGlobalStorage, 0)
  47.  
  48.                 -- Send Effects
  49.                 eventRoomPosition:sendMagicEffect(CONST_ME_TELEPORT)
  50.                 local pointingSummonPosition = summonMonsterPosition
  51.                 Position(pointingSummonPosition.x + 1, pointingSummonPosition.y, pointingSummonPosition.z):sendMagicEffect(CONST_ME_TUTORIALARROW)
  52.  
  53.                 -- Send Messages
  54.                 creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have total ".. creature:getCoins() .." coins.")
  55.                 creature:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome to the Tower Defense Event. The first wave will start in ".. twdConfig.eventStartTime .." seconds. Please build your first turret.")
  56.                 creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "The blue arrow, points where the monsters are comming from. Use the hammer, to build your first turret.")
  57.  
  58.                 -- Register Events
  59.                 creature:registerEvent("TWDOnLose")
  60.                 creature:registerEvent("TWDHealthChange")
  61.                 creature:registerEvent("TWDBuildWindow")
  62.                 creature:registerEvent("TWDOtherWindow")
  63.         end
  64.         return true
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement