1 /*-------------------------------------------------------------------------------
2
3 BARONY
4 File: entity_editor.cpp
5 Desc: implements a dummy entity class so the editor can compile
6 Yes, this file is an utter bodge. If a better solution can be found, great!
7
8 Copyright 2013-2016 (c) Turning Wheel LLC, all rights reserved.
9 See LICENSE for details.
10
11 -------------------------------------------------------------------------------*/
12 #include "entity.hpp"
13
14
15
Entity(Sint32 in_sprite,Uint32 pos,list_t * entlist,list_t * creaturelist)16 Entity::Entity(Sint32 in_sprite, Uint32 pos, list_t* entlist, list_t* creaturelist) :
17 char_gonnavomit(skill[26]),
18 char_heal(skill[22]),
19 char_energize(skill[23]),
20 char_torchtime(skill[25]),
21 char_poison(skill[21]),
22 char_fire(skill[36]),
23 chanceToPutOutFire(skill[37]),
24 circuit_status(skill[28]),
25 switch_power(skill[0]),
26 chestInit(skill[0]),
27 chestStatus(skill[1]),
28 chestHealth(skill[3]),
29 chestLocked(skill[4]),
30 chestOpener(skill[5]),
31 chestLidClicked(skill[6]),
32 chestAmbience(skill[7]),
33 chestMaxHealth(skill[8]),
34 chestType(skill[9]),
35 chestPreventLockpickCapstoneExploit(skill[10]),
36 chestHasVampireBook(skill[11]),
37 chestLockpickHealth(skill[12]),
38 monsterState(skill[0]),
39 monsterTarget(skill[1]),
40 monsterTargetX(fskill[2]),
41 monsterTargetY(fskill[3]),
42 crystalInitialised(skill[1]),
43 crystalTurning(skill[3]),
44 crystalTurnStartDir(skill[4]),
45 crystalGeneratedElectricityNodes(skill[5]),
46 crystalNumElectricityNodes(skill[6]),
47 crystalHoverDirection(skill[7]),
48 crystalHoverWaitTimer(skill[8]),
49 crystalTurnReverse(skill[9]),
50 crystalSpellToActivate(skill[10]),
51 crystalStartZ(fskill[0]),
52 crystalMaxZVelocity(fskill[1]),
53 crystalMinZVelocity(fskill[2]),
54 crystalTurnVelocity(fskill[3]),
55 monsterAnimationLimbDirection(skill[20]),
56 monsterAnimationLimbOvershoot(skill[30]),
57 monsterSpecialTimer(skill[29]),
58 monsterSpecialState(skill[33]),
59 monsterSpellAnimation(skill[31]),
60 monsterFootstepType(skill[32]),
61 monsterLookTime(skill[4]),
62 monsterMoveTime(skill[6]),
63 monsterLookDir(fskill[4]),
64 monsterEntityRenderAsTelepath(skill[41]),
65 playerLevelEntrySpeech(skill[18]),
66 playerAliveTime(skill[12]),
67 playerVampireCurse(skill[51]),
68 playerAutomatonDeathCounter(skill[15]),
69 playerCreatedDeathCam(skill[16]),
70 monsterAttack(skill[8]),
71 monsterAttackTime(skill[9]),
72 monsterArmbended(skill[10]),
73 monsterWeaponYaw(fskill[5]),
74 monsterShadowInitialMimic(skill[34]),
75 monsterShadowDontChangeName(skill[35]),
76 monsterLichFireMeleeSeq(skill[34]),
77 monsterLichFireMeleePrev(skill[35]),
78 monsterLichIceCastSeq(skill[34]),
79 monsterLichIceCastPrev(skill[35]),
80 monsterLichMagicCastCount(skill[37]),
81 monsterLichMeleeSwingCount(skill[38]),
82 monsterLichBattleState(skill[27]),
83 monsterLichTeleportTimer(skill[40]),
84 monsterLichAllyStatus(skill[18]),
85 monsterLichAllyUID(skill[17]),
86 monsterPathBoundaryXStart(skill[14]),
87 monsterPathBoundaryYStart(skill[15]),
88 monsterPathBoundaryXEnd(skill[16]),
89 monsterPathBoundaryYEnd(skill[17]),
90 monsterStoreType(skill[18]),
91 monsterStrafeDirection(skill[39]),
92 monsterPathCount(skill[38]),
93 monsterAllyIndex(skill[42]),
94 monsterAllyState(skill[43]),
95 monsterAllyPickupItems(skill[44]),
96 monsterAllyInteractTarget(skill[45]),
97 monsterAllyClass(skill[46]),
98 monsterDefend(skill[47]),
99 monsterAllySpecial(skill[48]),
100 monsterAllySpecialCooldown(skill[49]),
101 monsterAllySummonRank(skill[50]),
102 monsterKnockbackVelocity(fskill[9]),
103 monsterKnockbackUID(skill[51]),
104 creatureWebbedSlowCount(skill[52]),
105 monsterFearfulOfUid(skill[53]),
106 creatureShadowTaggedThisUid(skill[54]),
107 monsterIllusionTauntingThisUid(skill[55]),
108 monsterLastDistractedByNoisemaker(skill[55]),
109 monsterSentrybotLookDir(fskill[10]),
110 monsterKnockbackTangentDir(fskill[11]),
111 playerStrafeVelocity(fskill[12]),
112 playerStrafeDir(fskill[13]),
113 entityShowOnMap(skill[59]),
114 effectPolymorph(skill[50]),
115 effectShapeshift(skill[53]),
116 particleDuration(skill[0]),
117 particleShrink(skill[1]),
118 monsterHitTime(skill[7]),
119 itemNotMoving(skill[18]),
120 itemNotMovingClient(skill[19]),
121 itemSokobanReward(skill[20]),
122 itemOriginalOwner(skill[21]),
123 itemStolen(skill[22]),
124 itemShowOnMap(skill[23]),
125 itemDelayMonsterPickingUp(skill[24]),
126 itemReceivedDetailsFromServer(skill[25]),
127 itemAutoSalvageByPlayer(skill[26]),
128 gateInit(skill[1]),
129 gateStatus(skill[3]),
130 gateRattle(skill[4]),
131 gateStartHeight(fskill[0]),
132 gateVelZ(vel_z),
133 gateInverted(skill[5]),
134 gateDisableOpening(skill[6]),
135 leverStatus(skill[1]),
136 leverTimerTicks(skill[3]),
137 boulderTrapRefireAmount(skill[1]),
138 boulderTrapRefireDelay(skill[3]),
139 boulderTrapAmbience(skill[6]),
140 boulderTrapFired(skill[0]),
141 boulderTrapRefireCounter(skill[4]),
142 boulderTrapPreDelay(skill[5]),
143 boulderTrapRocksToSpawn(skill[7]),
144 doorDir(skill[0]),
145 doorInit(skill[1]),
146 doorStatus(skill[3]),
147 doorHealth(skill[4]),
148 doorLocked(skill[5]),
149 doorSmacked(skill[6]),
150 doorTimer(skill[7]),
151 doorOldStatus(skill[8]),
152 doorMaxHealth(skill[9]),
153 doorStartAng(fskill[0]),
154 doorPreventLockpickExploit(skill[10]),
155 doorForceLockedUnlocked(skill[11]),
156 doorDisableLockpicks(skill[12]),
157 doorDisableOpening(skill[13]),
158 doorLockpickHealth(skill[14]),
159 particleTimerDuration(skill[0]),
160 particleTimerEndAction(skill[1]),
161 particleTimerEndSprite(skill[3]),
162 particleTimerCountdownAction(skill[4]),
163 particleTimerCountdownSprite(skill[5]),
164 particleTimerTarget(skill[6]),
165 particleTimerPreDelay(skill[7]),
166 particleTimerVariable1(skill[8]),
167 particleTimerVariable2(skill[9]),
168 pedestalHasOrb(skill[0]),
169 pedestalOrbType(skill[1]),
170 pedestalInvertedPower(skill[3]),
171 pedestalInGround(skill[4]),
172 pedestalInit(skill[5]),
173 pedestalAmbience(skill[6]),
174 pedestalLockOrb(skill[7]),
175 orbInitialised(skill[1]),
176 orbHoverDirection(skill[7]),
177 orbHoverWaitTimer(skill[8]),
178 orbStartZ(fskill[0]),
179 orbMaxZVelocity(fskill[1]),
180 orbMinZVelocity(fskill[2]),
181 orbTurnVelocity(fskill[3]),
182 portalAmbience(skill[0]),
183 portalInit(skill[1]),
184 portalNotSecret(skill[3]),
185 portalVictoryType(skill[4]),
186 portalFireAnimation(skill[5]),
187 portalCustomLevelsToJump(skill[6]),
188 portalCustomRequiresPower(skill[7]),
189 portalCustomSprite(skill[8]),
190 portalCustomSpriteAnimationFrames(skill[9]),
191 portalCustomZOffset(skill[10]),
192 portalCustomLevelText1(skill[11]),
193 portalCustomLevelText2(skill[12]),
194 portalCustomLevelText3(skill[13]),
195 portalCustomLevelText4(skill[14]),
196 portalCustomLevelText5(skill[15]),
197 portalCustomLevelText6(skill[16]),
198 portalCustomLevelText7(skill[17]),
199 portalCustomLevelText8(skill[18]),
200 teleporterX(skill[0]),
201 teleporterY(skill[1]),
202 teleporterType(skill[3]),
203 teleporterAmbience(skill[4]),
204 spellTrapType(skill[0]),
205 spellTrapRefire(skill[1]),
206 spellTrapLatchPower(skill[3]),
207 spellTrapFloorTile(skill[4]),
208 spellTrapRefireRate(skill[5]),
209 spellTrapAmbience(skill[6]),
210 spellTrapInit(skill[7]),
211 spellTrapCounter(skill[8]),
212 spellTrapReset(skill[9]),
213 ceilingTileModel(skill[0]),
214 floorDecorationModel(skill[0]),
215 floorDecorationRotation(skill[1]),
216 floorDecorationHeightOffset(skill[3]),
217 floorDecorationXOffset(skill[4]),
218 floorDecorationYOffset(skill[5]),
219 floorDecorationInteractText1(skill[8]),
220 floorDecorationInteractText2(skill[9]),
221 floorDecorationInteractText3(skill[10]),
222 floorDecorationInteractText4(skill[11]),
223 floorDecorationInteractText5(skill[12]),
224 floorDecorationInteractText6(skill[13]),
225 floorDecorationInteractText7(skill[14]),
226 floorDecorationInteractText8(skill[15]),
227 furnitureType(skill[0]),
228 furnitureInit(skill[1]),
229 furnitureDir(skill[3]),
230 furnitureHealth(skill[4]),
231 furnitureMaxHealth(skill[9]),
232 furnitureTableRandomItemChance(skill[10]),
233 furnitureTableSpawnChairs(skill[11]),
234 pistonCamDir(skill[0]),
235 pistonCamTimer(skill[1]),
236 pistonCamRotateSpeed(fskill[0]),
237 arrowPower(skill[3]),
238 arrowPoisonTime(skill[4]),
239 arrowArmorPierce(skill[5]),
240 arrowSpeed(fskill[4]),
241 arrowFallSpeed(fskill[5]),
242 arrowBoltDropOffRange(skill[6]),
243 arrowShotByWeapon(skill[7]),
244 arrowQuiverType(skill[8]),
245 arrowShotByParent(skill[9]),
246 actmagicIsVertical(skill[6]),
247 actmagicIsOrbiting(skill[7]),
248 actmagicOrbitDist(skill[8]),
249 actmagicOrbitVerticalDirection(skill[9]),
250 actmagicOrbitLifetime(skill[10]),
251 actmagicMirrorReflected(skill[24]),
252 actmagicMirrorReflectedCaster(skill[12]),
253 actmagicCastByMagicstaff(skill[13]),
254 actmagicOrbitVerticalSpeed(fskill[2]),
255 actmagicOrbitStartZ(fskill[3]),
256 actmagicOrbitStationaryX(fskill[4]),
257 actmagicOrbitStationaryY(fskill[5]),
258 actmagicOrbitStationaryCurrentDist(fskill[6]),
259 actmagicOrbitStationaryHitTarget(skill[14]),
260 actmagicOrbitHitTargetUID1(skill[15]),
261 actmagicOrbitHitTargetUID2(skill[16]),
262 actmagicOrbitHitTargetUID3(skill[17]),
263 actmagicOrbitHitTargetUID4(skill[18]),
264 actmagicProjectileArc(skill[19]),
265 actmagicOrbitCastFromSpell(skill[20]),
266 actmagicSpellbookBonus(skill[21]),
267 actmagicCastByTinkerTrap(skill[22]),
268 actmagicTinkerTrapFriendlyFire(skill[23]),
269 goldAmount(skill[0]),
270 goldAmbience(skill[1]),
271 goldSokoban(skill[2]),
272 interactedByMonster(skill[47]),
273 soundSourceFired(skill[0]),
274 soundSourceToPlay(skill[1]),
275 soundSourceVolume(skill[2]),
276 soundSourceLatchOn(skill[3]),
277 soundSourceDelay(skill[4]),
278 soundSourceDelayCounter(skill[5]),
279 soundSourceOrigin(skill[6]),
280 lightSourceBrightness(skill[0]),
281 lightSourceAlwaysOn(skill[1]),
282 lightSourceInvertPower(skill[2]),
283 lightSourceLatchOn(skill[3]),
284 lightSourceRadius(skill[4]),
285 lightSourceFlicker(skill[5]),
286 lightSourceDelay(skill[6]),
287 lightSourceDelayCounter(skill[7]),
288 textSourceColorRGB(skill[0]),
289 textSourceVariables4W(skill[1]),
290 textSourceDelay(skill[2]),
291 textSourceIsScript(skill[3]),
292 textSourceBegin(skill[4]),
293 signalActivateDelay(skill[1]),
294 signalTimerInterval(skill[2]),
295 signalTimerRepeatCount(skill[3]),
296 signalTimerLatchInput(skill[4]),
297 signalInputDirection(skill[5]),
298 thrownProjectilePower(skill[19]),
299 thrownProjectileCharge(skill[20]),
300 playerStartDir(skill[1])
301 {
302 int c;
303 // add the entity to the entity list
304 if (!pos)
305 {
306 mynode = list_AddNodeFirst(entlist);
307 }
308 else
309 {
310 mynode = list_AddNodeLast(entlist);
311 }
312 mynode->element = this;
313 mynode->deconstructor = &entityDeconstructor;
314 mynode->size = sizeof(Entity);
315
316 myCreatureListNode = nullptr;
317
318 // now reset all of my data elements
319 lastupdate = 0;
320 lastupdateserver = 0;
321 ticks = 0;
322 x = 0;
323 y = 0;
324 z = 0;
325 new_x = 0;
326 new_y = 0;
327 new_z = 0;
328 focalx = 0;
329 focaly = 0;
330 focalz = 0;
331 scalex = 1;
332 scaley = 1;
333 scalez = 1;
334 vel_x = 0;
335 vel_y = 0;
336 vel_z = 0;
337 sizex = 0;
338 sizey = 0;
339 yaw = 0;
340 pitch = 0;
341 roll = 0;
342 new_yaw = 0;
343 new_pitch = 0;
344 new_roll = 0;
345 sprite = in_sprite;
346 light = nullptr;
347 string = nullptr;
348 children.first = nullptr;
349 children.last = nullptr;
350 //this->magic_effects = (list_t *) malloc(sizeof(list_t));
351 //this->magic_effects->first = NULL; this->magic_effects->last = NULL;
352 for ( c = 0; c < NUMENTITYSKILLS; ++c )
353 {
354 skill[c] = 0;
355 }
356 for (c = 0; c < NUMENTITYFSKILLS; ++c)
357 {
358 fskill[c] = 0;
359 }
360 skill[2] = -1;
361 for (c = 0; c < 16; ++c)
362 {
363 flags[c] = false;
364 }
365 if (entlist == map.entities)
366 {
367 if (multiplayer != CLIENT || loading)
368 {
369 uid = entity_uids;
370 entity_uids++;
371 }
372 else
373 {
374 uid = -2;
375 }
376 }
377 else
378 {
379 uid = -2;
380 }
381 behavior = nullptr;
382 ranbehavior = false;
383 parent = 0;
384 path = nullptr;
385
386 clientStats = nullptr;
387 clientsHaveItsStats = false;
388 }
389
~Entity()390 Entity::~Entity()
391 {
392 if ( clientStats )
393 {
394 delete clientStats;
395 }
396 }
397
getStats() const398 Stat* Entity::getStats() const
399 {
400
401 if ( this->children.first != nullptr )
402 {
403 if ( this->children.first->next != nullptr )
404 {
405 return (Stat*)this->children.first->next->element;
406 }
407 }
408
409
410 return nullptr;
411 }
412
addToCreatureList(list_t * list)413 void Entity::addToCreatureList(list_t *list)
414 {
415 return;
416 }
417
isInvisible() const418 bool Entity::isInvisible() const
419 {
420 //Dummy function.
421 return false;
422 }
423
actMonster(Entity * my)424 void actMonster(Entity* my)
425 {
426 return;
427 }
428
actPlayer(Entity * my)429 void actPlayer(Entity* my)
430 {
431 return;
432 }
433
actSpriteNametag(Entity * my)434 void actSpriteNametag(Entity* my)
435 {
436 // dummy function
437 return;
438 }
439
playerEntityMatchesUid(Uint32 uid)440 int playerEntityMatchesUid(Uint32 uid)
441 {
442 return -1;
443 }
444
isPlayerHeadSprite()445 bool Entity::isPlayerHeadSprite()
446 {
447 // dummy function
448 return false;
449 }
450
monsterChangesColorWhenAlly(Stat * myStats,Entity * entity)451 bool monsterChangesColorWhenAlly(Stat* myStats, Entity* entity)
452 {
453 // dummy function
454 return false;
455 }