Kavawuvi

Team-based bipeds

34 posts in this topic

So I see SAPP has an EVENT_PRESPAWN callback.

I'm working on addressing the problem with collision models. Apparently it's not very usable in multiplayer, otherwise. I've used EVENT_PRESPAWN countless times already. Edited by 002

Share this post


Link to post
Share on other sites

Tiddy-bits:

Some changes:

  • Added SAPP support. It uses the new 1.7.0.0 scripting API, which means that there are no collision model or hitbox issues.
  • Dropped Phasor support. The older Phasor script is available in the spoiler below, but I will not bother solving any issues with it. The event used isn't compatible with the Phasor API, and a workaround would be more complicated than it is worth, so one would have to make a new script.

002 makes too many of these proof of concept videos.

Phasor Script: https://gist.github.com/Halogen002/c8afd0252858077d7f68

Substitute elitetag_path with whatever variable you want.

To people who will probably say "zomg but sapp has scripting": SAPP does have scripting and it has a player spawning event, but it's timed after clients are notified that they have spawned, which means that only players who have joined after the respawn will see changes. I've suggested an event to occur before players are notified, and sehé said "Ok I'll add it.", so it should (assuming it was implemented the right way) be possible in the next version of SAPP, which then I will provide a script for SAPP.

Edited by 002

Share this post


Link to post
Share on other sites

ok so I have this problem running this script. Sometimes the teambipeds work and yet on other games it reverts back to the normal bipeds assigned to the map

 

1) I am running CTF mode

2) I have blue team set as a "Pirate Biped"

3) screencap of my bipeds in map (below)

 

Q4nFce.png

-- Team-based Bipeds 1.1 by 002
-- Configuration
TEAM_RED = "deathstar\\poqisland_modv1\\biped\\tag_2085"
TEAM_BLUE = "deathstar\\pirate_ship\\biped\\tag_112"
-- Free-For-All Biped Selection:
--  true = Randomly choose biped in free-for-all
--  false = Alternate between red and blue
FFA_RANDOM = true
-- End of Configuration
api_version = "1.7.0.0"
DEFAULT_BIPED = nil
RED_BIPED = nil
BLUE_BIPED = nil
function OnScriptLoad()
    register_callback(cb['EVENT_OBJECT_SPAWN'],"OnObjectSpawn")
    register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
end
function OnScriptUnload() 
    DEFAULT_BIPED = nil
    RED_BIPED = nil
    BLUE_BIPED = nil
end
function FindBipedTag(TagName)
    local tag_array = read_dword(0x40440000)
    for i=0,read_word(0x4044000C)-1 do
        local tag = tag_array + i * 0x20
        if(read_dword(tag) == 1651077220 and read_string(read_dword(tag + 0x10)) == TagName) then
            return read_dword(tag + 0xC)
        end
    end
end
function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
    if(player_present(PlayerIndex) == false) then return true end
    if(DEFAULT_BIPED == nil) then
        local tag_array = read_dword(0x40440000)
        for i=0,read_word(0x4044000C)-1 do
            local tag = tag_array + i * 0x20
            if(read_dword(tag) == 1835103335 and read_string(read_dword(tag + 0x10)) == "globals\\globals") then
                local tag_data = read_dword(tag + 0x14)
                local mp_info = read_dword(tag_data + 0x164 + 4)
                for j=0,read_dword(tag_data + 0x164)-1 do
                    DEFAULT_BIPED = read_dword(mp_info + j * 160 + 0x10 + 0xC)
                end
            end
        end
    end
    if(MapID == DEFAULT_BIPED) then
        if(RED_BIPED == nil) then RED_BIPED = FindBipedTag(TEAM_RED) end
        if(BLUE_BIPED == nil) then BLUE_BIPED = FindBipedTag(TEAM_BLUE) end

        BIPED_TO_USE = RED_BIPED
        if(get_var(PlayerIndex,"$ffa") == "1") then
            if(FFA_RANDOM == true) then
                if(rand(0,2) == 1) then BIPED_TO_USE = BLUE_BIPED end
            else
                if(PlayerIndex % 2 == 1) then BIPED_TO_USE = BLUE_BIPED end
            end
        elseif(get_var(PlayerIndex,"$team") == "blue") then
            BIPED_TO_USE = BLUE_BIPED
        end
        return true,BIPED_TO_USE
    end
    return true
end
function OnGameEnd()
    DEFAULT_BIPED = nil
    RED_BIPED = nil
    BLUE_BIPED = nil
end

 

Weyland likes this

Share this post


Link to post
Share on other sites

Hi Down Under,

 

Did you ever get this script - or one like it - working?

 

I'm trying to run it on a Bigass CTF and having the same problem you did.

 

Thanks.

Share this post


Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.