The Dink Network

Reply to Re: Cloud Castle 2 : It still exists!

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:
 
 
May 24th 2004, 03:10 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Er, you're not SUPPOSED to implement burnable plantlife that way. Don't take the way Seth did things as the one true way

Modifying the fireball script whenever you want to burn something else just seems... silly. What if you only want one log to be burnt? Then you'd put some &player_map checking in there, and maybe checking the sprite number too. And it just becomes on big jumbled mess when someone else goes to look at your D-Mod... what the heck, how does that log burn? It doesn't have a script?

The problem also lies in if you have different magic that can burn things, ala Fireball and Hellfire in the original. You basically have to duplicate the code (copy and paste), which isn't a very good idea because you'll make a bug fix in one version whilst forgetting the other. There were a couple bugs with Hellfire burning down trees with scripts attached in the original game due to this very reasoning.

The way I prefer to implement it is weird. Basically I'll give the sprite that is burnable a script that sets a sp_gold value unique to burnable objects, say, 80. As sp_gold isn't used by any of the original game objects, you can be fairly safe to assume that it will be ok to just claim a number for burning things. I then add a 'fire' function/method into the script, which will then activate whenever a fireball hits it.

How? In the fireball script(s) I have it check the sp_gold value of the sprite that it damages, and if it is 80 I do this:

int &junk = is_script_attached(&missile_target);
run_script_by_number(&junk, "fire");

Tada, it runs the 'fire' subroutine of the burnable sprite that the fireball hits.

The sp_gold nonsense is requred because if you use run_script_by_number and the subroutine you specify is undefined, then it will run an existing subroutine anyway.

But this method is actually kinda cool in that it supports weird things happening. You could easily have something like an enemy shooting some weird fire magic at Dink, and add in the sp_gold checking above, and then it could set all burnable objects on fire just like *that*.