Skip to content

Commit

Permalink
change civ_state calculation for better gameplay with changed setting…
Browse files Browse the repository at this point in the history
…s, population calculation is now only a scale for better calculation of civ_state
  • Loading branch information
cech12 committed Nov 28, 2017
1 parent 3397959 commit 1842c5f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Data/Scripts/ai/change_std_ai.tcl
@@ -0,0 +1,6 @@
$start
$replace
set civ_state [expr {([gamestats attribsum $populationowner expsum]+[gamestats numbuiltprodclasses $populationowner])*0.01}]
$with
set civ_state [get_civ_state $populationowner]
$end
31 changes: 28 additions & 3 deletions Data/Scripts/classes/zwerg/change_z_spare_main.tcl
@@ -1,6 +1,31 @@
$start
$replace
return [hmin [expr {10.0+$civ*20.0}] 22.0]
proc sparetime_get_popsoll {civ} {
if {$civ<0.15} {
return [expr {7.0+$civ*20.0}]
} elseif {$civ<0.4} {
return [expr {5.2+$civ*32.0}]
} else {
return [hmin [expr {10.0+$civ*20.0}] 22.0]
}
}
$with
return [hmin [expr {(54.0 - 2.0*$print:POP_SOLL.0)+$civ*(5*$print:POP_SOLL.0 - 90)}] $print:POP_SOLL.0]
$end
proc sparetime_get_popsoll {civ} {
set populationFactor [expr {$print:POP_SOLL.0/22.0}]
if {$civ<0.15} {
return [expr {populationFactor*(7.0+$civ*20.0)}]
} elseif {$civ<0.4} {
return [expr {populationFactor*(5.2+$civ*32.0)}]
} else {
return [expr {populationFactor*([hmin [expr {10.0+$civ*20.0}] 22.0])}]
}
}
$end


$start
$replace
set civ_state [expr {([gamestats attribsum $own expsum]+[gamestats numbuiltprodclasses $own])*0.01}]
$with
set civ_state [get_civ_state $own]
$end
38 changes: 38 additions & 0 deletions Data/Scripts/misc/change_utility.tcl
@@ -0,0 +1,38 @@
$start
$after
call scripts/misc/animclassinit.tcl


$put


proc get_civ_state {owner} {
//get gnome list
set gnomes [obj_query $owner -class Zwerg -owner $owner -cloaked 1]
if {$gnomes==0} {set gnomes {}}
//calculate sum of all exp of all gnomes
set exp_sum 0
foreach gnome $gnomes {
set gnome_exp 0
foreach attribut [get_expattrib] {
fincr gnome_exp [get_attrib $gnome $attribut]
}

//scaling [0, MIN_EXP] with weight 1 and [MIN_EXP, MAX_EXP] with weight 1
if {$gnome_exp > $print:MIN_EXP} {
fincr exp_sum 1.0
set gnome_exp [expr {$gnome_exp-$print:MIN_EXP.0}]
//MAX_EXP scaling
fincr exp_sum [expr {$gnome_exp/($print:MAX_EXP.0-$print:MIN_EXP.0)}]
} else {
//MIN_EXP scaling
fincr exp_sum [expr {$gnome_exp/$print:MIN_EXP.0}]
}
}
//population scaling
set exp_sum [expr {(22.0/$print:POP_SOLL.0*$exp_sum)}]

return [expr {($exp_sum+[gamestats numbuiltprodclasses $owner])*0.01}]
}

$end
2 changes: 1 addition & 1 deletion config.json
@@ -1,5 +1,5 @@
{
"version" : "1.0",
"version" : "1.1",
"author" : "cech12",

"name" : {
Expand Down

0 comments on commit 1842c5f

Please sign in to comment.