|
|
Can't get character to pick up item
#132631
05/29/07 23:55
05/29/07 23:55
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
This is kinda my first shot at an actual "game" (just a pick 'em up). What I can't figure out is why my guy won't pick up my items! I tried this code for the pick-up: Code:
action get_item1 { while(1) { my.pan+= 4 * time_step; if(event_type== event_entity) { items= items + 1; ent_remove(my); } wait(1); } }
but the only part that works is the my.pan bit. It's the exact same for the other two, get_item2 and get_item3 (they would all disappear if I used one action for all the items). It's probably one of those problems where you wanna kick yourself when you realize the simplicity of the answer (  ), but I really don't get it. Should I be using event_entity? I think that might be it, but I'm not sure what to use instead. So, can anyone point me in the right direction (no matter how kick-yourself-worthy it is,  )?
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
Re: Can't get character to pick up item
[Re: MrCode]
#132632
05/30/07 06:32
05/30/07 06:32
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
Try something like this... Code:
function item_event { if(event_type == event_entity) && (you == player) { ent_remove(me); } }
action item_action { my.eneble_entity = on; my.event = item_event; while(me); { my.pan += 4* time_step; wait(1); } } And remember about bounding boxes or use polygon detection
Never say never.
|
|
|
Re: Can't get character to pick up item
[Re: tompo]
#132633
05/30/07 22:51
05/30/07 22:51
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Um, it didn't work. Is the code in the wrong place? Here's the whole thing: Code:
var video_mode= 8; var video_screen= 1; var video_depth= 32;
var walk_speed; var breath_speed; var jump_speed; var run_speed; var mouseSensitivity= 10; var mouseInvert= 1;
var items;
string level_wmb= <weird_room.wmb>;
string racer_mdl= "racer1new.mdl"; string earth_mdl= "earth_distort.mdl"; string sprite_pcx= "wroom_side.pcx"; string char= "char.mdl"; string dragrcr_mdl= "drgrcr.mdl";
sound duh_wav= "the_duhds.wav"; sound morph_wav= "morph.wav"; sound tada= "tada.wav";
bmap side_pcx= "wroom_side.pcx"; bmap other_side_pcx= "wroom_side2.pcx"; bmap congrats_pcx= "congrats.pcx";
function play_duh_snd() { snd_play (duh_wav,100,0); }
function main() { level_load (level_wmb); wait(3); on_d= play_duh_snd; mouse_look(); }
function item_event { if(event_type == event_entity) && (you == player) { items= items + 1; ent_remove(me); } }
action item_action1 { my.enable_entity = on; my.event = item_event; while(me) { my.pan += 4 * time_step; wait(1); } }
action item_action2 { my.enable_entity = on; my.event = item_event; while(me) { my.pan += 4 * time_step; wait(1); } }
action item_action3 { my.enable_entity = on; my.event = item_event; while(me) { my.pan += 4 * time_step; wait(1); } }
action rotate { while(1) { my.pan+= 1 * time_step; wait(1); } }
action morpher { player= me; my.enable_entity= on; my.fat= on; my.narrow= on; c_setminmax(my); while(1) { if(key_t== on) { c_move(my,vector(6 * time_step,0,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= 7 * time_step; } else { ent_animate(my,"stand",breath_speed,anm_cycle); breath_speed+= 3 * time_step; } if(key_g== on) { c_move(my,vector(-6 * time_step,0,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= -7 * time_step; } if(key_f== on) { my.pan+= 10 * time_step; } if(key_h== on) { my.pan-= 10 * time_step; } if(mouse_left== on) { c_move(my,nullvector,vector(0,0,15 * time_step),glide); ent_animate(my,"jump",jump_speed,anm_cycle); jump_speed+= 14 * time_step; } else { c_move (my,nullvector,vector(0,0,-15 * time_step),glide); } if(key_m== on) { snd_play (morph_wav,100,0); wait(-1); ent_morph (my,racer_mdl); wait(-1); ent_morph (my,earth_mdl); wait(-1); ent_morph (my,dragrcr_mdl); wait(-1); ent_morph (my,sprite_pcx); wait(-1); ent_morph (my,char); wait(1); my.pan= 0; } if(mouse_right== on) && (key_t== on) { c_move(my,vector(10 * time_step,0,0),nullvector,glide); ent_animate(my,"run",run_speed,anm_cycle); run_speed+= 9 * time_step; } wait(1); } }
action platform_rotate { while(1) { if(event_type== event_entity) { my.pan+= 2 * time_step; } wait(1); } }
panel side_pan { pos_x= 0; pos_y= 640; bmap= side_pcx; alpha= 100; flags= visible, overlay, filter, transparent; }
panel other_side_pan { pos_x= 740; pos_y= 640; bmap= other_side_pcx; alpha= 100; flags= visible, overlay, filter, transparent; }
panel end_game { pos_x= 320; pos_y= 240; bmap= congrats_pcx; alpha= 100; flags= overlay, filter, transparent; }
function success() { while(1) { side_pan.alpha-= 1 * time_step; if(side_pan.alpha<= 0) { side_pan.visible= off; } other_side_pan.alpha-= 1 * time_step; if(other_side_pan.alpha<= 0) { other_side_pan.visible= off; } end_game.alpha+= 1 * time_step; wait(1); snd_play(tada,100,0); wait(1); } }
function score_tracker() { if(items== 3) { success(); } }
function mouse_look() { while(1) { camera.pan-= mouse_force.x * mouseSensitivity * time_step; camera.tilt+= mouse_force.y * mouseSensitivity * mouseInvert * time_step; wait(1); } }
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
Re: Can't get character to pick up item
[Re: MrCode]
#132634
05/30/07 22:54
05/30/07 22:54
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile

3D Artist
|

3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
I Think it must be lower than ure Player Action... maybe move this under the Player Action... Because he wants Player==1
cYa Sebastian
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: Can't get character to pick up item
[Re: rvL_eXile]
#132635
05/30/07 23:00
05/30/07 23:00
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Nope, still nuthin'. I hope there's nothing else wrong! Code:
var video_mode= 8; var video_screen= 1; var video_depth= 32;
var walk_speed; var breath_speed; var jump_speed; var run_speed; var mouseSensitivity= 10; var mouseInvert= 1;
var items;
string level_wmb= <weird_room.wmb>;
string racer_mdl= "racer1new.mdl"; string earth_mdl= "earth_distort.mdl"; string sprite_pcx= "wroom_side.pcx"; string char= "char.mdl"; string dragrcr_mdl= "drgrcr.mdl";
sound duh_wav= "the_duhds.wav"; sound morph_wav= "morph.wav"; sound tada= "tada.wav";
bmap side_pcx= "wroom_side.pcx"; bmap other_side_pcx= "wroom_side2.pcx"; bmap congrats_pcx= "congrats.pcx";
function play_duh_snd() { snd_play (duh_wav,100,0); }
function main() { level_load (level_wmb); wait(3); on_d= play_duh_snd; mouse_look(); }
function item_event { while(1) { if(event_type == event_entity) && (you == player) { items= items + 1; ent_remove(me); } wait(1); } }
action rotate { while(1) { my.pan+= 1 * time_step; wait(1); } }
action morpher { player= me; my.enable_entity= on; my.fat= on; my.narrow= on; c_setminmax(my); while(1) { if(key_t== on) { c_move(my,vector(6 * time_step,0,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= 7 * time_step; } else { ent_animate(my,"stand",breath_speed,anm_cycle); breath_speed+= 3 * time_step; } if(key_g== on) { c_move(my,vector(-6 * time_step,0,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= -7 * time_step; } if(key_f== on) { my.pan+= 10 * time_step; } if(key_h== on) { my.pan-= 10 * time_step; } if(mouse_left== on) { c_move(my,nullvector,vector(0,0,15 * time_step),glide); ent_animate(my,"jump",jump_speed,anm_cycle); jump_speed+= 14 * time_step; } else { c_move (my,nullvector,vector(0,0,-15 * time_step),glide); } if(key_m== on) { snd_play (morph_wav,100,0); wait(-1); ent_morph (my,racer_mdl); wait(-1); ent_morph (my,earth_mdl); wait(-1); ent_morph (my,dragrcr_mdl); wait(-1); ent_morph (my,sprite_pcx); wait(-1); ent_morph (my,char); wait(1); my.pan= 0; } if(mouse_right== on) && (key_t== on) { c_move(my,vector(10 * time_step,0,0),nullvector,glide); ent_animate(my,"run",run_speed,anm_cycle); run_speed+= 9 * time_step; } wait(1); } }
action platform_rotate { while(1) { if(event_type== event_entity) { my.pan+= 2 * time_step; } wait(1); } }
action item_action1 { my.enable_entity = on; my.event = item_event; while(me) { my.pan += 4 * time_step; wait(1); } }
action item_action2 { my.enable_entity = on; my.event = item_event; while(me) { my.pan += 4 * time_step; wait(1); } }
action item_action3 { my.enable_entity = on; my.event = item_event; while(me) { my.pan += 4 * time_step; wait(1); } }
panel side_pan { pos_x= 0; pos_y= 640; bmap= side_pcx; alpha= 100; flags= visible, overlay, filter, transparent; }
panel other_side_pan { pos_x= 740; pos_y= 640; bmap= other_side_pcx; alpha= 100; flags= visible, overlay, filter, transparent; }
panel end_game { pos_x= 320; pos_y= 240; bmap= congrats_pcx; alpha= 100; flags= overlay, filter, transparent; }
function success() { while(1) { side_pan.alpha-= 1 * time_step; if(side_pan.alpha<= 0) { side_pan.visible= off; } other_side_pan.alpha-= 1 * time_step; if(other_side_pan.alpha<= 0) { other_side_pan.visible= off; } end_game.alpha+= 1 * time_step; wait(1); snd_play(tada,100,0); wait(1); } }
function score_tracker() { if(items== 3) { success(); } }
function mouse_look() { while(1) { camera.pan-= mouse_force.x * mouseSensitivity * time_step; camera.tilt+= mouse_force.y * mouseSensitivity * mouseInvert * time_step; wait(1); } }
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
Re: Can't get character to pick up item
[Re: MrCode]
#132636
05/30/07 23:03
05/30/07 23:03
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile

3D Artist
|

3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
ohh.. take this "my.event = item_event;" into the Player Action... Because the player must touch the entity and process the Function My Last Hope  cYa Sebastian
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: Can't get character to pick up item
[Re: rvL_eXile]
#132637
05/30/07 23:12
05/30/07 23:12
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Ok, this is really frustrating!  It still won't work! I tried this: Code:
var video_mode= 8; var video_screen= 1; var video_depth= 32;
var walk_speed; var breath_speed; var jump_speed; var run_speed; var mouseSensitivity= 10; var mouseInvert= 1;
var items;
string level_wmb= <weird_room.wmb>;
string racer_mdl= "racer1new.mdl"; string earth_mdl= "earth_distort.mdl"; string sprite_pcx= "wroom_side.pcx"; string char= "char.mdl"; string dragrcr_mdl= "drgrcr.mdl";
sound duh_wav= "the_duhds.wav"; sound morph_wav= "morph.wav"; sound tada= "tada.wav";
bmap side_pcx= "wroom_side.pcx"; bmap other_side_pcx= "wroom_side2.pcx"; bmap congrats_pcx= "congrats.pcx";
function play_duh_snd() { snd_play (duh_wav,100,0); }
function main() { level_load (level_wmb); wait(3); on_d= play_duh_snd; mouse_look(); }
function item_event { while(1) { if(event_type == event_entity) && (you == player) { items= items + 1; ent_remove(me); } wait(1); } }
action rotate { while(1) { my.pan+= 1 * time_step; wait(1); } }
action morpher { player= me; my.event = item_event; my.fat= on; my.narrow= on; c_setminmax(my); while(1) { if(key_t== on) { c_move(my,vector(6 * time_step,0,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= 7 * time_step; } else { ent_animate(my,"stand",breath_speed,anm_cycle); breath_speed+= 3 * time_step; } if(key_g== on) { c_move(my,vector(-6 * time_step,0,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= -7 * time_step; } if(key_f== on) { my.pan+= 10 * time_step; } if(key_h== on) { my.pan-= 10 * time_step; } if(mouse_left== on) { c_move(my,nullvector,vector(0,0,15 * time_step),glide); ent_animate(my,"jump",jump_speed,anm_cycle); jump_speed+= 14 * time_step; } else { c_move (my,nullvector,vector(0,0,-15 * time_step),glide); } if(key_m== on) { snd_play (morph_wav,100,0); wait(-1); ent_morph (my,racer_mdl); wait(-1); ent_morph (my,earth_mdl); wait(-1); ent_morph (my,dragrcr_mdl); wait(-1); ent_morph (my,sprite_pcx); wait(-1); ent_morph (my,char); wait(1); my.pan= 0; } if(mouse_right== on) && (key_t== on) { c_move(my,vector(10 * time_step,0,0),nullvector,glide); ent_animate(my,"run",run_speed,anm_cycle); run_speed+= 9 * time_step; } wait(1); } }
action platform_rotate { while(1) { if(event_type== event_entity) { my.pan+= 2 * time_step; } wait(1); } }
action item_action1 { my.enable_entity = on; while(me) { my.pan += 4 * time_step; wait(1); } }
action item_action2 { my.enable_entity = on; while(me) { my.pan += 4 * time_step; wait(1); } }
action item_action3 { my.enable_entity = on;; while(me) { my.pan += 4 * time_step; wait(1); } }
panel side_pan { pos_x= 0; pos_y= 640; bmap= side_pcx; alpha= 100; flags= visible, overlay, filter, transparent; }
panel other_side_pan { pos_x= 740; pos_y= 640; bmap= other_side_pcx; alpha= 100; flags= visible, overlay, filter, transparent; }
panel end_game { pos_x= 320; pos_y= 240; bmap= congrats_pcx; alpha= 100; flags= overlay, filter, transparent; }
function success() { while(1) { side_pan.alpha-= 1 * time_step; if(side_pan.alpha<= 0) { side_pan.visible= off; } other_side_pan.alpha-= 1 * time_step; if(other_side_pan.alpha<= 0) { other_side_pan.visible= off; } end_game.alpha+= 1 * time_step; wait(1); snd_play(tada,100,0); wait(1); } }
function score_tracker() { if(items== 3) { success(); } }
function mouse_look() { while(1) { camera.pan-= mouse_force.x * mouseSensitivity * time_step; camera.tilt+= mouse_force.y * mouseSensitivity * mouseInvert * time_step; wait(1); } }
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
Re: Can't get character to pick up item
[Re: MrCode]
#132638
05/30/07 23:20
05/30/07 23:20
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile

3D Artist
|

3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
Try this COde !!!!! This Works 100 % ! Code:
Function Item { while(my){ if(event_type == event_entity ) { if(my.skill2 && you.skill1) { Points+=10; ent_remove(my); } }
} }
Action Player_Move { player=my; my.skill1=1; camera_pos(); my.enable_entity=on; my.event=Item; }
Action Item { my.skill2=1; my.enable_entity=on; my.event=item; while(1) { my.pan+=1*time_Step; wait(1); } }
cYa Sebastian
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: Can't get character to pick up item
[Re: rvL_eXile]
#132639
05/31/07 01:21
05/31/07 01:21
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
*do not directly modify (invoke ent_remove, ent_create, c_move, etc.) in an event function ---if necessary, wait(1) before modifying ---instead use a flag / variable to modify in action while loop (hinted at by the manual) *keep while loops out of event functions *only use (global?) event_type in event functions (typically near top) ---do not use event_type in action loops or outside event functions (function redirection ok)Code:
// just a sloppy example var plItems[10]; // items carried by the player define _id, skill6; define _carry, flag5;
text itemT0 { pos_x = 0; pos_y = 0; string = "cabbage.mdl"; string = "hemorrhoidOintment.mdl"; string = "vodka.mdl"; string = "duckTape.mdl"; }
function itemEvent0() { if (event_type == event_entity || event_type == event_impact || event_type == event_push) { if (you == player) { my._carry = ON; //exit loop my.event = NULL; } } } action aItem0 { wait(1); c_setminmax(me); my.event = itemEvent0; while(me != NULL && my._carry == OFF) { my.pan += 4 * time_step; wait(1); } if (my._carry == ON) { plItems[my._id] += 1; } if (me != NULL) { ent_remove(me); } }
function itemDrop(&_items, id) { _items[id] -= 1; ent_create(itemT0[id], my.x, aItem0); // no gravity }
|
|
|
|