-
-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: script improvements and remove unused config (#2242)
- Loading branch information
1 parent
1c4bea7
commit aa797ff
Showing
6 changed files
with
56 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
data-otservbr-global/scripts/globalevents/others/spawns_npc_by_time.lua
This file was deleted.
Oops, something went wrong.
69 changes: 26 additions & 43 deletions
69
data-otservbr-global/scripts/quests/threatened_dreams/event-raven_herb_bush.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
data-otservbr-global/scripts/world_changes/spawns_npc_by_time.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
local npcSpawns = { | ||
{ name = "Ghostly Wolf", spawnPeriod = LIGHT_STATE_SUNSET, despawnPeriod = LIGHT_STATE_SUNRISE, position = { x = 33332, y = 32052, z = 7 } }, | ||
{ name = "Talila", spawnPeriod = LIGHT_STATE_SUNSET, despawnPeriod = LIGHT_STATE_SUNRISE, position = { x = 33504, y = 32222, z = 7 } }, | ||
{ name = "Valindara", spawnPeriod = LIGHT_STATE_SUNRISE, despawnPeriod = LIGHT_STATE_SUNSET, position = { x = 33504, y = 32222, z = 7 } }, | ||
} | ||
|
||
local spawnsNpcByTime = GlobalEvent("SpawnsNpcByTime") | ||
|
||
function spawnsByTimeEvent.onPeriodChange(period) | ||
for _, npcSpawn in ipairs(npcSpawns) do | ||
if npcSpawn.spawnPeriod == period then | ||
local spawnNpc = Game.createNpc(npcSpawn.name, npcSpawn.position) | ||
if spawnNpc then | ||
spawnNpc:setMasterPos(npcSpawn.position) | ||
npcSpawn.position:sendMagicEffect(CONST_ME_TELEPORT) | ||
logger.info("[NPC Spawn] {} has spawned", npcSpawn.name) | ||
end | ||
elseif npcSpawn.despawnPeriod == period then | ||
local despawnNpc = Npc(npcSpawn.name) | ||
if despawnNpc then | ||
despawnNpc:getPosition():sendMagicEffect(CONST_ME_TELEPORT) | ||
despawnNpc:remove() | ||
logger.info("[NPC Despawn] {} has despawned", npcSpawn.name) | ||
end | ||
end | ||
end | ||
return true | ||
end | ||
|
||
spawnsNpcByTime:register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters