Open pandaro opened 7 years ago
i have searched around for a lot of time, I can not get to the root of the problem, sorry.
continuing to search: UnitDamaged is not called at all, from ai.lua , aibase.lua , unit.lua , unithandler.lua , behaviour.lua , is never called in lua so i have try to move up, in to the src but my c/c++ skill are superbasic. this is the function inside the test.cpp:
void CTestAI::UnitDamaged(IUnit* unit, IUnit* attacker, IDamage::Ptr damage){
lua_getglobal(this->L, "ai");
lua_getfield(this->L, -1, "UnitDamaged");
lua_getglobal(this->L, "ai");
SWIG_NewPointerObj(this->L,unit,unittype,0);
SWIG_NewPointerObj(this->L,attacker,unittype,0);
IDamage::Ptr* ptrptr = new IDamage::Ptr(damage);
SWIG_NewPointerObj(this->L,ptrptr,damagePtr,1);
if(lua_isfunction(this->L,-4)){
this->lua_epcall( 3 );
} else {
this->game->SendToConsole( "ShardCPP Warning: ai:UnitDamaged failed isfunction test, make sure it's defined in lua" );
}
}
i have try to skip the if statement where: if(lua_isfunction(this->L,-4)){
and call direct : this->lua_epcall( 3 );
the error give is a bit criptic:
[f=0000146] <SkirmishAI: Shard dev (team 1)>: attempt to call a table value
stack traceback:
[C]: ?
[C]: ?
i have then try to move me to IDamage.cpp and IDamage.h but here the situation is much complex than my actually capability can handle. I can just help in debug
I suspect the stack numbers are off by 1, specifically the -4
, it may need to be -5
, as there are 3 parameters, a 4th referring to self
and then the 5th being the function to be called
<SkirmishAI: Shard dev (team 1)>: ShardCPP Warning: ai:UnitDamaged failed isfunction test, make sure it's defined in lua