Trying to stop character's having a collision event after inventory used.

Started by barefoot, Wed 04/05/2011 11:22:34

Previous topic - Next topic

barefoot

Hi

I'm trying to work out what would be the most efficient way to stop character's having a collision event.

I already have in rep execute:

Code: ags

if (cskeleton1.IsCollidingWithChar(cwizard2) == 1) 



cskeleton1 changes to an animation and then to view 55 after an inventory (ifireball) is used on it.. and colllisions work fine.   So far so good.

I am trying to then put if colliding make it ==0.  Because at the moment if the main char goes near cskeleton1 the collision events happen when it should not (some text said and score adjusted);

I have this in Rep execute:
Code: ags

{

 if (cskeleton1.IsCollidingWithChar(cwizard2) == 1)

{
	
  cwizard2.Say("Aghhh!!");
	GiveScore (-1);
  SetGlobalInt (1, 100);
	cwizard2.Walk(cwizard2.x + 20, cwizard2.y +0, eBlock, eAnywhere);
{


And this when Inv is used:

Code: ags

function cskeleton1_UseInv()
{
 if (player.ActiveInventory==ifireball){
	 
 player.ActiveInventory=null;
 cskeleton1.ManualScaling=true;
 cskeleton1.Scaling=28;
 cskeleton1.ChangeView(54);
 cskeleton1.Animate(0, 5, 0, eBlock, eBackwards);
 cskeleton1.UnlockView();
 cskeleton1.ChangeView(55);
 cskeleton1.FollowCharacter(null);
 Display("The skeleton is now burnt to a crisp and lifeless!");

  }


Hope this is understandable though I'm certain the solution may well be simple yet been overlooked.

cheers

barefoot








I May Not Be Perfect but I Have A Big Heart ..

Khris

Both functions are inside the global script, so just put this at the top of Global.asc:
Code: ags
bool skeleton_alive = true; 


Then use:
Code: ags
if (cskeleton1.IsCollidingWithChar(cwizard2) && skeleton_alive)  // you don't need ==1


Then add this to your UseInv/fireball block:
Code: ags
  skeleton_alive = false;


And please, please bookmark this or one of your other ten "you need a variable" threads. :=

barefoot

Hi Khris

It certainly is in my top ten now....... I already had one in the Global already...

How could I not remember.. I will now...

Thanks so much Khris

:=

barefoot




I May Not Be Perfect but I Have A Big Heart ..

barefoot

Hi Khris

script error says: Failed to save room room30.crm; details below
room30.asc(148): Error (line 148): undefined symbol 'skeleton_alive'

that line is the collision script rep exec:

if (cskeleton1.IsCollidingWithChar(cwizard2) && skeleton_alive)

Have also declared it in Global as instructed top part and when inv used.

barefoot



I May Not Be Perfect but I Have A Big Heart ..

Khris

Oh, you're doing this inside a room script?
Then you have to make it an actual global variable.

Remove the "bool skeleton_alive = true;" line from the global script and create the variable using the Global variables pane.

barefoot

Hi Khris

Yes, just the one room.

I created Variable in pane and it now works as it should..

I can use this type of variable for a number of things now.

Many many thanks

:=

barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk