### Variable References and Properties in SCP Source: https://context7.com/sphereserver/scripts/llms.txt Enables data access and manipulation within scripts using tagged references for context variables and object properties. This example demonstrates using MORE1 and MORE2 for item charges and types. ```scp [TYPEDEF t_potion_keg] ON=@DClick // = player clicking the keg // = the keg item itself // = action target (if any) LOCAL.Charges= IF ( < 1) SRC.SYSMESSAGE The keg is empty. RETURN 1 ENDIF // Check if player has an empty bottle LOCAL.BottleUID= IF !() SRC.SYSMESSAGE You need an empty bottle to use this keg. RETURN 1 ENDIF // Consume bottle and create potion REF1= REF1.REMOVE SERV.NEWITEM= // MORE2 stores the potion type NEW.AMOUNT=1 NEW.BOUNCE // Put in player's backpack MORE1=-1> // Decrease charges SRC.SYSMESSAGE You fill a bottle with potion. [ charges remaining] UPDATE RETURN 1 ON=@TargOn_Item // Refilling the keg with potions IF ( != ) SRC.SYSMESSAGE That potion type does not match this keg. RETURN 1 ENDIF LOCAL.ToAdd= IF (+> > 100) LOCAL.ToAdd=> SRC.SYSMESSAGE You fill the keg completely. Some potion remains. ARGO.AMOUNT=-> ELSE SRC.SYSMESSAGE You pour the potion into the keg. ARGO.REMOVE ENDIF MORE1=+> UPDATE ``` -------------------------------- ### Game Event Callbacks in SCP Source: https://context7.com/sphereserver/scripts/llms.txt Handles game events as callbacks, allowing scripts to intercept, modify, or cancel default game actions. This example shows event handling for equipping/unequipping items, timers, and client tooltips. ```scp [ITEMDEF i_magic_ring] NAME=ring of regeneration TYPE=t_jewelry LAYER=layer_ring ON=@Equip IF ( < 25) SRC.SYSMESSAGE You are too weak to wear this ring. RETURN 1 // Cancel equip ENDIF SRC.SYSMESSAGE You feel the ring's regenerative power flow through you. SRC.TAG.RegenRing=1 RETURN 0 ON=@Unequip SRC.TAG.RegenRing= SRC.SYSMESSAGE The regenerative power fades. RETURN 0 ON=@Timer IF () && () IF ( < ) CONT.HITS=+2 CONT.EFFECT 3,i_fx_heal_effect,1,5 ENDIF ENDIF TIMER=5 RETURN 0 ON=@ClientTooltip SRC.ADDCLILOC 1060617 // Regeneration 2 ON=@ContextMenuRequest SRC.ADDCONTEXTENTRY 100, "Examine Ring" ON=@ContextMenuSelect IF ( == 100) SRC.SYSMESSAGE This ring pulses with magical energy. ENDIF ``` -------------------------------- ### Define Game Items with ITEMDEF Source: https://context7.com/sphereserver/scripts/llms.txt Item definitions (ITEMDEF) create game objects such as weapons, armor, and resources. They specify properties like appearance, functionality, value, and crafting requirements. The example shows a bone machete definition with its damage, skill, value, weight, and event handlers for creation and use. ```scp [ITEMDEF 020e] DEFNAME=i_bone_machete NAME=bone machete TYPE=t_weapon_sword DAM=13,15 SKILL=Swordsmanship SPEED=47 VALUE=142 WEIGHT=7.0 TWOHANDS=N RESOURCES=14 i_ingot_iron,1 i_bone SKILLMAKE=Blacksmithing 70.0 ReqStr=20 ON=@Create HITPOINTS={36 48} ON=@DClick IF ( < 20) SRC.SYSMESSAGE You are not strong enough to wield this weapon. RETURN 1 ENDIF RETURN 0 ``` -------------------------------- ### Define Characters and Monsters with CHARDEF Source: https://context7.com/sphereserver/scripts/llms.txt Character definitions (CHARDEF) specify NPCs, monsters, and creature templates. They include stats, combat abilities, AI behavior, loot tables, and taming requirements. The example defines an ogre with its combat stats, desired/aversion behaviors, food type, resources, and event handlers for creation, restocking, and death. ```scp [CHARDEF 01] DEFNAME=c_ogre NAME=ogre ICON=i_pet_ogre SOUND=snd_monster_ogre1 CAN=MT_WALK|MT_USEHANDS|MT_EQUIP DAM=9,11 ARMOR=32 DESIRES=r_forests,t_gold,t_coin,t_gem,t_arock AVERSIONS=t_trap,r_civilization FOODTYPE=t_meat_raw MAXFOOD=35 RESOURCES=2 i_ribs_raw TAG.Barding.Diff=48.8 TAG.SlayerGroup=OGRE,REPOND TEVENTS=e_carnivores2 ON=@Create NPC=brain_monster FAME=3000 KARMA=-3000 STR={165 195} DEX={45 65} INT={45 70} MAXHITS={100 120} WRESTLING={70.1 80.0} TACTICS={60.1 70.0} MAGICRESISTANCE={55.1 70.0} RESPHYSICAL={30 35} RESFIRE={15 25} RESCOLD={15 25} RESPOISON={15 25} RESENERGY={15 25} ON=@NPCRestock ITEM=loot_ogre ON=@Death SRC.SYSMESSAGE You have slain an ogre! IF ( < 10000) SRC.KARMA=+10 ENDIF ``` -------------------------------- ### Define Player Skills with SKILL Source: https://context7.com/sphereserver/scripts/llms.txt Skill definitions (SKILL) configure player abilities, including advancement rates, stat influences, delays, ranges, and event handlers for success, failure, and abortion. The Alchemy skill example shows its definition, stat bonuses, advancement rates, and specific event logic for failure and success, including consuming reagents. ```scp [SKILL 0] DEFNAME=Skill_Alchemy KEY=Alchemy TITLE=Alchemist FLAGS=skf_craft DELAY=1.2 STAT_STR=5 STAT_DEX=40 STAT_INT=75 BONUS_STR=0 BONUS_DEX=20 BONUS_INT=80 BONUS_STATS=10 ADV_RATE=10.0,200.0,800.0 VALUES=1,20,100 ON=@Fail SRC.SYSMESSAGE You toss the failed mixture from the mortar, unable to create a potion from it. IF () // ARGN1 contains the item we were trying to craft CONSUME 1 i_reag_blood_moss CONSUME 1 i_reag_nightshade ENDIF ON=@Abort SRC.SYSMESSAGE You fail to complete the potion. ON=@Success SERV.NEWITEM= NEW.BOUNCE SRC.SYSMESSAGE You create a potion and place it in your backpack. ``` -------------------------------- ### Define Magic Spells with SPELL Source: https://context7.com/sphereserver/scripts/llms.txt Spell definitions (SPELL) specify magic effects, including cast time, reagent costs, mana usage, damage/healing, duration, and targeting behavior. The Clumsy spell example details its sound, resources, effects, mana cost, skill requirement, and event handlers for spell effect and success, including stat modification. ```scp [SPELL 1] DEFNAME=s_clumsy NAME=Clumsy SOUND=snd_spell_clumsy RUNES=UJ CAST_TIME=0.5 RESOURCES=i_reag_blood_moss,i_reag_nightshade RUNE_ITEM=i_rune_clumsy SCROLL_ITEM=i_scroll_clumsy FLAGS=spellflag_dir_anim|spellflag_targ_char|spellflag_harm|spellflag_fx_targ|spellflag_nounparalyze EFFECT_ID=i_fx_curse EFFECT=3,15 LAYER=layer_spell_stats DURATION=2*60.0,3*60.0 MANAUSE=4 SKILLREQ=MAGERY 10.0 INTERRUPT=100.0,100.0 ON=@Effect IF ( > 3) LOCAL.DEXLOSS= * / 100> ARGO.DEX= - ARGO.SYSMESSAGE You feel very clumsy! ENDIF ON=@Success SRC.EFFECT 3,i_fx_curse,10,16 SRC.SOUND snd_spell_clumsy ``` -------------------------------- ### Add Item Behaviors with TYPEDEF - SCP Script Source: https://context7.com/sphereserver/scripts/llms.txt The TYPEDEF script allows for the addition of custom behaviors and event responses to item types. It uses event triggers like '@DClick' or '@Step' to define how an item reacts to player interaction or game events. These scripts enhance item functionality. ```scp [TYPEDEF t_shrine] ON=@DClick IF ( > 0) SRC.RESURRECT SRC.HITS= SRC.MANA= SRC.STAM= SRC.SYSMESSAGE The shrine's holy power resurrects and heals you! SRC.EFFECT 3,i_fx_heal_effect,10,15 SRC.SOUND snd_spell_heal ELSE SRC.SYSMESSAGE Your negative karma prevents the shrine from aiding you. ENDIF RETURN 1 [TYPEDEF t_landmine] ON=@Step IF !() EFFECT=3,i_fx_explode SOUND=snd_SPELL_EXPLOSION SRC.DAMAGE={5 20} MORE1=1 TIMER=10 ENDIF ON=@Timer REMOVE ``` -------------------------------- ### Define In-Game GUI with DIALOG - SCP Script Source: https://context7.com/sphereserver/scripts/llms.txt The DIALOG script defines in-game graphical user interfaces (GUIs) with interactive elements like buttons, text fields, and images. It allows for custom player interaction screens and layouts. Dependencies include the SCP scripting engine. ```scp [DIALOG d_charprop1] 50,50 page 0 resizepic 0 0 5054 605 445 gumppictiled 10 10 585 20 2624 checkertrans 10 10 585 425 dhtmlgump 10 11 585 20 0 0 CHARACTER PROPERTIES tilepichue 525 60 &~ 08000|04000> page 1 button 490 140 4008 4010 0 0 0 dtext 525 140 193 GENERAL button 10 55 4005 4007 1 0 100 dtext 45 55 2048 Body dcroppedtext 120 55 125 20 1000 button 10 95 4005 4007 1 0 102 dtext 45 95 2048 Flags dcroppedtext 120 95 125 20 1000 dtextentry 120 110 200 20 1000 200 [DIALOG d_charprop1 BUTTON] ON=0 DIALOGCLOSE d_charprop1 ON=100 LOCAL.NewBody= IF ( >= 0) BODY= UPDATE ENDIF DIALOGCLOSE d_charprop1 SDIALOG d_charprop1 ON=200 NAME= UPDATE ``` -------------------------------- ### Define Crafting System with SKILLMENU - SCP Script Source: https://context7.com/sphereserver/scripts/llms.txt SKILLMENU scripts define crafting recipes for a crafting system, such as blacksmithing. They specify the item to be created, the required resources, the skill level needed, and the category for organization. This enables players to craft items within the game. ```scp [SKILLMENU sm_blacksmith] Ringmail ON=i_ringmail_tunic_human MAKEITEM=i_ringmail_tunic_human RESOURCES=16 i_ingot_iron SKILL=Blacksmithing 50.0 CATEGORY=Ringmail Armor ON=i_ringmail_gloves MAKEITEM=i_ringmail_gloves RESOURCES=10 i_ingot_iron SKILL=Blacksmithing 45.0 CATEGORY=Ringmail Armor [SKILLMENU sm_blacksmith] Weapons ON=i_sword_katana MAKEITEM=i_sword_katana RESOURCES=8 i_ingot_iron,2 i_board SKILL=Blacksmithing 44.0 CATEGORY=Weapons ON=i_dagger MAKEITEM=i_dagger RESOURCES=3 i_ingot_iron SKILL=Blacksmithing 30.0 CATEGORY=Weapons ``` -------------------------------- ### SCP: Control Flow and Conditional Logic Script Source: https://context7.com/sphereserver/scripts/llms.txt This script demonstrates control flow and conditional logic in SCP. It checks vendor stock based on time and inventory, restocks items if below a threshold, and manages gold. It uses local variables, conditional statements (IF/ENDIF), loops (FOR/ENDFOR), and server commands. ```scp [FUNCTION CheckVendorStock] // Restock vendor based on time and inventory LOCAL.CurrentTime= LOCAL.LastRestock= IF (-> < 3600) RETURN 0 // Less than 1 hour since last restock ENDIF // Count current inventory LOCAL.ItemCount=0 FORCONTID i_sword_katana LOCAL.ItemCount += ENDFOR IF ( < 10) // Need to restock katanas LOCAL.ToCreate=> FOR 1 SERV.NEWITEM=i_sword_katana NEW.CONT= NEW.AMOUNT=1 ENDFOR SYSMESSAGE Restocked > katanas. ENDIF // Restock gold LOCAL.Gold= IF ( < 1000) GOLD=5000 ENDIF TAG.LastRestock= RETURN 1 ``` -------------------------------- ### SCP: Item Collections and Loot Tables Templates Source: https://context7.com/sphereserver/scripts/llms.txt These SCP templates define reusable item collections for loot drops, vendor inventories, and container contents. They specify items, quantities, and conditional drops based on random chance. Some templates also define item properties like hit points and magic charges. ```scp [TEMPLATE loot_ogre] CONTAINER=i_corpse ITEM=i_gold,{50 150} IF < 3 ITEM=i_gem_ruby ENDIF IF < 2 ITEM=i_magic_wand ENDIF ITEM={i_ribs_raw 2} IF < 1 ITEM=random_magic_weapon ENDIF [TEMPLATE random_magic_weapon] ITEM={i_sword_katana i_sword_longsword i_axe_battle i_mace_war} NEW.HITPOINTS={40 60} NEW.MOREZ={1 3} // Magic charges [TEMPLATE t_vendor_blacksmith] CONTAINER= ITEM=i_ingot_iron,50 ITEM=i_sword_katana,5 ITEM=i_sword_longsword,5 ITEM=i_axe_battle,3 ITEM=i_ringmail_tunic_human,3 ITEM=i_chainmail_coif,4 ITEM=i_platemail_arms,2 ``` -------------------------------- ### Implement Event Handlers with EVENTS - SCP Script Source: https://context7.com/sphereserver/scripts/llms.txt The EVENTS script block allows for the implementation of custom event handlers for characters or items. It uses trigger handlers like '@Hit' or '@GetHit' to override or extend default game actions, enabling complex scripted behaviors and responses. ```scp [EVENTS e_undead] ON=@Hit IF ( & statf_dead) RETURN 1 // Cannot harm the dead ENDIF ON=@GetHit LOCAL.DAMAGETYPE= IF ( & ) // Undead take extra fire damage LOCAL.DAMAGE= * 15 / 10 ARGO.SYSMESSAGE The flames sear the undead flesh! ENDIF IF ( & ) // Undead resist cold damage LOCAL.DAMAGE= * 5 / 10 ENDIF ON=@SpellEffect IF ( == s_heal) || ( == s_greater_heal) // Healing spells harm undead DAMAGE= RETURN 1 ENDIF IF ( == s_poison) || ( == s_poison_field) // Undead are immune to poison RETURN 1 ENDIF ``` -------------------------------- ### SCP: Creature Spawning System Definition Source: https://context7.com/sphereserver/scripts/llms.txt Defines a creature spawning system in SCP. It lists creatures to spawn and an area definition that includes spawn logic. Creatures are spawned if the current population is low, with random placement within the defined area. It uses server commands for spawning and tags for population tracking. ```scp [SPAWN spawn_dungeon_ogres] c_ogre c_ogre c_ettin [AREADEF a_dungeon_covetous_1] NAME=Covetous Dungeon Level 1 GROUP=Dungeons P=5456,1863,0,0 RECT=5450,1850,5480,1900,0 FLAGS=region_flag_underground EVENTS=r_default_rock,r_dungeon ON=@Enter SRC.SYSMESSAGE You have entered Covetous Dungeon. ON=@RegPeriodic // Spawn creatures if population is low LOCAL.CurrentPop= IF ( < 10) SERV.NEWCHAR=spawn_dungeon_ogres NEW.P= NEW.NPC=brain_monster TAG.Population += 1 ENDIF ``` -------------------------------- ### NPC Speech Recognition in SCP Source: https://context7.com/sphereserver/scripts/llms.txt Enables NPCs to recognize player text input using pattern matching and execute commands. It utilizes ON directives for keyword matching and IF statements for conditional logic based on NPC or player properties. ```scp [SPEECH spk_shopkeep] ON=*buy*,*purchase*,*shop* IF ( == brain_vendor) BUY ELSE SAY I have nothing to sell. ENDIF ON=*sell* IF ( == brain_vendor) SELL ELSE SAY I do not purchase goods. ENDIF ON=*bank* IF ( == c_banker) || ( == c_banker_f) BANKSELF ELSE SAY I am not a banker. ENDIF ON=*train*,*teach*,*learn* IF ( == brain_vendor) TRAIN ELSE SAY I cannot teach you anything. ENDIF ``` -------------------------------- ### Custom Script Functions in SCP Source: https://context7.com/sphereserver/scripts/llms.txt Allows the creation of reusable script routines that can be invoked from other scripts or triggers. Functions can accept arguments and return values, facilitating modular code design. ```scp [FUNCTION f_isHuman] IF ( == c_man) || ( == c_woman) || ( == c_ghostman) || ( == c_ghostwoman) RETURN 1 ENDIF RETURN 0 [FUNCTION f_isElf] IF ( == c_elf_male) || ( == c_elf_female) RETURN 1 ENDIF RETURN 0 [FUNCTION MODMAXHITS] // Adjust maximum hit points based on str and other factors LOCAL.OldMaxHits= LOCAL.NewMaxHits= IF () LOCAL.NewMaxHits= + 100 ENDIF MAXHITS= IF ( > ) HITS= ENDIF SYSMESSAGE Your maximum health is now . [FUNCTION TreasureMap_Dig] // Handle treasure map digging mechanics IF !(> < 2) SRC.SYSMESSAGE You must be closer to dig for treasure. RETURN 1 ENDIF IF ( != t_weapon_mace_pick) SRC.SYSMESSAGE You must be holding a shovel to dig. RETURN 1 ENDIF SRC.SKILLUSE Skill_Mining SERV.NEWITEM=i_treasure_chest_ NEW.P= NEW.TIMER=300 RETURN 0 ``` -------------------------------- ### Define Harvestable Resources with REGIONRESOURCE - SCP Script Source: https://context7.com/sphereserver/scripts/llms.txt REGIONRESOURCE scripts define the types and amounts of resources that can be harvested in specific regions. They specify the item to be reaped, the quantity, required skills, and regeneration rates. These are used in conjunction with REGIONTYPE definitions. ```scp [REGIONRESOURCE mr_iron] AMOUNT=9,30 REAP=i_ore_iron REAPAMOUNT=1,3 SKILL=Mining 1.0,100.0 REGEN=60*60*10 [REGIONRESOURCE mr_tree1] AMOUNT=9,30 REAP=i_log REAPAMOUNT=10,20 SKILL=Lumberjacking 1.0,100.0 REGEN=60*60*5 [REGIONTYPE r_default_rock t_rock] RESOURCES=80.0 mr_iron RESOURCES=15.0 mr_copper RESOURCES=5.0 mr_gold ON=@RegPeriodic // Check for random ore vein depletion/regeneration IF ( < 5) // 0.5% chance per periodic tick to shift resources RESMAKE i_ore_shadow,1 ENDIF ON=@ResourceTest IF ( == t_ore) IF ( < 50.0) SRC.SYSMESSAGE You have no idea how to extract ore from this type of rock. RETURN 1 ENDIF ENDIF ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.