Author Topic: Combathistory, remembering attacks  (Read 2438 times)

Offline Atomic

  • BFF
  • ***
  • Posts: 115
  • To infinity and beyond!
    • View Profile
Combathistory, remembering attacks
« on: February 16, 2007, 04:18:26 am »
Does DS2 support any form of combat remembrance?  ???
I'd like to make it so that entering/leaving rooms could trigger combat,

based upon:

- previous combat
- alignment (could be done by editing npc's script, checking for alignment, if blah then attack)
- stopping combat (either by spell or command), leaving room, npc remembers you and starts again,
  even if alignments are found to be good and npc is not auto-aggressive).
Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.

Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
Re: Combathistory, remembering attacks
« Reply #1 on: February 16, 2007, 11:15:41 am »
There are no premade functions which do what you describe, but it is a fairly simple matter to make some. You can use invis objects with call_out self-destructs or heart_beats (the preferred method if this is going to be a common event on your mud) to mark chars which have recent engaged in combat in room X. Then you can setup any conditional that you wish: eg
it can be as simple as if living_enters() (there is a function that checks if a living enters the room, dont remember name exactly) then all last_attacker()->attacks player when he/she reenters the room or complex conditionals
or it can be quite complex eg.
if living_enters() && playerrace!=orc && TP->GetMorality()>0 && player is not wearing orc's guard uniform, then all mobs in the room attack him/her.

I would also recommend adding a counter to your combat. So that you can count the number of rounds a player has been in combat. Optionally you can save this information to the playerfile and use it on conditionals. if player counter > 5 then attack him/her when she reenters. (the unnecessary else statement {do not attack if less than 5 } does not need to be written out).

-Detah@Arcania

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Combathistory, remembering attacks
« Reply #2 on: February 16, 2007, 12:57:39 pm »
Quote
Does DS2 support any form of combat remembrance?

Yes and no.

Quote
- previous combat

This, definitely. If you pick a fight with a smurf, then leave the room, then come back in a little
later, it'll still be miffed. Both of you will remember you're supposed to be fighting. And if for some
reason you've forgotten, he won't.

However, if you're talking about that smurf never ever forgetting he hates you, that is quite
a different story. Now you're talking about world persistence, because not only can the mud
reboot, that room and that smurf will eventually reset. The new clone has no idea what came before.

If what you mean is that you don't want npc's to ever forget you and fight you on sight, this becomes
a discussion on the implementation of persistence. Is this what you mean?

Quote
- alignment (could be done by editing npc's script, checking for alignment, if blah then attack)

This sort of thing is trivial to implement. See the Creator's Manual chapter 22 on NPC building. It's
just a question of adequately coding the SetEncounter.

Quote
- stopping combat (either by spell or command), leaving room, npc remembers you and starts again,
  even if alignments are found to be good and npc is not auto-aggressive).

Not too sure what yer getting at here, but my guess is this goes back to the question of persistence.
Specifically, the question would be how/where to save the "jerk list". One simple way is to establish a
save/ directory that the npc can write to (/realms/atomic/area/save perhaps) and using that
directory to save the npc object occasionally, such as when it gets attacked. By using the
save_object and restore_object efuns, you can save the npc's variables to a file in your save
dir and restore them when he is cloned again.

An example of npc's with saved variables like this are Charles and Charly, the AI savants in
the /domains/campus/npc directory.

Their code is complicated because they are making statistical calculations. Don't get wrapped up
in the math. Just pay attention to the spots where they use save_object and restore_object.

-Crat

 EDIT: woops! looks like an oversight on my part made this part of Charles and Charly not work.
To make sure they work as suppsoed to, fix my bug by typing:

mkdir /domains/campus/save
« Last Edit: February 16, 2007, 01:02:05 pm by cratylus »