Commit graph

1219 commits

Author SHA1 Message Date
David Kindl
d0a51b4291
Cleanup:
- remove trailing whitespaces
- clang-format: MaxEmptyLinesToKeep: 2
- grammar
2025-05-28 09:34:58 +02:00
Orfeo Ciano
6194606ab9
Add "getting started" documentation (#1276) 2024-08-26 18:45:16 +02:00
Raylde
baf9658f05
Add GitHub actions and project folder clean up (#925) 2022-11-01 12:45:48 +01:00
cbnolok
a5412da290 Added lazy evaluation of expressions inside conditional statements (IF/ELIF/ELSEIF).
- Changed: Now conditional statements (IF/ELIF/ELSEIF) will perform a lazy evaluation of the conditional expression, whereas before they fully evaluated the whole expression.
 Lazy evaluation means that the expression will be evaluated one piece (or, one subexpression) at a time. At each stage, if it's sure that the whole expression value (true or false) won't change
 even if new subexpressions will be evaluated, the evaluation will stop there.
 Example:
  IF (<LINK.ISVALID> && (<LINK.TAG0.test> == 1))
  Won't return an error if item's LINK is invalid or not set, because the evaluation will only halt to <LINK.ISVALID>.
 Other than allowing more flexible IF tests in just one line, this change will grant faster evaluation times for complex IF tests.
2021-01-11 20:55:27 +01:00
cbnolok
73d6dcebe5 Fixed lazy parsing of nested QVALs and added new TRY behavior.
Added errors on a few more invalid operations (r_Verb on invalid object).

- Changed: Now TRY can be used to explicitly "TRY" to execute a command or set a property on an object which may or may not exist.
  If the object doesn't exist, no operation is done and no error is returned. It can't be used to TRY to retrieve a value (like <TRY FINDID.invalid_item.NAME>).
  Its use is DISCOURAGED, but sometimes it might be an easy way to execute trivial operations without a lot of if/endif clauses.
  This is a way to explicitly allow what Sphere already did by default in the past (not checking if the object is valid and not returning an error),
  which is something that only sometimes we expect and we want, most of the times it caused obscure bugs.
2021-01-03 20:46:15 +01:00
cbnolok
0dc1b58f17 Added: ISVALID keyword to check if a script object is valid (LINK/REFx/ARGO/REGION), instead of having to check them against numbers (0 or -1/0FFFFFFFF). 2021-01-01 17:12:16 +01:00
cbnolok
881ef75f16 - Changed: Accessing invalid objects (like REFx/OBJ/ARGO/LINK.something) now returns an error. This was needed because many invalid operations were not executed and there wasn't any trace in the log, leading to difficult script debugging and unexpected behaviors.
If you just want to test the object (like <OBJ>), like always, 0 will be returned with no error if it's invalid.

Fixed: PacketContainer (0xF7) using wrong base class and constructor arguments.
Changed: restricted data types accepted by CUID methods, avoiding multiple misuse cases and unnecessary type conversions.
2020-12-29 19:41:45 +01:00
cbnolok
89f0bdf008 Added: RESDEFNAME section, similar to the DEFNAME one but to be used to define aliases for Sphere resources (as example for backward compatibility defnames in scripts).
Thus, backwards compatibility defnames should be moved inside a RESDEFNAME section (Issue #357).
2020-12-20 22:28:14 +01:00
Jhobean
4f6cfc92be
Fix sell system do not show/give correct gold (Issue #456) (#545)
Fix sell system do not show/give correct gold (Issue #456)
2020-12-01 14:57:26 +01:00
cbnolok
9ce0ad5c29 Added f_onchar_create_init, changes/additions to @(Item)DropOn_Ground triggers, disabled VS code analysis for 3rd party code.
- Added: f_onchar_create_init function in core/serv_triggers.scp; it's called after the client sent the character creation data, but before
	the character is created server-side (f_onchar_create is called after the creation, so the function arguments are read-only).
	Function parameters:
	 Variables:
	   Read-Write:
		 ARGN1 --> Feature flags sent by client
		 ARGN2 --> Character profession (0=Advanced, 1=Warrior, 2=Mage, 3=Blacksmith, 4=Necromancer, 5=Paladin, 6=Samurai, 7=Ninja)
		 ARGN3 --> Character race (1=Human, 2=Elf, 3=Gargoyle)
	   Read-Only:
		 ARGS  --> Account name
		 ARGO  --> Client creating the character
	 Return:
		0 --> Allow character creation (default action)
		1 --> Deny character creation
- Fixed: @(Item)DropOn_Ground ARGS not being used, as indicated in the wiki.
- Changed: @(Item)DropOn_Ground now fires BEFORE the new P is set! The new P is stored in the ARGS of the trigger. Prior to this change, the triggers were called after the new P was set.
- Added: In @(Item)DropOn_Ground, ARGN2 value is now == 1 if the trigger is called during a BOUNCE check (the char is overloaded and the item is being dropped on ground).
- Fixed: @(Item)DropOn_Ground not firing when, during a BOUNCE check, the char was overloaded and the item was being dropped on ground (Issue #295).

Disabled Visual Studio 2019 static code analysis for 3rd party code (zlib, deelx, sqlite).
Fixed a couple of warnings reported by VS2019 code analysis.
2019-08-10 18:37:24 +02:00
cbnolok
76c9cdf488 Fixed various issues, reorganized docs folder, little cleanup of spheresvr.cpp.
- Fixed: WEIGHTREDUCTION not working correctly for items inside a container (Issue #289).
- Fixed: Retrieving a value from an unexistant LIST did not return -1; overwriting a LIST element generated an exception (Issue #290).
- Fixed: Profiler and worldsave message showing incorrect times (Issue #296).
- Fixed: Client listing showing the number of the online clients at the end of the list, instead of the top.
- Added: Doc file "Porting from 0.55 to 0.56.txt" (the content was posted years ago by XuN on the forum).

Changed GetPreciseSysTimeNano to GetPreciseSysTimeMicro, nanoseconds timer isn't so precise and it isn't even worth it.
Disabled DEBUGF_EXP log message when the delta exp is == 0.
Added class GlobalInitializer to initialize some global variables and do pre-server startup sanity checks and function calls.
Moved GetTimeMinDesc function from spheresvr.cpp to a static method of CServerTime.
Removed unused bFull parameter from CObjBase::CallPersonalTrigger.
2019-07-21 23:17:59 +02:00
cbnolok
4638cf130a Fixed some includes path, renamed and moved changelogs, added comments to CMake MSVC toolchain. 2016-05-14 12:02:15 +02:00
cbnolok
310295af4d Cmake improvements, Linux fix and general cleaning and tidying.
Fixed a compilation error on Linux.
Cmake now works with manually defined toolchains, supports different build types (Release, Debug, Nightly), correctly define macros for them and supports manual build type override from command line (useful for Linux).
Copied REVISIONS* from main repo, renamed current changelog file and moved old to docs/past changelogs/.
Cleaned archivied folder of some imho useless files.
2016-04-19 19:08:23 +02:00
nefthon
88be0ad262 Changed CGrayError to CSphereError.
Changed CGrayInst to CUOInstall, also renamed files and changed includes.
2016-03-26 19:51:22 +01:00
nefthon
4121a6c77e Updated fork to commit 01a385398b1f1b912186ce3907a8c186273b3042 (last on main repo as date of 25/03/2016) 2016-03-25 12:42:15 +01:00
cbnolok
88ca3a1c9c Fixed spawn COUNT prop and changed MoveNear accepted args type.
Fixed: Spawn items created with random COUNT property.
Changed: MoveNear functions now accept WORD iStep argument instead of int, since x and y coordinates are stored as WORD.
2016-02-25 15:51:13 +01:00
nefthon
bf1374e628 Improved the code of NPC's SpellCasting engine: removed some code and updated a bit the current. Also moved some spells to give them higher priority (Healing > cure poison > buffs ...)
Added SKF_DISABLED, setting this flag on skills will not allow to use them by players or npcs
Added Skill_CanUse(skill) checking if the skill is disabled. Maybe this can be expanded to differ Players from NPCs , adding expansion & resdisp checks, etc.
WARNING: Following changes won't affect current scripts, but adapting them will remove the performance impact (Read NOTE for more tips about what to update).
CHANGED: Moved formulas for SpellEffect's damage above @SpellEffect trigger, so these formulas will be calculated regardless of the returns of the trigger,
			this will allow working with precise numbers instead of wondering what ARGN1 may be and creating own formulas to handle it.
	Also added for this trigger:
		-local.dam with final damage received (if any).
		-local.resist: Damage reduction to apply, it's set to 25 automatically when the spell is going to be resisted, then sysmessage <DEFMSG.RESISTMAGIC> will be shown. Setting it to 0 will result in no resist and no sysmessage. You can force or totally remove resists here.
NOTE: Since formulas will be calculated yes or yes from now, checks about spell's affecting this char or not should be moved to @SpellSuccess ( they should've been there from an start, but we all placed them in @SpellEffect :P) so @Effect won't even be called.
Fixed some spells not being correctly found in case of having multiple books since the code for GetSpellbook() returned the first found book, and this may not have the requested spell.

Script Pack:
	-sphere_defs.scp: Added SKF_DISABLED
2016-02-25 14:05:31 +01:00
coruja747
b3c8b60d58 Fixed: Some clients not parsing correctly the last number/letter of client version
The previous sphere parser was limiting the last byte to 0e (dec: 14 / ASCII: 'n'), making it return wrong last byte on all old clients > 'n' (eg: 3.0.8q being read as 3.0.8n) or newest clients > '14' (eg: 7.0.47.62 being read as 7.0.47.14).
Now with this new parser it can set/get correctly all client version formats (1.25.35a, 2.0.0, 5.0.0a, 6.0.5.6, 7.0.47.62, etc), except enhanced clients which it still not being parsed correctly*

*enhanced clients send a strange client version to server (eg: enhanced client 4.0.47.62 reporting 67.0.47.0 to server). Maybe OSI changed some packet, or maybe it need some math magic to convert this number into correct value. I already searched about it but nothing found
2016-02-23 16:38:58 -03:00
coruja747
74023491ce Fixed: Enhanced clients not placing items on correct container GRID slot when using containers on 'list view' mode. 2016-02-22 16:13:22 -03:00
cbnolok
7264f63c1e Slight changes in the revisions changelog. 2016-02-22 15:36:25 +01:00
cbnolok
f6e2e835db Changed: ITEMUSE_SPAWN_RSET to ITEMUSE_SPAWN_RESET. 2016-02-22 15:14:40 +01:00
cbnolok
51bbc21633 Various fixes and improvements to the spawn system.
Fixed: T_SPAWN_ITEM not automatically setting attr_invis, whereas it happened with T_SPAWN_CHAR.
Fixed: T_SPAWN_ITEM not removing spawned items when it got deleted.
Fixed: forced T_SPAWN_ITEM and T_SPAWN_CHAR to be unstackable through an internal workaround, stopping the Enhanced Client behaviour
	of "unstacking" spawn items with amount > 1 when trying to move them. Did this via creating GetAmount(), GetAmount() and m_iAmount in CItemSpawn. These work with BYTE values, not WORD, because the max amount of spawnable objects per spawn item is actually UCHAR_MAX. More infos at the declarations in CObjBase.h.
Changed: T_SPAWN_ITEM now colours itself red, like t_spawn_char, and when initialized it changes the DispID to i_worldgem_lg, in order to differentiate it to worldgem bits related to resource gathering and to make it more visible.
Changed: the MORE2 of a T_SPAWN_CHAR does no more indicate the amount of chars spawned, for that there is the COUNT property, (read only, introduced time ago) which works also for T_SPAWN_ITEM.
  COUNT is now stored, for both T_SPAWN_CHAR and T_SPAWN_ITEM in CItemSpawn:m_currentSpawned. There is the MOREM BYTE free in CItem but i feel it was messy to use it.
  MORE2 is used only by T_SPAWN_ITEM to indicate the maximum pile amount of the spawned item (if this is 0, spawn up to the total amount). COUNT property does not sum the amount of each spawned item.
  This resolves the ambiguity of MORE2 meaning and saves some space in the save files.

  -IMPORTANT: this change means that if in your scripts you get the T_SPAWN_CHAR or T_SPAWN_ITEM amount of spawned chars with MORE2,
     you should now reference to it with COUNT!

Fixed: MORE2 property for T_SPAWN_ITEM not working as intended.
Changed: now double clicking a T_SPAWN_ITEM spawnitem has the same effect it has on T_SPAWN_CHAR, that is resetting it (remove existing items spawned from it) if the timer is running, otherwise starting it (forcing the spawn to work and create some items).
[sphere_msgs.scp] Removed ITEMUSE_SPAWNCHAR_NEG, ITEMUSE_SPAWNCHAR_RESET, ITEMUSE_SPAWNITEM_TRIG and unified them as: ITEMUSE_SPAWN_NEG and ITEMUSE_SPAWN_RESET.
2016-02-22 15:03:03 +01:00
cbnolok
2669caa8d0 Update REVISIONS-56-SERIES.TXT
Added informations about XuN's last commit.
2016-02-19 18:25:21 +01:00
cbnolok
d9523304ec Fixed ACT not being updated when using .add to add an item.
This solves also AxisII being unable to initialize placed spawn items.
2016-02-19 18:09:08 +01:00
coruja747
3cdc3699f6 Fixed functions ATTACK/FACE/SALUTE crashing Sphere if called using too many args 2016-02-17 18:00:59 -02:00
nefthon
14eb47ee90 Fully enabled MT_NONMOVER from source, NPC's with this CAN flag will not move at all (avoiding glitching with dex 0 or using tag.nomovetill, which both could screw some things). Updated on sphere_defs.scp too.
Added GetSight() to Char's range in NPC_LookAround to get a dynamic value of the VisualRange property, which was not working on NPCs.
Changed: ARGN1 = 1 in @Stroke trigger(s) calling UpdateDir on character against it's target instead of forcing it to always turn if SKF_GATHER was present.
2016-02-17 20:49:00 +01:00
cbnolok
1f03c21565 Update REVISIONS-56-SERIES.TXT 2016-02-17 12:01:52 +01:00
cbnolok
0571ab9202 Fixed #2576: SpawnItem value is now readable under @Create trigger.
Changed: When a spawn item generates a new object, it updates its tooltip in order to view updated data.
2016-02-17 11:17:13 +01:00
cbnolok
f7cc7b5910 Various fixes to ships and buy from vendor procedure.
Fixed: Ships moving but not updating the multi part on Enhanced Client with smooth sailing disabled.
Changed: Removed useless screen updates when smooth sailing is on, making sailing more fluid.
Changed: Removed declarations and calculations on unused variables in the sailing engine.
Fixed: Price of items sold by the vendor swapped on Enhanced Client.
Changed: Removed unnecessary casts and changed variable type from INT64 to LONG in CItemVendable::GetVendorPrice and CClient::Event_VendorSell.
Changed: Removed useless packets sent when opening vendor sell gump on Enhanced Client.
2016-02-16 20:26:07 +01:00
coruja747
4cd2f2f00c Improved Sphere main timestamp engine
Replaced obsolete functions clock() [Win] and gettimeofday() [Linux] with recommended functions QueryPerformanceCounter() [Win] and clock_gettime() [Linux]
https://msdn.microsoft.com/en-us/library/ee417693(VS.85).aspx

These functions are more optimized and can handle values with microseconds precision, but I lowered this precision back to tenths of second to make it compatible with current script values like TIMERD/SERV.TIME/etc
PS: still need some testing on linux (I can't test it here because I don't use linux) :P
2016-02-16 16:31:43 -02:00
coruja747
79cb76e52b Fixed: Some skills not calling skillgain when action difficulty > skill value, making the skillgain chance always be 0% 2016-02-13 21:33:57 -02:00
coruja747
014cba4ad4 Fixed: Buff/Debuff bar showing wrong time left on spells memories using TIMER=-1 2016-02-13 02:00:12 -02:00
coruja747
42b4efb670 [sphere_msgs.scp]: Added new message 'macro_opendoor' and removed 'msg_nospellbook', 'npc_generic_thanks', 'npc_pet_drop' 2016-02-11 20:27:25 -02:00
coruja747
d561360af3 Changed: Improved handling of 'Open Spellbook' and 'Open Door' client macro 2016-02-11 19:55:52 -02:00
coruja747
f426c64af1 Fixed: Hiding skill not removing previous Invisibility spell effect on success.
Fixed: Char STEPSTEALTH value being reseted to 0 when function REVEAL is called to clear a single flag but the char still invisible using other flags.
2016-02-11 16:20:27 -02:00
Vjacheslav Kanivetc
b108678c1a it's 2016 already, Coruja) 2016-02-05 20:09:44 +02:00
coruja747
8b946633ec Fixed: Character stats gump (hits/mana/stam) showing wrong info for players on same party. 2016-01-31 02:00:05 -02:00
coruja747
30dfb51c1d Added: New function OPENTRADEWINDOW to start an trade window between 2 players (both clients must be in range and visible).
Usage: OPENTRADEWINDOW player_uid, item_uid (item uid is optional)
2016-01-31 01:48:54 -02:00
coruja747
150ebaf3fe Fixed: Summon Creature spell not working correctly 2016-01-28 03:10:37 -02:00
coruja747
52025eeff2 Fixed: Items disappearing when players try equip it without have required STR.
Fixed: LOWERREQ item property not working correctly.
2016-01-26 21:49:08 -02:00
coruja747
e4ba5879af Fixed: Polymorph spell and POLY function not working correctly. 2016-01-23 14:11:24 -02:00
coruja747
ee99c6d076 Fixed: Pets accepting items from its owner even when the owner can't access the pet backpack. 2016-01-22 20:53:02 -02:00
coruja747
c84c58ad24 Added: New pet command '* unfriend'.
Changed: Many improvements on pet commands engine.
[sphere_speech.scp]: Added UNFRIEND line on speech lists.
[sphere_msgs.scp]: Added new messages 'npc_pet_confused' and 'npc_pet_targ_*'.
2016-01-22 19:08:26 -02:00
coruja747
8b21e1096b Changed: Summon spells now will create NPCs with HOME and HOMEDIST=10 set by default 2016-01-21 22:34:55 -02:00
coruja747
ac9936fec5 Fixed: t_spawn_item not saving/loading correctly spawned items.
Fixed: Spawns (worldgem bit) not updating the tooltip when add/delete objects.
2016-01-21 19:57:39 -02:00
coruja747
c616cc09e6 Fixed many casts on CClientMsg.scp
And also added missing tame/bonded/summoned tooltips on NPCs
2016-01-21 19:49:37 -02:00
coruja747
4d739df5c5 Fixed: Console error when GM use commands to add objects on undefined regions 2016-01-20 20:43:00 -02:00
coruja747
5f6288a739 Fixed: CChar::Fight_Attack() sending unnecessary WarMode packets to clients even when the char is already on WarMode 2016-01-19 17:47:04 -02:00
coruja747
2b8cd917f1 [Sphere.ini]: Changed GameMinuteLength default value
UO time is 1d real = 8h ingame (which is the same of 60sec real = 20sec ingame)
2016-01-19 17:11:21 -02:00
coruja747
05b240ac86 Changed: Improved Detecting Hidden skill behavior 2016-01-19 17:01:37 -02:00