okay, I'm making progress. I want it really simple, so that whne you click on the bad guy (ZOMBIE), your character throws a punch and the zombie takes damage. Also, the Zombie walks around randomly and takes swipes at you. Pretty simple.
In the room script I have:
// room text script file
function room_a() {
Ã, // script for room: First time player enters screenÃ, Ã,Â
if (character[BIFFY].prevroom == 8){
Ã, FollowCharacterEx (ZOMBIE,BIFFY,5,0);} }//zombie charges the player, BIFFY
function room_b() {
Ã, // script for room: Repeatedly execute
Ã,Â
if ((AreCharactersColliding (2,3)==1) && (GetGlobalInt(15)==1)){
Ã, Ã, Wait(2);
Ã, Ã, AnimateCharacterEx (3,5,5,0,0,1); // animate blocking
Ã, Ã, SetGlobalInt(10,GetGlobalInt(10)-10);//player takes damage
Ã, Ã, AnimateCharacterEx (2,6,3,0,0,1);//zombie attack animation
Ã, Ã, character[BIFFY].x-=10;//player is "knocked back" a few pixels
Ã, Ã, MoveCharacter(ZOMBIE,189,146);}}//zombie moves away and attacks again
This part works like a charm. I'm having problems getting the player to connect with any hits on the zombie.
So in my "any click on character" section of the zombie I have:
if (GetGlobalInt(16)==0){//If the zombie's health is zero
Ã, Ã, Ã, FollowCharacter(ZOMBIE, -1); // stop following anyone
Ã, Ã, Ã, AnimateCharacterEx (ZOMBIE,7,0,0,0,1);//zombie death animation
Ã, Ã, }Ã,Â
Ã,Â
if (character[BIFFY].x > character[ZOMBIE].x){//this is so the player punches in the right direction
Ã, Ã, SetGlobalInt(15,GetGlobalInt(15)+1);//set punching variable +1
Ã, Ã, AnimateCharacter (2,5,3,0);//player takes a swing left
Ã, Ã, Wait(1);
Ã, Ã, SetGlobalInt(15,GetGlobalInt(15)-1);//set punching variable back to 1
Ã, Ã, }Ã,Â
if (character[BIFFY].x < character[ZOMBIE].x){//same as above but player swings in other direction
Ã, Ã, SetGlobalInt(15,GetGlobalInt(15)+1);
Ã, Ã, AnimateCharacter (2,4,3,0);
Ã, Ã, Wait(1);
Ã, Ã, SetGlobalInt(15,GetGlobalInt(15)-1);
Ã, Ã, Ã, }
if ((AreCharactersColliding (2, 3)==1) && (GetGlobalInt(15)==2)){
Ã, Ã, Ã, SetGlobalInt(16,GetGlobalInt(16)-1);//if characters are colliding and punching variable is 2 zombie takes damage
Ã, Ã, Ã, AnimateCharacterEx (3,8,1,0,0,1);//zombie damage animation
Ã, Ã, Ã, character[ZOMBIE].x+=10;//zombie is knocked back a few feet
Ã, Ã, Ã, SetGlobalInt(15,GetGlobalInt(15)-1);}//hero's punch is set back to 1
I had the player hitting the zombie fine, until I put in the part under repetedly execute so the zombie could fight back. So I know the above code works, there's just something I'm doing wrong. Dam global variables make my head hurt. I think the repeatedly execute is overriding the click on character part, anybody have any suggestions?
Never mind guys, I got it working. I'm going to put in weapons, then I'll post the whole thing.