-
Notifications
You must be signed in to change notification settings - Fork 14
Home
You can find spell examples here
And skin examples here
If you want to make wand based skin, try to use these animation files (broken link)
In functions you're able to use self
Be careful, saved data in self on clientside can be lost easily!
I hope this helps
Short version
Reference
- All functions except marked as clientside or shared are serverside!
- self - in your spell table you can use this. Except everything below it contains self.Owner if exists and Name
- wand - player's wand weapon entity, it must be always valid
- spell - spell entity
- ply - player
Misc
NodeDraw(nodeReference, x, y, radius) clientside
When the node is drawing in the spelltree, return true to override default drawing
NodeDrawOpti(nodeReference, x, y, radius) clientside
Optimized version (will stop drawing when not seeing), return true to override default drawing
NodeEdgeDraw(parentNodeReference, parentX, parentY, childNodeReference, childX, childY, radius) clientside
This function calls for every child of the node, return true to override default drawing
NodeEdgeToParentDraw(childNodeReference, childX, childY, parentNodeReference, parentX, parentY, radius) clientside
From the child to the parent edge
FightingEffect(numPoints, points) clientside
This draw function is being called when you're fighting. Requires Fightable = true
Main stuff
DrawMagicSprite(wand, vm, spriteBone) clientside
When that sprite on the end of the wand is being drawn
PostDrawViewModel(wand, vm) clientside
When view model is being drawn
DrawWorldModel(wand) clientside
When world model is being drawn
GetAnimations(wand)
Return animation enum to override fire animation event
Think(wand) shared
This function is being called when wand's current spell is this spell
OnHolster(wand)
When player changes current spell / skin from your spell / skin
OnSelect(wand) return true or false
False will block spell selection
PreFire(wand) return true or false
Being called before you cast a spell, returning false will block spell casting
OnFire(wand) return true or false
True will spawn a spell entity - entity_hpwand_flyingspell. Skin can have OnFire function too, but skin doesn't spawn spells. This function can be in shared realm if you set UseClientsideOnFire to true
OnWandHolster(wand)
When player is changing his current weapon
Learning stuff
OnStartLearn(ply) return true or false shared
Being called before player starts learning your spell. False will block it
OnPreLearn(ply) return true or false
Being called before learning process being finished. False will block it and player won't learn the spell
OnPostLearn(ply) shared
After learning
OnStopLearn(ply) shared
If player has stopped learning spell
Receiving, losing stuff
OnSpellGiven(ply) return true or false shared
When PlayerGiveSpell called. Return true to allow player get this spell
OnSpellRemoved(ply) shared
When PlayerRemoveSpell called
Some entity stuff
Be careful when you're trying to do something with spell.Owner
OnSpellSpawned(wand, spell)
After spell entity spawned
PhysicsThink(spell)
Physics of flying spell; return angForce Vector, force Vector, shouldOverride bool
OnCollide(spell, data, physobj)
When spell entity collides with something, return true to override default collision function
Please don't use more than data.HitEntity, data.HitPos, data.Speed, data.HitNormal in the data table
OnDataReceived(spell) clientside
Being called when all networked stuff has initialized on clientside
Draw(spell) clientside
Spell entity draw function
SpellThink(spell) shared
Think of spell entity
OnRemove(spell) shared
When spell entity is about to remove
Here are functions that only exist in skin table
GetCastSound(wand) return soundPath, shouldOverride
Overrides spellcast sound
PreSkinSelect(wand) return true or false
Return false to block skin choosing
OnSkinSelect(wand)
When skin has been chosen
OnSkinHolster(wand)
When skin has been changed from this skin
GetSpellPosition(wand, oldpos)
Return Vector to override spell entity position
Base
Put a name of a spell / skin that you want your spell / skin to be copied from
BaseClass
Exists when you have Base spell
PhysObjRadius
Overrides spell's physics sphere radius
AnimSpeedCoef
Overrides animation speed by multiplying it's default playtime by this value
WhatToSay
Override spell casting chat expression
UseClientsideOnFire
Changing it to true will enable OnFire function existance on clientside
ClientsideOnFireShouldBroadcast
Should clientside OnFire function be sended to everyone? UseClientsideOnFire required
FlyEffect
PCF effect name, don't fill if you don't use pcf effects
ImpactEffect
PCF effect name, impact effect
CanSelfCast
Can your spell be casted on yourself? True by default
ShouldReverseSelfCast
If it's true, it will enable reversed self-cast key: when you're not holding self-cast key you will cast spell on yourself
DoSelfCastAnim
Do self cast animation on self cast event
LearnTime
Learning time in seconds
ForceAnim
Array of ACT_VM enums
ApplyDelay
How many time we have to wait before casting spell? Calculates like AnimationDelay * ApplyDelay, so 1 means full animation event
AccuracyDecreaseVal
How many accuracy points your spell should take? (Value between 0 and 1)
DoSparks
Makes sparks at the end of the wand with SpriteColor color
SparksLifeTime
Life time of the sparks (optional)
ShouldSay
Bool value. If true, player will say spell name in chat
ShowInSpawnmenu
Should spell be shown in spawnmenu?
CreateEntity
Should we create spell book entity?
InstantLearn
If you want to make your spell instant learnable leave true here
ShouldCount
If false, it won't count it in (HpwRewrite.NumOfSpells or HpwRewrite.NumOfSkins) and PLAYER.HpwRewrite.NumOfSpells
SecretSpell
If true, player won't be able to get this spell by learning, spell will be hidden
AbsoluteSecret
Will be available only if you somehow got this spell
DoCongrats
Should we congratulate player if he just got secret spell? Works only if SecretSpell is true
Description
Description for your spell. Use [[]] instead of ""
LeaveParticles
Should it leave your pcf FlyEffect or remove it in the moment when spell hit something? Use only to set it to true
Models
Array of models for spell book
NodeDependOn
Name of the spell that you want your spell node be depended on, makes your NodeOffset be local position of that spell. Useful when you're making a big pack of spells
CalculateNodeOffset
Bool value. Will calculate offset depending on amount of nodes, will not work if there's a parent node. I recommend you to put this if you're making big pack of spells
CalculationCoef
Number value. Multiplying calculated offset. Works only if CalculateNodeOffset is true
NodeIntersectDist
Radius of the node
NodeOffset
Vector value. It's quite necessary to put this
OnlyWithSkin
Array of models. Make spell available only with these skins
OnlyIfLearned
Array of spell names. Creates nodes relationship. Will block learning if these spells are not learned
Fightable
Should we fight with someone? Fighting will start only if both collided spells has this flag. To make fighting effect use FightingEffect function
SpriteColor
Color(r, g, b, a) If you set this, wand will make sprite when you attack
SpriteTime
Number value. As more this is as faster sprite disappears. By default its 400
ForceDelay
Delay between attacks in seconds
PlayAnimation
Should we play animations when cast the spell? True by default
Here are variables that only exist in skin table
SpellFilter
Array of spell names. Will block these spells with your skin
OnlyTheseSpells
Array of spell names. Only these spells will be able to use with your skin
AutoFire
Enables SWEP.Primary.Automatic to your spell, use only to set it to true
ShouldLearn
Should we add skin to learnables or give it instantly? Something similar to InstantLearn, default is false
You can use hpwrewrite_loaded hook to do some code after addon's loading
WandEntity:HPWGetAimEntity(distance, mins, maxs)
Returns Entity and TraceStructure, mins and maxs are optional
WandEntity:RequestSprite(name, col, time, size, forcedata)
Sends net message to everyone to produce a magic sprite at the end of the wand
WandEntity:UpdateClientsideSkin(player)
Updates View and World models of skin for player or everyone if player is nil
WandEntity:HPWSetWandSkin(skinName)
Changes current skin of the wand
WandEntity:HPWSetCurrentSpell(spellName)
Changes current spell of the wand
WandEntity:HPWRemoveCurSpell()
Wipes CurrentSpell variable
WandEntity:HPWDecreaseAccuracy(amount)
Decreases accuracy by amount. Amount must be decimal between 0 and 1
WandEntity:HPWSpawnSpell(spellTable)
Spawns a new entity spell basing on spellTable spell table. Don't use this function at all
WandEntity:HPWDoSprite(spellTable)
Calls WandEntity:RequestSprite() function basing on spellTable spell table
WandEntity:HPWDoSpell(spellTable)
Calls WandEntity:HPWSpawnSpell() and WandEntity:HPWDoSprite() basing on spellTable spell table. You shouldn't use this function
WandEntity:AnimationSpeedTimer(speedValue, howMuchSeconds)
Adjusts speed of animations on howMuchSeconds time
WandEntity:AttackSpell(spellTable)
Performs a full cycle of making spell basing on spellTable spell table. You should never use this function
WandEntity:PlayCastSound()
Plays the cast sound. Useful in OnSpellSpawned function
WandEntity:GetSpellSpawnPosition()
Returns the actual position where spells should come from
WandEntity:HPWSendAnimation(ACT_VM_)
Plays animation. See actual ACT_VM_ values down here
WandEntity:EmptySpellAttack()
Emulates None spell's attack effect. You shouldn't use this function
WandEntity:MakeSparks(color, effectLifeTime)
Produces magic sparks effect
HpwRewrite.MakeEffect(effectName, pos, ang, entity, attachment) shared
Equivalent to ParticleEffect and ParticleEffectAttach
HpwRewrite.IsValidWand(wandEntity) shared
Checks if wandEntity is valid wand entity
HpwRewrite.CheckAdmin(player) shared
Checks if player is admin
HpwRewrite:LogDebug(text) shared
Saves text into the debug history and prints it to console. Useless when hpwrewrite_sv_debugmode is 0
HpwRewrite:IncludeFolder(path, recursive, str, fileFilter) shared
Includes lua files from some folder
HpwRewrite:LoadFile(path) shared
Includes some lua file
HpwRewrite:GetWand(player) shared
Returns wandEntity if has and NULL if not
HpwRewrite:HasWand(player) shared
Checks if player has wand
HpwRewrite:IsHoldingSelfCast(player) shared
Is player holding selfcast key?
HpwRewrite:DoNotify(...)
Serverside, sends notify to some player, arguments are:
1 - Player to send the message to
2 - Message itself, string value
3 - NOTIFY_, type of message
4 - How much time should the message be on the player's screen in seconds
Clientside, produces message instantly, arguments are:
1 - Message itself
2 - NOTIFY_
3 - How much time
You should use ThrowEntity instead of ThrowPlayer and ThrowNPC
HpwRewrite:ThrowPlayer(entity, direction, forceAmount, spawnDelayAmount, damagerAttacker, spawnCallback)
HpwRewrite:ThrowNPC(entity, direction, forceAmount, spawnDelayAmount, damagerAttacker, spawnCallback)
HpwRewrite:ThrowEntity(entity, direction, forceAmount, spawnDelayAmount, damagerAttacker, spawnCallback)
Functions to turn someone into ragdoll, very useful, used in huge amount of the basic spells
HpwRewrite:RequestSpell(spellName)
HpwRewrite:DrawSpellRect(spellName, bindKey, x, y, w, h)
HpwRewrite:AddSpell(spellName, table)
HpwRewrite:GetSpells()
HpwRewrite:GetSpell(spellName)
HpwRewrite:GetSpellIcon(spellName)
HpwRewrite:GetLearnedSpells(player)
HpwRewrite:GetLearnableSpells(player)
HpwRewrite:GetPlayerSpell(player, spellName)
HpwRewrite:GetPlayerLearnableSpell(player, spellName)
HpwRewrite:PlayerHasSpell(player, spellName)
HpwRewrite:PlayerHasLearnableSpell(player, spellName)
HpwRewrite:PlayerNumSpells(player)
HpwRewrite:SkillLevel(player)
HpwRewrite:IsSpellInAdminOnly(spellName)
HpwRewrite:IsSpellInBlacklist(spellName)
HpwRewrite:CanLearn(ply, spellName)
HpwRewrite:CanUseSpell(ply, spellName)
Serverside only functions
HpwRewrite:CleanEverything()
HpwRewrite:SaveToCache(player, spellTable)
HpwRewrite:RemoveFromCache(player, spellName)
HpwRewrite:LoadFromCache(player, spellName)
HpwRewrite:SetDefaultSkin(skinName)
HpwRewrite:CheckSpellUseable(player, spellName)
HpwRewrite:SpellToBlacklist(spellName)
HpwRewrite:SpellToAdminOnly(spellName)
HpwRewrite:WriteSpell(player, spellName)
HpwRewrite:EraseSpell(player, spellName)
HpwRewrite:WriteLearnableSpell(player, spellName)
HpwRewrite:EraseLearnableSpell(player, spellName)
HpwRewrite:EraseDataFile(player)
HpwRewrite:PlayerGiveLearnableSpell(player, spellName, skipskin)
HpwRewrite:PlayerRemoveLearnableSpell(player, spellName)
HpwRewrite:PlayerGiveSpell(player, spellName, spellTableCopy, forceAdd)
HpwRewrite:PlayerRemoveSpell(player, spellName)
HpwRewrite:PlayerUnlearnSpell(player, spellName)
HpwRewrite:PlayerDeleteSpell(player, spellName)
HpwRewrite:DeletePlayerSpells(player)
HpwRewrite:SaveAndGiveSpell(player, spellName, skipTree)
HpwRewrite:PlayerStartLearning(player, spellName)
HpwRewrite:PlayerStopLearning(player)
HpwRewrite:EmptyTables(player)
HpwRewrite:SendConfig(player)
HpwRewrite:LoadSpells(player)
HpwRewrite:UpdatePlayerInfo(player)
Everything related to data manager contains in HpwRewrite.DM
I use JSON to store data
HpwRewrite.DM:ReadBinds()
HpwRewrite.DM:ReadFavourites()
HpwRewrite.DM:AddToFavourites()
HpwRewrite.DM:RemoveFromFavourites()
HpwRewrite.DM:ReadConfig()
HpwRewrite.DM:GetFilenameID(player)
HpwRewrite.DM:LoadDataFile(player)
Everything related to fighting manager contains in HpwRewrite.FM
HpwRewrite.FM:GetValue(player)
HpwRewrite.FM:SetValue(player, boolVal)
HpwRewrite.FM:SetupPlayer(player)
HpwRewrite.FM:DestroyPlayer(player)
HpwRewrite.FM:CheckFighting(player1, player2)
HpwRewrite.FM:StartFighting(player1, player2, spellTable1, spellTable2, oldSpellPos)
HpwRewrite.FM:EndFighting(fightingID, winner)
%N shows how much the animation is used in fight spells
ACT_VM_PRIMARYATTACK - default animation %1
ACT_VM_PRIMARYATTACK_1 - avada kedavra fight animation %5
ACT_VM_PRIMARYATTACK_2 - avada kedavra fight animation %5
ACT_VM_PRIMARYATTACK_3 - expelliarmus wave animation %3
ACT_VM_PRIMARYATTACK_4 - protego sharp wave animation %2
ACT_VM_PRIMARYATTACK_5 - crucio accurate swing %5
ACT_VM_PRIMARYATTACK_6 - dremboom long wave animation %4
ACT_VM_PRIMARYATTACK_7 - hail of bullet swing %3
ACT_VM_PRIMARYATTACK_8 - aguamenti twice swings %2