• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Coding Luigi's Ghost Mansion

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
Hello,

im still bored, so i start to coding the Luigi's Ghost Mansion game.


Todo:
Code:
*Flash Light Battery (X)
*Flash Light Effect & Damage (X)
*Ghost Appears when light hit it (X)
*Ghost goes back invisible, when there is no player near him 2sqm around (X)
*Speed added to ghost when its hitted (X)
*Showing battery left (X)
*When players has "0" health, it should turn into dead body and should send heart effect over the body and call for help (?)
*Able to revive team mates (?)
*Thunder appears to display the ghost location for few seconds (?)
*Make lever and set randomly one ghost [When they are starting the game] (?)
*Battery spawns randomly in game area (?)
*Other players should not be able to see if someone is ghost! (?)

Feel free to help and comment if i should finish it.

Here some images:
k4J7A8.png

P6DVkm.png

R_QQNa.png


Here is the two script asfar i made:
The recharge battery onstepin:
Code:
local battery_storage = 1000

function onStepIn(cid, item, position, lastPosition)
    if (isPlayer(cid) and not isPlayerGhost(cid)) then
        doCreatureSetStorage(cid, battery_storage, 100)
        doSendMagicEffect(getThingPos(cid), CONST_ME_PURPLEENERGY)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your flashlight has been charged.")
        doRemoveItem(item.uid, 1)
    end
    return true
end

Then i made the "flash light" in talkactions!
Code:
local config = {
    battery_storage = 1000, --use empty storage
    ghost = 3 --when the ghost has been flashed, how long until it get invisible
}

local lightarea = createCombatArea{
    {0, 3, 0},
    {0, 1, 0},
}

local function ReGhost(cid)
    if (isPlayer(cid)) then
        if (not isPlayerGhost(cid)) then
            local p = getSpectators(getCreaturePosition(cid), 2, 2, false)
            local players = #p
            for _, pid in pairs(p) do
                if (players == 1) then
                    doCreatureExecuteTalkAction(cid, "/ghost", true)
                    doChangeSpeed(cid, -getCreatureSpeed(cid)+350)
                else
                    addEvent(ReGhost, 1*1000, cid)
                break
                end
            end
        end
    end
    return true
end

function onSay(cid, words, param, channel)
    local pos = getThingPos(cid)
    local player = {}
    local playerPosition = {
        {x=pos.x, y=pos.y-1, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
        {x=pos.x, y=pos.y-2, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
    }
    local playerPosition1 = {
        {x=pos.x+1, y=pos.y, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
        {x=pos.x+2, y=pos.y, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
    }
    local playerPosition2 = {
        {x=pos.x-1, y=pos.y, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
        {x=pos.x-2, y=pos.y, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
    }
    local playerPosition3 = {
        {x=pos.x, y=pos.y+1, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
        {x=pos.x, y=pos.y+2, z=pos.z, stackpos = STACKPOS_TOP_CREATURE},
    }
    if (getCreatureStorage(cid, config.battery_storage) > 0) then
        doCreatureSetStorage(cid, config.battery_storage, getCreatureStorage(cid, config.battery_storage) -1)
        doPlayerSendCancel(cid, "You have "..getCreatureStorage(cid, config.battery_storage).."% battery left.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have no battery left in your flashlight.")
        doSendMagicEffect(getThingPos(cid), 2)
    return true
    end
    if (getCreatureLookDirection(cid) == NORTH) then
        doAreaCombatHealth(cid, COMBAT_ENERGYDAMAGE, {x=pos.x, y=pos.y-2, z=pos.z}, lightarea, -1, -1, CONST_ME_YELLOWENERGY)
        for i = 1, 2 do
            player[i] = getThingfromPos(playerPosition[i])
            if (player[i].itemid > 0) then
                if (isPlayer(player[i].uid) == TRUE and isPlayerGhost(player[i].uid)) then
                    doCreatureExecuteTalkAction(player[i].uid, "/ghost", true)
                    addEvent(ReGhost, config.ghost*1000, player[i].uid)
                    doChangeSpeed(player[i].uid, 500)
                end
            end
        end
    elseif (getCreatureLookDirection(cid) == EAST) then
        doAreaCombatHealth(cid, COMBAT_ENERGYDAMAGE, {x=pos.x+2, y=pos.y, z=pos.z}, lightarea, -1, -2, CONST_ME_YELLOWENERGY)
        for i = 1, 2 do
            player[i] = getThingfromPos(playerPosition1[i])
            if (player[i].itemid > 0) then
                if (isPlayer(player[i].uid) == TRUE and isPlayerGhost(player[i].uid)) then
                    doCreatureExecuteTalkAction(player[i].uid, "/ghost", true)
                    addEvent(ReGhost, config.ghost*1000, player[i].uid)
                end
            end
        end
    elseif (getCreatureLookDirection(cid) == WEST) then
        doAreaCombatHealth(cid, COMBAT_ENERGYDAMAGE, {x=pos.x-2, y=pos.y, z=pos.z}, lightarea, -1, -2, CONST_ME_YELLOWENERGY)
        for i = 1, 2 do
            player[i] = getThingfromPos(playerPosition2[i])
            if (player[i].itemid > 0) then
                if (isPlayer(player[i].uid) == TRUE and isPlayerGhost(player[i].uid)) then
                    doCreatureExecuteTalkAction(player[i].uid, "/ghost", true)
                    addEvent(ReGhost, config.ghost*1000, player[i].uid)
                end
            end
        end
    elseif (getCreatureLookDirection(cid) == SOUTH) then
        doAreaCombatHealth(cid, COMBAT_ENERGYDAMAGE, {x=pos.x, y=pos.y+2, z=pos.z}, lightarea, -1, -2, CONST_ME_YELLOWENERGY)
        for i = 1, 2 do
            player[i] = getThingfromPos(playerPosition3[i])
            if (player[i].itemid > 0) then
                if (isPlayer(player[i].uid) == TRUE and isPlayerGhost(player[i].uid)) then
                    doCreatureExecuteTalkAction(player[i].uid, "/ghost", true)
                    addEvent(ReGhost, config.ghost*1000, player[i].uid)
                end
            end
        end
    end
    return true
end
 
Last edited:
Nice, I'll just move this to Discussion since this doesn't really fit in Support. :p
 
Back
Top