1 registered members (AndrewAMD),
1,089
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Shoots to the moon
[Re: mschoenhals]
#454494
09/09/15 14:18
09/09/15 14:18
|
Malice
Unregistered
|
Malice
Unregistered
|
In your gravity code, you may be using the flag USE_BOX.
Don't!
But to be of any help you will need to post the players action, Also check the BBOX size. Last this can happen with unchecked frame rates like windowed at 300. It could also be that your gravity code is actually doing the pushing.
Last edited by Malice; 09/09/15 14:20.
|
|
|
Re: Shoots to the moon
[Re: mschoenhals]
#454499
09/09/15 17:40
09/09/15 17:40
|
Malice
Unregistered
|
Malice
Unregistered
|
Yuck template code... I'd be happy to look at the door action, if I had any clue where in the template stack it is.
Let me dig
|
|
|
Re: Shoots to the moon
[Re: ]
#454501
09/09/15 17:45
09/09/15 17:45
|
Malice
Unregistered
|
Malice
Unregistered
|
// skill1: speed 4
// skill2: key 0
// skill3: offset_x 0
// skill4: offset_y 0
// skill5: offset_z 200
// skill6: swing 0
// skill7: angle 90
// skill8: open_manually 0
action t_door()
{
while (!player) {wait (1);} // wait until the player is loaded
vec_set (my.skill61, my.x); // store the xyz initial position of the door inside skill61... 63
my.skill64 = my.pan; // store the initial pan angle
if (my.speed == 0)
my.speed = 4;
if (my.offset_z == 0)
my.offset_z = 200;
if (my.angle == 0)
my.angle = 90;
while (1)
{
c_scan(my.x, my.pan, vector(360, 180, t_door_range), IGNORE_ME | SCAN_ENTS); // each door scans around it, trying to detect the player
if (you) // detected an entity?
{
if (you == player) // and that entity is the player?
{
if (my.open_manually) // need to press a key in order to open the doors?
{
if(key_pressed(key_for_str(key_open))) // the "open" key was pressed?
{
if (my.skill2 > 0) // this door needs a key?
{
if (player.skill70 == my.skill2) // the player has got the proper key? then let's open the door!
{
t_open_doors(); // this function opens the doors
return;
}
else // the player doesn't have the needed key?
{
wait (1); // don't do anything
}
}
else // the door doesn't need a key
{
t_open_doors(); // this function opens the doors
return; // the action stops afterwards
}
}
}
else // the door opens automatically
{
if (my.skill2 > 0) // this door needs a key?
{
if (player.skill70 == my.skill2) // the player has got the proper key? then let's open the door!
{
t_open_doors(); // this function opens the doors
return; // the action stops afterwards
}
}
else // this door doesn't need a key
{
t_open_doors(); // this function opens the doors
return; // the action stops afterwards
}
}
}
}
wait (1);
}
}
Please explain, should the door open auto or on keypress? I not sure I can help as I never use template code.
Last edited by Malice; 09/09/15 17:49.
|
|
|
Re: Shoots to the moon
[Re: ]
#454515
09/09/15 20:35
09/09/15 20:35
|
Joined: Aug 2013
Posts: 101
mschoenhals
OP
Member
|
OP
Member
Joined: Aug 2013
Posts: 101
|
I created the door code from another tutorial as the one in the RPG didn't have one. The player can open doors, but ejection to the moon takes place. Here's my door code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Template rpg doors and keys
// Written by Mike Schoenhals, May 11th, 2015.
// based on the Tutorial code by Bandicam, Devon Lively
//DOOR MUST HAVE BOUNDING BOX FLAG ENABLED!!!!!!!
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define key skill1
#define key skill2
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var door_range = 120; //scan distance of door to player
var key_rotating_speed = 5; //how fast should the key rotate when visible
STRING* got_key_wav = "gotkey.wav"; //sets the file name for getting a key
STRING* door_opens_wav = "dooropens.wav"; //sets the file name for opening the door
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function key_collision()
{
if (you == player)
{
my.skill67 = 1;
}
}
//Below is a define skill statement needed for the customizable window in WED. Note how they are commented out.
// skill1: key 0
action keys()
{
set (my, PASSABLE); // the key is passable
while (!player) {wait (1);} // wait until the player model is loaded
while (vec_dist (player.x, my.x) > 50) // wait until the player comes close to the key
{
my.pan += 5 * time_step; // rotate while waiting for the player
wait (1);
}
player.skill70 = my.skill1; // now pass the value set inside the key's skill1 using Wed to player's skill70
SND_CREATE_STATIC(got_the_key, got_key_wav);
snd_play(got_the_key, 80, 0); // play the "got the key" sound
set (my, INVISIBLE); // make the key invisible
wait (-1);
ent_remove(my); // and then remove it after a second
}
function open_doors() // this function is called by each door
{
set(me, POLYGON | SHADOW);
var door_swing_speed = 5;
var closed_pan = my.pan;
var OPEN_OR_CLOSED = 0;
// if (is(my.FLAG1)) {OPEN_OR_CLOSED = 1;my.pan+=90;closed_pan = my.pan-90;}
VECTOR door_handle;
vec_for_vertex(door_handle, me, 1);
while(1){wait(1);
if(vec_dist(door_handle.x, player.x) < 100 && my.pan == closed_pan){
set(me, PASSABLE);
while(my.pan < closed_pan+90){wait(1);my.pan+=door_swing_speed;}
SND_CREATE_STATIC(door_opens, door_opens_wav); // play the "door opens" sound
snd_play(door_opens, 100, 0);
// door_sounds(); //runs the function for sounds below.
reset(me, PASSABLE);
while(key_enter){wait(1);}
}
}
}
// skill2: key 0
action door()
{
while (!player) {wait (1);} // wait until the player is loaded
vec_set (my.skill61, my.x); // store the xyz initial position of the door inside skill61... 63
my.skill64 = my.pan; // store the initial pan angle
while (1)
{
c_scan(my.x, my.pan, vector(360, 180, door_range), IGNORE_ME | SCAN_ENTS); // each door scans around it, trying to detect the player
if (you) // detected an entity?
{
if (my.skill2 > 0) // this door needs a key?
{
if (player.skill70 == my.skill2) // the player has got the proper key? then let's open the door!
{
open_doors(); // this function opens the doors
return; // the action stops afterwards
}
}
else // this door doesn't need a key
{
open_doors(); // this function opens the doors
return; // the action stops afterwards
}
}
wait (1);
}
}
|
|
|
Re: Shoots to the moon
[Re: mschoenhals]
#454517
09/09/15 21:10
09/09/15 21:10
|
Malice
Unregistered
|
Malice
Unregistered
|
//DOOR MUST HAVE BOUNDING BOX FLAG ENABLED!!!!!!! Your door is actually using the POLYGON flag not a bounding box. Both player and doors should not use POLYGON but actual BBoxs What and where is this skill set? If you know?
if(vec_dist(door_handle.x, player.x) < 100 && my.pan == closed_pan){
set(me, PASSABLE);
Your setting the door passable, is the gravity trace using IGNORE_PASSABLE flag? You actually should not set the door passable. What might be happening is a timing error. You set the door passable, then walk in to it, the reset passable - making it solid. That will cause the player bbox to be in the door as well as the gravity trace to be in the door. Gravity trace hitting inside a door will cause a negative trace return, which would cause the player to fly upward.
c_scan(my.x, my.pan, vector(360, 180, door_range), IGNORE_ME | SCAN_ENTS); // each door scans around it, trying to detect the player
if (you) // detected an entity?
This scan should also IGNORE_PASSABLE or IGNORE_PASSENTS Also after the '''if(you)''' you need to do another check for either the '''player''' pointer or some or id var, otherwise the scan can be trigger by others. - Although that is a potential problem not a real one at the moment.
while(key_enter){wait(1);}
not sure why the nested loop to wait. EDITED HEAVILY Mal
Last edited by Malice; 09/09/15 21:20.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|