AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   VSH / Freak Fortress (https://forums.alliedmods.net/forumdisplay.php?f=154)
-   -   FF2 [Subplugin] Summon a boss (https://forums.alliedmods.net/showthread.php?t=330421)

LeAlex14 02-03-2021 04:03

[Subplugin] Summon a boss
 
8 Attachment(s)
I really like minions or clones... But sometimes, we need another boss, so I create this plugin (I just pick a function of BatFox's ff2 code, really, I do nothing). I also really like the idea of red backup, but sometimes, the backup wasn't really strong vs the boss.
So this plugin add 2 new ability, summon a boss (works like clones) or summon a red boss backup.
Code:

"ability5"
        {
                "name"                "Summon_Another_Boss0"

                "arg1"                "0" // Boss Index in character.cfg -1 (yes, don't works if you don't set that) I don't mention it but you can put a lot of index and the plugin choose a random ("1 ; 2 ; 3")
                "arg2"                "2"        // Number of boss
               
                "arg3"                "2" // HP Mode (works with arg4) : 1 = Defined Hp; 2 = % Summoner Max Hp; 3 = % Summoned boss Hp in normal mode
                "arg4"                "65" // HP receive (% if arg3 = 2 or 3)
               
                "arg5"                "4" // Lives Mode (works with arg6) : 1 = If summoned have multiple life, add new life number and maxnumber; 2 = If summoned have multiple life, add % of summoned life number and maxnumber; 3 = % Summoner life; 4 = Add life and max life
                "arg6"                "1" // Lives receive (% if arg3 = 2 or 3)
               
                "arg7"                "2" // Damage rage Mode (works with arg8) : 1 = Defined Rage damage; 2 = % Summoner Rage Damage; 3 = % Summoned rage damage in normal mode
                "arg8"                "75" // Damage rage needed (% if arg3 = 2 or 3)
               
                "arg9"                "1" // 0 = at the spawn, 1 = on the player
                "arg10"            "0" // Trigger by ams 0 = no, 1 = yes

                "plugin_name"        "ff2_summonaboss"
        }
       
        "ability6"
        {
                "name"                "Boss_Merc_Backup"

                "arg1"                "3"        // Merc need to left
                "arg2"                "1"        // Boss Index in character.cfg -1 (yes, don't works if you don't set that) you can also put some index and the plugin choose randomly 1
                "arg3"                "1" // Number of boss
               
                "arg4"                "1" // HP Mode (works with arg5) : 1 = Defined Hp; 2 = % Boss with this ability Max Hp; 3 = % Summoned boss Hp in normal mode
                "arg5"                "5000" // HP receive (% if arg3 = 2 or 3)
               
                "arg6"                "4" // Lives Mode (works with arg7) : 1 = If summoned have multiple life, add new life number and maxnumber; 2 = If summoned have multiple life, add % of summoned life number and maxnumber; 3 = % Boss with this ability life; 4 = Add life and max life
                "arg7"                "3" // Lives receive (% if arg3 = 2 or 3)
               
                "arg8"                "1" // Damage rage Mode (works with arg9) : 1 = Defined Rage damage; 2 = % Boss with this ability Rage Damage; 3 = % Summoned rage damage in normal mode
                "arg9"                "2500" // Damage rage needed (% if arg3 = 2 or 3)
               
                "arg10"                "1"        // Backup mode 0 = infinite backup if another summoned boss have backup, 1 = 1 backup

                "plugin_name"        "ff2_summonaboss"
        }



I also join 2 plugin compatible with this boss spawn, Dynamics Defaults and Improved Saxton.
You can download the seeldier.cfg, and saxtinv2.cfg (download saxton hale v2 for ressource at this link) and place him into character.cfg like that:
Code:

"Freak Fortress 2"
{
        "1"                "seeldier"
        "2"                "saxtonv2"
}



:!: WARNING :!: You need compatible plugin because a lot of plugin works with on round start, so, you need to hook when a player spawn.

:!: WARNING :!: Ams are not compatible with summoned boss and i'll upload a version of summonaboss compatible with ams and with menu manager later (in 1/2 hours)


Example:
Code:

public OnPluginStart2()
{
        HookEvent("arena_round_start", event_round_start);
        HookEvent("teamplay_round_win", OnRoundEnd, EventHookMode_PostNoCopy);
}

public void OnRoundEnd(Event event, const char[] name, bool dontBroadcast)
{
        UnhookEvent("player_spawn",SpawnEvent);
}

public Action SpawnEvent(Handle event,const char[] name,bool dontBroadcast)
{
    int client_id = GetEventInt(event, "userid");
    int client = GetClientOfUserId(client_id);

    CreateTimer(0.5, IsASummondedBoss, client, TIMER_FLAG_NO_MAPCHANGE);
}

public Action TimerHookSpawn(Handle timer)
{
    HookEvent("player_spawn",SpawnEvent,EventHookMode_PostNoCopy);
}

public Action IsASummondedBoss(Handle timer, int client)
{
    // Stuff in on round start for one player, example:
int boss = FF2_GetBossIndex(client);
        if(boss>=0 && (FF2_HasAbility(boss, this_plugin_name, "example")))
        {
                VarExample[client]=true;
        }
}


public Action:event_round_start(Handle event, const char[] name, bool dontBroadcast)
{
        for(new client=1;client<=MaxClients;client++)
        {
                new boss=FF2_GetBossIndex(client);
                if(boss>=0 && (FF2_HasAbility(boss, this_plugin_name, "example")))
                {
                        VarExample[client]=true;
                }
        }
}

Credit:
Batfox for his amazing work with his plugin
Sarysa for all plugin

Change:
Add menu ability and ams

Project:
If you like this plugin, i'll try to make include files for easier compatibility

J0BL3SS 02-03-2021 05:40

Re: [Subplugin] Summon a boss
 
Great subplugin. But needs a lot improvements

LeAlex14 02-03-2021 08:27

Re: [Subplugin] Summon a boss
 
Update:
Add compatibility with ams and menu (for multiple boss)
Add a reworked version of Bat's menu wich works with summoned boss

J0BL3SS 02-03-2021 09:54

Re: [Subplugin] Summon a boss
 
Quote:

Originally Posted by LeAlex14 (Post 2735581)
Update:
Add compatibility with ams and menu (for multiple boss)
Add a reworked version of Bat's menu wich works with summoned boss

i suggest you to zip all of these. Also perfect!

Batfoxkid 02-03-2021 11:39

Re: [Subplugin] Summon a boss
 
There's no need to edit Menu Abilities to add compatibility as it already offers natives to use

Code:

/**
 * Sets up boss casting (make sure the boss has the menu manager ability)
 *
 * @param boss                Boss index
 * @param call                Call the MA_OnMakeBoss forwards
 *
 * @noreturn
 */
native void MA_MakeBoss(int boss, bool call=true);


LeAlex14 02-03-2021 12:00

Re: [Subplugin] Summon a boss
 
Quote:

Originally Posted by Batfoxkid (Post 2735595)
There's no need to edit Menu Abilities to add compatibility as it already offers natives to use

Code:

/**
 * Sets up boss casting (make sure the boss has the menu manager ability)
 *
 * @param boss                Boss index
 * @param call                Call the MA_OnMakeBoss forwards
 *
 * @noreturn
 */
native void MA_MakeBoss(int boss, bool call=true);


Oh thanks, i didn't see that ! Go to remove and sorry.

LeAlex14 02-03-2021 12:24

Re: [Subplugin] Summon a boss
 
Quote:

Originally Posted by Batfoxkid (Post 2735595)
There's no need to edit Menu Abilities to add compatibility as it already offers natives to use

Code:

/**
 * Sets up boss casting (make sure the boss has the menu manager ability)
 *
 * @param boss                Boss index
 * @param call                Call the MA_OnMakeBoss forwards
 *
 * @noreturn
 */
native void MA_MakeBoss(int boss, bool call=true);


Can you explain me how use this native please.

Batfoxkid 02-03-2021 17:05

Re: [Subplugin] Summon a boss
 
Quote:

Originally Posted by LeAlex14 (Post 2735602)
Can you explain me how use this native please.

After you use FF2_MakeBoss you can then use
Code:

if(FF2_HasAbility(boss, "ffbat_menu_abilities", "special_menu_manager"))
        MA_MakeBoss(boss);


LeAlex14 02-05-2021 02:34

Re: [Subplugin] Summon a boss
 
Quote:

Originally Posted by Batfoxkid (Post 2735621)
After you use FF2_MakeBoss you can then use
Code:

if(FF2_HasAbility(boss, "ffbat_menu_abilities", "special_menu_manager"))
        MA_MakeBoss(boss);



Ok so i tried to do that but when MA_MakeBoss (i also included ffbat_menu) that broke the entire plugin. Idk why but even the FF2_OnAbility didn't work.

J0BL3SS 02-05-2021 12:08

Re: [Subplugin] Summon a boss
 
Code:

public void OnPluginStart()
{
        HookEvent("arena_round_start", Event_RoundStart);
        HookEvent("teamplay_round_active", Event_RoundStart); // for non-arena maps
}

public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
        MainBoss_PrepareAbilities();
        CreateTimer(1.0, TimerHookSpawn, _, TIMER_FLAG_NO_MAPCHANGE);
}

public Action TimerHookSpawn(Handle timer)
{
        HookEvent("player_spawn", Event_PlayerSpawn);
}

public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
        int iClient = GetEventInt(event, "userid");
        if(!GetClientOfUserId(iClient))
        {
                CreateTimer(0.2, SummonedBoss_PrepareAbilities, GetClientOfUserId(iClient), TIMER_FLAG_NO_MAPCHANGE);
        }
        else
        {
                LogError("ERROR: Invalid client index. %s:Event_PlayerSpawn()", this_plugin_name);
        }
}

public void MainBoss_PrepareAbilities()
{
        if(!FF2_IsFF2Enabled() || FF2_GetRoundState() != 1)
        {
                LogError("ERROR: Abilitypack called when round is over or when gamemode is not FF2. %s:MainBoss_PrepareAbilities()", this_plugin_name);
                return;
        }
        for(int bossClientIdx = 1; bossClientIdx < MaxClients; bossClientIdx++)
        {
                int bossIdx = FF2_GetBossIndex(bossClientIdx);
                if(bossIdx >= 0)
                {
                        HookAbilities(bossIdx, bossClientIdx);
                }
        }
}

public Action SummonedBoss_PrepareAbilities(Handle timer, int bossClientIdx)
{
        if(!bossClientIdx)
        {
                int bossIdx = FF2_GetBossIndex(bossClientIdx);
                if(bossIdx >= 0)
                {
                        HookAbilities(bossIdx, bossClientIdx);
                }
                else
                {
                        PrintToServer("WARNING: Respawned player has no boss index. %s:SummonedBoss_PrepareAbilities()", this_plugin_name);
                        //LogError("WARNING: Respawned player has no boss index. %s:SummonedBoss_PrepareAbilities()", this_plugin_name);
                }
        }
        else
        {
                LogError("ERROR: Unable to find respawned player. %s:SummonedBoss_PrepareAbilities()", this_plugin_name);
        }
}

public void HookAbilities(int bossIdx, int bossClientIdx)
{
        //Define Your Ability Arguments, do things ...
        //My Rage
        if(FF2_HasAbility(bossIdx, this_plugin_name, "rage_myability"))
        {
                //AMS Triggers
                AMS_TEST[bossClientIdx] = AMS_IsSubabilityReady(bossIdx, this_plugin_name, "rage_myability");
                if(AMS_TEST[bossClientIdx])
                {
                        AMS_InitSubability(bossIdx, bossClientIdx, this_plugin_name, "rage_myability", "TEST");
                }
                MyAbility_Duration[bossClientIdx] = FF2_GetAbilityArgumentFloat(bossIdx, this_plugin_name, "rage_myability", 1, 10.0);
                MyAbility_Distance[bossClientIdx] = FF2_GetAbilityArgumentFloat(bossIdx, this_plugin_name, "rage_myability", 2, 1024.0);
        }
}

This is what i did to make compatible my subplugins to future usage.


All times are GMT -4. The time now is 06:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.