Spellbook spawning when cart is pushed on Hightower Event?

Discussion in 'Mapping Questions & Discussion' started by oWave, Nov 9, 2016.

  1. oWave

    oWave L1: Registered

    Messages:
    10
    Positive Ratings:
    3
    I'm trying to figure out how the spellbooks spawn from the carts on Hightower Event, mainly to figure out how the spellbook movement works for a sourcemod plugin.

    There doesn't appear to be an entity that is responsible for spawning the spellbooks. They just spawn from the mapobj_cart_dispenser.

    Is there some entity/input that I missed or is the spawning hardcoded?
     
  2. Benoist3012

    Benoist3012 L3: Member

    Messages:
    145
    Positive Ratings:
    201
    I can tell you It's hardcoded I never really spent time to look at which function spawns them, might do it tomorrow
     
    • Agree Agree x 1
  3. oWave

    oWave L1: Registered

    Messages:
    10
    Positive Ratings:
    3
    Should you look at the spawning, could you send me the code for that function? All I would need are the EntProps that the spell pickups are spawned with.
     
  4. Benoist3012

    Benoist3012 L3: Member

    Messages:
    145
    Positive Ratings:
    201
    The function called is
    Code:
    CObjectCartDispenser::DropSpellPickup
    I reversed the function from assembly to c++ for you:
    Code:
    public CSpellPickup CObjectCartDispenser::DropSpellPickup()
    {
        CSpellPickup *pSellPickup;
        if (g_pGameRules->m_halloweenScenario == HELLTOWER_SCENARIO)//Yes this means only helltower can drop spells, unless you use a plugin and set m_halloweenScenario on 4
        {
            if (m_spawnflags & HEAL_DISGUISED_STEALTHED_SPIES)
            {
                CalcAbsolutePosition();
            }
            pSellPickup = g_pGameRules->DropSpellPickup(m_vecAbsOrigin, 0); //(CTFGameRules::DropSpellPickup)
        }
    }
    
    public CSpellPickup CTFGameRules::DropSpellPickup(const Vector *vecPosition, int iSpellTier)
    {
        CSpellPickup *pSellPickup;
        if ( IsUsingSpells() )
        {
            //Some vecpostion changes not really important
            CBaseEntity *pEntity = CBaseEntity::CreateNoSpawn("tf_spell_pickup", vecPosition, vec3_angle, 0);
            pSellPickup = (CSpellPickup *)pEntity;
            if ( pSellPickup )
            {
                pSellPickup->m_nTier = iSpellTier;
                DispatchSpawn(pSellPickup);
                Vector *vecVelocity;
                //Velocity calculation crap
                CTFPowerup::DropSingleInstance((CTFPowerup *)pSellPickup, vecVelocity, 0, 0.0, 0.1);
            }
        }
      }
      return pSellPickup;
    }
    
    public void CTFPowerup::DropSingleInstance(Vector *vecVelocity, CBaseCombatCharacter *pPlayer, float flSomething, float flSomething2)
    {
        //Begining of CTFPowerup::DropSingleInstance
        //Only that part is interesting
        SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
        SetAbsVelocity(vecVelocity);
        //Something stored at 368
        pSomething->SetSolid(SOLID_BBOX);
    }