@ vampyre
Right, you would setup a variable for your character and NPC, say
Set up few general, global declarations (variables later used)
Global MaxPlayers : MaxPlayers=5
Global OurState
Global NPCState
#CONSTANT AVATAR_IDLE 1
#CONSTANT AVATAR_WALK 2
#CONSTANT AVATAR_POSSESED 3
#CONSTANT AVATAR_POSSESING 4
After that you would need to define some attributes for your character and NPC(trust me), using a type
type Attributes
ID as integer
x as integer
y as integer
z as integer
state as integer
endtype
Now delcare a variable for each the player and the NPC to assign the above Attributes to (effectively creating a small database for each character)
Dim Avatars(MaxPlayers) as Attributes
This has assigned the Attributes to all of '5' players (I know you only need 2 for this example but this shows how you can expand through optimisation)
Now, obviously, you need to create the avatar (rotten cubes for now

)
for i = 0 to array count(Avatars())
Avatars(i).ID = FreeObject()
make object cube Avatars(i).ID,10
'assign some random positions to each avatar (could use data here in future!)
Avatars(i).x = rnd(100)
Avatars(i).y = 0
Avatars(i).z = rnd(100)
position object Avatars(i).ID,Avatars(i).x,Avatars(i).y,Avatars(i).z
'set all avatars' states to IDLE
Avatars(i).state = AVATAR_IDLE
next i
'Assign MyChar variable to an object of Avatar array
MyChar = Avatar(0).ID 'this extracts the number into myChar
'Assign NPC to varaible
NPC = Avatar.(1).ID 'copies the object number into NPC
'Colour myChar red to denote as our player
color object MyChar,RGB(255,0,0)
A simple process. Don't worry about the 'FreeObject()' for now, ill explain later
Ok so now you have 5 cube seemingly independant from each other on your screen in random positions!
Now onto the 'possesion part'
Add simple controls to out Main player (MyChar)
do
'get our player state and NPC state for MyChar and NPC
OurState = Avatar(0).state
NPCState = Avatar(1).state
'basic player controls for movement
if OurState = AVATAR_IDLE or OurState = AVATAR_WALK then Move_Object(MyChar, OurState) 'move myChar if we are not possessing NPC
if OurState = AVATAR_POSSESING then Move_Object(NPC, NPCState) 'moves NPC using same controls to give illusion of possession
'Posses the NPC
if controlkey()=1 then OurState = AVATAR_POSSESING
'state of NPC
if OurState = AVATAR_POSSESING then NPCstate = AVATAR_POSSESED
sync
loop
So, now we need to create the movement part of the code in the form of 'Move_Object(Object)' function
Function move_Object(ObjectNo, state)
select state
case AVATAR_IDLE 'is the value 1?
if ObjectNo = MyChar and upkey()=1 then avatar(0).state = AVATAR_WALK
if ObjectNo = NPC and upkey()=1 then avatar(1).state = AVATAR_WALK
end case
case AVATAR_WALK 'is the value 1?
if ObjectNo = MyChar then move object MyChar,5
if ObjectNo = MyChar and upkey()=0 then Avatar
if leftkey()=1 and ObjectNo = MyChar then yrotate object MyChar,object angle y(MyChar) - 1
if rightkey()=1 and ObjectNo = MyChar then yrotate object MyChar,object angle y(MyChar) + 1
(0).state = AVATAR_IDLE
if ObjectNo = NPC and upkey()=0 then Avatar(1).state = AVATAR_IDLE
end case
case AVATAR_POSSESING 'is the value 4?
if ObjectNo = NPC then move object NPC,5
if leftkey()=1 and ObjectNo = NPC then yrotate object NPC,object angle y(NPC) - 1
if rightkey()=1 and ObjectNo = NPC then yrotate object NPC,object angle y(NPC) + 1
if controlkey()=0 then OurState = AVATAR_IDLE : NPCState = AVATAR_IDLE
Endfunction
Basically this code moves the appropriate player based on what state the main player is in. Its only simple so the basics should work, you coul always expand on it
Now about the 'FreeObject()' function. This is a great little function that finds a free object number in the system. You should always assign a varaible name to the free object found for manipulation. Its more object orientated than anythign else.
function FreeObject()
repeat
inc i
if object exist(i)=0 then found=1
until found
endfunction i
The function return the object number 'i' to where the function was invked (in this case into the variable Avatar(i).ID' effectively creating MaxPlayer Amount (10) free objects. PUT THIS AFTER MAIN LOOP
Hope that helps. I wrote entierely in the annoying little message windown and havn'et complied it. If it doesnt work email or tell me here and i'' check back soon.