SetPlayer() and other stuff...
Displaying 1-3 of 3 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
happy

Hello,

I wanted to create some code that would take away control from the player for a while and then give it back to him/her, and started off using

int player = EntitySpawn(blah blah);

void TogglePlayerControl(int on)
{
if(on) { SetPlayer(player); } else { SetPlayer(0-1); }
}

This does indeed take control from the player, but the camera seems to jump back to the top-left corner of the map! Do I need to dick about with the cameratracker and cameratracking vars to avoid this?

Also, I had a go making a WaitForEntity() function and came up with this... is there a better way to do this?

void WaitForEntity(int ent, string script)
{
TogglePlayerControl(0);

MoveEntity(ent, script);
while(entity.movecode[ent] == 3)
{
Render();
ShowPage();
}

TogglePlayerControl(1);
}

Thanks for your time, guys!

Posted on 2007-09-03 08:07:31

Overkill

Quote:Originally posted by happy

Hello,

I wanted to create some code that would take away control from the player for a while and then give it back to him/her, and started off using

This does indeed take control from the player, but the camera seems to jump back to the top-left corner of the map! Do I need to dick about with the cameratracker and cameratracking vars to avoid this?

Also, I had a go making a WaitForEntity() function and came up with this... is there a better way to do this?

void WaitForEntity(int ent, string script)
{
TogglePlayerControl(0);

MoveEntity(ent, script);
while(entity.movecode[ent] == 3)
{
Render();
ShowPage();
}

TogglePlayerControl(1);
}

Thanks for your time, guys!


Yep, set cameratracking to 0 to allow user control of the camera (that is, it won't change unless you alter xwin/ywin), cameratracking to 1 when you're following the player, cameratracking to 2 when you're following cameratracker (an entity index). That make
int player = EntitySpawn(blah blah);

void TogglePlayerControl(int on)
{
if(on)
{
cameratracking = 1;
SetPlayer(player);
}
else
{
cameratracking = 0;
SetPlayer(-1);
}
}


Also, if your WaitForEntity thing works, it's probably a good way to do it. I've been wondering about how to make scripts pause for non-player entity movements (PlayerMove() does Render()/ShowPage() until the animation finishes). I was sort timing animations as they went along and had a Wait() function that would specify a delay directly after EntityMove(). Your idea's way better though. Although... I don't think you need to toggle the player control, since the player entity controls are only processed when there's no VC functions active.

Posted on 2007-09-03 09:55:12 (last edited on 2007-09-03 09:57:56)

happy

Ah, thanks for that, cheers. Yep, my WaitForEntity thing works just dandy, I just wasn't sure whether I was doing it in a retarded way.

Posted on 2007-09-04 08:08:51


Displaying 1-3 of 3 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.