Jump to content

Photo

NPC (Non Playable Character) coding questions


  • Please log in to reply
3 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 19 June 2018 - 12:45 AM

I would like my questions answered similar to
Screen->Message(85);
for example please, thank you.



#1: How do I choose a tile as an image for an npc?



#2: How do I choose the size (width and height) of the image for the npc?



#3: How do I destroy the npc?



#4: If I want an npc to move left 18 pixels how would I do it?



#5: If I want it if there is nothing solid 18 pixels to the left of npc the npc moves left by 18 pixels how would I code it?



#6: How do I set how much health the npc has?



#7: If I want an npc to look as close as possible to Gleeok Fire (1 head) how would I do so?

#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 19 June 2018 - 02:14 PM

I would like my questions answered similar to

Screen->Message(85);
for example please, thank you.



#1: How do I choose a tile as an image for an npc?

 

 

 

npc->Tile

 

#2: How do I choose the size (width and height) of the image for the npc?


npc->TileWidth, npc->HitWidth, npc->TileHeight, npc->HitHeight
 

#3: How do I destroy the npc?

 

 

Remove(identifier), which does this:

n->DrawYOffset = -32768;
n->X = -32768;
n->HP = HP_SILENT;

#4: If I want an npc to move left 18 pixels how would I do it?

 

npc->X -= 18;

 

#5: If I want it if there is nothing solid 18 pixels to the left of npc the npc moves left by 18 pixels how would I code it?

 

if (!(Screen->isSolid(n->X-18, n->Y)) { n->X -= 18; }
 

#6: How do I set how much health the npc has?

 

npc->HP = amount;
 

#7: If I want an npc to look as close as possible to Gleeok Fire (1 head) how would I do so?


You can set the gleeok head tile to a flying/floating npc in the enemy edior. ;)

 

In all of these examples, npc-> should be a valid pointer to an npc. You establish a pointer first, then load an npc to it, or create an npc using it.

npc n = Screen->LoadNPC(2); //Loads Screen NPC index 2 into the pointer 'n'.
// This is normally done after establishing how many npcs are on the screen with Screen->NumNPCs().
npc m = Screen->CreateNPC(30); //creates an npc of ID 30. The pointer is 'm'.
 
n->X -= 18; //moves pointer 'n'.
m->Tile = 100; //Changes the tile of pointer 'm'.


#3 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 19 June 2018 - 02:25 PM

Awesome thank you

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 19 June 2018 - 08:30 PM

Awesome thank you

 

Not a problem. Just be aware that ZC considers npcs to be enemies. I don't know your intent here.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users