• entries
44
• comments
44
• views
58672

### About this blog

About the game Caveman

## Caveman 3.0 Beta 12 released!

Caveman 3.0 Beta 12 released!

PLAY NOW!
http://rocklandsoftware.net/beta.php

Game info:
http://rocklandsoftware.net/Caveman.php

New for beta 12:
---------------------------------------------
* refactored and improved AI
* give orders to party members
* sound effects
* music
* animations for actions

details:
* following band members now keep up during cross country movement.
* band member AI uses best weapon
* band member AI leaves temp shelter on hostile encounter
* band member AI: stops action if animals nearby. animal must now be within 50, not 100. warriors, companions, tamed, subdued, captured, and non attack_AI animals are now excluded.
* game now checks for encounters once per party, not once per BM. doesn't check encounters for BMs who are within 300 of a BM who has already had their encounters checked.
* fixed: don't let 2 bm's butcher same animal!
* band member AI: attack orders: doesn't attack wounded fleeing thief? cant catch - target too fast?
fixed: was comparing target run speed vs BM walk speed for "skip if target is to fast to catch"
* new AI and orders menu design
* new bandmember AI done
* new orders menu done
* compiles with no warnings with all warnings turned on. fixed a half dozen non-explicit conversions, made them explicit.
* compiles with no warnings in static code analysis. fixed a few potential range check errors, and a couple of possibly uninitialized variables.
* made new band member AI use sprint speed
* made new band member AI play correct animations
* animal and avian AI done
* model animal fatigue
* model animal (flunkey) sneak detection
* set "animal taking fire variables" in check_missile_collision code
* avian version of do_orders
* new avian AI
* load and save animal[a].diving
* collision maps
* ambient sfx
* water sfx
* fire sfx
* BM atttack sfx
* play action animations w/ ani camera view
* finished animal attack sfx
* npc attack sfx
* bm take non-missile hit sfx
* npc take non-missile hit sfx
* code for animal take non-missile hit sfx
* takehit sfx for all animals
* random grunts - caveman ambient audio
* missile hitting tgt sfx
* code to play action sfx
* assign sfx's to all actions
* assign make/repair sfx's to all object types
* get/find sfx for all object types
* sfx when learn skills that use male/female voice (singing and talking type skills)
* ocean sfx when near ocean
* action anis
* stop all wavs when quit game.
* don't let player tab to dead BM
* music
* all audio working
* no random sfx at high game speeds - runs out of voices
* destroy_finished voices added to run_song, stop_all_wavs, and play_ambient_audio
* music starts at title screen now - not main menu
* when possible, uses sfx/wav # != -1, not Zvoice_is_playing to determine if a wav is playing
* use shift select for give bm item
* band member menu: show bm name and relations
* abandon current hut and take over this one: i suspect they will lose all their stuff at the old hut!
when hut is abandoned, instead of asking player if they want to abandon their old hut and take this one over,
create an abandoned hut world object that weathers away over time.
player can take it over at any time.
abandoned hut actions: takeover, inspect, demolish.
added abandoned_hut object, and inspect and demolish actions for abandoned_huts
* remove non-hostiles over time when gamespeed > 128x
* increased volume of smallherd_takehit.wav
* fixed defend ai: now only attacks if tgt is within 50.
* tutor: automatically stops cross country movement when the player first finds water, food, and rocks.
* audio: fixed: didnt check for voice ptr=0 in voice is playing
* doesn't switch to action ani fast enough? was calling startani with params reversed!
* fixed: cave hyena attak sfx is lame

## Progress Report - July 21st 2014

Progress Report - July 21st 2014

Beta 9 has been posted to the website, with a new download page:

http://rocklandsoftware.net/beta.php

I could really use some feedback on the game, so please, check it out! Its just a 60 meg download, and should provide about one evening's worth of gameplay.

Beta 9 now includes such niceities as real setup and uninstall programs.

Still needs audio and an opening animation. But I found a copy of caveman 1.0, complete with all the original wav files! And i still have source code for version 1.0, including the music player code. X Audio 2 based code is already in Caveman v3.0, - ready to go - just add wav files and stir!

I'm thinking I'll hold off on offspring, dinos, modern, an aquatic animals due to the time required to create the additional content (models, meshes, textures, and animations for babies, children, dinos, modern animals, and aquatic animals).

Audio and some serious play testing seems to be the next most important thing on the to do list for the project.

I also added a "quick tour" of the game to the website:

http://rocklandsoftware.net/caveman-tour.php

That's all for now!

Remember - keep your eye on the prize! Twice as important when its a big prize and takes a long time.

Hailing frequencies closed...

## AI in Caveman

Caveman ai:

ai in caveman has been through three major versions.

the first version was just quick and dirty code to get things going. like
all code of this type, it quickly grew and evolved into an ugly mess.

the second version of the ai was a more traditional setstate/runstate
type affair. setstate selected one of about 14 or so AI states for an
entity, depending on what was going on. runstate was a big switch
statement that executed the code for the various states. one problem
with the traditional setstate/runstate model is that it only has one
state variable. so if you have multiple states at once you must have
different states for each combo.

the third and current version of the AI uses a different approach.

it uses prioritized condition checks to determine what to do. as soon as
a condition is found it should react to, it does so, then returns. no
setstate/runstate. as soon as condition is found, the equivalent setstate
is therby determined and the appropriate runstate code can be immediately
executed.

it also uses multiple AI state variables (mostly booleans) in lieu of a
single AIstate variable as in setstate/runstate. so it has AI state
variables like in_collsion _recovery, in_collsion_avoidance,
taking_missile_fire, orders (goto, attack, follow, etc.), and so on.
this allows an entity to be in multiple states at once such as:
"in_collision_recovery" while moving to attack due to
"taking_missile_fire" while "following" another entity. when they finish
collision recovery, they resume moving to attack. when done attacking,
they resume following the entity. without the need to push and pop states
on and off a state stack. the condition check priorities cause them to
automatically resume a lower priority state once a higher priority
state is no longer in effect.

the prioritized condition checks work as an expert system.
the condition handlers (code) in turn are each mini expert systems in
handling their condition. implementation varies depending on the condition
being handled. most are rule based systems. some are state machines. the
handlers in turn may call even lower level expert systems for tasks such
as selecting best weapon to use, etc.

all told, the game implements about 18 different types of ai depending on
the entity type and whose side they're on. so for example, AI for a pet
dire wolf is different from that for a wild, subdued, or captured dire wolf.
and AI for a traveling companion caveman is different from that of a neutral,
hostile, thief, hired warrior, or band member caveman.

there are four basic types of AI for animals:
1. defend - the animal will stand its ground and defend itself if approached.
2. maintain_distance - the animal will attempt to maintain a safe distance
from all threats. if approached, it will flee.
3. attack - the animal is predator. when hungry it will go hunting, feeding
on nearby carcasses if available, or attacking other animals not bigger than
itself. when not hungry it just hangs out.
4. defend_location - the animal will defend a specific location in the game
world. used by quests where animals guard treasure. if far from the
location, the animal will move to the location. if at the location, it will
attack all who approach.

Avian AI is completely separate from that for ground animals, although it
takes the same form.

All animals include "graze" as one of their possible AI moves. its usually
the last choice - IE when there's nothing more important to do.
"graze" cycles between stand, wander, flock, and migrate states periodically
at random. its an example of a condition handler that uses a state machine.
wander simply moves to a random wander_to point. flock moves towards the leader
(the first animal of a given type appearing in the entities list). in the case
of the leader, flock becomes stand. migrate is only used by the leader. the
leader moves off in a migrate_direction determined by the type of animal (so
they still migrate the same direction even if the leader is killed). if a
leader is killed, the next active animal of that type becomes the new "leader".

note that leader migration behavior in combo with flock behavior leads to emergent herd migration behavior! ; )

model the little stuff right and the big stuff happens on its own! - well at least sometimes - if you do it right.

multiple AI states vs setstate/runstate is another example of this. by tracking _multiple_ states (which setstate/runstate does not do) - IE by modeling state in greater depth than setstate/runstate - you automatically get emergent push-state, pop-state type behavior with no pushing, popping or state stack required.

## A day in the life...

A day in the life...

This will give you an idea of what its like to be an indie.

Tasks to be done on the project go on the "todo list". once they're completed, they're moved to the "done list".

here's the "done list" for Caveman for the last few days:

 march 15th:* draw prairie better - need ref photos. need prairie grass textures. made new grass mesh, new grass textures, new grass ground tiles, new grass drawing routine. * draw savanna better - need ref photos. need red dirt tex. need brown grass tex. need acacia tree meshes. need acacia tree bark texxture. need acacia tree leaf texture. made acacia tree leaf texture, tree turnk mesh, and tree model. added ability to add a model to a chunk. added new draw tree routine. march 16-17th:* need to model getting lost better? get lost too easily? adjusted chance to get lost. some difficulty generting a low enough probabiltity check, as the dice() funtion can only go down to 1 in 32K chance. the odds are more like 1 in 2 million (or billion?) per frame.* tried numerous (six?) methods for drawing rain, including particle system. still no satisfactory solution. march 18th:* fixed weather engine (hopefully). world now split into 3 climate zones, hot, med, cold. sand, jungle, savanna only found in hot zone. limits placed on "temp at cm0", based on climate zone. so no snow in hot zone etc. * snow in jungle - weather engine* different weather for different areas? improved weather engine* snow in desert - weather engine* snow in savanna- weather engine* wood spear male 1st person atk ani - already fixed* water quads - gaps at seams - already done* water quads - increase clip rad - already done* clouds move too fast? cut speed in half* gap in ground mesh where flowing water meets ocean. need to change heightmap near ocean. if at edge near ocean, heightmap = lerp from std heightmap to zero. fixed. heightmap was returning water edges with no seam fixup. now it does water heightmap, then seam fixup.seam fixup already accounts for ocean.* fix heightmap where flowing water crosses map square edge. was caused by no seam fixup. now it does seam fixup.* z fighting where flowing water meets ocean. made hm_flowing_water_edge routine that comes before (overrides) seam fix where water crosses map edge.* ocean color is darker than flowing water. generate ground mesh: ocean was using ground material, not default material.* add impass mtns to player map when they come into view* automap the local map more often, spinting skips some local map squares.* butcher animal - show % done. already done.* should not get fatigue watching clouds etc. - you don't. its damage and encumberance doing it.* animate player run (walk, actually) in cross country 3pv* clouds move too fast, shouldn't move as fast as wind? cut speed 50%. march 19th:* player jump ani in 3pv* 3pv, jump: make model go up/dn.* fixed: forward motion stops while jumping during continuous movement.* jump: restart sneak ani from the beginning each time they start a jump.* impass mtns - show msg, improve hgt map. already done.* game starts in winter! fixed, starts in spring. * stargaze, etc - show mood during the action. did stargaze, watch clouds, sing, dance, play drums, play flute, and daydream.* draw player upatree in 3pv.* dont draw player upatree so high in a tree in savanna. upatree increases y by 20. this is done many places in the code, hard coded as 20. making it a variable would be major work. probably not worth it. * superclip4 was clipping bandmember upatree. turned it off for drawing current bandmember upatree.* move upatree height down to work with acacias, as well as taller trees. so that hard coded 20 became a #defined constant after all.* disable move, climb, sneak, and jump when upatree* moving manually, fatigue hits 100%, triggers rest action, speed doesn't drop back to normal at end of rest action. fixed. it was pushing donothing on the action stack. when rest ended, it would pop donothing and not change speed, instead of setting action to donothing and speed to normal.* increase clip rad of acacia tree model. same issue as 3pv clipping of player up a tree? superclip not working for objects below the camera?* sleep doesn't take long enough? increased base time from 1500 to 1700.* green sky, just before noon? fixed. limited r,g,b to 255. brighter sky was probably causing wrap around.* should rain wake you up? rain and snow now wake you up when it starts to rain or snow.* rest - if no action afterwards, set gamespeed to normal (1). already done.* use old flat heightmap for swamp* rest action: show fatigue %* ACTION AREA FOR RIVER NOT WIDE ENOUGH? fixed. increased from 20 to 30 radius.* river quads dont quite reach to edge of river bank. fixed. increased draw rad from 30 to 40.* small deer are too small and slow. fixed. animal 28. scaled model by 1.5. changed texture and moved horns so it wasn't just a smaller version of animal 11. increased speed to .4* improve heightmap where flowing water crosses map edges.* more stars at night - double up the textures march 20th:* savanna being generated in bottom 1/2 of map, not bottom 1/3!* need non-tropical savanna. same as savanna, appears in northern 2/3 of world, uses regular tree models.* regen terrain chunk if waterhole or creek goes wet/dry. covergae can change too. and other types of water. 2 choices: 1. regen map sqaures that change. 2. invalidate all chunks when the map changes, forcing regen of all chunks. made it init_chunks after change_the_map. no problem. runs plenty fast. didnt even notice it re-generating all visible chunks. march 22nd:* input mapper. can remap input controls to any key or mouse button. added new playetest menu, triggered by alt-F12. moved playtest hotkeys (including old playtest menu) to new playtest menu. pain in the ass. lot of typing. 2 days. 33 input controls, mappable to any key, or L or R mouse button. needed a routine to return the name of a key/button. numbers, function keys, and letters were easy. everything else required a huge switch statement. same thing when checking what key they pressed. tons of typing.* falling snow needs help - need to get online. current effect is passable. good enough for now.* rain: need better rain effect - need to get online. made rain tube w/ endcaps. tube is cylindrical mapping scaled 30x10, endcaps are planar mapping scaled 10x10. uses 4 animated textures in round robin fashion. tube is unit size, scaled to 3 ft height and diameter around the camera. march 23rd:* improved caveman font* dropped lit torch - animate flames !use torch model. save head texture. change head texture to flames, and also draw a quad with flames. similar to flaming javelin. restore head texture when done.should a lit torch go out if you drop it? - No.make flaming torch model - animate the textures before drawingdone. model already made. animated the textures, set material to beacon.* crc check for corrupt savegame files. give option to load backup if corruption detecteddid checksum. added to z3d library:appendfilebin()filesize()file_checksum_ok()calc_checksum()append_checksum()made the game load save "b" if no save "a" found.added checksum to save and load game. shows msg if checksum bad. aborts load.ran quite slow at first, doing it one byte at a time, 15 seconds? made it use 2K buffers. takes about 2 seconds. maybe 4 from disk. not bad for a 67 meg savefile.* add optimize meshes to playtest menu. remove optimize mesh from loadmeshes. march 24th:* skybox not low enough. fixed. made it unit size, centered on origin. made it draw at scale 3, centered on camera.* made sun and moon draw centered on camera, not player at y=0. skybox centered on camera and sun/moon centered on player caused parallax motion of moon when you slew the 3pv camera around.* fixed block ani 1pv* block ani 3pv* draw lit torch in hand, 3pv. added draw_lit_torch_BM(). added drawinlh(). * draw lit torch in hand, 3pv, animate the flames. set material to beacon.* change defult mapping of "sheath wpn" to the "F" key. "H" is too far from W and left shift when you're trying to sprint away and sheath your weapon to move faster.* remap input: doesnt list all control names correctly (function keys). both remap and get_vk_name used string manipulator at same tme! made get_vk_name use its own internal string.* add: reset input controls to default mapping.

## The Building of Caveman - part 2. What to build, and tool selection

The Building of Caveman - part 2.

What to build, and how?

What to build? thats the first of a million questions to be answered when
building a game.

Well, the answer turns out to be pretty simple:

you build what you want to play, that somebody else hasn't already built
for you.

odds are, if you think its cool enough to play that you'd go through the
effort of building it just to play it, then maybe other people might
like to play it as well.

in my case, it was pretty easy. i'd already made over a dozen games over
the years. some hits, some ok, some that didn't sell much at all.

so you go with what works.

the line of thought was: "well, my biggest hit was probably Caveman,
so i probbaly ought to do that first."

So that settled what to build: you lead with your strong suit, your
flagship product.

Now, how to build it:

Platform:
PC. bigger installed base than mac and linux. insufficient
manpower (i'm an army of one) to support multiple platforms,
so PC is it. moble etc isnt even an option ue to the size of the
game - at least at first - pc alone is plenty of a challenge.

Language(s) and libraries:

WHATEVER:
1. HAS THE CAPABILITIES REQUIRED
2. RUNS FAST ENOUGH
and
3. WILL REQUIRE THE LEAST LEARNING AND DEVELOPMENT TIME

in my case, that was procedural ADT C++ code (look it up!), and DX9
fixed function. i'd been coding C/C++ games since before OO syntax,
and didn't really need the OO language extenstions, thus the
procedural ADTs. And Caveman has a paleolithic setting with no
magic or fantasy elements, so not much in the way of special effects,
smoke, flames, clouds, thats about it. so all i needed was
aniso-mipmapped textured meshes, with a little alpha test and alpha
blend. I do use a 2 stage textre blend for snow on the ground but
thats it. i was already familair with dx8, and hadn't learned
shaders yet - i hadn't needed them. still haven't really learned
them or needed them yet in fact. truth is, i'm a little scared
to get into shaders for fear i'll like it too much. the mere
concept of such power to "party on the bitmap" is...
intoxicating .

At this point i should mention that Caveman was developed on a
budget of $0. one baseline$400 pc (no graphics card), and
internet access, thats all you get to work with. no money for
tools, content, middleware, etc.

Compiler:
ms visual studio of course. i started with basic, then pascal,
then watcom C, all in the quest for speed. sometime in the mid
90's microsoft got a clue and added the compiler optimizations
required for games to the free version of MC C++. And directx
tends to work better with ms c++ than with some other compilers.

3d modeler:
truespace rosetta 7.61 beta
1. its free
2. used to be the next best thing after 3dsmax
3. full directx .x save capabilities built in. no conversion /
import / export headaches.

2d paint programs:
paint.net and "free clone stamp tool".
both are free. paint.net has the basic capabilities of
photoshop. clone stamp takes up the slack. a really awesome
little texture painting program.

Audio tools:
TBD (to be determined)
i have xaudio 2 up and runnning but so far all it does is
play "time to relax", track 1 from the album "smash"
(as i recall) by the offspring as a test. it was the first
wav file i came across on my hard drive. the music for the
game is pretty simple, tom toms and flute for atmosphere,
funky beats reampped to jungle drum kits for combat. and i
have the general 6000 series 50 cd sound effects library
from Sound Ideas for foley sfx. but i gues i'll have to
build another bow. the sound of a primitive bow firing was
the only effect i had to make myself for the original version.
to do it, i made a 7 foot long bow, with fishing line for
the bowstring, and relatively straight wood sticks for
arrows. having paid $1000 for the sound effects library, i was bound and determined to get my money's worth out of it. so i used the box as the mike stand while i recorded the sound of me firing the bow down the hallway in the house! . up next: step one, getting a handle on directx graphics. part 3: https://www.gamedev.net/blog/1730/entry-2259520-the-building-of-caveman-part-3-getting-a-handle-on-directx/ part 1: https://www.gamedev.net/blog/1730/entry-2259487-the-building-of-caveman-part-1/ ## Caveman v3.0 general desciption [color=rgb(40,40,40)][font=arial]CAVEMAN 3.0 general description.[/font][/color] [color=rgb(40,40,40)][font=arial]Someone suggested i post a description of CAVEMAN as a reference link in threads about the game.[/font][/color] [color=rgb(40,40,40)][font=arial]CAVEMAN is a fully immersive 3d Paleo-World simulator. Its a persistent modifiable open world RPG / person sim, with a fps / 3ps interface.[/font][/color] [color=rgb(40,40,40)][font=arial]so its sort of a cross of a fps like Oblivion, an RPG like table top D&D or Traveller, and a person sim like The SIMs.[/font][/color] [color=rgb(40,40,40)][font=arial]you can do all the normal rpg stuff, plus you can select almost anything in the environment and interact with it like in The SIMs.[/font][/color] [color=rgb(40,40,40)][font=arial]The setting is paleolithic, about 200,000 to 10,000 years ago. no techno. no magic.[/font][/color] [color=rgb(40,40,40)][font=arial]the player can control a band of up to 10 cavemen (like a household in The SIMs).[/font][/color] [color=rgb(40,40,40)][font=arial]Band members have core stats like strength, intelligence, etc. - the usual RPG stuff.[/font][/color] [color=rgb(40,40,40)][font=arial]Band members also have variable stats as seen in The SIMs, like food, water, hygiene, and mood.[/font][/color] [color=rgb(40,40,40)][font=arial]46 skills and experience in each. You can research, teach, and learn skills, as well as acquire then through use.[/font][/color] [color=rgb(40,40,40)][font=arial]no classes.[/font][/color] [color=rgb(40,40,40)][font=arial]a 2500x2500 mile randomly generated, persistent, modifiable world. The "ground mesh" for the world is procedurally generated in chunks on the fly as needed from data structures containing the "world map" (right down to the last rock, plant, and clump of grass). The entire world ground mesh is [/font][/color]87.12 TRILLION triangles[color=rgb(40,40,40)][font=arial].[/font][/color] [color=rgb(40,40,40)][font=arial]Over 200 types of objects you can make or find.[/font][/color] [color=rgb(40,40,40)][font=arial]62 types of weapons.[/font][/color] [color=rgb(40,40,40)][font=arial]Over 50 types of extinct Mega-fauna to hunt or be hunted by.[/font][/color] [color=rgb(40,40,40)][font=arial]thousands of possible actions, from filling water skins, to repairing a bow.[/font][/color] [color=rgb(40,40,40)][font=arial]exploration, resource gathering, crafting, and trade.[/font][/color] [color=rgb(40,40,40)][font=arial]In depth modeling and simulation of lots of stuff, from windage effects on arrows to death by background radiation (IE old age).[/font][/color] [color=rgb(40,40,40)][font=arial]The player starts with one band member, but can get NPCs to join their band.[/font][/color] [color=rgb(40,40,40)][font=arial]The objective is for your band to become as powerful as possible and last as long as possible.[/font][/color] [color=rgb(40,40,40)][font=arial]The game ends if all your band members die. [/font][/color] ## Caveman v3.0 Beta 19 released Caveman v3.0 Beta 19 released! Play now! http://rocklandsoftware.net/beta.php Numerous changes in Beta 19: * added export band member * added import band member * added de-activate band member * make pigment rock object smaller. * draws obj in hand for find pigment rock action. * confirmed game won't run on XP. * added obj in hand for make/find objects #70 pigments thru #173 blanket (103 objects - some need new anis though). added dinfo and fix as needed. made draw_dropped_object use dinfo where appropriate. * added: stone drill required to make stone top armor. * completed first pass at assigning obj in hand for make or find anis for all 237 object types. but some still need new graphics and / or anis. so most make, find, and repair animations draw object in right hand now, say 400-500 animations or so. * reduced size of clay object * make, repair, demolish type animations drawn closer to ground. * increased NPC base chance to hit from 50% to 70%. * increased BM hand attack base chance to hit from 60% to 70%. * increased BM missile attack base chance to hit from 50% to 70%. * moved make ani back down to -1.5 * made selected_dropped_object the first check in select(). * turned off colision avoidance in rocks. terrains is so thick they appear to just cycle between collision avoidance and collision recovery. * select: checks for shelter before bedding. * collision recovery: cut recovery time in half, since they now move at sprint speed (2x run speed) * BM attack AI: explicitly calcs rng to tgt for start of attack. rng may have not been preset in cases such as "attack orders tgt", which overrides the tgt set by set_tgt. set_tgt pre-calcs rng and rh to tgt when it set the tgt. * BM AI: no badguys nearby: priorities changed to: 1. do action 2. collision recovery 3. do orders 4. recover fatigue 5. stand * BM collision recovery: cut recovery time in half, since they now move at sprint speed (2x run speed) * maintain dist ai: added is_maintaining _distance AI state flag to animalrec. AI now flees at 25 and stops fleeing at 50, instead of starting and stopping at 20. * added BM AI on/off for CM0 via backslash key w/ AI display * BM AI: draws wpn if attacking * BM AI: reduced start atk rng * sleep ani drawn lower to ground * made sleep take a little longer * increased rad for "inside perm shelter" from 5 to 10 feet * daydream, watch clouds, stargaze: mood now goes up one every 5 minutes not 6. * improved bigdice routine * AI backs up at half speed * BM AI start attack range for missile wpns set to 50. * turned off collision avoiadance in woods - too dense * collision avoidance rng reduced fro 15 to 10 ft * playtesting * flint spear: reduced cordage required from 3 to 2 * doubled value of hides and all objects made from hides * done - made int affect building and fixing hut * done - made int affect learn action: time, chance, and xp earned. * done - fill waterskins takes too long * done - draw all bm's on local map * done - remove dead / butchered / sacrificed anilas after a while * done - kick bm out of band * done: " you learned something new about " msg * done: show bm name for a few secs when tab to next bm * done: changed "do" and ".do" keywords in cscript to "d" and ".d". removed all c++ code blocks from source code. all code is now cscript or c++ that does not conflict with cscipt keywords. no c++ code pass thru blocks required! no "cpp" and ".cpp" everyhwere in the code! recompiled all source code with new version of cscript. * done: made perm shelters a world object * done: repair: parts reqd: 1/2 round down, not up. * done: repair: quality is now avg of old and new. * done - too easy to find cool rocks * done - adj party str - too many badguys? * done - companion ai stop when within 20 * done - increase base chance to make lean-to * done - made int have greater effect on time and chance to learn stuff * done: increase value of hides and stuff made with hides * done: make flint tipped spear: only reqires two cordage. * done: objects ropped in aved get placed outside caves. * done: made int affect qual of tirm repaired * dont let them pickup player huts - and abandoned huts - and landmarks * adjust hut collision checks * separate key for pickup dropped object. - z? * bmsg "you pass out from lack of sleep" * add "quiting caveman" screen at end of prog * storepit full msg added, objects no longer lost when pit is full. * precip increases water table by twice as much. no precip reduces water table by half as much. water table goes to baseline twice as fast over time. had global warming issues. * automap_small_stuff radius increased to 300 feet * fixed: automap_small_stuff does huts now. * added next idle band member hotkey "N" * daydream etc increases mood faster * bmsg you arrive at your dest * quiting caveman screen * show all parts / skils for action if you dont have something * joke and story actions: increased chance of relations improvement, increased mood boost. * doubled find time for flint and cool rocks * added initializing blank game msg * increased base chance to make temp shelter. made int affect chance. improved how chance is calculated. * increased chance to make storepit * reduced caveman base number appearing. * reduced effect of party strength on cavean number appearing * party strength based on those within 300 feet, not on those in same map sqaure. * increased drawing radius of bedding and storepits * fixed: party_strength: using a continue statment in the while loop skipped the call to next_active_BM at the end of the loop. hazards of using a "findfirst/findnext while loop" instead of a "0 to max for loop". bloody generic iterators! * make cordage, make arrow actions: now continue until you run out of parts. * show next BM name in UL corner of screen for a moment when tab to next BM. * remove butchered / sacrificed animals after some period of time. * increased no draw rng for huts and storepits. * fixed: common ai: tgt is stronger: was using BMs hp adjusted for diff lvl, not base hp for a type 2 animal (homo sapien). predators would close, then flee during common fight or flight. * fixed: subdued and captured animals shouldn't be able to move. * turned off atk to subdue. doesnt make sense for domesticating dire wolves, and you can't subdue and capture cavemen, and you shouldnt really be able to domesticate anything else, so... * dire wolf hp reduced to less than humans so they dont atk people. * need to implement new way to domesticate dire wolf. dire wolf goes for dropped meat. drop enough they follow you. drop more they allow you to approach. give meat action. give enough meat, they become pet. added new dire wolf AI: if dropped meat nearby, they goto dropped meat and eat it. eat enough, they start following the closest BM at that time. eat more, that bm can approach and select and get dire wolf menu (give meat, cancel). give enough eat, they become state=TAMED. * dire wolf - they dont move to the meat - exhausted? called run (spd based on rng to tgt) instead of run maxspd * fixed: predators ignore stronger animals. sets pred tgt (ignore equal or stronger) only when hunting, and sets wild tgt (dont ignore any) the rest of the time. * fatigued animals now rest until fully rested, not 2% rested * wolf: moveto owner: runs if rng > 100 * wolves with relations > 1000 are not removed when distant * player can now accel tieme faster than 128x when only predators weaker than humans are nearby * added message when tame wolf * added "enter name for new pet..." when tame wolf * fixed: other wolves attack your wolf when you tame it. friendly wolves no longer count as leader for flock behavior. other wolves now wander off. * fixed: wounded tame animals flee forever. made AI flee from closest threat, not current target (pet owner if pet is far from owner). added closest threat function based on animal type (wild animals and hostile cavemen, -or- pets, warriors, companions, friendly cavemen, and bandmembers). * predators now only target weaker foes, not equal or weaker. * wild leaders for flock behavoir now excludes tamed animals and friendly wolves. * fixed: drink from leaves: says its snowing when its raining! used 40 degrees instead of SNOW_TEMP. searched the entire code. this was the only place SNOW_TEMP wasn't used when it should be. * fixed: pick fruit crashes game. tool_and_part_quality: calculating avg quality of tools and parts used: did divide by zero if numtools and numparts was zero. now returns quality of 100 of numtools and numparts is zero. did same fix to RR_tool_and_part_quality. no other occurances of similar code "/ sum count" in the game. shift select blows up if list full, no range check? - same bug. * fixed: pick fruit action - game crashes. tool_and_part_quality: calculate avg tool and part quality: divide by zero if numparts and numtools = 0. now returns quality 100 if numprts and numtools = 0. did same fix to RR_tool_and_part_quality. searched entire code for: "/ sum" to find bugs similar to: "/ sum count". none found. * fixed: full storpit - get stuff - scroll way down crahses? select_object and shift_select_object: list was 20 long, now is 40 long, scroll limit was still max-20, not max-40. no similar bugs found. * animals list full? added error messages everywhere the game adds animals. * cool rocks still too easy to find. doubled time required. cut chance in half. works out to about 4x as hard. * fixed: demolish wood shelter doesnt take long enough. demolish_shelter action used buildtime(world_object_index), not buildtime(world_object_index.shelter_type) oops! . * fixed: demolish leanto doesnt take long enough: fix to demolish_shelter action fixed this too! * base chance to make bedding too low? increased from 50% to 70% * bow wears out too quickly? cut avg rate of wear by factor of 10. * add storepit - doesnt rest chunks and collision maps? the low level funtion now does it for all calls to add storpit. * fixed: demolish bedding in shelter demolishes the bedding. was demolishing sheletr_index, not sheleter_index.bedding_index oops! . * fixed: shelter weathers away while bm inside asleep, or inside in general. added msg that your temp shelter weathered away. * fixed: ingame menu: increase width of hotspots * fixed: ingame menu: video and gameplay hotspots overlap * fixed: ingame menu: only play klik when the click on an option. * fixed: dont let them move x-country from inside temp shelter. did "up a tree" too! now can only move x-country when OUTSIDE or ONRAFT * fixed: npcs: all interests should be unique * show msg when complete search dead caveman action, then show the take item screen. * search dead caveman: if they dont have anything, just show a msg instead of the take item screen. * fixed: daydream etc should reduce fatigue. energy wasn't set to 1 for daydream, stargaze, and watch clouds actions. energy=1 means they recharge fatigue while doing that action. * fill waterskinrain doesnt take long enough - increased time by factor of 10. * done: to make / fix (skills list) msg: dont say make / fix. its used for stuff like learn too! * fixed: collision recovery moves before it finishes turning? now it doesnt move until abs(rh) < ~11 degrees, not <45 degreees. * what happens when run out of ani players? turned on error msg in z3d library * fixed: falling rain should not wake up bms inside a hut. BMs in player huts and rock shelters are not woken up by precip. * fixed: move following bm's moves any following even if not nearby or following someone else. only move nearby who are following the BM in question. * increase size of collision map cache. increased from 20 to 40. * done: make mouse wheel zoom camera in and out faster. did keyboard controls too (numpad plus and minus by default). * done: 3pv cam vs hut interior - switch to 1pv temporarily? uses 1pv when player is inside hut. * fixed: glypto moves too fast. cut speed in half. * big cats get stuck in woods . big animal encounter spacing vs rocks and other dense terrain . big animal encounter rng too close . elasmo vs woods . imp mammoth encounters too close to player. . imp mammoths start too close togetehr. flip betw collision avoiddance and recovery. . palorchestes gets stuck in woods increased spacing. increased encounter range based on size of group. now near edge of group, not center of group, is at encounter range. fixed something in way of animal - it didnt take radius into account - thus the animals stuck in rocks etc. now it checks center, and the 4 bbox corners for something in way of an animal when doing initial placement of animals encountered. * fixed: game crashes when you try to fix something that can't be fixed (wood grindstone, 1 hand hammer, etc). now it gives you a message saying that type of object can't be repaiered. * fixed: follower joins band: rain sfx stops. player stuck in collision with new BM. action sfx init-ed to 0 not -1. didn't adjust bandmember location. adj bm loc didnt handle radius. stuck in collsion with new bm: rounding error: animal_in_way_of_bm used float rng, bm_in_way_of_bm used ints. now both use floats. * fixed: move followers, moves those with orders to the contrary suchas wait here goto here, etc. followers with goto orders, or orders to follow someone other than the moving BM, dont get moved. * attack thief - all neutrals become hostile? only if you attack before the dialog shows. * yield: init NPC_type so yield works? test yield. make sure it works. it may not use npc_type anymore. yield works. npc type is set already. make thief_dialog set thief to NPC_KILLER if they become a HOSTILE. * cave hyena didn't attack? increased hp of some predators so their AI will attack humans * orders: atk: doesn't work when no tgt? or at all? need to test it some. if no orders tgt, uses current tgt, if none, doesnt atk. tested. woking fine. * fixed: order pet to wait here doesnt work. b2_issue_animal_orders told animal i to goto bandmember i's location, not animal i's location. a copy-paste-edit error, introduced when converting the code from cm[] to animal[]. but follower AI still needs help. they follow owner before following orders! * follower ai needs help - make it like bm ai. changed follower ai: old priorities: do common AI move2owner if > 100 if tgt nearby do orders or atk listen to story etc moveto owner if > 20 stand new priorities: do common AI do orders (if has orders) atk nearby tgt (if has one) listen to story etc set move2owner_flag move2owner (if flag set) stand * fixed: game doesn't model spoilage of food in storepits * already done: teach doesn't take as long as learn? already fixed: learn was called once per game minute, and teach was called once per frame (update or turn) - IE 15x per game second. * show skills: dont show last 3 undefined skills. dont show mapmaking. is bonelore used? mapmaking? re-did view_skills - made a new view_skills2 routine. bonelore and mapmaking are gone. * order everyone: gets goto location, target, or who to follow just once, instead of once for each party member ordered. * fixed: didnt set bedding's world object ID when resting on bedding. * DONE: dont let 2 BMs use the same bedding at same time. when select bedding, need to check all other bm's for bedding action with that bedding, if found, show msg saying someone is already using that bedding. DONE: WATER and WATERSKINS: * improve how water and waterskins work. move the water with the container. make sure they have sufficient waterskins whenever they transfer water. store in pit, drop on ground, fill waterskins (water source or rain), give water to bm, pickup dropped, etc. when they transfer a waterskin, transfer water as needed. dont let them drop water. only let them drop water in waterskins. abandon water as requierd if they abandon waterskin. need to possibly mod calls to add2inventory and add2stufflist. fill waterskin watersource, fill waterskin rain, give water to bm, npc menu (trade, ask for item), trade with band (get water). * fill waterskins and fill waterskins rain check for waterskins full and max encumberance at start of action handlers. fill waterskins didnt check encumberance until water was gathered. fill waterskins rain didnt check it at all! * all fill waterskin from water source actions now use try_fill_waterskins. * made sure fill waterskins and fill waterskins rain check for player has waterskins. so now - for sure - they can't gather water without waterskins. can only get it from storepit, other BM, NPC, or trading with a friendly band. * checked: get stuff from storepit makes sure they can carry water before giving it to them. so it makes sure they have enough waterskins. * store stuff: checks for waterskins in the pit, and not all full. now you cant store water in a pit that doesnt have non-full waterskins. * drop object: no longer lets you drop water. tells you to drop a waterskin instead. * checked: pickup dropped object calls can_carry, which check encumberance, container capacity, and waterskin capacity. so they can't pickup dropped water without a non-full waterskin. * newtrade and trade_with_band: doesnt let you trade for water if you dont have non-full waterskin. * ask for item: doesnt give water if cant carry * trader hut: doesnt trade for water if cant carry * give_item2bandmember: doesnt give water if cant carry * getstuff and storestuff: transfers water as needed when get/store waterskin. * give_item2bandmember: transfers water as needed when give waterskin. * trade_with_band: removes water as needed when trade away waterskins * new_trade: removes water as needed when trade away waterskins * trader_hut: removes water as needed when trade away waterskins * fixed: some calls to indexdropat checked for return of 0, not -1 on error. * indexdropat activates new record for each waterskin dropped. no longer adds waterskins to existing active records. so each active record with a waterskin has only one waterskin, and data[0] can be used to store how much water is in it. * drop object: transfers water to dropped waterskin as needed. amount of water is stored in waterskin worldobj[].data[0]. * abandon object: removes water as needed when abandon waterskins * transfer_to_waterskin_as_needed: calcs avg qual of water transferred, and stores it in worldobj[].data[1] * pickup_object: if object is WATERSKIN, checks encumbrance vs waterskin+the water in it, and transfers the water with the waterskin, if they can carry both the waterskin and the water in it. --- END WATER AND WATERSKINS CHANGES --- * DONE: turn clip ranges and autocliprange on again. this also fixed: clip rng for animals too far compared to clip rng for terrain chunks. * cant see small dead animal under the water. draw them at y = 0. dead animal in water are now drawn at y=0 (water level) - IE half floating in the water. * 3pv cam, make min altitude ground + a few feet so its above ground coverage. defined MIN_ALT_3PV_CAM. set it to 3.0f (three feet). old hard coded value was 1 foot. added it to set 3pv cam for: cave, cavern, outdoors, perm shelter, rockshelter, and hut. * make anis: need different y's for male and female. * dawn & dusk are a little to dark. they are now lower limited to nighttime lightness. * fixed: doesnt do fire light in adjacent map sq * make 3pv cam look over avatar's rt shoulder * sleep ani - draw at different heights dependingon has bedding * dont draw avatar in 3pv if player is looking almost straight up. * make sure accel time display, tutor messages, hud, etc dont overdraw each other. * already done: not stop and start anis correctly when NPC joins band? * already done: view inventory: flush sprites before drawmouse * sleep on bedding: make them line up on the bedding. adjust location and orientation. * dont play rain sfx when snowing * doesnt play fire sfx in adj map sq. typo bug. called dist w/ mx,mx,x,z, not mx,mz,x,z. * view stats - only play klick when they click on the done or rename buttons. * add tada sfx to game saved. * make animals do sliding collisions * already done during playtesting: show all BMs on local map * make mouse wheel zoom world map in and out. * reinit dice from time to time. now calls initdice once per game day. * more animals ? double the base chance of animal encounters? increased by 10x. try it and see... * more water. rocks etc? water: every map sq, to once every 10-100 map squares rocks: chert, flint: 28% of land = 1 in 3.57 map sq's on avg. obsidian, quartzite: 1 per 230 map squares (mtns & volcanos only) volcanoes: one per 4600 map sq on avg. in lines along plate boundaries. tar: seeps from underground oil deposits which cover perhaps 10% of the planet. = 1 in 10 map sq's on avg. * talk to caveman: ask directions to rocks, berry bushes, good hunting grounds, etc. a simple goto location quest. getting there is the reward. talk to cavemen: ask directions to water, woods, rocks, etc. do they always know where stuff is? do they always tell you? do they sometimes tell you a bogus location? can you ask them more than once and get a different response?-no + trade maps w/ npcs, will they trade? do they gve you a bogus map? can you trade more than once and get different maps?-no + npcs: ask whats around: do they always know? will they tell always you? do they sometimes give you bogus info? can you ask more than once and get a different response?-no + combine ask directions, whats around, and trade maps, and what do you get? an extended whats around. npc: exchange knowledge of area. caveman: ask whats nearby - automaps everything in a 1 or 2 (or more?) map square radius around the player. not as realistic as tracking what each npc knows, wheter they will tell you, if they give you bogus info, if you've already asked them, etc. so you need flags for "what they know", and "if you've asked them already" for each thing you can ask them (where's rocks, water, wood, whats to the north, etc) + simpler - relations governs if they tell you or not, and it reveals world map in a 2 map sq rad (for example) on success, and nukes relations some on failure. but can ask again, (with ever decreasing chance of success due to ever decreasing relations from repeatedly asking ; ) ). + or would early humans freely share such knowledge? friendly caveman: exchange knowledge of local region. why wouldnt they? resource competition? not in early stages when resoureces where plentiful. cant see why they wouldnt share knowldge of local area. it would automap say, everything in a 1 map sq radius around current location - world and local maps - completely - IE entire local maps revealed. * talk to cavemen, ask if you can travel with them. - if yes...then what? you can follow them around -whooptie do! if no...then what? they throw rocks at you to keep you from following them? i mean - hey, its a free planet - right? if you happen to go where they do, as long as you dont interact with tem and nuke relations, no biggie. - or- you become their companion, and must hang out near them, and they fight with you, and give you orders. go here, wait, attack that, etc. but a nearby friendly will generally fight with you. so ask to travel with may not be needed. you can just follow them if you feel like it. * add dismiss follower action * already done: encounters don't correct for encounter location in adjacent map sq when player near map sq edge. * "move storepit" added to playtest menu * fixed: Zdomessages, getmouse, and mouse wheel. now fps view and world map both zoom with mouse wheel. * grogs game converted to new savegame format. * new world map generated for grogs game. moved the base camp. added new huts and bedding. moved all storepuits. abandodned empty storepits. * finished converting grogs game to new world map. demolished all old huts and bedding. now they're all at the new camp, making arrows, gathering wood, or sleeping. * made BM vs BM and BM vs NPC relations go to zero over time * followers: take shares. original version, followers took a share of hides, meat etc from kills at the end of fps combat mode. now follower reations go down over time. if < 50, they leave your party. so you have to give hides etc to keep them in your party. * types and numbers of animals at crh's is not persistant. when gen encounter, have to set type and num. when one dies, reduce num. added animal_type and num_animals to crhrec. added is_crh_animal and crh_num to animal rec. if game does cave or rocksheletr animal encounter, if crh2.num_animals<1, it generates crh2.animal_type and crh2.num_animals. else it uses the current values. when an animal is killed, if animal.is_crh_animal, crh2[animal.crh_num].num_animals--. * eruptions: should be 10% chance per year per volcano of 1 eruption. = 10/365/24% chance per hour for a given volcano. reduced from one per week on avg to ~10% chance per year, specifically: 11 in 1000000 per hour. * improve timing of state changes in graze AI. reduced chance for state changes by factor of 10. flock rng changed from 50 to 25*animaltype.rad. * make int have greater effect on time and chance to make and fix stuff. some of this is already done, but not all make and fix actions. make int affect time, chance, and qual of all items made or repaired. also added adjust for dex as needed. ALREADY DONE: makeobj learn fix_object build_playerhut repair_playerhut makeobj2 repair_world_obj repair_trap teach bandmember (learners int only, not teachers) FIXED: makefire cook make_shelter repair_shelter make_bedding makebedshelter fixbedding make_storepit repair_storepit make_raft repair_raft poison wpn find_object addwood2fire forrage train (w/ wpn) learn_from_caveman teach_caveman learn_sailing apply_camo * improve avian ai. fixed: move_avian set y to ground height! made "orders: maintain distance" use new maintain_distance AI code. made avian AI code match animal AI code. collapsed some redundant code into single stand alone function calls. * drop object doesnt handle dropping objects across a map sq edge into the next map sq! need to normalize dropat location rel to cm0. either that or remove distant dropped doesnt work across map squares. fixed: drop_object now normalizes drop location. any_BM_near_worldobj: added check for BB map sq dist < 2. it already handled map sq edges in other respects. * game doesn't model bedding weathering, just wearing out from use. * fixed: bedding.data[0]=is_in_shelter, bedding.data[1]=shelter_num, shelter.data[0]=has_bedding, shelter.data[1]=bedding_num * make teachers int affect "teach bandmember" action. * fixed: bm_in_way_of_bm: call to BBdist: typo: was mx1 mx1 mx2 mz2, not mx1 mz1 mx2 mz2. duh! took all morning to find and fix. will check all calls to bbdist for similar typos. and calls to dist2! * fixed: get_fire_sfx: typo in call to bbdist * fixed: get_fire_sfx: typo in call to dist2 * checked all 174 occurances of BBdist for typos. only found the one in get_fire_sfx. * checked all 68 occurances of dist2 for typos. get_fire_sfx was the only one. * fixed: getstuff and storestuff: was if index==WATER, not if object[index].type==WATER. * fixed: getstuff and storestuff: was "if index==WATER", not "if object[index].type==WATER". * fixed: drop_object: was "if index==WATER", not "if object[index].type==WATER". * fixed: too many encounters are elephants. now all 6 elephant types collectively have the same chance as any other single animal type of appearing in a given type of terrain. IE if there are say, 32 differnt types of common animals in a given terrain type, now just one will be "some sort of elephant". what sort of elephant is then determined based on the terrain type (not all types of elephants appear in all terrain types). this for example, reduced elphant encounters in savanna from 16% to 3% of all animal encounters. * checked out skinned meshes. code looks doable. .x files look ok. truespace has rigged models ready to go. need to learn how to animate models in truespace. * eat/drink: show a menu of edible inventory to choose from. * make mouse wheel zoom world map faster. * butcher: add bmsg(). added ": you butchered an animal!" made all messages such as "you get some meat!" read ": you get some meat!". that should help keep things straight when the band is butchering kills after a hunt. * automatically load last saved game if player dies (except in tutor). added to continue, new, and load. * replace all calls to select_item with shift_select_item. now only repair_object and sell_to_trader actions have you select just one object at a time. only "select item to trade band for" needed to be changed. all others already used shift_select_item. * implemented new zoom-able local map! : ) * more hotkeys for world map: arrow keys and numpad arrow keys to scroll u/d/l/r. * more hotkeys for local map: arrow keys and numpad arrow keys to scroll u/d/l/r. * fixed: 1pv w/ wpn drawn, or sprinting, can see 3pv avatar! code got screwed up when "dont draw avatar in 3pv when looking almost straight up" was added. this also fixed: still draws 3pv cam when look up * fixed: 3pv cam is too far to the right. moved to from 1 foot to 1/2 foot right of center. #defined xofs_3pv_cam. made all six versions of set3pv cam use it. there are six versions to adjust to the six different types of complex environments in the game (outdoors, in hut, in rockshelter, in cave, in cavern, and in playerhut). * girl sleep on bedding: bandmember y is too high. chnged from baseline_y-1 to baseline_y-1.5 * increase drawing clip rad of animal #30 small antelope. increased from 2 to 3. * change loading screen to copyright 2015. made new loadmsg() routine. * add ability to toggle between world and local maps * test avian attack ai - not working right? + fixed: didnt call set_predator_tgt (weaker prey only) when hunting. it would target strong prey, then flee when close! + fixed: didn't call do_animal_attack when attacking! it would dive on a target correctly (the hard part), but not attack when it got there! + fixed: avians start their attack too late. doubled avian vs ground target start_attack_range from 30 to 60. makes perfect sense. the new AI attacks at sprint speed, not run speed - IE double the speed it used to. so now it needs to start its attack twice as far away. i love it when the physics works out correctly! now once again, if there are big hungry avian predators around, you'd better do something or you're going to die! + fixed: avians now land before resting due to fatigue + fixed: set xr (pitch) to zero when standing. + fixed: climb/dive vs avian tgt: it was setting desired_altitude to ground level at target's location for all targets, even avains. now it sets desired_altitude for avian targets to the target's altitude. ***** still need to test avian vs avain start_attack_range. in general, start attack range formula may need to get fancier, and take into account speed and direction of attacker and target, not just speed of attacker and range to target. stuff done to fix avian vs avian AI: * renamed b2_avian_attack() to b2_avian_attack_ground_target(). B2_avain_attack() is tailored for ground attack. * added b2_avian_attak_avian_target() * added: b2_avian_match_targets_altitude() for use by avians against avian targets. * fixed: draw_animal_model: if dead: if in water draw at water level, else draw at ground level. was backwards: if in_water draw at ground level, else draw at water level. (oops!) * fixed: didnt start to land to eat carcass until right above it. now: if not at carcass, but within within 50: if flying, lands, else fly a bit (towards carcass). landing starting at 50 put them close, fly a bit (which causes oscillation betwen fly and land, until at carcass) make them "hop up" to the carcass - just like a real bird. * added instructions to the "create a new character" screen * demo now starts player in temperate savanna terrain. * end demo: removed references to atk to subdue and capture. * tutor: added info about "z" key to pick up dropped objects * turned off playtest hotkeys in demo * increased cave hyena hp in demo so they attack player. * tutor: gives encounter advice right after the normal encounter message - not right before. * upatree: badguys dont leave! simply have them ignore targets that are up a tree. set_predator_target now ignores band members who are up a tree if the animal type cant climb trees. ## Progress report - Nov 2013 Progress report - Nov 2013 Its been a while since I posted any info on the Caveman project, so I thought i ought to post an update. While I haven't posted any blog entries or screenshots in a couple months, I have been very busy working on the game. As of the last update in mid-September, a first pass had been completed at making it draw everything in the game. Since then, most work has been on polishing the graphics, with some optimization of accelerated time mode as well. The following was completed in the last half of September: adding dead as well as alive bandmembers led to the "code change in 99 places!" thread, and a bit of modding of the code. In the end, its refactored, better designed, more generic, and more flexible for use with adding further features. a simple alpha texture blending effect was used to draw snow on the ground with fixed function pipeline. a generic ground mesh generator was created, then added to the game to create cavern floor meshes on the fly as needed. its based off the "new way" chunk terrin mesh generator, and is generic enough to be used for caverns, caves, even the outdoor terrain meshes. but the chunk system works fine, so i see no reason to refactor it to use the generic mesh generator. however, all future features will use the new generic mesh generator. I've actually done this with a number of systems developed for the game. For instance, there are three different internal API's available for checking the conditions for beginning an action. The original API could only perform basic checks, such as some level of a single skill and some quantity of a single object. The second API expanded this some. The third and current API uses a "requirements record", a struct that contains all the info related to performing an action: skills, tools, and parts required, in what quantities, and of what quality, and what skills you get experience points in when you successfully complete the action. Since the game has 100 types of actions, and many can be triggered in multiple ways (gather wood is an option on both the jungle and woods action menus), and since the older APIs worked fine for the actions that used them, i never went back and refactored them to use the newest API. When i do need to make changes to the trigger for an action, i update it to the new API if needed. This is basically a case of "not fixing it if its not broken", because there's so much other work to be done. I added a Zaudio library to the collection of Z libraries - a wrapper for the Xaudio2 and 3D sound APIs, and made the game use it. So the game can now play wav music and sound effects. However i still have yet to create any audio content for it. at the moment it simply plays track one off of an Offspring album as a test. can't remember the name of the album. "self esteem" and "gotta keep em separated" are on it. Npcs now use all types of weapons and armor in the game. The code has been modified with conditional compilation to create both a full version and a demo version of the game. the demo will be used for beta testing, and as marketing material. The game now lets you view the model of your player. A caveman model viewer has been added that lets you view any caveman model in the game - of which there are almost 600 now. As an example of the level of detail in polishing graphics: The game now draws rain outside an overhang, not inside it, when you're under an overhang. Not even Oblivion does this. try it. goto weynon priory, and walk through the "tunnel" to the stables when its raining. it rains inside the tunnel! Actually most games do this, they draw rain if outdoors, and don't if indoors, and leave it at that. It was only after i added the effect that i noticed that Oblivion doesn't do it. A generic random map API was created. Since pretty much all of Caveman is procedurally generated, it relies heavily on "pattern maps" of various sorts. these maps specify the location and orientation of things like trees, bushes, rock outcroppings, plants, as well as things like what ground texture tile to use on a given ground quad. The heightmap for canyon floors needed improvement. it seemed a perfect time to experiment with a generic random pattern map. the map itself is a simple structure: int randmap[100][100] its seeded with random values from 1 through 100. the map can then be interpreted as one sees fit for any purpose. for its first use, i wrote a routine that converted an x,z location to a y altitude based on the random map. x and z were dvided by 10, then modded to get the "randmap[x][z]" indices. an flerp was done along the north and south edges, and then between the edges, to the the exact point between the corners [x][z] and [x+1][z+1] on the randmap. the user interface for the game was changed. it no longer displays any stats whatsoever, no health bar or anything! instead, when a stat gets low, an "idiot light" such as "low water" or "high damage" is displayed. this seems to make for a much more seamless and immersive experience. besides the above mentioned, the following graphics were done during late September: falling snow cavern interiors chasecam view in interior scenes improvements to clouds, sky, plants, skybox, dropped objects, and lighting. October: * drawing swamp * bandmember attack animations based on weapon type. * player's model animated in 3rd person view. * i found an interesting typo / logic error (yes, a BUG in one of MY programs!): frame % 15 == a, instead of: a % 15 == frame this made NPCs numbers 15 and higher never select a new target, causing them to all run off in the same direction. * new AI for bandmembers and npcs with missile weapons. * hit points were re-balanced from body_wt / 10 to sqrt(body_wt). the old formula made big critters unrealistically hard to kill (like 100+ spear hits to take down a mammoth). now the hit points and damage system are in line with all available archaeological evidence as to just what it took to kill these animals. * made accelerated time run faster. this was done by using the 2D indexes for the flatfile cave and hut databases. The game has 50,000 caves, 5000 rockshelters, and 28,000 huts. all in one big flat file database (array of structs). the first 50,000 structs are caves, the next 5000 are rockshelters, and the last 28,000 are huts. looping through 5000 rockshelters checking for encounters with their occupants isn't too bad, but doing so for 50,000 caves or 28,000 huts is a bit slow. so 2D indexes were created for caves and huts. the index is a 2d array whose indiecs are the map square coordiantes. the entry is a list of the indexes of the caves caves or huts in that map square. so encounter checks are only done vs the caves and huts in the player's map square, not all 28,000 or 50,000. this sped up the periodic encounter checks for occupants of nearby caves and huts. as a result, accelerated time runs much faster now. A fast as one game hour per real world second, while still doing full simulation of everything. * drawing missiles (arrows, altatl darts, sling stones) in attack animations. it already draws the weapon, and draws the missiles in flight and on the ground. * improvements to rain and falling snow effects * improvements to rendering tall grass terrain. added a second grass texture, tweaked the textures for more realistic coloring. added functions that use the new generic randmap to do texID, scale, rotation, and offset for grass. Now the tall grass terrain is generated using a single generic random map - the same one used for canyon floor heightmaps! looks good. i'll post a screenshot. November: on october 30th i started on improving the animal animations. its now November 27th, and i'm still at it. The game has about 50 types of extinct mega-fauna in the game. each type of animal has 5 animations: stand, walk, run, attack, and dead. So far i've done about 40 of the 50 animals in the game. Each animal takes about half a day. The game is now up to about 110 animations total. reuse of animations between animal models has been less than hoped for. this is partly due to inconsistencies in the modeling. if a body mesh is flipped around end to end or upside down when creating the model, the rotations for the animations are backwards, resulting in some interesting moonwalk type results. This requires separate animations for critters with flipped bodies. next time, i'd just use two separate un-flipped body meshes so i could share animations. size of the animal also can make animation sharing impossible. large and small animals seem to need to move at different speeds. and the leg length of an animal has a definite effect on the speed at which a walk or run animation should play to sync properly with their forward progress across the ground. One of the big surprises is the stand animations. you would think that one generic animation of standing around doing nothing would work fine. As it turns out the stand and attack animations tend to be unique for each type of critter. Stand is where the personality of the animal comes out. so the stand animation for a hippidion proto-horse must behave like a horse, and camelops must behave like a camel, and silvatherium must behave like girrafe, and... well you get the idea... so slowly but surely i'm bringing all these extinct mega fauna back to life. testing the animations is quite interesting. You start a playtest game, punch up the animal in question, and watch it - like on animal channel! makes me feel like the crock hunter, or marty stoufer of wild america, or marlin perkins of mutual of omaha's wild kingdom. Once you've got them behaving correctly and have the walk sync'd up to the right speed, then you punch up some caveman encounters and watch the combat. this lets you check out the attack and run animations. after much back and forth of "this leg kicks out to far" and "runs still seems a bit slow", you eventually get something that starts looking and behaving like a real live animal. as i go along, some need improvements. i redid similodon populator (the biggest saber tooth ever) and homotherium (american scimitar cat) from scratch. Since taking on a saber tooth tiger was the original inspiration for the game, figured i HAD to have a better looking smilodon. so it was back to the reference photos, and the downloaded models to create a new set of limb meshes and assemble a new model. results were better than expected. A couple other models got minor adjustments to improve the head pivoting of the model for animation purposes. i'm currently working on animal type 61, the dire wolf. between the terrain graphics and the animal models and animations, there are times when its really starting to look like the real thing! which is much more than i could ever hope for - given that its just me, and not an army of graphics coders, modelers, and animators. improved animations is last major thing for graphics. i'd really like to get some rayleigh in-scattering atmospherics going, but that will have to wait. there are more important features to be implemented. savanna and prairie terrains still need to be improved. looks like i'll be making my own acacia tree model from scratch, as none - even those for sale on turbosquid - looks correct. a few other minor things, and animating flames, is about it for graphics. Then its time to implement the remaining high level features such as raidung and inter-band rivalry. and then its test and tweak time, along with beta testing, and when its ready (but not until!), release! wait, is that a speck of light i see at the end of the tunnel? ## An example of a big change in Caveman An example of a big change to Caveman I've been playtesting a lot recently. Drawing objects in an avatar's hands in animations is the next thing on the todo list - and that's just eye candy. I'm into gameplay, not eye candy. So I've been playtesting my long term playtest game, making note of fixes to be made. I've gotten to the point where I have 10 bandmembers in my band! Occasionally I'll stop and make a change necessary to continue testing. But that is becoming less and less frequent. I can test for an entire day with no changes required to continue testing. That's a sure sign that the game is getting closer to completion, when everything is working correctly and no major issues are encountered while testing for hours or days on end. I just finished a change that was really required for futher testing. Permanent shelters have been replaced by a new type of object, a PLAYERHUT. Before the change, each bandmember had to create or takeover their own hut, and they were limited to one each. Now, each bandmember can create or takeover as many huts as they wish, and huts are owned by the band, not individual bandmembers. So one bandmember with lots of construction skills can build huts for all the bandmembers. A description of the changes involved: #declare object type -------------------- defines an ID number for this type of object. the game tracks items in the world using a "objrec2", which is an instance of 1 or more items of a given type and quality at a given location. lists of objrec2's are used for containers, PC and NPC inventories, and the world objects list (dropped inventory items and items built by the player - such as huts! ). The game uses a relational database design, with objrec2's pointing to object type instances in the object types database, via a object type ID number. object type instances contain info like name, weight, and price which are common to all objects of a given type. init_object_types_database -------------------------- inits the object type's entry in the object types database. IE sets name, weight, price, etc. not much here, i set the name and radius but the code uses neither! :O PLAYERHUT methods: ------------------ build inspect repair demolish in_way_of_drawing // boolean. dont draw plants etc in huts! in_way_of_moving // boolean. collision check add_to_collision_map // adjusts 3pv camera location to hut interior get_3pv_camera_coordinates first_BM_nearby raid // conducts hostile caveman raid on a player hut should get_3pv_camera_coordinates be a camera method or a playerhut method? it uses both... continuing along those lines... should in_way_of_drawing be a render method? should in_way_of_moving be a physics method? should add_to_collision_map be a collision map method? should first_BM_nearby be a bandmember method? more and more its seems that for loose coupling and tight cohesion, code ought to be divied up into two types: 1. low level classes that know only about themselves, and 2. controling code that uses low level classes. then the controling code would do something like: loc=bandmember.get_location loc2=calculate 3pv camera location from loc playerhut.adjust_3pv_cam_location(&loc2) camera.set(loc2) bandmember, playerhut, and camera only know about themsleves. only locations are passed between them and the controling code. world objects list methods: --------------------------- // checks if a world object is in any player hut worldobj_in_playerhut // checks if a bandmember is in any player hut BM_in_playerhut remove_stuff_nearby_playerhut render methods: --------------- draw_world_objects draw_local_map draw_world_map process_input methods: ---------------------- selected_playerhut // boolean playerhut_menu // playerhut actions takeover_abandonded_hut update methods: --------------- remove_distant_dropped_objects // dont remove stuff near huts! model_playerhut_raids // calls playerhut.raid if a raid occurs model_playerhut_weathering other methods: -------------- // boolean. checks if bandmember is near a player owned cave, rockshelter, or hut BM_near_shelter // boolean. checks if player owns a cave, rockshelter, or hut owns_shelter The actual changes were pretty straightforward. permanent shelters used: bandmember.has_perm_shelter bandmember.perm_shel_quality bandmember.shel_mx bandmember.shel_mz bandmember.shel_x bandmember.shel_z and player huts use: worldobj.active worldobj.qual worldobj.mx worldobj.mz worldobj.x worldobj.z all the code already existed, it just needed to be changed to use PLAYERHUT world objects instead of a bandmember's permanent shelter. One prime motivation for this change was the fact that caves, rockshelters, and NPC huts you can take over now occur at random locations in a map square (a square 5 miles across). They used to be at most one of each per map square, and always in the same place. And if there was water in the map square it was always nearby all of them - IE everything was near the center of the map square. Now its much rarer for a cave or hut to be near water and all rockshelters are more than a mile from the closest water. So building a hut is the best way to get a shelter close to water, which is the most frequently required required resource in the game. And it takes a lot of skills to build a hut. The research tree is incredibly long and complex. So requiring each bandmember to go through this to be able to build a hut when their fellow bandmember(s) already have the skills to do so didn't make sense. Not sufficiently realistic, needed to be improved. Thus the change. And now... I'm off to build huts for all my bandmembers! You should see what its like trying to cram all ten of them in one hut so their mood doesn't go down from being out in the rain! . ## How can i kill thee? let me count the ways... How can i kill thee? let me count the ways... There are lots of ways to die in Caveman. For a long time, I've been wanting to post a list, but have never gotten around to it until now. I've been play testing the past few days. Now I'm implementing the changes that play testing uncovered. Then I'll post beta 15. One change is taking 1 dp as well as getting sick from eating raw or spoiled food. But if you take damage, you can die! So now there's yet another way to die in Caveman! . This got me to wondering just how many ways you could die now in Caveman, so I searched the code, and made a list: Ways to die in Caveman: -------------------------------------------- 1. killed by hostile caveman 2. killed by wild animal 3. swept away by flood waters and drown 4. food poisoning - NEW! before was only indirectly through death by illness (caused by food poisoning). 5. drug overdose 6. dehydration 7. illness 8. exposure to cold 9. heatstroke 10. starvation 11. volcano 12. earthquake 13. comet strike 14. meteor shower 15. hailstorm 16. wildfire 17. fall from tree while climbing up or down 18. falling to your death (fall off cliff, etc) 19. background radiation (old age) 20. drown while swimming did I forget any? . ## "instancing" with DX9 The new PC has arrived (i7-6700K, GTX1080), and I'm starting on the final graphics for the game. Better grass plants were one of the first things. The placeholder graphics were ultra-low-poly, just 3 or 4 quads. I could only draw them every 5 feet or so, any closer together was too many instances. They were scaled very wide and flat to cover the gaps. it looked ok en masse, but individual plants weren't that great. So after watching Youtube tutorials, i made some better plant models. I was testing them out, but noticed a frame rate hit. 2500 instances was ok, but a bit of a performance hit. 10,000 was a big performance hit. So i did some experimenting. i would track the number actually drawn, and the number of polys in the mesh being used, and the FPS, and the scale. at first it seemed the number of draw calls was having the biggest effect, followed by the number of tris in the mesh used, with mesh scale (big tri rasteriization) practically no effect (scale up the grass in your game to 20-30 feet tall - it looks wild!). but on closer inspection, i was drawing about the same number of quads with 10000 one quad meshes vs 2500 3 quad meshes, but 10000 was half as fast. turned out it was the figuring out of which of the 10,000 to draw that was the performance hit. So then it was time for some test code. The optimal way to do it would be to pre-calc the lsit of plants to draw, along with their world mats. set the texture, material, mesh, clamp, cull, tex scale, etc just once, then for each plant in the list, set world mat, then call D.I.P. I tried it with 2500 plants. a 100x100 foot area with one plant every 2 feet. worked like a charm. no change in framerate. still 60 FPS. then i tried 10000 plants (200x200 foot area, one plant every 2 feet). worked like a charm. no change in framerate. screenshots: the total meshes drawn is in addition to the 10000 grass plant meshes. those are the ground, tress, berry bushes, the huts, the teepee, the fire, people, etc. this shows a closeup of the grass. still needs work, but its getting better. and here's the test code: /* optimal: pre-calc all world mats set alphatest, cull, clamp, material, and tex scaling once. set each tex once. for each tex, set each mesh once. for each mesh, set world mat, call DIP */ #define max_grass_list 10000D3DXMATRIX grass_list[max_grass_list]; int num_grass_list;void init_savanna_grass_list(){ int x1,z1; float x,y,z,sx,sy,sz,ry,jitter,scale; ZeroMemory(grass_list,sizeof(D3DXMATRIX)*max_grass_list); num_grass_list=0; for (x1=0; x1<100; x1++) { for (z1=0; z1<100; z1++) { x=26200.0f+(float)x1*2.0f; z=13100.0f+(float)z1*2.0f; jitter=grass_offset((int)x,(int)z); jitter/=2.0f; x+=jitter; z+=jitter; y=heightmap(cm[cm0].mx,cm[cm0].mz,x,z); scale=(float)grass_scale((int)x,(int)z); sx=scale*0.05f; sy=scale*0.03f; sz=scale*0.05f; ry=grass_rotation((int)x,(int)z); Mstart(); Mscale(sx,sy,sz);// MrotateRADS(0,rx); MrotateRADS(1,ry);// MrotateRADS(2,rz); Mmove(x,y,z); grass_list[num_grass_list]=Mmat; num_grass_list++; } } }void test_draw_savanna_grass(){int a;HRESULT result;trace[0]=0;Zsettex(454); // 6=oceanZsetmesh(4);Zalphatest(1);Zcull(1);Zclamp(1); Zsetmaterial(7);Ztexture_scaling(0);for (a=0; aSetTransform(D3DTS_WORLD,&grass_list[a]); result=Zd3d_device_ptr->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,Znum_verts,0,Znum_primitives); trace[0]++; if (result != D3D_OK) { Zmsg2("test draw savanna grass error"); exit(1); } }} so it would seem that lots of drawcalls is not necessarily a bottleneck. perhaps even less of a bottleneck than high poly meshes. i tested plant meshes with as few as two triangles, and as many as 64 triangles. as is often the case, its visible surface determination that's the bottleneck here. In such cases, optimization in the form of DOD seems to be the best approach. EDIT: I turned off the test code to draw savanna grass, and turned generate_savanna_grass back on. I kicked it up from one plant every 3 feet to 1 plant every 2 feet (from 10,000 to 22,500 plants per 300x300 foot chunk). This required an increase in the number of max_meshes in a terrain chunk (from 20,000 meshes to 25,000 meshes). but with a chunk cache of 90 chunks, that ran out of memory. So i knocked the cache size back down to its original 30 chunk size. i'm now making 36,000+ draw calls per frame at 60 FPS - clip range in this shot is set to 400 feet for everything: Since the data structure for visible surface determination is the key to all this, i'll provide a few details.... the entire graphics engine is build around a struct called a Zdrawinfo struct. it contains all the basic parameters for a draw call, such as mesh ID, texture ID, material ID, and flags like cull, clamp, alphatest, etc. When a terrain chunk is generated, data from the world map and plant maps determine the terrain type and placement of trees etc. A terrain chunk is a list of Zdrawinfo structs - all the meshes in the chunk. it also has an index, which lists the structs in texture, mesh order. When a mesh is added to the list, an in-order insertion is done to the index. so the chunk contains the list of Zdrawinfo structs, and an index that consists of a list of textures, and for each texture, a list of meshes, and for each mesh, a list of instances in the Zdrawinfo list that use that texture and mesh combo. The index is implemented using ints for storage, and stores texture IDs, mesh IDs, and Zdrawinfo list indices . When rendering, the index is used to draw the meshes in texture, mesh order - to minimize state changes. The graphics engine includes state managers for all states such as cull clamp, alpha test, etc. - so so any redundant changes occurring there while rendering the instances of a texture.mesh combo will be automatically filtered out. Chunks are generated on-demand in the foreground if necessary, as well as being generated in the background using a multi-pass look ahead system to generate chunks around the player before they move into visible range. Generating 22,500 plants vs 10,000 in a single background pass is slightly noticeable. I'll probably need to split that up into two passes. Depending on the type of terrain in a chunk, a chunk can require up to 6 or 8 passes to generate in the background. background chunk generation runs at 15Hz. The game now features a user defined variable frame rate limiter that scales update to the desired framerate. Vsync is still on to avoid tearing, but desired FPS values of 1 through 1000.are supported by the code - if you have the hardware to do it. NOTE: Apologies for the somewhat dark images. these screenshots were taken at 6:30 AM game time under natural lighting conditions. ## The building of Caveman - part 6 - data structures The building of Caveman - part 6 - data structures When i first got into programming as my major, my biggest fear was that I'd end up as a database programmer. Turns out I became a gamedev. But i still have to do database programming. Sure, games are interactive multimedia entertainment simulations, but underneath all that is - you guessed it - relational databases! It turns out that a complex game can have a rather complex relational database system behind it. Terminology: database or list: a static array of structs, usually a one dimensional array. record: a struct in an array field: a variable in a struct. In the game, most databases and lists are implemented as static arrays of structs. structs are referenced via their array index. Maximum sizes required are known ahead of time, which allows the use of fast simple static data structures. Many of the databases are relational, with some field (variable) in a record (struct) being the array index of some other record (struct) in some other database (array of structs). Some of the databases are nested, with one field in a record being an entire list. IE a variable in a struct might be a whole array of structs. For example, each band member struct has a member varable which is a list of active traps, implemented as an array of structs. These are the data structures used by the game: Asset databases: First off, the generic databases for assets: 1. meshes - a VB and IB, numtris, and numverts. 2. textures - a d3d texture of some type 3. models - models simply refer to meshes and textures. 4. animations - a list of keyframes with limb orientations 5. animation players - a playback counter, plus model and animation references. Caveman follows a mantra of one texture per mesh for speed. Models are made up of multiple meshes. An entry in the models database references meshes in the mesh database, and textures in the texture database. An entry in the animation players database references a model from the models database, and an animation from the animations database. All asset databases are part of the generic Z game library used by Caveman. Type databases: 1. actions - prerequisites, time required, chance of success, etc. prerequisites can include references to skills and object types. 2. skills - prerequisites to learn, time required to learn, chance of learning success, etc. prerequisites can include references to skills and object types. 3. object types - prerequisites to craft, weight, damage, cost, time to craft, chance to craft, etc. prerequisites can include references to skills and object types. 4. animal types - hit points, turn rate, speed, etc. IE non-variable stats. animal types include a reference to the models database, and references to the animations database. single instance lists: 1. active bandmembers - an entity list for PCs. the player can tab between PCs at any time. Other PCs are controlled by AI. each active bandmember has an inventory list, a list of active traps, a list of active quests, and a list of active intoxicants. a bandmeber record has references to the following databases: models (for body), meshes (for face and hair), textures (for skintone), and animations. 2. active animals - all NPC cavamen and animals (every non-PC entity). animals which are of type 2 (homo sapien) refer to an entry in the NPCs database where additional NPC specific data is stored. animal records also refer to the animal types database, and the bandmembers list (for owners of pets). 3. active missiles - arrows, throwing rocks, etc. Smoke from fires may be implemented as a type of missile. missile records refer to either the bandmember list or the active animals list (for owner), and also refers to the object types database. 4. world objects - temporary shelters, storage pits, rafts, landmarks, dropped objects, etc. Basically anything man-made except for huts. structs in this array reference the object types database. 5. active storage pits - a list of storage pits created by the player. refers to the world objects database (a storage pit is a world object). includes an inventory list for each pit. 6. active rafts list - a list of active rafts. references the world objects database (a raft is a world object). 7. NPCs - non bandmember cavemen. contains info on NPCs encountered by the player. references the model, mesh, and texture databases. includes an inventory list for each NPC. NPCs at a CRH reference the CRH list. 8. CRHs (caves, rockshelters, and huts) - a list of all the caves, rockshelters, and huts in the game - 83,000 of them! each entry has an inventory list (paged from disk). CRHs occupied by animals refer to the animal types database. There is also a player's version of the CRH list, that only contains info about CRHs the player has discovered. 9. player cave list - a list of those CRHs controlled by the player. references the CRH list. basically an index of player controlled CRHs for use with the CRH database. single instance matrixes (2d arrays of ints): 1. numconvos - tracks the number of conversations this day between band members and NPCs 2. relations - tracks relations amongst bandmembers, and between bandmembers and NPCs. multiple instance lists: 1. inventory lists - list of objects carried, stored, or for trade. entires in the list refer to the object types database. each bandmember, storage pit, NPC, and cave/rockshelter/hut occupied by friendlies has an inventory list as one variable in their struct declarations. 2. Trap lists - a list of the status of active traps set by a band member. refers to the world objects list (the trap is a world object). each band memeber record includes a trap list field (variable). 3. Active quest lists - a list of active quests. references the animal types database. each band member struct has an active quest list. 4. Active intoxicants lists - a list of intoxicants currently affecting a band member. references the object types database. each bandmember struct has an active intoxicants list. handy structs used in the game: i find that sometimes its handy to have a sturct to pass info around. 1. location - the world map is a 500x500 grid of map squares. each map square is 5 miles across. a location is specifed by its map square indices (mx,mz) and by its d3d location in that map square (x,y,z). a scale of 1 d3d unit = 1 foot is used. a location struct is a handy way to store both the map sqaure and location of an object. 2. requirementsrec - a list of parts, tools, and skills required to do something. used by skills, object types, and actions. 3. Zdrawinfo - all the info to draw a mesh, static model, animated model, 2d billboard, or 3d billboard. used everyhwere to pass drawing info around. 4. objectrec2 - an inventory list entry: active, object type, quantity, quality, location. Used for inventory and world object lists. world map data structures: 1. the world map - a 2d array of structs. the world map is 500x500 map squares in size. a map square is 5 miles across. a location is specified by its map sqaure indices (mx,mz), and its d3d location in the map square (x,y,z). a scale of 1 d3d unit = 1 foot is used. a maps sqaure struct contains info for elevation, vegetation coverage, water, resources, etc. there is also a player's version of the world map that only contians data for explored areas. 2. the local map - basically a 2d array of ints, used as booleans, explored/unexplored. This is used as a "bitmap mask" to cover over unexplored sections of a map square when viewing the local map. 3. cavern maps - a 2d array of ints. values indicate walls, open space, encouter points, exits, etc. 4. plant maps - i needed a way to tell it where to draw plants, rocks, trees, etc. generating a bunch of level maps was out of the question - too big for memory. what i came up with was what i call a "pattern map". its a sparse matrix list of objects (trees, rocks, plants, etc). when drawing the scene, this pattern map is tiled across the ground. Maps are large enough that no repetition is within visible range. the game uses 4 such pattern maps - each one different - to place rocks, trees, berry bushes, etc. 4. wood grass map - another pattern map, for undergrowth in woods. 5. ground texture map - a 2d array of ints. caveman uses ground texture tile sets of 4 textures each. the ground texture map contains random values 0 through 3, indicating which tile in the set to use for texturing a ground quad. Agian, this "pattern map" is large enough so repetition is not within visible range. 6. generic pattern map - as development progressed, i found myself needing a pattern map from time to time. so i decided to create a generic one that i could write functions for that would return whatever i needed. the geneic pattern map is a 100x100 array of random ints 0 through 100. functions are then written to return values as needed. example: return the scale of a plant at x,z: map x,z to 0-99,0-99, and return some permutation of the value in the generic pattern map at that location. Uses of the generic pattern map include control of model, texture, scale, rotation, and offset of tall grass plants, and as the basis for a double interpolated height map for canyons. terrain chunks: originally, the game drew the scene by brute force, drawing the ground one quad at a time, or with a dynamic buffer, and iterating thorough the various pattern maps drawing tress and rocks etc, all the while checking for collisions with man made objects (dont draw plants inside a hut!). Scene composition simply took too long this way. So i stared at the lowest level and let that define how the code should work and how the data should be organized. basically, what directx wants is an ordered list of renderables, sorted on texture, then mesh, then near to far (for non-alpha). instead of generating the list of renderables each frame, i decided to divide the terrain into chunks 300x300 d3d units (feet) in size. a chunk consists of an unordered list of all renderables in the 300x300 area (in zdrawinfo structs), and a 3D index: a list of textures, and for each texture, a list of meshes, and for each mesh, a list of instances which are indexes into the list of renderables for the chunk. chuncks are genrated as needed and then stored in a cache with LRU discard. to draw a chunk, the index is used to traverse the list of renderables in correct drawing order. for each renderable, a frustum cull check is preformed, and if it passes, its added to the render queue. the render queue: the 3d indexed renerables list from chunks worked out so well that i redesigned the render queue in the Z game library to use a 3d index. originally it was a simple list that got sorted just before drawing. Now, as a renderable is added to the queue, its also added to the 3d index, in what is essentially a bucket sort type of thing. And that's pretty much it for the data structures. If i had to do it all over gain, i'd use more of a composition type approach, and give animals and bandmebers a location struct for example. that way i could write one piece of code to work with a location instead of one to work with bandmembers and one for animals. As i go along, i try to do this with new code i write. Note that almost everything is stored in ram. local maps use a cache and are paged to and from disk as needed. Cavern maps are generated as needed, saved when you leave a cavern, and loaded when you re-enter a cavern. Part 5: https://www.gamedev.net/blog/1730/entry-2260302-the-building-of-caveman-part-5-general-code-organization/ ## Caveman v3.0 progress report, April 20th 2014. Caveman 3.0 progress report April 20th 2014 Work on Caveman continues. Its down to high level features and polishing. Currently, the quest generator is under construction, with 14 types of quests implemented so far. Also the Beta has begun. Check it out and let me know what you think! https://sites.google.com/site/rocklandsoftware/home/cmbeta1 Please send feedback to rocklandsoftware at gmail dot com. Thanks! If you find its your kind of game, I'm still looking for more play testers. Recently done: * added chance to discover you're lost while travelling cross-country, and stop. * "view model" assigned to F4 by default * "save game" assigned to F5 by default * move slower uphill and faster downhill. speed based on slope. * cut number of rocks in rocks terrain in half * adjustable diff levels for: > hit points > caveman encounter chance > animal encounter chance the game already has adjustable healing rate. * pushes action (saves it) when interrupted by sleep, resumes action when you wake up. * number keys for select wpn * added ability to yield while in combat. * NPCs switch to "stand around" AI when combat ends. * added trader encounters * added ability to strip gear from dead bodies. * more realistic gear loadout for npc's, including small chance for artifact. * added thief encounters. * fixed: hut NPC encounters were not setting NPC's house_index for new npcs. * fixed: cliprng not set for hut doors and centerpole. * demo version * beta version * huts and caves are no longer created in canyons * cross country movement is now at walk speed. * system requirements are now displayed when unable to create d3d device due to pc not meeting minimum system requirements of 1600x900, 32bit ARGB, 24 bit depth buffer. * improved frustum culling. terrain chunks behind player are no longer culled in 3pv max zoom out looking straight down. * fixed: swamp ground texture wrong. * fixed: skills display, throwing rock atk text too wide * fixed: skills display, throwing axe atk text too wide * dead npc: the game now changes wih (weapon in hand) to hands if the player takes the npc's wih. * more trees in northern savanna * clear all terrain chunks if player doesn't take over abandoned hut (makes hut disappear) * removed "bury" from dead caveman menu * fixed: stream quads don't quite reach to bank (about 1" short) * fixed: check fire - shows fuel left * fixed: recover from illness too fast? * fixed: fruit spoils too fast? * double the rate of fatigue increase when sprinting * added double quote to caveman font * fixed: local map scrolls a little too fast * speedups: indexing huts, indexing caves, updating crh (cave, rockshelter, hut) stufflists (what they have to trade). * new all-in-one "start new game" screen * improved heightmap formulas for flowing water. reduced z fighting where size of flowing water changes at map square edges. * fixed: 1pv 1 hand stone hammer male atk ani stone not drawn in hand correctly (off by 2 inches) * added pound sign to caveman font * fixed: female vest armor too small * forrage action: now shows food stat * ability to block all the time, even when you weapon is not drawn. * sprinting and fatigue modeling for npc's and animals. * draw shield in 1pv block ani * tutorial * gamespeed 5. 1 screen per hour, does not draw the scene. therefore no need to generate terrain chunks for each screen if travelling cross country. * fixed: river action area too samll * full fatigue no longer triggers rest action. now it reduces player to walk speed. * added animal and NPC attack fatigue modeling. * gamespeed 6. one screen per hour, does not draw the scene. does not run animals or npc's. only available when no badguys are nearby. * questgen: 14 types of quests so far. time to implement the next type of quest! ## Action animations So the next thing is to make the game draw animations when a band member is performing an action such as making a spear, starting a fire, gathering wood, practicing with a flint throwing hatchet, etc. So for every action - and there are over 100 TYPES of actions - there will be an animation, and an animation object in hand, and zero or more animation objects on the ground. And some actions such as cook, make, gather, repair, etc will use different objects in hand and on the ground, depending on whats being made, gathered, repaired, etc. And the Learn action will required animations and objects in hand and on the ground for each skill in the game (about 50). so every object (about 300) will have a make or find animation along with an animation object in hand and animation objects on the ground list. every object will also have drawing information, and a fixup translation and rotations for placing it in an avatar's hand. the fixup for each object will need to be determined experimentally in the modeler. the fixup locates the object with respect to the avatar's "weapon bone". its required because the size of an object at its "grip point" and its required orientation can vary. and every action (about 100 types) will have an animation along with an animation object in hand and animation objects on the ground list - or use those for an object or skill. and every skill (about 50) will have a learn animation along with an animation object in hand and animation objects on the ground list. All the basic animations are in the game and hooked up for all actions. But actions that work with different objects (make, cook, etc), and learn, which works with different skills, all use the same animation for the moment. i hope to make maximum effect of asset reuse. but the first thing i tried was drawing reeds in hand when gathering reeds, only to discover that i need a new asset (handful of reeds) because the best existing one (bundle of reeds) simply didn't look right. I decided to do that one later . My second attempt with the makefire action fared little better, as it will require its own custom animation - or two if i decide to actually show a fire bow when they use one. so this item on the todo list is going to take a LONG time. its pretty much the last major thing left to do on the game project. beyond that i'm down to adding better graphics, more actions, skills, and objects that were thought of late in the project, more animal types (i have no modern animals or sea creatures yet), and high level things like mini-games. Other nice things like a target browser. so mostly nice features, add-ons, eye candy, and gold plating, but nothing that must absolutely ship in the first release. which means, once i get the animations done and finish play testing and polishing, it should be ready to go! finally! ## The basic game is DONE! that's right... after taking a break and evaluating skyrim, my motivation levels were back up. A final push, and as of 7pm eastern time, march 24th 2014, the basic game is done! and my original estimate of how long it would take was pretty accurate: about 2 years, working full/over time. all that's left is adding on new high end features. well, that and audio.... but the music is simple native tom-tom and flute stuff, the main theme music has already been written (for version 1.0), and the combat music is just a decent funky 4 measure drum loop remapped to a cool jungle drum kit. it would be trivial if my Alesis drum machine still worked. I plan to DL some freeware tools for that. voice acting consists of 40 samples, 20 male and 20 female, saying the 20 syllables in the caveman language. then you just play them in the correct order to say anything in the caveman language. i may just have them say random syllables. but i do have to get the infamous "bah-gah-bah" in there. In the original version, it played like a FPS when you were in combat, a settlement, or a cavern. the rest of the time it played like TheSIMs. you'd pick an action from the actions menu, and your caveperson would say "bah-gah-bah" as if saying "Ok", then go off and do the action. when they finished, they'd return to the center of the scene, and say "bah-gah-bah" again, as if saying "all done!". for the foley effects, i have the general 6000 series 50 cd sound effects library from Sound Ideas out of canada. so i'm good to go there. paid$1000 bucks for it at CGDC '96. one of the best gamedev purchases i've ever made. and about the only content i've ever paid for. well, that and pyromania 1 and 2.

and it doesn't do animations of your cave person performing an action such as picking berries, like the first version did. but it can draw a mesh or multi-mesh model in a character's hands, and it can draw every object in the game, and there;'s the built-in animation editor. so its simply a matter of making some generic animations for different actions (pick.ani, hammer.ani, etc) perhaps 1-2 dozen (watch - it'll be 50! ). then add some code to set the camera for a good animation view, set the model's animation to "hammer" or whatever, and just draw that as the action completes. right now it just draws whatever's in front of the camera, with a progress message - no animations of you doing stuff.

i've divided the remaining new features/improvements into: code, graphics, and new: actions, skills, animals, objects, etc.

remaining coding tasks have been divided into: important, less important, and "even less important". there's also an "easy" category, which i'll knock out tonight.

here's whats on the "important" list. some folks here may recognize some features they've offered suggestions about. this is a direct copy and paste from the Caveman todo list, so you can see the actual workflow document (note the time estimates on some features): * option to disable windows key - need to get online * adjustable diff levels for:healing ratehit pointscaveman encountersanimal encountersparty strength (affects number appearing) * number keys for select wpn * yield, surrender, and parlay1 DAY * add thief encounters. guy walks up, "gimme all your stuff or else!"1/4 DAY * add slaver encounters. attack to subdue. capture. model escaping, etc. - REQUIRES ADDITIONAL AI 2 DAYS * kidnappers: like thieves and bushwhackers and slavers. attack to subdue. take captive, but to ransom you back, not sell off as a slave.1 DAY - ONCE SLAVERS ARE DONE * add encounters with traders who do settlement trader's hut type trading (IE professional traders). make friendly cavemen just do "what i got on me" trading (amateur traders). * questgen1 WEEK * raiding and inter-band rivalry/conflict, and forming alliances with other bands. 3 DAYS * romance, mating, offspring.tied to relations. mate action on talk to cavemanneed very good relations + opposite sex + physical attractionneed to track who is who's mate, and who has no matemating may lead to offspring.pregnancy: food, water, sleep go down faster. fatigue goes up faster. movement rate goes down. damage or illness has chance of causing miscarriage.physical attraction: charisma, but more - phermones - genes. compatability. hmm...the 6 way street: 2way like, 2 way love, 2 way lust.3 DAYS 
the questgen is big, probably a week. mating may take more than 3 days. diff levels and hot keys, probably less than a day. yield, parlay, and
surrender, a few hours. but then you have to model escaping too. All the new encounter types can be done in 2 days. raiding might only take
2 days, maybe just one, or even less, basically its just triggering an encounter. but you do have to model who's at war with who.

wait and see how it goes.

time to get back to work.

whats next?

ah yes, give the player a chance to recognize
they're lost and stop travelling cross country.
add an is_lost variable to a bandmember struct.
set it to false when they start to travel cross
country. set it to true if they get lost.
when you check for getting lost, if they're
already lost, check for them recognizing they're
lost, and stopping.

til next time...

code once, test twice!

## Status report 6-15-2016

status report 6-15-2016

the game is really coming along. its now complete, stable, and appealing enough that i've started playing it just for fun, instead of playing store bought games i own. "resource tracking on a per resource basis" and "lack of variety in diet affecting mood" have really made gathering and preparing food more realistic, challenging, and interesting. the addition of large and small flint points and pitch has made crafting much more realistic. it amazing how small rule changes in the mechanics of a game can result in big changes in the dynamics of a game. those two small changes have raised gameplay immersion levels by amazing amounts.

highlights of new features:
* about 20 types of quest generators completed so far
* A* (A-star) path finding
* wood palisaides
* villages
* cave painings
* numerous new actions and objects

big stuff left to do:
* quest generators
* final graphics

new since the last status report on 3-17-2016:
* game tracks last 10 types of food eaten. eating the same thing too often reduces mood.
* followers and pets now moveto owner at rng 50 and stop at rng 10.
* TAMED no longer migrate as part of graze behavior
* added msg if your pet gets killed
* all damage in the game now uses hit loction. old damage variables turned off.
* crippling affects animal and NPC movement rates and attack capabilities.
* give some indication of effect upon eating a spirit plant.
* changed popup & fullscreen menus and messages to dark stone background for greater contrast with white text.
* fixed: selected_pet wasnt hooked up.
* make BMs move out of your way when you push against them. when player collides w/ bm doing nothing, they go into collision recovery.
* fixed: sleep in bedding in hut, then get stuck in walls when wake up. sleep in bedding snaps them to bedding center. bedding center is in walls. select picks spot 3-4 feet in front of BM, inside hut. beding is made 5 feet infront of BM, and thus inside the hut walls. simply create bedding at BM loc, then its guaranteed to not be inside the wall! : )
* pets should reduce chance of being suprised - should raise alarm when encounters happen. pet within 100 cuts BM chance of being suprised in half.
* option to switch to bm if they are attacked while doing an action
* companions, warriors, and pets move out of your way when you push against them.
* make b2_avian_eatkill use meat resources, not general resources.
* defend berrybush, fruit tree and waterhole quests now fail if player flees.
* fixed: rockshelter collisions not working. terrain_in_way and terrain_in_way2 now use rockshelter_in_way instead of collision map. a rockshelter is not a BBox radius type obstacle. generic_move2 and b2_bm_move didnt do collision checks when BM was inside rock shelter. so BM sometimes got stuck in collision against interior walls.
* fixed: silvatherium attacks CHR cavemen at rockshelter, and they just stand around. friendly AI was just targeting HOSTILE, not WILD.
* new_set_tgt must consider all potential threats when selecting targets, or fight or flght won't work. so friendly AI must tgt WILD and hostile for
example.
+ wild should target: all but their own kind.
+ goodguys should target: hostile and wild
+ hostiles should tgt all but hostiles.
+ nobody targets captured or subdued
WARROIR, COMPANION, and TAMED now use set_friendly_tgt (all wilds/hostiles) set_wild_tgt and set_hostile_tgt are already correct. set_friendly_tgt was fixed yesterday.
* fixed: forgot to add "staunch wounds" to the "other actions" menu.
* fixed: dropall and a number of similar routines (give_all, storeall, etc) didnt check for active object. all were code used by routines that call
shift_select. checked all calls to shift_select, to make sure all such routines were fixed. this was the cause of nuts appearing in storage pits!
* defend quests: takes too long for badguys to show up. i'm defending a rockshelter. gotten a dozen animals encounters (its a busy place!), but no badguys. been there almost a day. increased raid chance from 1 in 100K per sec to 1 in 10K per sec. avg of 2.77 hrs, vs 27.777 hrs between encounters.
* fixed: boost stats doesnt un-cripple limbs
* cut encounter ranges for dense terrain types (woods, grass, jungle, rocks)
* volcano collision rad is off - increased to 55. volcanos can span more than 1 collision map. so portion in adjacent map doesnt get set to impassable. will need different collsion check for volcanos. removed volcanos from collision maps. now uses true 2d rad of 70 ft.
* not many volcanoes in the world? increased chance 10x
* fixed: quest_animals_removed doesnt work with multiple simultaneous defloc encounters.
+ add is_quest_animal, quest_BM, and questnum to animalrec.
+ set is_quest_animal etc when spawn quest animals.
+ add animals_removed to questrec.
+ make remove_animals set cm[quest_BM].quest[questnum].animals_removed if it removes a quest animal.
* new: need non-defloc aggressive quest AI. if quest animal and not defloc, runs new quest AI.
new quest gens:
defend rock shelter
defend hut
defend berry bush
defend fruit tree
defend waterhole
moveto
transport
get special item
volcano quest
* attack cave rockshelter and hut quests done
* new fuction: dist3. bbdist in ft. works up to 75K map sq range! (375,000 miles!)
* fixed: crh encounters now spawn outside the crh
* replace quest_animal_alive (any defloc alive) w/ quest_animal_alive2 (any quest animal for cm1 quest q alive)
* replace quest_animal_removed with cm[a].quest.animals_removed
* done: all quest gens: must trap out player simply fleeing and quest animals deactivating.
* checked volcano quest. double spawn is fixed.
* kill animals for reward - places animals at a map sq too far from questor, should be 1-2 sq radius. same for kill cavemen for reward. made a version of randommapsquare that takes a radius.
* MOVETO_QUEST (find treasure) need to change view_quest message when quest begins. general loc is now known. no longer random chance to find treasure, now must look for it.
* refactor: getter and setter functions for animal, caveman, and worldobj locations. make them call generic location getter and setter fucntions.
* success, fail, and encounter wavs for quest messages.
* fixed: friendlies talking to you: if they ask you to talk and you say yes, and you do a talk action, they greet you again after the talk action. didn't set flag to "npc done talking to player" when called the talk action. so after the talk action, it went back to NPC talks to player again.
* increase clip rad of gt moa
* fixed: cant eat w/ 1 crippled arm. EAT was not set to 1 hand action. made a couple other actions 1 hand (like staunch wounds).
* crh hostiles get stuck in / spawn in rocks. uses something_in_way_of_animal for placement. 5 calls to terrain_in_way with +1 on rad - uses collision maps for rocks. uses terrain_in_way2 for movement. one call. uses collision maps for rocks. the +1 rad fix might take care of it. have to wait and see.
* make sure new items like teepees and bedrolls are on treasure tables.
* grunt sfx for npc talk to player dialog messages.
* success and fail wavs for talk to caveman menu
* to do an action, anvil stones can now be nearby or in your inventory.
* only one BM at a time can use a dropped anvil stone to do an action.
* picking up an anvil stone in use stops the user's action.
* tried lessons and advisor
* improved character creation
* improved tutorial
* set bleeding, crippled, etc to false when bring them back to life.
* anvilstone nearby fixed
* butcher time and butcher quality fixed.
* improved getstring
* improved fullscreen menu
* new: stone buttons
* make sure all calls to getstring say "Enter ..."
* add success and fail wavs to run_tutor
* checked: resource depletion by other bands works with the new resource levels by type
* fixed: BM_bestwpn and npc_bestwpn now take crippling vs 1 and 2 handed wpns into account.
* fixed: if missile tries to hit animal, animal sets all nearby friendly animals to "taking fire". even if animal is killed in a single shot, the rest have been alerted.
* fixed: terrain_in_way and terrain_in_way2 sometimes returned CM terrian type, not 1. made someting_in_way_of_animal not work. thats why animals were spawning in rocks.
* put trace on pet wolf AI
* added collsion map check w/ radius to something in way of animals. rocks are still an issue.
* fixed: run_pack_ai didnt check if animal was wild. only wild animals run pack ai. bug made tamed run pack ai sometimes.
* collsion avoidance doesn't look as far ahead, doesn't move as far.
* collision recovery ends sooner
* bandmembers, companions, warriors, and tamed now follow you in and out of caves and caverns, either as owner, or via follow orders.
* fixed: friendly leaders collision avoid cm0 while approaching cm0 to greet.
* fixed: 3pv cam vs NPC huts. adjusted check for crh huts to match that for player huts. added check for crh huts to 1pv vs 3pv code. wrote new routine to check abandoned huts. made it match the code for player huts. added that to 1pv vs 3pv code.
* fixed: 3pv: draw player in hut if doing action. if they are doing an action, it does not check for "don't draw in hut".
* fixed: 1pv skin tex not set when follower joins band
* fixed: 1pv skin tex not set for playtest game
* fixed: reduce radius for fire light and sound.
* fixed: no grass area around tarpit is too big? tarpit too small? its that darn 10 rez on the ground mesh. cant model small curves well. make tarpits bigger. increased rad of tarpit from 15 to 30.
* fix: lakes should be bigger. be sure to resize both graphics AND collision checks! increased rad from 30 to 100.
* implemented A*. still ned to test it, then hook it up to the game.
* spiced veggies: findtime and findchance were not set. was using defaults (1 hour and 1% chance of success). removed spiced veggies from the init lookup functions and into the regular init code.
* learn hafting: now requires flint knife, not cutting tool as part.
* change stoneworking to knapping. require flint, knapping tool, and one hand hammer to learn.
* changed time to make wood arrow from 8 hrs to 30 min.
* add large & small flint point objects. large to make knifes and spears, small to make everything else. 300 stoneworking to make small, 500 to make large. need small to learn hafting. draw lg point as flint knife w/o handle. draw small point as 1/3 size lg point.
* make cutting tool no longer requires knapping skill. make cutting tool now increases knapping skill.
* got 2d map A* working. long setup time. high ram requirements. fast.
* got traditional 2 list A* working. zero setup time. low ram requirements. fast. not fully optimized yet.
* fixed AI vs campfires. flee from campfire has its own vars now. wild animals don't target entities near fires.
* added fight or flight to predator respond to missile fire.
* collision map system now supports collision maps at arbitrary scales. no public API change required! just get_CM_index API used by A*.
* got A* fully working in the game.
* collision checks use high rez collision maps once again.
* added +0.5 x and z offsets for collsion map checks for "pixel perfect" accuracy (rasterization rules).
* "make small flint point" action now repeats as long as you have parts.
* social is zero, but not nuking mood. changed mood reduction from 23 in 10000 chance of 1 every 15 minutes to 1 every 15 minutes.
* make cordage: says no anvil stone on or nearby, when there is. there are 2 stones, one already in use. but use of second stone was stopped by combat. it still may be flagged as in use. added stop_usng_anvilstone if new action==DONOTHING to setaction.
* removed from game: (not realistic)
stone arrow
stone spear
stone javelin
stone atlatl dart
stone fish spear
throwhatchet.
flint throw rock
* add 1 wood required for flint knife. knife gets wood handle. need model.
already added leather handle requierd. added cordgae, hafting, etc. made new model.
draw 1pv wih doen't use new model yet.
* cook foods: ask how many to make? just make all? make up to 5 at a time? already makes as many as you have parts for. how many would require modding each try_cook(somefood) call.
* pet: check health: left arm hp/dmg: need space after "l arm".
* as friendly leaders migrate and get removed, each new leader come up to player and greets them. should set all nearby friendlies to will_talk=0 when set leader to will_talk=0. now sets all freindlies within 500 feet of player to done talking when leader is done.
* quit to desktop from ingame menu
* fight or flight: should do flight for some period of time, not just until reach edge of fight or flight check range.
* CRH npc asks to trade: should do band trade, not individual trade.
* add band dialog action: ask ally to join village (move next door). checked and done!
* if CRH band is ally and shelter is within 500 of player's shelter, divide migration rate by 10 when changing the map. checked and done!
* villages - ally invite to join - add build hut quest. checked and done!
* allies should not ask you to join village if they have already asked you and you accepted but have not buiilt a hut there yet. checked and done!
* allies should not ask you to join village if you already have a hut near them. checked and done!
* added log object checked and done!
* heavy objects are exempt from container rules checked and done!
* heavy objects need only be nearby to use them checked and done!
* mark and unmark nearby objects as in use checked and done!
* added gather logs action checked and done!
* added wood wall object checked and done!
* added make wood wall action checked and done!
* inspect wood wall action checked and done!
* repair wood wall action checked and done!
* demolish wood wall action checked and done!
* select dead BM, take stuff. checked and done!
* add ability (IE action) to check resoureces in the area, see how low they are. . checked and done!
* new: fish with fishnet action. new object: fishnet. - already done : )
* new: add fishing actions to shoreline/ocean terrain . checked and done!
* new action: play with water. all water terrains. . checked and done!
* watch sunrise action . checked and done!
* watch sunset action . checked and done!
* new action: watch snow fall, like watch clouds.
* chat w/ bm action . checked and done!
* chat w/ npc action. . checked and done!
* catch rain in mouth (drink)
* catch snow in mouth (drink)
* select snow on the ground
* eat snow on ground for water. water goes up, but food goes down a little.
* melt snow with fire to make water
* shoreline: swim in ocean action . checked and done!
* select cave interior wall. checked and done!
* make cave painting. checked and done!
* new: obsidian resource. better than flint.- fisrt and easiest thing you can do is make it so you can find flint (obsidian) at volcanoes. then you can add the obsidian object (like the flint object), and the small obsidian point, and large obsidian point (takes less time, lower chance of success, higher value than flint). and then add obsidian weapons and tools. or just use obsidian to make higher quality flint tools. add obsidian object, only gather ta volcano. add small and large obsidian points. when make stuff with points, give option to use flint or obsidian, if obsidian, increase quality of weapon. or just add obsidian object, and give choice of obsidian or flint when making the point, and it increses the quality of the point, which will ultimately increase the quality of the tool or weapon. thats the easiest way to do it. so add obsidian object which can be gathered near volcanos (say within 300 feet). when make points, give optin to use flint or obsidian. if obsidian, increase quality greatly, or simply have obsidian always be 150 or 200 quality or something. coyuuld just have it display the name obsidian if the quality is high, and obsidian is just a high quality type of flint. that would be even easier. so add "gather obsidian (high quality flint)" to the volacano menu. takes a long time? yields high quality flint. requires one hand hammer stone?. checked and done!
* new object: pitch. a glue used for hafting etc. can use tar or tree (pine) pitch. to harvest pitch, wound the tree, then wait a few days. hmm - how to model that? woods - cut trees for pitch. woods gather pitch. must cut trees for pitch first. marks trees as cut - with a timestamp. when harvest, only
proceed if timestamp is old enough. clear timestamp when they harvest. make pitch use wood resources. make all objects require pitch for crafting. can't use tar yet, just pitch. checked and done!
* add to game: S_MEATVEGGIESTEW. already in there: S_STEW. object #31.
* new object: sundial compass stick. stick it in the ground pointing at the sun, and wait 15 minutes. the shadow points roughly east.
* find sundial compass stick action
* use sundial compass stick action
* researched deadfall traps, fishtraps, and tanning
* changed requirements for making tanned hide.
tanned furs:
1. scrape inside w/ scraper
2. mix brains and water, coat inside(?). soak & stretch to soften. - smoking can hasten process somewhat?
3. smoke to make insect repellent (optional)
tanned leather:
1. remove fur - scrape
2. scrape interior
3. soak in brains and water and stretch to soften - smoking can hasten process somewhat?
3. smoke to make easer to re-soften after getting wet. (optional)
so they are both basically the same, one you scrape off the fur, the other you don't.
so a tanned hide can be with or without fur.
and it requires brains, water, a clay pot, a scraper.
and all items should be made from tanned hides, not hides.
need to add brains object.... ugh could assume they take the brains with the hide... and the weight and value represents the hide and brains as a "package deal". until they make a tanned hide. then the brains are there, ready and waiting. except for buffalo, whose brains are too small to tan their own hide. no need to track eacj part of a butchered critter, just one per type of use. so for tanning you need hides and brains - in equal numbers, and you get hides and brains in equal numbers. so unless you get into trading them, you can just track one, and assume you always have the other to go with it - the "package deal" concept. so a hide is really more like "tanned hide parts".
* all objects now require tanned hide for crafting, not hide.
* removed tanned hide armors. all hide armors are now tanned.
* removed stone and shell armors - unrealistic.
* add funnel fishtrap object - inventory item
* add make funnel fishtrap action
* add set funnel fishtrap action. requires bait and stream, river, or lake. sets timestamp.
* add check funnel fishtrap action. check timestamp, add fish and remove bait
based on elapsed time.
* wood stake fishtrap object
* draw_dropped_obj draws wood stake fishtrap at water level
* make wood stake fishtrap action
* inspect wood stake fishtrap action
* repair wood stake fishtrap action
* abandon wood stake fishtrap action
* bait wood stake fishtrap action
* check wood stake fishtrap for fish action
* maps as treasure on dead hostiles. adds info to player's world map.
* musical bow object
* make musical bow action
* play musical bow action
* added stufflist_wt_carried_in_containers() routine
* added stufflist_container_capacity() routine
* added stufflist_needs_more_waterskins() routine
* added stufflist_can_carry() routine
* added encumberance checks to transfer_items
* added container checks to transfer_items
* added waterskin checks to transfer_items
* added transfer_items to storepit menu
* added transfer_items to travois menu
* added transfer_items to bandmember menu
* added transfer_items to exchange items with companion menu
* added avoid_cliffs() to B2_avian_common_part1 AI. if below and just south of cliffs, flies south and climbs.
* defend friendly questgen:
player hears of friendly w/ quest. player goes to friendly. freindly aks for help killing badguys threatening them. player hangs out, badguys attack. if friendly survives and all badguys dead, player gets reqqrd and end of quest. if frieindly dies, no reward and end of quest. if badguys get away, trigger another badguy attack after a while.
* random_active_npc now handles "all known npcs already active in sim".
* new_npc now returns -1 on error.
* all calls to new_npc now handle -1 errors.
* all calls to set_npc now check for npc_in_sim first
* fixed: add_gift_giver now checks for npc_in_sim already. was just adding the first npc found. used by both gifts and call for aid. get both at once and it tries to add the same npc twice - and BOOM! animation controller collision!
* turned off title screen
* allies ask you to join village: menu() is off by 1.
* fixed: allies give gifts too often?
* fixed: allies ask for help too often ?
* fixed: allies ask you to join village: menu() does yes when you click no and vica versa.
* decreased time for find wild veggies
* increased food boost of wild veggies
* fixed: gather pitch was missing from savanna and jungle menus.
* sleep goes down 10% slower on average.
* reduced frequency of ally gift encounters
* reduced frequency of ally call for aid encounters
* fixed: search dead BM: shows player's inventory, not dead BM's. says "give 10" and "give all", not "get 10" and "get all"
* exit cave: place them a little farther from the entrance.
* can't select cave interior to paint cave painiting!
* collision rad for cave interiors is a little too big.
* don't let them select the sky when inside a cave.
* adjutsed time and chance to find flint.
* fixed: gather pitch: shows fail msg after showing success msg.
* fixed: dont let them start gathering pitch if another BM in the map sq is already gathering pitch. action stops if another BM gathers the pitch first.

## Work on skinned meshes continues

Work on skinned meshes continues

I added the ability to draw weapon-in-hand to the skinned mesh test routine. It can toggle between weapon types, and uses the game's built-in matrix editor to position the weapon with respect to the hand bone. The test routine is used to determine the fixup transform for a weapon, which is then added to the database info for that weapon type.

It now draws all 65 or so different types of weapons in a skinned mesh female's hand.

A fixup transform for male meshes is next. Male and female meshes share almost identical skeletons, so just a single fixup for male vs female skinned mesh is required to make all the weapons draw in a male skinned mesh hand as well - IE move everything down and right a bit to account for the difference in the male and female hand meshes. These fixup transforms are roughly the equivalent of positioning a weapon bone for each skinned mesh in the modeling software, and transforming all weapon models in the modeling software so their grip point is at the origin, then drawing the weapon at the weapon bone with no transform. Unlike your typical shooter, not every weapon in Caveman has a uniform type and size of grip, such as a pistol grip or sword handle. so tweaking on a per weapon basis is really required to get the best possible fit.

Then comes the remaining attack animations. One hand attack is already done. spear thrust, bow attack, and a few others still need to be made. It looks like I can even share animations between male and female skeletons. It also looks like I need to clean up the skin weights a bit on the male meshes - the upper arm influences the ribs area. I thought it was from using the female attack animation, but its just a weight tweak issue, not an animation sharing issue.

I'll need to make a version of the skinned mesh textures for use with the existing 1st person attack animations - a simple copy/paste type operation in paint.net or gimp.

I also need to make some improvements to the startup resolution autodetect code. Right now its selects the resolution with the highest horizontal value that supports A8R8G8B8, and assumes 24bit depth buffer support is available at that resolution - which may not be a safe assumption in rare cases. I've only had two people report such issues.

And then its time to release beta 21. Beta 20 has already expired, so at the moment there is no beta available for download. Beta 21 should be ready in a couple of weeks. In order to get beta 21 out sooner, it will not draw armor or equipment, and won't have action animations. those will all be included in beta 22, which will probably take 2-3 weeks from the time beta 21 is released.

And then comes skinned mesh animals....

i'd better get back to work!

## Progress report - it finally draws everything in the game!

Progress report - it finally draws everything in the game!

After a long struggle with character weapons and equipment, Caveman now draws everything in the game. Some of the stuff still needs work, but at least it draws something.

I need to get caught up on posting screenshots.

making the cloud particle system use world coordinates as opposed to camera relative coordinates is next. Clouds are alpha blended. so they're sorted on range to camera. the world is divided up into chunks or "map squares" of 26400x26400 d3d units (feet), IE 5x5 miles. each map square has its own d3d coordinate system. when the player changes map squares, the world origin changes, so the camera's coordinates change to compensate. this sudden change of camera x or z by 26400 units changes the sort order of the clouds slightly (IE the difference between x,z locations 5000,0 and 5000,26399 for example). so the clouds "jump" slightly when you change map squares. the fix is to use world coordinates, IE map square x,z plus d3d x,y,z in the map square. when the player leaves a cloud far behind, its regenerated on the leading face of the could cube area that surrounds the camera.

the general idea of the cloud particle system is you have a cube shaped area that surrounds the camera (a "cloud box") that's full of cloud particles. info from the weather engine is used to move the particles, and to determine the number active. when a particle moves out of the "cloud box", a new position is randomly generated for it on the opposite face of the cloud box from the face it exited through. the cloud box moves with the camera. when the cloud box moves so a cloud exits the box, again, the new position for the cloud is randomly generated on the opposite face. by "on the opposite face, i mean in that direction and at that range from the camera - IE somewhere on that face of the cloud box.

right now the could system doesn't use world coordinates, and its not hooked up to the weather engine. it just draws 100% cloud cover and stationary clouds (IE cloudcover 1.0f, windspeed 0.0f, winddir 0.0f weather settings) for testing the alpha blend effect. but the api's already exist to hook the two together.

## World coordinate system based cloud particle system done

World coordinate system based cloud particle system done

well that didn't take long!

Caveman uses the following world coordinate system:

The game world map is divided up into 5x5 mile map squares. Each map square has its own d3d coordinate system. So a location in the world is speccified by map x and z, AND by a d3d x,y,z in that map square: IE mx,mz,x,y,z.

all i had to do was add an mx,mz to a cloud struct.

init them to the players mx,mz in init_cloud2

made draw_cloud3 use them instead of the player's mx,mz to calculate camera relative coordinates.

added a wrap_around_cloud function to wrap a cloud around to the other side of the cloud box when it moves outside the cloud box, or the cloud box moves beyond it.

added a movecloud function to move a cloud based on windspeed and direction from the weather engine

made sort_clouds (for alpha blending) use world cloud coordinates converted to camera relative coordinates for sorting

added a remove_last_cloud function to remove the last active cloud from the array of cloud structs. The array of cloud structs is statically allocated, as the max number of particles (currently 400) is known at compile time. each cloud struct has an "active" boolean (implemented as int, 0=false, 1=true). when a cloud is added, its "active" variable is set to 1. when its removed, its "active" variable is set to 0. only active clouds are rendered and updated.

added an update _clouds function that adds or removes clouds based on changes in cloud cover info provided by the weather engine, and then calls update_cloud for each active cloud.

added a wrap_around_clouds function that calls wrap _around_cloud on each active cloud. the "cloud box" is the area around the camera that active clouds are in. the cloud box is currently set to a bounding box radius of 2000 units around the camera, and altitudes from 500 to 700 units. since the cloud box is based on the camera's location, the camera must be set before making clouds outside the cloud box wrap around. this tripped me up for a moment. i was handling wrap around once after player/camera/cloud box movement and cloud movement had both been done. but when you changed map squares, it seemed to draw the clouds at their old position (IE 5 miles away) for one frame. doing wrap around after cloud box movement and after cloud movement didn't fix things. the reason is because the player had moved to the next map square, but render hadn't been called, yet, so the camera hadn't been moved to the next map square yet! the solution was to call wrap around once on all clouds just before drawing, at which point the camera has already been set to the new map square.

so now the clouds come and go as you move, and come and go with the winds, and don't change drawing order when you change map squares, and increase and decrease in number with changes in cloud cover. now i need to add grey and red cloud textures and make it use them when appropriate. The original version supported blue, grey, and red skies, and white, grey, and red clouds. Right now the new version only supports blue skies and white clouds.

I think a lot of why it was so quick and easy had to do with the following:

1. CScript. all the new code was done in CScript which allowed the quick coding of the simple routines required.

2. Existing functions in the game. things like normalize_location and camera_relative_coords. being able to copy paste edit x+=spd*cos(yr) etc from generic_move to update_cloud. i can never remember if its x+=sin or x+=cos. wait. just thought about it for a sec, its x+=sin(yr). but usually i'm lazy and just find the formula somewhere in the code like generic_move (moves the player any of 4 directions), move_animal (moves a non-player entity), or move_missile (moves a projectile), and copy and edit it - less typing!

3. the fact that i've been writing particle systems for games for 25 years now. yeah - i know, no fair!

CScript really is nice, i should have been using it all along. i can code new stuff and mod old stuff in a flash. and it only adds 2 seconds to the build time for 71,000+ lines of source code, and that includes the time to minimize visual studio 2012, launch CScript, click to quit when it finishes translating, maximize VS 2012 again, and hit F7 to build. I had it setup as a pre-build step, but since you edit the CScript .cs input file and not the .cpp output file generated by CScipt, VS 2012 thinks the build is up to date since the .cpp file hasn't changed (yet). this means you have to do a rebuild to trigger the CScript pre-build action, or make a change to the current .cpp file. so i went back to a shortcut on the desktop to launch CScript. i also tried it as a tool button, but you can't make it project specific to pass project specific source file names. There's probably some way to do it, but the desktop shortcut with the file name as a parameter works fine.

## New Avian AI done + yet more raycaster / raypickcode!

New Avian AI done

The new Avian AI has been implemented.

There are just a few remaining tasks to complete, and then the AI will be refactored, with the new orders features added.

first off, i still have to hook up the avian ai:

the current code:
you can see how avians were originally implemented as a bunch of special cases throughout the animal AI code.
you can also see where the old land animal AI has been turned off, and the new land animal AI gets called instead.
All three versions of the AI are still in the code: the original AI, the setstate/runstate refactored AI, and the new AI.
Most of the old AI code is turned off via comment blocks. function level linking takes care of the rest.

 void move_animals(){int a,t;if (turns_per_render > 128) return;if (last_active_animal < 0) return;for (a=0; a <= last_active_animal; a++) { if (!animal[a].active) continue; if (!animal[a].alive) continue; t=animal[a].type; if (animaltype[t].avian) { if (animal[a].suprised) { move_suprised_avian(a); continue; } else if (animaltype[t].AI==ATTACK_AI) avian_predator_setstate(a); else setstate(a); runstate(a); } else { if (animal[a].suprised) continue; // setstate(a); // runstate(a); B2_run_animal_AI(a); } }} 

the new code will look more like:

 void move_animals(){int a,t;if (turns_per_render > 128) return;if (last_active_animal < 0) return;for (a=0; a <= last_active_animal; a++) { if (!animal[a].active) continue; if (!animal[a].alive) continue; t=animal[a].type; if (animaltype[t].avian) B2_run_avian_AI(a); else { if (animal[a].suprised) continue; B2_run_animal_AI(a); } }} 

I also need to add fatigue modeling to the animal and avian movement code in the new AI.
Here's a snippet of code from the old AI that does fatigue modeling and sets the movement amount all at once.
This will be adapted to create a routine that increases fatigue based on the animal's current movement rate.
This "increase_fatigue" routine will then be called by the land animal and avian move routines.

 if (animal[a].fatigue>=100000) { animal[a].fatigue-=7; return; }t=animal[a].type;spd=animal_speed(a);if (running) { if (animal[a].fatigue<100000) { spd*=4.0f; animal[a].fatigue+=64; if (animal[a].fatigue>100000) animal[a].fatigue=100000; } else { spd *= 2.0f; animal[a].fatigue+=4; if (animal[a].fatigue>100000) animal[a].fatigue=100000; } }else { animal[a].fatigue+=2; if (animal[a].fatigue>100000) animal[a].fatigue=100000; } 

i also need to add modeling of sneak detection for hired NPC warriors and NPC travelling companions. while they are NPCs,
they are friendly with the player, and the player can give them combat orders. One of the orders they can be given is to
use sneak mode. So i need to make a version of the sneak detection code that works with animals. Cavemen are just another
animal type (species), type 2 to be specific: homo sapien. Hippidion is type 0, smilodon is type 1. pterasaur is type 3,
in anticipation of the bring on the dinos option. Yes, you can punch up a pterasaur encounter and tkae them on with a
spear and throwing rocks! . But for now, they can only be triggered from the playtest menu, and are not in the game's
encounter tables.

The current code only works for bandmembers. its that same old design question we all face when starting a game project: should
i make the player part of the entity list or keep them separate? keeping them in the list means possible code reuse (a good thing).
but usually you need much more data about the player then other entities. that leads to designs where some data is in the entity
list, and the rest is elsewhere. somewhat more complex (a bad thing). a lot depends on whether you can get code savings.
A C-E apprach for components shared by both player and non-player entities seesm like a good idea, but can also be a bit
more complex than a brute force implementation. In my Airships simulator, i model the players ship in great detail, then copy
the pertinant results to entity #0 which is predfeined to be the player's ship. This gives me a simple player airship data
structure, but can still use generic entity code for things like movement, collisions, drawing, etc.

In Caveman, there's isnt a single PC like in most single player games. The human player can control up to 10 PCs. So Caveman
has two entity lists: one for PCs, and one for eveything else. The data for a PC is much more than that for an animal
(everything else). so they are two different types of data strutres stored in two separate lists. Right now, the sneak code work
with a cavemanrec, but not with an animalrec. note that this code is actually in CScript, a c++ macro processor/code generator
i wrote and use in-house. You can freely mix c++ and Cscript code. the first line of BMmodel_sneak_detection() reads:
function void BMmodel_sneak_detection int a
the . at the end is a close squiggly.
This code includes raypick /raycasting style line-of-sight testing.
Note that Caveman differentiates between detected by friendly and detected by hostile. That way you're not detected just becasue
your horse can see you (Oblivion!).

 int detection_range(int a) // returns dist at which player a can be seen{int x,z;x=cm[a].mx;z=cm[a].mz;switch(map[x][z].coverage) { case WOODS: case GRASS: case JUNGLE: return(50); }return(300);} // returns 1 if there's a clear line-of-sight from location L to loction L2int clear_LOS(location *L,location *L2){float dx,dy,dz, // displacement & normalized direction vector from p1 to p2 x,y,z, // the point we raycast from p1 to p2 mag; // magnitude of displacement vector from p1 to p2 int mx,mz, // mx,mz of the point we raycast from p1 to p2 a; // loop counter. the number of steps iterated so far in the raycast.location L3; // location of our raycast point for call to terrain_in_way()x = L2->x + (L2->mx - L->mx) * 26400.0f; // convert x,z of p2 to p1 mx,mz relative coordsz = L2->z + (L2->mz - L->mz) * 26400.0f; dx = x - L->x; // calc displacement vector dx,dy,dz between the 2 pointsdy = L2->y - L->y;dz = z - L->z;mag=sqrt(dx*dx+dz*dz); // calc magnitude of the displacement vectormag=sqrt(mag*mag+dy*dy);dx/=mag; // divide displacment vector by mag to get normalized direction vectordy/=mag;dz/=mag;mx=L->mx; // start at 1st pointmz=L->mz;x=L->x; y=L->y;z=L->z;for (a=0; a < (int)mag; a++) // dir vec mag = 1. # steps = mag of displacement vec. { x+=dx; // move the point y+=dy; z+=dz; if (x>26400.0f) // handle map sq edges { x-=26400.0f; mx++; } if (x<0.0f) { x+=26400.0f; mx--; } if (z>26400.0f) { z-=26400.0f; mz++; } if (z<0.0f) { z+=26400.0f; mz--; } L3.mx=mx; // check for terrain collision L3.mz=mz; L3.x=x; L3.y=y; L3.z=z; if (terrain_in_way(&L3)) return(0); if (heightmap(mx,mz,x,z) >= y) return(0); // check for ground collision }return(1); // no collisions, have clear LOS, return 1.} // returns: 0=not detected. 1=detected by some animal. 2=detected by wild or hostile targeting the playerint detection_state(int a) // a is band member #{int b, // animal # dr, // detection rng of bandmember a rh, // rel heading, animal to band member rng, // range from band member to animal result, // return value targeting_player; // booleanfloat x,z;location L,L2;dr=detection_range(a);result=0;for (b=0; b.active) continue; if (! animal.alive) continue; if (animal.location != cm[cm0].location) continue; if (abs(cm[a].mx-animal.mx) > 1) continue; // more than 1 map sq away in x direction if (abs(cm[a].mz-animal.mz) > 1) continue; // more than 1 map sq away in z direction if ( ((animal.state==WILD) || (animal.state==HOSTILE)) && (animal.tgt_is_caveman==1) && (animal.tgt==a)) targeting_player=1; else targeting_player=0; if ( (result==0) || ((result==1) && (targeting_player)) ) { x=cm[a].x+(cm[a].mx-animal.mx)*26400.0f; // calc band member x,z rel to animal's map sq z=cm[a].z+(cm[a].mz-animal.mz)*26400.0f; // calc band member x,z rel to animal's map sq rng=rng2D((int)animal.x,(int)animal.z,(int)x,(int)z); if (rng > animal_cliprng-20) continue; if (rng > dr) continue; rh=relheading((int)animal.x,(int)animal.z,(int)rad2deg(animal.yr),(int)x,(int)z); // normalized, ok. if (abs(rh) > 90) continue; L.mx=animal.mx; L.mz=animal.mz; L.x=animal.x; L.y=animal.y; L.z=animal.z; L2.mx=cm[a].mx; L2.mz=cm[a].mz; L2.x=cm[a].x; L2.y=cm[a].y; L2.z=cm[a].z; if (! clear_LOS(&L,&L2) ) continue; } else continue; switch(result) { case 0: if (targeting_player) return(2); else result=1; break; case 1: return(2); } }return(result);} // returns 1 if band member a is targeted by a hostile caveman or wild animalint bandmember_targeted(int a){int b;for (b=0; b.active) continue; if (! animal.alive) continue; if ((animal.state != HOSTILE) && (animal.state != WILD)) continue; if (! animal.tgt_is_caveman) continue; if (animal.tgt != a) continue; return(1); }return(0);} fn v BMmodel_sneak_detection i aif (a % 15 != frame) return;if (cm[a].sneak_state==0) return;if (cm[a].sneak_state==3) { if (! bandmember_targeted(a)) cm[a].sneak_state=1; }else // states 1 & 2 { switch (detection_state(a)) { case 0: cm[a].sneak_state=1; // sneaking - undetected break; case 1: cm[a].sneak_state=2; // sneaking - detected - non-hostile break; case 2: cm[a].sneak_state=3; // sneaking - detected - hostile break; } }. 

another thing left to do is to init the "taking fire" variables for animals when they get hit by a missile.
again, there's only code for bandmembers at the moment. More CScript. this function just sets three variables.
It gets called when a bandmember gets hit by a missile. I need to make a version for animals. IE: replace cm[] with
animal[], then call it from the code that checks missile collisions with animals.

 fn v set_BM_taking_fire i cm1= cm[cm1].taking_fire 1= cm[cm1].taking_fire_counter 0= cm[cm1].taking_fire_dir (float)(dice(628)/100.0f). `

another thing to do is make an avian version of do_orders, where the new AI follows the player's orders. This
is basically a copy / paste /edit of B2_do_orders to create B2_avian_do_orders. calls to B2_avian_setpitch get
added after calls to turn the animal, and avian versions of attack and move are used.

the last thing left is to add animal[a].diving to the savegame file format. Its used by avian predators to track
their attack state (diving on tgt, or climbing for next pass). the variable has already been added to the
animalrec struct declaration and is used by the code. but the vsae and load code writes individual fields, not
entire structs. so the old savegames will still load, with animal[a].diving taking a default value of zero (false)
as desired. So all i have to do is add one line of code to save the variable, then run the game to convert the
existing savegames to the new format by simply loading and saving each one (there's only one - a long term
playtest game). Then i add one line of code to read the new variable, and i'm done. file format updated, and
savegames converted. If i wanted backward compatability with savegames i didn't convert, i add an extra line of
code to save a junk value before the new data. when i read, i try to tread the junk value. if i get an EOF, its
an old format, and any variables normally read after that point will not be read and simpy keep their default
initial values. if i don't get an eof, there's more data, so i keep reading until the next "EOF test" or i've
read everything. Since changes to the file format are appended at the end of the file, you can read in something
many versions old and get the original data plus defualt values for newver variables. So the basic idea is you
init everything to default values, then read in the savegame values over them. whatever you don't read in,
uses the default values. when you save, you write everyting.

## The Building of Caveman - Part 1

The Building of Caveman, Part 1

in this series of posts i will explain the process of making the game
Caveman v3.0.

What was done and why.

this is done in hopes that it may help others in their quest for success.

first, who i am:

i'm life long gamer.

as a little kid (before computers!), wargames facinated me.
that big hex map with all that terrain, and all those unit counters! and the
dice and the charts! WAY too cool! there was something seriously cool going on
here!

then there were arcade games like "night bomber", a very rudimentary
b-58 hustler flight sim arcade machine. it had a backlit plastic 3d
conveyor belt of plastic for the ground mesh, and used some sort of illuminated
platic for the missiles in flight. then it was mirror projected to the view
screen of the cabinet. explosions were backlit under the "terrain mesh".
i can still remember the "shoo,shoo,shoo - booom, boom, BOOM!" sound effect
it made when you cut loose with a salvo of missiles. . i was so little i
had to stand on a stool to play!

later came D&D, then Traveller, then both at once! Two years as president of
the wargame club in high school. I also designed few table top games during
this period. There was a super RISK type wargame with land, sea, air and
carrier units, land, sea, and air bases, and land sea, and air zones for
movement. There was a sharship combat game, turn based strategy with carriers,
battle crusers, fighters, and such. and there was a simple futuristic RPG
inspired by the first star wars movie, set in a huge abandoned space station,
the rules of which were made upduring one of those rpg club convetions a
friend took me to once. Everyone always wanted to play in my D&D world, i was
almost always the DM, seldom got to be a player, but i learned as a player
from a great dm (thanks John Durfee!). i learned one of my first and best
game design lessons there: NO MONTY HAUL!

About the same time, i took my first
programming class (sophmore in high school i think it was). interperted
basic on an ibm 360 mainframe accessed remotely via 3 dumb tremials and a
teletype terminal, each running at 1200 bits per second. . I wrote a
turn-based clone of the arcade game "lunar lander" on that system. you'd
input your x and y thrusts, and then it would draw the next frame .
You should have seen how many trees i killed when i ran it one time on the
teletype terminal. to clear the screen and draw the next frame, it did a page
feed. so every frame printed an entire page on an 18" wide line printer
teletype terminal. the classroom was awash with printer paper! .

after high school, i used my buddy's mom's pc to write a text and vector
graphics turn based D&D game. it was a sperry rand pc with 64k, 2 360k
floppies and a CGA card. interperted basic on dos 2.11.

a couple years later i got my first pc, an 8khz 8088 overclocked to
10khz. word was, for second year physics lab, even if your experiment was
unsucessful, if you could write it up correctly with all the charts and
graphs etc in a word processor, "real professional like", you got an A.
so that was my justificsation for getting a pc. now adays its almost
de-regeur, i'd assume. at first i wrote a few apps in basic: text editor,
autoscheduler, quicken-type software, etc. and "flying saucer shooter" -
think missile command vs flying saucers, and you get ground based lasers.
my first realtime arcade game!

then i got into developing operating environments and integrated packages
(look them up!).I learned how to write just about every kind of app.

flash forward about 6 years. By this time i had almost completed my
software engineering degree at OSU (i switched from aerospace when the
cold war ended). i had worked as a systems analyst for the air force
as my engineering co-op, specializing in needs analysis and puchase
recommendations for executive information systems software (looks it up!).
i had also worked for the OSU school of medicine dept of anatomy where i
specialized in needs analysis and purchase reccomendations for
multi-media computer network systems (they were putting Gray's anatomy
online for the first time ever anywhere - in high resolution full
living color).

one day, me and a buddy were DLing Star Trek games, and they were all
the same top down view, sector quadrant, turn based text mode trek game.
i said, "I could write something better than that!" - and in six weeks, i had.
showed it to my friends. they said, "looks cool! needs better
explosions!" (you know how players are! ). so i added better explosions.

then i sent an email to the sysop of the biggest BBS at OSU, and asked him
very politely how he thought i ought to distribute it. he replied that the
model recently established by a new game called "castle wolfenstein 3d",
where you gave them a little for free (about 5% of the game - roughly $1 worth of content at wolf's originl price point of$20), and if they
liked it they paid for the full version. sounded good to me. but my game
was a mission based starship flight sim, not a level based shooter.
so i limited it to 4 types of missions (out of 10) and 10 missions
completed max (vs unlimited).

then i posted it to the local bbs's. about 3 weeeks later someone uploaded
it to AOL. i didn't even have an account. it became a top 10 download of
the week on AOL, with over 10,000 copies downloaded the first week.
all thanks to good copy in the file description (marketing, marketing,
marketing!), and a cool game to back it up. for a flight sim it was
pretty easy to play, as you could automatically lock onto any target with
the computers, and fly to it or attack it.

SIMTrek was followed by many other games, apps, and utilities on and off
over the years (this is the fourth time i've started or re-started my
software company).

i was blessed with a second hit when i restarted Rockland Software
Productions for the second time in 2000. Caveman v1.0 was picked up by
the local NBC news in Washington DC (where i live) as a last minute
xmas gift. response was so great it crashed the website!

about 3 years later, i got cracked by a team out of eastern europe.
the cracked version of Caveman v1.3 was posted on a warez site in
Africa, hosted on servers in Russia. it was probably on other warez
sites as well. losses were so bad, i had to fold the company.

in 2006 i started developemnt of caveman 2.0, a full first person
view virtual world implementation of the game, and almost finished it.
but i lost funding and the project had to be abandonded.

in 2012 i re-started rockland software productions for the fourth time.
so i was (re)starting my software company from scratch. what to build?

this is where the story of the building of Caveman begins...

part 2:

https://www.gamedev.net/blog/1730/entry-2259488-the-building-of-caveman-part-2-what-to-build-and-tool-selection/

,

## Progress report, August 28th, 2014

[color=#ff8c00][size=7][font=arial]Progress report, August 28th, 2014[/font][/color]

Playtesting and tweaking continues. As they say "God is in the details!" Adjusting: collision radii, clip radii, research times and chances, gathering times and chances, etc. The Avian AI is still exhibiting odd behavior at times. Bandmember AI (AI that runs a PC when the human player is not controlling them) needs a number of minor adjustments.

Along with the usual "how things are going" info, i'd like to touch on a few ganmedev related topics that have come up since the last progress report.

[color=#ff8c00]

# [font=arial]Project size and scope:[/font]

[/color]
Caveman 3.0 is big. Probably the biggest game i've ever made. Probably bigger than one person ought to try to do by themselves. I'm not saying it can't be done, its just a HUGE time investment for one person. If you're a lone wolf or small team, think long and hard before you take on a big project. If you do decide to go for it, it might be a good idea to build and release in stages. Start with the core game, then expand in future versions. Big projects that take a long time can lead to my next topic...

[color=#ff8c00]

# [font=arial]Procrastination and burnout:[/font]

[/color]
About 2 years into the project, i found my productivity dropping. Team burnout was the cause. In my case, i reached my limit at 27 months of continuous maximum effort. So i'd take a break. But even after extended breaks, i was still not motivated. While surfing the web i came across "7 causes of procrastination and what to do about them". Turns out my cause was #2, burnout. So i switched gears a bit and spent some time evaluating other games, and watching tv and movies related to games i'm working on. I continued to work on Caveman, but not every waking moment. Sure enough, after a while, i was thinking about the project again while playing another game or watching tv or a movie, and soon after that i was motivated to get back to it fulltime. lessons learned: you gotta take a break every once in a while, and don't be in too much of a hurry to get back to work, wait until once again its what you really WANT to do. Spending time watching tv and movies and evaluating other games leads to my next topics...

[color=#ff8c00]

# [font=arial]Faith:[/font]

[/color]
[color=#ff0000]WARNING: if you have never seen korean dramas or korean historical dramas, they are quite addictive, if you get hooked, don't blame me![/color]
One of the things i did while taking a break was i watched "Faith" for the second time all the way through. Its a korean historical fantasy drama set in the 14th century. A big budget production. And its got it all: action, martial arts, intrigue, drama, medical drama, fantasy, time travel, romance, comedy, you name it! All the production values are top notch: writing, costumes and props, sets, settings, special effects, anamie, subtle incorpration of fantasy elements in a beliveable way, casting, and acting (from what i can tell, i don't speak korean). The entire story is told in a one year long series, 24 one hour episodes, about the same as a long mini-series in the US. I can not recommend it highly enough if it sounds like your cup of tea. goto hulu.com and do a search on "Faith"

[color=#ff8c00]

# [font=arial]A lot of my time playing games is spent waiting...[/font]

[/color]

The Sims: you queue up a bunch of actions, then you wait. or you wait while your sim sleeps or is at work. dont even get me started on the 4 minute load times for a small savegame file! And you can't speed up the game by much. normal speed appears to be something like 1 second of real time = 1 minute of game time. fastest speed is perhaps at most two or three times that.

Skyrim: not so bad, since its basically a big shooter. travelling to undiscovered locations for a quest. turn on continuous move and wait. and then there's the load screens. i actually find myself deciding what to do based on the fewest loadscreens required. IE i might sell or store an item at one location vs another because its 4 vs 6 loadscreens to get there. when loadscreens affect player gameplay decisions in this manner, it CAN'T be a good thing.

Rome II Total War: much of my time is spent waiting for other factions to take their turn, or waiting for troops in battle to march across the field to the enemy. And like the sims, the battles cant be sped up by much more than 2x.

Simcity: waiting for time to pass. again, you can't speed up the game by much.

[color=#ff8c00]

# [font=arial]Low framerates:[/font]

[/color]
I was shocked to find out how low the framerates were for some games on my PC. The SIMs 3 in native resolution and lowest graphics settings clocks in at a whopping 9 to 12 fps! The graphics benchmark from Rome II Total War at lowest resolution and graphics setting can only manage 12 FPS. And this is on a PC that came out at the same time as these games. By comparison, Caveman 3.0 can do 15,000+ non-instanced meshes at 15 PFS all day long. And it can do over 100 animated charaters at once onscreen at 15 FPS. A typical complex scene (~10,000 meshes, perhaps 20 animated charaters) runs at about 20FPS with the framerate limiter turned off.

[color=#ff8c00]

# [font=arial]Responding to input immediately:[/font]

[/color]
I've noticed a number of places in a number of games where the only response to input is a momentary or extended freeze or lockup. Saving in Rome II comes to mind. You click the OK button, and the game frezees. No "Saving game..." message or anything. The only signs of life are the hard drive light blinking. After some number of seconds, it comes back with a game saved message. I've also noticed a number of games are rather sluggish in response to input, as though clicks are being sent to some messaging system for processing by other components, instead of being handled immediately upon detection. Obviously i'm not privvy to the inner working of these games, and can only guess that its some morass of message queuing, multithreading with stalls, unoptimized middleware, and slow garbage collectors that causes this. divvying things up and passing messages everywhere may be a neat way to organize code, but it also adds overhead. i'm of the old school when it comes to how responsive software is: "If the task is not completed by the time i lift my finger from the key or button, its too slow!" perhaps this should be modified to "if it doesn't at least respond somehow by then, its too slow".

[color=#ff8c00]

# [font=arial]The fastest code:[/font]

[/color]
"The fastest code is code that never gets executed". We've all heard it. Sure, it sounds great, but turning off code usually isn't a practical speedup. While playtesting, I've constantly been plagued by the fact that the simulation simlpy can't run blazingly fast and do complex AI for lots of targets all at once. Because of this, when i get an encounter, i usually move on until the animals are removed from the simulation due to distance. Then i get back to making a spear or whatever, once the simulation is running blazingly fast again. The obvious answer was further optimization of the AI. But i'd already been there and done that. Iterating through the list of active entities to select a combat target is the bottleneck, with no obvious solution in sight. Nothing less than a pardigm shift would change things. So i changed the rules! You can now only accelerate the game faster than 128x if there are no hostiles around. and at speeds above 128x it doesn't update non-hostiles at all (the AI code doesn't run at all). This simple rule change makes all the difference in the world. Now you can fast forward through actions with non-hostiles nearby at blazing speeds, and you still get full tilt AI when hostiles are around - having your cake and eating it too, very WITH my religion (as opposed to being against my religion).

[color=#ff8c00]

# [font=arial]We now return you to your regularly scheduled progress report:[/font]

[/color]

recently done:
* increased sleep time by about 10%
* gifts to cavemen increase relations by twice as much.
* fixed: cant rest & heal in temp shelter w/ bedding when sick but not injured.
all rest and heal action triggers now use a single generic try_rest_heal() routine that lets you rest and heal if you have damage or are sick.
* fixed: getting encumbrance fatigue when not moving or engaged in sedentary activities
* added button graphics to view inventory and view help
* rest and heal now shows damage as well as progress
* added eat/drink actions inside shelters
* find reeds: doubled time required, cut chance in half
* fixed: doesn't moves followers when cross-country movement stopped due to encounters, etc
* fixed: companion's model and textures not copied to new bandmember when they join your band
* fixed: companion's 3rd interest not copied to new bandmember when they join your band
* fixed: companion's social not set when they join your band. now set to 100.
* turned off damage display over bandmembers
* added "add companion" to playtest menu
* added "add lean-to" to playtest menu
* AI recalcs best tgt every 2 secs, not every 5.
* fixed: doesn't draw rain/snow outside temp shelters
* fixed: new bm not set to alive when companion joins band
* fixed: not loading and saving cm[].alive
* increased MAX_RESOURCES in a map sq from 1000 to 2000
* cut crh resource reduction chance by 50%
* fixed: added renew_resources() to change_the_map(). 10% chance per day for depleted map sq to renew back to MAX_RESOURCES.
* added "issue orders". remapable "o" key input. orders menu: follow me, attack, and as you were.
* added "make sacrifice to earth godess gah" to rocks menu. volcanos only was too hard.
* sucessful sacrifice actions now boost god relations by 30. was 5 for fire, and 20 for all others.
* increased local automap range from just the players current local map sqaure (100 foot) to a radius of 2 local map squares around
the player's local map sq. range before: 0-100 feet. range now: 200-300 feet.
* game now runs fast with non-hostiles nearby! wont go faster than 128x with hostiles alive. doesnt run animals at speeds above 128x.
* button graphics for select_object screen
* button graphics for shift_select_object screen
* button graphics for trade screen
* increased collision rad: mixotoxodon
* increased collision rad: gt ground sloth
* increased collision rad: short faced bear
* fixed: animal encounters: start location not normalized
* fixed: caveman encounters: start location not normalized
* make bedding: shows progress %
* make bedding in shelter: shows progress %
* fixed: draws plants over bedding
* fixed: regen terrain chunks when build temp shelter
* fixed: regen terrain chunks when build bedding
* fixed: search dead CM: take one: doesn't remove item from list!
* fixed: action msg for making fire is messed up
* increased clip rad: world objects (due to temp wood shelter).
* increased action area for selecting temp shelter.
* 1 hand stone hammer: doubled time to find, cut chance to find in half.
* added /d command line switch: enables display of debugging messages as the program starts up.

beta 11 has been posted.

[color=#ff8c00]

[/color]

# [font=arial]http://rocklandsoftware.net/beta.php[/font]

## Building a large procedurally generated world with no load screens: How caveman 3.0 works.

Building a large procedurally genrated world with no load screens:
How caveman 3.0 works.
======================================================================

GAME WORLD DATA STRUCTURES:
=====================================================================

1. the world map
---------------------------------------------------------------------
the world map is stored in a 500x500 array of structs.
each map square is 5 miles across.

terrain chunks and collisions maps are generated from the world map data.

assets are loaded once at program start. asset reuse is maximized.
load times are on the order of 20 seconds or so for EVERYTHING! : )

if required, paging of assets could be implemented.

the map structs hold info about elevation (heightmap used), vegetation
(what plants to draw, what ground texture tile set to use), water
(what water to draw), and miscellaneous terrain features, such as rock
outcroppings, fruit trees, berry bushes, tar pits, etc (more stuff to
draw).

the world map is randomly generated at game start, updated (changes)
once per game day, and is included in a save game.

2. pattern maps:
------------------------------------------------------------------------
so the world map tells us more or less what to draw, but not necessarily
where exactly to draw stuff.

enter "pattern maps".

a pattern map is a 2d array, either a true 2d array, or implemented as
a sparse matrix (a list).

so you have a pattern maps to tell you where to draw trees, rocks, etc.
pattern maps are then repeatedly tiled over a map square to place trees,
etc. The size of a pattern map should be big enough that no moiarre'
patterns are discernible within viewing range. this usually works out to
a size of two times visible range.

multiple pattern maps are used for different things so rocks and trees
for example don't all appear at the same locations.

pattern maps can contain more information that just location, they can
also include things like type information for determining drawing info,
or even render and physics info like scale, bbox dimensions, etc.

ground coverage plants can simply be draw every x number of feet with
type based on "location mod ".

caveman uses 5 pattern maps: one for trees, one for rocks, one for berry
bushes, one for fruit trees, and a generic pattern map for tall grass,
canyon heightmaps, and a few other things.

pattern maps are randomly generated at game start, and are included
in a save game.

3. The CRH list:
----------------------------------------------------------------------
the CRH list is a list of all the caves, rock shelters, and huts in the
game (IE all buildings in essence). an index is used to speed searches.
the index is a 2d array the size of the world map. for each map square,
the index holds a list of the CRH's in that map square
(IE their indexes in the CRH list).
the CRH list is randomly generated at game start, is updated once per
game day, and is included in a save game.

4. The world objects list:
-----------------------------------------------------------------------
this is a list of all the immobile objects the player has built in the
game world such as shelters, huts, landmarks, traps, bedding, etc.
it also includes all inventory objects the player has dropped. dropped
objects are only persistent inside player owned CRH's, otherwise they
are removed from the simulation when the player is no longer nearby.
so its ok to store them here without running out of room.

TERRAIN CHUNK GENERATION:
=======================================================================
when it comes time to render, the game determines the terrain chunks
in visible range, and draws each one. if a chunk is not in the cache
its generated on the fly. chunks are also generated in the background.

a terrain chunk is basically a pre-generated render queue list of all
the meshes in the chunk to be drawn, ready for sort on distance
(if desired), frustum cull and rendering.

a chunk is generated by clearing the cache slot, then adding meshes, then
setting the slot to active for use by the renderer.

the coverage and miscellaneous terrain features in a map square
determines what to draw, and the pattern maps are used to place items
such as trees, rocks, and plants.

the world map, pattern map, and world objects list determine the meshes
added to the chunk. once the meshes are added, the chunk is marked as
active for use by the renderer.

the optimal size for a chunk appears to be whatever visual range is.

ground mesh generation:
-----------------------------------------------------------------------
ground meshes are generated as follows:
pre-allocated static buffers are used.
the ground is composed of four interleaved meshes, one for each of the
four texture tiles used. a pattern map determines the texture used
by a quad. all quads using a texture are heightmapped and added to the
static buffers (VB and IB) for that mesh. the four meshes draw together
form one continuous ground mesh with tiled textures that still follows
the game's mantra of "one texture per mesh" for speed.

the elevation in a map square determines the heightmap used by the
ground meshes. elevations can vary from map square to map sqaure.
a "heightmap seam fixer" is used at map square edges. the ground
texture pattern map determines which texture a ground quad uses.

collision maps:
------------------------------------------------------------------------------
collision maps are generated on the fly, in a manner similar to terrain chunks,
and stored in a collision map cache.
the maps are 2d arrays of ints, with different values indicating different types
of obstacles: 0=none 1=rock 2=tree, etc.
collision maps are the same size as terrain chunks.
when a collision check is made, the location is translated to a collision map
and coordinates in the map. if the map indicates something there, true is returned
for the collision check.
if a collision map is not in the cache, its generated on the fly.
a maps is generated by clearing it, then adding trees, rocks, buildings, etc.
as specified by the world map, pattern maps, and world objects list. collision map
generation is faster than terrain chunk generation because it only sets a few ints
instead of adding a drawinfo struct to a database with a 2d index. so background
generation is unnecessary.

overall results:
--------------------------------------------------------------------------------------
as the player moves across the world, terrain chunks and collision maps are generated
as needed. right now there is a slight delay when a large number terrain chunks must be
generated in the foreground on the fly, but its too short to even display a
"generating area..." message. as i fine tune the background chunk generation to run
faster with more passes of less stuff per pass, and increase terrain chunk cache size,
and perhaps increase the background generator's look ahead range, i hope to eliminate
the slight delay entirely.

this approach gives you a procedurally generated random persistent modifiable game world
with no load screens.

## Beta 21 w/ skinned meshes released!

Beta 21 w/ skinned meshes released!

guys look kinda dumb, girls aren't that pretty, the guy walk ani is kinda awkward (leg bones rotated outwards too far), no action animations or drawing of equipment yet other than weapon in hand, but its a start!

http://rocklandsoftware.net/beta.php

action animations and drawing equipment is next. I'll clean up that guy walk ani too. i found an unbelievably beautiful female head while looking for PD skinned meshes, which i plan to try and "Dr Frankenstein" onto a body. plus i also have the pretty girl heads from the rigid body models. Good looking guys - not so much luck. Just ultra high poly stuff i cant use - such as my original rigid body guy - the search continues. Just like a writer / producer / director in the film industry, i want/need/should use the most photogenic actors. My players deserve no less.