AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity only takedamage from knife (https://forums.alliedmods.net/showthread.php?t=309236)

Celena Luna 07-18-2018 14:37

Entity only takedamage from knife
 
I tried to create entity (boss) that can takedamage.

PHP Code:

public create_revenant()
{
    static 
EntEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    if(!
pev_valid(Ent)) return
    
set_pev(Entpev_originpOrigin)
    
    
set_pev(Entpev_anglespv_Origin)
    
    
set_pev(Entpev_health30000.0)

    
set_pev(Entpev_classnameGIANT_CLASSNAME)
    
engfunc(EngFunc_SetModelEntGIANT_MODEL)
    
set_pev(Entpev_solidSOLID_BBOX)

    
set_pev(Entpev_movetypeMOVETYPE_PUSHSTEP)
    
set_pev(Entpev_gamestate1)
    
set_pev(Entpev_stateSTATE_COMBAT//pev_state = pev_iuser1
    
set_pev(Entpev_takedamage1.0)

    static 
Float:Takedamagepev(Entpev_takedamageTakedamage)
    
client_print(0print_chat"TAKEDAMAGE: %f"Takedamage//printed 1.0

    
static Float:Maxs[3], Float:Mins[3]
    
Maxs[0] = 75.0;
    
Maxs[1] = 75.0;
    
Maxs[2] = 120.0
    Mins
[0] = -75.0;
    
Mins[1] = -75.0;
    
Mins[2] = -150.0;
    
entity_set_size(EntMinsMaxs)
    
Play_Animation(EntANIME_APPEAR)
    
    
emit_sound(EntCHAN_BODYGiantSounds[3], VOL_NORMATTN_NORM0PITCH_NORM)

    static 
Float:Origin[3]; pev(Entpev_originOrigin)
    
Origin[2] += 36.0
    Create_Rock
(Origin)
    
    
drop_to_floor(Ent)
    
entity_set_float(EntEV_FL_nextthinkget_gametime() + 5.5)
    
    if(!
g_HamReg)
    {
        
g_HamReg 1
        client_print
(0print_console"Ham Registered")
        
RegisterHamFromEntity(Ham_TakeDamageEnt"fw_BossTakeDamage")
        
//RegisterHamFromEntity(Ham_TraceAttack, Ent, "fw_BossTraceAttack")
    
}

    
g_Test Ent
}

public 
fw_BossTakeDamage(victiminflictorattackerFloat:damagedamagebits)
{
    
//static Float:Origin[3]
    //fm_get_aim_origin(attacker, Origin)
    //create_blood(Origin)
    
client_print(attackerprint_center"%.f"damage)


The problem is it doesn't take damage from any weapon except knife.
I am using amx 1.8.3

HamletEagle 07-18-2018 14:51

Re: Entity only takedamage from knife
 
Is TraceAttack called? Can you also test with a shotgun?

Celena Luna 07-18-2018 14:58

Re: Entity only takedamage from knife
 
PHP Code:

if(!g_HamReg)
    {
        
g_HamReg 1
        
//client_print(0, print_console, "Ham Registered")
        //RegisterHamFromEntity(Ham_TakeDamage, Ent, "fw_BossTakeDamage")
        
RegisterHamFromEntity(Ham_TraceAttackEnt"fw_BossTraceAttack")
    }

    
g_Test Ent
}

public 
fw_BossTraceAttack(EntAttackerFloat:DamageFloat:Dir[3], ptrDamageType)
{
    
client_print(Attackerprint_center"%.f"Damage)


Shotgun also didn't work. Only Knife.
I also disabled all other plugins (to make sure it isn't cost by other plugins).
I switched from takedamage to traceattack. Still only knife deal damage but not other.

Ghosted 07-18-2018 16:25

Re: Entity only takedamage from knife
 
[DEBUGGING OPTION] Try separatelly remove stuff from entity and test each one

Celena Luna 07-18-2018 16:54

Re: Entity only takedamage from knife
 
Quote:

Originally Posted by Ghosted (Post 2604631)
[DEBUGGING OPTION] Try separatelly remove stuff from entity and test each one

PHP Code:

public create_revenant()
{
    static 
EntEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    if(!
pev_valid(Ent)) return
    
set_pev(Entpev_originpOrigin//Appear in right Origin
    
    
set_pev(Entpev_anglespv_Origin//Appear in right Angel
    
    
set_pev(Entpev_health30000.0//Correct Health

    
set_pev(Entpev_classnameGIANT_CLASSNAME//Think works so Classname is correct
    
engfunc(EngFunc_SetModelEntGIANT_MODEL//Appear in right model
    
set_pev(Entpev_solidSOLID_BBOX//Touchable

    
set_pev(Entpev_movetypeMOVETYPE_PUSHSTEP//(how to check this?)
    
set_pev(Entpev_gamestate1//Turn on or off doesn't effect
    
set_pev(Entpev_stateSTATE_COMBAT//pev_state = pev_iuser1

    
set_pev(Entpev_takedamage1.0
    static 
Float:Takedamagepev(Entpev_takedamageTakedamage)
    
client_print(0print_chat"TAKEDAMAGE: %f"Takedamage//printed 1.0

    
static Float:Maxs[3], Float:Mins[3]
    
Maxs[0] = 75.0;
    
Maxs[1] = 75.0;
    
Maxs[2] = 120.0
    Mins
[0] = -75.0;
    
Mins[1] = -75.0;
    
Mins[2] = -150.0;
    
entity_set_size(EntMinsMaxs//Can jump above so the hitbox is correct
    
Play_Animation(EntANIME_APPEAR//Did run the animation
    
    
emit_sound(EntCHAN_BODYGiantSounds[3], VOL_NORMATTN_NORM0PITCH_NORM)

    
//static Float:Origin[3]; pev(Ent, pev_origin, Origin)
    //Origin[2] += 36.0
    //Create_Rock(Origin)
    
    
drop_to_floor(Ent)
    
entity_set_float(EntEV_FL_nextthinkget_gametime() + 5.5)
    
    if(!
g_HamReg)
    {
        
g_HamReg 1
        client_print
(0print_console"Ham Registered"//Did print
        
RegisterHamFromEntity(Ham_TakeDamageEnt"fw_BossTakeDamage"//Does show damage on knifing
        //RegisterHamFromEntity(Ham_TraceAttack, Ent, "fw_BossTraceAttack")
    
}

    
g_Test Ent



Ghosted 07-18-2018 16:58

Re: Entity only takedamage from knife
 
Quote:

Originally Posted by Celena Luna (Post 2604650)
PHP Code:

public create_revenant()
{
    static 
EntEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    if(!
pev_valid(Ent)) return
    
set_pev(Entpev_originpOrigin//Appear in right Origin
    
    
set_pev(Entpev_anglespv_Origin//Appear in right Angel
    
    
set_pev(Entpev_health30000.0//Correct Health

    
set_pev(Entpev_classnameGIANT_CLASSNAME//Think works so Classname is correct
    
engfunc(EngFunc_SetModelEntGIANT_MODEL//Appear in right model
    
set_pev(Entpev_solidSOLID_BBOX//Touchable

    
set_pev(Entpev_movetypeMOVETYPE_PUSHSTEP//(how to check this?)
    
set_pev(Entpev_gamestate1//Turn on or off doesn't effect
    
set_pev(Entpev_stateSTATE_COMBAT//pev_state = pev_iuser1

    
set_pev(Entpev_takedamage1.0
    static 
Float:Takedamagepev(Entpev_takedamageTakedamage)
    
client_print(0print_chat"TAKEDAMAGE: %f"Takedamage//printed 1.0

    
static Float:Maxs[3], Float:Mins[3]
    
Maxs[0] = 75.0;
    
Maxs[1] = 75.0;
    
Maxs[2] = 120.0
    Mins
[0] = -75.0;
    
Mins[1] = -75.0;
    
Mins[2] = -150.0;
    
entity_set_size(EntMinsMaxs//Can jump above so the hitbox is correct
    
Play_Animation(EntANIME_APPEAR//Did run the animation
    
    
emit_sound(EntCHAN_BODYGiantSounds[3], VOL_NORMATTN_NORM0PITCH_NORM)

    
//static Float:Origin[3]; pev(Ent, pev_origin, Origin)
    //Origin[2] += 36.0
    //Create_Rock(Origin)
    
    
drop_to_floor(Ent)
    
entity_set_float(EntEV_FL_nextthinkget_gametime() + 5.5)
    
    if(!
g_HamReg)
    {
        
g_HamReg 1
        client_print
(0print_console"Ham Registered"//Did print
        
RegisterHamFromEntity(Ham_TakeDamageEnt"fw_BossTakeDamage"//Does show damage on knifing
        //RegisterHamFromEntity(Ham_TraceAttack, Ent, "fw_BossTraceAttack")
    
}

    
g_Test Ent



What? You want me to test ? :crab:

Celena Luna 07-18-2018 17:04

Re: Entity only takedamage from knife
 
Quote:

Originally Posted by Ghosted (Post 2604651)
What? You want me to test ? :crab:

No? I tested myself while waiting for HamletEagle's reply for 2 hours including installing in clean HLDS from steam with clean amx 1.8.3 installed
I wrote the test result in the code. Didn't you see it?

Ghosted 07-18-2018 17:13

Re: Entity only takedamage from knife
 
Tested full code, damage output was 33 by USP, maybe i sucked when spawned revenant (actually i had no revenant model but minion model revenant looked better) but no matters, it worked.

EDIT:
[MoreInfo]
using ReGameDLL, ReHLDS, AMX 1.8.3, Metamod 1.21P

Celena Luna 07-18-2018 17:33

Re: Entity only takedamage from knife
 


Here is my test

Edit:
Metamod-P, Amxmodx 1.8.3

Ghosted 07-18-2018 17:38

Re: Entity only takedamage from knife
 
Quote:

Originally Posted by Celena Luna (Post 2604662)


Here is my test

Edit:
Metamod-P, Amxmodx 1.8.3

:*, :nono: that's about model index, you are shooting up & missing shots cause modelindex size is not so big. I though printed damage was zero.


All times are GMT -4. The time now is 12:51.

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