Learning how to get a new spell in game

Discussion in 'General Modification' started by vampiricpuppy, Jun 7, 2009.

Remove all ads!
  1. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    ok, so i'm making a seperate thread for this, as i'm in danger of derailing several threads already:

    What i am doing is attempting to create a spell (doing the particle effect, spell .py script, mes entries, the works. (without knowing how to do most of it, im learning as i go along :))

    For those who havent seen my other threads (some were in the KOTB forum), i am attempting to mod in the following spell:

    Yes, its an electric fireball. im starting simple. shhhhhhhhhhh :)

    Ok, so i've done some searching around, and found a nifty little post of Allyx's that summarises what each new castable spell needs:

    So i am going to be going through that list.

    Most of the entries seem relatively straightforward at least, barring the .py files, so i thought i'd start with the hard part (well the particle effect is already mostly done) but anyway....

    Basically i am using a modified Fireball Spell script for this spell, as they are pretty much identical, barring the electricity descriptor and electricity damage type.

    Please bear in mind that i am no computer programmer - i havent done any coding since about 10 years ago, and as such, may make some very fundamental mistakes here :D

    Here is the original "Spell171 - Fireball.py" script from toee3.dat

    Code:
    from toee import *
    
    def OnBeginSpellCast( spell ):
    	print "Fireball OnBeginSpellCast"
    	print "spell.target_list=", spell.target_list
    	print "spell.caster=", spell.caster, " caster.level= ", spell.caster_level
    	game.particles( "sp-evocation-conjure", spell.caster )
    
    def OnSpellEffect( spell ):
    	print "Fireball OnSpellEffect"
    
    	game.particles( 'sp-Fireball-conjure', spell.caster )
    
    def OnBeginRound( spell ):
    	print "Fireball OnBeginRound"
    
    def OnBeginProjectile( spell, projectile, index_of_target ):
    	print "Fireball OnBeginProjectile"
    
    	#spell.proj_partsys_id = game.particles( 'sp-Fireball-proj', projectile )
    	projectile.obj_set_int( obj_f_projectile_part_sys_id, game.particles( 'sp-Fireball-proj', projectile ) )
    
    def OnEndProjectile( spell, projectile, index_of_target ):
    	print "Fireball OnEndProjectile"
    
    	remove_list = []
    
    	spell.duration = 0
    	dam = dice_new( '1d6' )
    	dam.number = min( 10, spell.caster_level )
    
    	game.particles_end( projectile.obj_get_int( obj_f_projectile_part_sys_id ) )
    	game.particles( 'sp-Fireball-Hit', spell.target_loc )
    
    	for target_item in spell.target_list:
    
    		if target_item.obj.reflex_save_and_damage( spell.caster, spell.dc, D20_Save_Reduction_Half, D20STD_F_NONE, dam, D20DT_FIRE, D20DAP_UNSPECIFIED, D20A_CAST_SPELL, spell.id ):
    			# saving throw successful
    			target_item.obj.float_mesfile_line( 'mes\\spell.mes', 30001 )
    		else:
    			# saving throw unsuccessful
    			target_item.obj.float_mesfile_line( 'mes\\spell.mes', 30002 )
    
    		remove_list.append( target_item.obj )
    
    	spell.target_list.remove_list( remove_list )
    	spell.spell_end( spell.id )
    
    def OnEndSpellCast( spell ):
    	print "Fireball OnEndSpellCast"
    Now, Obviously i'll have to create all the other relevant line entries for this thing to work under a new name, but for the purposes of the script, its simple enough to find+replace "Fireball" with "Scintillating Sphere". All other effects of the spell are the same, except for the damage type + desriptor.

    Now, so far as im aware, the descriptor is specified in the \rules\spells\171 - fireball.txt file so hopefully all i need to worry about is the damage type (with regards to the script alone).

    The D20DT_FIRE string is immediately obvious to me, and when cross referenced against Spell275 - lightning bolt.py which contains D20DT_ELECTRICITY, the first assumption that comes to me is that those strings are specifying the damage type.

    Is that correct? or are there other strings that need to be modified?

    If it is correct, and working under the assumption that i can correctly create line entries for the rest of the files mentioned by Allyx's post, this is what the script could feasibly look like:

    Code:
    from toee import *
    
    def OnBeginSpellCast( spell ):
    	print "scintillating sphere OnBeginSpellCast"
    	print "spell.target_list=", spell.target_list
    	print "spell.caster=", spell.caster, " caster.level= ", spell.caster_level
    	game.particles( "sp-evocation-conjure", spell.caster )
    
    def OnSpellEffect( spell ):
    	print "scintillating sphere OnSpellEffect"
    
    	game.particles( 'sp-scintillating sphere-conjure', spell.caster )
    
    def OnBeginRound( spell ):
    	print "scintillating sphere OnBeginRound"
    
    def OnBeginProjectile( spell, projectile, index_of_target ):
    	print "scintillating sphere OnBeginProjectile"
    
    	#spell.proj_partsys_id = game.particles( 'sp-scintillating sphere-proj', projectile )
    	projectile.obj_set_int( obj_f_projectile_part_sys_id, game.particles( 'sp-scintillating sphere-proj', projectile ) )
    
    def OnEndProjectile( spell, projectile, index_of_target ):
    	print "scintillating sphere OnEndProjectile"
    
    	remove_list = []
    
    	spell.duration = 0
    	dam = dice_new( '1d6' )
    	dam.number = min( 10, spell.caster_level )
    
    	game.particles_end( projectile.obj_get_int( obj_f_projectile_part_sys_id ) )
    	game.particles( 'sp-scintillating sphere-Hit', spell.target_loc )
    
    	for target_item in spell.target_list:
    
    		if target_item.obj.reflex_save_and_damage( spell.caster, spell.dc, D20_Save_Reduction_Half, D20STD_F_NONE, dam, D20DT_ELECTRICITY, D20DAP_UNSPECIFIED, D20A_CAST_SPELL, spell.id ):
    			# saving throw successful
    			target_item.obj.float_mesfile_line( 'mes\\spell.mes', 30001 )
    		else:
    			# saving throw unsuccessful
    			target_item.obj.float_mesfile_line( 'mes\\spell.mes', 30002 )
    
    		remove_list.append( target_item.obj )
    
    	spell.target_list.remove_list( remove_list )
    	spell.spell_end( spell.id )
    
    def OnEndSpellCast( spell ):
    	print "scintillating sphere OnEndSpellCast"
     
    Last edited: Jun 7, 2009
  2. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    no replies yet? :p big post but i was only asking a small question :p

    does the D20DT_ELECTRICITY signify the damage type? is the descriptor set in the script at all? or in the .txt file data/rules/spells/ folder?

    anyhoo, more musings ahead for the rest of the spell. I'm typing this as i analyse the contents of various files, and i'll be researching this myself by hunting the forums, but if anyone wants to correct/inform me about anything i type, please do! :D

    data/rules/spell.mes

    [​IMG]

    I'd need to add a new line, sometime after 784, which would make my new spell's number (eg. fireball is 171). 800 & 801 are already taken, but apart from that theres room from 785-3999.

    I assume that in choosing a number it would be a very good idea to check with other people handling spells/spell like effects in mods, to make sure i dont overlap numbers they intend to use :D Is there a common etiquette for this?


    data/rules/spelllist.mes

    The numbers for this file match up (with extra digits at the end) to the spell.mes number.

    So 171 - fireball looks like:

    [​IMG]

    Ok, some thoughts here, all the spells seem to have an xxx010, xxx011 and xxx015 line, not sure why!

    But for the purposes of the fireball -> scintillating sphere conversion, all that i think i need to do is copy everything and make the [fire] into [electricity].

    (it is difficult to tell at a glance whether information in these files is referenced by the engine, or merely displayed on screen or in the console at some point, unfortunately - a .mes file would imply 'messages' i would assume though, so going to work under the assumption that they are information that is displayed rather than referenced by the engine)

    data/rules/spell_enum.mes

    [​IMG]

    pretty bare bones file here, seemingly pretty straightforward. According to Allyx's post this has something to do with links to descriptions in help.tab (ingame help spell descriptions?) As with the others, the numbers match.

    data/rules/spells/*.txt

    According to Allyx's post, this is where the in-game functionality for the spell is located (other than the .py script). So hopefully, anything missing from the script is taken from here.

    171 - fireball.txt looks like this

    Code:
    School: Evocation
    Descriptor: Fire
    Level: Sor 3
    Level: Wiz 3
    Component: V
    Component: S
    Casting Time: 1 action
    Range: Long
    Saving Throw: None
    Spell Resistance: Yes
    Projectile: Yes
    flags_Target: Range
    inc_flags_Target: Self
    inc_flags_Target: Other
    exc_flags_Target: Dead
    exc_flags_Target: Non-critter
    mode_Target: Area
    radius_Target: 20
    ai_type: ai_action_offensive
    So it has descriptor (yay), who can cast it, and at what level, components, etc.

    Everything down until Projectile is pretty self explanatory - after that, some other variables are listed:

    ai_action_offensive seems to mean that it will be regarded as an attack by the ai? but this kind of thing could also be handled by the flag commands... not too sure on that one. It could also define it as a potential attack for an ai controlled caster... ill have to search around.

    The mode_target and radius_target seem pretty straightforward, with a 20ft area burst spell :)

    Finally there is the help.tab entry. I'll probably leave this until last, as it is only meant to allow people to read the description in game (still a good thing, just need to get the spell working as intended before anything like that :p)
     
    Last edited: Jun 10, 2009
  3. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    You've got everything spot on, I'd say (so that answers your question in a cryptic way :p). Which is to say, the .txt file controls the descriptor for things like whether a Domain gets it, while the .py controls the actual damage. And if you go outside, wear a mask, especially if you see any Storm players around ;)
     
  4. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    yay! thanks ted :hug: now about 'reserving' numbers for spells... :)
     
  5. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    VP, you should consider 5.5.0 beta the official current state of affairs (for the Co8 mod anyway). Add your stuff to the pertinent files in that release and you won't go wrong. The only other person who's working on post-5.5.0 spells right now is Ted, so if you square up with him you should be okay.

    In the old(er) days we had the CMF thread to post new mods in, but there is no such thing for 5.5, so you'll have to post any completed add-ons in separate threads. Please don't let this discourage you - I plan to return to the CMF format (or something similar) when the release goes out of beta, but for now it's kind of limited in that regard.

    Also, don't forget spell audio! If you want I can help you with that.
     
  6. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    sweet gaear :D that helps a lot!

    I may have a crack at the audio myself, ive dones some very basic sound effects before, but its not really my department :p

    May take you up on the offer ;)

    Ted, do you have a general set of numbers you're using?
     
  7. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,038
    Likes Received:
    42
    I believe Ted is using 766 - 774. Other stretches that are free:

    590 - 599
    610 - 698
    744 - 757
    785 - 799
    801 and onwards
     
  8. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Yup: I haven't added anything since the Bucket-o-Spells pack.

    Can I ask you add yours on to the Bucket-o-Spells stuff? As I mentioned at the time, if we just put everything in together, it should be quite easy to have a small add-on (specificaly, the .txt files) that will then determine whether the spells appear in game: so folks who want the new spells can easily activate them and folks who don't like all these unfamiliar names in the core spell lists won't have to see them.
     
  9. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    You'd actually be doing me a huge favour by absorbing my little efforts into yours, as i still havent got the slightest idea how to get an individual mod working the way your bucket of spells does :p

    So a definite YES to that :)

    For the time being, is it ok with you guys if i just start adding stuff after 801?

    Also, for me to get my spells into your mod, is it simply a matter of me providing you with the versions of my files and you copying the lines over? or is there more work that i should do before sending them over to you :) i know your hands are full with kotb :p
     
  10. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Sure, just send them over when you are done :)

    Btw, I will actually try to test those spell effects and give you some feedback tonight.
     
  11. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    yep cool :)

    if they're the wrong size etc changes are easy to make :)
     
  12. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    Bah! and here i thought i was being thorough! :p

    time to check for typos methinks -cant add it to my book for some reason, even as a non spec wizard.

    Incidentally i had to add an extra line 5802 in spell.mes for the description down the bottom, Otherwise it just had an error message listed there.

    [​IMG]
     
    Last edited: Jun 10, 2009
  13. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    I'm kind of stumped here:

    I checked my files, and everything seems (to me) to be in order.

    The two places where i know the 'scribability' of the spell is mentioned:

    802 - Scintillating Sphere.txt in data/rules/spells

    spelllist.mes in data/rules

    both seem to be in order.

    The only 'messy' part of my spell is that the partsys lines are scattered in amongst the fireball lines (until i figure out how to move them where i want them to go).

    I wouldn't think that partsys would effect the scribability of a spell?

    i replaced the script with fireballs script, no dice there.

    :twitch:

    i'm sure its something simple that i've forgottten!
     
  14. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    heres the spelllist.mes entry

    [​IMG]

    and the 802 - Scintillating Sphere.txt looks like this

    Code:
    School: Evocation
    Descriptor: Electricity
    Level: Sor 3
    Level: Wiz 3
    Component: V
    Component: S
    Casting Time: 1 action
    Range: Long
    Saving Throw: None
    Spell Resistance: Yes
    Projectile: Yes
    flags_Target: Range
    inc_flags_Target: Self
    inc_flags_Target: Other
    exc_flags_Target: Dead
    exc_flags_Target: Non-critter
    mode_Target: Area
    radius_Target: 20
    ai_type: ai_action_offensive
    I'm thinking the problem is either caused by me having left something out, or one of my files/lines has a name that the game doesnt respond well to :roll:
     
  15. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    ok found two areas in spell_enum.mes that had entries for spells

    seems they have the original

    xxx number

    then also 5xxx and 20xxx fields corresponding to the spells.

    So i added entries for those based on what i saw other spells had. No luck in fixing the un-scribeable spell problem :(
     
Our Host!