Jump to content
  • 0

Video function (as 'cutin')


Vykimo

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  236
  • Reputation:   189
  • Joined:  11/27/11
  • Last Seen:  

Hi all,

I'm trying to build a src function to show kind of ""video"" (more a gif since it'll play a lot of .bmp in succession) based on the cutin function.

In fact, It's already possible doing things like this :

mes "Video";
for(.@i=0;.@i<100;.@i++) {
cutin "image"+.@i,0;
sleep2 500;
}
close2;
cutin "",255;
end;

BUT the problem is that during the animation, the player can't do anything!!

What I'd to do is a src function like that :

 

 *video "<filename>,<position>,<number of frame>,<number of repeat 0 for infinite>,<timetick>; 

 

And during the animation, the player can close the npc dialog to stop the video for example.

 

 

I'm convinced that I need to create a sub-executed program like 'donpcevent' does and put a line in 'close' function to abort this sub-program.

but I don't know how to manage to do this.

 

I started like this :

BUILDIN(video)
{
    TBL_PC* sd;
    int i;
    char *image;

    sd = script->rid2sd(st);
    if( sd == NULL )
        return true;
    
    image = Malloc((sizeof(script_getstr(st,2)) + 1)*sizeof(char));
    
    // Need to create a sub-executed program to not interrupt the running of the main script

    do {
        for(i=1; i<=script_getnum(st,4);i++) {
            
            sprintf(image,"%s%d",script_getstr(st,2),i);
            
            clif->cutin(sd,image,script_getnum(st,3));
            
            ticks = script_getnum(st,5);

            // Timer Function, still don't know what using
            
    } while(script_getnum(st,4)==0);
    
    free(image);
    return true;
}

Can someone help me to build it?

It's a masterpiece function in customization and I'm sure It'll help a lot of people.. wink.png

Thanks in advance!

Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   4
  • Joined:  01/04/12
  • Last Seen:  

Fresh idea, i like it :)  may u attach screen shot?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  20
  • Reputation:   0
  • Joined:  10/21/13
  • Last Seen:  

nice idea,

how about give an option next and close for each picture?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  350
  • Reputation:   43
  • Joined:  09/07/12
  • Last Seen:  

a possible reason why the player(s) cant move,

 

maybe map server run on a single processing thread,

if it is, then it will wait for that improvised video to finish the loop,

then resuming map server function.

( not really pausing map server, but prioritizing the npc script this causes the player to unable to move)

 

you can make a new thread to run this npc script or all of your npc script,

if you can do that, then you can play that video of yours w/o interrupting player interaction.

 

also making that new thread for npc(s) could help make your map server more smooth,
in other term, less lag for player ( maybe /heh )

Edited by Eat Sleep Dota
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

I think being able to render animated gif would require some mods on the client side since it's only made to read bitmaps.

You can use OnTimer but it will be tedious if you have more than 10 images to show,

here's an excerpt from one of my scripts:

OnInit:
        Initnpctimer;
        end;

OnTimer500:
	attachrid(.char);
	cutin "malaya_ghost01",4;
	detachrid;	
	end;
OnTimer1000:
	attachrid(.char);	
	cutin "malaya_diwata01",0;
	detachrid;	
	end;
OnTimer1500:	
	attachrid(.char);
	cutin "malaya_diwata02",1;
	detachrid;
        initnpctimer;	
	end;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  236
  • Reputation:   189
  • Joined:  11/27/11
  • Last Seen:  

Fresh idea, i like it :) may u attach screen shot?

You want screenshot of what?

nice idea,

how about give an option next and close for each picture?

I could add some extra option later like pause or stop the animation but for now I need to build the core function.

@jezznar I succeed of making it with script but its dirty and i want to make clean src function..

@Eat sleep Yes I need to make new thread, its where I need some precisions.

Edited by Vykimo
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

 

@jezznar I succeed of making it with script but its dirty and i want to make clean src function..

 

 

Looking forward to see this merged :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  350
  • Reputation:   43
  • Joined:  09/07/12
  • Last Seen:  

you can try to look for starting point in map.c

the call for initial functions are written there.

 

if you successfully did it, please make push to git.
this will be a good contribution to community. /slur

Edited by Eat Sleep Dota
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  236
  • Reputation:   189
  • Joined:  11/27/11
  • Last Seen:  

Hmm, I don't think there is something interesting in map.c.

 

It's more in script.c (and a bit in npc.c) with the function run_script_main.... 

 

But I really need advice from src expert or rather core dev... :/ Not sure they look often at this section.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  236
  • Reputation:   189
  • Joined:  11/27/11
  • Last Seen:  

Up

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  20
  • Reputation:   0
  • Joined:  10/21/13
  • Last Seen:  

have you ever think?

how if player who "attached" with animation "dialogs" intrupted or talk with other NPC?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...