Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, Ayumi, 1 invisible), 708 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Alignment Problem... #172325
12/11/07 20:06
12/11/07 20:06
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
I am having a problem with this function. It creates a projectile that is supposed to appear aligned to the player. It appears aligned only sometimes. I don't understand it because I have made similar functions in the past with no problems, it should be simple right?

Code:

//use action
function init_use_action()
{

//locals
var init_spell;
init_spell = off;

//terminate if already in progress
if(my.current_state == _state_use){return;}

//setup this state
my.current_state = _state_use;
my.anim_new_scene = my.scene_use;

//loop while state is valid
while(my.anim_dist < 100)
{

//cancel still count
my.still_count = 0;

//execute only if player is aligned to camera
if(my.pan <= camera.pan + 10 && my.pan >= camera.pan - 10)
{

//wait for animation blending
while(my.anim_dist == -1){wait(1);}

//handle creation of spell
if(my.anim_dist > 10 && init_spell == off)
{
init_spell = on;

//create spell
you = ent_create("temp.mdl",my.x,mis_generic);
vec_set(you.pan,my.pan);
}

//animate for current state
my.anim_dist += (8 * time_step);
ent_animate(me,my.anim_new_scene,my.anim_dist,anm_cycle);

//while using, rotate with mouse force
my.pan -= (mouse_force.x * 5) * time_step;

}

//align to camera
pl_rotate(camera.pan,20);

wait(1);
}

//update states
my.scene_idle = "idle";
my.last_state = my.current_state;
wait(1);
init_idle_action();
}



Here is the function of the created entity and its event function.

Code:

//generic spell projectile event
function event_mis_generic()
{

//on impact with entity
if(event_type == event_entity){my.hp = 0;}

//on impact with block
if(event_type == event_block){my.hp = 0;}
}


Code:

//generic spell projectile
function mis_generic()
{

//setup
setup_bb();
my.roll = random(360);
my.passable = on;
// my.invisible = on;
my.hp = 1;

//setup events
my.enable_entity = on;
my.enable_block = on;
my.event = event_mis_generic;

//while in effect
while(my.hp > 0)
{

//make unpassable if 'old' enough
my.hp += (1 * time_step);
if(my.hp > 10){my.passable = off;}

//move me
c_move(me,vector(30,0,0),nullvector,ignore_passable|use_box);

//roll
my.roll += (15 * time_step);

wait(1);
}
ent_remove(me);
return;
}



Things that I have already tested:

The player's origin is centered, no problems there. The "temp.mdl" is a simple diamond shape and its origin is in the center as well.

For $h!ts and giggles, I commented out the c_move and make unpassable part to see if it appears a befunkled alignment and it is aligned to the center correctly so I can't figure it is a problem with anything else.


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Alignment Problem... [Re: draculaFactory] #172326
12/13/07 20:22
12/13/07 20:22
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
jesus why do i bother posting anymore?


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Alignment Problem... [Re: draculaFactory] #172327
12/14/07 23:20
12/14/07 23:20
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline
User
JazzDude  Offline
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
I can't see anything wrong but here's a suggestion:

Quote:

if(my.pan <= camera.pan + 10 && my.pan >= camera.pan - 10)




You might try putting that in a while condition or using || instead of &&

Also, have you checked the bounding boxes by hitting F11 twice?

Just shots in the dark from a klutz koder.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1