Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.97 KB

README.md

File metadata and controls

57 lines (42 loc) · 1.97 KB

Build Status Release Version

Kamp FCNPC Wrapper

A wrapper for the native FCNPC plugin.

To create NPCs, simple inject ch.leadrian.samp.kamp.fcnpcwrapper.service.FCNPCService in your class:

class MyAmazingService
@Inject
constructor(private val npcService: FCNPCService) {

    fun doSomething() {
        npcService.create("Hans_Wurst")
    }

}

A lot of functionality is wrapped in ch.leadrian.samp.kamp.fcnpcwrapper.entity.FullyControllableNPC. However, some additional functionality can be found in:

  • ch.leadrian.samp.kamp.fcnpcwrapper.entity.MovePath
  • ch.leadrian.samp.kamp.fcnpcwrapper.entity.Node
  • ch.leadrian.samp.kamp.fcnpcwrapper.entity.PlaybackRecord All the entities mentioned above can be created and accessed using FCNPCService.

In order to listen to NPC related callbacks, register your class as a callback listener just like with any other callback provided by Kamp:

@Singleton
class MyAmazingCallbackListener
@Inject
constructor(
        private val callbackListenerManager: CallbackListenerManager
) : OnNPCDeathListener, OnNPCUpdateListener {
    
    @PostConstruct
    fun initialize() {
        callbackListenerManager.register(this) 
    }
    
    override fun onNPCDeath(npc: FullyControllableNPC, killer: Player?, reason: WeaponModel) {
        println("Oopsie!")
    }
    
    override fun onNPCUpdate(npc: FullyControllableNPC): Result {
        println("Updated NPC ${npc.id}")
        return OnNPCUpdateListener.Result.Sync    
    }
}

All available callbacks can be found in the package ch.leadrian.samp.kamp.fcnpcwrapper.callback.