AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What's wrong with the entity ? (https://forums.alliedmods.net/showthread.php?t=209487)

EDUTz 02-26-2013 05:25

What's wrong with the entity ?
 
So i have a small problem with an entity. I don't understant why it gives me invalid entity...
Run time error 10: native error (native "set_pev")
Think_Boss (line 553)

I highlighted the line, it's the last set_pev.

I've checked the other "cases", all of them are working but the last one.

Code:

public Think_Boss(Ent)
{
        if (pev(Ent, pev_deadflag) == DEAD_DYING)
                return
       
        static bool:one
       
        switch ( Ability ) {
                case IDLE: {
                        Ability = WALK
                        set_task(10.0, "RandomAbility", 1337, _, _, "b")
                        set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
                        return
                }
                case WALK: {
                        static Float:Origin[3], Float:Origin2[3], Float:Vector[3], Float:Angle[3]
                        if (!is_user_alive(g_BossTarget)) {
                                g_BossTarget = GetRandomAlive(random_num(1, GetAliveCount()))
                                set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
                                return
                        }
                        if (one) {
                                set_pev(Ent, pev_movetype, MOVETYPE_PUSHSTEP)
                                Anim(Ent, 3)
                                one = false
                        }
                        pev(Ent, pev_origin, Origin)
                        pev(g_BossTarget, pev_origin, Origin2)
                       
                        xs_vec_sub(Origin2, Origin, Vector)
                        vector_to_angle(Vector, Angle)
                        new Float:num = floatsqroot(float(boss_speed)*float(boss_speed) / (Vector[0]*Vector[0] + Vector[1]*Vector[1] + Vector[2]*Vector[2]))
                        Vector[0] *= num
                        Vector[1] *= num
                        Vector[2] ? (Vector[2] = 0.0) : (Vector[2] *= num)
                        set_pev(Ent, pev_velocity, Vector)
                        Angle[0] = 0.0
                        Angle[2] = 0.0
                        set_pev(Ent, pev_angles, Angle)
                        set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
                        return
                }
                case ATTACK: {
                        static num                       
                        switch (num) {
                                case 0: {
                                        Anim(Ent, 6)
                                        num++
                                        set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
                                        return
                                }
                                case 1: {
                                        static Float:OriginA[3], Float:OriginA2[3], Float:LenA, Float:Vector[3], Float:Velocity[3]
                                       
                                        pev(g_Alien, pev_origin, OriginA)
                                        pev(VictimID, pev_origin, OriginA2)
                                       
                                        xs_vec_sub(OriginA2, OriginA, Velocity)
                                        xs_vec_sub(OriginA, OriginA2, Vector)
                                       
                                        LenA = xs_vec_len(Vector)
                                       
                                        if (LenA <= 170) {
                                                xs_vec_normalize(Velocity, Velocity)
                                                Velocity[2] = 0.5
                                                xs_vec_mul_scalar(Velocity, 1000.0, Velocity)
                                                ExecuteHamB(Ham_TakeDamage, VictimID, 0, VictimID, float(dmg_attack), DMG_BULLET)
                                                ScreenFade(VictimID, 3, {255, 0, 0}, 120)
                                                ScreenShake(VictimID)
                                                set_pev(VictimID, pev_velocity, Velocity)
                                        }
                                }
                        }
                        num = 0
                        one = true
                        Ability = WALK
                        set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
                }
                case MS: {
                        static num, Float:Origin[3], Float:Origin2[3], Float:Vector[3], Float:Angle[3]
                        switch ( num ) {
                                case 0: {
                                        new MS_Attack = GetRandomAlive(random_num(1, GetAliveCount()))
                                       
                                        pev(MS_Attack, pev_origin, Origin)
                                        pev(Ent, pev_origin, Origin2)
                                       
                                        xs_vec_sub(Origin, Origin2, Vector)
                                        vector_to_angle(Vector, Angle)
                                        xs_vec_normalize(Vector, Vector)
                                        xs_vec_mul_scalar(Vector, 2000.0, Vector)
                                        Angle[0] = 0.0
                                        Angle[2] = 0.0
                                        Vector[2] = 0.0
                                        set_pev(Ent, pev_angles, Angle)
                                        set_pev(Ent, pev_movetype, MOVETYPE_NONE)
                                        Anim(Ent, 7)
                                        set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
                                        num++
                                        return
                                }
                                case 1: {
                                        set_pev(Ent, pev_movetype, MOVETYPE_FLY)
                                        set_pev(Ent, pev_velocity, Vector)
                                        set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
                                        num++
                                        return
                                }
                        }
                        set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
                        num = 0
                        Ability = WALK
                        one = true
                        return
                }
                case SW: {
                        static num, FluxSpr, Float:Origin[3], sw_random
                        switch ( num ) {
                                case 0: {
                                        sw_random = random(3)
                                        Anim(Ent, 2)
                                        FluxSpr = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
                                        pev(Ent, pev_origin, Origin)
                                        Origin[2] += 70
                                        engfunc(EngFunc_SetOrigin, FluxSpr, Origin)
                                        engfunc(EngFunc_SetModel, FluxSpr, Resource[5])
                                        set_pev(FluxSpr, pev_solid, SOLID_NOT)
                                        set_pev(FluxSpr, pev_movetype, MOVETYPE_NOCLIP)
                                        switch(sw_random) {
                                                case 0: {
                                                        set_rendering(FluxSpr, kRenderFxFadeSlow, 255, 0, 0, kRenderTransAdd, 255)
                                                        set_rendering(Ent, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 30)
                                                }
                                                case 1: {
                                                        set_rendering(FluxSpr, kRenderFxFadeSlow, 255, 255, 0, kRenderTransAdd, 255)
                                                        set_rendering(Ent, kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 30)
                                                }
                                                case 2: {
                                                        set_rendering(FluxSpr, kRenderFxFadeSlow, 0, 0, 255, kRenderTransAdd, 255)
                                                        set_rendering(Ent, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 30)
                                                }
                                        }
                                        set_pev(FluxSpr, pev_framerate, 5.0)
                                        dllfunc(DLLFunc_Spawn, FluxSpr)
                                        set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
                                        num++
                                        return
                                }
                                case 1..10: {
                                        for(new id = 1; id <= get_maxplayers(); id++) {
                                                if (!is_user_alive(id))
                                                        continue
                                               
                                                static Float:OriginSW[3], Float:OriginSW2[3], Float:Vector[3]
                                                pev(Ent, pev_origin, OriginSW)
                                                pev(id, pev_origin, OriginSW2)
                                               
                                                xs_vec_sub(OriginSW, OriginSW2, Vector)
                                                xs_vec_normalize(Vector, Vector)
                                                xs_vec_mul_scalar(Vector, 800.0, Vector)
                                                set_pev(id, pev_velocity, Vector)
                                                set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
                                                num++
                                                return
                                        }
                                }
                                case 11: {
                                        engfunc(EngFunc_RemoveEntity, FluxSpr)
                                        Anim(Ent, 5)
                                        set_pev(Ent, pev_nextthink, get_gametime() + 2.2)
                                        num++
                                        return
                                }
                                case 12: {
                                        static Float:Orig[3]
                                        pev(Ent, pev_origin, Orig)
                                        set_rendering(Ent)
                                       
                                        switch (sw_random) {
                                                case 0: ShockWave(Orig, 5, 35, 1000.0, {255, 0, 0}) // 450
                                                case 1: ShockWave(Orig, 5, 35, 1000.0, {255, 255, 0})
                                                case 2: ShockWave(Orig, 5, 35, 1000.0, {0, 0, 255})
                                        }
                                       
                                        for(new id = 1; id <= get_maxplayers(); id++) {
                                                if (!is_user_alive(id))
                                                        continue
                                               
                                                if (pev(id, pev_flags) & FL_ONGROUND) {
                                                        static Float:gOrigin[3], Float:Vec[3], Float:Len
                                                        pev(id, pev_origin, gOrigin)
                                                        xs_vec_sub(Orig, gOrigin, Vec)
                                                        Len = xs_vec_len(Vec)
                                                        if (Len <= 450.0) {
                                                                switch (sw_random) {
                                                                        case 0: user_kill(id)
                                                                                case 1: {
                                                                                ScreenFade(id, 5, {255, 0, 0}, 120)
                                                                                ExecuteHamB(Ham_TakeDamage, id, 0, id, float(dmg_sw), DMG_SONIC)
                                                                                ScreenShake(id)
                                                                        }
                                                                        case 2: {
                                                                                client_cmd(id, "drop")
                                                                                ScreenShake(id)
                                                                        }
                                                                }
                                                        }
                                                }
                                        }
                                        Ability = WALK
                                        one = true
                                        num = 0
                                        set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
                                        return
                                }
                        }
                }
        }
}


Podarok 02-26-2013 06:05

Re: What's wrong with the entity ?
 
Provide us the full code

EDUTz 02-26-2013 06:15

Re: What's wrong with the entity ?
 
http://pastebin.com/8vpP1Us7


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

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