Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible), 637 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
enemy personal variables #306730
01/24/10 15:17
01/24/10 15:17
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
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

Re: enemy personal variables [Re: rtsgamer706] #306731
01/24/10 15:20
01/24/10 15:20
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
You can use entity skills for this.
See here: http://www.conitec.net/beta/aentity-skill.htm

Re: enemy personal variables [Re: Saturnus] #306809
01/25/10 04:09
01/25/10 04:09
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
Every time you make an entity that have all those skills already, no need to declare extra vars that are not needed.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: enemy personal variables [Re: FoxHound] #306810
01/25/10 04:24
01/25/10 04:24
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
BTW, if you use 'function prototypes' then it doesn't matter which action is first because the engine will know what you mean...
Code:
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.

Re: enemy personal variables [Re: DJBMASTER] #306940
01/25/10 23:37
01/25/10 23:37
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
thanks but how do I make a prototype action?

Re: enemy personal variables [Re: rtsgamer706] #306942
01/25/10 23:59
01/25/10 23:59
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Code:
#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'.

Re: enemy personal variables [Re: DJBMASTER] #307624
01/30/10 15:55
01/30/10 15:55
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
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

Last edited by rtsgamer706; 01/30/10 15:55.
Re: enemy personal variables [Re: rtsgamer706] #307633
01/30/10 16:31
01/30/10 16:31
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
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.

Last edited by DJBMASTER; 01/30/10 16:31.
Re: enemy personal variables [Re: DJBMASTER] #307640
01/30/10 18:14
01/30/10 18:14
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
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)
....


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