Runuo - Help calling a method via addoncomponent

Finaltwist

Squire
Greetings all! trying to fix an issue for ultima adventures, and have been hitting my head on a wall for weeks now so i figured id ask the pros here :D

Here's the issue:
There are items in class called Stealbase (baseaddon) that generate a box (addoncomponent) on it. I'd like for players to be able to use the stealing skill on it.

So when a player uses stealing, and targets the box, ontarget in stealing.cs identifies the target as AddonComponent, not as a stealbase. When i try to cast it as a stealbase i get a server crash

1616597979874.png

I am trying to call a method in the stealbase class from the addoncomponent, but using

((StealBase)toSteal).DoDamage( m_Thief );

is what is causing the issue. in the above line, toSteal is the addoncomponent.
I uploaded stealbase script to the thread so you can see how the addoncomponent is generated.

Question: how would i call the StealBase.DoDamage method from the OnTarget from stealing?

sorry if i haven't explained property - just trying to be as clear as i can!
 

Attachments

  • StealBase.cs
    43.5 KB · Views: 7

PyrO

Moderator
StealBase is a BaseAddon, not a AddonComponent. Therefor you can not cast to AddonComponent.

Each AddonComponent has a reference to the BaseAddon from the Property
Code:
public BaseAddon Addon { get; set; }