Posted By: rtsgamer706
enemy personal variables - 01/24/10 15:17
I am a programmer making a sci-fi game. I want my enemy's ships to have 15 hp.
I have tried putting a personal variable in the ships action
but the separate action that deducts health when I shoot it has to go before the ships original action.
So then it doesn't know what my health variable is because it reads
hp -= 6;
//before reading
var hp =15;
I use lite-c can someone please help me. Thanks in advance
rtsgamer
Posted By: Saturnus
Re: enemy personal variables - 01/24/10 15:20
You can use entity skills for this.
See here:
http://www.conitec.net/beta/aentity-skill.htm
Posted By: FoxHound
Re: enemy personal variables - 01/25/10 04:09
Every time you make an entity that have all those skills already, no need to declare extra vars that are not needed.
Posted By: DJBMASTER
Re: enemy personal variables - 01/25/10 04:24
BTW, if you use 'function prototypes' then it doesn't matter which action is first because the engine will know what you mean...
action act_player();
action act_shootme();
Prototypes just make the engine aware that there is an action with a certain name, it has no idea what it does, until you provide a defintion for it later.
Posted By: rtsgamer706
Re: enemy personal variables - 01/25/10 23:37
thanks but how do I make a prototype action?
Posted By: DJBMASTER
Re: enemy personal variables - 01/25/10 23:59
#include <acknex.h>
#include <default.c>
action act_player();
action act_shootme();
....
action act_player()
{
act_shootme();
}
action act_shootme()
{
///bla bla
}
You can see that act_player uses act_shootme, yet it is defined later down in the script, so normally the compiler wouldn't be able to find it and throw an error. Now that you've added prototypes at the beginning of your script, the compiler knows that there are 2 actions called 'act_player' and 'act_shootme'.
Posted By: rtsgamer706
Re: enemy personal variables - 01/30/10 15:55
thanks but I still have a problem, when it reads
hp -= 15;
it still says hp undeclared identifier even though
action scabbard_stuff()
{
var hp = 15;
scabbard = me;
c_setminmax(me);
while (1)
{
c_move (my, vector(-28*time_step, 0, 0), nullvector, GLIDE); // move the fragment left
wait (1);
my.emask = (ENABLE_IMPACT); // make entity sensitive for block and entity collision
my.event = remove_scab;
}
}
is before it!
I don't understand why I have that problem please help
rtgamer
Posted By: DJBMASTER
Re: enemy personal variables - 01/30/10 16:31
Well this is only a small part of your code and it's hard to see where the problem is. Also note that when you declare 'var hp=15' inside an action/function, you can't access it from another function/action.
Posted By: Widi
Re: enemy personal variables - 01/30/10 18:14
You define the var hp local (in a action/function), so you don`t can use this var in others functions. Move the line "var hp = 15;" out of every action or function.
example:
var hp = 15;
action scabbard_stuff()
{
scabbard = me;
c_setminmax(me);
while (1)
....