User Tools

Site Tools


cerea2:build:followmode

Making NPCs follow

How it works

following is controlled by 3 variables:

FollowModeIntIf set to 1, will follow the object given in FollowObject
FollowObjectobjectwhen FollowMode is set to 1, will follow this object
FollowCombatIntUsed with FollowMode. If set to 1, will continue to follow even in combat, if 0, will stop following in combat and restart after it

The heartbeat script chekcs for follow mode and if set checks for follow object and combat state.

If the follow object is not valid will cancel follow mode, wait for for 10 minutes in that location and will then automatically start walkking waypoints again.

Using

There are several helpfull scripts as interface to the followmode in conversations.

ca_g_followmode

Action taken script for conversations to start and stop following.

Normal usage: ca_g_followmode(1,0,0,0) to start follow
ca_g_followmode(0,0,0,10) to end.

Takes 4 parameters

nFollow

type: int
setting nFollow to 1 makes the NPC start following PC
setting to 0 will make it stop

nPerception

type: int
setting nPerception to 1 will make the NPC react normally to seen things
setting to 0 will make it ignore perception until attacked.

nFollowInCombat

type: int
setting nFollowInCombat to 1 will make the creature follow even in combat
setting to 0 will make follow only when not in combat.

fDelay

type: float fDelay is the time to wait after stop follow before start walking waypoints again.

Notes

This script enables and disable walking of waypoints to make the following work.

cc_g_isfollowing

Conversation conditional script used to check if NPC is following anyone

Normal usage: are we following the speaker: cc_g_isfollowing(0)
are we following someone else: cc_g_isfollowing(-1)
are we following anyone at all: cc_g_isfollowing(1)

Returns true if the NPC is following and fullfills the requirement given in nAnyone

Has one parameter

nAnyone

type: int

if nAnyone is set to 1 will return true for following anyone
if nAnyone is set to 0 will only return true if following PCspeaker.
if nAnyone is set to -1 will only return true if following someone else not PC

cc_g_checkarea

Used to check if the NPC is in given area for quests of type: take me to “area” Normal usage: cc_g_checkarea(“a_vesper”) will return true if the npc is in Vesper.

one parameter:

sTag

stype: string
Give the area tag as the parameter, if the NPC is currently in that area, return TRUE, else false.

cc_g_checknear

Used to check if the NPC is near another object for quests of type: take me to “creature/exact place”

Normal usage: cc_g_checknear(“WP_nayegates”,20.0) will return true if the npc is within 20.0 meters from nayebay gates.

Give the tag of object and distance as parameter, if the NPC is currently that distance of less from the object, return TRUE, else false.

Has two paramters:

sTag

type:string Tag of the object to be near. This can be any object type, but does not work for items inside objects. Typically is a waypoint or creature tag.

fDistance

type:float Have to be this close to the given object to return true. Remember that the NPC folows at few meters distance from you so normally a paramater of less that 10.0 will cause problems. 15-20 is normally a good choise.

Example convo

whoconditionalsay whatactiontakenNote
NPCcc_g_isfollowing(-1)Hi As following someone else, just greet
NPCcc_g_isfollowing(0)Hi, there yet? As following PC, ask if we arrived
-PC nope Generic reply
-PC cc_g_checkarea(“a_vesper”)Yes we are ca_g_followmode(0,0,0,10) disable follow mode
ca_g_q_success(“QUEST_MY_MY”) <and set quest to success
NPCcc_g_q_running(“QUEST_MY_MY”)Continue? Not following anyone but PC has quest going(like PC crashed)
NPCNOT cc_g_checkarea(“a_tk_dyoa”)Hi Just say greeting and exit if not in start area
NPCcc_g_canstart(“QUEST_MY_MY”)Take me to Vesper! can start the quest so say things and such
-PC No pc declines
-PC Sureca_g_followmode(1,0,0,0) PC agrees so set follow mode
ca_g_q_setstate(“QUEST_MY_MY”,1) and start the quest
NPC Hi done

Overall notes on NPCs

Setting the NPC to immortal allows PC to raise/heal the NPC back, not setting effectively fails quest on NPC death.

Setting the perception flag to 1 in follow causes the NPC to do normal actions like attack enemies it sees so makes the quest much harder.

Note that the NPCs are still neutral to PCs with this so they are affected by some spells.

cerea2/build/followmode.txt · Last modified: 2015/05/03 12:32 by 127.0.0.1