Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.56 KB

B_MoveMob.md

File metadata and controls

34 lines (26 loc) · 1.56 KB

B_MoveMob

How to open doors

High Level concept description

oCMobDoor object has 2 free positions:

  1. FRONT
  2. BACK

oCMobDoor FRONT & BACK

This information is stored in zCList<TMobOptPos> oCMobInter.optimalPosList in nodeName:

class TMobOptPos {
	var int trafo[16];	//zMAT4
	var int distance;	//int
	var int npc;		//oCNpc*
	var string nodeName;	//zSTRING
};

When engine searches for free positions oCMobInter::SearchFreePosition for NPC, it will update oCMobDoor.addName with nodeName of a position that is closer to NPC.

With this we can figure out where NPC is standing and where it needs to go: oCMobDoor BACK & FRONT vector

So how do we open and close doors then?

  1. NPC goes to the doors.
  2. With AI_UseMobPtr_Ext (self, vobPtr, 1, "UNLOCK"); (function from AFSP) NPC will unlock doors (if locked) and will open them.
  3. We will use both free positions (FRONT & BACK) to calculate target position, where NPC needs to go to once doors are open.
  4. NPC goes to new calculated target position.
  5. NPC will either use AI_UseMobPtr (self, vobPtr, 0); function or AI_UseMobPtr_Ext (self, vobPtr, 0, "LOCK"); if doors were locked before to close them.
  6. NPC goes to position of next waypoint in its route AI_GotoPos (self, _@ (nextWP.pos)); - this is important, because if NPC would try to use 'vanilla' navigation method, it might go back to previous waypoint (if it is nearest one, and would get stuck on the door opening/closing them)