Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --The machine gun item
- --Problem: the RunScript part in OnSpellStart clearly isn't working because the script that it's running is supposed to print a simple message but it doesn't. There are no errors in the console.
- "item_ak_stickarena"
- {
- "ID" "4126"
- "BaseClass" "item_datadriven"
- "AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_POINT | DOTA_ABILITY_BEHAVIOR_CHANNELLED"
- "AbilityUnitTargetTeam" "DOTA_UNIT_TARGET_TEAM_ENEMY"
- "AbilityUnitTargetType" "DOTA_UNIT_TARGET_HERO"
- "AbilityUnitDamageType" "DAMAGE_TYPE_PURE"
- "AbilityChannelTime" "50"
- "AbilityCastAnimation" "ACT_DOTA_ATTACK"
- "AbilityTextureName" "item_ak"
- "Model" "models/items/sniper/machine_gun_charlie/machine_gun_charlie.vmdl"
- // Stats
- //-------------------------------------------------------------------------------------------------------------
- "AbilityCastRange" "%projectile_distance"
- "AbilityCastPoint" "0.2"
- "AbilityCooldown" "4"
- "AbilityDamage" "150"
- // Item Info
- //-------------------------------------------------------------------------------------------------------------
- "AbilityManaCost" "0"
- "ItemCost" "0"
- "ItemInitialCharges" "0"
- "ItemDroppable" "1"
- "ItemSellable" "0"
- "ItemRequiresCharges" "0"
- "ItemShareability" "ITEM_NOT_SHAREABLE"
- "ItemDeclarations" "DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_TO_SPECTATORS"
- "MaxUpgradeLevel" "1"
- "ItemBaseLevel" "1"
- "precache"
- {
- "model" "models/items/sniper/machine_gun_charlie/machine_gun_charlie.vmdl"
- }
- "OnEquip"
- {
- "RunScript"
- {
- "ScriptFile" "equip.lua"
- "Function" "EquipWeapon"
- "NewWeaponModel" "models/items/sniper/machine_gun_charlie/machine_gun_charlie.vmdl"
- }
- }
- "OnUnequip"
- {
- "RunScript"
- {
- "ScriptFile" "equip.lua"
- "Function" "UnequipWeapon"
- }
- }
- "OnSpellStart"
- {
- "RunScript"
- {
- "ScriptFile" "items/ak.lua"
- "Function" "InitializeMachineGun"
- "Target" "POINT"
- "TicksBetweenBursts" "%ticks_between_bursts"
- "BurstCount" "%burst_count"
- "ProjectileSpeed" "%projectile_speed"
- "ProjectileDistance" "%projectile_distance"
- "ProjectileRadius" "%projetile_radius"
- "ThinkInterval" "%think_interval"
- "ChannelTime" "%channel_time"
- }
- }
- "OnChannelFinish"
- {
- "RunScript"
- {
- "ScriptFile" "items/ak.lua"
- "Function" "StopMachineGun"
- }
- }
- "OnProjectileHitUnit"
- {
- "Damage"
- {
- "Target" "TARGET"
- "Type" "DAMAGE_TYPE_PURE"
- "Damage" "%AbilityDamage"
- }
- "FireSound"
- {
- "EffectName" "Hero_Sniper.ProjectileImpact"
- "Target" "TARGET"
- }
- }
- "Modifiers"
- {
- "modifier_item_ak"
- {
- "Passive" "1"
- "IsHidden" "1"
- "Attributes" "MODIFIER_ATTRIBUTE_MULTIPLE"
- "Properties"
- {
- "MODIFIER_PROPERTY_MOVESPEED_BONUS_UNIQUE" "%bonus_movement_speed"
- }
- }
- }
- // Special
- //-------------------------------------------------------------------------------------------------------------
- "AbilitySpecial"
- {
- "01"
- {
- "var_type" "FIELD_INTEGER"
- "projectile_distance" "1500"
- }
- "02"
- {
- "var_type" "FIELD_INTEGER"
- "projectile_damage" "150"
- }
- "03"
- {
- "var_type" "FIELD_INTEGER"
- "projectile_radius" "30"
- }
- "04"
- {
- "var_type" "FIELD_INTEGER"
- "projectile_speed" "2000"
- }
- "05"
- {
- "var_type" "FIELD_INTEGER"
- "bonus_movement_speed" "50"
- }
- "06"
- {
- "var_type" "FIELD_INTEGER"
- "channel_time" "50"
- }
- "07"
- {
- "var_type" "FIELD_INTEGER"
- "burst_count" "3"
- }
- "08"
- {
- "var_type" "FIELD_FLOAT"
- "think_interval" "0.3"
- }
- "09"
- {
- "var_type" "FIELD_FLOAT"
- "ticks_between_bursts" "2"
- }
- }
- }
- --items/ak.lua
- require('libraries/timers')
- function InitalizeMachineGun(keys)
- print('[STICKARENA] Initalizing Machine Gun')
- local caster = keys.caster
- caster.ticknumber = 0
- Timers:CreateTimer(0.01, -- Start this timer 30 game-time seconds later
- function()
- print('[STICKARENA] MachineGunThink')
- if caster.ticknumber * keys.ThinkInterval >= keys.ChannelTime then
- print('[STICKARENA] notice: caster.ticknumber * keys.ThinkInterval >= keys.ChannelTime')
- return
- elseif caster.ticknumber == -1 then
- print('[STICKARENA] notice: caster.ticknumber == -1')
- return
- end
- local totalmodulus = keys.TicksBetweenBursts + keys.BurstCount
- local ticknumber = caster.ticknumber
- local interval = ticknumber % totalmodulus
- local ifinterval = keys.BurstCount - 1
- --Fire Projectile
- if interval <= ifinterval then
- local vec = keys.target_points[1]
- local diff = vec - caster:GetAbsOrigin()
- diff.z = 0
- local dir = diff:Normalized()
- local info =
- {
- Ability = keys.ability,
- EffectName = "particles/linear_projectiles/sniper_base_attack.vpcf",
- vSpawnOrigin = caster:GetAbsOrigin(),
- fDistance = keys.ProjectileDistance,
- fStartRadius = keys.ProjectileRadius,
- fEndRadius = keys.ProjectileRadius,
- Source = caster,
- bHasFrontalCone = false,
- bReplaceExisting = false,
- iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY,
- iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_NONE,
- iUnitTargetType = DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC,
- fExpireTime = GameRules:GetGameTime() + 10.0,
- bDeleteOnHit = true,
- vVelocity = dir * keys.ProjectileSpeed,
- bProvidesVision = false,
- iVisionRadius = 0,
- iVisionTeamNumber = caster:GetTeamNumber()
- }
- caster:EmitSound("weapons/hero/sniper/projectile_impact01.wav")
- dir = RotatePosition(Vector(0,0,0), QAngle(0,RandomInt(-3,3),0), dir)
- info.vVelocity = dir * keys.ProjectileSpeed
- ProjectileManager:CreateLinearProjectile( info )
- end
- caster.ticknumber = caster.ticknumber + 1
- return keys.ThinkInterval -- Rerun this timer
- end)
- end
- function MachineGunEnd(keys)
- keys.caster.ticknumber = -1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement