[CF-Devel] Traps not working reliable
crossfire-devel at archives.real-time.com
crossfire-devel at archives.real-time.com
Sun Aug 29 13:29:42 CDT 2004
I noticed that some traps (in chests and doors) do not work reliable
anymore. Sometimes you set off a trap, but nothing happens.
My investigations resulted in:
- There is a bug in trap_adjust() in server/rune.c. The code basically
does "level = MAX(1, rndm(...))" to ensure "level >= 1".
This does not work because MAX() is a macro and evaluates its
arguments multiple times. The result may be a trap (RUNE) with level
zero: a rune that does not detonate.
- It seem me that there are three ways to puts spells into runes:
1) put an item (spell) into inventory
2) use spell name in 'slaying' field
3) use archetype name in 'other_arch' field
For traps,
1) can't be used because inventory items can't be used in archetypes.
2) The 'slaying' field (or the obsolete spell number in the 'sp'
field) is converted to an inventory item by check_loaded_object()
in loader.l. However, this conversion is not done by
create_all_treasures()/create_one_treasure() in treasure.c.
spring_trap() in server/rune.c does not use the 'slaying' field,
only inventory items or the 'other_arch' field.
Therefore runes using the slaying field do not work when created
by a treasure list.
3) The other_arch field does work. But I'm not sure if that is the
preferred way: doc/Developers/runes, server/rune.c, and
CFJavaEditor specify to use the 'slaying' field but do not mention
the 'other_arch' field.
After fixing the bug in rune.c and changing most runes in the archetypes
file according to 3), I got all kinds of traps working again. I
summarized some attributes of the runes in runes-old.txt/runes-new.txt,
because the diff of the archetypes file is not very clear.
Besides that, I re-enabled the 'maxhp' field for runes to cast more than
one spell. Now it works for all types of spells, not just for summoning
spells.
-------------- next part --------------
Index: lib/archetypes
===================================================================
RCS file: /cvsroot/crossfire/crossfire/lib/archetypes,v
retrieving revision 1.151
diff -c -5 -r1.151 archetypes
*** lib/archetypes 11 Jun 2004 06:21:42 -0000 1.151
--- lib/archetypes 29 Aug 2004 18:16:42 -0000
***************
*** 35496,35506 ****
range_modifier 4
maxsp 9
type 101
subtype 7
value 10
- attacktype 4
no_drop 1
invisible 1
editor_folder arch/spell/Ability
end
Object abil_fear
--- 35496,35505 ----
***************
*** 41563,41573 ****
end
Object rune_drain_magic
name Rune of Magic Draining
type 154
speed 1
- slaying magic drain
hp 1
face drain_magic.111
msg
You feel depleted of psychic energy!
endmsg
--- 41562,41571 ----
***************
*** 41576,41586 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 18
Cha 20
other_arch spell_magic_drain
editor_folder arch/spell/Rune
end
Object generic_rune
--- 41574,41583 ----
***************
*** 41640,41650 ****
end
Object rune_ball_lightning
name Rune of Ball Lightning
type 154
face rune_blightning.111
! slaying ball lightning
hp 1
speed 1
msg
You detonate a Rune of Ball Lightning
endmsg
--- 41637,41647 ----
end
Object rune_ball_lightning
name Rune of Ball Lightning
type 154
face rune_blightning.111
! other_arch spell_ball_lightning
hp 1
speed 1
msg
You detonate a Rune of Ball Lightning
endmsg
***************
*** 41662,41672 ****
end
Object rune_create_bomb
name Rune of Create Bomb
type 154
face rune_bomb.111
! slaying create bomb
speed 1
hp 1
msg
RUN! The timer's ticking!
endmsg
--- 41659,41669 ----
end
Object rune_create_bomb
name Rune of Create Bomb
type 154
face rune_bomb.111
! other_arch spell_create_bomb
speed 1
hp 1
msg
RUN! The timer's ticking!
endmsg
***************
*** 41675,41692 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 3
dam 90
Cha 20
editor_folder arch/spell/Rune
end
Object rune_confusion
name Rune of Confusion
! slaying mass confusion
type 154
face rune_confusion.111
hp 2
msg
You detonate a Rune of Mass Confusion!
--- 41672,41689 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 1
dam 90
Cha 20
editor_folder arch/spell/Rune
end
Object rune_confusion
name Rune of Confusion
! other_arch spell_mass_confusion
type 154
face rune_confusion.111
hp 2
msg
You detonate a Rune of Mass Confusion!
***************
*** 41697,41707 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 6
Cha 20
editor_folder arch/spell/Rune
end
Object rune_death
name Rune of Death
--- 41694,41703 ----
***************
*** 41746,41756 ****
editor_folder arch/spell/Rune
end
#
Object rune_burning_hands
name Rune of Burning Hands
- slaying burning hands
type 154
face rune_fire.111
hp 1
other_arch spell_burning_hands
msg
--- 41742,41751 ----
***************
*** 41762,41778 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 6
Cha 20
editor_folder arch/spell/Rune
end
Object rune_dragonbreath
name Rune of Dragon's Breath
- slaying dragonbreath
type 154
face rune_fire.111
hp 1
other_arch spell_dragonbreath
msg
--- 41757,41771 ----
***************
*** 41784,41803 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 6
Cha 20
editor_folder arch/spell/Rune
end
Object rune_medium_fireball
name Rune of Fireball
type 154
speed 1
hp 1
! slaying medium fireball
face rune_fireball.111
msg
You set off a fireball!
endmsg
animation rune_medium_fireball
--- 41777,41795 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
Cha 20
editor_folder arch/spell/Rune
end
Object rune_medium_fireball
name Rune of Fireball
type 154
speed 1
hp 1
! other_arch spell_medium_fireball
face rune_fireball.111
msg
You set off a fireball!
endmsg
animation rune_medium_fireball
***************
*** 41805,41826 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
- maxhp 5
editor_folder arch/spell/Rune
end
Object rune_large_fireball
name Rune of Fireball
type 154
speed 1
hp 1
! slaying large fireball
face rune_fireball.111
msg
You set off a large fireball!
endmsg
animation rune_large_fireball
--- 41797,41817 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 6
dam 90
Cha 20
editor_folder arch/spell/Rune
end
Object rune_large_fireball
name Rune of Fireball
type 154
speed 1
hp 1
! other_arch spell_large_fireball
face rune_fireball.111
msg
You set off a large fireball!
endmsg
animation rune_large_fireball
***************
*** 41828,41841 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
- maxhp 5
editor_folder arch/spell/Rune
end
Object rune_frost
name Rune of Frost
type 154
--- 41819,41831 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 6
dam 90
Cha 20
editor_folder arch/spell/Rune
end
Object rune_frost
name Rune of Frost
type 154
***************
*** 41857,41867 ****
Cha 20
editor_folder arch/spell/Rune
end
Object rune_icestorm
name Rune of Icestorm
- slaying icestorm
type 154
face rune_frost.111
hp 1
other_arch spell_icestorm
speed 1
--- 41847,41856 ----
***************
*** 41873,41889 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 18
Cha 20
editor_folder arch/spell/Rune
end
Object rune_large_icestorm
name Rune of Large Icestorm
- slaying large icestorm
type 154
face rune_frost.111
hp 1
other_arch spell_large_icestorm
speed 1
--- 41862,41876 ----
***************
*** 41895,41914 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 18
Cha 20
editor_folder arch/spell/Rune
end
Object rune_heal
name Rune of Heal
speed 1
type 154
face rune_heal.111
! slaying heal
hp 1
msg
You set off a Rune of Heal
endmsg
animation rune_heal
--- 41882,41900 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
Cha 20
editor_folder arch/spell/Rune
end
Object rune_heal
name Rune of Heal
speed 1
type 154
face rune_heal.111
! other_arch spell_heal
hp 1
msg
You set off a Rune of Heal
endmsg
animation rune_heal
***************
*** 41916,41935 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 1
Cha 1
editor_folder arch/spell/Rune
end
Object rune_small_lightning
name Rune of Lightning
type 154
speed 1
hp 2
! slaying small lightning
face rune_lightning.111
msg
You set off a bolt of lightning!
endmsg
animation rune_small_lightning
--- 41902,41920 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
Cha 1
editor_folder arch/spell/Rune
end
Object rune_small_lightning
name Rune of Lightning
type 154
speed 1
hp 2
! other_arch spell_sm_lightning
face rune_lightning.111
msg
You set off a bolt of lightning!
endmsg
animation rune_small_lightning
***************
*** 41937,41955 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
- maxhp 5
editor_folder arch/spell/Rune
end
Object rune_paralysis
name Rune of Paralysis
! slaying paralyze
type 154
face rune_paralysis.111
hp 4
msg
You detonate a Rune of Paralysis!
--- 41922,41939 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 10
dam 90
Cha 20
editor_folder arch/spell/Rune
end
Object rune_paralysis
name Rune of Paralysis
! other_arch spell_paralyze
type 154
face rune_paralysis.111
hp 4
msg
You detonate a Rune of Paralysis!
***************
*** 41960,41976 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 6
Cha 20
editor_folder arch/spell/Rune
end
Object rune_poison_cloud
name Rune of Poison Cloud
! slaying poison cloud
type 154
face rune_pcloud.111
hp 1
msg
You detonate a Rune of Poison Cloud!
--- 41944,41959 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
Cha 20
editor_folder arch/spell/Rune
end
Object rune_poison_cloud
name Rune of Poison Cloud
! other_arch spell_poison_cloud
type 154
face rune_pcloud.111
hp 1
msg
You detonate a Rune of Poison Cloud!
***************
*** 41981,42000 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 6
Cha 20
editor_folder arch/spell/Rune
end
Object rune_restoration
name Rune of Restoration
speed 1
type 154
face rune_heal.111
! slaying restoration
hp 1
msg
You set off a Rune of Restoration
endmsg
animation rune_restoration
--- 41964,41982 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
Cha 20
editor_folder arch/spell/Rune
end
Object rune_restoration
name Rune of Restoration
speed 1
type 154
face rune_heal.111
! other_arch spell_restoration
hp 1
msg
You set off a Rune of Restoration
endmsg
animation rune_restoration
***************
*** 42002,42012 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 1
Cha 1
editor_folder arch/spell/Rune
end
Object rune_shock
name Rune of Shocking
--- 41984,41993 ----
***************
*** 42031,42041 ****
end
Object rune_regenerate_spellpoints
name Rune of Magic Power
type 154
speed 1
! slaying regenerate spellpoints
hp 1
face rune_sp_res.111
msg
You feel powerful!
endmsg
--- 42012,42022 ----
end
Object rune_regenerate_spellpoints
name Rune of Magic Power
type 154
speed 1
! other_arch spell_regenerate_spellpoints
hp 1
face rune_sp_res.111
msg
You feel powerful!
endmsg
***************
*** 42044,42063 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 18
editor_folder arch/spell/Rune
end
Object rune_summon_air_elemental
name Rune of Summoning
type 154
- race air_elemental
speed 1
hp 1
! slaying summon air elemental
face rune_summon_air.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_air_elemental
--- 42025,42042 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
editor_folder arch/spell/Rune
end
Object rune_summon_air_elemental
name Rune of Summoning
type 154
speed 1
hp 1
! other_arch spell_summon_air_elemental
face rune_summon_air.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_air_elemental
***************
*** 42065,42088 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
#
Object rune_summon_devil
name Rune of Summoning
type 154
- race devil
speed 1
hp 1
! slaying summon devil
face rune_summon.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_devil
--- 42044,42066 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 2
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
#
Object rune_summon_devil
name Rune of Summoning
type 154
speed 1
hp 1
! other_arch spell_summon_devil
face rune_summon.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_devil
***************
*** 42090,42113 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
#
Object rune_summon_earth_elemental
name Rune of Summoning
type 154
- race earth_elemental
speed 1
hp 1
! slaying summon earth elemental
face rune_sum_earth.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_earth_elemental
--- 42068,42090 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 2
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
#
Object rune_summon_earth_elemental
name Rune of Summoning
type 154
speed 1
hp 1
! other_arch spell_summon_earth_elemental
face rune_sum_earth.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_earth_elemental
***************
*** 42115,42137 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
Object rune_summon_fire_elemental
name Rune of Summoning
type 154
- race fire_elemental
speed 1
hp 1
! slaying summon fire elemental
face rune_sum_fire.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_fire_elemental
--- 42092,42113 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 2
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
Object rune_summon_fire_elemental
name Rune of Summoning
type 154
speed 1
hp 1
! other_arch spell_summon_fire_elemental
face rune_sum_fire.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_fire_elemental
***************
*** 42139,42162 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
#
Object rune_summon_water_elemental
name Rune of Summoning
type 154
- race water_elemental
speed 1
hp 1
! slaying summon water elemental
face rune_sum_water.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_water_elemental
--- 42115,42137 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 2
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
#
Object rune_summon_water_elemental
name Rune of Summoning
type 154
speed 1
hp 1
! other_arch spell_summon_water_elemental
face rune_sum_water.111
msg
A portal opens up, and screaming hordes pour through!
endmsg
animation rune_summon_water_elemental
***************
*** 42164,42174 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 18
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
--- 42139,42149 ----
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
! attacktype 2
dam 90
Cha 20
maxhp 5
editor_folder arch/spell/Rune
end
***************
*** 42186,42196 ****
is_animated 0
invisible 1
no_pick 1
walk_on 1
editable 32
- attacktype 18
other_arch spell_transference
editor_folder arch/spell/Rune
end
Object runedet
name trap
--- 42161,42170 ----
Index: server/rune.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/rune.c,v
retrieving revision 1.38
diff -c -5 -r1.38 rune.c
*** server/rune.c 18 Jun 2004 07:45:29 -0000 1.38
--- server/rune.c 29 Aug 2004 18:16:42 -0000
***************
*** 266,282 ****
--- 266,284 ----
trap->y=victim->y;
insert_ob_in_map(trap,victim->map,trap,0);
if (was_destroyed (trap, trap_tag))
return;
+ for(i = 0; i < MAX(1, trap->stats.maxhp); i++) {
if (trap->inv)
cast_spell(trap,trap,trap->direction,trap->inv,NULL);
else {
spell = arch_to_object(trap->other_arch);
cast_spell(trap,trap,trap->direction,spell,NULL);
free_object(spell);
}
+ }
} else {
rune_attack(trap,victim);
if (was_destroyed (trap, trap_tag))
return;
}
***************
*** 424,434 ****
/* now we set the trap level to match the difficulty of the level
* the formula below will give a level from 1 to (2*difficulty) with
* a peak probability at difficulty
*/
! trap->level = MAX(1, rndm(0, difficulty-1) + rndm(0, difficulty-1));
/* set the hiddenness of the trap, similar formula to above */
trap->stats.Cha = rndm(0, 19) + rndm(0, difficulty-1) + rndm(0, difficulty-1);
if (!trap->other_arch && !trap->inv) {
--- 426,438 ----
/* now we set the trap level to match the difficulty of the level
* the formula below will give a level from 1 to (2*difficulty) with
* a peak probability at difficulty
*/
! trap->level = rndm(0, difficulty-1) + rndm(0, difficulty-1);
! if(trap->level < 1)
! trap->level = 1;
/* set the hiddenness of the trap, similar formula to above */
trap->stats.Cha = rndm(0, 19) + rndm(0, difficulty-1) + rndm(0, difficulty-1);
if (!trap->other_arch && !trap->inv) {
***************
*** 440,451 ****
trap->stats.dam = 0;
for(i=0;i<difficulty;i++)
trap->stats.dam+=rndm(0, 4);
/* the poison trap special case */
! if(trap->attacktype & AT_POISON)
! trap->stats.dam = MAX(1, rndm(0, difficulty-1));
/* so we get an appropriate amnt of exp for AT_DEATH traps */
if(trap->attacktype & AT_DEATH) trap->stats.dam = 127;
}
--- 444,458 ----
trap->stats.dam = 0;
for(i=0;i<difficulty;i++)
trap->stats.dam+=rndm(0, 4);
/* the poison trap special case */
! if(trap->attacktype & AT_POISON) {
! trap->stats.dam = rndm(0, difficulty-1);
! if(trap->stats.dam < 1)
! trap->stats.dam = 1;
! }
/* so we get an appropriate amnt of exp for AT_DEATH traps */
if(trap->attacktype & AT_DEATH) trap->stats.dam = 127;
}
-------------- next part --------------
rune name dam attacktype slaying maxhp other_arch randomitems
======================================================================================================
Ball Lightning 1 magic elec ball lightning
Blasting 90 phys magic
Burning Hands 0 magic fire burning hands spell_burning_hands
Confusion 0 magic fire mass confusion
Create Bomb 90 phys magic create bomb
Death 400 death
diseased needle 10 phys needle_diseases
Dragon's Breath 0 magic fire dragonbreath spell_dragonbreath
Fire 30 magic fire
Fireball 90 magic cold large fireball 5
Fireball 90 magic cold medium fireball 5
Frost 35 magic cold
Heal 0 phys heal
Icestorm 0 magic cold icestorm spell_icestorm
Large Icestorm 0 magic cold large icestorm spell_large_icestorm
Lightning 90 magic cold small lightning 5
Magic Draining 0 magic cold magic drain spell_magic_drain
Magic Power 0 magic cold regenerate spellpoints
Magical Rune 0 magic
Nullification 1 magic cancellation
Paralysis 0 magic fire paralyze
Poison Cloud 0 magic fire poison cloud
Restoration 0 phys restoration
Shocking 40 magic elec
Summoning 90 magic cold summon air elemental 5
Summoning 90 magic cold summon devil 5
Summoning 90 magic cold summon earth elemental 5
Summoning 90 magic cold summon fire elemental 5
Summoning 90 magic cold summon water elemental 5
Transferrence 0 magic cold spell_transference
-------------- next part --------------
randomitems
======================================================================================================
Ball Lightning 1 magic elec spell_ball_lightning
Blasting 90 phys magic
Burning Hands 0 spell_burning_hands
Confusion 0 spell_mass_confusion
Create Bomb 90 phys spell_create_bomb
Death 400 death
diseased needle 10 phys needle_diseases
Dragon's Breath 0 spell_dragonbreath
Fire 30 magic fire
Fireball 90 magic fire spell_large_fireball
Fireball 90 magic fire spell_medium_fireball
Frost 35 magic cold
Heal 0 spell_heal
Icestorm 0 spell_icestorm
Large Icestorm 0 spell_large_icestorm
Lightning 90 magic elec spell_sm_lightning
Magic Draining 0 spell_magic_drain
Magic Power 0 spell_regenerate_spellpoints
Magical Rune 0 magic
Nullification 1 magic cancellation
Paralysis 0 spell_paralyze
Poison Cloud 0 spell_poison_cloud
Restoration 0 spell_restoration
Shocking 40 magic elec
Summoning 90 magic 5 spell_summon_air_elemental
Summoning 90 magic 5 spell_summon_devil
Summoning 90 magic 5 spell_summon_earth_elemental
Summoning 90 magic 5 spell_summon_fire_elemental
Summoning 90 magic 5 spell_summon_water_elemental
Transferrence 0 spell_transference
-------------- next part --------------
_______________________________________________
crossfire-devel mailing list
crossfire-devel at lists.real-time.com
https://mailman.real-time.com/mailman/listinfo/crossfire-devel
More information about the crossfire
mailing list