1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-02 17:27:23 -04:00
OpenDiablo2/d2common/d2enum/item_events.go
Intyre 9e58b134e5
Refactored d2enum (#567)
* Refactored animation mode enum

* More d2enum changes

* Refactored tile enum

* Refactored weapon class enum

* Refactored more enums

* Refactored item event enum

* Fixed init_functions animation mode

* Removed string2enum from MonsterAnimationMode

* Refactored ItemStatCost description

* Last enum lint errors

* Regenerated monster stringer file
2020-07-09 23:12:28 -04:00

53 lines
1.8 KiB
Go

package d2enum
// ItemEventType used in ItemStatCost
type ItemEventType int
// Item event types
const (
ItemEventNone ItemEventType = iota
ItemEventHitByMissile // hit By a Missile
ItemEventDamagedInMelee // Damaged in Melee
ItemEventDamagedByMissile // Damaged By Missile
ItemEventAttackedInMelee // melee Attack atttempt
ItemEventDoActive // do active state skill
ItemEventDoMeleeDamage // do damage in melee
ItemEventDoMissileDamage // do missile damage
ItemEventDoMeleeAttack // do melee attack
ItemEventDoMissileAttack // do missile attack
ItemEventKill // killed something
ItemEventKilled // killed By something
ItemEventAbsorbDamage // dealt damage
ItemEventLevelUp // gain a level
)
//nolint:gochecknoglobals // better for lookup
var itemEventsLookup = map[string]ItemEventType{
"hitbymissile": ItemEventHitByMissile,
"damagedinmelee": ItemEventDamagedInMelee,
"damagedbymissile": ItemEventDamagedByMissile,
"attackedinmelee": ItemEventAttackedInMelee,
"doactive": ItemEventDoActive,
"domeleedamage": ItemEventDoMeleeDamage,
"domissiledamage": ItemEventDoMissileDamage,
"domeleeattack": ItemEventDoMeleeAttack,
"domissileattack": ItemEventDoMissileAttack,
"kill": ItemEventKill,
"killed": ItemEventKilled,
"absorbdamage": ItemEventAbsorbDamage,
"levelup": ItemEventLevelUp,
}
// GetItemEventType returns the ItemEventType from string, expects lowercase input
func GetItemEventType(s string) ItemEventType {
if s == "" {
return ItemEventNone
}
if v, ok := itemEventsLookup[s]; ok {
return v
}
return ItemEventNone
}