How to make an NPC die?

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

foody
Posts: 35
Joined: Tue Apr 24, 2007 1:56 pm

How to make an NPC die?

Post by foody »

Hello,

I have a problem here. I want to make it such as when you talk to an NPC if you trigger a certain keyword that the second you step on a tile or space that I specify it's location that particular NPC (NOT PC) dies. I want to put it in a more clarified picture:


Legions: P = Player Character, NPC = Non Player Character, S = Space



S(P) Wall NPC

When the P is touching the S as seeing there (S(P)) the NPC behind that wall dies in such away that when I reenter the room through the door I see a dead corpse instead of the NPC walking randomly. Thanks in advance. (PS "This same method is to be used if I want an NPC on a different map to move one step when I talk to an NPC of a different map to trigger that NPC of a different map to move.")
I WANT ULTIMA 7 OR ULTMIA 6 CONSTRUCTION SET! I WILL DO ANYTHING! PAY ANYTHING! GIVE ANYTHING !

Chris H
Posts: 272
Joined: Sun Dec 02, 2007 4:07 pm
Location: California, USA

Post by Chris H »

I may have to add some more creature-handling macro commands, because I don't think what you're describing can be done right now unless the creature stays still.

In my Ultima parody I have a few cases where you're talking to someone and a macro in the conversation makes the person disappear from the map, and a new creature is created elsewhere on the map -- giving the illusion that you've done something that made them go somewhere else. But I'm doing it to creatures that don't move around, and with just the ordinary map-editing commands (if you drop brick floor on top of a creature, they're gone.) :)

What I'd like are macro commands that take a particular creature and let you directly edit its location or let you remove or create creatures. Next time I'm in the code, I'll see if I can make some new macro commands that make this a little easier.

However this would still be limited to a creature somewhat nearby on the same map as the player -- it's limited to being able to manipulate what's already in memory.

foody
Posts: 35
Joined: Tue Apr 24, 2007 1:56 pm

Post by foody »

Are you saying it is impossible to add a feature where if variable A is set to 1 and an NPC in the main map have a condition to move one step only to the left if A variable is set to 1 even though that variable A set to 1 was set in a whole different map? Also, are you saying it is impossible to add a feature where if A is set to 1 in the map that if the NPC walking randomly in the same map but in let us say in X 450 and Y 230 and the tile that triggers the even at X 10 and Y 10 that when I step on it that NPC at the current, X and Y coordinate will simply die as if I killed it on my own? :smile:

It would be awesome if you could add these two features and also possible if you have what we call step event for the NPC where every step the NPC moves it executes the event according to the condition I have set it. Let us say for example an NPC called Jason he moves step by step in the same map as I am and I said something like "murder" and this keyword in the conversation triggers the variable A to 1 where the next step the NPC does in the condition step event:

if A = 1 then
MurderMyself
End if

and then the next step he does that condition meets and he dies or even without him moving it is a timer event where every second that event is executed in the condition etc...

if you give us this power...THE POSSIBILITY and fun is endless. If you can make global variable set (256 in total like everything else due to DOS restrictions) and with the timer event for the NPC where I set the milliseconds it executes I can trigger in the global variable in room type map for example A = 1 and the NPC with the timer event I put in the world map where:

If variable A = 1 Then
MoveMeOneStepToLeft
Set variable A = 2
Endif

You know what I mean? Please consider this...thanks in advance. (If you add these features, YOU WOULD HAVE SAVED MY LIFE because then I can resume my game development this way, otherwise I am restricting and removing SOME AWESOME ideas rendering this game to be missing, boring or monotonic robotic.)

Thanks in advance.
I WANT ULTIMA 7 OR ULTMIA 6 CONSTRUCTION SET! I WILL DO ANYTHING! PAY ANYTHING! GIVE ANYTHING !

rld

Post by rld »

Chris H wrote: What I'd like are macro commands that take a particular creature and let you directly edit its location or let you remove or create creatures. Next time I'm in the code, I'll see if I can make some new macro commands that make this a little easier.

However this would still be limited to a creature somewhat nearby on the same map as the player -- it's limited to being able to manipulate what's already in memory.
That would be very cool!

If you also had a step macro that a creature could execute each turn, along with the ability for that macro to manipulate a few of the creature's internal states, you would be able to add an enormous amount of flexibility.

For example, let's say the macro had access to the following variables:

CRX, CRY - creature's location in the current room
CRHP - creature's current hit points
CRACT - variable that is optionally set by the macro to tell the creature what to do, sort of a reverse version of LASTMOV:
0 - allow the creature to do whatever it normally would
1/2/3/4 - move N/S/E/W
5 - attack with melee weapon (if possible)
6 - attack with distance weapon (if possible)

So, before the macro runs for a given creature, CRX and CRY would be set to its current location, and CRHP would be set to its current HP. After the macro runs, changes in CRX, CRY and CRHP would propagate back to the creature, and CRACT would be consulted to determine if the macro had decided to override the creature's normal action.

This would allow implementation of things like:
- creatures that cast spells on the player
- creatures that cast spells to heal themselves
- creatures that have limited ammo for a distance weapon
- creatures that teleport around the room (by changing CRX/CRY)
- creatures that follow designated patrol paths (like guards)

You probably wouldn't go to this level of complexity for *most* creatures, but for higher-level monsters or boss fights it might be interesting.

If you added to this the ability to create/delete creatures, you might also be able to implement simple party members/allies that followed you from room to room and helped you fight, cast healing spells, etc.

Chris H
Posts: 272
Joined: Sun Dec 02, 2007 4:07 pm
Location: California, USA

Post by Chris H »

I still haven't looked at this, but still plan to. The step macro is an interesting idea, and I don't see why the CRACT variable wouldn't be doable. I might even add a CRGOX and CRGOY that, when set, would tell the creature "attempt to walk to this X,Y spot."

Part of the problem is that the engine only makes an NPC do things if it's on the screen. This means NPCs can't follow you through portals, and can't go to off-screen patrol points, because once the NPC leaves your view area, the engine doesn't care about it anymore (It's extremely player-centric.)

foody
Posts: 35
Joined: Tue Apr 24, 2007 1:56 pm

Post by foody »

I cannot take it anymore! :evil: I want an Ultima 7 Construction Set so badly (ENOUGH WITH EXULT, THAT WON'T DO) that I am going to officially save money up to 10,000 and pay anyone with this amount of money to make me a real 100% pure ULTIMA 7 Construction Set.

I am not joking either. It may take me couple of years to save this much, but I am going to put it in an envelope and label it Ultima 7 Construction Set. Then I am going to go RentAcode and hire a real pure programmer of 20+ more years and pay him this amount of money to make me an Ultima 7 Construction Set.

I am serious as stone.

P.S "I would rather pay you Chris H this money but you are not the type of person to do it even if I put three zeroes after the number and showed it to you in front of your face. I doubt any money in the world would make you do that step."
I WANT ULTIMA 7 OR ULTMIA 6 CONSTRUCTION SET! I WILL DO ANYTHING! PAY ANYTHING! GIVE ANYTHING !

rld

Post by rld »

Chris H wrote:I still haven't looked at this, but still plan to. The step macro is an interesting idea, and I don't see why the CRACT variable wouldn't be doable. I might even add a CRGOX and CRGOY that, when set, would tell the creature "attempt to walk to this X,Y spot."

Part of the problem is that the engine only makes an NPC do things if it's on the screen. This means NPCs can't follow you through portals, and can't go to off-screen patrol points, because once the NPC leaves your view area, the engine doesn't care about it anymore (It's extremely player-centric.)
Sure, I assumed as much. Creatures in another room than the player (or offscreen from the player in world maps) aren't active and thus wouldn't have their step macros run. You might be able to rig it using a combination of the player's step macro and portal macros so that the NPC ally was deleted when the player left one room and recreated in the next room. This would require the addition of creature add/delete commands, however.

But, this is getting a bit ahead of things, and the concept of "party members" is quite a stretch for the ACK engine as it stands now.

Just having a creature step macro (which uses the temporary variables CRX/CRY/CRHP/CRACT/CRGOX/CRGOY) would allow the implementation of a HUGE number of highly entertaining things. Since the temporary variables would be set/checked before and after the macro was run for a creature, you could have more than one creature in a room using the same step macro with no problems.

jjsonick
Posts: 145
Joined: Tue Apr 10, 2007 2:49 pm

Post by jjsonick »

Just chiming in that this creature step macro idea would be AWESOME and very useful.

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Post by GB »

'm surprised that no one suggested a simpler action, like a behavior that would make an ally attempt to follow the player in the same way that aggressive creatures move toward them or a behavior that would cause a creature to flee from the player, which mightbr set by a condition like, has no weapons or no ammo.

Take the gremlin that steals food, sure, he takes some of your food when he hits you, but he stays and fights to the death so he never gets to enjoy eating it. The loss of food is just a special kind of damage with no motive.

What would you have to do to make a monster run from nowhere, touch and swipe something off the player, turn and run away, and hide or leave the region?

What would you have to do to make it possible for it to steal something essential, and then later be able to recover by vanquishing the thief-like the only key to get into a room that you needed to enter to win the game?

Could you have an npc, who was, in effect, not hostile, come up beside the player and initiate a dialog? Or even a short message? (perhaps blinking so that you know who spoke)

So yes, CREATURE GO X Y, FOLLOW, FLEE these creature behaviors are great ideas.

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

GB wrote:'m surprised that no one suggested a simpler action, like a behavior that would make an ally attempt to follow the player in the same way that aggressive creatures move toward them or a behavior that would cause a creature to flee from the player, which mightbr set by a condition like, has no weapons or no ammo.

...

What would you have to do to make a monster run from nowhere, touch and swipe something off the player, turn and run away, and hide or leave the region?

What would you have to do to make it possible for it to steal something essential, and then later be able to recover by vanquishing the thief-like the only key to get into a room that you needed to enter to win the game?

Could you have an npc, who was, in effect, not hostile, come up beside the player and initiate a dialog? Or even a short message? (perhaps blinking so that you know who spoke)
As Chris said in another thread, it is possible to use map-editing macro commands to move creatures around on the map (creatures show up as #255 objects).

So having a creature hit you, steal something using a touch macro, and then vanish is doable, using MAPTAKE to remove the creature. The only problem is that if there is more than one creature next to the player, there is currently no way for a macro to identify which creature is which type (so it knows which one to remove).

There is no way that I know of right now to make a creature 'flee' from the player. I believe that creatures which are hostile but have no weapons equipped will still follow the player, so you can approximate 'ally' behavior there. The creature can't follow the player from one room to another, however.

If you only have one creature in a given room/region, you could make the creature walk up to the player (by making it hostile but not giving it a weapon) and then use the step macro to monitor the squares adjacent to the player using MAPCHK. When the step macro 'sees' the creature next to the player, you could trigger a message or dialog at that point.

The other wrinkle in all of this is that if you use map-editing commands (or even the TAKE ALL FROM THIS AREA action) it tends to give creatures in the area two (or occasionally three) moves in a row. For example, if you remove a 'trap' floor stacked on top of a creature using TAKE ALL FROM THIS AREA (triggered by the player stepping on a 'trap' tile or something similar), the creature will usually move twice (and potentially attack the player twice) before the player gets a chance to respond.

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Post by GB »

That's an interesting idea about using mapcheck to start the dialog.

I assume it would require a fully scripted environment, such that you had no other monsters wandering around in the room, the player cannot have a spell or item that might otherwise summon a creature.

Then as you enter the area you start a macro that runs a check on adjacent squares per step. A hostile but weaponless creature is revealed, and if it comes within striking distance of the player the macro starts a dialog. After that the macro may replace the creature with another type (but with the same graphic and name) which may be hostile or benign, or it may simply remove the creature from the room altogether.

Do I have the idea?

I experimented with a weaponless gremlin. he does a good job of following, staying just one or two squares ahead or behind, and can follow a long way on world maps. You have to watch out for tight spaces though or you'll have to kill him just to get back out of them.

If you use an aggressive creature to deliver a message like this, might the player be able to see this as aggressive behavior?

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

GB wrote:That's an interesting idea about using mapcheck to start the dialog.

I assume it would require a fully scripted environment, such that you had no other monsters wandering around in the room, the player cannot have a spell or item that might otherwise summon a creature.
Basically, yeah. Unless we get a macro command added in a subsequent ACK revision that allows you to pull up a creature type value using the creature instance number, there's no way for macros to tell creatures apart right now.
GB wrote:Then as you enter the area you start a macro that runs a check on adjacent squares per step. A hostile but weaponless creature is revealed, and if it comes within striking distance of the player the macro starts a dialog. After that the macro may replace the creature with another type (but with the same graphic and name) which may be hostile or benign, or it may simply remove the creature from the room altogether.
Now that I think about it, if you have a controlled environment like this (with the player plus just one creature), you might be able to do some other effects as well.

If you make the creature the same alignment as the player (both GOOD, for example), the creature would normally not head towards the player. However, if you set the player to 'criminal' mode by setting CRIM=1, then the creature will attack the player. You could use this to make a creature approach the player, deliver a dialog or message, and then stop following the player after the event has completed.

Something else that might be interesting would be to have the player and the creature both GOOD, and place pseudo-creatures in a room (with EVIL alignment) that look like walls or other scenery. These pseudo-creatures would be invulnerable, but their purpose would be to 'draw' the GOOD creature towards them. You could move/destroy/hide these creatures as needed to change where you wanted the GOOD creature to go.

So, you could use this to do some sort of scripted event where the creature walked up to the player, the player talked to the creature, and then the creature said 'hey, I'm going to go open that door' and walked over to another part of the room.

Of course, mosaics are also good for animating this sort of thing, but that requires everything to be laid out in advance.
GB wrote:I experimented with a weaponless gremlin. he does a good job of following, staying just one or two squares ahead or behind, and can follow a long way on world maps. You have to watch out for tight spaces though or you'll have to kill him just to get back out of them.

If you use an aggressive creature to deliver a message like this, might the player be able to see this as aggressive behavior?
You can always make the creature invulnerable if you don't want the player to be able to kill it. Of course, then you might get stuck like you mentioned. Unfortunately, if a creature is in 'attack' mode then if the player examines it, it will be listed as "(HOSTILE)" even if they are of the same alignment. So I don't think there's any way to make a creature follow the player but still be obviously friendly, unless you set up some sort of color-coded marking or other convention specific to your game.

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

GB wrote: I experimented with a weaponless gremlin. he does a good job of following, staying just one or two squares ahead or behind, and can follow a long way on world maps. You have to watch out for tight spaces though or you'll have to kill him just to get back out of them.
Also, I just thought of something else. Creatures can be restricted to only walk on a particular terrain. So, you could have a 'path' that your creature would follow (you could even make the path terrain invisible to the player) that restricts its movement to prevent it from backing the player into a corner.

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Post by GB »

Thank you for sharing those ideas, they are very interesting and may be useful. I'm going to have to try experimenting with that.

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Aggro

Post by GB »

I've been experimenting with these suggestions and browsing the docs. I note that the updates text says of the AGGRO variable that it tests whether the player is in combat, that is, has hostile creatures in view. So I suppose that if you have combat music set this will play when you have a hostile creature approaching, so in this event you'll be cued that he's not friendly whether you look or not.

I'm noticing a couple of weird things about room maps in the process of trying out these ideas, coming back to a room map after going to a world map isn't resetting the crim variable for the rooms map. Though crim information doesn't seem to be passed between world maps and room maps.

I have a macro set crim to 1 in a rooms map, am approached by a lawful creature, go back to the world map, am ignored by lawful creatures, go back to the room map, and the creature is still hostile to me.
Crim is set by a custom space floor tile that calls a macro with 3 functions, removing all instances of itself, removing another floor tile concealing a creature, setting crim to 1 and stop.

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Re: Aggro

Post by rld »

GB wrote:I'm noticing a couple of weird things about room maps in the process of trying out these ideas, coming back to a room map after going to a world map isn't resetting the crim variable for the rooms map. Though crim information doesn't seem to be passed between world maps and room maps.
Each region also has entrance and exit macros that you can set to be invoked when the player enters and leaves the region, so you might be able to work around this by setting the exit macro

SET CRIM = 0

for all your regions.

Post Reply