void SendFlowHitToEntity( EntityId targetId, EntityId shooterId, int damage, const Vec3& pos ) { if (IEntity* pGameRules = CCryAction::GetCryAction()->GetIGameRulesSystem()->GetCurrentGameRulesEntity()) { if (IScriptTable* pGameRulesScript = pGameRules->GetScriptTable()) { IScriptSystem* pSS = pGameRulesScript->GetScriptSystem(); if (pGameRulesScript->GetValueType("CreateHit") == svtFunction && pSS->BeginCall(pGameRulesScript, "CreateHit")) { pSS->PushFuncParam(pGameRulesScript); pSS->PushFuncParam(ScriptHandle(targetId)); pSS->PushFuncParam(ScriptHandle(shooterId)); pSS->PushFuncParam(ScriptHandle(0)); // weapon pSS->PushFuncParam(damage); pSS->PushFuncParam(0); // radius pSS->PushFuncParam(""); // material pSS->PushFuncParam(0); // partID pSS->PushFuncParam("normal"); // type pSS->PushFuncParam(pos); pSS->PushFuncParam(FORWARD_DIRECTION); // dir pSS->PushFuncParam(FORWARD_DIRECTION); // normal pSS->EndCall(); } } } }
//------------------------------------------------------------------------ void CWorkOnTarget::StartWork(IEntity *pEntity) { m_pWeapon->SetBusy(true); m_working=true; m_lastTargetId=pEntity->GetId(); if(CGameRules *pGameRules=g_pGame->GetGameRules()) { if(m_pWeapon->IsServer()) { if(IScriptTable *pScriptTable=pGameRules->GetEntity()->GetScriptTable()) Script::CallMethod(pScriptTable, "StartWork", ScriptHandle(m_lastTargetId), ScriptHandle(m_pWeapon->GetOwnerId()), m_workparams.work_type.c_str()); } } }
//------------------------------------------------------------------------ void CWorkOnTarget::StopWork() { if(m_working) m_pWeapon->PlayAction(m_workactions.postfire.c_str()); m_pWeapon->PlayAction(m_workactions.idle.c_str(), 0, true, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending); m_pWeapon->SetDefaultIdleAnimation(eIGS_FirstPerson, m_workactions.idle.c_str()); if(m_effectId) { int slot = m_pWeapon->GetStats().fp? eIGS_FirstPerson: eIGS_ThirdPerson; m_pWeapon->AttachEffect(slot, m_effectId, false); m_effectId=0; } if(m_soundId != INVALID_SOUNDID) { m_pWeapon->StopSound(m_soundId); m_soundId=INVALID_SOUNDID; } if(CGameRules *pGameRules=g_pGame->GetGameRules()) { if(m_pWeapon->IsServer()) { if(IScriptTable *pScriptTable=pGameRules->GetEntity()->GetScriptTable()) Script::CallMethod(pScriptTable, "StopWork", ScriptHandle(m_pWeapon->GetOwnerId())); } } m_pWeapon->SetBusy(false); m_working=false; m_firing=false; m_lastTargetId=0; }
const char *CHUDTagNames::GetPlayerRank(EntityId uiEntityId) { const char *szRank = NULL; IGameRules *pGameRules = g_pGame->GetGameRules(); int iPlayerRank = 0; if(IScriptTable *pGameRulesTable=pGameRules->GetEntity()->GetScriptTable()) { HSCRIPTFUNCTION pfnGetPlayerRank = NULL; if(pGameRulesTable->GetValue("GetPlayerRank",pfnGetPlayerRank) && pfnGetPlayerRank) { Script::CallReturn(gEnv->pScriptSystem,pfnGetPlayerRank,pGameRulesTable,ScriptHandle(uiEntityId),iPlayerRank); gEnv->pScriptSystem->ReleaseFunc(pfnGetPlayerRank); } } if(iPlayerRank) { static string strRank; static wstring wRank; strRank.Format("@ui_short_rank_%d",iPlayerRank); if(gEnv->pSystem->GetLocalizationManager()->LocalizeLabel(strRank,wRank)) { ConvertWString(wRank,strRank); } szRank = strRank.c_str(); } return szRank; }
//------------------------------------------------------------------------ int CScriptBind_Item::GetOwnerId(IFunctionHandler *pH) { CItem *pItem = GetItem(pH); if (!pItem) return pH->EndFunction(); return pH->EndFunction(ScriptHandle(pItem->GetOwnerId())); }
int CScriptBind_MatchMaking::GetCurrentRegion( IFunctionHandler* pH ) { //TODO: sort out how we want to handle region/country filtering on each platform (C2 PC did no region filtering) int regValue = 0; #if GAMELOBBY_USE_COUNTRY_FILTERING regValue = g_pGame->GetUserRegion(); #endif return pH->EndFunction( ScriptHandle( regValue ) ); }
//------------------------------------------------------------------------ int CScriptBind_Inventory::GetCurrentItemId(IFunctionHandler *pH) { CInventory *pInventory = GetInventory(pH); CRY_ASSERT(pInventory); EntityId currentItemId = pInventory->GetCurrentItem(); if (currentItemId) return pH->EndFunction(ScriptHandle(currentItemId)); return pH->EndFunction(); }
int CScriptBind_MatchMaking::GetCurrentRegion( IFunctionHandler* pH ) { //TODO: sort out how we want to handle region/country filtering on each platform (C2 PC did no region filtering) int regValue = 0; #if USE_CRYLOBBY_GAMESPY regValue = eSR_All; #endif return pH->EndFunction( ScriptHandle( regValue ) ); }
//---------------------------------------------------------------------- int CScriptBind_Inventory::GetGrenadeWeaponByClass(IFunctionHandler *pH, const char *className) { CInventory *pInventory = GetInventory(pH); CRY_ASSERT(pInventory); IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(className); EntityId itemId = pInventory->GetItemByClass(pClass,NULL); if (itemId) return pH->EndFunction(ScriptHandle(itemId)); return pH->EndFunction(); }
//------------------------------------------------------------------------ void CScriptBind_Inventory::AttachTo(CInventory* pInventory) { IScriptTable *pScriptTable = pInventory->GetEntity()->GetScriptTable(); if (pScriptTable) { SmartScriptTable thisTable(m_pSS); thisTable->SetValue("__this", ScriptHandle(pInventory)); thisTable->Delegate(GetMethodsTable()); pScriptTable->SetValue("inventory", thisTable); } }
//------------------------------------------------------------------------ void CScriptBind_Item::AttachTo(CItem *pItem) { IScriptTable *pScriptTable = pItem->GetEntity()->GetScriptTable(); if (pScriptTable) { SmartScriptTable thisTable(m_pSS); thisTable->SetValue("__this", ScriptHandle(pItem->GetEntityId())); thisTable->Delegate(GetMethodsTable()); pScriptTable->SetValue("item", thisTable); } }
//------------------------------------------------------------------------ void CScriptBind_Actor::AttachTo(CActor *pActor) { IScriptTable *pScriptTable = pActor->GetEntity()->GetScriptTable(); if (pScriptTable) { SmartScriptTable thisTable(m_pSS); thisTable->SetValue("__this", ScriptHandle(pActor->GetEntityId())); thisTable->Delegate(GetMethodsTable()); pScriptTable->SetValue("actor", thisTable); } }
//------------------------------------------------------------------------ void CScriptBind_Weapon::AttachTo(CWeapon *pWeapon) { IScriptTable *pScriptTable = ((CItem *)pWeapon)->GetEntity()->GetScriptTable(); if (pScriptTable) { SmartScriptTable thisTable(m_pSS); thisTable->SetValue("__this", ScriptHandle(pWeapon->GetEntityId())); thisTable->Delegate(GetMethodsTable()); pScriptTable->SetValue("weapon", thisTable); } }
void CScriptBind_NetworkBuilding::AttachTo( CNetworkBuilding *pInteractiveObject ) { IScriptTable *pScriptTable = pInteractiveObject->GetEntity()->GetScriptTable(); if (pScriptTable) { SmartScriptTable thisTable(m_pSS); thisTable->SetValue("__this", ScriptHandle(pInteractiveObject->GetEntityId())); thisTable->Delegate(GetMethodsTable()); pScriptTable->SetValue("networkBuilding", thisTable); } m_NetworkBuildingMap.insert(TNetworkBuildingMap::value_type(pInteractiveObject->GetEntityId(), pInteractiveObject)); }
//------------------------------------------------------------------------ void CScriptBind_Vehicle::AttachTo(IVehicle *pVehicle) { IScriptTable *pScriptTable = pVehicle->GetEntity()->GetScriptTable(); if (!pScriptTable) return; SmartScriptTable thisTable(gEnv->pScriptSystem); thisTable->SetValue("vehicleId", ScriptHandle(pVehicle->GetEntityId())); thisTable->Delegate(GetMethodsTable()); pScriptTable->SetValue("vehicle", thisTable); SmartScriptTable seatTable(gEnv->pScriptSystem); pScriptTable->SetValue("Seats", seatTable); }
//------------------------------------------------------------------------ bool CScriptControlledPhysics::Init(IGameObject *pGameObject) { CScriptableBase::Init(gEnv->pScriptSystem, gEnv->pSystem, 1); SetGameObject(pGameObject); pGameObject->EnablePhysicsEvent(true, eEPE_OnPostStepLogged); RegisterGlobals(); RegisterMethods(); SmartScriptTable thisTable(gEnv->pScriptSystem); thisTable->SetValue("__this", ScriptHandle(GetEntityId())); thisTable->Delegate(GetMethodsTable()); GetEntity()->GetScriptTable()->SetValue("scp", thisTable); return true; }
//------------------------------------------------------------------------ bool CWorkOnTarget::WorkOnTarget(IEntity *pEntity, float frameTime) { if (!m_pWeapon->IsServer()) return false; if (CGameRules *pGameRules=g_pGame->GetGameRules()) { if (IScriptTable *pScriptTable=pGameRules->GetEntity()->GetScriptTable()) { HSCRIPTFUNCTION pfnWork=0; if (pScriptTable->GetValueType("Work")==svtFunction && pScriptTable->GetValue("Work", pfnWork)) { bool result=false; Script::CallReturn(gEnv->pScriptSystem, pfnWork, pScriptTable, ScriptHandle(m_pWeapon->GetOwnerId()), m_workparams.amount, frameTime, result); gEnv->pScriptSystem->ReleaseFunc(pfnWork); return result; } } } return false; }
bool CAIGroupProxy::CallNotification(IScriptTable* table, const char* notification, uint32 notificationID, IScriptTable* sender) { if (table) { HSCRIPTFUNCTION functionToCall = 0; if (table->GetValue(notification, functionToCall) && functionToCall) { gEnv->pScriptSystem->BeginCall(functionToCall); gEnv->pScriptSystem->PushFuncParam(table); gEnv->pScriptSystem->PushFuncParam(m_script); gEnv->pScriptSystem->PushFuncParam(ScriptHandle(notificationID)); gEnv->pScriptSystem->PushFuncParam(sender); gEnv->pScriptSystem->EndCall(); gEnv->pScriptSystem->ReleaseFunc(functionToCall); return true; } } return false; }
int CScriptBind_MatchMaking::GetCurrentPlaylist( IFunctionHandler* pH ) { return pH->EndFunction( ScriptHandle( (int)GameLobbyData::GetPlaylistId() ) ); }
//------------------------------------------------------------------------ IEntity *CWorkOnTarget::CanWork() { static Vec3 pos,dir; static ICVar* pAimDebug = gEnv->pConsole->GetCVar("g_aimdebug"); CActor *pActor=m_pWeapon->GetOwnerActor(); static IPhysicalEntity* pSkipEntities[10]; int nSkip = CSingle::GetSkipEntities(m_pWeapon, pSkipEntities, 10); IEntity *pEntity=0; float range=m_workparams.range; IMovementController * pMC = pActor ? pActor->GetMovementController() : 0; if (pMC) { SMovementState info; pMC->GetMovementState(info); pos = info.weaponPosition; if (!pActor->IsPlayer()) { dir = range * (info.fireTarget-pos).normalized(); } else { dir = range * info.fireDirection; // marcok: leave this alone if (g_pGameCVars->goc_enable && pActor->IsClient()) { CPlayer *pPlayer = (CPlayer*)pActor; pos = pPlayer->GetViewMatrix().GetTranslation(); } } } else { assert(0); } primitives::sphere sphere; sphere.center = pos; sphere.r = m_workparams.radius; Vec3 end = pos+dir; geom_contact *pContact=0; float dst=gEnv->pPhysicalWorld->PrimitiveWorldIntersection(sphere.type, &sphere, end-sphere.center, ent_all, &pContact, 0, (geom_colltype_player<<rwi_colltype_bit)|rwi_stop_at_pierceable, 0, 0, 0, pSkipEntities, nSkip); if (pContact && dst>=0.0f) { IPhysicalEntity *pCollider = gEnv->pPhysicalWorld->GetPhysicalEntityById(pContact->iPrim[0]); if(pCollider && pCollider->GetiForeignData() == PHYS_FOREIGN_ID_ENTITY) { if (pEntity = static_cast<IEntity *>(pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY))) { if (CGameRules *pGameRules=g_pGame->GetGameRules()) { if (IScriptTable *pScriptTable=pGameRules->GetEntity()->GetScriptTable()) { HSCRIPTFUNCTION pfnCanWork=0; if (pScriptTable->GetValueType("CanWork")==svtFunction && pScriptTable->GetValue("CanWork", pfnCanWork)) { bool result=false; Script::CallReturn(gEnv->pScriptSystem, pfnCanWork, pScriptTable, ScriptHandle(pEntity->GetId()), ScriptHandle(m_pWeapon->GetOwnerId()), m_workparams.work_type.c_str(), result); gEnv->pScriptSystem->ReleaseFunc(pfnCanWork); if (result) return pEntity; } } } } } } return 0; }
int CScriptBind_MatchMaking::GetCurrentMatchMakingVersionNum( IFunctionHandler* pH ) { return pH->EndFunction( ScriptHandle( GameLobbyData::GetVersion() ) ); }
//------------------------------------------------------------------------ void CGameRules::ServerSimpleHit(const SimpleHitInfo &simpleHitInfo) { switch (simpleHitInfo.type) { case 0: // tag { if (!simpleHitInfo.targetId) return; // tagged entities are temporary in MP, not in SP. // bool temp = gEnv->bMultiplayer; //kirill: - not anymore - design says must stay on bool temp = false; AddTaggedEntity(simpleHitInfo.shooterId, simpleHitInfo.targetId, temp); } break; case 1: // tac { if (!simpleHitInfo.targetId) return; CActor *pActor = (CActor *)gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(simpleHitInfo.targetId); if (pActor && pActor->CanSleep()) { pActor->Fall(Vec3(0.0f,0.0f,0.0f),false,simpleHitInfo.value); //This is only used in SP by the player, so don't need further checks CPlayer* pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor()); if(pPlayer) pPlayer->PlaySound(CPlayer::ESound_TacBulletFeedBack,true); } } break; case 0xe: // freeze { if (!simpleHitInfo.targetId) return; CActor *pActor=GetActorByEntityId(simpleHitInfo.targetId); if (pActor && pActor->IsPlayer() && pActor->GetActorClass()==CPlayer::GetActorClassType()) { CPlayer *pPlayer=static_cast<CPlayer *>(pActor); if (CNanoSuit *pSuit=pPlayer->GetNanoSuit()) if (pSuit->IsInvulnerable()) return; } // call OnFreeze bool allow=true; if (m_serverStateScript.GetPtr() && m_serverStateScript->GetValueType("OnFreeze")==svtFunction) { HSCRIPTFUNCTION func=0; m_serverStateScript->GetValue("OnFreeze", func); Script::CallReturn(m_serverStateScript->GetScriptSystem(), func, m_script, ScriptHandle(simpleHitInfo.targetId), ScriptHandle(simpleHitInfo.shooterId), ScriptHandle(simpleHitInfo.weaponId), simpleHitInfo.value, allow); gEnv->pScriptSystem->ReleaseFunc(func); } if (!allow) return; if (IEntity *pEntity=gEnv->pEntitySystem->GetEntity(simpleHitInfo.targetId)) { IScriptTable *pScriptTable=pEntity->GetScriptTable(); // call OnFrost if (pScriptTable && pScriptTable->GetValueType("OnFrost")==svtFunction) { HSCRIPTFUNCTION func=0; pScriptTable->GetValue("OnFrost", func); Script::Call(pScriptTable->GetScriptSystem(), func, pScriptTable, ScriptHandle(simpleHitInfo.shooterId), ScriptHandle(simpleHitInfo.weaponId), simpleHitInfo.value); gEnv->pScriptSystem->ReleaseFunc(func); } FreezeEntity(simpleHitInfo.targetId, true, true, simpleHitInfo.value>0.999f); } } break; default: assert(!"Unknown Simple Hit type!"); } }
int CScriptBind_Physics::RayWorldIntersection(IFunctionHandler *pH) { assert(pH->GetParamCount()>=3 && pH->GetParamCount()<=7); Vec3 vPos(0,0,0); Vec3 vDir(0,0,0); ScriptHandle skipId1; ScriptHandle skipId2; IEntity *skipEnt1 = 0; IEntity *skipEnt2 = 0; int nMaxHits,iEntTypes=ent_all; SmartScriptTable hitTable(m_pSS); if (!pH->GetParams(vPos,vDir,nMaxHits,iEntTypes)) return pH->EndFunction(); int nParams = pH->GetParamCount(); if (nParams >= 5 && pH->GetParamType(5) != svtNull && pH->GetParam(5, skipId1)) skipEnt1 = gEnv->pEntitySystem->GetEntity((EntityId)skipId1.n); if (nParams >= 6 && pH->GetParamType(6) != svtNull && pH->GetParam(6, skipId2)) skipEnt2 = gEnv->pEntitySystem->GetEntity((EntityId)skipId2.n); bool bHitTablePassed = (nParams >= 7 ); if(bHitTablePassed) pH->GetParam(7, hitTable); if (nMaxHits>10) nMaxHits=10; ray_hit RayHit[10]; //filippo: added support for skip certain entities. int skipIdCount = 0; IPhysicalEntity *skipPhys[2] = {0,0}; if (skipEnt1) { ++skipIdCount; skipPhys[0] = skipEnt1->GetPhysics(); } if (skipEnt2) { ++skipIdCount; skipPhys[1] = skipEnt2->GetPhysics(); } Vec3 src = vPos; Vec3 dir = vDir; int nHits= m_pSystem->GetIPhysicalWorld()->RayWorldIntersection(src, dir, iEntTypes, geom_colltype0<<rwi_colltype_bit | rwi_stop_at_pierceable, RayHit, nMaxHits,skipPhys,skipIdCount); for (int i=0;i<nHits;i++) { SmartScriptTable pHitObj(m_pSS); ray_hit &Hit=RayHit[i]; pHitObj->SetValue("pos",Hit.pt); pHitObj->SetValue("normal",Hit.n); pHitObj->SetValue("dist", Hit.dist); pHitObj->SetValue("surface", Hit.surface_idx); IEntity * pEntity = (IEntity*) Hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY); if (pEntity) pHitObj->SetValue("entity", pEntity->GetScriptTable()); else { if(Hit.pCollider->GetiForeignData()==PHYS_FOREIGN_ID_STATIC) { IRenderNode * pRN = (IRenderNode*)Hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_STATIC); if (pRN) pHitObj->SetValue("renderNode", ScriptHandle(pRN)); } else if(Hit.pCollider->GetiForeignData()==PHYS_FOREIGN_ID_FOLIAGE) { IRenderNode * pRN = ((IFoliage*)Hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_FOLIAGE))->GetIRenderNode(); if (pRN) pHitObj->SetValue("renderNode", ScriptHandle(pRN)); } } hitTable->SetAt(i+1, pHitObj); } if (bHitTablePassed ) return pH->EndFunction(nHits); return pH->EndFunction(*hitTable); }
//------------------------------------------------------------------------ void CGameRules::ServerSimpleHit(const SimpleHitInfo &simpleHitInfo) { if (my->CallHook( "OnEntityDamage", oohh::GetEntityFromId(simpleHitInfo.targetId), oohh::GetEntityFromId(simpleHitInfo.weaponId), oohh::GetEntityFromId(simpleHitInfo.shooterId), simpleHitInfo.value, Vec3(0,0,0), Vec3(0,0,0) )) { if (true) return; } switch (simpleHitInfo.type) { case 0: // tag { if (!simpleHitInfo.targetId) return; // tagged entities are temporary in MP, not in SP. bool temp = gEnv->bMultiplayer; AddTaggedEntity(simpleHitInfo.shooterId, simpleHitInfo.targetId, temp); } break; case 1: // tac { if (!simpleHitInfo.targetId) return; CActor *pActor = (CActor *)gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(simpleHitInfo.targetId); if (pActor && pActor->CanSleep()) pActor->Fall(Vec3(0.0f,0.0f,0.0f),simpleHitInfo.value); } break; case 0xe: // freeze { if (!simpleHitInfo.targetId) return; // call OnFreeze bool allow=true; if (m_serverStateScript.GetPtr() && m_serverStateScript->GetValueType("OnFreeze")==svtFunction) { HSCRIPTFUNCTION func=0; m_serverStateScript->GetValue("OnFreeze", func); Script::CallReturn(m_serverStateScript->GetScriptSystem(), func, m_script, ScriptHandle(simpleHitInfo.targetId), ScriptHandle(simpleHitInfo.shooterId), ScriptHandle(simpleHitInfo.weaponId), simpleHitInfo.value, allow); gEnv->pScriptSystem->ReleaseFunc(func); } if (!allow) return; if (IEntity *pEntity=gEnv->pEntitySystem->GetEntity(simpleHitInfo.targetId)) { IScriptTable *pScriptTable=pEntity->GetScriptTable(); // call OnFrost if (pScriptTable && pScriptTable->GetValueType("OnFrost")==svtFunction) { HSCRIPTFUNCTION func=0; pScriptTable->GetValue("OnFrost", func); Script::Call(pScriptTable->GetScriptSystem(), func, pScriptTable, ScriptHandle(simpleHitInfo.shooterId), ScriptHandle(simpleHitInfo.weaponId), simpleHitInfo.value); gEnv->pScriptSystem->ReleaseFunc(func); } FreezeEntity(simpleHitInfo.targetId, true, true, simpleHitInfo.value>0.999f); } } break; default: assert(!"Unknown Simple Hit type!"); } }
//------------------------------------------------------------------------ IEntity *CWorkOnTarget::CanWork() { static Vec3 pos,dir; static ICVar *pAimDebug = gEnv->pConsole->GetCVar("g_aimdebug"); CActor *pActor=m_pWeapon->GetOwnerActor(); static IPhysicalEntity *pSkipEntities[10]; int nSkip = CSingle::GetSkipEntities(m_pWeapon, pSkipEntities, 10); IEntity *pEntity=0; float range=m_workparams.range; IMovementController *pMC = pActor ? pActor->GetMovementController() : 0; if(pMC) { SMovementState info; pMC->GetMovementState(info); pos = info.weaponPosition; if(!pActor->IsPlayer()) { dir = range * (info.fireTarget-pos).normalized(); } else { dir = range * info.fireDirection; // marcok: leave this alone if(g_pGameCVars->goc_enable && pActor->IsClient()) { CPlayer *pPlayer = (CPlayer *)pActor; pos = pPlayer->GetViewMatrix().GetTranslation(); } } } else { assert(0); } static ray_hit hit; if(gEnv->pPhysicalWorld->RayWorldIntersection(pos, dir, ent_all, rwi_stop_at_pierceable|rwi_ignore_back_faces, &hit, 1, pSkipEntities, nSkip)) { if(hit.pCollider && hit.pCollider->GetiForeignData() == PHYS_FOREIGN_ID_ENTITY) { if(pEntity = (IEntity *)hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY)) { if(CGameRules *pGameRules=g_pGame->GetGameRules()) { if(IScriptTable *pScriptTable=pGameRules->GetEntity()->GetScriptTable()) { HSCRIPTFUNCTION pfnCanWork=0; if(pScriptTable->GetValueType("CanWork")==svtFunction && pScriptTable->GetValue("CanWork", pfnCanWork)) { bool result=false; Script::CallReturn(gEnv->pScriptSystem, pfnCanWork, pScriptTable, ScriptHandle(pEntity->GetId()), ScriptHandle(m_pWeapon->GetOwnerId()), m_workparams.work_type.c_str(), result); gEnv->pScriptSystem->ReleaseFunc(pfnCanWork); if(result) return pEntity; } } } } } } return 0; }