Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411526 Posts in 69381 Topics- by 58437 Members - Latest Member: GlitchyPSI

May 02, 2024, 01:22:24 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Game Maker 7 Tech question
Pages: [1]
Print
Author Topic: Game Maker 7 Tech question  (Read 1394 times)
Destral
Level 10
*****


Climbing that mountain...


View Profile WWW
« on: December 03, 2009, 11:30:49 PM »

Howdy folks. I'm working on a game using Game Maker 7. Part of the gameplay involves units moving across the screen from opposite sides and fighting when they meet in the middle.

Each set of units (sides) has a parent (obj_human_parent and obj_undead_parent). All other units are children of these two. All units have the following variables, defined in the Create Event:

Quote
uHealth = 1;
uMoveSpeed = 1;
uAttackPower = 1;
uAttackDelay = 0;
uAttackDelayMax = 30;
uDefense = 1;

The above variables are for the undead units. Human units have humVariable to differentiate them. The values given are arbitrary.

The way I have it set up, in the Step event of the each parent, I have a collision check with the parent of the other side. If there is a collision, uAttackDelay is set to -=1 unless uAttackDelay < 1, at which point it is set to uAttackDelayMax, and I use a set variable action to reduce the other unit's health by uAttackPower.

When I run the game, however, when two units come into contact with each other, I get an error saying that 'uAttackPower' is an unknown variable. I've checked the spelling, I've tried specifying self.uAttackPower in the action, all to no avail.

Anyone have any idea what the problem might be?
Logged

Currently working on: Sword Surfer
ChevyRay
Guest
« Reply #1 on: December 04, 2009, 12:02:51 AM »

Hmm, can you post the code for your creation events and the step event that does the check? I can't seem to locate an error in your design, unless you somehow overlooked actually making the objects have the _parent objects as their parents. :/
Logged
Destral
Level 10
*****


Climbing that mountain...


View Profile WWW
« Reply #2 on: December 04, 2009, 12:29:59 AM »

Create Event:

Quote
uHealth = 1;
uMovSpeed = 1;
uAtkPow = 1;
uAtkDelay = 0;
uAtkDelayMax = 30;
uDefense = 1;




Sorry for the crappy image quality, photobucket's image compression doesn't do it much good.


I'm messing around with it in another instance of GM7, and think I might have figured it out, but there's the very distinct possibility that another, bigger problem will crop up as soon as I fix this Angry
« Last Edit: December 04, 2009, 02:30:13 AM by Destral » Logged

Currently working on: Sword Surfer
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #3 on: December 04, 2009, 12:45:37 AM »

the problem is you have 'other' selected. when you have 'other' selected, it treats the script as being run from the other object, not from the current object.

in other words, the script that's using the 'undead' variable is being run from the human object, not from the undead object.

to fix it, either change it to not use other, or prepend other. in front of the variable. other.uHealth for example.
Logged

Destral
Level 10
*****


Climbing that mountain...


View Profile WWW
« Reply #4 on: December 04, 2009, 12:51:18 AM »

Oh, I see. I thought 'other' referred to whose variable was getting modified. Let me try that real quick.

EDIT: Yes, that fixes it! Thanks a bunch, Paul! Now to see if my fears with that other bug are confirmed.
« Last Edit: December 04, 2009, 12:55:40 AM by Destral » Logged

Currently working on: Sword Surfer
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #5 on: December 04, 2009, 12:56:43 AM »

an interesting thing to remember is that the other from the other is yourself.

so, for example

with (obj_pc) {
 with (other) {
  x += 1;
 }
}

is the same as

with(self) {
 x += 1;
}
Logged

Destral
Level 10
*****


Climbing that mountain...


View Profile WWW
« Reply #6 on: December 04, 2009, 01:05:16 AM »

Indeed. I mistook the 'Other' at the top of that particular menu window to mean 'Change the Other object's 'Health' variable to -(this object's attack power)', rather than 'Use the other object's attackpower variable to change this object's health variable', with the latter being the case.

Thanks again!
 Gentleman
Logged

Currently working on: Sword Surfer
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic