Hey all. Sorry to be a pest. This has vexed me on a few previous games I've made. Never found a good solution. Essentially I am wanting to know if there is a functionality for detecting whether a non player character is moving or static. I've tried a few clumsy solutions in the past. At present, the player deals with NPCs who are possessed by demonic forces who like to crack out their telekinesis from time to time. I have rooms full of objects created as characters (chairs, tables, knives, pots and pans etc). Have set it so that at random intervals the possessed will hurl one of these objects telekinetic at the player. Easy enough. The character (chair, pot etc) projects from where it is to where the player is, non eblocked. Problem is, I am wanting it to only inflict damage while in motion, not to cause damage if a player sprite collides with it when it is static. In past games I've made with projectiles, I've rigged them with timers. Problem is if they land to close, they remain dangerous due to the timer status even when static until the timer runs down. I am trying out a clumsy method at the moment whereby I establish multiple definable variables for each throwable thing. Example: WHere cChair = the throwable chair character Where Chaircurrentx = the x position of the chair in the current loop Where Chairpriorx= the x position of the chair in the previous loop Where Chairmoving = an assessment as to whether or not the chair is moving Chairpriorx=Chaircurrentx; Chaircurrentx=cChair.x; If (Chaircurrentx != Chairpriorx) Chairmoving=1; THis isn't the exact script I've used for this. I dont have the internet at home so have come to an internet cafe to make this query. But I'm sure you all get the gist. The same tests are sett for Y variables too. Essentially each loop tests whether the co ordinates of the chair character are the same as the previous loop. If not, it returns a 1 to another variable that indicates that the chair is in motion. This will factor into another IF conditional statement which will lead into a damage assessment and infliction subroutine. etc. Given that I intend to have situations with a great many objects that can be psychically thrown at the player, I was wondering if there was a less cumbersome method than replicating numerous variable sets for each throwable object? |
Quotereadonly bool Character.Moving
Returns true if the character is currently moving, or false if not.
if cChair.Moving {
//this is what it does
}
if(cChar.Moving){
//this is what it does
}
QuoteYou're wrong, geork. The character is called cChair, not cChar.