The Dink Network

Re: Equipping magic during a cutscene

October 9th 2007, 04:10 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
I know how to automatically equip a weapon/item, but is there any way to do that for magic? Instead of &cur_weapon (forgive me if I'm incorrect, it's late at night and I'm not concentrating very well) is there something like &cur_magic?
October 9th 2007, 08:15 AM
anon.gif
helper
Ghost They/Them
 
you mean like add_magic("item-fb", 437, 1); ?
October 9th 2007, 09:57 AM
pq_cthunik.gif
GOKUSSJ6
Peasant He/Him Poland
Everyone should get a pizza for free in each week. 
I don't know but i've found in WInDInkEdit Help about this script:
"# Categories: Inventory; Weapon; Undocumented
# Prototype:
# void arm_magic( void );

[Magic-item counterpart of arm_weapon(), below. Arms the magic in the magic-inventory slot (1-8) specified in &cur_magic, or disarms magic if &cur_magic is 0. This command does not update the status area: you will usually want to draw_status() after using this command. Example:

// disarm Dink's magic:
&cur_magic = 0;

arm_magic();
draw_status();

There is no direct way to know whether a given slot is empty or what is in it -- command compare_magic() is non-functional.]

See also: arm_weapon(), draw_status(); variable &cur_magic"

Maybe this script will help.
October 9th 2007, 10:23 AM
dinkdead.gif
And there is such a thing as &cur_magic. See DinkC Ref. v4.0 under "required global variables" (Gokussj6's quote is from v3.2).
add_magic adds it to the inventory but doesn't arm it.
October 9th 2007, 01:39 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Equipping magic is much more difficult then it looks. The problem is that for arm_magic(); you need to specify &cur_magic. The problem is that you don't know which value of &cur_magic belongs to the magic you're trying to equip, and there's no direct method to find out as far as I know... Compare_magic(); does work, but it gives only the amount of magic of the same type. (So if you have 2 fireballs it will return 2, without specifying in which slots they're in)

I can think of one solution which isn't exactly ideal. For that make sure that you give the player magic in the beginning of the game. This way slot 1 is always full. Then replace this magic with the magic you want to arm, and then arm it. Now you know for sure that the magic you want to arm is in the first slot.

I did something like that for the final battle in the Scourger I replaced the fist with a sword for the final battle, making sure that was always armed for that fight.
October 9th 2007, 02:38 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
How about:

int &temp = get_magic("item-fb");
if (&temp > 0)
{ &cur_magic = &temp; arm_magic();
}

Which is the DinkC.chm example at the page about get_magic():

get_magic
Category: Inventory, Script
Version: 1.08+
Prototype: int get_magic(string script[9]);

get_magic returns the first slot of the given script in the player's magic inventory. Returns 0 if not found. This is useful if you want to arm the fireball, but you don't know what inventory slot it is in.


EDIT: get_item(); works in the same way.
October 9th 2007, 03:12 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Cool, I'm starting to like v1.08 more and more... Would have saved me a cumbersome workaround in the Scourger... *sigh*
October 9th 2007, 07:16 PM
anon.gif
dinkmega
Ghost They/Them
 
Yeah, nice stuff!
October 10th 2007, 03:41 AM
wizardb.gif
Phoenix
Peasant He/Him Norway
Back from the ashes 
Huh... didn't they fix compare_magic() when they upgraded 1.07 to 1.08? That would've been a good idea.
October 10th 2007, 05:06 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Okay, look. The spell (fireball) is in slot 1. You wanna know how I know this? Because it's the only magic spell you get in the entire game. So tell me the simplest way to arm the magic spell in slot one.
October 10th 2007, 01:31 PM
spike.gif
&cur_magic = 1;
arm_magic();
October 10th 2007, 04:33 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Huh... didn't they fix compare_magic() when they upgraded 1.07 to 1.08? That would've been a good idea.

It was fixed as far as I know.
October 11th 2007, 01:40 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
"&cur_magic = 1;
arm_magic();"


Thank you scratcher. You're so very kind.