Gamestudio Links
Zorro Links
Newest Posts
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
2 registered members (TipmyPip, AndrewAMD), 1,151 guests, and 4 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
empty pointer in my function #307096
01/27/10 03:48
01/27/10 03:48
Joined: Jan 2010
Posts: 4
H
Hissatsu Offline OP
Guest
Hissatsu  Offline OP
Guest
H

Joined: Jan 2010
Posts: 4
Im getting a message box that says "empty pointer in function enemy" I cant seem to figure it out . . .

action enemy()
{
player = my;
c_setminmax(me);
my.emask |= ENABLE_IMPACT;
ENTITY* enemy = NULL;

VECTOR vFeet;
vec_for_min(vFeet,me);
set(my,FLAG2);
my.STATE = 1;
while(1)
{

if(my.STATE == 1)
{
c_scan(my.x,my.pan,vector(1000,0,900),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
my.ANIMATION += 10 * time_step;
ent_animate(my, "idle", my.ANIMATION, ANM_CYCLE);
if(you)
{
my.ANIMATION = 0;
my.STATE = 2;
enemy = your.CREATOR;
}
}

if(my.STATE == 2)
var dist = vec_dist(my.x, your.x);
{
while(1)
{
var distance =-3*time_step;
c_move(me, vector(0,distance,0), EVENT_ENTITY, IGNORE_ME | GLIDE );
my.ANIMATION += 2* distance;
ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);


c_trace (my.x,vector(my.x,my.y,my.z),IGNORE_ME|IGNORE_PASSABLE|SCAN_TEXTURE);
if (hit.texname)
{
my.ANIMATION += 25 * time_step;
ent_animate(my,"punch",my.ANIMATION,ANM_CYCLE);
}



wait(1);
}

}
wait(1);
}

Re: empty pointer in my function [Re: Hissatsu] #307116
01/27/10 10:33
01/27/10 10:33
Joined: Jan 2005
Posts: 12
Shelby, Montana
toby2000 Offline
Newbie
toby2000  Offline
Newbie

Joined: Jan 2005
Posts: 12
Shelby, Montana
im not exactly sure- but your saying -> player = my; <- which should set it to the player name- might mess up things later in your script- and when you call -> ENTITY* enemy = NULL; <- im thinkin that turns the enemy off- if your using c-script - i would have said -> enemy = my; <- and not even put in hte part about enemy = null; although i own a7 pro- i only use a5- due to my comp- but the rest of script seems ok- havent work with the whole c_scan c_move before- im using the predecessor but it used in the same way just switched around- like more lines- but the principle is the same- im thinkin the problem is the play=me and enemy= null stuff- try that- should work- if im wrong i apologize- -peace-

Re: empty pointer in my function [Re: toby2000] #307238
01/28/10 01:52
01/28/10 01:52
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Firstly, get rid of "player = me;".
Its un-necessary in an enemy function and may cause problems.
"player" ISNT instanced like "me" or "you", its a public pointer.
So changing its contents affects all functions/action that are using it.

Secondly, try replacing your "STATE==1" block with this....
Code:
...
   if(my.STATE == 1)
   {
      you = NULL;
      c_scan(my.x,my.pan,vector(1000,0,900),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
      my.ANIMATION += 10 * time_step;
      ent_animate(my, "idle", my.ANIMATION, ANM_CYCLE);
      if(you)
      {
         if(your.CREATOR)
         {
            my.ANIMATION = 0;
            my.STATE = 2;
            enemy = your.CREATOR;
         }
      }
   }
...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: empty pointer in my function [Re: EvilSOB] #307300
01/28/10 13:53
01/28/10 13:53
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Also in the 'STATE==2' clause you use vec_dist(me.x,your.x) without checking if 'your' is NULL. It's always wise to check if a pointer is NULL before using it.


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