YolkfolkThe Dizzy Fansite 0 logged in0 playing
Community discussion

Any suggestions to how to animate triggered draw_0 to draw_3 brush/object?

Started by Captain Jonesy on 15 October 2010 • 10,861 views

21 posts
#54817

Hi guys,

Wondering if I could pick your brains for any suggestions to how overcome the issue I'm having currently.

Basically I have this dragon character where I want to be able to give a item (ID==104 - skull) to and then he shoots a flame/fire (ID==1004) across the screen hitting/killing dizzy. I'm currently using waypoints for the flame which doesn't work, but wondering if because the flame is draw and material is set as "0" then becomes triggered to become draw and material "3". I Also tried using code below:

if(IsUpdate(3)) 
    {
        //update the bat only once each 3 frames
        idx = ObjFind(1004);
        x = ObjGet(idx,O_ X) ;
        x+=4; // move from 4 to 4 pixels
        if(x>410) x=350;
        ObjSet(idx,O_X,x);

With this code, the flame was animated (flying across the screen) but it didn't kill dizzy although flame class is set to "Kill". Here is the current code I'm using:

func UpdateRoom_1_3() ///////////dragon flame
{ 
 idx = ObjFind(1004);// dragon flame
     AIUpdateTrain(idx); 
     ObjPresent(idx);         
}
/////////////Dragon 
func ActionObject_1003()
{
idx = ObjFind(1003);

if (ObjGet(idx, O_STATUS) == 0)
{

  Message2(7,5,"Hello! Who comes there?");
  Message1(3,4,"Hello I'm Dizzy");
  Message1(4,5,"I'm wondering whynare you preventing Jimnfrom entering hisnlaboratory?"); MessagePop();
  Message2(7,5,"Well, I don't like wizards");
  Message2(7,5,"These wizards alwaysnuse these places to ncreate anti-dragon devices."); 
  Message2(7,7,"Like potions and spells"); MessagePop();     
  Message1(4,5,"Jim isn't like that");
  Message2(5,6,"I don't believe you!n Go away!"); MessagePop();  
  ObjSet(ObjFind(1003),O_STATUS,1);
  }
if(ObjGet(ObjFind(1003),O_STATUS)==1)
{      
Message2(7,5,"Get away, you wizard!"); MessagePop();
 idx = OpenDialogInventory();
     if (idx!=-1) 
    { 
     UseObject(idx);
    }
   }
  } 
func UseObject_1003( idx )
{
if(idx==ObjFind(104))////skull
    {
        InventorySub(idx);
        Message2(5,6,"A skull hahahahah");
        Message2(6,7,"You think thatnwould scare me off!");
        Message2(7,8,"Hahahahhahahaahah"); MessagePop();
        Message2(7,8,"I've killed many humansnin my day"); MessagePop();
        Message2(5,6,"So I have no problemnkilling you"); MessagePop(); 
        ObjSet(ObjFind(1004), B_DRAW, 3);
        ObjSet(ObjFind(1004), B_MATERIAL, 3);//Kill material 
         GameCommand(CMD_REFRESH);                      
    }     
  }

Any suggestions would great and thanks in advance.

Jonesy

👍 0
#71841
Sorry to make myself more clear - the flame currently doesn't animate with waypoints and trying to make the flame to travel from right to left on the screen hitting/killing dizzy as he finishes speaking to the dragon.

Thanks again

Jonesy
👍 0
#71842
uhhh still unsure exactly what the problem is...

does it animate as in move between frames? or is it just not moving across the screen? If the latter, that's not animation, that's movement!

Also, if it doesn't kill him, have you tried setting property COLLIDER to CALL HANDLER?

You may also have to change the STATUS property of the flame to 1, otherwise the AI code for the waypoints won't work.


Personally I wouldn't use waypoints for one movement like this, but that's just me :smile:
👍 0
#71856

Yes the flame animates, just doesn't move across the screen. I was using waypoints with your suggestions but the invisible flame would kill dizzy before speaking/giving item to the dragon so that's no good. So yeah I think you are right that using movement is the right way forward for this, although I haven't coded any movment yet (used only waypoints so far), what code would you suggest? I want the flame move from right to left on the screen once as for this code from previous post

if(IsUpdate(3)) 
    {
        //update the bat only once each 3 frames
        idx = ObjFind(1004);
        x = ObjGet(idx,O_ X) ;
        x+=4; // move from 4 to 4 pixels
        if(x>410) x=350;
        ObjSet(idx,O_X,x);

moves the flame from left to right and the movement keeps looping (starting from left to right again), which isn't what I'm looking forward, yet again thanks for the help and support.

By the way, thanks Pogie for the tip but this is my 1st dizzy level/game so I'm trying to keep things simple for the time being, I will defo use that guide/tips when I become more experienced using dizzy.

Thanks

Jonesy

👍 0
#71857

Sorry to forgot include this in previous post but code:

if(IsUpdate(3))
    {
        //update the bat only once each 3 frames
        idx = ObjFind(1004);
        x = ObjGet(idx,O_ X) ;
        x+=4; // move from 4 to 4 pixels
       if(x>410) x=350;
        ObjSet(idx,O_X,x);

the flame is always active whilst in the room, what code would you suggest to use to allow the flame to be enabled once dizzy gives the dragon the item?

👍 0
#71858
It sounds what you after is similar to when Dizzy meets Zaks in my game 'Excalibur Dizzy'. If you haven't played it then what happens is that Zaks throws an lightening bolt at Dizzy if he approaches. I know you want it to happen by the giving of an item rather than a collision but the same code should work, it's just the trigger is different.

I don't have 'Excalibur' on this computer to give you more details but you're welcome to look at my source code if you want. I'll be able to help further tomorrow if your still stuck.
👍 0
#71859
Hi Macon, thanks for the heads up. I've just downloaded 1.2 version of your Excalibur Dizzy game, here: https://www.yolkfolk.com/bb/showthread.php?t=211

This version hasn't got any scripts so I can't look and learn from your code, do you have version with script files included i could look at please?
👍 0
#71860
In DizzyAge there is a tool called PAK. Use it to unpack the file named Dizzy.pak within the excalibur folder. This will give you a folder containing the scripts, map, graphics, music etc. Make sure you unpack it to the same folder.
👍 0
#71862
That's great, I didn't realise could you do that, I wondered why 90% people levels I've downloaded so far didn't have scripts in the folder by default, this certainly explains why. Thanks a lot and I start learning the way of the code! {yolkfolk}:dizzy:
👍 0
#71863

Hi Macon, sorry to be pain. I'm just looking at your code figuring out how the thunder bolt is triggered and how it disabled after dizzy dies, just wondering if you would explain your code or confirm if my understanding is correct;

ACTIVATE LIGHTENING (2182)
///////////////////////////////////////
func CollideObject_2182_2(idx)
{
    if (!ObjGet(ObjFind(2182),O_STATUS))
    {
        Say(ZAKS,"I don't know hownyou managed to getnpast my guardians!");
        Say(ZAKS,"But you will not findnit as easy to getnpast me !!!");
        ObjSet(ObjFind(2182),O_STATUS,1);
    }
    ObjSet(ObjFind(2181),O_DISABLE,0);
}

//////////////////////////////////////////
// DE-ACTIVATE LIGHTENING (2183)
//////////////////////////////////////////
func CollideObject_2183_2(idx)
{
    ObjSet(ObjFind(2181),O_DISABLE,1);
    ObjSet(ObjFind(2181),O_X,3428);
}

I'm not quite sure what func CollideObject command is for, but I'm guessing that it is some type of collision triggering device that when player walks into it, triggers a event in this case with "func CollideObject_2182_2(idx)" a dialogue with Zaks and then afterwards activates the thunder via -

ObjSet(ObjFind(2181),O_DISABLE,0);.

I'm not sure what func CollideObject_2183_2(idx) is but I can see that thunder disables with code:

ObjSet(ObjFind(2181),O_DISABLE,1);// disable thunder
ObjSet(ObjFind(2181),O_X,3428); // thunder Movement?

Also what I'm wondering how does this code correspond the thunder bolt
move across the screen only once (not keep looping) or stopping after dizzy death? Anyway thats I gather so far, I am on the right track? I hope you clear up some of my understanding. Thanks in advance.

Jonesy

👍 0
#71866
When Dizzy approaches Zaks he collides with an invinsible hotspot which turns on the lightening and disables the hotspot. I know you want to trigger it in a different way the principles the same.

Ignore the second collision. The second collision is to reset the lightening bolt if Dizzy leaves the screen. This was my first game and at that time I didn't that there is a special function for events on leaving the screen.

The lightening moves in the room update for that location. It just moves the lightening then checks if it has reached the screen end. If so it is moved bac to the beginning. But you could also disable it at this point if you wanted.
👍 0
#71867

Ok sure, I understand about invinsible hotspot ( that's cool way to trigger things by the way, I use that in the future). I'm currently looking at your Update room lightening bolt code and that's gone over my head.

func UpdateRoom_14_2()
{
    bolt = ObjFind(2181);
    if ((!ObjGet(bolt,O_DISABLE)) && (ObjGet(bolt,O_STATUS)<2))
    {
        ObjSet(bolt,O_X,ObjGet(bolt,O_ X) +1);
        if (ObjGet(bolt,O_ X) >=3600) ObjSet(bolt,O_X,3428);
    }
    if ((!ObjGet(bolt,O_DISABLE)) && (ObjGet(bolt,O_STATUS)>0))
    {
        ClearKeys();
    }
    if ((!ObjGet(bolt,O_DISABLE)) && (ObjGet(bolt,O_STATUS)==2))
    {
        ObjSet(bolt,O_X,ObjGet(bolt,O_ X) -1);
        if (ObjGet(bolt,O_ X) <=3416)
        {
            ObjSet(ObjFind(2180),O_ANIM,1);
            ObjSet(bolt,O_DISABLE,1);
            PlayerSet(P_TILEIDLE,10);
            PlayerSet(P_TILE,10);
        }
    }
    if (ObjGet(ObjFind(2180),O_FRAME) == 11) ObjSet(ObjFind(2180),O_DISABLE,1);
}

Sorry I'm newbie at this; this is quite advanced for me, so I'm just wondering what you what code would you suggest to make flame go right to left on screen and disables crossing the screen once? Sorry to be pain, I just really stuck {yolkfolk}:eek:

👍 0
#71868

I'd forgotten there was a bit more than the lightening movement going on in that room.

1st you neede to check if the lightening has been enabled. if it has then move it. Finally check to see if has reached the edge of the screen. If so disable it.

bolt = ObjFind(2081); // use the correct id for the lightening
if (ObjGet(bolt,O_DISABLE) == 1) return; // lightening is not active so exit
ObjSet(bolt,O_X,ObjGet(bolt,O_ X) -1); // move lightening left
if (ObjGet(bolt,O_ X) <=3416) // use x coordinate where you want lightening to vanish.
{
ObjSet(bolt,O_DISABLE,1); // lightening disappears
}
👍 0
#71869

Thank you very much Macon, that works really well, you're been really helpful {yolkfolk}:thumb: .

Just to ask you one more thing (sorry to keep asking questions, I promise this will be my last question), how would you enable the flame movement again for each different item given to the dragon? Currently the flame can be activated with movement across screen only once within player duration (any single item) but I need to enable the flame movement for each item given.

It's item puzzle you see, two items lead to the player's death with the flame and one item leads to player pass the dragon.
Here is the code written for the flame trigger and giving the item to the dragon which triggers the flame (each item has the same code):

func UpdateRoom_1_3() 
{
idx = ObjFind(1004); ///// Dragon flame
if(ObjGet(ObjFind(1004),O_STATUS)==1)
{
if (ObjGet(idx,O_DISABLE) == 1) return; /// flame is not active so exit
ObjSet(idx,O_X,ObjGet(idx,O_ X) -3); /// moves left
if (ObjGet(idx,O_ X) <=250) /// where the flame vanishes.
ObjSet(idx,O_DISABLE,1); /// flame disappears
 } 
}
func UseObject_1003( idx )
{
if(idx==ObjFind(104))////skull
	{
	    InventorySub(idx);
Message2(5,6,"So I have no problemnkilling you"); MessagePop(); 
		idx = ObjFind(1004);//flame
		ObjSet(ObjFind(1004),O_DISABLE,0);
		ObjSet(ObjFind(1004),O_STATUS,1); // enable flame loop 
		ObjSet(ObjFind(1004), B_DRAW, 3); //Draw flame
		ObjSet(ObjFind(1004), B_MATERIAL, 3);
 GameCommand(CMD_REFRESH); 

I would of thought these lines for each item:

idx = ObjFind(1004);//flame
ObjSet(ObjFind(1004),O_DISABLE,0);
ObjSet(ObjFind(1004),O_STATUS,1);

would allow the flame to loop back to orignal status with:
if(ObjGet(ObjFind(1004),O_STATUS)==1)
within the Update room? But that doesn't work, any suggestions? Thanks again in advance!

Jonesy

👍 0
#71870
When the flame reaches the end of the screen and you disable it, have you tried resetting its O_X property, setting the status to zero and also resetting any other properties that has changed such as draw and material. In other words put everything back to how it was before the flame was triggered.

Not sure if that is what you need.
👍 0
#71875

Yeah good idea - I didn't think of that approach although what code would you use to reset the O_X property/location? Sorry I'm such a newbie at this, here is my code so far:

idx = ObjFind(1004); ///// Dragon flame
if(ObjGet(ObjFind(1004),O_STATUS)==1)
{
if (ObjGet(idx,O_DISABLE) == 1) return; /// flame is not active so exit
ObjSet(idx,O_X,ObjGet(idx,O_ X) -3); /// moves left
if (ObjGet(idx,O_ X) <=250) /// where the flame vanishes.
ObjSet(idx,O_DISABLE,1); /// flame disappears              
ObjSet(ObjFind(1004),O_STATUS,0);  
} 
if(ObjGet(ObjFind(1004),O_STATUS)==0)
{
ObjSet(ObjFind(1004), B_DRAW, 0); //Draw flame
ObjSet(ObjFind(1004), B_MATERIAL, 0); 
ObjSetPos(434,486);

This line: ObjSetPos(434,486); doesn't change it's location by default, suggestions? Thanks again and again in advance lol {yolkfolk}:delight:

Jonesy

👍 0
#71876
O_X is simply just another Object property, so you just need to use ObjSet(idx,O_X,434);
👍 0
#71877

also, these two lines will throw up errors:

ObjSet(ObjFind(1004), B_DRAW, 0); //Draw flame
ObjSet(ObjFind(1004), B_MATERIAL, 0); 

this is because you're trying to change brush properties (B_) using code for objects (ObjSet). Use both parts of the object code (ObjSet & O_) for Dynamic Objects, and both parts of the brush code (BrushSet & B_) for Static Brushes.

👍 0
#71878

Thanks delta again, oh yeah you're right - of course, the flame is a object so I changed all accordingly. Macon I just tried that with this recent attempt;

idx = ObjFind(1004); ///// Dragon flame
if(ObjGet(ObjFind(1004),O_STATUS)==1)
{
if (ObjGet(idx,O_DISABLE) == 1) return; /// flame is not active so exit
ObjSet(idx,O_X,ObjGet(idx,O_ X) -3); /// moves left
if (ObjGet(idx,O_ X) <=250) /// where the flame vanishes.
ObjSet(idx,O_DISABLE,1); /// flame disappears              
ObjSet(ObjFind(1004),O_STATUS,0);  
} 
else
if(ObjGet(ObjFind(1004),O_STATUS)==0)
{
ObjSet(ObjFind(1004),O_DRAW,0); //Draw flame
ObjSet(ObjFind(1004),O_MATERIAL,0); 
ObjSet(idx,O_X,434);
 } 
}

Currently you see the flame appear but resets to draw and material 0 instantly, not travelling across screen anymore, so I guess ObjSet(ObjFind(1004),O_STATUS,0); is overriding the movement function, any ideas? :dizzy_confused:

Jonesy

👍 0
#71879

yes, you're right, so you also need to change the status property back to 1:

ObjSet(ObjFind(1004),O_STATUS,1);

Simple! :smile:

👍 0