diff --git a/Changelog.txt b/Changelog.txt index a72642778..39b42cc58 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3985,3 +3985,43 @@ Added: 'H' shortcut for variables to get the value as hexadecimal. TALKMODE_SPELL = 10 // Used by spells TALKMODE_GUILD = 13 // Used by guild chat (client shortcut: \) TALKMODE_ALLIANCE = 14 // Used by alliance chat (client shortcut: shift+\) + +20-12-2024, canerksk +[Sphere.ini] +- Removed: (Action require by admin and must update this) + EventsPet=e_npc_generic_event + EventsPlayer=e_player_generic_event +- Added: Event definitions have been made more extensive. + // Events related to all NPCs + EventsNPC=e_npc_all + + // Events related to all animals (brain_animal without mountables) + EventsNPCAnimal=e_npc_animals + + // Events related to all monsters (brain_monster, brain_dragon, brain_berserk) + EventsNPCMonster=e_npc_monsters + + // Events related to all animals (brain_animal with mountable) + EventsNPCMountable=e_npc_mountables + + // Events related to all shopkeepers (brain_vendor, brain_stable, brain_healer) + EventsNPCShop=e_npc_shopkeepers + + // Events related to all clients (player and staff) + EventsClient=e_client_all + + // Events related to all staff (if plevel is higher than 1) + EventsClientStaff=e_client_staffs + + // Events related to all players (if the plevel is lower than 1) + EventsClientPlayer=e_client_players + + // Events related to all regions + //EventsRegion=e_region_all + + // Events related to all items + EventsItem=ei_items + + // Events related to all weapons + EventsItemWeapon=ei_item_weapons + diff --git a/src/game/CServerConfig.cpp b/src/game/CServerConfig.cpp index a39727897..3128e1e17 100644 --- a/src/game/CServerConfig.cpp +++ b/src/game/CServerConfig.cpp @@ -548,9 +548,16 @@ enum RC_TYPE RC_ERALIMITGEAR, // _iEraLimitGear RC_ERALIMITLOOT, // _iEraLimitLoot RC_ERALIMITPROPS, // _iEraLimitProps - RC_EVENTSITEM, // m_sEventsItem - RC_EVENTSPET, // m_sEventsPet - RC_EVENTSPLAYER, // m_sEventsPlayer + RC_EVENTSCLIENT, // m_sEventsClient + RC_EVENTSCLIENTPLAYER, // m_sEventsClientPlayer + RC_EVENTSCLIENTSTAFF, // m_sEventsClientStaff + RC_EVENTSITEM, // m_sEventsItem + RC_EVENTSITEMWEAPON, // m_sEventsItemWeapon + RC_EVENTSNPC, // m_sEventsNpc + RC_EVENTSNPCANIMAL, // m_sEventsNpcAnimal + RC_EVENTSNPCMONSTER, // m_sEventsNPCMonster + RC_EVENTSNPCMOUNTABLE, // m_sEventsNPCMountable + RC_EVENTSNPCSHOP, // m_sEventsNPCShop RC_EVENTSREGION, // m_sEventsRegion RC_EXPERIENCEKOEFPVM, // m_iExperienceKoefPVM RC_EXPERIENCEKOEFPVP, // m_iExperienceKoefPVP @@ -842,9 +849,16 @@ const CAssocReg CServerConfig::sm_szLoadKeys[RC_QTY + 1] { "ERALIMITGEAR", { ELEM_BYTE, static_castOFFSETOF(CServerConfig,_iEraLimitGear) }}, { "ERALIMITLOOT", { ELEM_BYTE, static_castOFFSETOF(CServerConfig,_iEraLimitLoot) }}, { "ERALIMITPROPS", { ELEM_BYTE, static_castOFFSETOF(CServerConfig,_iEraLimitProps) }}, + { "EVENTSCLIENT", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsClient) } }, + { "EVENTSCLIENTPLAYER", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsClientPlayer) } }, + { "EVENTSCLIENTSTAFF", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsClientStaff) } }, { "EVENTSITEM", { ELEM_CSTRING, static_castOFFSETOF(CServerConfig,m_sEventsItem) }}, - { "EVENTSPET", { ELEM_CSTRING, static_castOFFSETOF(CServerConfig,m_sEventsPet) }}, - { "EVENTSPLAYER", { ELEM_CSTRING, static_castOFFSETOF(CServerConfig,m_sEventsPlayer) }}, + { "EVENTSITEMWEAPON", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsItemWeapon) } }, + { "EVENTSNPC", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsNPC) } }, + { "EVENTSNPCANIMAL", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsNPCAnimal) } }, + { "EVENTSNPCMONSTER", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsNPCMonster) } }, + { "EVENTSNPCMOUNTABLE", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsNPCMountable) } }, + { "EVENTSNPCSHOP", { ELEM_CSTRING, static_cast OFFSETOF(CServerConfig, m_sEventsNPCShop) } }, { "EVENTSREGION", { ELEM_CSTRING, static_castOFFSETOF(CServerConfig,m_sEventsRegion) }}, { "EXPERIENCEKOEFPVM", { ELEM_INT, static_castOFFSETOF(CServerConfig,m_iExperienceKoefPVM) }}, { "EXPERIENCEKOEFPVP", { ELEM_INT, static_castOFFSETOF(CServerConfig,m_iExperienceKoefPVP) }}, @@ -4818,7 +4832,10 @@ bool CServerConfig::Load( bool fResync ) pRegion->MakeRegionDefname(); } - // parse eventsitem + ///////////////////// + // parse eventsitem + ///////////////////// + // all items m_iEventsItemLink.clear(); if ( ! m_sEventsItem.IsEmpty() ) { @@ -4826,21 +4843,83 @@ bool CServerConfig::Load( bool fResync ) m_iEventsItemLink.r_LoadVal(script, RES_EVENTS); } - // parse eventspet - m_pEventsPetLink.clear(); - if ( ! m_sEventsPet.IsEmpty() ) - { - CScript script("EVENTSPET", m_sEventsPet); - m_pEventsPetLink.r_LoadVal(script, RES_EVENTS); - } + // all weapons + m_iEventsItemWeaponLink.clear(); + if (!m_sEventsItemWeapon.IsEmpty()) + { + CScript script("EVENTSITEMWEAPON", m_sEventsItemWeapon); + m_iEventsItemWeaponLink.r_LoadVal(script, RES_EVENTS); + } - // parse eventsplayer - m_pEventsPlayerLink.clear(); - if ( ! m_sEventsPlayer.IsEmpty() ) - { - CScript script("EVENTSPLAYER", m_sEventsPlayer); - m_pEventsPlayerLink.r_LoadVal(script, RES_EVENTS); - } + ///////////////////// + // parse eventsnpc + ///////////////////// + // all npcs + m_pEventsNPCLink.clear(); + if (!m_sEventsNPC.IsEmpty()) + { + CScript script("EVENTSNPC", m_sEventsNPC); + m_pEventsNPCLink.r_LoadVal(script, RES_EVENTS); + } + + // all animals + m_pEventsNPCAnimalLink.clear(); + if (!m_sEventsNPCAnimal.IsEmpty()) + { + CScript script("EVENTSNPCANIMAL", m_sEventsNPCAnimal); + m_pEventsNPCAnimalLink.r_LoadVal(script, RES_EVENTS); + } + // all monsters + m_pEventsNPCMonsterLink.clear(); + if (!m_sEventsNPCMonster.IsEmpty()) + { + CScript script("EVENTSNPCMONSTER", m_sEventsNPCMonster); + m_pEventsNPCMonsterLink.r_LoadVal(script, RES_EVENTS); + } + + // all mountables + m_pEventsNPCMountableLink.clear(); + if (!m_sEventsNPCMountable.IsEmpty()) + { + CScript script("EVENTSNPCMOUNTABLE", m_sEventsNPCMountable); + m_pEventsNPCMountableLink.r_LoadVal(script, RES_EVENTS); + } + + // all shopkeepers + m_pEventsNPCShopLink.clear(); + if (!m_sEventsNPCShop.IsEmpty()) + { + CScript script("EVENTSNPCSHOP", m_sEventsNPCShop); + m_pEventsNPCShopLink.r_LoadVal(script, RES_EVENTS); + } + + ///////////////////// + // parse eventsClient + ///////////////////// + + // allClient (players or staffs) + m_pEventsClientLink.clear(); + if (!m_sEventsClient.IsEmpty()) + { + CScript script("EVENTSCLIENT", m_sEventsClient); + m_pEventsClientLink.r_LoadVal(script, RES_EVENTS); + } + + // all players + m_pEventsClientPlayerLink.clear(); + if (!m_sEventsClientPlayer.IsEmpty()) + { + CScript script("EVENTSCLIENTPLAYER", m_sEventsClientPlayer); + m_pEventsClientPlayerLink.r_LoadVal(script, RES_EVENTS); + } + + // all staffs + m_pEventsClientStaffLink.clear(); + if (!m_sEventsClientStaff.IsEmpty()) + { + CScript script("EVENTSCLIENTSTAFF", m_sEventsClientStaff); + m_pEventsClientStaffLink.r_LoadVal(script, RES_EVENTS); + } // parse eventsregion m_pEventsRegionLink.clear(); diff --git a/src/game/CServerConfig.h b/src/game/CServerConfig.h index 6e7864c8c..5a31d9578 100644 --- a/src/game/CServerConfig.h +++ b/src/game/CServerConfig.h @@ -434,17 +434,60 @@ extern class CServerConfig : public CResourceHolder CSString m_sDumpAccPackets; #endif - CSString m_sEventsPet; // Key to add Events to all pets. - CResourceRefArray m_pEventsPetLink; // EventsPet. - - CSString m_sEventsPlayer; // Key to add Events to all players. - CResourceRefArray m_pEventsPlayerLink; // EventsPlayer. - - CSString m_sEventsRegion; // Key to add Events to all regions. - CResourceRefArray m_pEventsRegionLink; // EventsRegion. - - CSString m_sEventsItem; // Key to add Events to all items. - CResourceRefArray m_iEventsItemLink; // EventsItem. + + ////////////////////// + // Npcs + ////////////////////// + // EVENTSNPC + CSString m_sEventsNPC; // Key to add Events to all npc. + CResourceRefArray m_pEventsNPCLink; // m_sEventsNPC. + + // EVENTSNPCANIMAL + CSString m_sEventsNPCAnimal; // Key to add Events to all animals + CResourceRefArray m_pEventsNPCAnimalLink; // m_sEventsNPCAnimal. + + // EVENTSNPCMONSTER + CSString m_sEventsNPCMonster; // Key to add Events to all monsters (brain_monster, brain_dragon, brain_berserk). + CResourceRefArray m_pEventsNPCMonsterLink; // m_sEventsNPCMonster. + + // EVENTSNPCMOUNTABLE + CSString m_sEventsNPCMountable; // Key to add Events to all mountables (brain_animal). + CResourceRefArray m_pEventsNPCMountableLink; // EventsNPCMountable. + + // EVENTSNPCSHOP + CSString m_sEventsNPCShop; // Key to add Events to all shopkeepers (brain_vendor). + CResourceRefArray m_pEventsNPCShopLink; // EventsNPCShop. + + ////////////////////// + // Clients + ////////////////////// + // EVENTSCLIENT + CSString m_sEventsClient; // Key to add Events to all players and staff. + CResourceRefArray m_pEventsClientLink; // EventsClient. + + // EVENTSCLIENTSTAFF + CSString m_sEventsClientStaff; // Key to add Events to all players. + CResourceRefArray m_pEventsClientStaffLink; // EventsClientStaff. + + // EVENTSCLIENTPLAYER + CSString m_sEventsClientPlayer; // Key to add Events to all players. + CResourceRefArray m_pEventsClientPlayerLink; // EventsClientPlayer. + + ////////////////////// + // Regions + ////////////////////// + CSString m_sEventsRegion; // Key to add Events to all regions. + CResourceRefArray m_pEventsRegionLink; // EventsRegion. + + ////////////////////// + // Items + ////////////////////// + CSString m_sEventsItem; // Key to add Events to all items. + CResourceRefArray m_iEventsItemLink; // EventsItem. + + // Weapon + CSString m_sEventsItemWeapon; // Key to add Events to all items. + CResourceRefArray m_iEventsItemWeaponLink; //EventsItemWeapon. // Third Party Tools CSString m_sStripPath; // Strip Path for TNG and Axis. diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index d6bf5d4e1..2ba4b1bc7 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -5602,48 +5602,191 @@ TRIGRET_TYPE CChar::OnTrigger( lpctstr pszTrigName, CTextConsole * pSrc, CScript } } - // 5) EVENTSPET triggers for npcs - if (m_pNPC != nullptr) - { - EXC_SET_BLOCK("NPC triggers - EVENTSPET"); // EVENTSPET (constant events of NPCs set from sphere.ini) - for (size_t i = 0; i < g_Cfg.m_pEventsPetLink.size(); ++i) - { - CResourceLink * pLink = g_Cfg.m_pEventsPetLink[i].GetRef(); - if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) - continue; + // NPCs + if (m_pNPC != nullptr) + { + // 5) EVENTSNPC triggers for npcs + // All Npcs + EXC_SET_BLOCK("NPC triggers - EVENTSNPC"); // EVENTSNPC (constant events of NPCs set from sphere.ini) + for (size_t i = 0; i < g_Cfg.m_pEventsNPCLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; - CResourceLock s; - if (!pLink->ResourceLock(s)) - continue; + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; - executedEvents.emplace(pLink); - iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); - if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) - goto stopandret; - } - } + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } - // 6) EVENTSPLAYER triggers for players - if ( m_pPlayer != nullptr ) - { - // EVENTSPLAYER triggers (constant events of players set from sphere.ini) - EXC_SET_BLOCK("chardef triggers - EVENTSPLAYER"); - for ( size_t i = 0; i < g_Cfg.m_pEventsPlayerLink.size(); ++i ) - { - CResourceLink *pLink = g_Cfg.m_pEventsPlayerLink[i].GetRef(); - if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) - continue; + ITEMID_TYPE memoryId = Horse_GetMountItemID(); - CResourceLock s; - if (!pLink->ResourceLock(s)) - continue; + // 6) EVENTSNPCANIMAL triggers for all animals npc (without mountables) + if (m_pNPC->m_Brain == NPCBRAIN_ANIMAL && memoryId <= ITEMID_NOTHING) + { + EXC_SET_BLOCK("NPC triggers - EVENTSNPCANIMAL"); + for (size_t i = 0; i < g_Cfg.m_pEventsNPCAnimalLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCAnimalLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + + // 7) EVENTSNPCMOUNTABLE triggers for all mountables npc + if (memoryId > ITEMID_NOTHING) + { + EXC_SET_BLOCK("NPC triggers - EVENTSNPCMOUNTABLE"); + for (size_t i = 0; i < g_Cfg.m_pEventsNPCMountableLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCMountableLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + + // 8) EVENTSNPCMONSTER triggers for all monsters npc + // Monsters + EXC_SET_BLOCK("NPC triggers - EVENTSNPCMONSTER"); + if (m_pNPC->m_Brain == NPCBRAIN_MONSTER || m_pNPC->m_Brain == NPCBRAIN_BERSERK || m_pNPC->m_Brain == NPCBRAIN_DRAGON) + { + for (size_t i = 0; i < g_Cfg.m_pEventsNPCMonsterLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCMonsterLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + + // Shopkeepers + // 9) EVENTSNPCSHOP triggers for all shopkeepers + EXC_SET_BLOCK("NPC triggers - EVENTSNPCSHOP"); + if (m_pNPC->m_Brain == NPCBRAIN_VENDOR || m_pNPC->m_Brain == NPCBRAIN_STABLE || m_pNPC->m_Brain == NPCBRAIN_HEALER) + { + for (size_t i = 0; i < g_Cfg.m_pEventsNPCShopLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCShopLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + + // Guards + /* + EXC_SET_BLOCK("NPC triggers - EVENTSNPCGUARD"); + if (m_pNPC->m_Brain == NPCBRAIN_GUARD) + { + } + */ + } + + // Chars + if (m_pPlayer != nullptr) + { + // 10) EVENTSCLIENT triggers for chars (players or staffs) + EXC_SET_BLOCK("chardef triggers - EVENTSCLIENT"); + for (size_t i = 0; i < g_Cfg.m_pEventsClientLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsClientLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + + // 11) EVENTSCLIENTPLAYER triggers for playerss + if (GetPrivLevel() <= PLEVEL_Player) + { + // EVENTSCLIENTPLAYER triggers (constant events of players set from sphere.ini) + EXC_SET_BLOCK("chardef triggers - EVENTSCLIENTPLAYER"); + for (size_t i = 0; i < g_Cfg.m_pEventsClientPlayerLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsClientPlayerLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + + // 12) EVENTSCLIENTSTAFF triggers for staffs + if (GetPrivLevel() >= PLEVEL_Counsel) + { + // EVENTSCLIENTSTAFF triggers (constant events of players set from sphere.ini) + EXC_SET_BLOCK("chardef triggers - EVENTSCLIENTSTAFF"); + for (size_t i = 0; i < g_Cfg.m_pEventsClientStaffLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsClientStaffLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + } - executedEvents.emplace(pLink); - iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); - if ( iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT ) - goto stopandret; - } - } } stopandret: diff --git a/src/game/chars/CCharNPC.cpp b/src/game/chars/CCharNPC.cpp index 8f855ef37..b386804e1 100644 --- a/src/game/chars/CCharNPC.cpp +++ b/src/game/chars/CCharNPC.cpp @@ -323,20 +323,89 @@ void CChar::NPC_CreateTrigger() return; } - // 4) EVENTSPET triggers - for (size_t i = 0; i < g_Cfg.m_pEventsPetLink.size(); ++i) - { - CResourceLink * pLink = g_Cfg.m_pEventsPetLink[i].GetRef(); - if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) - continue; + // 4) EVENTSNPC triggers + for (size_t i = 0; i < g_Cfg.m_pEventsNPCLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, this, nullptr); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + return; + } - CResourceLock s; - if (!pLink->ResourceLock(s)) - continue; + // 5) EVENTSNPCANIMAL triggers + for (size_t i = 0; i < g_Cfg.m_pEventsNPCAnimalLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCAnimalLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, this, nullptr); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + return; + } + + // 6) EVENTSNPCMONSTER triggers + for (size_t i = 0; i < g_Cfg.m_pEventsNPCMonsterLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCMonsterLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, this, nullptr); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + return; + } + + // 7) EVENTSNPCMOUNTABLE triggers + for (size_t i = 0; i < g_Cfg.m_pEventsNPCMountableLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCMountableLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, this, nullptr); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + return; + } + + // 8) EVENTSNPCSHOP triggers + for (size_t i = 0; i < g_Cfg.m_pEventsNPCShopLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_pEventsNPCShopLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction) || (executedEvents.find(pLink) != executedEvents.end())) + continue; + + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + + executedEvents.emplace(pLink); + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, this, nullptr); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + return; + } - executedEvents.emplace(pLink); - iRet = CScriptObj::OnTriggerScript(s, pszTrigName, this, nullptr); - if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) - return; - } } diff --git a/src/game/items/CItem.cpp b/src/game/items/CItem.cpp index fba785497..dce5fada5 100644 --- a/src/game/items/CItem.cpp +++ b/src/game/items/CItem.cpp @@ -3769,6 +3769,24 @@ TRIGRET_TYPE CItem::OnTrigger( lpctstr pszTrigName, CTextConsole * pSrc, CScript goto stopandret; } + // Weapons + if (pItemDef->IsTypeWeapon(m_type)) + { + EXC_SET_BLOCK("Item triggers - EVENTSITEMWEAPON"); + for (size_t i = 0; i < g_Cfg.m_iEventsItemWeaponLink.size(); ++i) + { + CResourceLink *pLink = g_Cfg.m_iEventsItemWeaponLink[i].GetRef(); + if (!pLink || !pLink->HasTrigger(iAction)) + continue; + CResourceLock s; + if (!pLink->ResourceLock(s)) + continue; + iRet = CScriptObj::OnTriggerScript(s, pszTrigName, pSrc, pArgs); + if (iRet != TRIGRET_RET_FALSE && iRet != TRIGRET_RET_DEFAULT) + goto stopandret; + } + } + // 5) TYPEDEF EXC_SET_BLOCK("typedef"); { diff --git a/src/sphere.ini b/src/sphere.ini index f35328575..8f204c771 100644 --- a/src/sphere.ini +++ b/src/sphere.ini @@ -661,16 +661,37 @@ SpeechSelf=spk_player SpeechPet=spk_pet // Events related to all NPCs -EventsPet=e_npc_generic_event //This is the default events for script pack - -// Events related to all players -EventsPlayer=e_player_generic_event,e_player_crafting_event //This is the default events for script pack +//EventsNPC=e_npc_all + +// Events related to all animals (brain_animal without mountables) +//EventsNPCAnimal=e_npc_animals + +// Events related to all monsters (brain_monster, brain_dragon, brain_berserk) +//EventsNPCMonster=e_npc_monsters + +// Events related to all animals (brain_animal with mountable) +//EventsNPCMountable=e_npc_mountables + +// Events related to all shopkeepers (brain_vendor, brain_stable, brain_healer) +//EventsNPCShop=e_npc_shopkeepers + +// Events related to all clients (player and staff) +EventsClient=e_client_all,e_player_generic_event + +// Events related to all staff (if plevel is higher than 1) +//EventsClientStaff=e_client_staffs + +// Events related to all players (if the plevel is lower than 1) +//EventsClientPlayer=e_client_players // Events related to all regions -//EventsRegion=e_your_event +//EventsRegion=e_region_all // Events related to all items -//EventsItem=ei_your_event +//EventsItem=ei_items + +// Events related to all weapons +//EventsItemWeapon=ei_item_weapons // When player skills/stats goes this times more than skillclass allowed, drop // them to skillclass level. Setting this to 0 disables the action.