The Dink Network

Reply to Re: Help me Revise the DinkC reference.

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
August 15th 2021, 02:53 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
I had to bump, because when I tried to add all this to the above post, it says it's too much content. So, some of it is added above, some in this bump.

====================
**FUNCTIONS (H - K)**
====================

Function: hurt()
Addition: Made a few different additions. Below is the entire revised function doc.
hurt() damages active_sprite with damage amount of damage. Note that it will damage an exact amount, but it does take defense into account. Also, there is still a chance of 1 damage if the defense of active_sprite is higher than int damage.

This function will always trigger the hit() procedure of active_sprite (even if no damage is dealt).

If the active_sprite receives damage, blood spurts are added, free of charge.


[Dink version < 1.08]:
- A negative damage value would cause the game to freeze.
- If the script that calls this function is attached to a sprite, Required global variable `&enemy_sprite` will be updated to `¤t_sprite`.


[Dink version 1.08, FreeDink all versions]:
- Ignores the command safely.
- If the script that calls this function is attached to a sprite, Required global variables `&enemy_sprite` and `&missle_source` will be updated to `¤t_sprite`.


===============================================
===============================================

Function: init()
Addition: Made a few different additions. Below is the entire revised function doc.

init() allows you to execute a line normally run from the dink.ini file. It can be used to replace graphics on the fly, such as for Dink's weapons, or anything else.

// excerpt from item-sw1.c
init("load_sequence_now graphics\dink\sword\walk\d-sw1- 71 43 64 69 -14 -10 14 10");
init("load_sequence_now graphics\dink\sword\walk\d-sw2- 72 43 35 70 -21 -10 19 10");
init("load_sequence_now graphics\dink\sword\walk\d-sw3- 73 43 28 69 -13 -9 13 9");
init("load_sequence_now graphics\dink\sword\walk\d-sw4- 74 43 66 75 -14 -12 20 12");

If replacing sequences with different numbers of frames, the longest sequence should be loaded first in the dink.ini, otherwise it might replace frames in other sequences.

[Dink version < 1.08]:
init() only works well if the graphics are in dir.ff format. If the graphics are plain bmps, and the replaced sequence is played, it may include frames from other sequences.


[Dink version 1.08, FreeDink all versions]:
init() will work well with plain bmps, there is no need to pack the graphics into dir.ff format.


===============================================
===============================================

Function: initfont()
Addition: Made a few different additions. Below is the entire revised function doc.

initfont() will cause the game to use font for all current and future text. Note that the font must be installed as a normal font (in the Windows/Fonts folder on Windows). The default font is 'Arial'.

There are some differences in the way font is interpreted between Dink/Freedink, and also between font filetypes.

Depending on the Dink Engine version and the font filetype, you will need to specify font as either a font name, or the actual font filename.

TIP

The Font Name is the name displayed when you preview a font by opening it.

The actual font filename is viewed in the file properites - Right Click on the font and click properties and find the filename.

Below you will find the requirements for string font based on filetype and Dink Engine version.

[FreeDink, all versions]: Only Truetype fonts(*.ttf) are compatible with initfont()


*.ttf: [Dink, all versions]: Font name.
[Freedink, all versions]: File name.

*.fon, *.ttc: [Dink, all versions]: Font name.

*.otf: [Dink, all verisons]: File name.

===============================================
===============================================

Function: kill_cur_item()
Addition: Added warning of flaw in function and a workaround example.

WARNING

The game will stop executing the script once this function is called. The item will be killed, but the item image will remain in the status bar until draw_status() is called.

Be careful not to call kill_cur_item from a spawned script, or it will stop executing and survive forever.

Here is a nice work around to fix the flaw in this function, using set_callback_random() to callback a procedure in the script, after it stops executing:

void main(void)
{
 //set a callback to the 'killscript()' proc, with a wait time of 1.
 //so after we run the flawed 'kill_cur_item()' function, it immediately runs 'killscript()'
 set_callback_random("killscript", 1, 1);

 //flawed 'kill_cur_item()' function - will stop the current script executing
 kill_cur_item();
}

void killscript(void)
{
 //this will run immediately after 'kill_cur_item()'
 //draw the status to make the item image vanish properly
 draw_status();

 //kill off this script so it doesn't remain in memory.
 kill_this_task();
}


===============================================
===============================================

Function: kill_cur_magic()
Addition: Similar additions to kill_cur_item, but changed to suit kill_cur_magic. See above.

===============================================
===============================================

Function: kill_this_magic()
Addition: Added warning of flaw in function and a workaround example.

WARNING

If the magic being killed off is currently armed when this function is called, the item image in the status bar will also vanish, and the green magic charge bar can sometimes be left behind.

Here is a work around to fix the flaw in this function:

void main(void)
{
 //store '&cur_weapon' in a local variable
 int &fix_weap = &cur_weapon;

 //kill off the fireball spell
 kill_this_magic("item-fb");

 //fix unwanted side effects with magic charge bar and empty slot staying equipped
 &cur_magic = 0;
 &magic_cost = 0;
 &magic_level = 0
 arm_magic();

 //restore &cur_weapon, arm it, and draw the status
 &cur_weapon = &fix_weap;
 arm_weapon();
 draw_status();
}