Jump to content


Photo

Questions about modding weapons


42 replies to this topic

#41 Gambit

Gambit

    title available

  • Members
  • 5,851 posts
  • Location:Athens, Greece

Posted 16 March 2019 - 11:34 AM

... But.... There is NO call for the SetSquadLimitsBasedOnStrategy anywhere :p

If you see above, my Daemons code calls it :grad:

So you simply forgot a line!. You must do the same as in Daemons, so try this:

 

 

.......

    if (iRandom <= iBuildProgram1) then

        

        return 1

    elseif (iRandom <= iBuildProgram2) then

        

        return 2

    elseif (iRandom <= iBuildProgram3) then

        

        return 3

    elseif (iRandom <= iBuildProgram4) then

        self:SetSquadLimitsBasedOnStrategy(4)

        return 4

    end

end

.....

 

 

The idea is, once you have chosen a program, to RE-INPUT the updated values.

So you must call the function, because by itself it does.... nothing :p


Edited by Gambit, 16 March 2019 - 11:39 AM.

-In search of Papasmurf...

#42 Moreartillery

Moreartillery
  • Members
  • 26 posts

Posted 17 March 2019 - 05:50 AM

I can't believe I missed that :facepalm: It works now.

 

A part I still don't understand is

-- If we got here, no program has been chosen, so go ahead and chose one!
	iBuildProgram2 = iBuildProgram1 + iBuildProgram2  -- =55
	iBuildProgram3 = iBuildProgram2 + iBuildProgram3  -- =55
	iBuildProgram4 = iBuildProgram3 + iBuildProgram4  -- =55
	iBuildProgram5 = iBuildProgram4 + iBuildProgram5  -- =68

If these build programs have the same value, (in this case 55) doesn't that mean only the first one of the 3 can be chosen? For example if iRandom chooses a number between  27 and 55 won't it stop at

	elseif (iRandom <= iBuildProgram2) then
		g_iHarassingLeader = 2
		return 2

therefor preventing program 3 and 4 from being considered? Maybe I'm reading this wrong but it looks like program 3 and 4 can never be chosen.



#43 Gambit

Gambit

    title available

  • Members
  • 5,851 posts
  • Location:Athens, Greece

Posted 17 March 2019 - 11:29 AM

The logic above is wrong...

The three lines where "=55" is repeated, should NOT be so, because at that point the code calculates the CUMULATIVE value of each strategy, NOT the actual value of each strategy itself! So the new values should be ascending, not equal.

 

So, yes, if it is so, as long as the randomiser value is below or equal to 55, ONLY STRATEGY ONE will be chosen.

Else, (>55) it will always choose strategy 4.

 

The idea is:

1] Calculate the BASIC probability of each strategy, based on map size and optionally, closer enemy distance.

2] Modify the basic probability, based on closer enemy race, or other factors.

3] Add probabilities so that to get cumulative values, and choose based on that.

 

 

 

 

 

----------------------------------------

More thoughts...

 

First, let me say that I am NOT using that exact logic I described above, for the races I code.

I prefer a different approach in each, and I adapt and changes the code based on each race's needs.

 

Even so, the idea above is:

 

1] The probability of each build program is calculated initially, based on map size, and then modified by closest enemy. For example, in the Eldar strategy you posted (which is NOT generic, but highly specialised, for strategy 4)

    if (sMapSize == "small" or iClosestEnemyDistance <= 100) then
    
        iBuildProgram1 = 34
        iBuildProgram2 = 33
        iBuildProgram3 = 33
        iBuildProgram4 = 0
        
 
    elseif (sMapSize == "large" and iClosestEnemyDistance >= 100) then
    
        iBuildProgram1 = 0
        iBuildProgram2 = 0
        iBuildProgram3 = 0
        iBuildProgram4 = 100
    else
    
        iBuildProgram1 = 0
        iBuildProgram2 = 0
        iBuildProgram3 = 0
        iBuildProgram4 = 100
    end
    
    -- Modify probabilities according to the closest enemy player
    local oEnemy = cpu_manager:FindClosestEnemyPlayer(false)
    local sEnemy = oEnemy:GetPlayerRaceName()        
    if (sEnemy == "space_marine_race" or "chaos_marine_race") then
    
        iBuildProgram2 = iBuildProgram2 + 0
        iBuildProgram3 = iBuildProgram3 - 0
        
    elseif (sEnemy == "guard_race" or sEnemy == "tau_race" or sEnemy == "ork_race") then
    
        iBuildProgram1 = iBuildProgram1 - 0
        iBuildProgram2 = iBuildProgram2 + 0
        iBuildProgram3 = iBuildProgram3 - 0
    end

Say we have a small map, and the first enemy is closer than 100. The prorgam will follow the first IF, and set the original values thus:

iBuildProgram1 = 34
iBuildProgram2 = 33
iBuildProgram3 = 33
iBuildProgram4 = 0

2] Then, based on closest enemy, it will modify the values. Your code was:

    -- Modify probabilities according to the closest enemy player
    local oEnemy = cpu_manager:FindClosestEnemyPlayer(false)
    local sEnemy = oEnemy:GetPlayerRaceName()        
    if (sEnemy == "space_marine_race" or "chaos_marine_race") then
    
        iBuildProgram2 = iBuildProgram2 + 0
        iBuildProgram3 = iBuildProgram3 - 0
        
    elseif (sEnemy == "guard_race" or sEnemy == "tau_race" or sEnemy == "ork_race") then
    
        iBuildProgram1 = iBuildProgram1 - 0
        iBuildProgram2 = iBuildProgram2 + 0
        iBuildProgram3 = iBuildProgram3 - 0
    end

... Which does NOT modify the probabilities at all!!! Why so??? If you do not modify, then simply remove this part of the code :p


Edited by Gambit, 17 March 2019 - 11:30 AM.

-In search of Papasmurf...



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users