Pychnight / TshockRpgToolKit

Master Controller for distrubtion of quests, custom npcs, custom items and skills, housing, leveling, npcshops, etc.
GNU General Public License v2.0
11 stars 1 forks source link

[Custom Npcs 2] Skeleton System #20

Closed Pychnight closed 5 months ago

Pychnight commented 5 years ago

Converted from https://github.com/Pychnight/Custom-Npcs-2/issues/16

The current skeleton system does not properly handle attachment.

Killing attached npc seem cause problems

def OnCheckSpawn(player as TSPlayer , x as int, y as int):
    if FindCustomNpcs("PP06").Length<=6:
        return (AtSurfaceLevel(player) and 15 or 0)
    else:
        return 0

def OnSpawn(npc as CustomNpc):
    npc["hostdead"]=false
    npc["attach"]=false
    npc["Ability1_Cooldown"]=1600

def OnCollision(npc, player):
    npc["attach"]=true

def OnAiUpdate(npc as CustomNpc) as bool:
    ability1_timer = npc.GetVariable("Ability1_Cooldown", 0)
if npc["once"]==false:
    head = SpawnCustomNpc("PP06A", npc.Position + Vector2(0, 0))
    npc.AttachChild(head)
    host = npc.Parent
    npc["once"]=true

if npc.Npc.active == true and CustomIDContains("PP06"):
    pass

elif npc.Npc.active == false and CustomIDContains("PP06"):
    npc.Children[0].Npc.aiStyle = 1
    npc["hostdead"]=true

if npc.HasChildren == true:
    child = npc.Children[0]

if ability1_timer > 0:
    ability1_timer = ability1_timer - 1
    npc["Ability1_Cooldown"]=ability1_timer

if npc["Ability1_Cooldown"]==0: 
    npc.Children[0].TargetClosestPlayer()
    targetHead = npc.Children[0].Target
    position = targetHead.TPlayer.position
    if targetHead != null and npc.Children[0].HasLineOfSight(position):
        npc.Children[0].ShootProjectileAt(position, 188, 20, 5, 20)

    npc["Ability1_Cooldown"]=1600

if npc["hostdead"]==true and npc["attach"]==true and CustomIDContains("PP06A"):
    child.Center = child.Target.TPlayer.position 

return false

No eater of worlds examples

Find how terraria handles the skeleton hands npc and see if it's possible to attach this npc to other monsters without having it die..