IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Adding More Weapons?
JRob
post Oct 6 2015, 10:24 AM
Post #1


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



I have tried adding more weapons to bot_weapons.cpp and bot_weapons.h but to no success.

CODE

    {TF2_SLOT_PRMRY,TF2_WEAPON_HANDGUN_SCOUT_PRIMARY,        "tf_weapon_handgun_scout_primary",    WEAP_FL_KILLPIPEBOMBS|WEAP_FL_PRIM_ATTACK|WEAP_FL_UNDERWATER,0,800,1,3,0},
    {TF2_SLOT_PRMRY,TF2_WEAPON_SODA_POPPER,                    "tf_weapon_soda_popper",    WEAP_FL_KILLPIPEBOMBS|WEAP_FL_PRIM_ATTACK|WEAP_FL_UNDERWATER,0,800,1,3,0},
    {TF2_SLOT_PRMRY,TF2_WEAPON_PEP_BRAWLER_BLASTER,            "tf_weapon_pep_brawler_blaster",    WEAP_FL_KILLPIPEBOMBS|WEAP_FL_PRIM_ATTACK|WEAP_FL_UNDERWATER,0,800,1,3,0},
    {TF2_SLOT_SCNDR,TF2_WEAPON_JAR_MILK,                    "tf_weapon_jar_milk",    WEAP_FL_NONE,0,180,0,1,0},
    {TF2_SLOT_PRMRY,TF2_WEAPON_ROCKETLAUNCHER_AIRSTRIKE,    "tf_weapon_rocketlauncher_airstrike",    WEAP_FL_PRIM_ATTACK|WEAP_FL_EXPLOSIVE|WEAP_FL_UNDERWATER,BLAST_RADIUS*0.9,4096,1,3,TF2_ROCKETSPEED},
    {TF2_SLOT_SCNDR,TF2_WEAPON_FLAREGUN_REVENGE,             "tf_weapon_flaregun_revenge", WEAP_FL_PRIM_ATTACK, 0, 1600, 2, 2, TF2_GRENADESPEED * 1.5 },
    {TF2_SLOT_PRMRY,TF2_WEAPON_CANNON,                        "tf_weapon_cannon",   & nbsp;WEAP_FL_PROJECTILE|WEAP_FL_PRIM_ATTACK|WEAP_FL_EXPLOSIVE|WEAP_FL_UNDERWATER
,100,1200,1,2,TF2_GRENADESPEED*1.5},
    {TF2_SLOT_PRMRY,TF2_WEAPON_SHOTGUN_BUILDING_RESCUE,        "tf_weapon_shotgun_building_rescue",    WEAP_FL_KILLPIPEBOMBS|WEAP_FL_PRIM_ATTACK|WEAP_FL_UNDERWATER,0,800,1,2,0},

    // short circuit
    // wrangler
    {TF2_SLOT_MELEE,TF2_WEAPON_ROBOT_ARM,                    "tf_weapon_robot_arm",    WEAP_FL_PRIM_ATTACK|WEAP_FL_MELEE|WEAP_FL_UNDERWATER,0,180,3,1,0},

    {TF2_SLOT_PRMRY,TF2_WEAPON_SNIPERRIFLE_DECAP,            "tf_weapon_sniperrifle_decap",    WEAP_FL_SCOPE|WEAP_FL_PRIM_ATTACK,1000,4000,1,3,0},
    {TF2_SLOT_PRMRY,TF2_WEAPON_SNIPERRIFLE_CLASSIC,            "tf_weapon_sniperrifle_classic",    WEAP_FL_SCOPE|WEAP_FL_PRIM_ATTACK,1000,4000,1,3,0},

...

    TF2_WEAPON_HANDGUN_SCOUT_PRIMARY,
    TF2_WEAPON_SODA_POPPER,
    TF2_WEAPON_PEP_BRAWLER_BLASTER,
    TF2_WEAPON_JAR_MILK,
    TF2_WEAPON_ROCKETLAUNCHER_AIRSTRIKE,
    TF2_WEAPON_FLAREGUN_REVENGE,
    TF2_WEAPON_CANNON,
    TF2_WEAPON_SHOTGUN_BUILDING_RESCUE,
    TF2_WEAPON_ROBOT_ARM,
    TF2_WEAPON_SNIPERRIFLE_DECAP,
    TF2_WEAPON_SNIPERRIFLE_CLASSIC,


Apparently, there seems to be a MAX_WEAPONS defined to 48. I tried redefining this to TF2_WEAPON_MAX but it only results in random crashes. How are you supposed to add more than 48 weapons? There are obviously more than 48 weapon types in the game. I noticed that you have only been replacing unused entries to avoid this problem.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 6 2015, 12:17 PM
Post #2


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1



the default weapons in weapons.cpp is no longer used if you have weapons.ini in the config folder
see: http://rcbot.bots-united.com/forums/index....ost&p=13465
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
JRob
post Oct 6 2015, 07:50 PM
Post #3


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



I just updated and it still crashes when I try to add more weapons through weapons.ini.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 7 2015, 01:53 PM
Post #4


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1



QUOTE(JRob @ Oct 6 2015, 08:50 PM) *

I just updated and it still crashes when I try to add more weapons through weapons.ini.


MAX_WEAPONS is how many weapons a player can carry, not the maximum number of weapons in the game, although the old rcbot code used this as a maximum for in the game for convenience sake.

Though if you want to add a new weapon without weapons .ini, you need to have this:

CODE

{0, 0, "\0", 0, 0, 0, 0, 0, 0}//signal last weapon


at the end of the WeaponsData_t [] weaponlist

I noticed this was omitted out of DODs and HL2DM so I've added this back in just in case.

Could you locate where in the code it is crashing due to changing weapons.ini file?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
JRob
post Oct 7 2015, 11:38 PM
Post #5


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



QUOTE(Cheeseh @ Oct 7 2015, 01:53 PM) *

MAX_WEAPONS is how many weapons a player can carry, not the maximum number of weapons in the game, although the old rcbot code used this as a maximum for in the game for convenience sake.

Though if you want to add a new weapon without weapons .ini, you need to have this:

CODE

{0, 0, "\0", 0, 0, 0, 0, 0, 0}//signal last weapon


at the end of the WeaponsData_t [] weaponlist

I noticed this was omitted out of DODs and HL2DM so I've added this back in just in case.

Could you locate where in the code it is crashing due to changing weapons.ini file?


Line numbers for bot_task.cpp might be a bit off since I have added crash fixes you haven't incorporated yet.

I am using weapons.ini now so it is not an issue with the old way of adding weapons.

This is one of the crashes I get. There is another one but I deleted it.

#0 0xebefc76c in CWeapon::getID (this=0x0) at bot_weapons.h:423
423 return m_iWeaponId;
#0 0xebefc76c in CWeapon::getID (this=0x0) at bot_weapons.h:423
#1 0xebefc7fe in CBotWeapon::getID (this=0x158f2bd8) at bot_weapons.h:602
#2 0xebf6083e in CBotUseLunchBoxDrink::execute (this=0x14ba1440, pBot=0xafaa140, pSchedule=0x131880a8) at bot_task.cpp:1489
#3 0xebf57a04 in CBotSchedule::execute (this=0x131880a8, pBot=0xafaa140) at bot_schedule.cpp:798
#4 0xebee2fe5 in CBotSchedules::execute (this=0xe2910b8, pBot=0xafaa140) at bot_schedule.h:246
#5 0xebed8d79 in CBot::think (this=0xafaa140) at bot.cpp:960
#6 0xebee1267 in CBots::botThink () at bot.cpp:3566
#7 0xebf4aef6 in RCBotPluginMeta::Hook_GameFrame (this=0xec017c98 <g_RCBotPluginMeta>, simulating=true) at bot_plugin_meta.cpp:1266

The maximum number of weapons a player can carry is really 48? That seems really high. And it is strange that your weapon array is also MAX_WEAPONS.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 9 2015, 02:33 PM
Post #6


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1



parts of the weapon code are archaic and I'm updating it to allow id's outside the Max weapons boundary. but every CTFPlayer is derived from CBaseCombatCharacter which has an array of weapons up to Max weapons per player so it must be the max amount each player can carry
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
JRob
post Oct 20 2015, 01:10 AM
Post #7


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



QUOTE(Cheeseh @ Oct 9 2015, 02:33 PM) *

parts of the weapon code are archaic and I'm updating it to allow id's outside the Max weapons boundary. but every CTFPlayer is derived from CBaseCombatCharacter which has an array of weapons up to Max weapons per player so it must be the max amount each player can carry


Any estimate on when that might be coming around?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 20 2015, 10:51 AM
Post #8


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1



QUOTE(JRob @ Oct 20 2015, 02:10 AM) *

Any estimate on when that might be coming around?


I've already done so, I just need to update the SVN when i get back home
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 21 2015, 02:08 AM
Post #9


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1



QUOTE(Cheeseh @ Oct 20 2015, 11:51 AM) *

I've already done so, I just need to update the SVN when i get back home


I've updated the SVN. http://sourceforge.net/p/rcbot2/code/HEAD/...ls/RCBot2_meta/

It still needs more testing.

If you want to test and don't want to build I have the debug dll here http://sourceforge.net/p/rcbot2/code/HEAD/....dll?format=raw
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
JRob
post Oct 27 2015, 02:29 AM
Post #10


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



#0 0xebf568ec in CBotWeapon::getWeaponInfo (this=0x0) at bot_weapons.h:707
707 CWeapon *getWeaponInfo () { return m_pWeaponInfo; }
#0 0xebf568ec in CBotWeapon::getWeaponInfo (this=0x0) at bot_weapons.h:707
#1 0xebf7a832 in CBotTF2::selectBotWeapon (this=0xb9bd740, pBotWeapon=0x0) at bot_fortress.cpp:5273
#2 0xebf7a09f in CBotTF2::deployStickies (this=0xb9bd740, type=TF_TRAP_TYPE_FLAG, vStand=..., vLocation=..., vSpread=..., vPoint=0x1465a4bc, iState=0x1465a4f4, iStickyNum=0x1465a4f8, bFail=0xffe8da1b, fTime=0x1465a4ec, wptindex=0) at bot_fortress.cpp:5128
#3 0xebfc454e in CBotTF2DemomanPipeTrap::execute (this=0x1465a498, pBot=0xb9bd740, pSchedule=0x1505ec28) at bot_task.cpp:4476
#4 0xebfb1a60 in CBotSchedule::execute (this=0x1505ec28, pBot=0xb9bd740) at bot_schedule.cpp:798
#5 0xebf3d069 in CBotSchedules::execute (this=0x138d6060, pBot=0xb9bd740) at bot_schedule.h:246
#6 0xebf32de9 in CBot::think (this=0xb9bd740) at bot.cpp:960
#7 0xebf3b2eb in CBots::botThink () at bot.cpp:3566
#8 0xebfa4f52 in RCBotPluginMeta::Hook_GameFrame (this=0xec071c98 <g_RCBotPluginMeta>, simulating=true) at bot_plugin_meta.cpp:1266
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 27 2015, 05:43 AM
Post #11


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1



EDIT:

actually the bug is here

CODE

    static bool bNeedHealth;
    static bool bNeedAmmo;
    static bool bIsCloaked;

    extern ConVar rcbot_customloadouts;

    // FIX: MUST Update class
    m_iClass = (TF_Class)CClassInterface::getTF2Class(m_pEdict);

    if (rcbot_customloadouts.GetBool() && m_pVTable && m_pVTable_Attributes && (m_fEquipHatTime > 0.0f) && (m_fEquipHatTime < engine->Time()))
    {
        // Equip
        if (isAlive())
        {
                          m_iClass = (TF_Class)CClassInterface::getTF2Class(m_pEdict);


m_iClass = (TF_Class)CClassInterface::getTF2Class(m_pEdict);

should be updated no matter what. so put it here

CODE

void CBotTF2::modThink()
{
    static bool bNeedHealth;
    static bool bNeedAmmo;
    static bool bIsCloaked;

    extern ConVar rcbot_customloadouts;

    // FIX: MUST Update class
    m_iClass = (TF_Class)CClassInterface::getTF2Class(m_pEdict);

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
JRob
post Oct 27 2015, 09:55 PM
Post #12


Advanced Member
***

Group: Members
Posts: 52
Joined: 30-April 11
Member No.: 1,970



still the exact same error
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Oct 28 2015, 12:18 AM
Post #13


Admin
*****

Group: Admin
Posts: 3,016
Joined: 11-September 03
From: uk
Member No.: 1




change canDeployStickies like this
CODE

bool CBotTF2 :: canDeployStickies ()
{
    if ( m_pEnemy.get() != NULL )
    {
        if ( CBotGlobals::isAlivePlayer(m_pEnemy) )
        {
            if ( isVisible(m_pEnemy) )
                return false;        
        }
    }

    // enough ammo???
    CBotWeapon *pWeapon = m_pWeapons->getWeapon(CWeapons::getWeapon(TF2_WEAPON_PIPEBOMBS));

    if ( pWeapon )
    {
        return (pWeapon->hasWeapon() && pWeapon->getAmmo(this) >= 6);
    }

    return false;
}


change the demoman stuff in getTasks to this

CODE


    if ((m_iClass == TF_CLASS_DEMOMAN) && (m_iTrapType == TF_TRAP_TYPE_NONE) && canDeployStickies())
    {
        ADD_UTILITY(BOT_UTIL_DEMO_STICKYTRAP_LASTENEMY,m_pLastEnemy &&
            (m_iTrapType==TF_TRAP_TYPE_NONE),
            randomFloat(min(fDefendFlagUtility,fGetFlagUtility),max(fDefendFlagUtility,fGetFlagUtility)));

        ADD_UTILITY(BOT_UTIL_DEMO_STICKYTRAP_FLAG,
            CTeamFortress2Mod::isMapType(TF_MAP_CTF) && !bHasFlag &&
            (!m_fLastKnownTeamFlagTime || (m_fLastKnownTeamFlagTime < engine->Time())),
            fDefendFlagUtility+0.3f);

        ADD_UTILITY(BOT_UTIL_DEMO_STICKYTRAP_FLAG_LASTKNOWN,
            (CTeamFortress2Mod::isMapType(TF_MAP_MVM)||CTeamFortress2Mod::isMapType(TF_MAP_CTF)||(CTeamFortress2Mod::isMapType(TF_MAP_SD) &&
        (CTeamFortress2Mod::getFlagCarrierTeam()==CTeamFortress2Mod::getEnemyTeam(iTeam)))) && !bHasFlag &&
            (m_fLastKnownTeamFlagTime && (m_fLastKnownTeamFlagTime > engine->Time())),fDefendFlagUtility+0.4f);

        ADD_UTILITY(BOT_UTIL_DEMO_STICKYTRAP_POINT,(iTeam==TF2_TEAM_RED)&&(m_iCurrentDefendArea>0) &&
            (CTeamFortress2Mod::isMapType(TF_MAP_MVM)||CTeamFortress2Mod::isMapType(TF_MAP_SD)||CTeamFortress2Mod::isMapType(TF_MAP_CART)||
            CTeamFortress2Mod::isMapType(TF_MAP_CARTRACE)||CTeamFortress2Mod::isMapType(TF_MAP_ARENA)||
            CTeamFortress2Mod::isMapType(TF_MAP_KOTH)||CTeamFortress2Mod::isMapType(TF_MAP_CP)||
            CTeamFortress2Mod::isMapType(TF_MAP_TC)),
            fDefendFlagUtility+0.4f);

        ADD_UTILITY(BOT_UTIL_DEMO_STICKYTRAP_PL,
            (CTeamFortress2Mod::isMapType(TF_MAP_CART)||CTeamFortress2Mod::isMapType(TF_MAP_CARTRACE)) &&
            (m_pDefendPayloadBomb!=NULL),
            fDefendFlagUtility+0.4f);
    }


is rcbot_customloadouts 1 or 0?
if its crashing when it is 1, you might want to change the give weapon code in modthink to this

CODE

    if (rcbot_customloadouts.GetBool() && m_pVTable && m_pVTable_Attributes && (m_fEquipHatTime > 0.0f) && (m_fEquipHatTime < engine->Time()))
    {
        // Equip
        if (isAlive())
        {
            if (isDesiredClass(m_iClass))
            {
                extern ConVar rcbot_melee_only;

                bool bAdded = false;

                if ((m_iClass == TF_CLASS_ENGINEER) && !CTeamFortress2Mod::isMedievalMode())
                    m_pMelee = NULL;
                else if (m_pMelee == NULL)
                    m_pMelee = CTeamFortress2Mod::findRandomWeaponLoadOutInSlot(m_iClass, TF2_SLOT_MELEE);

                extern ConVar *mp_stalemate_meleeonly;

                if (!mp_stalemate_meleeonly || !mp_stalemate_meleeonly->GetBool() || !CTeamFortress2Mod::isSuddenDeath())
                {
                    // only add primary / secondary weapons if they are given them by the map
                    /*if (RCBotPluginMeta::TF2_getPlayerWeaponSlot(m_pEdict, TF2_SLOT_PRMRY) &&
                        RCBotPluginMeta::TF2_getPlayerWeaponSlot(m_pEdict, TF2_SLOT_SCNDR))
                        {*/
                    if (m_pPrimary == NULL)
                        m_pPrimary = CTeamFortress2Mod::findRandomWeaponLoadOutInSlot(m_iClass, TF2_SLOT_PRMRY);

                    if ((m_iClass == TF_CLASS_SPY) && !CTeamFortress2Mod::isMedievalMode())
                        m_pSecondary = NULL;
                    else if (m_pSecondary == NULL)
                        m_pSecondary = CTeamFortress2Mod::findRandomWeaponLoadOutInSlot(m_iClass, TF2_SLOT_SCNDR);
                }
                else
                {
                    // sudden death
                    m_pPrimary = NULL;
                    m_pSecondary = NULL;
                }

                // adding this will remove the builder -- don't do it!!!
                if ((m_iClass == TF_CLASS_ENGINEER) && !CTeamFortress2Mod::isMedievalMode())
                    m_pHat = NULL;
                else if (m_pHat == NULL)
                    m_pHat = CTeamFortress2Mod::findRandomWeaponLoadOutInSlot(m_iClass, TF2_SLOT_HAT);

                if (m_pMisc == NULL)
                    m_pMisc = CTeamFortress2Mod::findRandomWeaponLoadOutInSlot(m_iClass, TF2_SLOT_MISC);

                if (m_pMelee != NULL)
                    bAdded = RCBotPluginMeta::givePlayerLoadOut(m_pEdict, m_pMelee, TF2_SLOT_MELEE, m_pVTable, m_pVTable_Attributes);
                if (m_pPrimary != NULL)
                    bAdded |= RCBotPluginMeta::givePlayerLoadOut(m_pEdict, m_pPrimary, TF2_SLOT_PRMRY, m_pVTable, m_pVTable_Attributes);
                if (m_pSecondary != NULL)
                    bAdded |= RCBotPluginMeta::givePlayerLoadOut(m_pEdict, m_pSecondary, TF2_SLOT_SCNDR, m_pVTable, m_pVTable_Attributes);
                if (m_pHat != NULL)
                    bAdded |= RCBotPluginMeta::givePlayerLoadOut(m_pEdict, m_pHat, TF2_SLOT_HAT, m_pVTable, m_pVTable_Attributes);
                if (m_pMisc != NULL)
                    bAdded |= RCBotPluginMeta::givePlayerLoadOut(m_pEdict, m_pMisc, TF2_SLOT_MISC, m_pVTable, m_pVTable_Attributes);

                m_fEquipHatTime = 0.0f;
                m_bHatEquipped = true;

                if (bAdded)
                {
                    m_pSchedules->freeMemory(); // Could mess up weapons
                    m_pWeapons->resetSignature();
                    m_pWeapons->update(overrideAmmoTypes());
                }
            }
        }
    }
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th August 2019 - 04:20 AM