Jump to content


Photo

Questions about modding weapons


165 replies to this topic

#41 Gambit

Gambit

    title available

  • Members
  • 6,718 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
  • 247 posts
  • Projects:Cinematic Battles

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.


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#43 Gambit

Gambit

    title available

  • Members
  • 6,718 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...

#44 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 25 March 2019 - 07:20 AM

The previously mentioned system was hard to work with and too random in its decision making so I wrote this

function ChaosBuildBaseStrategy:ChooseBuildProgram()

	-- Check build program count
	if (table.getn(self.info.BuildPrograms) ~= 5) then
		return BuildBaseStrategy.ChooseBuildProgram(self)
	end

	-- Get map size and closest enemy distance
	local sMapSize, iClosestEnemyDistance = self:GetMapSize()
		
	-- Set probabilities of the strategies according to the map size
	local iBuildProgram1	-- Basic strategy
	local iBuildProgram2	-- Infantry strategy
	local iBuildProgram3	-- Raptor strategy
	local iBuildProgram4	-- Renegade strategy
	local iBuildProgram5	-- Tank	strategy
	-- Now choose a program
	local oEnemy = cpu_manager:FindClosestEnemyPlayer(false)
	local sEnemy = oEnemy:GetPlayerRaceName()	
	if (sEnemy == "space_marine_race" or sEnemy == "chaos_marine_race" or sEnemy == "necron_race") and (iClosestEnemyDistance <= 300) then
		return math.random(2, 4)
		
	elseif (sEnemy == "guard_race" or sEnemy == "ork_race" or sEnemy == "eldar_race" or sEnemy == "tau_race") and (iClosestEnemyDistance <= 300) then
		return math.random(2, 4)
		
	elseif (iClosestEnemyDistance > 300) then
		return 5
	end
end	

Its much easier to see the probability's now. In my mod there is a big difference between light and heavy infantry so most races now chose a plan to counter the most common infantry type in the enemy army. Like this
 

function EldarBuildBaseStrategy:ChooseBuildProgram()

	-- Check build program count
	if (table.getn(self.info.BuildPrograms) ~= 4) then
		return BuildBaseStrategy.ChooseBuildProgram(self)
	end

	-- Get map size and closest enemy distance
	local sMapSize, iClosestEnemyDistance = self:GetMapSize()
		
	-- Set probabilities of the strategies according to the map size
	local iBuildProgram1	-- Basic strategy
	local iBuildProgram2	-- Reaper rush / anti infantry
	local iBuildProgram3	-- Banshee rush / anti heavy infantry
	local iBuildProgram4	-- Hover Tank strategy
	
	-- Now choose a program
	local oEnemy = cpu_manager:FindClosestEnemyPlayer(false)
	local sEnemy = oEnemy:GetPlayerRaceName()	
	if (sEnemy == "space_marine_race" or sEnemy == "chaos_marine_race" or sEnemy == "necron_race") and (iClosestEnemyDistance <= 300) then
		return 3
		
	elseif (sEnemy == "guard_race" or sEnemy == "ork_race" or sEnemy == "eldar_race" or sEnemy == "tau_race") and (iClosestEnemyDistance <= 300) then
		return 2
		
	elseif (iClosestEnemyDistance > 300) then
		return 4
	end
end	

I've been thinking about using the unfocused basic strategy on easier difficulty levels and making the ChooseBuildProgram() function run whenever a player is defeated but I don't have much experience coding.


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#45 Gambit

Gambit

    title available

  • Members
  • 6,718 posts
  • Location:Athens, Greece

Posted 25 March 2019 - 11:40 AM

Yeah, the logic you followed above for strategy selection is neat.

And frankly, I used similar variations (some widely varied) for specific mods, like Chaos Daemons or Thousand Sons.

 

Three remarks:

 

1] In both tactics, Strategy 1 is NEVER chosen. Why? For Chaos is 2-5 and for Eldar 2-4. But never 1.

 

 

2] In Chaos tactic, the first two conditions generate the same result, so the "proper" coding method is a bit different. Thus, instead of :

...
if (sEnemy == "space_marine_race" or sEnemy == "chaos_marine_race" or sEnemy == "necron_race") and (iClosestEnemyDistance <= 300) then
        return math.random(2, 4)
        
    elseif (sEnemy == "guard_race" or sEnemy == "ork_race" or sEnemy == "eldar_race" or sEnemy == "tau_race") and (iClosestEnemyDistance <= 300) then
        return math.random(2, 4)
...

...you should have both in ONE check:

...
    if (sEnemy == "space_marine_race" or sEnemy == "chaos_marine_race" or sEnemy == "necron_race" or sEnemy == "guard_race" or sEnemy == "ork_race" or sEnemy == "eldar_race" or sEnemy == "tau_race") and (iClosestEnemyDistance <= 300) then
        return math.random(2, 4)
...

3] The only thing that I kinda disagree with, is that in your Eldar version, the code invariably chooses strategy, solely based on given conditions. You could risk a modicum of randomness, because it is not proper to ALWAYS have the same tactic.

 

For example, you can use a logic like...

...
    if (sEnemy == "space_marine_race" ...) then
        if math.random(1, 4) > 1 then
            return 2
        else
            return 3
        end
    elseif
...

In this case if the first conditions are met, the code will return Strategy 2, with 75% probability (3 out of 4). Else, it will return Strategy 3. This, DOES add a modicum of randomness, and is still very consistent to what you are trying to achieve. :thumbsupcool:

And by increasing 4 to (say) 5, the math.random(1, 5) will give 80% chance. And so on.

Sometimes, I even use even more complex probability formulae, like math.random(1, math.random(1, 3)) :twisted:

 

 

I've been thinking about using the unfocused basic strategy on easier difficulty levels and making the ChooseBuildProgram() function run whenever a player is defeated but I don't have much experience coding.

I am under the impression that in easy/easier difficulty, the code ALWAYS returns Strategy 1...
So my Remark 1] above, may not need addressing!
Meaning, that you have already reserved strategy 1 EXCLUSIVELY for easy games :thumbsuphappy:

But I am not 100% certain on my assumption... ( and I am lazy to look at the CORE AI code to make sure :p  )


Edited by Gambit, 25 March 2019 - 11:50 AM.

-In search of Papasmurf...

#46 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 25 March 2019 - 03:41 PM


I am under the impression that in easy/easier difficulty, the code ALWAYS returns Strategy 1...
So my Remark 1] above, may not need addressing!
Meaning, that you have already reserved strategy 1 EXCLUSIVELY for easy games :thumbsuphappy:

But I am not 100% certain on my assumption... ( and I am lazy to look at the CORE AI code to make sure :p  )

You're right. I didn't know it did that.


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#47 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 06 April 2019 - 02:08 AM

What is the difference between modifiers\health_rangedamage_received_1_modifier.lua and modifiers\health_rangedamage_received_2_modifier.lua?


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#48 Gambit

Gambit

    title available

  • Members
  • 6,718 posts
  • Location:Athens, Greece

Posted 06 April 2019 - 10:14 AM

The health_rangedamage_received_2_modifier is NOT used... They must have designed it for something else, but didn't implement it.


-In search of Papasmurf...

#49 Kasrkin84

Kasrkin84

    title available

  • Members
  • 329 posts
  • Location:Birmingham, UK
  • Projects:Strongholds, Unification

Posted 06 April 2019 - 10:56 AM

There are some abilities/researches that seem to use it, but it doesn't have any effect.



#50 fuggles

fuggles

    title available

  • Members
  • 4,849 posts

Posted 07 April 2019 - 07:39 AM

What does aftermath effect do?

#51 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 27 April 2019 - 04:11 AM

What does aftermath effect do?

What file is it in?


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#52 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 28 April 2019 - 04:51 AM

I'm trying to remove a map from the skirmish list. I deleted in scenarios>mp but it still showed up. So I deleted it from ALL mods and dxp2 and wh40k scenarios>mp folder but its still there, what gives?


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#53 Gambit

Gambit

    title available

  • Members
  • 6,718 posts
  • Location:Athens, Greece

Posted 28 April 2019 - 09:48 AM

Is that map part of an SGA?


-In search of Papasmurf...

#54 Kasrkin84

Kasrkin84

    title available

  • Members
  • 329 posts
  • Location:Birmingham, UK
  • Projects:Strongholds, Unification

Posted 28 April 2019 - 12:34 PM

If it's in an SGA as Gambit suggests, you can get rid of it by creating an empty text file and renaming it to match the map file (including the .sgb file extension).



#55 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 29 April 2019 - 12:24 AM

The maps are 2p_Tau Blockade.sgb and 2p_abandon_all_hope.sgb. Adding the text file didn't work.


Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#56 Kasrkin84

Kasrkin84

    title available

  • Members
  • 329 posts
  • Location:Birmingham, UK
  • Projects:Strongholds, Unification

Posted 29 April 2019 - 11:38 AM

2p_abandon_all_hope is in the vanilla game, so it's definitely in an SGA archive. So you created a blank text file, renamed it to "2p_abandon_all_hope.sgb" and put it in data/scenarios/mp?



#57 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 01 May 2019 - 04:16 AM

2p_abandon_all_hope is in the vanilla game, so it's definitely in an SGA archive. So you created a blank text file, renamed it to "2p_abandon_all_hope.sgb" and put it in data/scenarios/mp?

I forgot to remove the hidden .txt extension, it works now.


Edited by Moreartillery, 01 May 2019 - 08:41 AM.

Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#58 Kasrkin84

Kasrkin84

    title available

  • Members
  • 329 posts
  • Location:Birmingham, UK
  • Projects:Strongholds, Unification

Posted 01 May 2019 - 07:04 AM

The community maps will be wherever you saved them - probably in dxp2/data/scenarios/mp or w40k/data/scenarios/mp unless they're included with a mod.



#59 Moreartillery

Moreartillery
  • Members
  • 247 posts
  • Projects:Cinematic Battles

Posted 09 May 2019 - 02:05 AM

I get this error whenever I try to export from 3ds max, I already set up the pipeline.ini and I can't figure out whats wrong.

 

 

; NOTE: Replace "my_mod" with the name of your mod folder below!
[project:Cinematic_Battles]
Description        = Cinematic_Battles
DataSource        = ModTools\DataSrc\Cinematic_Battles
DataIntermediate    = ModTools\DataInt\Cinematic_Battles
DataGeneric        = ModTools\DataGeneric\Cinematic_Battles
DataBurn        = Cinematic_Battles
DataFinal        = Cinematic_Battles\Data
DataExtra        =
LocaleFolder        = Cinematic_Battles\Locale\English
Parent            = DXP2
DataSourceShared    = ModTools\DataSrc\Cinematic_Battles
DataPreview        =
AttrLoc            =

Attached Files


Edited by Moreartillery, 09 May 2019 - 02:06 AM.

Developer of the Cinematic Battles mod.

https://www.moddb.co...nematic-battles


#60 Kekoulis

Kekoulis

    Apothecary Novice

  • Members
  • 2,151 posts
  • Location:Reclaimed Chemos
  • Projects:Emperor's Children
  •  Slaanesh's Glory

Posted 13 May 2019 - 12:05 PM

I get this error whenever I try to export from 3ds max, I already set up the pipeline.ini and I can't figure out whats wrong.

 

 

; NOTE: Replace "my_mod" with the name of your mod folder below!
[project:Cinematic_Battles]
Description        = Cinematic_Battles
DataSource        = ModTools\DataSrc\Cinematic_Battles
DataIntermediate    = ModTools\DataInt\Cinematic_Battles
DataGeneric        = ModTools\DataGeneric\Cinematic_Battles
DataBurn        = Cinematic_Battles
DataFinal        = Cinematic_Battles\Data
DataExtra        =
LocaleFolder        = Cinematic_Battles\Locale\English
Parent            = DXP2
DataSourceShared    = ModTools\DataSrc\Cinematic_Battles
DataPreview        =
AttrLoc            =

You know this is not an weapon coding related question,right?

 

Anyways,need to ask,in what path did you install the Mod Tools?

 

They must be at C:\Program Files (x86)\THQ\Dawn of War Dark Crusade\ModTools.

In addition,never replace the ''My_Mod'' with your mod name.

MAX goes bonkers if you do that for some reason.Blame Relic.


ec-sig-early2.gif

Mankind has seen the light,the light of Slaanesh.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users