Combreal icon

Melee.lua

Combreal | PRO | 02/04/14 12:09:50 PM UTC | 0 ⭐ | 1197 👁️ | Never ⏰ | []
Lua |

6.46 KB

|

None

|

0 👍

/

0 👎

-- Inspired from TelyX, A§H»Wizard, H»Kennan & AelitePrime 's work --
                        -- For the skull weapon --
 
 
    skull = {}
    frag_count = 0
    plasma_count = 0
    max_health = 0.1
 
 
function GetRequiredVersion() return 200 end
 
function OnScriptLoad(processid, game, persistent) end
 
function OnNewGame(map)
    LoadTags()
end
 
function OnPlayerSpawn(player)
    writefloat(getobject(getplayerobjectid(player)) + 0xE0, max_health)
end
 
function OnPlayerSpawnEnd(player, m_objectId)
    local hash = gethash(player)
    skull[hash] = skull[hash] or {}
    local m_object = getobject(m_objectId)
    if m_object then
        writebyte(m_object + 0x31E, frag_count)
        writebyte(m_object + 0x31F, plasma_count)
    end
    for i = 0,3 do
        local m_object = getobject(m_objectId)
        if m_object then
            local weapID = readdword(m_object + 0x2F8 + i*4)
            local weap = getobject(weapID)
            if weap then
                destroyobject(weapID)
            end
        end
    end
    skull[hash].objId = createobject(oddball_tag_id, 0, 1, false, 0, 0, 0)
    assignweapon(player, skull[hash].objId)
end
 
function OnObjectCreationAttempt(mapId, parentId, player)
    return checkObject(mapId)
end
 
function OnObjectInteraction(player, objId, mapId)
    if mapId == fragnade_tag_id or plasmanade_tag_id or oddball_tag_id then
            return false
    end
    return true
end
 
 
function OnDamageLookup(receiving, causing, mapId, tagdata)
    if mapId == global_fallingId then
        return false
    elseif mapId == oddball_melee_tag_id then
        writefloat(tagdata, 0x1D0, 500)
        writefloat(tagdata, 0x1D4, 500)
        writefloat(tagdata, 0x1D8, 500)
    end
    if causing then
        local c_object = getobject(causing)
        if c_object then
            local causer = objectaddrtoplayer(c_object)
            if causer then
                if isinvehicle(causer) then
                    local m_vehicleId = getplayervehicleid(causer)
                    if m_vehicleId then
                        local m_vehicle = getobject(m_vehicleId)
                        local driver = getdriverplayer(m_vehicle)
                        if driver == causer then
                            return false
                        end
                    end
                end
            end
        end
    end
end
 
function OnPlayerKill(killer, victim, mode)
    if mode == 2 then
        local victim_kills = readword (getplayer(victim), 0x9C)
        victim_kills = victim_kills + 1
        --guardianed = getplayer(victim)
        writeword(getplayer(victim) + 0x9C, victim_kills)
        privatesay(getplayer(victim), "Damned guardians, here earn your frag")
    end
    local m_player = getplayer(victim)
    if m_player == nil then
        return
    end
    local m_object = getobject(readdword(m_player +  0x34))
    if m_object then
        for i = 0,3 do
            local weapID = readdword(m_object + 0x2F8 + i*4)
            if weapID then
                local weap = getobject(weapID)
                if weap then
                    destroyobject(weapID)
                end
            end
        end
    end
end
 
function OnClientUpdate(player)
    local hash = gethash(player)
    local m_player = getplayer(player)
    if m_player == nil then
        return
    end
    local m_objectId = getplayerobjectid(player)
    if m_objectId == nil then
        return
    end
    local m_object = getobject(m_objectId)
    if m_object then
        local shooting = readbit(m_object + 0x209, 4)
        local nading2 = readbit(m_object + 0x209, 2)
        local nading = readbit(m_object + 0x209, 3)
        if shooting == true or nading == true then
            weapID = skull[hash].objId
            if m_player then
                if weapID then
                    if getobject(weapID) then
                        assignweapon(player, weapID)
                    end
                end
            end
        end
    end
end
 
function checkObject(mapId)
    if mapId == "nil" then
        return false
    end
    return oddball_tag_id
end
 
function LoadTags()
    -- Equipment
    camouflage_tag_id = gettagid("eqip", "powerups\\active camouflage")
    healthpack_tag_id = gettagid("eqip", "powerups\\health pack")
    overshield_tag_id = gettagid("eqip", "powerups\\over shield")
    doublespeed_tag_id = gettagid("eqip", "powerups\\double speed")
    fullspec_tag_id = gettagid("eqip", "powerups\\full-spectrum vision")
    fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade")
    plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade")
    rifleammo_tag_id = gettagid("eqip", "powerups\\assault rifle ammo\\assault rifle ammo")
    needlerammo_tag_id = gettagid("eqip", "powerups\\needler ammo\\needler ammo")
    pistolammo_tag_id = gettagid("eqip", "powerups\\pistol ammo\\pistol ammo")
    rocketammo_tag_id = gettagid("eqip", "powerups\\rocket launcher ammo\\rocket launcher ammo")
    shotgunammo_tag_id = gettagid("eqip", "powerups\\shotgun ammo\\shotgun ammo")
    sniperammo_tag_id = gettagid("eqip", "powerups\\sniper rifle ammo\\sniper rifle ammo")
    flameammo_tag_id = gettagid("eqip", "powerups\\flamethrower ammo\\flamethrower ammo")
    -- Weapons
    assaultrifle_tag_id = gettagid("weap", "weapons\\assault rifle\\assault rifle")
    oddball_tag_id = gettagid("weap", "weapons\\ball\\ball")
    flag_tag_id = gettagid("weap", "weapons\\flag\\flag")
    flamethrower_tag_id = gettagid("weap", "weapons\\flamethrower\\flamethrower")
    gravityrifle_tag_id = gettagid("weap", "weapons\\gravity rifle\\gravity rifle")
    needler_tag_id = gettagid("weap", "weapons\\needler\\mp_needler")
    pistol_tag_id = gettagid("weap", "weapons\\pistol\\pistol")
    plasmapistol_tag_id = gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
    plasmarifle_tag_id = gettagid("weap", "weapons\\plasma rifle\\plasma rifle")
    plasmacannon_tag_id = gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon")
    rocketlauncher_tag_id = gettagid("weap", "weapons\\rocket launcher\\rocket launcher")
    shotgun_tag_id = gettagid("weap", "weapons\\shotgun\\shotgun")
    sniper_tag_id = gettagid("weap", "weapons\\sniper rifle\\sniper rifle")
    -- Globals
    global_distanceId = gettagid("jpt!", "globals\\distance")
    global_fallingId = gettagid("jpt!", "globals\\falling")
    -- Others
    assaultrifle_melee_tag_id = gettagid("jpt!", "weapons\\assault rifle\\melee")
    flag_melee_tag_id = gettagid("jpt!", "weapons\\flag\\melee")
    flamethrower_melee_tag_id = gettagid("jpt!", "weapons\\flamethrower\\melee")
    needler_melee_tag_id = gettagid("jpt!", "weapons\\ball\\melee")
    pistol_melee_tag_id = gettagid("jpt!", "weapons\\pistol\\melee")
    plasmapistol_melee_tag_id = gettagid("jpt!", "weapons\\plasma pistol\\melee")
    plasmarifle_melee_tag_id = gettagid("jpt!", "weapons\\plasma rifle\\melee")
    plasmacannon_melee_tag_id = gettagid("jpt!", "weapons\\effects\\plasma_cannon_melee")
    rocketlauncher_melee_tag_id = gettagid("jpt!", "weapons\\rocket launcher\\melee")
    shotgun_melee_tag_id = gettagid("jpt!", "weapons\\shotgun\\melee")
    sniper_melee_tag_id = gettagid("jpt!", "weapons\\sniper rifle\\melee")
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎