# defend sacred animals quest

## Recommended Posts

i'm currently adding quest generator #24 to Caveman 3.0 (FPSRPG / person sim hybrid - stone age setting).

the quest: defend a herd of scared animals from hunters.

current behavior:

player goes to where herd is.

herd spawns.

player must wait for hunters to show up.

herd probably wanders off before hunters arrive.

if player leaves area: quest failure.

hunters later show up, and attack player for being there and interfering with their hunt.

i don't have any turn key AI that will make a critter just hang out in a specific area, except for "defend location" AI which would attack anything nearby including the player. i could always code some up right quick, but setting the herd to use it might be a bit of work, it would require modding the spawn code.

i could spawn both the herd and hunters when the player arrives at the scene and say they arrive just as the hunt is about to begin...   somewhat contrived?

suggestions?

wait for the hunters can be either challenging (when in a remote area) or boring - IE the fact that you have to wait. but you can always accelerate time. and you can always craft something or learn a skill while you wait.

the hunters are set to spawn:

' 12 in 1000000 per sec = 23.1 hrs on avg
so they should show up within one game day.
Edited by Norman Barrows

##### Share on other sites

You might consider salt licks as a reason for a herd to stay in one place for a bit - they can be both naturally occurring or artificially placed. You could also generate an amount quantity for the salt lick which would act as a timer for the quest itself i.e. lick is finished, herd moves on.

##### Share on other sites

[b]@[member='Stormynature'][/b], Great idea about the salt lick. Gives the herd a real reason to be there over another location and it can be a good visual clue for the player.

##### Share on other sites

Suggestions? Well, let the player join the hunters and kill the animals, getting something in return. Or dont join the hunters and let the player kill the animals for themselves (sell the pelts or something). Or let the player kill everything and everyone for no reason. Those should all be properly handled and possible quest outcomes.

Nothing screams RPG to me more than getting a "Bandits are attacking our village, help us!" quest, then going to the bandits and joining them in the raid.

Edited by TheChubu

##### Share on other sites

I think the herd should move from place to place stopping to eat etc. and run if they hear or sent the player. This forces the player to have to stay with the herd to protect them, rather than just sitting around passing time. When the hunters then show up they should be stalking the prey and the player can try and take out the hunters quietly if they can find them, scare the herd to charge off to have the hunters reveal themselves or wait until the hunters reveal themselves to strike.

##### Share on other sites

You might consider salt licks as a reason for a herd to stay in one place for a bit

well, that would be a very believable justification for the behavior, but i'd still have to code up the custom AI behavior. and set the herd to use that AI when it was spawned. right now there is no "just hang out" AI in the game. but a copy/paste/edit of the "defened location" AI can fix that - probably in less than an hour. also, AI is currently assigned on a per type basis, not per entity. for some quest critters, a flag is used to override the default type-specific AI for that entity and instead use the 'defend location" AI for that critter. "hang out" AI would require a second flag, or changing the flag to a variable for "entity specific AI type" (defend location, hang out, or normal AI for that critter type). a non-trivial amount of modding to the code. its probably the right way to do it though.

##### Share on other sites

Well, let the player join the hunters and kill the animals, getting something in return. Or dont join the hunters and let the player kill the animals for themselves (sell the pelts or something). Or let the player kill everything and everyone for no reason.

lots of good plot twists there!

but for the moment i'm starting with the straight-forward quests with no plot twists.

i started to code the first quest generator (kill animals defending treasure) with plot twists like; "you're not the only group going after the treasure", but found that the possible permutations quickly grew into a very large branching quest. the time to write the quest code was measured in days, not hours.

so quest generator #24 is a simple quest, defend herd for reward, with no plot twists (yet). success if hunters dead, fail if leave area. right now it doesn't even matter if the herd wanders off, although it definitely doesn't look right <g>.  by spawning the herd and hunters at the same time, the battle with the hunters should be over before the herd wanders off - and i don't have to create "hang out in one spot" AI.

##### Share on other sites

Nothing screams RPG to me more than getting a "Bandits are attacking our village, help us!" quest, then going to the bandits and joining them in the raid.

yes, the ability to choose either side is very nice. in this particular case, unless you give the player a chance to parlay with the hunters, the hunters will attack the player simply for being there (the way its coded right now).  if the player parlayed with the hunters and "switched sides", it would be automatic quest failure, and the hunters would no longer be hostile.  but you can also yield while in combat. but i think the hunters are set as "hostiles" which means they never accept a yield.

but as i said, i'm trying to think of a clever way to implement the basic quest (without plot twists) without having to add a bunch of new capabilities to the engine, such as "hang out" AI, and multiple types of entity specific AI (defend location, hang out, or the normal type-specific AI behavior).

am i just being lazy?  <g>.

##### Share on other sites

I think the herd should move from place to place stopping to eat etc. and run if they hear or sent the player.

yes following the herd would be much more realistic. change the fail condition from "player beyond 500 feet from spawn point" to something like "no herd animals active"  (animals deactivate when they move beyond 350 feet from all the player's band members).   but tracking what's a quest animal is a bit tricky. definitely more coding work than "> 500 from spawn point". as i recall, other quests required me to add the ability to track which critters go with which quests for which band members. so odds are the code to do that already exists. that's one of the cool things about working on a big project when you're near the end of it. often times the code to do something already exists in some form in the game engine somewhere.

the critter type of the herd is random. their behavior is the normal AI for that critter type. so it may be a herd of small antelope that run from everything, or it may be a sabertooth

that has no qualms about eating the player for lunch, or it may be a herd of mastodon that will stomp anything that gets too close.

When the hunters then show up they should be stalking the prey and the player can try and take out the hunters quietly if they can find them, scare the herd to charge off to have the hunters reveal themselves or wait until the hunters reveal themselves to strike.

when the player encounters the hunters, either side might be surprised for a moment or two (as with all encounters), and the player can use stealth mode at any time in any combat. scaring off the herd depends on what kind of critter it is.  rhim gazelle? no problem! woolly rhino? big problem! <g>. although a well placed missile attack from an unknown quarter might work even against large herd animals. reacting to "missile fire from undetected shooter" is part of the standard AI used by all critters.

##### Share on other sites

looks like this quest gen is going to need some more work. i tried spawning the herd and hunters at the same time. but the herd is just a random wilderness encounter based on terrain type, which is often a critter the hunters can't really take on. and the hunters are using "defend location" AI, with the quest location as the location to defend. the critters follow their normal AI for their species, which is either "defend against weaker and flee from stronger" or that plus "hunt or pack hunt equal or weaker" (for predators). put it all together, and the hunters attack whatever is closest to their spawn point, even if its a herd animal they can't possibly kill. when they get close to a tough herd animal, the herd animal moves to attack them, and the hunters flee back to the spawn point, then turn and attack whatever is closest once again. if the player remains farther than the herd from the hunters, the hunters ignore the player. in some cases the herd is predators (american scimitar cat) and attacks and kills the player.  in other cases the herd (woolly mammoth) kills the hunters! about the only thing left to try is spawning the herd far from the quest location, so the player is guaranteed to be the closest thing to the quest location the hunters are defending. that might get the desired basic behavior, but technically it wouldn't really be the desired behavior. the hunters should attack the player, not defend a location. or they should attack the herd until the player attacks them, then attack the player. and the herd should probably be something that hunters might hunt, and not a "sacred" sabertooth or some other impossible to kill critter.

hmm...  why does everything always have to be complicated? <g>.

Edited by Norman Barrows

##### Share on other sites
I'm not much of a programmer, but maybe my attempt to help could be salvaged in some way, shape, or form. :P I'm going to play this off the awesome salt lick idea and using deer as an example herd.

Instead of using data and values, with my tiny brain I'mma refer to them as tags. Now what if you 'tagged' the hunters (going to just call it a red tag) and the deer (yellow tag). NPCs with the red tag could be set to ignore or be neutral to creatures except for those with the yellow tag, which they pursue. Yellow tags obviously try and avoid these.

Now to make the salt licks work, you could use them as the center of an invisible circle that NPCs with the yellow tags cannot pass. If a yellow tagged NPC hits the wall they're re-directed away from it.

Using some tagged animals would allow you to be a bit more selective in what happens, right? Red tags pursue purple and yellow tags. Purple tags aggro on red tags after x. Yellow tags flee red tags.

##### Share on other sites

I'mma refer to them as tags.

tags / variables - same difference.

only problem is you have to add any new tags and any new AI behaviors to the game engine that don't yet exist.

right now the only tags are:

what species the critter is

a tag if the critter uses "defend location" AI instead of the normal AI for its species or NPC type.

a tag if the person or animal is part of this quest.

and the only behaviors are:

non-predator: flee from stronger - defend against others.

predator: as non-predator + hunt or pack hunt not-stronger prey.

defend location: attack whatever is closest to some location that is a different species.

badguy: attack player and neutral NPCs

predator or non-predator is assigned on a per species basis. so for example, all sabertooths are predator AI by default.

a tag (flag / boolean variable) indicates if a critter uses defend location AI instead of the usual predator or non predator AI for its species. that way you can spawn a herd of anything you want and make them defend a location for a quest. defend location is fight to the death AI, it will never flee.

by making the hunters badguys, they will automatically attack the player. by making them defend location, they will attack anything near the "location".

both predator and non-predator AI include behaviors like wander, flock, and migrate.  migrate makes them wander away after a while.   defend location AI doesn't migrate or wander. if its far from the location, it moves to the location. else if there's anything near the location, it attacks, else it just stands, waiting for something to approach the location.

the problem is the existing tags and behaviors aren't exactly whats desired. or at least i haven't come up with a combo of setting that ought to work. spawning badguys (but not defend location badguys) at the quest location and spawning the herd some distance away might work. the badguys would only attack the player, not whatever is close.

but the herd sill might be a nasty critter (mammoth), and if its in the way, it might kill the hunters trying to get to the player.

or the herd might be a predator (sabertooth, etc) and eat everyone - hunters and player alike!

this might turn out to be a quest where the herd does the work for the player some of the time. unless i make the herd weak prey.

and there are no encounter tables for weak prey, only common, uncommon, and quest for each of 8 or 9 terrain types.

its not that its not do-able, its really a matter of how to do it with the least amount of effort.

##### Share on other sites

i changed the hunters from quest hostiles with defend location AI to ordinary hostile cavemen who just attack the player. the herd is still just an ordinary random animal encounter. i'm using "no hostile caveman within 500 ft of player" as the check for success (IE all dead / run off).

seems to work ok, but the herd can still be a predator, or a large animal capable of killing the player if they get too close.

of course, nothing said the herd animals weren't dangerous...    just that they were "sacred".    ; )

does this sound ok?  or am i being a little too sneaky as a DM here?   <g>.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627701
• Total Posts
2978698

• 21
• 14
• 12
• 10
• 12