obj |
Problem description:
Objects.dm:17:error:target:undefined var
Objects.dm:18:error:target:undefined var
Objects.dm:19:proj :warning: variable defined but not used
I've also tried usr.target and it doesn't work as well.
ID:140751
Sep 25 2009, 4:13 am
|
||
Code:
Problem description: Objects.dm:17:error:target:undefined var Objects.dm:18:error:target:undefined var Objects.dm:19:proj :warning: variable defined but not used I've also tried usr.target and it doesn't work as well. | ||
#3 Sep 26 2009, 4:44 am
|
||||||
Odd, it compiles fine for me when I use the . operator properly.
The proj warning is because your setting a variable to the new object and then not using it, which defeats the purpose of declaring a variable. I assume what you want to do is update the bullet's attacker variable to the usr? Which you have already done (not the way I would of though). Seeing as the first argument of the New proc is normally the location I suggest you make sure for certain that the bullet's loc isn't being set to inside the attacker, perhaps replacing that line with:
Will do what is desired. Also I only just noticed that you were actually setting the attacker as the gun and not the usr (who is firing it). Be more careful next time :D | ||||||
#4 Sep 26 2009, 7:27 am
|
|||
Gamemakingdude wrote:
Code:
This was what I was talking about by placing the /mob/ above the rest of the code, so it gets declared first. Of course, that's somewhat inefficient, as you're making the target of the shot a global variable (or at least that's what it looks like).
This way you don't take up needless resources with a global target variable. As a rule of thumb, don't use globals if you can avoid it. | |||
#5 Sep 26 2009, 10:05 am
|
|||
Also want to point out that those nested loops you have there are very poorly made.
What this actually does is go through every enemy in range, THEN goes through every mob except for yourself, and if THEY'VE fired recently, blah blah blah. However, for each enemy it loops through, it sleeps for 4 ticks and then sets fired to 0, which will then set up a situation where somebody can rapid-fire if there are multiple enemies nearby, as previous shots are now setting fired to 0 every 4 ticks. What it really should look like is this:
| |||
One more thing. If i make it usr.target i get more errors.
| |
Although, I would suggest passing the target as an argument instead of as a global variable. Takes up less space that way.