Page 1 of 2 12 LastLast
Results 1 to 50 of 65

Keeper Phase Ability

  1. #1

    Keeper Phase Ability

    Well, I think it's been explored before, but not sure. But anyway's, can it be used? Maybe as a special type of hyperspace that also auto repairs. What do you think?

    I have found a bunch of files that deal with it, but many make little or no sense to me. :'( Has anybody figured it out. (I hope not, then I can be the first to make it wokr )

  2. #2
    How about making it a Cloaking, Deffence Field, or other type of special ability animation (don't know if it's possible).

  3. #3
    Well, I did just find an old discussion abuot ti, but i lead me nowhere. <_< I will see if maybe level or gametype scripting is going to be needed, or a spcial effect. But i did learn the "phase out" is an .hod file. O.o but that ALL i knoiw. I am digging in the data folder to find ANYTHING that corisponds with it. **wish me luck **

    Edit: Sofar, I have found the .HOD files, and the fx files that control the effects. But nothing on how to trigger then.

    Edit2: I hav efound the code that triggers it within the SP mission

    Edit3: Found out that the phase out is a hyperspace without the effect.

    Edit4: found that
    Code:
    { "g_Keeper_Phase_Effect_id = FX_PlayEffect( 'kpr_phase_destroyer_mesh', g_Keeper_Phase_Out, 1)", "", }
    triggers the effect. no to see if it can be made to work as a special effect.

    Edit umm...5 (loosing cout):
    Okay, I've come to were I have little knowledge. I have found that the code above triggers the effect, but...how to I incorpirate that into a function, or as a special type of hyperspace effect for only the keepers. the full code, that both starts the FX and disavles the standard HS FX is as follows:
    Code:
     { "SobGroup_Despawn(g_Keeper_Phase_Out)", "", }, 
                { "g_Keeper_Phase_Effect_id = FX_PlayEffect( 'kpr_phase_destroyer_mesh', g_Keeper_Phase_Out, 1)", "", }, HW2_Wait(7), },
    altohugh i could be missing some things. Can anybody help me on this?
    Last edited by Shipyard Nabal; 20th Jun 06 at 2:51 PM.

  4. #4
    Seems you're on the right track. Good luck.
    Scripting is not my best asset. Not at this level anyway.

    Models and ideas, I can provide...

  5. #5
    Lol, well scriptig is my only skill. Perhaps I will inlist your skills soon .

    But those anyody else have anu thoughs on this. I have never triedadding new functions, special abilities, etc.. or gametypes, and of course, if taht is what i should be looking for.

  6. #6
    Member Le Sun Tzu's Avatar
    Join Date
    Oct 2005
    Location
    City of Light
    I think Relic has said on this forum that it is not possible to add new abilities because they are hardcoded.

    You may try to emulate an ability by putting it into a gamerule script and tie it to an event key. I suspect that what you have posted is only a part of the phase scripts and it must be cleaned up because it's in the format of SP events (with curly braces and empty strings all over the place). To tie it to an event key, you can look at evillejedi's SobGroup_ModifySelected custom functions on the Karos wiki. However that should not be simple since you need to have both phase in and phase out, ie select a ship AND set up an exit point. I have no idea of how you can do that part.

  7. #7
    Remember when the keepers phased out??? (Low health, that's right.) make it a special ability, and... subtract some RU's from the player (If the player has that much!)
    Look into B1FF's ResourceRace mod, there you can find ways to create volumes, check whether a temporary volume is empty or not ( for Crates! ). You could make the Phase function to exit where there is no enemy, at cost of RU's or something like that ( Keepers are already powerful enough, so there must be some limitation for 'phase ability' )

  8. #8
    Well, can it be possible that the phase out can be used in place of the hyperspace out effect, and can exit regularly. Is that possible?

    Edit1: Well, I;m bust ATM with some othe rtihngs, but as I was doinf them, I noticed this again, hyperspace_gate_kpr.lua and hyperspace_gate_kpr_m10.lua . They are both exactly the same, but why is it there. Can you make another with the phase out fx instead of the regular fx?

    Edit2: Well, anothe rinteresting thing I found, there is an animation event in the .event file for the keeper. Phase and Phase_loop. It also states the mesh it loads, etc. Will see where that leads me.(is thier a way to trigger effects in the event file with a key or special attack?, or to replace the regular Hyperspace with this one?)
    Last edited by Shipyard Nabal; 21st Jun 06 at 6:58 PM.

  9. #9
    void FX_StartEvent (const char *sobGroupName, const char *eventName) Start playing an effect event.

    sobGroupName must be a single ship for this to work properly.

  10. #10
    err...what is that specificly for? Gamerule, singleplayer script, somethign else?

    Edit: Well, I finished the build thing, so now i started looking at the gametype functions, to see if i can get it to work with that. It seems possible to activate it if, the Keepers health is at a certain amount (like 1/4 left) it will "PHase out" and hyperspace to, letsay the mothership, other some other defined location. What do you tihnk? (you could also enable/disable before oyu start the game.)

    Edit2: also, i could make it phase out, be fully repaired, and hyperspace back (after a certain amount of time)

    Edit3: well, I hadmy first atempt at it, but 0 success. :'( I'm not good with GameTypes/Rules. Can anybody please help me out on this?
    Last edited by Shipyard Nabal; 22nd Jun 06 at 6:55 PM.

  11. #11
    **bump** (sorry, but check edited post above. )

    Edit: Here is the code i used. If it looks retared, this is my first attempt to make a gamerule by myslef.
    Code:
    function keeperPhaseOut()
    exit_location = layer_GetShipsByType (i, Kpr_Sajuuk)
       for i=0, g_players do
    	if SobGroup_GetHardPointHealth(Kpr_Keeper, Root)== 10000 then
     	FX_PlayEffect( 'kpr_phase_destroyer_mesh', exit_location, 1) while
    	SobGroup_Despawn(Kpr_Keeper)
    	end
               end
    end
    Last edited by Shipyard Nabal; 22nd Jun 06 at 7:16 PM.

  12. #12
    EhraniNavy
    Guest
    Code:
    function keeperPhaseOut()
       Volume_AddSphere( "exit_location", SobGroup_GetPosition(Player_GetShipsByType("Kpr_Sajuuk")), 500)
       SobGroup_Create("keepers")
       Player_FillShipsByType("keepers", 0, "Kpr_Keeper")
       SobGroup_Despawn("keepers")
       FX_PlayEffect( "kpr_phase_destroyer_mesh", "keepers", 1)
       SobGroup_Spawn("keepers", "exit_location")
    end
    This is really just a suggestion. It creates a volume called "exit_location" wherever Sajuuk is, puts all the keepers into a SobGroup (this will have some problems, hopefully there is only one keeper), and despawns them and plays the effect. It respawns them by Sajuuk.

  13. #13
    Ahem... what will happen if there are MORE than one Keeper. Instead, go to the wiki, from there, take the code for splitting SobGroups, split the sobgroups if the count is more than one, then do the code posted by EhraniNavy on each Keeper
    Oh, not neccessary the player would have a KPR_Sajuuk. Try taking a random position from current one. (ie use a random number generator function, there must be these functions somewhere )
    Let me think about this a bit deeply, I think the code posted by EhraniNavy will be almost, instanteous.... Let me think,

  14. #14
    EhraniNavy
    Guest
    Let me try that...

    Code:
    --global variables
    g_sobnum = 0
    g_done = 0
    function SobGroup_SplitGroup(SobGroupOut, SobGroupToSplit, NumberToSplit)
    	-- function created by Apollyon470
    	local index = 0
    	local distance = 0
    	local bool = 0
    	local SobNum = 0
    	SobGroup_Create("TempSobGroup")
    	SobGroup_Clear ("TempSobGroup")
    	SobGroup_Create("TempSobGroup1")
    	SobGroup_Clear ("TempSobGroup1")
    	SobGroup_SobGroupAdd ("TempSobGroup", SobGroupToSplit)
    	if ( SobGroup_Empty (SobGroupToSplit) == 1 ) then
    		return 0
    	end
    	if ( NumberToSplit > SobGroup_Count(SobGroupToSplit) ) then
    		NumberToSplit = SobGroup_Count(SobGroupToSplit)
    	end
    	while (index < NumberToSplit ) do
    		bool = 0
    		-- in the interests of resource saving, we start with a search band of 625
    		interval = 625
    		while (bool == 0) do
    			distance = distance + interval
    			-- something went wrong.  Please tell me, or have a go at fixing it yourself.
    			if (interval > 3000000) then
    				bool =1
    				return SobNum
    			end
    			SobGroup_FillProximitySobGroup ("TempSobGroup1", "TempSobGroup", SobGroupToSplit, distance)			
    			if (SobGroup_Empty("TempSobGroup1") == 1)then
    				-- get the next interval
    			else
    				if (SobGroup_Count("TempSobGroup1") > 1) then
    					-- too many ships, reduce interval
    					if (interval == 1) then
    						-- Screw it! chunk 'em all in the same sobgroup
    						SobGroup_Create(SobGroupOut .. tostring(SobNum))
    						SobGroup_Clear (SobGroupOut .. tostring(SobNum))
    						SobGroup_SobGroupAdd (SobGroupOut .. tostring(SobNum), "TempSobGroup1")
    						SobGroup_Create("tempsob")
    						SobGroup_FillSubstract("tempsob", "TempSobGroup", SobGroupOut .. tostring(SobNum))
    						SobGroup_Clear ("TempSobGroup")
    						SobGroup_SobGroupAdd ("TempSobGroup", "tempsob")
    						bool = 1
    					else
    						distance = distance - interval
    						interval = interval / 5
    					end
    				else
    					-- we got one! add it to the list!
    					SobGroup_Create(SobGroupOut .. tostring(SobNum))
    					SobGroup_Clear (SobGroupOut .. tostring(SobNum))
    					SobGroup_SobGroupAdd (SobGroupOut .. tostring(SobNum), "TempSobGroup1")
    					SobGroup_Create("tempsob")
    					SobGroup_FillSubstract("tempsob", "TempSobGroup", SobGroupOut .. tostring(SobNum))
    					SobGroup_Clear ("TempSobGroup")
    					SobGroup_SobGroupAdd ("TempSobGroup", "tempsob")
    					bool = 1
    				end
    			end			
    		end
    		index = index + SobGroup_Count(SobGroupOut .. tostring(SobNum))
    		SobNum = SobNum + 1
    	end
    	return SobNum
    end
    
    function keeperPhaseOut()
       local sobnum = 0
       SobGroup_Create("keepers")
       SobGroup_Clear("keepers")
       Player_FillShipsByType("keepers", 0, "Kpr_Keeper")
       sobnum = SobGroup_SplitGroup("keeper", "keepers", SobGroup_Count("keepers"))
       for i = 0, sobnum do
          if SobGroup_Selected("keeper"..i)==1 then
             if SobGroup_GetHardPointHealth("keeper"..i, "root")==10000 then
                SobGroup_Despawn("keepers")
                FX_PlayEffect( "kpr_phase_destroyer_mesh", "keeper"..i, 1)
                g_sobnum = i
                if g_done==1 then
                   Rule_AddInterval("Rule_RespawnKeeper", 60)
                end
             end
         end
      end
    end
    
    function Rule_RespawnKeeper()
          g_done = 0
          local sobname = "keeper"..g_sobnum
          Volume_AddSphere( "exit_location", {Random(-30000, 30000), Random(-20000, 20000), Random(-30000, 30000)}, 500)
          SobGroup_Spawn(sobname, "exit_location")
          Camera_AltFocus(sobname, 0)
          Rule_Remove("Rule_RespawnKeeper")
          g_done = 1
    end
    function OnInit()
       UI_BindKeyEvent(PKEY, "keeperPhaseOut")
    end
    Hopefully, get a keeper at full health, select it, and press p.
    Last edited by EhraniNavy; 23rd Jun 06 at 9:10 AM.

  15. #15
    It doesn't work. Ends at the first like. Here's the error log, and line 134 is the first line of the scrip you gave me. I looked at it, but I have no idea.
    Code:
    Fri Jun 23 11:21:36 2006
     Loaded Archive: 'Homeworld2.big' 
     UTIL -- filepath failure, path doesn't exists 'C:\PROGRA~1\Sierra\HOMEWO~1\data\locale\english' 
     Loaded Archive: 'english.big' 
     Uing ..profiles\ for profiles folder 
     LUA 'data:LevelData\Multiplayer\DEATHMATCH.LUA' -- parameter: attempt to call global `SobGroup_Create' (a nil value)
    stack traceback:
       1:  main of string "" at line 134 
     Error parsing 'DEATHMATCH.LUA' -- FATAL EXIT -- gameruleslibrary/146:! --stack trace-- 0x0055A87D: GSTracker::operator=                        () 0x0055A95F: GSTracker::operator=                        () 0x005A63D6: getLibraryID                                () 0x0048EA46: GSLobbySessionDesc::operator=               ()
    Sorry for all this, just that I've always wanted this to work.

    Edit: I had a few goes at it,but it didn't help,a t all.

    Edit2: Well, I tried the fiorst script also, the game plays fine, but no effect.
    Last edited by Shipyard Nabal; 23rd Jun 06 at 9:05 AM.

  16. #16
    EhraniNavy
    Guest
    EDIT: Actually just delete the whole line.

    Also, I made some changes to some errors in my post, so you might want to check on those.

  17. #17
    Wite the sobGroup_Create in the OnInit() function. That oughta make it work. (Anything in lua, outside a valid function 'chunk' is executed in the Universe section of HW2 loading (for known files only!) )

    EhraniNavy: Your code seems correct. Why use subsystem health on root hardpoint. Instead use SonGroup_HealthPercentage(const char *sobgroupName )

    EDIT:
    Your code looks promising. Just make it so that it looks for ALL players (instead of player 0 and the Respawn code has to be modified, make the time, umm.. instanteously, and subtract RU's from the player.)

  18. #18
    well...the game playsfine, but no phase out. i will take 4E534B suggestions, if i knew how. lol, gamtype functions are still nonsense to me, i have no idea how to get anything to work. <_<

  19. #19
    EhraniNavy
    Guest
    Code:
    --global variables
    g_sobnum = 0
    g_done = 1
    function SobGroup_SplitGroup(SobGroupOut, SobGroupToSplit, NumberToSplit)
    	-- function created by Apollyon470
    	local index = 0
    	local distance = 0
    	local bool = 0
    	local SobNum = 0
    	SobGroup_Create("TempSobGroup")
    	SobGroup_Clear ("TempSobGroup")
    	SobGroup_Create("TempSobGroup1")
    	SobGroup_Clear ("TempSobGroup1")
    	SobGroup_SobGroupAdd ("TempSobGroup", SobGroupToSplit)
    	if ( SobGroup_Empty (SobGroupToSplit) == 1 ) then
    		return 0
    	end
    	if ( NumberToSplit > SobGroup_Count(SobGroupToSplit) ) then
    		NumberToSplit = SobGroup_Count(SobGroupToSplit)
    	end
    	while (index < NumberToSplit ) do
    		bool = 0
    		-- in the interests of resource saving, we start with a search band of 625
    		interval = 625
    		while (bool == 0) do
    			distance = distance + interval
    			-- something went wrong.  Please tell me, or have a go at fixing it yourself.
    			if (interval > 3000000) then
    				bool =1
    				return SobNum
    			end
    			SobGroup_FillProximitySobGroup ("TempSobGroup1", "TempSobGroup", SobGroupToSplit, distance)			
    			if (SobGroup_Empty("TempSobGroup1") == 1)then
    				-- get the next interval
    			else
    				if (SobGroup_Count("TempSobGroup1") > 1) then
    					-- too many ships, reduce interval
    					if (interval == 1) then
    						-- Screw it! chunk 'em all in the same sobgroup
    						SobGroup_Create(SobGroupOut .. tostring(SobNum))
    						SobGroup_Clear (SobGroupOut .. tostring(SobNum))
    						SobGroup_SobGroupAdd (SobGroupOut .. tostring(SobNum), "TempSobGroup1")
    						SobGroup_Create("tempsob")
    						SobGroup_FillSubstract("tempsob", "TempSobGroup", SobGroupOut .. tostring(SobNum))
    						SobGroup_Clear ("TempSobGroup")
    						SobGroup_SobGroupAdd ("TempSobGroup", "tempsob")
    						bool = 1
    					else
    						distance = distance - interval
    						interval = interval / 5
    					end
    				else
    					-- we got one! add it to the list!
    					SobGroup_Create(SobGroupOut .. tostring(SobNum))
    					SobGroup_Clear (SobGroupOut .. tostring(SobNum))
    					SobGroup_SobGroupAdd (SobGroupOut .. tostring(SobNum), "TempSobGroup1")
    					SobGroup_Create("tempsob")
    					SobGroup_FillSubstract("tempsob", "TempSobGroup", SobGroupOut .. tostring(SobNum))
    					SobGroup_Clear ("TempSobGroup")
    					SobGroup_SobGroupAdd ("TempSobGroup", "tempsob")
    					bool = 1
    				end
    			end			
    		end
    		index = index + SobGroup_Count(SobGroupOut .. tostring(SobNum))
    		SobNum = SobNum + 1
    	end
    	return SobNum
    end
    
    function keeperPhaseOut()
       local sobnum = 0
       local playerCount = Universe_PlayerCount()
       local b_go = 0
       for j=0, playerCount do
       if Player_GetRU(j) > 500 then
           Player_SetRU(j, Player_GetRU(j) - 500)
           b_go = 1
       else
          b_go = 0
       end
         if b_go == 1 then
         SobGroup_Create("keepers")
         SobGroup_Clear("keepers")
         Player_FillShipsByType("keepers", j, "kpr_destroyer")
         sobnum = SobGroup_SplitGroup("keeper", "keepers", SobGroup_Count("keepers"))
         print(sobnum)
         local i = 0
         while (i < sobnum) do
            if SobGroup_Selected("keeper"..i)==1 then
               if SobGroup_HealthPercentage("keeper"..i)==1 then
                  SobGroup_Despawn("keepers")
                  FX_PlayEffect( "kpr_phase_destroyer_mesh", "keeper"..i, 1)
                  if g_done==1 then
                    g_sobnum = i
                    Rule_AddInterval("Rule_RespawnKeeper", 60) --takes 60 seconds
                  end --end if
                end --end if
            end --end if
         end
        end --end while
        i = i + 1
       end --end for
    end
    
    function Rule_RespawnKeeper()
          g_done = 0
          local sobname = "keeper"..g_sobnum
          Volume_AddSphere( "exit_location", {random(-30000, 30000), random(-20000, 20000), random(-30000, 30000)}, 500)
          SobGroup_Spawn(sobname, "exit_location")
          Camera_AltFocus(sobname, 0)
          Rule_Remove("Rule_RespawnKeeper")
          g_done = 1
    end
    Ok, this works, but the random function will land you in about the same place every time for some reason. Also, it takes currently a minute to respawn the keeper, but you can change that. I used SobGroup_HealthPercentage as 43534B said, and it costs about 500 which is probably a little cheap but you can change that too.
    Last edited by EhraniNavy; 23rd Jun 06 at 1:42 PM.

  20. #20
    OH, didnt look you posted that, EhraniNavy
    Nice, but it is vital you check the player has that much RU's or not. Also, if you intend to keep non Instantaneous, then consider using tables

    Init block (Not in ANY function)
    =======================
    <VarName>={}

    OnInit() function
    ============
    for i=1,Universe_PlayerCount() do
    for j=1,<Function-To-Get-Caps-Of-Keepers> do
    -- This will init the table, two 'indexes', i,j
    -- For player index AND no of keepers.
    <VarName>[i][j]=0
    end
    end

    Now, use this <VarName>[i][j]> if a keeper had despawned (maybe this will be the time, if so, then use the function to get time, add the time after which the keepere spawns, divide it by the current time, if it is mor ethan 0.9 or less than 1.1 then this is the keeper whic hdespawned before -- This is needed to prevent the keppers which despawned later from appearing before,, keep in mind, since Numbers are double in lua (64bits), usage of this method a lot will cause lag to those, whose internet connection is slow)

    Understanding what I said, or I am confusing? (My english is NOT-SO-PERFECT)

    ------------ original Post ------------
    Try adding a print(<SomeMessage>) at various places in the script (For debugging only!)

    Then you will know till where the code was executed. Look in HW2.log for the <SomeMessage> Then you we know, till where the code is executed and which one is faulty. Wee, I DO believe it is possible. I've made ships do damage to surrounding ships when they die, I've somehow managed to make massive ships, with massive subsystems, spawn explosions (from the ship effects, though). So this *IS* possible I say.

  21. #21
    if you had that work, then it has t be me. O.o It'sstill won't work. The game doesn't even load. (I will add print(<SomeMessage>) to see were it stops)

    Edit: I can't figure a dam thign out. Sorry, but I have no idea. :'(

    Edit2: OK, I saw one thing, the key you press was in the wrong location, I also switched it form P to F9 (P was already in use) but, when i press it, the game crashes. this is the error log:
    Code:
    Fri Jun 23 17:19:05 2006
     Loaded Archive: 'Homeworld2.big' 
     UTIL -- filepath failure, path doesn't exists 'C:\PROGRA~1\Sierra\HOMEWO~1\data\locale\english' 
     Loaded Archive: 'english.big' 
     Uing ..profiles\ for profiles folder 
     GAME -- Using player profile ModTester 
     Changing from a 32 bit colour depth in winNT (5.1 build 2600), Service Pack 2 
     Using ATI Technologies Inc.'s 1.3.1062 WinXP Release MOBILITY/RADEON 9250/9200 Series DDR x86/SSE2 renderer (Suspected driver is atioglxx.dll 6.14.10.5757) 
     Loaded Archive: 'englishSpeech.big' 
     Loaded Archive: 'Music.big' 
     SOUND -- created destination [ fdaudio ], handle [ 4 ] with [ 48 ] channels created 
     SOUND -- created destination [ fda streamer ], handle [ 5 ] with [ 8 ] channels created 
     Build name: The Dust Wars  - AutoBuild3569 - Ordered by smmatte 
     Built by  : mrbuild 
     Data path : C:\PROGRA~1\Sierra\HOMEWO~1\data 
     Could not initialize all fragment programs.  Please use the '-fragment_program 0' command line parameter 
     Resetting fp control word. 
     CmdLine: -overrideBigFile -luatrace 
     Starting Level: data:LevelData\Multiplayer\Deathmatch\3P_DANTES_REQUIEM.LEVEL 
     LUA 'data:Ship\KPR_KEEPER\KPR_KEEPER.events' -- parameter: <name> or `[' expected;
      last token read: `,' at line 287 in string "" 
     persistant data loading: trying to put a non dock capable ship in parade (Kpr_Dreadnaught), has the NIS put crap in the player's fleet again? 
     persistant data loading: trying to put a non dock capable ship in parade (Kpr_Dreadnaught), has the NIS put crap in the player's fleet again? 
     persistant data loading: trying to put a non dock capable ship in parade (Kpr_Keeper), has the NIS put crap in the player's fleet again? 
     persistant data loading: trying to put a non dock capable ship in parade (Kpr_Keeper), has the NIS put crap in the player's fleet again? 
     build available 
     generic build available KPR_ATTACKDROID  FIGHTER 
     carrier open 
     carrier open 
     ** CommandHyperspaceGiven: shipname = Kpr_Dreadnaught code = 0 
     0 
     parameter: attempt to perform arithmetic on global `i' (a nil value)
    stack traceback:
       1:  function `keeperPhaseOut' at line 215 [string ""] 
     Error: Scar Event function (keeperPhaseOut) not found or called properly for key(120) -- FATAL EXIT -- scar/307:! --stack trace-- 0x0060274C: getLibraryID                                ()    0x00491221: GSLobbySessionDesc::operator=               ()
    Edit3: Guess I'm alone from now on....
    Last edited by Shipyard Nabal; 23rd Jun 06 at 8:21 PM.

  22. #22
    Post the *WHOLE* deathmatch.lua here...

  23. #23
    *BUMP*



    Guess I'm alone from now on....
    WADDAYA MEAN "ALONE"???. I don't think anyone will be deserted *completely* on these forums (Until that person commits an unbannable offence)

    Well, I am hoping you know scripting (basics, atleast). Here it is:
    Code:
    ----------------------------------------------------------------------------------------------------------
    --	Variables for race: PROGENITOR (KPR)	--
    ----------------------------------------------------------------------------------------------------------
    -- If one, the code will be executed, then, this will be resetted.
    KPR_Destroyer_PhaseMe = 0
    -- Destroyer SobGroup Table
    KPR_Destroyer = {}
    KPR_Destroyer_i = {}
    -- MOVEME: Move this code to ShipScAR_Vars.lua, when finished, and make it a tunable.
    KPR_Destroyer_PhaseMeKey = HKEY
    -- Number of keepers that 'can' phase out at a time (every PK_PhaseTime).
    -- keep this a integer. And realistic
    UC_KPR_Destroyer = 20
    -- Health threshold for progenitor keepers to phase.
    -- if this is kept 1, then health checks will be 'by-passed'
    PK_HealthThreshold = 1
    -- RU cost for phasing-out Progenitor Keepers, and the duration.
    PK_PhaseCost = 500
    PK_PhaseTime = 5 --50
    PK_PhaseLocationRandomization = 10000
    --  Health, they will have after returning from phase state.
    PK_PhaseOut_Health = 1
    -- Event name(s) and duration(s) for the 'phase' effects\events:
    PK_Phase_EffectName = "KPR_Phase_Destroyer_Mesh"
    PK_PhaseOut_EffectName = "KPR_Phase_Destroyer_Mesh_PhaseOut"
    ----------------------------------------------------------------------------------------------------------
    --	Functions for race: PROGENITOR (KPR)	--
    ----------------------------------------------------------------------------------------------------------
    function InitShipScAR_KPR()
     if ShipScAR_Debug_Mode==3 then
      print("*SSSU* -> At InitShipScAR_KPR");
     end
     
     ----------------------------------
     -- Routines for KPR_Destroyer --
     ----------------------------------
     if ShipScAR_Debug_Mode~=0 then
      print("*SSSU* -> Binding Key "..KPR_Destroyer_PhaseMeKey.." to Watch_KPR_Destroyer");
     end
     
     UI_BindKeyEvent(HKEY, "Watch_KPR_Destroyer");  -- Watch for House-Keepering Function
     Rule_AddInterval("Rule_KPR_Destroyer", 1);   -- House-Keeping function
     
     for i=0,Universe_PlayerCount()-1 do
      for j=0,UC_KPR_Destroyer do
       -- Create a whole load of SobGroups!
       if ShipScAR_Debug_Mode>1 then
    	print("Init Data:"..i..j..".");
       end
       
       KPR_Destroyer[i*UC_KPR_Destroyer+j] = "KPR_Destroyer["..(i*UC_KPR_Destroyer+j).."]"
       SobGroup_Create(KPR_Destroyer[i*UC_KPR_Destroyer+j]);
       SobGroup_Clear(KPR_Destroyer[i*UC_KPR_Destroyer+j]);
      end
      
      -- Don't forget to init the index too!
      KPR_Destroyer_i[i] = 0
     end
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSU* -> Leaving InitShipScAR_KPR");
     end
    end
    Watch_KPR_Destroyer = function()
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUW* -> At Watch_KPR_Destroyer");
     end
     
     -- Make sure that it is NOT one before proceeding, (Possibiliy, users may press the PhaseKey more than once, in a second.)
     if KPR_Destroyer_PhaseMe~=1 then
      if ShipScAR_Debug_Mode~=0 then
       print("*SSSUW* -> User pressed key "..KPR_Destroyer_PhaseMeKey.."!");
      end
      
      -- Mark it, so that withing next, ummm... ~1-(1/infinity) seconds this code is executed (Well, theorotically, this is true.)
      KPR_Destroyer_PhaseMe=1
      
      -- This code should be kept small, so that even if executed ten times a second, it doesn't make 0.8GHz computers (P3) lag...
     else
      if ShipScAR_Debug_Mode>1 then
       print("*SSSUW* -> Stop pressing key "..KPR_Destroyer_PhaseMeKey.." again and again so quickly! BAD!!!");
      end
     end
     
     Rule_Remove("Watch_KPR_Destroyer");
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUW* -> Leaving Watch_KPR_Destroyer");
     end
    end
    Rule_KPR_Destroyer = function()	-- 'House-Keeping' function
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> At Rule_KPR_Destroyer");
     end
     
     if KPR_Destroyer_PhaseMe==1 then 
      -- Reset this. So that we don't come here again.
      KPR_Destroyer_PhaseMe=0
      
      -- Init of a new SobGroup
      local KPRSob="KPRSob" 
      SobGroup_Create(KPRSob);
      
      for i=0,Universe_PlayerCount()-1 do
       -- Get me the Progenitor Keepers, I'll keep a few of them with me.
       KPRSob=Player_GetShipsByType(i, "KPR_Destroyer")
       
       if ShipScAR_Debug_Mode>1 then
    	print("No of keepers of player "..i.." = "..SobGroup_Count(KPRSob)..".");
       end
       
       if SobGroup_Count(KPRSob)==1 then  -- Single Ship
    	-- OK. Very nice to be here. First check whether they are selected,
    	if SobGroup_Selected(KPRSob)~=0 then
    	 -- Make sure they are not hyper-spacing and\or they are not in hyper-space (and any thing related.)
    	 if SobGroup_AreAllInRealSpace(KPRSob)==1 and 
    	   SobGroup_IsDoingAbility(KPRSob, AB_Hyperspace)==0 and
    	   SobGroup_IsDoingAbility(KPRSob, AB_HyperspaceViaGate)==0 then
    	  -- Now, are they below this health
    	  if PK_HealthThreshold==1 or 
    		-- if, keeper health is exactly PK_HealthThreshold, then a simple '<' wont allow the code execution below.
    		-- therefore this *must* be used
    		not SobGroup_HealthPercentage(KPRSob)>PK_HealthThreshold then
    	   -- ERROR: "attempt to compare nil with number" can be prevented by checking whether the player is alive,
    	   -- or not. Therefore, "do this now"
    	   if Player_IsAlive(i) then
    		-- Is the player wealthy enough?
    		-- TODO: should thise be made like hyperspace, cost per meter, base cost, max cost??? Maybe NO.
    		if Player_GetRU(i)>(PK_PhaseCost-1) then
    		 -- Subtract that much RU's
    		 if ShipScAR_Debug_Mode~=0 then
    		  print("Setting player "..i.."'s RU's to "..Player_GetRU(i)-PK_PhaseCost.."!");
    		 end
    		 
    		 Player_SetRU(i, Player_GetRU(i)-PK_PhaseCost);
    		 
    		 -- Disable the ship... like in SP
    		 if ShipScAR_Debug_Mode~=0 then
    		  print("Disabling player "..i.."'s Keeper's Abilites!");
    		 end
    		 
    		 -- Increment the index,
    		 KPR_Destroyer_i[i] = KPR_Destroyer_i[i] + 1
    		 
    		 -- Single keeper. Don't worry about Indexes.
    		 KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[i]] = KPRSob
    		 
    		 -- It seems that the effect is played on the keeper while it disappears into the thin air... hmm...
    		 FX_PlayEffect (PK_Phase_EffectName, KPRSob, 1);
    		 SobGroup_Despawn(KPRSob);
    		 
    		 -- So that even accidentally this code is not executed.
    		 SobGroup_DeSelectAll();
    		 
    		 Rule_AddInterval( "Rule_KPR_Destroyer_Phase", PK_PhaseTime );
    		else
    		 -- Only Clear un-needed SobGroups.
    		 SobGroup_Clear(KPRSob);
    		end
    	   end
    	  end
    	 end
    	end
       elseif SobGroup_Count(KPRSob)~=0 then -- here we go again...
    	-- Split SobGroups....
    	local numShips=SobGroup_SplitGroup("KPRSobB", KPRSob, SobGroup_Count(KPRSob))
    	
    	for j=0,numShips-1 do
    	 SobGroup_Clear(KPRSob);
    	 KPRSob="KPRSobB"..j
    	 
    	 -- Rest is same as "Above" == SingleShip Code
    	 if SobGroup_Selected(KPRSob)~=0 then
    	  -- Make sure they are not hyper-spacing and\or they are not in hyper-space (and any thing related.)
    	  if SobGroup_AreAllInRealSpace(KPRSob)==1 and 
    		SobGroup_IsDoingAbility(KPRSob, AB_Hyperspace)==0 and
    		SobGroup_IsDoingAbility(KPRSob, AB_HyperspaceViaGate)==0 then
    	   -- Now, are they below this health
    	   if PK_HealthThreshold==1 or 
    		 -- if, keeper health is exactly PK_HealthThreshold, then a simple '<' wont allow the code execution below.
    		 -- therefore this *must* be used
    		 not SobGroup_HealthPercentage(KPRSob)>PK_HealthThreshold then
    		-- ERROR: "attempt to compare nil with number" can be prevented by checking whether the player is alive,
    		-- or not. Therefore, "do this now"
    		if Player_IsAlive(i) then
    		 -- Is the player wealthy enough?
    		 -- TODO: should thise be made like hyperspace, cost per meter, base cost, max cost??? Maybe NO.
    		 if Player_GetRU(i)>(PK_PhaseCost-1) then
    		  -- Subtract that much RU's
    		  if ShipScAR_Debug_Mode~=0 then
    		   print("Setting player "..i.."'s RU's to "..Player_GetRU(i)-PK_PhaseCost.."!");
    		  end
    		  
    		  Player_SetRU(i, Player_GetRU(i)-PK_PhaseCost);
    		  
    		  -- Disable the ship... like in SP
    		  if ShipScAR_Debug_Mode~=0 then
    		   print("Disabling player "..i.."'s Keeper's Abilites!");
    		  end
    		  
    		  -- Increment the index,
    		  KPR_Destroyer_i[i] = KPR_Destroyer_i[i] + 1
    		  
    		  -- Single keeper. Don't worry about Indexes.
    		  KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[i]] = KPRSob
    		  
    		  -- It seems that the effect is played on the keeper while it disappears into the thin air... hmm...
    		  FX_PlayEffect (PK_Phase_EffectName, KPRSob, 1);
    		  SobGroup_Despawn(KPRSob);
    		  
    		  -- So that even accidentally this code is not executed.
    		  SobGroup_DeSelectAll();
    		  
    		  Rule_AddInterval( "Rule_KPR_Destroyer_Phase", PK_PhaseTime );
    		 else
    		  -- Only Clear un-needed SobGroups.
    		  SobGroup_Clear(KPRSob);
    		 end
    		end
    	   end
    	  end
    	 end
    	end
       end
      end
      
      if ShipScAR_Debug_Mode>1 then
       print("*SSSUR* -> KPR_Destroyer_PhaseMe == "..KPR_Destroyer_PhaseMe);
      end
     end
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> Leaving Rule_KPR_Destroyer");
     end
    end
    Rule_KPR_Destroyer_Phase = function()   -- 'House-Keeping' function 2
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> At Rule_KPR_Destroyer_Phase");
     end
     
     -- Remove this, only supposed to execute once. So that if any code FAILS, this doesn't execute again and again
     -- Fact: It's not the too much 'code' that starts lagging -- It's too much console (HW2.log) outpute.
     Rule_Remove("Rule_KPR_Destroyer_Phase");
     
     -- Init of a new SobGroup
     local KPRSob="KPRSob"
     SobGroup_Create(KPRSob);
     
     if ShipScAR_Debug_Mode~=0 then
      print("*SSSUR* -> Will try to awaken keepers");
     end
     
     for i=0,Universe_PlayerCount()-1 do
      --	 _v-> No point wasting our time on Non-Progenitors <-v_
      if KPR_Destroyer_i[i]>-1 and Player_GetRace(i)==Race_Keeper then	 -- Race_Keeper=3
       for j=KPR_Destroyer_i[i],0,-1 do
    	local KPRSob=KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[j]]   -- Get mySOBGroup!!!
    	local PK_SpawnVol_Tmp="PK_SpawnVol_Tmp"	   -- A "place-holder"
    	
    	-- Well then begin keeper retrival.
    	if ShipScAR_Debug_Mode~=0 then
    	 print("*SSSUR* -> Trying to awaken keeper(s) of player "..i.."!");
    	end
    	
    	-- Create a volume. 
    	Volume_AddSphere(PK_SpawnVol_Tmp, {
    	 random()*PK_PhaseLocationRandomization, 
    	 random()*PK_PhaseLocationRandomization, 
    	 random()*PK_PhaseLocationRandomization, 
    	}, PK_PhaseLocationRandomization/10 );
    	----------------------------------------------------------
    	-- Note: Function random is providied by LUA; --
    	-- can be called as random(), random(u), random(u,v) --
    	-- returns 0-1, 0-u, [u,v) respectively.  --
    	----------------------------------------------------------
    	
    	SobGroup_ExitHyperSpace(KPRSob, PK_SpawnVol_Tmp);
    	FX_PlayEffect(PK_PhaseOut_EffectName, KPRSob, 1);
    	
    	-- Check the health, fix those scratches...
    	if SobGroup_HealthPercentage( KPRSob ) < PK_PhaseOut_Health then
    	 SobGroup_SetHealth(KPRSob, PK_PhaseOut_Health)
    	end
    	
    	Volume_Delete(PK_SpawnVol_Tmp);	  -- Don't forget to 'de-lit' the Volume
    	SobGroup_Clear(KPRSob);		-- and the SobGroup too!
       end
       
       -- Checking out...
       KPR_Destroyer_i[i]=-1
       
       -- And thank you for using Keeper Phase System. Have a Nice day :)
      end
     end
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> Leaving Rule_KPR_Destroyer_Phase");
     end
    end
    function UnInitShipScAR_KPR()
     Rule_Remove("Rule_KPR_Destroyer");
    end
    That's well commented, so you shouldn't have much problems. As you can see, I have a completely new file. Deathmatch.lua executes the Init (and when the game is stopped the 'UnInit' function ) is called. They, inturn, call functions for other ships. This way, I want to prevent code related to ships cluttering Deathmatch.lua. Also, you can see there is a variable, which controls how much debugging information is given out. I keep it ZERO when not needed. It's not the code which makes lag... its the huge amout of data continously written into files (my experience.)
    The code does work fine. I've tried to stay away from all possible errors that came in my mind. Code for manking a single Keeper phase out twice works, so it MUST properly work [i]n times also. I've used a 'table' and 'index' method of keeping track of SobGroups (like a "Stack")
    So.... am not I the first one to make Keeper phasing work properly and efficiently???

    EDIT:
    Forgot to tell. Race_Keeper must be defined as 3 ("THREE") or else the game may crash and\or you may get limited functionality.
    Last edited by 4E534B; 24th Jun 06 at 10:38 PM.

  24. #24
    Well, I tihnk it's me puttign the cod ein, not oyu guys making errors. Here is a the whole deathmatch.lua
    Code:
    GUID = 
        { 110, 91, 157, 190, 18, 23, 250, 78, 144, 20, 41, 246, 181, 128, 214, 12, }
    GameRulesName = "$3203"
    Description = "$3230"
    GameSetupOptions = 
        { 
        { 
            name = "resources", 
            locName = "$3240", 
            tooltip = "$3239", 
            default = 1, 
            visible = 1, 
            choices = 
                { "$3241", "0.5", "$3242", "1.0", "$3243", "2.0", }, }, 
        { 
            name = "unitcaps", 
            locName = "$3214", 
            tooltip = "$3234", 
            default = 1, 
            visible = 1, 
            choices = 
                { "$3215", "Small", "$3216", "Normal", "$3217", "Large", }, }, 
        { 
            name = "resstart", 
            locName = "$3205", 
            tooltip = "$3232", 
            default = 0, 
            visible = 1, 
            choices = 
                { "$3206", "1000", "$3207", "3000", "$3208", "10000", "$3209", "0", }, }, 
        { 
            name = "lockteams", 
            locName = "$3220", 
            tooltip = "$3235", 
            default = 0, 
            visible = 1, 
            choices = 
                { "$3221", "yes", "$3222", "no", }, }, 
        { 
            name = "startlocation", 
            locName = "$3225", 
            tooltip = "$3237", 
            default = 0, 
            visible = 1, 
            choices = 
                { "$3226", "random", "$3227", "fixed", }, }, 
        }
    dofilepath("data:scripts/scar/restrict.lua")
    Events = {}
    Events.endGame = 
        { 
            { 
                { "wID = Wait_Start(5)", "Wait_End(wID)", }, 
            }, 
        }
    function OnInit()
        MPRestrict()
        Rule_Add("MainRule")
    ----------------------------------------------------------------------------------------------------------
    --	Variables for race: PROGENITOR (KPR)	--
    ----------------------------------------------------------------------------------------------------------
    -- If one, the code will be executed, then, this will be resetted.
    KPR_Destroyer_PhaseMe = 0
    -- Destroyer SobGroup Table
    KPR_Destroyer = {}
    KPR_Destroyer_i = {}
    -- MOVEME: Move this code to ShipScAR_Vars.lua, when finished, and make it a tunable.
    KPR_Destroyer_PhaseMeKey = HKEY
    -- Number of keepers that 'can' phase out at a time (every PK_PhaseTime).
    -- keep this a integer. And realistic
    UC_KPR_Destroyer = 20
    -- Health threshold for progenitor keepers to phase.
    -- if this is kept 1, then health checks will be 'by-passed'
    PK_HealthThreshold = 1
    -- RU cost for phasing-out Progenitor Keepers, and the duration.
    PK_PhaseCost = 500
    PK_PhaseTime = 5 --50
    PK_PhaseLocationRandomization = 10000
    -- Health, they will have after returning from phase state.
    PK_PhaseOut_Health = 1
    -- Event name(s) and duration(s) for the 'phase' effects\events:
    PK_Phase_EffectName = "KPR_Phase_Destroyer_Mesh"
    PK_PhaseOut_EffectName = "KPR_Phase_Destroyer_Mesh_PhaseOut"
    end
    
    function MainRule()
        local playerIndex = 0
        local playerCount = Universe_PlayerCount()
        while  playerIndex<playerCount do
            if  Player_IsAlive(playerIndex)==1 then
                if  Player_HasShipWithBuildQueue(playerIndex)==0 then
                    Player_Kill(playerIndex)
                end 
    
            end 
    
            playerIndex = (playerIndex + 1)
        end 
    
        local numAlive = 0
        local numEnemies = 0
        local gameOver = 1
        playerIndex = 0
        while  playerIndex<playerCount do
            if  Player_IsAlive(playerIndex)==1 then
                local otherPlayerIndex = 0
                while  otherPlayerIndex<playerCount do
                    if  AreAllied(playerIndex, otherPlayerIndex)==0 then
                        if  Player_IsAlive(otherPlayerIndex)==1 then
                            gameOver = 0
                        else
                            numEnemies = (numEnemies + 1)
                        end 
    
                    end 
    
                    otherPlayerIndex = (otherPlayerIndex + 1)
                end 
    
                numAlive = (numAlive + 1)
            end 
    
            playerIndex = (playerIndex + 1)
        end 
    
        if  numEnemies==0 and numAlive>0 then
            gameOver = 0
        end 
    
        if  gameOver==1 then
            Rule_Add("waitForEnd")
            Event_Start("endGame")
            Rule_Remove("MainRule")
        end 
    
    end
    
    ----------------------------------------------------------------------------------------------------------
    --	Functions for race: PROGENITOR (KPR)	--
    ----------------------------------------------------------------------------------------------------------
    function IninShipScAR_KPR()
    if ShipScAR_Debug_Mode==3 then
    print("*SSSU* -> At InitShipScAR_KPR");
    end
     
    ----------------------------------
    -- Routines for KPR_Destroyer --
    ----------------------------------
    if ShipScAR_Debug_Mode~=0 then
    print("*SSSU* -> Binding Key "..KPR_Destroyer_PhaseMeKey.." to Watch_KPR_Destroyer");
    end
     
    UI_BindKeyEvent(HKEY, "Watch_KPR_Destroyer"); -- Watch for House-Keepering Function
    Rule_AddInterval("Rule_KPR_Destroyer", 1); -- House-Keeping function
     
    for i=0,Universe_PlayerCount()-1 do
    for j=0,UC_KPR_Destroyer do
    -- Create a whole load of SobGroups!
    if ShipScAR_Debug_Mode>1 then
    	print("Init Data:"..i..j..".");
    end
     
    KPR_Destroyer[i*UC_KPR_Destroyer+j] = "KPR_Destroyer["..(i*UC_KPR_Destroyer+j).."]"
    SobGroup_Create(KPR_Destroyer[i*UC_KPR_Destroyer+j]);
    SobGroup_Clear(KPR_Destroyer[i*UC_KPR_Destroyer+j]);
    end
     
    -- Don't forget to init the index too!
    KPR_Destroyer_i = 0
    end
    
    if ShipScAR_Debug_Mode==3 then
    print("*SSSU* -> Leaving InitShipScAR_KPR");
    end
    end
    Watch_KPR_Destroyer = function()
    if ShipScAR_Debug_Mode==3 then
    print("*SSSUW* -> At Watch_KPR_Destroyer");
    end
    
    -- Make sure that it is NOT one before proceeding, (Possibiliy, users may press the PhaseKey more than once, in a second.)
    if KPR_Destroyer_PhaseMe~=1 then
    if ShipScAR_Debug_Mode~=0 then
    print("*SSSUW* -> User pressed key "..KPR_Destroyer_PhaseMeKey.."!");
    end
    
    -- Mark it, so that withing next, ummm... ~1-(1/infinity) seconds this code is executed (Well, theorotically, this is true.)
    KPR_Destroyer_PhaseMe=1
    
    -- This code should be kept small, so that even if executed ten times a second, it doesn't make 0.8GHz computers (P3) lag...
    else
    if ShipScAR_Debug_Mode>1 then
    print("*SSSUW* -> Stop pressing key "..KPR_Destroyer_PhaseMeKey.." again and again so quickly! BAD!!!");
    end
    end
    
    Rule_Remove("Watch_KPR_Destroyer");
    
    if ShipScAR_Debug_Mode==3 then
    print("*SSSUW* -> Leaving Watch_KPR_Destroyer");
    end
    end
    Rule_KPR_Destroyer = function()	-- 'House-Keeping' function
    if ShipScAR_Debug_Mode==3 then
    print("*SSSUR* -> At Rule_KPR_Destroyer");
    end
    
    if KPR_Destroyer_PhaseMe==1 then 
    -- Reset this. So that we don't come here again.
    KPR_Destroyer_PhaseMe=0
    
    -- Init of a new SobGroup
    local KPRSob="KPRSob" 
    SobGroup_Create(KPRSob);
    
    for i=0,Universe_PlayerCount()-1 do
    -- Get me the Progenitor Keepers, I'll keep a few of them with me.
    KPRSob=Player_GetShipsByType(i, "KPR_Destroyer")
    
    if ShipScAR_Debug_Mode>1 then
    	print("No of keepers of player "..i.." = "..SobGroup_Count(KPRSob)..".");
    end
    
    if SobGroup_Count(KPRSob)==1 then -- Single Ship
    	-- OK. Very nice to be here. First check whether they are selected,
    	if SobGroup_Selected(KPRSob)~=0 then
    	 -- Make sure they are not hyper-spacing and\or they are not in hyper-space (and any thing related.)
    	 if SobGroup_AreAllInRealSpace(KPRSob)==1 and 
    	 SobGroup_IsDoingAbility(KPRSob, AB_Hyperspace)==0 and
    	 SobGroup_IsDoingAbility(KPRSob, AB_HyperspaceViaGate)==0 then
    	 -- Now, are they below this health
    	 if PK_HealthThreshold==1 or 
    		-- if, keeper health is exactly PK_HealthThreshold, then a simple '<' wont allow the code execution below.
    		-- therefore this *must* be used
    		not SobGroup_HealthPercentage(KPRSob)>PK_HealthThreshold then
    	 -- ERROR: "attempt to compare nil with number" can be prevented by checking whether the player is alive,
    	 -- or not. Therefore, "do this now"
    	 if Player_IsAlive(i) then
    		-- Is the player wealthy enough?
    		-- TODO: should thise be made like hyperspace, cost per meter, base cost, max cost??? Maybe NO.
    		if Player_GetRU(i)>(PK_PhaseCost-1) then
    		 -- Subtract that much RU's
    		 if ShipScAR_Debug_Mode~=0 then
    		 print("Setting player "..i.."'s RU's to "..Player_GetRU(i)-PK_PhaseCost.."!");
    		 end
    		 
    		 Player_SetRU(i, Player_GetRU(i)-PK_PhaseCost);
    		 
    		 -- Disable the ship... like in SP
    		 if ShipScAR_Debug_Mode~=0 then
    		 print("Disabling player "..i.."'s Keeper's Abilites!");
    		 end
    		 
    		 -- Increment the index,
    		 KPR_Destroyer_i[i] = KPR_Destroyer_i[i] + 1
    		 
    		 -- Single keeper. Don't worry about Indexes.
    		 KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[i]] = KPRSob
    		 
    		 -- It seems that the effect is played on the keeper while it disappears into the thin air... hmm...
    		 FX_PlayEffect (PK_Phase_EffectName, KPRSob, 1);
    		 SobGroup_Despawn(KPRSob);
    		 
    		 -- So that even accidentally this code is not executed.
    		 SobGroup_DeSelectAll();
    		 
    		 Rule_AddInterval( "Rule_KPR_Destroyer_Phase", PK_PhaseTime );
    		else
    		 -- Only Clear un-needed SobGroups.
    		 SobGroup_Clear(KPRSob);
    		end
    	 end
    	 end
    	 end
    	end
    elseif SobGroup_Count(KPRSob)~=0 then -- here we go again...
    	-- Split SobGroups....
    	local numShips=SobGroup_SplitGroup("KPRSobB", KPRSob, SobGroup_Count(KPRSob))
    	
    	for j=0,numShips-1 do
    	 SobGroup_Clear(KPRSob);
    	 KPRSob="KPRSobB"..j
    	 
    	 -- Rest is same as "Above" == SingleShip Code
    	 if SobGroup_Selected(KPRSob)~=0 then
    	 -- Make sure they are not hyper-spacing and\or they are not in hyper-space (and any thing related.)
    	 if SobGroup_AreAllInRealSpace(KPRSob)==1 and 
    		SobGroup_IsDoingAbility(KPRSob, AB_Hyperspace)==0 and
    		SobGroup_IsDoingAbility(KPRSob, AB_HyperspaceViaGate)==0 then
    	 -- Now, are they below this health
    	 if PK_HealthThreshold==1 or 
    		 -- if, keeper health is exactly PK_HealthThreshold, then a simple '<' wont allow the code execution below.
    		 -- therefore this *must* be used
    		 not SobGroup_HealthPercentage(KPRSob)>PK_HealthThreshold then
    		-- ERROR: "attempt to compare nil with number" can be prevented by checking whether the player is alive,
    		-- or not. Therefore, "do this now"
    		if Player_IsAlive(i) then
    		 -- Is the player wealthy enough?
    		 -- TODO: should thise be made like hyperspace, cost per meter, base cost, max cost??? Maybe NO.
    		 if Player_GetRU(i)>(PK_PhaseCost-1) then
    		 -- Subtract that much RU's
    		 if ShipScAR_Debug_Mode~=0 then
    		 print("Setting player "..i.."'s RU's to "..Player_GetRU(i)-PK_PhaseCost.."!");
    		 end
    		 
    		 Player_SetRU(i, Player_GetRU(i)-PK_PhaseCost);
    		 
    		 -- Disable the ship... like in SP
    		 if ShipScAR_Debug_Mode~=0 then
    		 print("Disabling player "..i.."'s Keeper's Abilites!");
    		 end
    		 
    		 -- Increment the index,
    		 KPR_Destroyer_i[i] = KPR_Destroyer_i[i] + 1
    		 
    		 -- Single keeper. Don't worry about Indexes.
    		 KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[i]] = KPRSob
    		 
    		 -- It seems that the effect is played on the keeper while it disappears into the thin air... hmm...
    		 FX_PlayEffect (PK_Phase_EffectName, KPRSob, 1);
    		 SobGroup_Despawn(KPRSob);
    		 
    		 -- So that even accidentally this code is not executed.
    		 SobGroup_DeSelectAll();
    		 
    		 Rule_AddInterval( "Rule_KPR_Destroyer_Phase", PK_PhaseTime );
    		 else
    		 -- Only Clear un-needed SobGroups.
    		 SobGroup_Clear(KPRSob);
    		 end
    		end
    	 end
    	 end
    	 end
    	end
    end
    end
    
    if ShipScAR_Debug_Mode>1 then
    print("*SSSUR* -> KPR_Destroyer_PhaseMe == "..KPR_Destroyer_PhaseMe);
    end
    end
    
    if ShipScAR_Debug_Mode==3 then
    print("*SSSUR* -> Leaving Rule_KPR_Destroyer");
    end
    end
    Rule_KPR_Destroyer_Phase = function() -- 'House-Keeping' function 2
    if ShipScAR_Debug_Mode==3 then
    print("*SSSUR* -> At Rule_KPR_Destroyer_Phase");
    end
    
    -- Remove this, only supposed to execute once. So that if any code FAILS, this doesn't execute again and again
    -- Fact: It's not the too much 'code' that starts lagging -- It's too much console (HW2.log) outpute.
    Rule_Remove("Rule_KPR_Destroyer_Phase");
    
    -- Init of a new SobGroup
    local KPRSob="KPRSob"
    SobGroup_Create(KPRSob);
    
    if ShipScAR_Debug_Mode~=0 then
    print("*SSSUR* -> Will try to awaken keepers");
    end
    
    for i=0,Universe_PlayerCount()-1 do
    --	 _v-> No point wasting our time on Non-Progenitors <-v_
    if KPR_Destroyer_i[i]>-1 and Player_GetRace(i)==Race_Keeper then	 -- Race_Keeper=3
    for j=KPR_Destroyer_i[i],0,-1 do
    	local KPRSob=KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[j]] -- Get mySOBGroup!!!
    	local PK_SpawnVol_Tmp="PK_SpawnVol_Tmp"	 -- A "place-holder"
    	
    	-- Well then begin keeper retrival.
    	if ShipScAR_Debug_Mode~=0 then
    	 print("*SSSUR* -> Trying to awaken keeper(s) of player "..i.."!");
    	end
    	
    	-- Create a volume. 
    	Volume_AddSphere(PK_SpawnVol_Tmp, {
    	 random()*PK_PhaseLocationRandomization, 
    	 random()*PK_PhaseLocationRandomization, 
    	 random()*PK_PhaseLocationRandomization, 
    	}, PK_PhaseLocationRandomization/10 );
    	----------------------------------------------------------
    	-- Note: Function random is providied by LUA; --
    	-- can be called as random(), random(u), random(u,v) --
    	-- returns 0-1, 0-u, [u,v) respectively. --
    	----------------------------------------------------------
    	
    	SobGroup_ExitHyperSpace(KPRSob, PK_SpawnVol_Tmp);
    	FX_PlayEffect(PK_PhaseOut_EffectName, KPRSob, 1);
    	
    	-- Check the health, fix those scratches...
    	if SobGroup_HealthPercentage( KPRSob ) < PK_PhaseOut_Health then
    	 SobGroup_SetHealth(KPRSob, PK_PhaseOut_Health)
    	end
    	
    	Volume_Delete(PK_SpawnVol_Tmp);	 -- Don't forget to 'de-lit' the Volume
    	SobGroup_Clear(KPRSob);		-- and the SobGroup too!
    end
    
    -- Checking out...
    KPR_Destroyer_i[i]=-1
    
    -- And thank you for using Keeper Phase System. Have a Nice day :)
    end
    end
    
    if ShipScAR_Debug_Mode==3 then
    print("*SSSUR* -> Leaving Rule_KPR_Destroyer_Phase");
    end
    end
    function UnInitShipScAR_KPR()
    Rule_Remove("Rule_KPR_Destroyer");
    end
    
    function waitForEnd()
        if  Event_IsDone("endGame") then
            setGameOver()
            Rule_Remove("waitForEnd")
        end 
    
    end
    Also, I noticed 2 things, you are playign the effect before the despawn, yet in the SP lua, it is reversed, despawn then effect. Don't know if that makes a diffrence. Also, I tihnk i can make out that it plays the effect when returning, right. That wouldn't make sense. Should be regular hyperspace. (you want to get out quickly, phaseout would take up alot of energy, not enough to do it twice quickly ) Oh yea, forgot, I press H, but under how much health must it have to work?

  25. #25
    My concept: Phase out takes RU's, not energy, like hyper-space.

    You put the code in completely wrong way!!! And I too, never saw that I wrote the code wrongly (a-bit IninShipScAR_KPR() instead of InitShipScAR_KPR() ) It should be like this....
    Code:
    GUID = 
    	{ 110, 91, 157, 190, 18, 23, 250, 78, 144, 20, 41, 246, 181, 128, 214, 12, }
    GameRulesName = "$3203"
    Description = "$3230"
    GameSetupOptions = 
    	{ 
    	{ 
    		name = "resources", 
    		locName = "$3240", 
    		tooltip = "$3239", 
    		default = 1, 
    		visible = 1, 
    		choices = 
    			{ "$3241", "0.5", "$3242", "1.0", "$3243", "2.0", }, }, 
    	{ 
    		name = "unitcaps", 
    		locName = "$3214", 
    		tooltip = "$3234", 
    		default = 1, 
    		visible = 1, 
    		choices = 
    			{ "$3215", "Small", "$3216", "Normal", "$3217", "Large", }, }, 
    	{ 
    		name = "resstart", 
    		locName = "$3205", 
    		tooltip = "$3232", 
    		default = 0, 
    		visible = 1, 
    		choices = 
    			{ "$3206", "1000", "$3207", "3000", "$3208", "10000", "$3209", "0", }, }, 
    	{ 
    		name = "lockteams", 
    		locName = "$3220", 
    		tooltip = "$3235", 
    		default = 0, 
    		visible = 1, 
    		choices = 
    			{ "$3221", "yes", "$3222", "no", }, }, 
    	{ 
    		name = "startlocation", 
    		locName = "$3225", 
    		tooltip = "$3237", 
    		default = 0, 
    		visible = 1, 
    		choices = 
    			{ "$3226", "random", "$3227", "fixed", }, }, 
    	}
    dofilepath("data:scripts/scar/restrict.lua")
    -- Controls how much info is to be given in HW2.log Possible values: 0, 1, 2, 3
    -- Change to zero in release versions....
    ShipScAR_Debug_Mode=1
    ----------------------------------------------------------------------------------------------------------
    --	Variables for race: PROGENITOR (KPR)	--
    ----------------------------------------------------------------------------------------------------------
    -- If one, the code will be executed, then, this will be resetted.
    KPR_Destroyer_PhaseMe = 0
    -- Destroyer SobGroup Table
    KPR_Destroyer = {}
    KPR_Destroyer_i = {}
    -- MOVEME: Move this code to ShipScAR_Vars.lua, when finished, and make it a tunable.
    KPR_Destroyer_PhaseMeKey = HKEY
    -- Number of keepers that 'can' phase out at a time (every PK_PhaseTime).
    -- keep this a integer. And realistic
    UC_KPR_Destroyer = 20
    -- Health threshold for progenitor keepers to phase.
    -- if this is kept 1, then health checks will be 'by-passed'
    PK_HealthThreshold = 1
    -- RU cost for phasing-out Progenitor Keepers, and the duration.
    PK_PhaseCost = 500
    PK_PhaseTime = 5 --50
    PK_PhaseLocationRandomization = 10000
    --  Health, they will have after returning from phase state.
    PK_PhaseOut_Health = 1
    -- Event name(s) and duration(s) for the 'phase' effects\events:
    PK_Phase_EffectName = "KPR_Phase_Destroyer_Mesh"
    PK_PhaseOut_EffectName = "KPR_Phase_Destroyer_Mesh_PhaseOut"
    ----------------------------------------------------------------------------------------------------------
    --	Functions for race: PROGENITOR (KPR)	--
    ----------------------------------------------------------------------------------------------------------
    function InitShipScAR_KPR()
     if ShipScAR_Debug_Mode==3 then
      print("*SSSU* -> At InitShipScAR_KPR");
     end
     
     ----------------------------------
     -- Routines for KPR_Destroyer --
     ----------------------------------
     if ShipScAR_Debug_Mode~=0 then
      print("*SSSU* -> Binding Key "..KPR_Destroyer_PhaseMeKey.." to Watch_KPR_Destroyer");
     end
     
     UI_BindKeyEvent(HKEY, "Watch_KPR_Destroyer");  -- Watch for House-Keepering Function
     Rule_AddInterval("Rule_KPR_Destroyer", 1);   -- House-Keeping function
     
     for i=0,Universe_PlayerCount()-1 do
      for j=0,UC_KPR_Destroyer do
       -- Create a whole load of SobGroups!
       if ShipScAR_Debug_Mode>1 then
    	print("Init Data:"..i..j..".");
       end
       
       KPR_Destroyer[i*UC_KPR_Destroyer+j] = "KPR_Destroyer["..(i*UC_KPR_Destroyer+j).."]"
       SobGroup_Create(KPR_Destroyer[i*UC_KPR_Destroyer+j]);
       SobGroup_Clear(KPR_Destroyer[i*UC_KPR_Destroyer+j]);
      end
      
      -- Don't forget to init the index too!
      KPR_Destroyer_i[i] = 0
     end
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSU* -> Leaving InitShipScAR_KPR");
     end
    end
    Watch_KPR_Destroyer = function()
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUW* -> At Watch_KPR_Destroyer");
     end
     
     -- Make sure that it is NOT one before proceeding, (Possibiliy, users may press the PhaseKey more than once, in a second.)
     if KPR_Destroyer_PhaseMe~=1 then
      if ShipScAR_Debug_Mode~=0 then
       print("*SSSUW* -> User pressed key "..KPR_Destroyer_PhaseMeKey.."!");
      end
      
      -- Mark it, so that withing next, ummm... ~1-(1/infinity) seconds this code is executed (Well, theorotically, this is true.)
      KPR_Destroyer_PhaseMe=1
      
      -- This code should be kept small, so that even if executed ten times a second, it doesn't make 0.8GHz computers (P3) lag...
     else
      if ShipScAR_Debug_Mode>1 then
       print("*SSSUW* -> Stop pressing key "..KPR_Destroyer_PhaseMeKey.." again and again so quickly! BAD!!!");
      end
     end
     
     Rule_Remove("Watch_KPR_Destroyer");
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUW* -> Leaving Watch_KPR_Destroyer");
     end
    end
    Rule_KPR_Destroyer = function()	-- 'House-Keeping' function
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> At Rule_KPR_Destroyer");
     end
     
     if KPR_Destroyer_PhaseMe==1 then 
      -- Reset this. So that we don't come here again.
      KPR_Destroyer_PhaseMe=0
      
      -- Init of a new SobGroup
      local KPRSob="KPRSob" 
      SobGroup_Create(KPRSob);
      
      for i=0,Universe_PlayerCount()-1 do
       -- Get me the Progenitor Keepers, I'll keep a few of them with me.
       KPRSob=Player_GetShipsByType(i, "KPR_Destroyer")
       
       if ShipScAR_Debug_Mode>1 then
    	print("No of keepers of player "..i.." = "..SobGroup_Count(KPRSob)..".");
       end
       
       if SobGroup_Count(KPRSob)==1 then  -- Single Ship
    	-- OK. Very nice to be here. First check whether they are selected,
    	if SobGroup_Selected(KPRSob)~=0 then
    	 -- Make sure they are not hyper-spacing and\or they are not in hyper-space (and any thing related.)
    	 if SobGroup_AreAllInRealSpace(KPRSob)==1 and 
    	   SobGroup_IsDoingAbility(KPRSob, AB_Hyperspace)==0 and
    	   SobGroup_IsDoingAbility(KPRSob, AB_HyperspaceViaGate)==0 then
    	  -- Now, are they below this health
    	  if PK_HealthThreshold==1 or 
    		-- if, keeper health is exactly PK_HealthThreshold, then a simple '<' wont allow the code execution below.
    		-- therefore this *must* be used
    		not SobGroup_HealthPercentage(KPRSob)>PK_HealthThreshold then
    	   -- ERROR: "attempt to compare nil with number" can be prevented by checking whether the player is alive,
    	   -- or not. Therefore, "do this now"
    	   if Player_IsAlive(i) then
    		-- Is the player wealthy enough?
    		-- TODO: should thise be made like hyperspace, cost per meter, base cost, max cost??? Maybe NO.
    		if Player_GetRU(i)>(PK_PhaseCost-1) then
    		 -- Subtract that much RU's
    		 if ShipScAR_Debug_Mode~=0 then
    		  print("Setting player "..i.."'s RU's to "..Player_GetRU(i)-PK_PhaseCost.."!");
    		 end
    		 
    		 Player_SetRU(i, Player_GetRU(i)-PK_PhaseCost);
    		 
    		 -- Disable the ship... like in SP
    		 if ShipScAR_Debug_Mode~=0 then
    		  print("Disabling player "..i.."'s Keeper's Abilites!");
    		 end
    		 
    		 -- Increment the index,
    		 KPR_Destroyer_i[i] = KPR_Destroyer_i[i] + 1
    		 
    		 -- Single keeper. Don't worry about Indexes.
    		 KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[i]] = KPRSob
    		 
    		 -- It seems that the effect is played on the keeper while it disappears into the thin air... hmm...
    		 FX_PlayEffect (PK_Phase_EffectName, KPRSob, 1);
    		 SobGroup_Despawn(KPRSob);
    		 
    		 -- So that even accidentally this code is not executed.
    		 SobGroup_DeSelectAll();
    		 
    		 Rule_AddInterval( "Rule_KPR_Destroyer_Phase", PK_PhaseTime );
    		else
    		 -- Only Clear un-needed SobGroups.
    		 SobGroup_Clear(KPRSob);
    		end
    	   end
    	  end
    	 end
    	end
       elseif SobGroup_Count(KPRSob)~=0 then -- here we go again...
    	-- Split SobGroups....
    	local numShips=SobGroup_SplitGroup("KPRSobB", KPRSob, SobGroup_Count(KPRSob))
    	
    	for j=0,numShips-1 do
    	 SobGroup_Clear(KPRSob);
    	 KPRSob="KPRSobB"..j
    	 
    	 -- Rest is same as "Above" == SingleShip Code
    	 if SobGroup_Selected(KPRSob)~=0 then
    	  -- Make sure they are not hyper-spacing and\or they are not in hyper-space (and any thing related.)
    	  if SobGroup_AreAllInRealSpace(KPRSob)==1 and 
    		SobGroup_IsDoingAbility(KPRSob, AB_Hyperspace)==0 and
    		SobGroup_IsDoingAbility(KPRSob, AB_HyperspaceViaGate)==0 then
    	   -- Now, are they below this health
    	   if PK_HealthThreshold==1 or 
    		 -- if, keeper health is exactly PK_HealthThreshold, then a simple '<' wont allow the code execution below.
    		 -- therefore this *must* be used
    		 not SobGroup_HealthPercentage(KPRSob)>PK_HealthThreshold then
    		-- ERROR: "attempt to compare nil with number" can be prevented by checking whether the player is alive,
    		-- or not. Therefore, "do this now"
    		if Player_IsAlive(i) then
    		 -- Is the player wealthy enough?
    		 -- TODO: should thise be made like hyperspace, cost per meter, base cost, max cost??? Maybe NO.
    		 if Player_GetRU(i)>(PK_PhaseCost-1) then
    		  -- Subtract that much RU's
    		  if ShipScAR_Debug_Mode~=0 then
    		   print("Setting player "..i.."'s RU's to "..Player_GetRU(i)-PK_PhaseCost.."!");
    		  end
    		  
    		  Player_SetRU(i, Player_GetRU(i)-PK_PhaseCost);
    		  
    		  -- Disable the ship... like in SP
    		  if ShipScAR_Debug_Mode~=0 then
    		   print("Disabling player "..i.."'s Keeper's Abilites!");
    		  end
    		  
    		  -- Increment the index,
    		  KPR_Destroyer_i[i] = KPR_Destroyer_i[i] + 1
    		  
    		  -- Single keeper. Don't worry about Indexes.
    		  KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[i]] = KPRSob
    		  
    		  -- It seems that the effect is played on the keeper while it disappears into the thin air... hmm...
    		  FX_PlayEffect (PK_Phase_EffectName, KPRSob, 1);
    		  SobGroup_Despawn(KPRSob);
    		  
    		  -- So that even accidentally this code is not executed.
    		  SobGroup_DeSelectAll();
    		  
    		  Rule_AddInterval( "Rule_KPR_Destroyer_Phase", PK_PhaseTime );
    		 else
    		  -- Only Clear un-needed SobGroups.
    		  SobGroup_Clear(KPRSob);
    		 end
    		end
    	   end
    	  end
    	 end
    	end
       end
      end
      
      if ShipScAR_Debug_Mode>1 then
       print("*SSSUR* -> KPR_Destroyer_PhaseMe == "..KPR_Destroyer_PhaseMe);
      end
     end
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> Leaving Rule_KPR_Destroyer");
     end
    end
    Rule_KPR_Destroyer_Phase = function()   -- 'House-Keeping' function 2
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> At Rule_KPR_Destroyer_Phase");
     end
     
     -- Remove this, only supposed to execute once. So that if any code FAILS, this doesn't execute again and again
     -- Fact: It's not the too much 'code' that starts lagging -- It's too much console (HW2.log) outpute.
     Rule_Remove("Rule_KPR_Destroyer_Phase");
     
     -- Init of a new SobGroup
     local KPRSob="KPRSob"
     SobGroup_Create(KPRSob);
     
     if ShipScAR_Debug_Mode~=0 then
      print("*SSSUR* -> Will try to awaken keepers");
     end
     
     for i=0,Universe_PlayerCount()-1 do
      --	 _v-> No point wasting our time on Non-Progenitors <-v_
      if KPR_Destroyer_i[i]>-1 and Player_GetRace(i)==Race_Keeper then	 -- Race_Keeper=3
       for j=KPR_Destroyer_i[i],0,-1 do
    	local KPRSob=KPR_Destroyer[i*UC_KPR_Destroyer+KPR_Destroyer_i[j]]   -- Get mySOBGroup!!!
    	local PK_SpawnVol_Tmp="PK_SpawnVol_Tmp"	   -- A "place-holder"
    	
    	-- Well then begin keeper retrival.
    	if ShipScAR_Debug_Mode~=0 then
    	 print("*SSSUR* -> Trying to awaken keeper(s) of player "..i.."!");
    	end
    	
    	-- Create a volume. 
    	Volume_AddSphere(PK_SpawnVol_Tmp, {
    	 random()*PK_PhaseLocationRandomization, 
    	 random()*PK_PhaseLocationRandomization, 
    	 random()*PK_PhaseLocationRandomization, 
    	}, PK_PhaseLocationRandomization/10 );
    	----------------------------------------------------------
    	-- Note: Function random is providied by LUA; --
    	-- can be called as random(), random(u), random(u,v) --
    	-- returns 0-1, 0-u, [u,v) respectively.  --
    	----------------------------------------------------------
    	
    	SobGroup_ExitHyperSpace(KPRSob, PK_SpawnVol_Tmp);
    	FX_PlayEffect(PK_PhaseOut_EffectName, KPRSob, 1);
    	
    	-- Check the health, fix those scratches...
    	if SobGroup_HealthPercentage( KPRSob ) < PK_PhaseOut_Health then
    	 SobGroup_SetHealth(KPRSob, PK_PhaseOut_Health)
    	end
    	
    	Volume_Delete(PK_SpawnVol_Tmp);	  -- Don't forget to 'de-lit' the Volume
    	SobGroup_Clear(KPRSob);		-- and the SobGroup too!
       end
       
       -- Checking out...
       KPR_Destroyer_i[i]=-1
       
       -- And thank you for using Keeper Phase System. Have a Nice day :)
      end
     end
     
     if ShipScAR_Debug_Mode==3 then
      print("*SSSUR* -> Leaving Rule_KPR_Destroyer_Phase");
     end
    end
    function UnInitShipScAR_KPR()
     Rule_Remove("Rule_KPR_Destroyer");
    end
    Events = {}
    Events.endGame = 
    	{ 
    		{ 
    			{ "wID = Wait_Start(5)", "Wait_End(wID)", }, 
    		}, 
    	}
    function OnInit()
    	MPRestrict()
    	Rule_Add("MainRule")
    	
    	-- Init ShipScAR for the Keepers
    	InitShipScAR_KPR();
    end
    function MainRule()
    	local playerIndex = 0
    	local playerCount = Universe_PlayerCount()
    	while  playerIndex<playerCount do
    		if  Player_IsAlive(playerIndex)==1 then
    			if  Player_HasShipWithBuildQueue(playerIndex)==0 then
    				Player_Kill(playerIndex)
    			end 
    		end 
    		playerIndex = (playerIndex + 1)
    	end 
    	local numAlive = 0
    	local numEnemies = 0
    	local gameOver = 1
    	playerIndex = 0
    	while  playerIndex<playerCount do
    		if  Player_IsAlive(playerIndex)==1 then
    			local otherPlayerIndex = 0
    			while  otherPlayerIndex<playerCount do
    				if  AreAllied(playerIndex, otherPlayerIndex)==0 then
    					if  Player_IsAlive(otherPlayerIndex)==1 then
    						gameOver = 0
    					else
    						numEnemies = (numEnemies + 1)
    					end 
    				end 
    				otherPlayerIndex = (otherPlayerIndex + 1)
    			end 
    			numAlive = (numAlive + 1)
    		end 
    		playerIndex = (playerIndex + 1)
    	end 
    	if  numEnemies==0 and numAlive>0 then
    		gameOver = 0
    	end 
    	if  gameOver==1 then
    		Rule_Add("waitForEnd")
    		Event_Start("endGame")
    		Rule_Remove("MainRule")
    	end 
    end
    function waitForEnd()
    	if  Event_IsDone("endGame") then
    		setGameOver()
    		Rule_Remove("waitForEnd")
    	end 
    	-- Remove all rules related to ShipScAR
    	UnInit_ShipScAR_KPR();
    end
    As you can see (If you'v read this ), I've modified waitForEnd() and OnInit() functions. Rest, order is changed. Look in the TOP, I *told* you this is not a copy and paste function. That has some useful things, if you wan't to change some other things than the ones for which I've added variables, then you will have to get help...

  26. #26
    Okay, I still don't think it works. Sorry, but if you like I can give oyu the enthier Data folder to see for youself. Maybe it's just me.

  27. #27
    First, copy and paste the entire HW2.log.
    OK? Then do this:
    Change this:
    Code:
    -- Controls how much info is to be given in HW2.log Possible values: 0, 1, 2, 3
    -- Change to zero in release versions....
    ShipScAR_Debug_Mode=1
    To This:
    Code:
    -- Controls how much info is to be given in HW2.log Possible values: 0, 1, 2, 3
    -- Change to zero in release versions....
    ShipScAR_Debug_Mode=3
    THEN post the HW2.log And don't worry if its 100 kb and you get a lots of laaaaaaaa.......................gg in MP

    Quote Originally Posted by EhraniNavy
    but the random function will land you in about the same place every time for some reason

    That's cause (I believe) RandomRange(x,y) maybe the RandomInt(x,y) functions are broken. Where these don't work, try using the random() function provided by lua

  28. #28
    Member Le Sun Tzu's Avatar
    Join Date
    Oct 2005
    Location
    City of Light
    Ehranyi: I don't think lua random accepts negative numbers as arguments. random(0, 60000) - 30000 will return a number between -30000 and 30000

  29. #29
    I don't think lua random accepts negative numbers as arguments. random(0, 60000) - 30000 will return a number between -30000 and 30000
    Change the assertion to quoation. By experimentation. I've tried -ve numbers, all I get is zero. So that means -- You're right - Lua hates -ve.

  30. #30
    Well, the HW2.log won't help musg, since the game loads, it's just when I try to get the Phaseout to activate, it won't go. The log says nothig. But I will still do what you told me.

  31. #31
    Listen fella (not Intending to be rude, nor intending to flame) It was I who made this code work, not for keepers, but for other ships too. ( using code of Apolloyon470 - SobGroup Spliting ) Have a good look at it. I can explain purpose of each and every thing, I can tell each and every line (in general, function of code) without looking at it. Because I made it. Look at it. You will see that at different places there is one line from these:

    Code:
    if ShipScAR_Debug_Mode~=0
    if ShipScAR_Debug_Mode>0
    if ShipScAR_Debug_Mode>1
    if ShipScAR_Debug_Mode>2
    So if you do as I say (a few posts above), we may (and will) be able to find out the bug, squash it for GOOD and maybe prevent more from coming


    [I DON'T intend to hurt your feelings, nevermind about anything, though what I have said, or written above is TRUE]

  32. #32
    Am I missing something?

  33. #33
    No, I am telling you to change the ShipScAR_Debug_Mode to 3 at the top (almost at the top) and then post your HW2.log HERE

  34. #34
    Member maxdamage's Avatar
    Join Date
    Dec 2003
    Location
    Gauteng,South Africa
    Just for fun I did the following:
    I replaced the code in the hyperspace_gate_kpr.lua file with the code from the kpr_phase_destroyer_mesh_phaseout.lua and this is what I got when hyperspacing a kpr ship:



    maxdamage.
    ::

  35. #35
    Great -- I dodn't knew you could use any effect for hyperspace. Thanks for telling us.

    Though I don't think that it would look very neat if we just used PhaseEffects instead of Hyperspace and phase effects.

  36. #36
    Member Thunderbolt's Avatar
    Join Date
    Apr 2004
    Location
    Cumberland, MD USA
    was the camera close the the ship you where hyperspacing or is the effect oversized ?

  37. #37
    Is that a Shadow Battlecrab?
    SCIENCE!*Warning: Unsuitable for the epileptic-prone*

  38. #38
    Member maxdamage's Avatar
    Join Date
    Dec 2003
    Location
    Gauteng,South Africa
    @Thunderbolt

    The effect is oversized.Could possibly be scaled down to look right?Look at the Bentus wreck and you'll see the Keeper destroyer nearby.
    Been thinking of adding all the code for the phase out and phase in together to see what happens for the hyperspace effect?

    @LynX

    Yes.That is my Shadow Battlecrab at 20138 faces.



    maxdamage.

  39. #39
    Quote Originally Posted by maxdamage
    Could possibly be scaled down to look right?
    You will have tgo change the radius of the ring so that it is rescaled by HW2 to 'fit' the destroyer... I think it would be easier to script and code it than this...

  40. #40
    Member maxdamage's Avatar
    Join Date
    Dec 2003
    Location
    Gauteng,South Africa
    posted by4E534B:
    You will have tgo change the radius of the ring so that it is rescaled by HW2 to 'fit' the destroyer... I think it would be easier to script and code it than this...

    Now what code must I add or change in the modified hyperspace_gate_kpr.lua to make the effect smaller?



    maxdamage.

  41. #41
    hyperspace_gate_kpr.lua or kpr_phase_destroyer_mesh_phaseout.lua -- doesn't matter since they are same, right?

    ok. so now hyperspace_gate_kpr.lua is a effect file with a ring effect. You'll need to change it's radius. try guessing and reducing its radius. It'll take more than one tries, so you'll have to do it many times, to make it of the correct size.

  42. #42
    wow! i missed alot. sorry guys, but i've been away. looks like oyu have alot of progress? (getting myself up-to-date atm)

    Edit: I tired it mayself, but i just used
    Code:
    NewShipType.alternativeHyperspaceV = "kpr_phase_destroyer_mesh"
    in the ship file instead. I guess you need to edit some of the kpr_phase_destroyer_mesh.lua for it to work properly. hmm...

  43. #43
    Member maxdamage's Avatar
    Join Date
    Dec 2003
    Location
    Gauteng,South Africa
    I modified the radius of the effect but it had no effect to the hyperspace_gate_kpr?
    From this:
    Code:
    { 
                name = "Radius", 
                type = "VARTYPE_ARRAY_TIMEFLOAT", 
                value = 
                    { 0, 1, 1, 1, }, },
    to this:
    Code:
    { 
                name = "Radius", 
                type = "VARTYPE_ARRAY_TIMEFLOAT", 
                value = 
                    { 0, 0.01, 0.01, 0.01, }, },


    maxdamage

  44. #44
    It goes:

    time, radius, time, radius

    So you might want it to be more like this:

    0, 0.1, 1, 0.1

    -Stefan-

  45. #45
    Sastrei was right. It works. But now, I just need to find the correct size. It's still oversized, just not as much.



    Edit: Well, I got the size part right, but it doen't work perfect. I phases out, but it doesn't look..."believable".
    Last edited by Shipyard Nabal; 12th Jul 06 at 11:17 AM.

  46. #46
    Member maxdamage's Avatar
    Join Date
    Dec 2003
    Location
    Gauteng,South Africa
    I modified that piece of the modified hyperspace_gate_kpr in the hope it will make the effect smaller but obviously it did not work.


    @Shipyard Nabal

    What did you modify in the modified hyperspace_gate_kpr to make the effect smaller?

    Honestly I have no clue( ) what I'm doing as I really sucked in match when I was in high school....

    maxdamage.

  47. #47
    Code:
    { 
                name = "Radius", 
                type = "VARTYPE_ARRAY_TIMEFLOAT", 
                value = 
                    { 0, 0.009, 1, 0.009, }, },
    Use that.

  48. #48
    Member maxdamage's Avatar
    Join Date
    Dec 2003
    Location
    Gauteng,South Africa
    Thanks.I tried the code and you're right the phase out doesn't look believable but the size is right!There must be a way to get it right?



    maxdamage.

  49. #49
    Only with gametype code, if even.

  50. #50
    Member Thunderbolt's Avatar
    Join Date
    Apr 2004
    Location
    Cumberland, MD USA
    can someone look and see what file or filetype might be referenced for the effect itself ? is there a file name listed or is there just alot of cords and vertices listed ?

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •