Checking the variables of two instances

0 favourites
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi, sorry if this is a noob question.

    I am trying to make a stealth game in scirra and sort of got stuck at implementing a feature where an enemy discovers another enemy that is dead.

    My enemy object uses line of sight behavior to see things.

    Their movement behaviour is determined by an instance variable which they all share -alertMode.

    Alert mode=0 - enemy is inactive

    =1 - enemy is patrooling

    =2 - enemy is alret and attacking

    =3 - investigating/ alert- looking for player

    =4 - enemy is dead (you need to hide the body)

    So we have two instances of the same object - enemy.

    One has alert mode=1 (patrooling), the other is dead (alert mode 4)

    How do I tell the patrooling enemy to change their alert mode to 3, when they have line of sight to a dead enemy (4).

  • Something like this?

    put the enemy in a family

    for each enemy

    enemy alert mode =1

    enemy has line of sight on family

    family Alert mode = 4

    • enemy set alert mode to 3
  • amily Alert mode = 4

    I cant access the enemy object variables through the family.

    They are not listed in the

    "compare instance variable" condition found in the "enemies" family.

  • I guess a dead enemy has a different animation from a living one, right?

    So you could check for animation. :)

  • or give the family the instance variables..

  • the problem is that both enemies are the same object and I dont know how to tell construct to compare their instance variables.

    How would you do it with animation frame condition instead of family? :)

  • The easiest way is to do it with family.

    Just check the animation frame of the family.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • is there a way to keep the animation code separate from the behavior code?

    :)

    Should I move the alert mode variable to the family and remove it from the enemy object inside the family?

  • Yes, it would probably be easiest to do that.

  • damn, I cant get it to work that way either. :(

    Something must be wrong in the way I am going it

  • is there an example capx file anywhere to see comparing instance variables in action?

  • Why don't you post your code?

  • dl.dropboxusercontent.com/u/114119373/a-STUFFF/problem.capx

    so basically the green columns are sight blockers. I have two enemies- both patrooling in 2 perimeters.

    To test it, let the first one see you and then walk to the right until you push it past the green column where the second enemy's parameter is. The second enemy must also become alert when seeing his alert comrade somehow.

    thanks in advance <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Could be me, but alertmodetest is 4 on start of layout and it is never set to 2 so the event if alertmodetest=2 will never be triggered, will it?

  • i didnt really replace it completely yet. Just created a test variable instead. To move the alretmode variable to the enemy family, i have to also change it everywhere in the code where its a condition and where it is set.

    Will do that if I am sure that it will do something. But im not sure how to do it because not sure how it does it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)