diff --git a/GameGuru Core/GameGuru/Source/G-Entity.cpp b/GameGuru Core/GameGuru/Source/G-Entity.cpp index 090c5f1e..01e56ffc 100644 --- a/GameGuru Core/GameGuru/Source/G-Entity.cpp +++ b/GameGuru Core/GameGuru/Source/G-Entity.cpp @@ -95,8 +95,12 @@ void entity_init ( void ) t.entid=t.entityelement[t.e].bankindex; if ( t.entid>0 ) { - // Activate entity - t.entityelement[t.e].active=1; + // Activate entity + if (t.entityelement[t.e].eleprof.spawnatstart == 1 ) + { + // LB: only activate entities that are set to spawn at start + t.entityelement[t.e].active = 1; + } t.tobj=t.entityelement[t.e].obj; if ( t.tobj>0 ) { diff --git a/Scripts/scriptbank/markers/plrinzone.lua b/Scripts/scriptbank/markers/plrinzone.lua index 990278df..d698f1fb 100644 --- a/Scripts/scriptbank/markers/plrinzone.lua +++ b/Scripts/scriptbank/markers/plrinzone.lua @@ -1,5 +1,5 @@ -- LUA Script - precede every function and global member with lowercase name of script + '_main' --- Player In Zone v14 by Necrym59 and Lee +-- Player In Zone v15 by Necrym59 and Lee -- DESCRIPTION: Re-triggerable zone to trigger an event. -- DESCRIPTION: [ZONEHEIGHT=100] controls how far above the zone the player can be before the zone is not triggered. -- DESCRIPTION: Set for [@MULTI_TRIGGER=2(1=Yes, 2=No)] @@ -8,7 +8,7 @@ -- DESCRIPTION: [SoundVolume=100[1,100] adjust this sounds volume -- DESCRIPTION: when entering zone -local plrinzone = {} +local g_plrinzone = {} local multi_dead = {} local multi_switch = {} local status = {} @@ -17,20 +17,20 @@ local wait = {} local waittime = {} function plrinzone_properties(e, zoneheight, multi_trigger, delay, spawnatstart, soundvolume) - plrinzone[e].zoneheight = zoneheight or 100 - plrinzone[e].multi_trigger = multi_trigger or 2 - plrinzone[e].delay = delay or 0 - plrinzone[e].spawnatstart = spawnatstart or 1 - plrinzone[e].soundvolume = soundvolume or 1 + g_plrinzone[e].zoneheight = zoneheight or 100 + g_plrinzone[e].multi_trigger = multi_trigger or 2 + g_plrinzone[e].delay = delay or 0 + g_plrinzone[e].spawnatstart = spawnatstart or 1 + g_plrinzone[e].soundvolume = soundvolume or 1 end function plrinzone_init(e) - plrinzone[e] = {} - plrinzone[e].zoneheight = 100 - plrinzone[e].multi_trigger = 2 - plrinzone[e].delay = 0 - plrinzone[e].spawnatstart = 1 - plrinzone[e].soundvolume = 100 + g_plrinzone[e] = {} + g_plrinzone[e].zoneheight = 100 + g_plrinzone[e].multi_trigger = 2 + g_plrinzone[e].delay = 0 + g_plrinzone[e].spawnatstart = 1 + g_plrinzone[e].soundvolume = 100 status[e] = "init" doonce[e] = 0 multi_dead[e] = 0 @@ -41,23 +41,23 @@ end function plrinzone_main(e) if status[e] == "init" then - if plrinzone[e].delay ~= nil then waittime[e] = plrinzone[e].delay * 1000 end - if plrinzone[e].spawnatstart > 0 then SetActivated(e,1) end - if plrinzone[e].spawnatstart == 0 then SetActivated(e,0) end + if g_plrinzone[e].delay ~= nil then waittime[e] = g_plrinzone[e].delay * 1000 end + if g_plrinzone[e].spawnatstart > 0 then SetActivated(e,1) end + if g_plrinzone[e].spawnatstart == 0 then SetActivated(e,0) end status[e] = "endinit" end if g_Entity[e]['activated'] == 1 then - if g_Entity[e]['plrinzone'] == 1 and multi_switch[e] == 0 and g_PlayerPosY > g_Entity[e]['y'] and g_PlayerPosY < g_Entity[e]['y']+plrinzone[e]['zoneheight'] then + if g_Entity[e]['plrinzone'] == 1 and multi_switch[e] == 0 and g_PlayerPosY > g_Entity[e]['y'] and g_PlayerPosY < g_Entity[e]['y']+g_plrinzone[e]['zoneheight'] then if doonce[e] == 0 then PlaySound(e,0) SetSound(e,0) - SetSoundVolume(plrinzone[e].soundvolume) + SetSoundVolume(g_plrinzone[e].soundvolume) wait[e] = g_Time + waittime[e] doonce[e] = 1 end end if g_Time > wait[e] then - if plrinzone[e].multi_trigger == 1 and multi_switch[e] == 0 then + if g_plrinzone[e].multi_trigger == 1 and multi_switch[e] == 0 then if doonce[e] == 1 then multi_switch[e] = 1 ActivateIfUsed(e) @@ -65,7 +65,7 @@ function plrinzone_main(e) doonce[e] = 2 end end - if plrinzone[e].multi_trigger == 2 then + if g_plrinzone[e].multi_trigger == 2 then if multi_dead[e] == 0 then ActivateIfUsed(e) PerformLogicConnections(e) @@ -85,7 +85,9 @@ function plrinzone_main(e) if g_EntityExtra[e]['restoremenow'] == 1 then g_EntityExtra[e]['restoremenow'] = 0 status[e] = "init" - plrinzone[e].spawnatstart = GetEntitySpawnAtStart(e) + -- no good, as GetEntitySpawnAtStart is always 1 and different from plrinzone[e].spawnatstart + -- plrinzone[e].spawnatstart = GetEntitySpawnAtStart(e) + -- instead the 'init' will use the newly renamed g_plrinzone state that is correct for new and reloaded level states! end end