Results 1 to 43 of 43

Coding an upgrade requirement that Allies must follow?

  1. #1
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat

    Coding an upgrade requirement that Allies must follow?

    Ok so let me explain my dilema...

    There is the air_recon ability and the Allies strafing run and I want to make it so that one of these abilities is active it locks down the other one for the duration of the ability. So what I have done is added a blank upgrade, with only the appropriate ucs entry for the requirement. And when I use the upgrade_add and upgrade_remove from the abilities start_self_abilities and end_self_abilities.

    However using this method only affects the user, not the whole team, which is what I want. By applying the exact same setup and using a scar_function_call to replace the upgrade_add and upgrade_remove, I have come up with something like this:

    Code:
    function Airspace_Shared_Timer_on()
    	for i = 1, World_GetPlayerCount() do
    		player = World_GetPlayerAt(i)
    		
    		if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
    			Cmd_InstantUpgrade(player, UPG.CW.AIRBORNE_SHAREDTIMER, ITEM_UNLOCKED)
    		end
    	end
    end
    
    function Airspace_Shared_Timer_off()
    	for i = 1, World_GetPlayerCount() do
    		player = World_GetPlayerAt(i)
    		
    		if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
    			Cmd_InstantUpgrade(player, UPG.CW.AIRBORNE_SHAREDTIMER, ITEM_LOCKED)
    		end
    	end
    end
    However ingame when I have unlocked the upgrade (this making the requirements incomplete) there is no help ucs text and the abilities stay un-useable even when I have locked the upgrade again...

    Does anybody know how to solve this issue?

  2. #2
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Does anybody think its due to the trying of unloading the upgrade? (ITEM_LOCKED) or is it supposed to be (ITEM_REMOVED) instead?
    Anyway I'm going to try it by running an ability instead of an upgrade through the scar coding. This way it should work, since I have previously got it working with the ability loading the upgrade.rgd instead.

  3. #3
    Not great on the mod side of things, but with map scar ITEM_UNLOCKED, LOCKED, REMOVED etc behave strangely at times. Generally REMOVED cannot be reversed by UNLOCKING, and frankly I try to LOCK and UNLOCK as infrequently as possible - they're effected by player tech upgrades (e.g. locking British Stuart tanks, will automatically unlock when player builds 1st captain, etc), and it just doesn't seem to stick properly at times.

    Think the ability way of doing it sounds more reliable.

  4. #4
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    Cmd_InstantUpgrade() does not have a parameter for locking an item. You are thinking of a different function. You are essentially passing an integer as an argument, for which the parameter is the number of upgrades to add to that player.

    Code:
    Void  Cmd_InstantUpgrade( PlayerID/EGroupID/SGroupID target, UpgradeBlueprint/Table blueprint[, Integer count] )
    What I would recommend is making two abilities. One that adds the upgrade and another that removes it. Then use Cmd_Ability() instead of Cmd_InstantUpgrade(). The abilities you want to be "locked" should have the not present requirement, so that when the upgrade is added the ability is unusable and has the red text with a UCS explanation.

    The reason for having two abilities to add or remove the upgrade is because SCAR is not really equipped to handle upgrades very well, but you can work around this by using abilities in SCAR to handle them instead.

  5. #5
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Cmd_Ability()
    I tried this and it led to a crash everytime... however I think this is down to the target?
    Code:
    Void  Cmd_Ability( PlayerID/EGroupID/SGroupID user, AbilityBlueprint blueprint, [Position/SGroupID/EGroupID target, Position direction, Bool skipCostPrereq, Bool queued] )

  6. #6
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    @DB What I don't understand is, why you need such thing in a coded variant. It is even easier to do it via a simple rgd edit.

  7. #7
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    @Darkbladecr
    I left out the arguments as you would just fill them in. There is no target parameter. Also, anything in square brackets [] is optional.

    So, based on the code you included in the first post, you would do something like this:

    Code:
    Cmd_Ability(player, ABILITY.WHATEVER.WHEREVER);
    Last edited by eliw00d; 28th Mar 12 at 10:29 AM.

  8. #8
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    @Eliw00d
    Oh I didn't know that! Thanks!

    @DB What I don't understand is, why you need such thing in a coded variant. It is even easier to do it via a simple rgd edit.
    Well we have a custom scar script to remove the Apache and Blackhawk models after their ability (so that it doesn't come up as lost vehicle on the leaderboard) and if there are two blackhawks on the field, when the first one is done and the scar function is called it removes the second one as well.

    To overcome this we want to set a requirement for all Allies that only one Blackhawk/apache can be on the field at a time. Likewise I would like to do this with our Hack attack, and Economic Sanction abilities so that the AI/players will not stack them leading to unintentional reduction in incomes/production speed (due to stacking)

  9. #9
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    Did you try making globally unique SGroups for your Blackhawks?

  10. #10
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Well we have a custom scar script to remove the Apache and Blackhawk models after their ability (so that it doesn't come up as lost vehicle on the leaderboard) and if there are two blackhawks on the field, when the first one is done and the scar function is called it removes the second one as well.
    This will be also be possible via a simple rgd edit. The removing of the helicopter you can still do via your scar script, what can be called from the rgd via an scar_function_call (in actions).

    we want to set a requirement for all Allies that only one Blackhawk/apache can be on the field at a time.
    Also this is much easier to handle by an rgd requirement. In this special case it would require two requirements and one upgrade. the "required_cap" requirement will work for a player only, so if you spawn a Blackhawk/Apache you have also to add a team upgrade. The second requirement will be then that this team_upgrade is present by using "required_team_upgrade" which has to be set to "using_and_display = false".

    But if you prefer the scar controlled method overall, I can understand it also and do respect this.

  11. #11
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    This will be also be possible via a simple rgd edit. The removing of the helicopter you can still do via your scar script, what can be called from the rgd via an scar_function_call (in actions).
    I know, that is currently how it is setup

    The second requirement will be then that this team_upgrade is present by using "required_team_upgrade" which has to be set to "using_and_display = false".
    I am not aware of this. I asked my coders if they could do it with rgd and they said they had no idea how to share the timer across all team members, so I went ahead and went for the scar path. If there is a much simpler way through rgd I'm all ears.

    globally unique SGroups for your Blackhawks?
    I didn't code it, SirPsycho did it for us a long time ago, so probably not. I'm not experienced enough to really know how to set this up. Our current coding is like this:
    Code:
    function Blackhawk_Remove_Function()
        
        local sg_blackhawk = SGroup_CreateIfNotFound("sg_blackhawk")
        
        for i = 1, World_GetPlayerCount() do
            player = World_GetPlayerAt(i)
            
            if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
                
                SGroup_Clear(sg_blackhawk)
                Player_GetAll(player, sg_blackhawk)
                SGroup_Filter(sg_blackhawk, SBP.CW.BLACKHAWK, FILTER_KEEP)
                if SGroup_IsEmpty("sg_blackhawk") == false then
                SGroup_DestroyAllSquads(sg_blackhawk)
                Rule_RemoveMe()
                end
            end
        end
    end

  12. #12
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    I am not aware of this. I asked my coders if they could do it with rgd and they said they had no idea how to share the timer across all team members, so I went ahead and went for the scar path. If there is a much simpler way through rgd I'm all ears.
    OK then, for what reason this timer is used in detail? For the time intervals in which this ability can used? If so this you can trigger via scar, by removing or adding the ability itself.

  13. #13
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    If so this you can trigger via scar, by removing or adding the ability itself.
    It is a doctrine ability, so I do not want to hide the ability. Anyway I'm going to see if I can just upgrade_add and upgrade_remove through independent abilities that are loaded through scar as Eliw00d suggested. Hopefully it shouldn't crash the game this time, as I will not put in the position variable.

  14. #14
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Try it your way first then.

  15. #15
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    I tried this with an ability just like you suggested Eliw00d I set the ability to be timed that way the upgrade_add would only last the duration I set, which would be the same as the ability.

    When I test ingame I get a crash, the final line in the warnings.log is:
    Code:
    Warning: no squad leader entity set for entities: ebps\races\amer\vehicles\blackhawk
    -- Seems like this is causing the crash... I have tried to add the leader_ext to the blackhawk ebps but there is still a crash?

    There is also this in the designmessages:
    Code:
    MOD -- WARNING: Missing movingextinfo for SBP "sbps\races\amer\vehicles\blackhawk" cannot spawn!
    Ignore this, this still appears even when the scar function is not loaded (does not cause crash)

    Code:
    function Airspace_Shared_Timer_on()
    	for i = 1, World_GetPlayerCount() do
    		player = World_GetPlayerAt(i)
    		
    		if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
    			Cmd_Ability(player, ABILITY.CW.AIRSPACE_TIMER)
    		end
    	end
    end
    Last edited by Darkbladecr; 28th Mar 12 at 5:15 PM.

  16. #16
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    Check your scarlog. What do you mean by crash? As in, crash to desktop? Or a Fatal SCAR Error?

  17. #17
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Crash to desktop. There is nothing in the scarlog

  18. #18
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    At loading time or ingame after using something of the involved stuff? If this crash comes from scar you could add some print statements inside the code, the best before and after a function is called. This way you have the chance to get the position (function) which cause the crash.

  19. #19
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    There is only one thing in the function_call as you can see above:
    Cmd_Ability(player, ABILITY.CW.AIRSPACE_TIMER)
    And yes... it is properly coded in the luaconsts.scar

    It crashes only when I add the Cmd_Ability if I comment it out, it doesn't. And the only change in the logs is that leader entity issue..

    Code:
    -- Log file for all error messages related to the Scar --
    
    Starting SCAR...
    VPTicker_OnInit
    Sound_Play2D unable to play sound file ambiences/ambiences_streamed/cxp2/genericambiences/backgrounds/wind/layers/generic_wind_rain
    Sound_Play2D unable to play sound file specialfx/radiofuzz
    Sound_Play2D unable to play sound file specialfx/tiger_radio_bg
    Sound_Play2D unable to play sound file mastereffects/reverbs/reverb_master
    Sound_Play2D unable to play sound file music/genericmissionmusic_cxp
    
    ***************************************
    * Modern Combat      : Version: 01.00
    * Modern Combat AI : Version: 00.02
    ***************************************
    
    ***CHEATMOD PRESENT***
    Here is the scarlog for proof, you can see it is a crash as there is no proper closing of the log:
    Code:
    WC_OnPlayerKilled
    Shutting Down SCAR...

  20. #20
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Did you check the ability separately "ABILITY.CW.AIRSPACE_TIMER", I meant without using it with scar? If the PlayerID/EGroupID/SGroupID (the first parameter) given to the Cmd_Ability is valid and is alive this should work, if the ability does not be the problem. Can you test this with another ability?

  21. #21
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    Since your SCAR log doesn't have any errors, it must be with the way you set up the ability in Mod Studio.

  22. #22
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Can you test this with another ability?
    Which one should I test with? All other abilities generally are targeted or only affect a certain squad?

    I'll try with the blitzkreig ability, so that all infantry and tanks get a fx on top of them and move faster.

  23. #23
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Ok tested with this Blitzkreig ability...

    There is no crash, so I guess it was down to my ability rgd
    However the function is called (I checked as I made a title message appear after the load of the ability, so it works) but the ability does not affect the player. I added the upgrade add to the Blitzkrieg ability (for now), and there is no change in my infantry/vehicle movement speed along with no FX, and the upgrade_add does not seem to have worked, since it does not lock down the other air abilities even though the requirements are correctly setup (I tested with just a normal upgrade_add and upgrade_remove to be sure)

  24. #24
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    That was my guess, so I mentioned the independent tests. So how we can help with this ability? Could you post the lua export of this ability? I I recall correct an upgrade_add does only add the upgrade as a possible upgrade but does not upgrading directly. It's more like an ability_add, which does not use the ability directly.

  25. #25
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Ok forget this requirement stuff... since it isn't working out for me, I have an alternative. Can we get scar to look for the SGroup, like I have in my script:

    Code:
    function Blackhawk_Remove_Function()
        
        local sg_blackhawk = SGroup_CreateIfNotFound("sg_blackhawk")
        
        for i = 1, World_GetPlayerCount() do
            player = World_GetPlayerAt(i)
            
            if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
                
                SGroup_Clear(sg_blackhawk)
                Player_GetAll(player, sg_blackhawk)
                SGroup_Filter(sg_blackhawk, SBP.CW.BLACKHAWK, FILTER_KEEP)
                if SGroup_IsEmpty("sg_blackhawk") == false then
                SGroup_DestroyAllSquads(sg_blackhawk)
                Rule_RemoveMe()
                end
            end
        end
    end
    However can we filter the group so that only the first one loaded is delete?

    Otherwise can a slot_item/upgrade be applied to the blackhawk/apache at the end of its ability and then the function is called, and it only searches for the Blackhawk/apache with this slot_item/upgrade?

    Void SGroup_FilterCount( SGroupID sgroup1, Int groupSize )
    Pass in a group and it will filter it down to the indicated number
    Maybe with this? Limiting group size to 1?

  26. #26
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    There is a problem how lua handles tables. I noticed several times that the order in which you add something to a table does not the actual order used inside the table. So this part could be a little bit tricky.

    SGroup_FilterCount looks like it limits the SGroup member count to a given limit. So for example, if you set this to one, it will only will hold one member of this SGroup type. I think this function is to use and before SGroup_Filter. I'm not sure if this is what you want.

    If I understand your problem correct, one player can have only one blackhawk - and this is working now, but you also want that the whole team can have only one blackhawk. Then you need a global SGroup (at least outside the for-loop). So you should try something like this instead:

    Code:
    function Blackhawk_Remove_Function()
        
        local sg_blackhawk = SGroup_CreateIfNotFound("sg_blackhawk")
        SGroup_Clear(sg_blackhawk)
        SGroup_FilterCount(sg_blackhawk, 1)  -- this should be the limitation of one blackhawk for the whole team
    
        for i = 1, World_GetPlayerCount() do
            player = World_GetPlayerAt(i)
            
            if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
                
                SGroup_Clear(sg_blackhawk)
                Player_GetAll(player, sg_blackhawk)
                if SGroup_Count(sg_blackhawk) < 1 then   -- maybe this is enough and you don't need the filterCount above
                   SGroup_Filter(sg_blackhawk, SBP.CW.BLACKHAWK, FILTER_KEEP)
                end
                
                -- I'm not sure what the following code should do? 
                -- it says if "sg_blackhawk" has a member then it should kill this group?
                if SGroup_IsEmpty("sg_blackhawk") == false then
                   SGroup_DestroyAllSquads(sg_blackhawk)
                   Rule_RemoveMe()
                end
            end
        end
    end

  27. #27
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    If I understand your problem correct, one player can have only one blackhawk - and this is working now, but you also want that the whole team can have only one blackhawk.
    Let me explain properly. There is a Blackhawk drop, like this: http://www.moddb.com/mods/company-of...-combat/videos
    And I want the scar script to only remove the first blackhawk. So if you and your allies want to call the blackhawk drop at the same time (coordinating an attack), the scar script will be called when the first one leaves, but it will erase both... since it looks for all of them [Player_GetAll(player, sg_blackhawk)].

    Your updated script still erases both Blackhawks...
    Last edited by Darkbladecr; 29th Mar 12 at 3:42 PM.

  28. #28
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    @Jagdpanther
    There is no such thing as scope when it comes to SGroups. All SGroups are global, regardless of how you declare them. In order for this to work the way Darkblade wants, you will have to use globally unique SGroups. For example, SGroup_CreateIfNotFound("sg_blackhawk_1") or SGroup_CreateIfNotFound("sg_blackhawk_2"), etc.

    ----------

    Try this:

    Code:
    function Blackhawk_Remove_Function()    
        for i = 1,World_GetPlayerCount() do
            local player = World_GetPlayerAt(i)
            if ( Player_GetRace(player) == 0 or Player_GetRace(player) == 1 ) then      
    	    local sg_blackhawk = SGroup_CreateIfNotFound("sg_blackhawk_" .. i)
                SGroup_Clear(sg_blackhawk)
                Player_GetAll(player, sg_blackhawk)
                SGroup_Filter(sg_blackhawk, SBP.CW.BLACKHAWK, FILTER_KEEP)
    			
                if ( not SGroup_IsEmpty(sg_blackhawk) ) then
    				SGroup_DestroyAllSquads(sg_blackhawk)
    				Rule_RemoveMe()
                end
            end
        end
    end
    Last edited by eliw00d; 29th Mar 12 at 4:50 PM.

  29. #29
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Unfortunately got a scar error:

    Code:
    *FATAL SCAR ERROR: Cannot find SGroup with name sg_blackhawk in function SGroup_CountSpawned
      Lua             GroupCallers.scar              Ln   14 (GetSpawnedCount)
      Lua             Groups.scar                    Ln   33 ((null))
      tail            =(tail call)                   Ln   -1 ()
      Lua             Modern_Combat.scar             Ln  295 (Blackhawk_Remove_Function)
    
    *FATAL SCAR ERROR: Error running function "Blackhawk_Remove_Function" from ScarFunctionCallAction.

  30. #30
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    Edited my post. For some reason, you had sg_blackhawk in quotes in the SGroup_IsEmpty() function in your original post.

  31. #31
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    @Eli: "All SGroups are global, regardless of how you declare them". Are you sure, if so Ok, I never notice this. But the error message "Cannot find SGroup with name sg_blackhawk in function SGroup_CountSpawned" sounds not likewise.

    @DB: if a SGroup or something similar has no members, the the whole SGroup is nil. That's why you get this error. You have to check this first by using "if sg_blackhawk then" before you can use a count or any other function using this SGroup.

    I also think, like Eli, it will be better then to use different SGroups for each player. This way you can handle they independently.

    Could you show us the code of "function SGroup_CountSpawned" what causes the error message?

    "Your updated script still erases both Blackhawks... ", Yepp I see, it was more intended to create only one than to remove only one.
    Last edited by Jagdpanther; 30th Mar 12 at 2:22 AM.

  32. #32
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Could you show us the code of "function SGroup_CountSpawned" what causes the error message?
    There is none in my .scar it must be a default function?

    @Eliw00d - no crash now, but it still works like before, deleting both blackhawks, when only the first one has finished

  33. #33
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    How do you detect, when a blackhawk leaves the battlefield, via a timer?

    The problem for the script is to "know" which one is the correct one, the "first" blackhawk.
    Last edited by Jagdpanther; 30th Mar 12 at 2:39 AM.

  34. #34
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    @Jagdpanther
    Yes, I am sure.

    @DB
    Actually, I didn't really think about this until just now. Your function always deletes every single player's Blackhawk. You need a specific function that only deletes one player's Blackhawk when needed. Since you are calling this function from an RGD, it is impossible to do that. You would need a more complex system that is entirely coded in SCAR in order to know which players have a blackhawk and when to delete them.

  35. #35
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Since you are calling this function from an RGD, it is impossible to do that. You would need a more complex system that is entirely coded in SCAR in order to know which players have a blackhawk and when to delete them.
    I can simply remove the Blackhawk loading from the RGD and spawn it with SCAR instead, all I will need to do is have the entry and exit animations incorporated in OE that way all animations are handled separately.

    If I spawn with SCAR can I not give it a unique name each time? That way when it looks for it, it will always erase the correct one?

  36. #36
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Minnesota
    Yeah, you can use something similar to what I did above. Since you are spawning it with SCAR, you will know which player owns it and only remove theirs when needed. However, I would make sure you call the remove function from within SCAR and not from an RGD. The RGD method is very limited, since no arguments can be passed to SCAR.

  37. #37
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    @DB: Try this code. Spawn your Blackhawk per rgd without using any scar action inside.
    Code:
    function Custom_CheckBlackhawk()
    	for i = 1,World_GetPlayerCount() do
    		local player_id = World_GetPlayerAt(i)
    
    		-- you can also use "Player_HasBuilding" to choose the hq for example)
    		if (Player_HasMapEntryPosition(player_id)) then
    			local add_MapEntryPoint = function(egroupid, itemindex, entityID)
    				if (Entity_GetBlueprint(entityID) == EBP.STRAT_POINT.ENTRY) then
    					map_entry_pos	= Util_GetPosition(entityID)
    				end
    			end
    			Player_GetAll(player_id)
    			EGroup_ForEach(eg_allentities, add_MapEntryPoint)
    
    			local sg_blackhawk = function(SGroupID, itemindex, squadID)
    				if (Squad_GetBlueprint(squadID) == SBP.CW.BLACKHAWK) then
    					if map_entry_pos ==  SGroup_GetPosition(SGroupID) then
    						SGroup_DestroyAllSquads(SGroupID)
    					end
    				end
    			end
    
    			Player_GetAll(player_id)
    			SGroup_ForEach(sg_allsquads, sg_blackhawk)
    		end
    	end
    end
    
    Rule_AddInterval(Custom_CheckBlackhawk, 1)
    This is the way I'm doing such things for myself. Eventually you should use a higher interval value, so the Sgroup will not be cleared at spawning. Play a little bit with this value.

  38. #38
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Just tried your version, the blackhawks don't get removed.

    Instead of the Rule_addInterval, loading all the time from the scar script. I loaded the function from the rgd ability, and at the end_self_target. I'm not sure if I am doing it wrong?

  39. #39
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Yepp, I also was thinking about a different starting variant. So, yes, a starting of the rule from inside scar would be better, otherwise it could be that the SGroup would be cleared if the blackhawk moves over the removing target, like the map_entry_point in the example.

    So you should start a scar script with your spawner rgd (a delay of one second would be enough) with the "start_blackhawk" and the modified script from above:

    Code:
    function Custom_CheckBlackhawk()
    	bh_found	= false
    
    	for i = 1,World_GetPlayerCount() do
    		local player_id = World_GetPlayerAt(i)
    
    		-- you can also use "Player_HasBuilding" to choose the hq for example)
    		if (Player_HasMapEntryPosition(player_id)) then
    			local add_MapEntryPoint = function(egroupid, itemindex, entityID)
    				if (Entity_GetBlueprint(entityID) == EBP.STRAT_POINT.ENTRY) then
    					map_entry_pos	= Util_GetPosition(entityID)
    				end
    			end
    			Player_GetAll(player_id)
    			EGroup_ForEach(eg_allentities, add_MapEntryPoint)
    
    			local sg_blackhawk = function(SGroupID, itemindex, squadID)
    				if (Squad_GetBlueprint(squadID) == SBP.CW.BLACKHAWK) then
    					if map_entry_pos ==  SGroup_GetPosition(SGroupID) then
    						SGroup_DestroyAllSquads(SGroupID)
    					else
    						bh_found	= true
    						
    						--------------------------------------
    						-- this part you only need if the Blackhawk do not return to a return location
    						-- and your checking function will get the blackhawk sometime
    						-- now you are sure your Blackhawk is doing it.
    						--------------------------------------
    						if Squad_IsMoving(squadID) == false then
    							if Timer_Exists(wait_delay) then
    								if Timer_GetRemaining(wait_delay) <= 0.01 then
    									-- this will move your Blackhawk back to the map_entry_point
    									Squad_SetPosition(squadID, map_entry_pos, map_entry_pos)
    									Timer_End(wait_delay)
    								end
    							else
    								-- set this delay to a time the Blackhawk needs for reinforcement)
    								Wait_Delay(5)
    							end
    						end
    						--------------------------------------
    					end
    				end
    			end
    
    			Player_GetAll(player_id)
    			SGroup_ForEach(sg_allsquads, sg_blackhawk)
    		end
    	end
    
    	if bh_found == false then
    		Rule_RemoveMe()
    	end
    end
    
    function start_blackhawk()
    
    	bh_found	= false
    
    	for i = 1,World_GetPlayerCount() do
    		local player_id = World_GetPlayerAt(i)
    		
    		local sg_bh = function(SGroupID, itemindex, squadID)
    			if (Squad_GetBlueprint(squadID) == SBP.CW.BLACKHAWK) then
    				bh_found	= true
    			end
    		end
    
    		Player_GetAll(player_id)
    		SGroup_ForEach(sg_allsquads, sg_bh)
    	end
    	
    	if bh_found == false or Rule_Exists(Custom_CheckBlackhawk) == false then
    	    Rule_AddInterval(Custom_CheckBlackhawk, 1)
    	end
    end
    
    --------------------------------------
    -- this part you only need if the Blackhawk do not return to a return location
    --------------------------------------
    function Wait_Delay(iDelay)
    	wait_delay = World_GetGameTime()
    	Timer_Start(wait_delay, iDelay)
    end
    --------------------------------------
    But the check is depending on where your blackhawk returns after reinforcing something. What's his last position?

    and at the end_self_target
    This would be great and the best I think, you are right here.

    Edit: Script modified
    If needed we can customizing the timer, so there is no overlapping, if two Blackhawks are on the map at the same time.
    Last edited by Jagdpanther; 30th Mar 12 at 11:09 AM.

  40. #40
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    this part you only need if the Blackhawk do not return to a return location and your checking function will get the blackhawk sometime now you are sure your Blackhawk is doing it.
    But the check is depending on where your blackhawk returns after reinforcing something. What's his last position?
    The blackhawk is spawned on the targeted location from the ability. It does not move at all, all the animations are done within OE, and when the animations are done, I deleted the model with scar.

    You can see it in the link I posted above. The whole reinforcement drop takes about 15-16 seconds. Should I set that as my Rule_AddInterval time? However it should only need to be called once shouldn't it?

    Anyway, so I load the function start_blackhawk() after the first second, so it notes down the blackhawk which is loaded. Then there is no need to put in the function Custom_CheckBlackhawk() into the end_self_target since it is already called from the first function. I can just adjust the interval time so that it unloads the model at the right time, is this correct?

  41. #41
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    Nevermind... I tried out the script, it still performs like the original and deletes both blackhawk's at the same time

    I sent you a PM with the specific mod files. (I suggest you change the crew on the blackhawk, and change the spawn squad in the air_drop ability otherwise you will get .lua errors)

  42. #42
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    OK I'll try it with the files you send me and drop you a note about the result then.

    Edit: OK, I have it now working and create a package for you with the description.
    Last edited by Jagdpanther; 31st Mar 12 at 11:34 AM.

  43. #43
    Moderator Darkbladecr's Avatar
    Join Date
    Nov 2005
    Location
    CoH:Modern Combat
    This was solved on the side by Jagdpanther, how he did it was by adding a blank upgrade to the Blackhawk, at the end of the ability duration end_target_ability

    And then ran this script after the exit animation was finished:
    Code:
    function remove_single_blackhawk()
    
    	for i = 1,World_GetPlayerCount() do
    		local player_id = World_GetPlayerAt(i)
    		
    		local sg_bh = function(SGroupID, itemindex, SquadID)
    			if (Squad_GetBlueprint(SquadID) == SBP.CW.BLACKHAWK) then
    				if Squad_HasUpgrade(SquadID, BP_GetUpgradeBlueprint("upgrade/amer/blackhawk_exit_upgrade.lua")) then
    					Squad_Destroy(SquadID)
    				end
    			end
    		end
    
    		Player_GetAll(player_id)
    		SGroup_ForEach(sg_allsquads, sg_bh)
    	end
    end
    With this:
    upgrade/amer/blackhawk_exit_upgrade.lua
    being the blank upgrade added to the blackhawk.

    Thanks Jagdpanther! Used the same concept for the apache and it also worked out!

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
  •