Refactored global scripts into their own module.

This commit is contained in:
Martin Haye 2015-12-29 11:22:14 -08:00
parent c4e46238cd
commit 9a1a1d0a0e
7 changed files with 472 additions and 360 deletions

View File

@ -955,10 +955,10 @@ class PackPartitions
//println "defCount =$defCount"
// Sanity checking on the offsets
assert asmCodeStart >= 0 && asmCodeStart < byteCodeStart
assert byteCodeStart >= asmCodeStart && byteCodeStart < fixupStart
assert initStart == 0 || (initStart+2 >= byteCodeStart && initStart+2 < fixupStart)
assert fixupStart < buf.length
assert asmCodeStart >= 0 && asmCodeStart <= byteCodeStart
assert byteCodeStart >= asmCodeStart && byteCodeStart <= fixupStart
assert initStart == 0 || (initStart+2 >= byteCodeStart && initStart+2 <= fixupStart)
assert fixupStart <= buf.length
// Split up the parts now that we know their offsets
def asmCode = buf[asmCodeStart..<byteCodeStart]
@ -1267,6 +1267,7 @@ class PackPartitions
readCode("tileEngine", "src/tile/build/tile.b")
readModule("gameloop", "src/plasma/build/gameloop.b")
readModule("globalScripts", "src/plasma/build/globalScripts.b")
readModule("combat", "src/plasma/build/combat.b")
}

View File

@ -27,25 +27,11 @@
<!-- Create build directory -->
<mkdir dir="${build.dir}"/>
<!-- Same with combat code -->
<echo>combat.pla</echo>
<!-- Translate the PLASMA code to ACME assembly code-->
<apply executable="../../../tools/PLASMA/src/plasm" dir="${src.dir}"
relative="true" parallel="false" failonerror="true" verbose="true"
addsourcefile="false">
<fileset dir="${src.dir}" includes="combat.pla"/>
<arg value="-AM"/>
<redirector logError="yes">
<inputmapper type="glob" from="*" to="${src.dir}/*"/>
<outputmapper id="out" type="glob" from="*.pla" to="${build.dir}/*.a"/>
</redirector>
</apply>
<!-- Translate the game loop from PLASMA to ACME assembly code-->
<echo>gameloop.pla</echo>
<apply executable="../../../tools/PLASMA/src/plasm" dir="${src.dir}"
relative="true" parallel="false" failonerror="true" verbose="true"
addsourcefile="false">
<fileset dir="${src.dir}" includes="gameloop.pla"/>
<fileset dir="${src.dir}" includes="*.pla" excludes="gen_*,heaptest*,playtype*"/>
<arg value="-AM"/>
<redirector logError="yes">
<!-- redirect STDIN; fileset collects relative to its dir, but we need -->

View File

@ -37,6 +37,11 @@ const ANIM_PAUSE_MAX = 300
include "playtype.plh"
include "gen_images.plh"
include "gen_modules.plh"
include "globalScripts.plh"
///////////////////////////////////////////////////////////////////////////////////////////////////
// Data structures
include "playtype.pla"
word global // the global heap object, from which all live objects must be reachable
@ -861,10 +866,6 @@ asm _rand16
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Data structures
include "playtype.pla"
///////////////////////////////////////////////////////////////////////////////////////////////////
// General methods
@ -1850,6 +1851,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def testCombat()
word globalScripts, callScript
word combatEngine
word x, y
byte dir
@ -1861,19 +1863,24 @@ def testCombat()
mmgr(RESET_MEMORY, 0)
renderLoaded = FALSE
combatEngine = mmgr(QUEUE_LOAD, MODULE_COMBAT<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 1) // 0 = close
globalScripts = mmgr(QUEUE_LOAD, MODULE_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 1) // 1 = keep open
callScript = globalScripts()
// Create the enemy group(s).
global=>p_enemyGroups = NULL
when rand16() % 2
is 0
addToList(@global=>p_enemyGroups, new_EnemyGroup_Dirt_Bags())
addToList(@global=>p_enemyGroups, callScript(script_new_EnemyGroup_Dirt_Bags))
break
otherwise
addToList(@global=>p_enemyGroups, new_EnemyGroup_Flesh_Feeders())
addToList(@global=>p_enemyGroups, callScript(script_new_EnemyGroup_Flesh_Feeders))
break
wend
// No need for the global scripts now that everything has been created
mmgr(FREE_MEMORY, globalScripts)
// Run the combat engine
combatEngine()
@ -1987,11 +1994,18 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up the small-object heap
def initHeap()
byte i
mmgr(SET_MEM_TARGET, heapStart)
mmgr(REQUEST_MEMORY, heapSize)
mmgr(LOCK_MEMORY, heapStart)
mmgr(HEAP_SET, heapStart)
addTypes()
i = 0
while typeTbls[i]
mmgr(HEAP_ADD_TYPE, typeTbls[i])
i = i+1
loop
global = mmgr(HEAP_ALLOC, TYPE_GLOBAL)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -2021,15 +2035,30 @@ def setLibVecs()
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Create the party
def initParty()
word globalScripts, callScript
globalScripts = mmgr(QUEUE_LOAD, MODULE_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 1) // 1 = keep open
callScript = globalScripts()
addToList(@global=>p_players, callScript(script_new_Player_Hue_Hauser))
addToList(@global=>p_players, callScript(script_new_Player_Mokahnu))
// No need for the global scripts now that everything has been created
mmgr(FREE_MEMORY, globalScripts)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Main code.
//
setLibVecs()
initHeap()
addToList(@global=>p_players, new_Player_Hue_Hauser())
addToList(@global=>p_players, new_Player_Mokahnu())
initParty()
loadTitle()
// Start map/loc per Seth. Need to have this in a script in the futurecheckScripts()
// Start map/loc per Seth. Need to have this in a script in the future()
mapIs3D = 0
mapNum = 1
initMap(6, 123, 12)

View File

@ -0,0 +1,322 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////
include "gamelib.plh"
include "playtype.plh"
include "gen_images.plh"
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Modifier(kind, value)
word p
p = mmgr(HEAP_ALLOC, TYPE_MODIFIER)
p->b_modKind = kind
p->b_modValue = value
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_Chaps
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Chaps")
p->b_itemKind = KIND_PANTS
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_ShamanHeaddress()
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Shaman Headdress(es)")
p->b_itemKind = KIND_HAT
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_TahnkuPants()
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Tahnku Pants")
p->b_itemKind = KIND_PANTS
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_TahnkuVest()
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Tahnku Vest(s)")
p->b_itemKind = KIND_SHIRT
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Weapon_Handgun
word p
p = mmgr(HEAP_ALLOC, TYPE_WEAPON)
p=>s_name = mmgr(HEAP_INTERN, "Handgun")
p->b_itemKind = KIND_HANDGUN
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_ammoKind = KIND_BULLET
p->b_clipSize = 6
p->b_clipCurrent = p->b_clipSize
p=>r_meleeDmg = encodeDice(1, 6, 0) // 1d6
p=>r_projectileDmg = encodeDice(1, 6, 0) // 1d6
p->ba_attacks[0] = 1 // single attack
p->b_weaponRange = 40
p=>s_combatText = mmgr(HEAP_INTERN, "shoots")
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Weapon_SpiritBow
word p
p = mmgr(HEAP_ALLOC, TYPE_WEAPON)
p=>s_name = mmgr(HEAP_INTERN, "Spirit Bow")
p->b_itemKind = KIND_BOW
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_ammoKind = KIND_ARROW
p->b_clipSize = 12
p->b_clipCurrent = p->b_clipSize
p=>r_meleeDmg = encodeDice(3, 6, 0) // 3d6
p=>r_projectileDmg = encodeDice(2, 6, 5) // 2d6+5
p->ba_attacks[0] = 1 // single attack
p->ba_attacks[1] = 3 // triple attack
p->b_weaponRange = 100
p=>s_combatText = mmgr(HEAP_INTERN, "shoots")
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Weapon_SpiritBlade
word p
p = mmgr(HEAP_ALLOC, TYPE_WEAPON)
p=>s_name = mmgr(HEAP_INTERN, "Spirit Blade")
p->b_itemKind = KIND_BOW
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_ammoKind = 0
p->b_clipSize = 0
p->b_clipCurrent = p->b_clipSize
p=>r_meleeDmg = encodeDice(7, 6, 0) // 7d6
p=>r_projectileDmg = 0
p->ba_attacks[0] = 1 // single attack
p->b_weaponRange = 10
p=>s_combatText = mmgr(HEAP_INTERN, "slices")
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def calcPlayerArmor(player)
word pItem
player->b_armor = 0
pItem = player=>p_items
while pItem
if pItem->t_type == TYPE_ARMOR
player->b_armor = player->b_armor + pItem->b_armorValue
fin
pItem = pItem=>p_nextObj
loop
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Player_Hue_Hauser
word p, pItem
p = mmgr(HEAP_ALLOC, TYPE_PLAYER)
p=>s_name = mmgr(HEAP_INTERN, "Hue Hauser")
p->b_intelligence = 5
p->b_strength = 6
p->b_agility = 3
p->b_bravery = 6
p->b_stamina = 4
p->b_charisma = 7
p->b_spirit = 5
p=>w_maxHealth = 12
p=>w_health = 12
// Basic skills
p->b_aiming = 2
p->b_dodging = 3
p->b_wilderness = 5
// Skills
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())
addToList(p + p_items, new_Weapon_Handgun())
// Calculated attributes
calcPlayerArmor(p)
// (No buffs or debuffs to start with.)
// All done with the player.
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Player_Mokahnu
word p, pItem
p = mmgr(HEAP_ALLOC, TYPE_PLAYER)
p=>s_name = mmgr(HEAP_INTERN, "Mokahnu")
p->b_intelligence = 7
p->b_strength = 4
p->b_agility = 6
p->b_bravery = 7
p->b_stamina = 6
p->b_charisma = 7
p->b_spirit = 10
p=>w_maxHealth = 40
p=>w_health = 40
p->b_playerFlags = PLAYER_FLAG_NPC
// Basic skills
p->b_aiming = 4
p->b_dodging = 3
p->b_wilderness = 5
// Skills
addToList(p + p_skills, new_Modifier(KIND_MINING, 0))
addToList(p + p_skills, new_Modifier(KIND_NATIVE_BOND, 10))
addToList(p + p_skills, new_Modifier(KIND_PYRE_WARE, 0))
addToList(p + p_skills, new_Modifier(KIND_BLADE, 3))
addToList(p + p_skills, new_Modifier(KIND_BOW, 3))
addToList(p + p_skills, new_Modifier(KIND_RIFLE, 3))
addToList(p + p_skills, new_Modifier(KIND_BLADE, 3))
// Items
addToList(p + p_items, new_Armor_ShamanHeaddress())
addToList(p + p_items, new_Armor_TahnkuPants())
addToList(p + p_items, new_Armor_TahnkuVest())
addToList(p + p_items, new_Weapon_SpiritBow())
addToList(p + p_items, new_Weapon_SpiritBlade())
// Calculated attributes
calcPlayerArmor(p)
// (No buffs or debuffs to start with.)
// All done with the player.
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Enemy_Dirt_Bag
word p
p = mmgr(HEAP_ALLOC, TYPE_ENEMY)
p=>s_name = mmgr(HEAP_INTERN, "Dirt-Bag(s)")
p=>w_health = rollDice(encodeDice(1, 6, 0))
p->ba_images[0] = PORTRAIT_GUNMAN5
p->b_attackType = 1 // melee
p=>s_attackText = mmgr(HEAP_INTERN, "swings at")
p->b_enemyAttackRange = 5
p->b_chanceToHit = 15
p=>r_enemyDmg = encodeDice(1, 6, 0) // 1d6
p=>r_groupSize = encodeDice(1, 4, 0) // 1d4
p=>r_initialRange = encodeDice(2, 10, 0)
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_EnemyGroup_Dirt_Bags
word p, enem, groupSize
p = mmgr(HEAP_ALLOC, TYPE_ENEMY_GROUP)
enem = new_Enemy_Dirt_Bag()
p->b_enemyGroupRange = rollDice(enem=>r_initialRange)
groupSize = rollDice(enem=>r_groupSize)
addToList(p + p_enemies, enem)
while groupSize > 1
addToList(p + p_enemies, new_Enemy_Dirt_Bag())
groupSize = groupSize - 1
loop
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Enemy_Flesh_Feeder
word p
p = mmgr(HEAP_ALLOC, TYPE_ENEMY)
p=>s_name = mmgr(HEAP_INTERN, "Flesh Feeder(s)")
p=>w_health = rollDice(encodeDice(6, 6, 0))
p->ba_images[0] = PORTRAIT_U_D_MAN1
p->b_attackType = 1 // melee
p=>s_attackText = mmgr(HEAP_INTERN, "bites")
p->b_enemyAttackRange = 5
p->b_chanceToHit = 40
p=>r_enemyDmg = encodeDice(3, 6, 0) // 3d6
p=>r_groupSize = encodeDice(1, 6, 0) // 1d6
p=>r_initialRange = encodeDice(1, 5, 0)
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_EnemyGroup_Flesh_Feeders
word p, enem, groupSize
p = mmgr(HEAP_ALLOC, TYPE_ENEMY_GROUP)
enem = new_Enemy_Flesh_Feeder()
p->b_enemyGroupRange = rollDice(enem=>r_initialRange)
groupSize = rollDice(enem=>r_groupSize)
addToList(p + p_enemies, enem)
while groupSize > 1
addToList(p + p_enemies, new_Enemy_Flesh_Feeder())
groupSize = groupSize - 1
loop
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def callGlobalScript(n)
when n
is 0; return new_Modifier()
is 1; return new_Armor_Chaps()
is 2; return new_Armor_ShamanHeaddress()
is 3; return new_Armor_TahnkuPants()
is 4; return new_Armor_TahnkuVest()
is 5; return new_Weapon_Handgun()
is 6; return new_Weapon_SpiritBow()
is 7; return new_Weapon_SpiritBlade()
is 8; return calcPlayerArmor()
is 9; return new_Player_Hue_Hauser()
is 10; return new_Player_Mokahnu()
is 11; return new_Enemy_Dirt_Bag()
is 12; return new_EnemyGroup_Dirt_Bags()
is 13; return new_Enemy_Flesh_Feeder()
is 14; return new_EnemyGroup_Flesh_Feeders()
otherwise; brk()
wend
end
return @callGlobalScript
done

View File

@ -0,0 +1,25 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////
const script_new_Modifier = 0
const script_new_Armor_Chaps = 1
const script_new_Armor_ShamanHeaddress = 2
const script_new_Armor_TahnkuPants = 3
const script_new_Armor_TahnkuVest = 4
const script_new_Weapon_Handgun = 5
const script_new_Weapon_SpiritBow = 6
const script_new_Weapon_SpiritBlade = 7
const script_calcPlayerArmor = 8
const script_new_Player_Hue_Hauser = 9
const script_new_Player_Mokahnu = 10
const script_new_Enemy_Dirt_Bag = 11
const script_new_EnemyGroup_Dirt_Bags = 12
const script_new_Enemy_Flesh_Feeder = 13
const script_new_EnemyGroup_Flesh_Feeders = 14

View File

@ -1,300 +1,56 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
def addTypes()
mmgr(HEAP_ADD_TYPE, @typeTbl_Global)
mmgr(HEAP_ADD_TYPE, @typeTbl_Player)
mmgr(HEAP_ADD_TYPE, @typeTbl_Modifier)
mmgr(HEAP_ADD_TYPE, @typeTbl_Effect)
mmgr(HEAP_ADD_TYPE, @typeTbl_Item)
mmgr(HEAP_ADD_TYPE, @typeTbl_Weapon)
mmgr(HEAP_ADD_TYPE, @typeTbl_Armor)
mmgr(HEAP_ADD_TYPE, @typeTbl_Stuff)
mmgr(HEAP_ADD_TYPE, @typeTbl_Enemy)
mmgr(HEAP_ADD_TYPE, @typeTbl_EnemyGroup)
global = mmgr(HEAP_ALLOC, TYPE_GLOBAL)
end
// Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Modifier(kind, value)
word p
p = mmgr(HEAP_ALLOC, TYPE_MODIFIER)
p->b_modKind = kind
p->b_modValue = value
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_Chaps
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Chaps")
p->b_itemKind = KIND_PANTS
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
byte typeTbl_Global[] = Global, p_players, p_enemyGroups, p_combatFirst, 0
byte typeTbl_Player[] = Player, p_nextObj, s_name, p_combatNext, p_skills, p_items, p_buffs, p_debuffs, 0
byte typeTbl_Modifier[] = Modifier, p_nextObj, 0
byte typeTbl_Effect[] = Effect, p_nextObj, s_effectDescrip, 0
byte typeTbl_Item[] = Item, p_nextObj, s_name, p_modifiers, 0
byte typeTbl_Weapon[] = Weapon, p_nextObj, s_name, p_modifiers, s_combatText, 0
byte typeTbl_Armor[] = Armor, p_nextObj, s_name, p_modifiers, 0
byte typeTbl_Stuff[] = Stuff, p_nextObj, s_name, 0
byte typeTbl_Enemy[] = Enemy, p_nextObj, s_name, p_combatNext, s_attackText, 0
byte typeTbl_EnemyGroup[] = EnemyGroup, p_nextObj, p_enemies, 0
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_ShamanHeaddress()
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Shaman Headdress(es)")
p->b_itemKind = KIND_HAT
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
word typeTbls = @typeTbl_Global, @typeTbl_Player, @typeTbl_Modifier, @typeTbl_Effect, @typeTbl_Item
word = @typeTbl_Weapon, @typeTbl_Armor, @typeTbl_Stuff, @typeTbl_Enemy, @typeTbl_EnemyGroup
word = 0
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_TahnkuPants()
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Tahnku Pants")
p->b_itemKind = KIND_PANTS
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
byte[] kind_bow_str = "bow(s)"
byte[] kind_blade_str = "blade(s)"
byte[] kind_explosive_str = "explosive(s)"
byte[] kind_handgun_str = "handgun(s)"
byte[] kind_hand_to_hand_str = "hand to hand"
byte[] kind_rifle_str = "rifle(s)"
byte[] kind_throwing_str = "throwing"
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Armor_TahnkuVest()
word p
p = mmgr(HEAP_ALLOC, TYPE_ARMOR)
p=>s_name = mmgr(HEAP_INTERN, "Tahnku Vest(s)")
p->b_itemKind = KIND_SHIRT
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_armorValue = 2
return p
end
byte[] kind_mining_str = "mining"
byte[] kind_native_bond_str = "native bond"
byte[] kind_pyre_ware_str = "pyre ware"
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Weapon_Handgun
word p
p = mmgr(HEAP_ALLOC, TYPE_WEAPON)
p=>s_name = mmgr(HEAP_INTERN, "Handgun")
p->b_itemKind = KIND_HANDGUN
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_ammoKind = KIND_BULLET
p->b_clipSize = 6
p->b_clipCurrent = p->b_clipSize
p=>r_meleeDmg = encodeDice(1, 6, 0) // 1d6
p=>r_projectileDmg = encodeDice(1, 6, 0) // 1d6
p->ba_attacks[0] = 1 // single attack
p->b_weaponRange = 40
p=>s_combatText = mmgr(HEAP_INTERN, "shoots")
return p
end
byte[] kind_bullet_str = "bullet(s)"
byte[] kind_arrow_str = "arrow(s)"
byte[] kind_buck_str = "buck"
byte[] kind_quarrel_str = "quarrel(s)"
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Weapon_SpiritBow
word p
p = mmgr(HEAP_ALLOC, TYPE_WEAPON)
p=>s_name = mmgr(HEAP_INTERN, "Spirit Bow")
p->b_itemKind = KIND_BOW
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_ammoKind = KIND_ARROW
p->b_clipSize = 12
p->b_clipCurrent = p->b_clipSize
p=>r_meleeDmg = encodeDice(3, 6, 0) // 3d6
p=>r_projectileDmg = encodeDice(2, 6, 5) // 2d6+5
p->ba_attacks[0] = 1 // single attack
p->ba_attacks[1] = 3 // triple attack
p->b_weaponRange = 100
p=>s_combatText = mmgr(HEAP_INTERN, "shoots")
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Weapon_SpiritBlade
word p
p = mmgr(HEAP_ALLOC, TYPE_WEAPON)
p=>s_name = mmgr(HEAP_INTERN, "Spirit Blade")
p->b_itemKind = KIND_BOW
p=>w_cost = -99 // for now
// no modifiers, max uses, etc. for now
p->b_ammoKind = 0
p->b_clipSize = 0
p->b_clipCurrent = p->b_clipSize
p=>r_meleeDmg = encodeDice(7, 6, 0) // 7d6
p=>r_projectileDmg = 0
p->ba_attacks[0] = 1 // single attack
p->b_weaponRange = 10
p=>s_combatText = mmgr(HEAP_INTERN, "slices")
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def calcPlayerArmor(player)
word pItem
player->b_armor = 0
pItem = player=>p_items
while pItem
if pItem->t_type == TYPE_ARMOR
player->b_armor = player->b_armor + pItem->b_armorValue
fin
pItem = pItem=>p_nextObj
loop
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Player_Hue_Hauser
word p, pItem
p = mmgr(HEAP_ALLOC, TYPE_PLAYER)
p=>s_name = mmgr(HEAP_INTERN, "Hue Hauser")
p->b_intelligence = 5
p->b_strength = 6
p->b_agility = 3
p->b_bravery = 6
p->b_stamina = 4
p->b_charisma = 7
p->b_spirit = 5
p=>w_maxHealth = 12
p=>w_health = 12
// Basic skills
p->b_aiming = 2
p->b_dodging = 3
p->b_wilderness = 5
// Skills
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())
addToList(p + p_items, new_Weapon_Handgun())
// Calculated attributes
calcPlayerArmor(p)
// (No buffs or debuffs to start with.)
// All done with the player.
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Player_Mokahnu
word p, pItem
p = mmgr(HEAP_ALLOC, TYPE_PLAYER)
p=>s_name = mmgr(HEAP_INTERN, "Mokahnu")
p->b_intelligence = 7
p->b_strength = 4
p->b_agility = 6
p->b_bravery = 7
p->b_stamina = 6
p->b_charisma = 7
p->b_spirit = 10
p=>w_maxHealth = 40
p=>w_health = 40
p->b_playerFlags = PLAYER_FLAG_NPC
// Basic skills
p->b_aiming = 4
p->b_dodging = 3
p->b_wilderness = 5
// Skills
addToList(p + p_skills, new_Modifier(KIND_MINING, 0))
addToList(p + p_skills, new_Modifier(KIND_NATIVE_BOND, 10))
addToList(p + p_skills, new_Modifier(KIND_PYRE_WARE, 0))
addToList(p + p_skills, new_Modifier(KIND_BLADE, 3))
addToList(p + p_skills, new_Modifier(KIND_BOW, 3))
addToList(p + p_skills, new_Modifier(KIND_RIFLE, 3))
addToList(p + p_skills, new_Modifier(KIND_BLADE, 3))
// Items
addToList(p + p_items, new_Armor_ShamanHeaddress())
addToList(p + p_items, new_Armor_TahnkuPants())
addToList(p + p_items, new_Armor_TahnkuVest())
addToList(p + p_items, new_Weapon_SpiritBow())
addToList(p + p_items, new_Weapon_SpiritBlade())
// Calculated attributes
calcPlayerArmor(p)
// (No buffs or debuffs to start with.)
// All done with the player.
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Enemy_Dirt_Bag
word p
p = mmgr(HEAP_ALLOC, TYPE_ENEMY)
p=>s_name = mmgr(HEAP_INTERN, "Dirt-Bag(s)")
p=>w_health = rollDice(encodeDice(1, 6, 0))
p->ba_images[0] = PORTRAIT_GUNMAN5
p->b_attackType = 1 // melee
p=>s_attackText = mmgr(HEAP_INTERN, "swings at")
p->b_enemyAttackRange = 5
p->b_chanceToHit = 15
p=>r_enemyDmg = encodeDice(1, 6, 0) // 1d6
p=>r_groupSize = encodeDice(1, 4, 0) // 1d4
p=>r_initialRange = encodeDice(2, 10, 0)
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_EnemyGroup_Dirt_Bags
word p, enem, groupSize
p = mmgr(HEAP_ALLOC, TYPE_ENEMY_GROUP)
enem = new_Enemy_Dirt_Bag()
p->b_enemyGroupRange = rollDice(enem=>r_initialRange)
groupSize = rollDice(enem=>r_groupSize)
addToList(p + p_enemies, enem)
while groupSize > 1
addToList(p + p_enemies, new_Enemy_Dirt_Bag())
groupSize = groupSize - 1
loop
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_Enemy_Flesh_Feeder
word p
p = mmgr(HEAP_ALLOC, TYPE_ENEMY)
p=>s_name = mmgr(HEAP_INTERN, "Flesh Feeder(s)")
p=>w_health = rollDice(encodeDice(6, 6, 0))
p->ba_images[0] = PORTRAIT_U_D_MAN1
p->b_attackType = 1 // melee
p=>s_attackText = mmgr(HEAP_INTERN, "bites")
p->b_enemyAttackRange = 5
p->b_chanceToHit = 40
p=>r_enemyDmg = encodeDice(3, 6, 0) // 3d6
p=>r_groupSize = encodeDice(1, 6, 0) // 1d6
p=>r_initialRange = encodeDice(1, 5, 0)
return p
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def new_EnemyGroup_Flesh_Feeders
word p, enem, groupSize
p = mmgr(HEAP_ALLOC, TYPE_ENEMY_GROUP)
enem = new_Enemy_Flesh_Feeder()
p->b_enemyGroupRange = rollDice(enem=>r_initialRange)
groupSize = rollDice(enem=>r_groupSize)
addToList(p + p_enemies, enem)
while groupSize > 1
addToList(p + p_enemies, new_Enemy_Flesh_Feeder())
groupSize = groupSize - 1
loop
return p
end
byte[] kind_shoes_str = "shoes"
byte[] kind_coat_str = "coat(s)"
byte[] kind_hat_str = "hat(s)"
byte[] kind_pants_str = "pants"
byte[] kind_shirt_str = "shirt(s)"
byte[] kind_gloves_str = "gloves"
byte[] kind_shield_str = "shield(s)"
// Text table for translating a kind to a string
word[] kinds = @kind_bow_str, @kind_blade_str, @kind_explosive_str, @kind_handgun_str, @kind_hand_to_hand_str, @kind_rifle_str, @kind_throwing_str
word = @kind_mining_str, @kind_native_bond_str, @kind_pyre_ware_str
word = @kind_bullet_str, @kind_arrow_str, @kind_buck_str, @kind_quarrel_str
word = @kind_shoes_str, @kind_coat_str, @kind_hat_str, @kind_pants_str, @kind_shirt_str, @kind_gloves_str, @kind_shield_str
word = NULL

View File

@ -1,3 +1,13 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// Structures for the heap
@ -15,7 +25,6 @@ struc Global
word w_mapY
byte b_mapDir
end
byte typeTbl_Global[] = Global, p_players, p_enemyGroups, p_combatFirst, 0
const PLAYER_FLAG_NPC = $01
@ -56,7 +65,6 @@ struc Player
word p_buffs // list:Effect
word p_debuffs // list:Effect
end
byte typeTbl_Player[] = Player, p_nextObj, s_name, p_combatNext, p_skills, p_items, p_buffs, p_debuffs, 0
// Combat skills, weapon modifiers, etc.
const TYPE_MODIFIER = $82
@ -66,7 +74,6 @@ struc Modifier
byte b_modKind
byte b_modValue
end
byte typeTbl_Modifier[] = Modifier, p_nextObj, 0
// Buffs and debuffs, that last until a specified time
const TYPE_EFFECT = $83
@ -78,7 +85,6 @@ struc Effect
word s_effectDescrip
word w_endTurn
end
byte typeTbl_Effect[] = Effect, p_nextObj, s_effectDescrip, 0
const TYPE_ITEM = $84
struc Item
@ -89,7 +95,6 @@ struc Item
word w_cost
word p_modifiers // list:modifier
end
byte typeTbl_Item[] = Item, p_nextObj, s_name, p_modifiers, 0
const WEAPON_FLAG_SINGLE_USE = $01
const WEAPON_FLAG_WHOLE_GROUP = $02
@ -117,7 +122,6 @@ struc Weapon
byte b_weaponRange
word s_combatText
end
byte typeTbl_Weapon[] = Weapon, p_nextObj, s_name, p_modifiers, s_combatText, 0
const TYPE_ARMOR = $86
struc Armor
@ -134,7 +138,6 @@ struc Armor
// Armor properties
byte b_armorValue
end
byte typeTbl_Armor[] = Armor, p_nextObj, s_name, p_modifiers, 0
// Countable things, e.g. ammo and pelts
const TYPE_STUFF = $87
@ -149,7 +152,6 @@ struc Stuff
word w_count
word w_maxCount
end
byte typeTbl_Stuff[] = Stuff, p_nextObj, s_name, 0
const TYPE_ENEMY = $88
struc Enemy
@ -170,7 +172,6 @@ struc Enemy
word r_groupSize // number encountered, as 3 hex digits for dice
word r_initialRange
end
byte typeTbl_Enemy[] = Enemy, p_nextObj, s_name, p_combatNext, s_attackText, 0
const TYPE_ENEMY_GROUP = $89
struc EnemyGroup
@ -179,37 +180,29 @@ struc EnemyGroup
word p_enemies
byte b_enemyGroupRange
end
byte typeTbl_EnemyGroup[] = EnemyGroup, p_nextObj, p_enemies, 0
// Weapon kinds
const KIND_BOW = 1; byte[] kind_bow_str = "bow(s)"
const KIND_BLADE = 2; byte[] kind_blade_str = "blade(s)"
const KIND_EXPLOSIVE = 3; byte[] kind_explosive_str = "explosive(s)"
const KIND_HANDGUN = 4; byte[] kind_handgun_str = "handgun(s)"
const KIND_HAND_TO_HAND = 5; byte[] kind_hand_to_hand_str = "hand to hand"
const KIND_RIFLE = 6; byte[] kind_rifle_str = "rifle(s)"
const KIND_THROWING = 7; byte[] kind_throwing_str = "throwing"
const KIND_BOW = 1;
const KIND_BLADE = 2;
const KIND_EXPLOSIVE = 3;
const KIND_HANDGUN = 4;
const KIND_HAND_TO_HAND = 5;
const KIND_RIFLE = 6;
const KIND_THROWING = 7;
// Skill kinds
const KIND_MINING = 8; byte[] kind_mining_str = "mining"
const KIND_NATIVE_BOND = 9; byte[] kind_native_bond_str = "native bond"
const KIND_PYRE_WARE = 10; byte[] kind_pyre_ware_str = "pyre ware"
const KIND_MINING = 8;
const KIND_NATIVE_BOND = 9;
const KIND_PYRE_WARE = 10
// Ammo kinds
const KIND_BULLET = 11; byte[] kind_bullet_str = "bullet(s)"
const KIND_ARROW = 12; byte[] kind_arrow_str = "arrow(s)"
const KIND_BUCK = 13; byte[] kind_buck_str = "buck"
const KIND_QUARREL = 14; byte[] kind_quarrel_str = "quarrel(s)"
const KIND_BULLET = 11
const KIND_ARROW = 12
const KIND_BUCK = 13
const KIND_QUARREL = 14
// Armor kinds
const KIND_SHOES = 15; byte[] kind_shoes_str = "shoes"
const KIND_COAT = 16; byte[] kind_coat_str = "coat(s)"
const KIND_HAT = 17; byte[] kind_hat_str = "hat(s)"
const KIND_PANTS = 18; byte[] kind_pants_str = "pants"
const KIND_SHIRT = 19; byte[] kind_shirt_str = "shirt(s)"
const KIND_GLOVES = 20; byte[] kind_gloves_str = "gloves"
const KIND_SHIELD = 21; byte[] kind_shield_str = "shield(s)"
// Text table for translating a kind to a string
word[] kinds = @kind_bow_str, @kind_blade_str, @kind_explosive_str, @kind_handgun_str, @kind_hand_to_hand_str, @kind_rifle_str, @kind_throwing_str
word = @kind_mining_str, @kind_native_bond_str, @kind_pyre_ware_str
word = @kind_bullet_str, @kind_arrow_str, @kind_buck_str, @kind_quarrel_str
word = @kind_shoes_str, @kind_coat_str, @kind_hat_str, @kind_pants_str, @kind_shirt_str, @kind_gloves_str, @kind_shield_str
word = NULL
const KIND_SHOES = 15
const KIND_COAT = 16
const KIND_HAT = 17
const KIND_PANTS = 18
const KIND_SHIRT = 19
const KIND_GLOVES = 20
const KIND_SHIELD = 21