Hello,
well i finally going to release the code for Colossus. Ofcourse the code can be improved, but i would like to hear feedback and also others input are welcome.
Features:
Create new lua file in data folder and name it: colossusLib.lua and paste this code:
Now in data/spells/spells.xml paste this line:
Now go into data/spells/scripts and create new lua and name it: ColossusMoves and paste the code below:
http://pastebin.com/KFAren5A
Now just go to monsters/monsters.xml and paste these lines:
Now go into monster and create new folder and name it: Colossus and create each lua and paste the codes below:
http://pastebin.com/5duDxasM
http://pastebin.com/19kJEx9A
http://pastebin.com/az3pvCfx
Download the attachment to get the map
Enjoy!
well i finally going to release the code for Colossus. Ofcourse the code can be improved, but i would like to hear feedback and also others input are welcome.
Features:
- 3 different moves
- Pushing creatures away
- If one hand dies, the other hand continues!
- Easy to configure!
- Highly optimized!
- What happens after both hands are dead?
- Spells should cause area effect and damage
- Others...
Create new lua file in data folder and name it: colossusLib.lua and paste this code:
Code:
colossusAwakenGlobalStorage = 100
moveExecuted = false
function doPushCreatures(cid, position, sqm)
local push = Tile(position):getCreatures()
if not push then -- There is no creatures to push, let's stop the code
return false
end
local creature
for i = 1, #push do
creature = push[i]
if creature:getId() ~= cid then -- Let's make sure not to push the Colossus
creature:teleportTo(Position(position.x, position.y + sqm, position.z), true)
end
end
end
function resetHandParts(itemId, currentPos, oldPos)
local tile = Tile(currentPos):getItemById(itemId)
if tile then
tile:moveTo(oldPos)
end
end
function removalFistParts(position, itemId)
local tile = Tile(position):getItemById(itemId)
if tile then
tile:remove(1)
end
end
function resetHand(cid, oldPos)
local monster = Monster(cid)
if not monster then --Check if the hand exsist, else stop the code from executing
return false
end
monster:teleportTo(oldPos)
moveExecuted = false
end
function doCastMove(cid, chance, hand)
if chance >= 1 and chance <= 19 then
colossusPunch(cid, hand)
elseif chance >= 20 and chance <= 39 then
colossusSmash(cid, hand)
elseif chance >= 40 and chance <= 60 then
colossusClap(cid, hand)
end
moveExecuted = true
end
function colossusSmash(cid, handId)
local monster = Monster(cid)
if not monster then -- Let's check if the hand exsist, else stop the code from executing.
return false
end
local monsterPos = monster:getPosition()
local handPositions = {
[12995] = {current = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z - 1)},
[12996] = {current = Position(monsterPos.x + 1, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x + 1, monsterPos.y - 1, monsterPos.z - 1)},
[12997] = {current = Position(monsterPos.x - 1, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x - 1, monsterPos.y - 1, monsterPos.z - 1)},
[12998] = {current = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z - 1)}
}
local tile
for i = 0, 1 do
tile = Tile(handPositions[handId + i].current):getItemById(handId + i)
if tile then
handPositions[handId + i].current:sendMagicEffect(CONST_ME_POFF)
tile:moveTo(handPositions[handId + i].new)
addEvent(resetHandParts, 1000, handId + i, handPositions[handId + i].new, handPositions[handId + i].current)
addEvent(doPushCreatures, 1000, cid, handPositions[handId + i].current, 1)
end
end
monsterPos:sendMagicEffect(CONST_ME_POFF)
monster:teleportTo(Position(monsterPos.x, monsterPos.y, monsterPos.z - 1))
addEvent(resetHand, 1000, cid, monsterPos)
addEvent(doPushCreatures, 1000, cid, monsterPos, 1)
end
function colossusClap(cid, handId)
local monster = Monster(cid)
if not monster then -- Let's check if the hand exsist, else stop the code from executing.
return false
end
local monsterPos = monster:getPosition()
local handPositions = {
[12995] = {current = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x + 1, monsterPos.y - 1, monsterPos.z)},
[12996] = {current = Position(monsterPos.x + 1, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x + 2, monsterPos.y - 1, monsterPos.z)},
[12997] = {current = Position(monsterPos.x - 1, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x - 2, monsterPos.y - 1, monsterPos.z)},
[12998] = {current = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x - 1, monsterPos.y - 1, monsterPos.z)}
}
local tile
for i = 0, 1 do
tile = Tile(handPositions[handId + i].current):getItemById(handId + i)
if tile then
doPushCreatures(cid, handPositions[handId + i].new, 1)
tile:moveTo(handPositions[handId + i].new)
addEvent(resetHandParts, 1000, handId + i, handPositions[handId + i].new, handPositions[handId + i].current)
addEvent(doPushCreatures, 1000, cid, handPositions[handId + i].current, 1)
end
end
local newPos
if handId == 12995 then
newPos = Position(monsterPos.x + 1, monsterPos.y, monsterPos.z)
else
newPos = Position(monsterPos.x - 1, monsterPos.y, monsterPos.z)
end
doPushCreatures(cid, newPos, 1)
monster:teleportTo(newPos)
addEvent(resetHand, 1000, cid, monsterPos)
addEvent(doPushCreatures, 1000, cid, monsterPos, 1)
end
function colossusPunch(cid, handId)
local monster = Monster(cid)
if not monster then -- Let's check if the hand exsist, else stop the code from executing.
return false
end
local monsterPos = monster:getPosition()
local handPositions = {
[12995] = {current = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x, monsterPos.y + 1, monsterPos.z)},
[12996] = {current = Position(monsterPos.x + 1, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x + 1, monsterPos.y + 1, monsterPos.z)},
[12997] = {current = Position(monsterPos.x - 1, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x - 1, monsterPos.y + 1, monsterPos.z)},
[12998] = {current = Position(monsterPos.x, monsterPos.y - 1, monsterPos.z), new = Position(monsterPos.x, monsterPos.y + 1, monsterPos.z)}
}
local tile
for i = 0, 1 do
tile = Tile(handPositions[handId + i].current):getItemById(handId + i)
if tile then
tile:moveTo(handPositions[handId + i].new)
addEvent(resetHandParts, 1000, handId + i, handPositions[handId + i].new, handPositions[handId + i].current)
end
end
if handId == 12995 then
for i = 0, 1 do
Game.createItem(12994, 1, Position(monsterPos.x, monsterPos.y - i, monsterPos.z))
Game.createItem(12994, 1, Position(monsterPos.x + 1, monsterPos.y - i, monsterPos.z))
addEvent(removalFistParts, 1000, Position(monsterPos.x, monsterPos.y - i, monsterPos.z), 12994)
addEvent(removalFistParts, 1000, Position(monsterPos.x + 1, monsterPos.y - i, monsterPos.z), 12994)
end
for i = 0, 2 do
doPushCreatures(cid, Position(monsterPos.x, monsterPos.y + i, monsterPos.z), 1)
doPushCreatures(cid, Position(monsterPos.x + 1, monsterPos.y + i, monsterPos.z), 1)
end
else
for i = 0, 1 do
Game.createItem(12994, 1, Position(monsterPos.x - 1, monsterPos.y - i, monsterPos.z))
Game.createItem(12994, 1, Position(monsterPos.x, monsterPos.y - i, monsterPos.z))
addEvent(removalFistParts, 1000, Position(monsterPos.x - 1, monsterPos.y - i, monsterPos.z), 12994)
addEvent(removalFistParts, 1000, Position(monsterPos.x, monsterPos.y - i, monsterPos.z), 12994)
end
for i = 0, 2 do
doPushCreatures(cid, Position(monsterPos.x, monsterPos.y + i, monsterPos.z), 1)
doPushCreatures(cid, Position(monsterPos.x - 1, monsterPos.y + i, monsterPos.z), 1)
end
end
monster:teleportTo(Position(monsterPos.x, monsterPos.y + 2, monsterPos.z))
addEvent(resetHand, 1000, cid, monsterPos)
end
Now in data/spells/spells.xml paste this line:
Code:
<instant name="ColossusMoves" words="###50" aggressive="1" needlearn="1" needtarget="1" script="ColossusMoves.lua"/>
Now go into data/spells/scripts and create new lua and name it: ColossusMoves and paste the code below:
http://pastebin.com/KFAren5A
Now just go to monsters/monsters.xml and paste these lines:
Code:
<!-- Colossus -->
<monster name="Colossus LH" file="Colossus/colossusLeftHand.xml"/>
<monster name="Colossus RH" file="Colossus/colossusRightHand.xml"/>
<monster name="Colossus F" file="Colossus/colossusFace.xml"/>
<monster name="Colossus M" file="Colossus/colossusMaster.xml"/>
Now go into monster and create new folder and name it: Colossus and create each lua and paste the codes below:
http://pastebin.com/5duDxasM
http://pastebin.com/19kJEx9A
http://pastebin.com/az3pvCfx
Download the attachment to get the map
Enjoy!
Attachments
-
Colossus.zip3.2 KB · Views: 61 · VirusTotal