Solved Didhitscript: #import "data/scripts/anim/Main.c" vs a Function within the Didhitscript.c

Question that is answered or resolved.

Bruce

Active member
Hello everyone,

First of all, I know both methods work, but there got to be some differences in terms of performance / memory issue.
I just wanted to pick out the best method as possible and wanted to understand more about it instead of copy and paste code.
Can someone please take a look at the code below and please advise?
Thank you so much

DidhitScript.c:
Code:
void main()
{
    void AttackType = getlocalvar("attacktype"); // Get attack type
    int KnockDownPower = getlocalvar("drop");
    if(KnockDownPower > 100) {
        void Target = getlocalvar("damagetaker"); // Enenemy
        void TYPE = getentityproperty(Target,"type");
        void HEALTH = getentityproperty(Target, "health");
        if((TYPE == openborconstant("TYPE_enemy") && HEALTH < 1){   
             AFunction();
        }
    }
}

void AFunction()
{
    .....
}


VS


Didhitscript2.c:
Code:
#import "data/scripts/anim/Main.c"
void main()

{
    void AttackType = getlocalvar("attacktype"); // Get attack type
    int KnockDownPower = getlocalvar("drop");
    if(KnockDownPower > 100) {
        void Target = getlocalvar("damagetaker"); // Enenemy
        void TYPE = getentityproperty(Target,"type");
        void HEALTH = getentityproperty(Target, "health");
        if((TYPE == openborconstant("TYPE_enemy") && HEALTH < 1){   
             AFunction();
        }
    }
}

Main.c:
Code:
void AFunction()
{
    .....
}
 
@DCurrent Can it cause some problem with the engine? Because I have many "main.c" in my scripts that concentrate all the code that should be used through #import directive.

Actually, I was thinking of function and got my wires cross. It doesn't matter at all really. Sorry about that. Fixing my answer accordingly.

DC
 
Back
Top Bottom