do not pick up when ammo is full?

Posted By: fp

do not pick up when ammo is full? - 09/14/07 20:04

how can i do it that the player do not pick up the ammo pack, when
"current_ammoreserve is 180"?



action ammo_pack
{
my.passable = on;
while (player == null) {wait (1);}
while (vec_dist (player.x, my.x) > 50)
{
my.pan += 3 * time_step;
wait (1);
}
snd_play (gotammo_wav, 80, 0);
ent_remove (my);
current_ammoreserve += 18;
current_ammoreserve = min(180, current_ammoreserve);
}
Posted By: Marwan

Re: do not pick up when ammo is full? - 09/14/07 22:16

\\I have changed it mostly only to make it easier, I did not try it , but it could work
\\replace it with the old one
var maximum_ammo=180;
var myammo;
action ammo_pack
{

my.passable = on;
while (player == null) {wait (1);}

while(1)
{
my.pan+=3*time_step;
current_ammoreserve=myammo;
if(current_ammoreserve>maximum_ammo)
{current_ammoreserve-=(myammo -maximum_ammo;}

if (vec_dist(player.x,my.x)<50 && current_ammoreserve<180)
{
snd_play (gotammo_wav, 80, 0);
ent_remove (my);
current_ammoreserve += 18;
}
wait(1);
}
}


Posted By: fp

Re: do not pick up when ammo is full? - 09/14/07 23:45

tried it and got the following error message:

empty pointer in ammo_pack:
((vec_dist(player.x, my.x) < 50 && current_ammoreserve < 180)
Posted By: flits

Re: do not pick up when ammo is full? - 09/15/07 08:41

do you have a player ?

action player
{
player = me;
Posted By: fp

Re: do not pick up when ammo is full? - 09/15/07 10:06

yes, i have a player. in another script, but i think that doesn´t matter, right?

i have a script player.wdl
in that script i included the weapons2.wdl
Posted By: Marwan

Re: do not pick up when ammo is full? - 09/15/07 10:31

Okay ,1- go to the player script file and do this

entity* player1;//I changed it from (player) to (player1)

2-go inside the player action and change (player=me;)to (player1=me;)

3-go to the ammo pack action and change ( vec_dist(player.x,my.x)) to (vec_dist(player1.x,my.x))
//that should do it
Posted By: flits

Re: do not pick up when ammo is full? - 09/15/07 13:32

{current_ammoreserve-=(myammo -maximum_ammo);}
Posted By: Marwan

Re: do not pick up when ammo is full? - 09/15/07 13:38


Quote:

{current_ammoreserve-=(myammo -maximum_ammocolor:red])[/color; ]



what?????
EDIT: Oh yeh i get it , sorry
Posted By: flits

Re: do not pick up when ammo is full? - 09/15/07 13:42

srry i dont get thate ubb coding yet so i need to idet it like 20 times lol
Posted By: elsewood

Re: do not pick up when ammo is full? - 09/15/07 14:26

Why not just changing in your original Code:
 while (vec_dist (player.x, my.x) > 50)

with Code:
 while (vec_dist (player.x, my.x) > 50 || current_ammoreserve >= 180)

??
Posted By: Marwan

Re: do not pick up when ammo is full? - 09/15/07 15:15

@flits : you can preview your post before submitting it
@elsewood :I dont know if im wrong or right but i dont think this could work , because logically if the player approches the ammo pack and his ammo is less than 180 , the function (my.pan+=3*time_step)wont run.
Posted By: elsewood

Re: do not pick up when ammo is full? - 09/15/07 15:34

You are right. As soon as the player approaches the ammo there are two possibilties:
1: ammo is full -> rotation stops to show that fact...
2: ammo is not full -> while loop ends and gives new ammo
Posted By: fp

Re: do not pick up when ammo is full? - 09/15/07 17:31

i do not understand what it makes for a difference, player or player1. But ok i did it and got an error message again:

player.wdl: double definition player1 Function Pointer
Posted By: flits

Re: do not pick up when ammo is full? - 09/15/07 18:46

try my_player ore player12 doesnt matter anyway player is oke anyway you didnt use it yet if player dont gives error's
Posted By: Marwan

Re: do not pick up when ammo is full? - 09/16/07 10:50

If I am wrong about this then I hope somebody fix my information, (player) is predefined , so i ment to change it into any thing else , for example (player1)
when you write the players action , and write in another action in a seperate script file a function refers to player , the engine wouldent know that the player you are talking about , is the player in the other script , I have had the same problem with the empty pointer , and solved it when i changed (player) to anything else,
now I dont have any Idea how it didnt work with you , and if so, why didnt the empty pointer error show up from the first place??.
I think that you have done somthing wrong that screwed it up
try to find whats wrong .
© 2024 lite-C Forums