Starting in on data generation.

This commit is contained in:
Martin Haye 2015-12-06 12:02:18 -08:00
parent 299b5aed2f
commit 059f77aba1
5 changed files with 85 additions and 21 deletions

View File

@ -1356,6 +1356,28 @@ class PackPartitions
println "Done."
}
void genEnemy(outStream, columns, data)
{
outStream.print("new enemy\n")
columns.eachWithIndex { col, idx ->
outStream.println(String.format(" %s=%s", col, data[idx]))
}
}
void dataGen()
{
// Translate enemies to code
new File("src/plasma/gen_enemies.pla").withOutputStream { outStream ->
def columns
new File("data/world/enemies.tsv").eachLine { line ->
if (columns)
genEnemy(outStream, columns, line.split("\t"))
else
columns = line.split("\t")
}
}
}
static void main(String[] args)
{
// Set auto-flushing for stdout
@ -1370,14 +1392,15 @@ class PackPartitions
flag = true
}
if (!flag) {
println "Error: assertions must be enabled. Run with 'ea-'"
println "Error: assertions must be enabled. Run with '-ea'"
System.exit(1);
}
// Check the arguments
if (args.size() != 2 && args.size() != 3) {
if (!((args.size() == 1 && args[0] == "-dataGen") || args.size() == 2 || args.size() == 3)) {
println "Usage: convert yourOutlawFile.xml game.part.0.bin [intcastMap.js]"
println " (where intcastMap.js is to aid in debugging the Javascript raycaster)"
println " or: convert -dataGen"
System.exit(1);
}
@ -1389,7 +1412,10 @@ class PackPartitions
// Go for it.
def inst = new PackPartitions()
try {
inst.pack(args[0], args[1], args.size() > 2 ? args[2] : null)
if (args[0] == "-dataGen")
inst.dataGen()
else
inst.pack(args[0], args[1], args.size() > 2 ? args[2] : null)
}
catch (Throwable t) {
errorFile.withWriter { out ->

View File

@ -29,6 +29,12 @@
<!-- Create build directory -->
<mkdir dir="${build.dir}"/>
<!-- Generate code from tables -->
<echo>Generating code from tables.</echo>
<java jar="${pack.dir}/PackPartitions.jar" fork="true" failonerror="true">
<arg value="-dataGen"/>
</java>
<!-- Build sub-projects -->
<echo>Building core.</echo>
<ant dir="${src.dir}/core" target="build" useNativeBasedir="true" inheritAll="false"/>

View File

@ -1403,7 +1403,6 @@ scanForAvail: !zone
;------------------------------------------------------------------------------
main_dispatch: !zone
!if SANITY_CHECK { jsr saneStart : jsr + : jmp saneEnd }
+ pha
lda #0
beq .go
@ -1412,6 +1411,7 @@ aux_dispatch:
lda #1
.go sta isAuxCmd
pla
!if SANITY_CHECK { jsr saneStart : jsr + : jmp saneEnd }
+ cmp #REQUEST_MEMORY
bne +
jmp mem_request
@ -1481,7 +1481,10 @@ saneStart: !zone {
pla
tay
+prChr 'M'
pla : pha : +prA
lda isAuxCmd
beq +
+prChr 'a'
+ pla : pha : +prA
+prX : +prY
pla
rts

View File

@ -1653,26 +1653,53 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def playerShoot(pPlayer, pWeapon)
word pEnemy, dmg
word pEnemy, pSkill, dmg
word chance
byte roll
pEnemy = chooseEnemy(pWeapon->b_weaponRange)
if !pEnemy; return FALSE; fin
// TODO: consider multi-shot weapons
dmg = rollDice(pWeapon=>r_projectileDmg)
// TODO: Add extra melee damage for skills, strength, etc.
// TODO: consider enemy dodge
pEnemy=>w_health = pEnemy=>w_health - dmg
// Figure out chance to hit. First come agility and aim.
chance = (pPlayer->b_agility * 4) + pPlayer->b_aiming
buildString(@addToString)
printf3("\n%s shoots %s for %d damage.", pPlayer=>s_name, pEnemy=>s_name, dmg)
if pEnemy=>w_health <= 0
printf1(" %s is killed!", pEnemy=>s_name)
nEnemiesFighting = nEnemiesFighting - 1
// Add in skill modifier, if any
pSkill = pPlayer=>p_skills
while pSkill
if pSkill=>b_modKind == pWeapon=>b_itemKind
chance = chance + pSkill=>b_modValue
fin
pSkill = pSkill=>p_nextObj
loop
// Nobody can have 100% chance to hit. Let's cap it at 90%.
chance = min(90, chance)
roll = rand16() % 100
if roll >= chance
// Miss!
displayf2("\n%s shoots at %s but misses.\n", pPlayer=>s_name, pEnemy=>s_name)
else
// TODO: consider multi-shot weapons
dmg = rollDice(pWeapon=>r_projectileDmg)
// TODO: Add extra melee damage for skills, strength, etc.
// TODO: consider enemy dodge
pEnemy=>w_health = pEnemy=>w_health - dmg
buildString(@addToString)
printf3("\n%s shoots %s for %d damage.", pPlayer=>s_name, pEnemy=>s_name, dmg)
if pEnemy=>w_health <= 0
printf1(" %s is killed!", pEnemy=>s_name)
nEnemiesFighting = nEnemiesFighting - 1
fin
puts("\n")
displayStr(finishString(0))
return TRUE
fin
puts("\n")
displayStr(finishString(0))
return TRUE
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1688,7 +1715,8 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def combatPause()
word n
for n = 1 to 2000
for n = 1 to 3000
next
end

View File

@ -111,6 +111,7 @@ def new_Player_Hue_Hauser
addToList(p + p_skills, new_Modifier(KIND_MINING, 0))
addToList(p + p_skills, new_Modifier(KIND_NATIVE_BOND, 0))
addToList(p + p_skills, new_Modifier(KIND_PYRE_WARE, 0))
addToList(p + p_skills, new_Modifier(KIND_HANDGUN, 1))
// Items
addToList(p + p_items, new_Armor_Chaps())