Skip to content

Commit 1af7cc2

Browse files
authored
Added Object Slappable property (dkfans#4794)
1 parent c050a30 commit 1af7cc2

16 files changed

Lines changed: 120 additions & 32 deletions

config/fxdata/magic.cfg

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,18 @@ Cooldown = 0
16781678
; BOUND_CRTRS - allow casting on creatures being affected by Armageddon and Teleport, those who are dragging, leaving or being sacrificed, allowing this may have bad side effects.
16791679
; ONLY_DIGGERS - can only be cast on special diggers.
16801680
; NO_DIGGERS - can only be cast on creatures that are not special diggers.
1681+
; ALL_OBJECTS - can target any object.
1682+
; OWNED_OBJECTS
1683+
; NEUTRL_OBJECTS
1684+
; ENEMY_OBJECTS
1685+
; ALL_OBJECTS_PICKUP - can target any object that can be picked up.
1686+
; OWNED_OBJECTS_PICKUP
1687+
; NEUTRL_OBJECTS_PICKUP
1688+
; ENEMY_OBJECTS_PICKUP
1689+
; ALL_OBJECTS_SLAP - can target any object that can be slapped.
1690+
; OWNED_OBJECTS_SLAP
1691+
; NEUTRL_OBJECTS_SLAP
1692+
; ENEMY_OBJECTS_SLAP
16811693
; Miscellaneous:
16821694
; NEEDS_DELAY - Requires a delay defined with 'Cooldown' in game turns before it can be cast again.
16831695
Castability =
@@ -1705,7 +1717,7 @@ SoundSamples = 0
17051717
SoundPlayed = 0
17061718
Power = 0 0 0 0 0 0 0 0 0 0
17071719
Cost = 0 0 0 0 0 0 0 0 0
1708-
Castability = ANYWHERE OWNED_CRTRS CUSTODY_CRTRS ALL_FOOD ALL_GOLD ALL_OBJECTS
1720+
Castability = ANYWHERE OWNED_CRTRS CUSTODY_CRTRS ALL_FOOD ALL_GOLD OWNED_OBJECTS_PICKUP
17091721
Artifact = SPELLBOOK_HOE
17101722
Properties = INSTINCTIVE
17111723
PlayerState = PLAYER_STATE_NONE
@@ -1768,7 +1780,7 @@ SoundPlayed = 75
17681780
Power = 0 0 0 0 0 0 0 0 0 0
17691781
Cost = 0 0 0 0 0 0 0 0 0
17701782
Duration = 500
1771-
Castability = ALL_GROUND OWNED_CRTRS BOUND_CRTRS CUSTODY_CRTRS OWNED_BOULDERS OWNED_FOOD
1783+
Castability = ALL_GROUND OWNED_CRTRS BOUND_CRTRS CUSTODY_CRTRS OWNED_BOULDERS OWNED_FOOD OWNED_OBJECTS_SLAP
17721784
Artifact = SPELLBOOK_SLAP
17731785
Properties = INSTINCTIVE
17741786
PlayerState = PLAYER_STATE_NONE
@@ -2280,7 +2292,7 @@ SoundSamples = 0
22802292
SoundPlayed = 109
22812293
Power = 0 0 0 0 0 0 0 0 0 0
22822294
Cost = 0 0 0 0 0 0 0 0 0
2283-
Castability = ANYWHERE OWNED_OBJECTS
2295+
Castability = ANYWHERE OWNED_OBJECTS_PICKUP
22842296
Artifact = NULL
22852297
Properties = INSTINCTIVE
22862298
PlayerState = PLAYER_STATE_NONE

config/fxdata/objects.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ FlameTransparencyFlags = 0
6969
Immobile = 0
7070
; Initial state, only used for chickens.
7171
InitialState = 0
72-
; Possible properties: EXISTS_ONLY_IN_ROOM, DESTROYED_ON_ROOM_CLAIM, CHOWNED_ON_ROOM_CLAIM, DESTROYED_ON_ROOM_PLACE, BUOYANT, BEATING, HEART, HOLD_IN_HAND, IGNORED_BY_IMPS.
72+
; Possible properties: EXISTS_ONLY_IN_ROOM, DESTROYED_ON_ROOM_CLAIM, CHOWNED_ON_ROOM_CLAIM, DESTROYED_ON_ROOM_PLACE, BUOYANT, BEATING, HEART, HOLD_IN_HAND, IGNORED_BY_IMPS, SLAPPABLE.
7373
Properties =
7474
; Function that should be executed to update the object.
7575
; UPDATE_DUNGEON_HEART, UPDATE_CALL_TO_ARMS, UPDATE_ARMOUR, UPDATE_OBJECT_SCALE, UPDATE_POWER_SIGHT, UPDATE_POWER_LIGHTNING, NULL.
@@ -325,7 +325,7 @@ Size_Z = 128
325325
MaximumSize = 300
326326
DestroyOnLava = 0
327327
DestroyOnLiquid = 1
328-
Health = 1000
328+
Health = 5
329329
FallAcceleration = 9
330330
HandIcon = 59
331331
HandAnimationID = 122
@@ -338,7 +338,7 @@ DrawClass = 2
338338
Persistence = 2
339339
Immobile = 0
340340
InitialState = 1
341-
Properties = DESTROYED_ON_ROOM_CLAIM
341+
Properties = DESTROYED_ON_ROOM_CLAIM SLAPPABLE
342342
UpdateFunction = NULL
343343

344344
[object11]

src/config_magic.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ const struct LongNamedCommand powermodel_castability_commands[] = {
377377
{"OWNED_OBJECTS", PwCast_OwnedObjects},
378378
{"NEUTRL_OBJECTS", PwCast_NeutrlObjects},
379379
{"ENEMY_OBJECTS", PwCast_EnemyObjects},
380+
{"ALL_OBJECTS_PICKUP", PwCast_AllObjectsPickup},
381+
{"OWNED_OBJECTS_PICKUP", PwCast_OwnedObjectsPickup},
382+
{"NEUTRL_OBJECTS_PICKUP", PwCast_NeutrlObjectsPickup},
383+
{"ENEMY_OBJECTS_PICKUP", PwCast_EnemyObjectsPickup},
384+
{"ALL_OBJECTS_SLAP", PwCast_AllObjectsSlap},
385+
{"OWNED_OBJECTS_SLAP", PwCast_OwnedObjectsSlap},
386+
{"NEUTRL_OBJECTS_SLAP", PwCast_NeutrlObjectsSlap},
387+
{"ENEMY_OBJECTS_SLAP", PwCast_EnemyObjectsSlap},
380388
{NULL, 0},
381389
};
382390

src/config_magic.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,19 @@ enum ShotModelFlags {
197197
#define PwCast_OwnedObjects (1LL << 32)
198198
#define PwCast_NeutrlObjects (1LL << 33)
199199
#define PwCast_EnemyObjects (1LL << 34)
200+
#define PwCast_OwnedObjectsPickup (1LL << 35)
201+
#define PwCast_NeutrlObjectsPickup (1LL << 36)
202+
#define PwCast_EnemyObjectsPickup (1LL << 37)
203+
#define PwCast_OwnedObjectsSlap (1LL << 38)
204+
#define PwCast_NeutrlObjectsSlap (1LL << 39)
205+
#define PwCast_EnemyObjectsSlap (1LL << 40)
200206

201207
#define PwCast_AllCrtrs (PwCast_CustodyCrtrs|PwCast_OwnedCrtrs|PwCast_AlliedCrtrs|PwCast_EnemyCrtrs|PwCast_NConscCrtrs|PwCast_BoundCrtrs)
202208
#define PwCast_AllFood (PwCast_OwnedFood|PwCast_NeutrlFood|PwCast_EnemyFood)
203209
#define PwCast_AllGold (PwCast_OwnedGold|PwCast_NeutrlGold|PwCast_EnemyGold)
204210
#define PwCast_AllObjects (PwCast_OwnedObjects|PwCast_NeutrlObjects|PwCast_EnemyObjects)
211+
#define PwCast_AllObjectsPickup (PwCast_OwnedObjectsPickup|PwCast_NeutrlObjectsPickup|PwCast_EnemyObjectsPickup)
212+
#define PwCast_AllObjectsSlap (PwCast_OwnedObjectsSlap|PwCast_NeutrlObjectsSlap|PwCast_EnemyObjectsSlap)
205213
#define PwCast_AllThings (PwCast_CustodyCrtrs|PwCast_OwnedCrtrs|PwCast_AlliedCrtrs|PwCast_EnemyCrtrs|PwCast_AllFood|PwCast_AllGold|PwCast_OwnedSpell|PwCast_OwnedBoulders|PwCast_AllObjects)
206214
#define PwCast_AllGround (PwCast_UnclmdGround|PwCast_NeutrlGround|PwCast_OwnedGround|PwCast_AlliedGround|PwCast_EnemyGround)
207215
#define PwCast_NotEnemyGround (PwCast_UnclmdGround|PwCast_NeutrlGround|PwCast_OwnedGround|PwCast_AlliedGround)

src/config_objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const struct NamedCommand objects_properties_commands[] = {
5858
{"HEART", OMF_Heart },
5959
{"HOLD_IN_HAND", OMF_HoldInHand },
6060
{"IGNORED_BY_IMPS", OMF_IgnoredByImps },
61+
{"SLAPPABLE", OMF_Slappable },
6162
{NULL, 0},
6263
};
6364

src/config_objects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ enum ObjectModelFlags {
5858
OMF_Heart = 0x0040, // Functions as the heart of the dungeon
5959
OMF_HoldInHand = 0x0080, // Object can be picked up to hold
6060
OMF_IgnoredByImps = 0x0100, // Specialdiggers don't dragging this object
61+
OMF_Slappable = 0x0200, // Object can be slapped
6162
};
6263

6364

src/magic_powers.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,29 +300,71 @@ TbBool can_cast_power_on_thing(PlayerNumber plyr_idx, const struct Thing *thing,
300300
}
301301
}
302302
if ((powerst->can_cast_flags & PwCast_OwnedObjects) != 0)
303+
{
304+
if (thing->owner == plyr_idx) {
305+
return true;
306+
}
307+
}
308+
if ((powerst->can_cast_flags & PwCast_NeutrlObjects) != 0)
309+
{
310+
if (is_neutral_thing(thing)) {
311+
return true;
312+
}
313+
}
314+
if ((powerst->can_cast_flags & PwCast_EnemyObjects) != 0)
315+
{
316+
if ((thing->owner != plyr_idx) && !is_neutral_thing(thing)) {
317+
return true;
318+
}
319+
}
320+
if ((powerst->can_cast_flags & PwCast_OwnedObjectsPickup) != 0)
303321
{
304322
if (thing->owner == plyr_idx) {
305323
if (object_is_pickable_by_hand_to_hold(thing)) {
306324
return true;
307325
}
308326
}
309327
}
310-
if ((powerst->can_cast_flags & PwCast_NeutrlObjects) != 0)
328+
if ((powerst->can_cast_flags & PwCast_NeutrlObjectsPickup) != 0)
311329
{
312330
if (is_neutral_thing(thing)) {
313331
if (object_is_pickable_by_hand_to_hold(thing)) {
314332
return true;
315333
}
316334
}
317335
}
318-
if ((powerst->can_cast_flags & PwCast_EnemyObjects) != 0)
336+
if ((powerst->can_cast_flags & PwCast_EnemyObjectsPickup) != 0)
319337
{
320338
if ((thing->owner != plyr_idx) && !is_neutral_thing(thing)) {
321339
if (object_is_pickable_by_hand_to_hold(thing)) {
322340
return true;
323341
}
324342
}
325343
}
344+
if ((powerst->can_cast_flags & PwCast_OwnedObjectsSlap) != 0)
345+
{
346+
if (thing->owner == plyr_idx) {
347+
if (object_is_slappable(thing)) {
348+
return true;
349+
}
350+
}
351+
}
352+
if ((powerst->can_cast_flags & PwCast_NeutrlObjectsSlap) != 0)
353+
{
354+
if (is_neutral_thing(thing)) {
355+
if (object_is_slappable(thing)) {
356+
return true;
357+
}
358+
}
359+
}
360+
if ((powerst->can_cast_flags & PwCast_EnemyObjectsSlap) != 0)
361+
{
362+
if ((thing->owner != plyr_idx) && !is_neutral_thing(thing)) {
363+
if (object_is_slappable(thing)) {
364+
return true;
365+
}
366+
}
367+
}
326368
if ((powerst->can_cast_flags & PwCast_OwnedSpell) != 0)
327369
{
328370
if (thing->owner == plyr_idx) {
@@ -337,7 +379,7 @@ TbBool can_cast_power_on_thing(PlayerNumber plyr_idx, const struct Thing *thing,
337379
if ((powerst->can_cast_flags & PwCast_OwnedBoulders) != 0)
338380
{
339381
if (thing->owner == plyr_idx) {
340-
if (shot_is_slappable(thing, plyr_idx)) {
382+
if (shot_is_slappable_by_player(thing, plyr_idx)) {
341383
return true;
342384
}
343385
}

src/packets_input.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ TbBool process_dungeon_control_packet_dungeon_control(long plyr_idx)
517517
{
518518
if (player->primary_cursor_state == CSt_PowerHand && (!player->one_click_lock_cursor)) {
519519
thing = get_nearest_thing_for_slap(plyr_idx, subtile_coord_center(stl_x), subtile_coord_center(stl_y));
520-
magic_use_available_power_on_thing(plyr_idx, PwrK_SLAP, 0, stl_x, stl_y, thing, PwMod_Default);
520+
if(!thing_is_invalid(thing))
521+
magic_use_available_power_on_thing(plyr_idx, PwrK_SLAP, 0, stl_x, stl_y, thing, PwMod_Default);
521522
}
522523
if ((pckt->control_flags & PCtr_LBtnHeld) == 0)
523524
{

src/player_instances.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ long pinstfe_hand_whip(struct PlayerInfo *player, int32_t *n)
281281
case TCls_Object:
282282
{
283283
struct Thing* efftng;
284-
if (object_is_slappable(thing, player->id_number))
284+
if (object_is_slappable_by_player(thing, player->id_number))
285285
{
286286
efftng = create_effect(&thing->mappos, TngEff_Dummy, thing->owner);
287287
if (!thing_is_invalid(efftng))

src/power_hand.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ TbBool can_thing_be_picked_up2_by_player(const struct Thing *thing, PlayerNumber
275275
}
276276
}
277277

278-
struct Thing *process_object_being_picked_up(struct Thing *thing, long plyr_idx)
278+
struct Thing *process_object_being_picked_up(struct Thing *thing, PlayerNumber plyr_idx)
279279
{
280280
struct Thing *picktng = INVALID_THING;
281281
struct Coord3d pos;
@@ -309,7 +309,7 @@ struct Thing *process_object_being_picked_up(struct Thing *thing, long plyr_idx)
309309
{
310310
picktng = create_gold_for_hand_grab(thing, plyr_idx);
311311
}
312-
else if (object_is_pickable_by_hand_to_hold_by_player(thing, plyr_idx))
312+
else if (object_is_pickable_by_hand_to_hold(thing))
313313
{
314314
picktng = thing;
315315
}
@@ -718,10 +718,17 @@ void draw_power_hand(void)
718718
}
719719
}
720720

721-
TbBool object_is_slappable(const struct Thing *thing, long plyr_idx)
721+
TbBool object_is_slappable(const struct Thing* thing)
722722
{
723-
if (thing->owner == plyr_idx) {
724-
return (object_is_mature_food(thing));
723+
struct ObjectConfigStats* objst = get_object_model_stats(thing->model);
724+
return ((objst->model_flags & OMF_Slappable) != 0);
725+
}
726+
727+
TbBool object_is_slappable_by_player(const struct Thing *thing, PlayerNumber plyr_idx)
728+
{
729+
if (thing->owner == plyr_idx)
730+
{
731+
return object_is_slappable(thing);
725732
}
726733
return false;
727734
}
@@ -785,18 +792,18 @@ long near_map_block_thing_filter_ready_for_hand_or_slap(const struct Thing *thin
785792
return -1;
786793
}
787794

788-
TbBool thing_slappable(const struct Thing *thing, long plyr_idx)
795+
TbBool thing_slappable(const struct Thing *thing, PlayerNumber plyr_idx)
789796
{
790797
switch (thing->class_id)
791798
{
792799
case TCls_Object:
793-
return object_is_slappable(thing, plyr_idx);
800+
return object_is_slappable_by_player(thing, plyr_idx);
794801
case TCls_Shot:
795-
return shot_is_slappable(thing, plyr_idx);
802+
return shot_is_slappable_by_player(thing, plyr_idx);
796803
case TCls_Creature:
797804
return creature_is_slappable(thing, plyr_idx);
798805
case TCls_Trap:
799-
return trap_is_slappable(thing, plyr_idx);
806+
return trap_is_slappable_by_player(thing, plyr_idx);
800807
default:
801808
return false;
802809
}
@@ -1465,8 +1472,7 @@ TbResult use_power_hand(PlayerNumber plyr_idx, MapSubtlCoord stl_x, MapSubtlCoor
14651472
}
14661473
if (!can_thing_be_picked_up_by_player(thing, plyr_idx))
14671474
{
1468-
ERRORLOG("The %s owned by player %d is not pickable by player %d",thing_model_name(thing),(int)thing->owner,(int)plyr_idx);
1469-
return Lb_OK;
1475+
return Lb_FAIL;
14701476
}
14711477
if (thing_is_special_box(thing))
14721478
{
@@ -1519,10 +1525,12 @@ void stop_creatures_around_hand(PlayerNumber plyr_idx, MapSubtlCoord stl_x, Map
15191525
}
15201526
}
15211527

1528+
#define HAND_TO_OBJECT_SLAP_DAMAGE 10
15221529
TbBool slap_object(struct Thing *thing)
15231530
{
1524-
if (object_is_mature_food(thing)) {
1525-
destroy_object(thing);
1531+
if (object_is_slappable(thing))
1532+
{
1533+
apply_damage_to_thing(thing, HAND_TO_OBJECT_SLAP_DAMAGE, thing->owner);
15261534
return true;
15271535
}
15281536
return false;

0 commit comments

Comments
 (0)