How to add/remove a NPC? (SOLVED in under a minute!)

Started by EnterTheStory (aka tolworthy), Mon 17/12/2007 20:54:39

Previous topic - Next topic

EnterTheStory (aka tolworthy)

I know this has to be blindingly obvious. but I've searched for enter/leave/add/delete/remove/and all the other terms I can think of, in both the manual and the forums, and I'm stumped. How to I add a non player character to a room where they did not start? How do I remove a non player character?

My immediate need is for a very large scrolling text box, and after finding that the credits module doesn't compile in 2.72, the credits plugin doesn't work in Linux, and the scrolling module needs a later version, it seemed like the simplest thing to do is write the text on a bitmap and add it as a character. But I searched for "add character" or "character.delete" in vain. I'm sure there's something very simple that I'm missing here.

EDIT: after posting this I found a reference to "character.changeroom" - is that the answer? Maybe my problem is I'm too bloodthirsty. I assumed that I had the right to create and destroy characters at will (isn't the whole point of a game to satisfy one's god-complex?) But it looks like characters have to be treated with respect. Maybe I shouldn't be applying the meat cleaver every time I want some personal space, maybe I just need to suggest the character leaves when they are not wanted.

Scorpiorus

It's "change" :)

Code: ags

cSomeNpc.ChangeRoom( 4); // put them in room 4
cSomeNpc.ChangeRoom(-1); // remove


See the manual for additional info on the subject.

Candall

You use the character.ChangeRoom(); function just as if said character were the PC.  You can also set x and y coordinates as parameters to have your player start offscreen and walk on if you so desire.

EnterTheStory (aka tolworthy)

Quote from: Candall on Mon 17/12/2007 21:02:40You can also set x and y coordinates as parameters to have your player start offscreen and walk on if you so desire.
You mean ego can start off a floor and walk onto the nearest one? I thought the only way to get to a floor was to jump to the nearest one. Or do you mean using eAnywhere to force them along a scripted path?

PS thanks for the quick response. Is this the fastest forum on earth? :)

Candall

Quote from: tolworthy on Mon 17/12/2007 21:06:07
Or do you mean using eAnywhere to force them along a scripted path?

Yup, that.  It was probably obvious, but worth mentioning.

Ashen

A scripted path is the only way to walk to a Walkable Area - but maybe you could use a dummy Character to automate it.

- Check if cEgo isn't standing on a Walkable Area (if (GetWalkableAreaAt(player.x-GetViewportX(), player.y - GetViewportY()) == 0)),
- If not, bring cDummy to the Room at the same coords (cDummy.ChangeRoom(player.Room, player.x, player.y);) and 'jump' them to a Walkable Area (cDummy.PlaceOnWalkableArea();).
- Walk cEgo to cDummys new location, using eAnywhere (player.Walk(cDummy.x, cDummy.y, eBlock, eAnywhere);).

Call that code from the Global on_event, and you should be good.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk