// Add an inventory item to all recepients. Return a new inhibit time, which depends on the reward // value and number of recipients. func ActivatorMessageInventoryAdd(recepients []quadtree.Object, modifier string, ac *user_coord) int { maker, ok := objectTable[modifier] if !ok { return -1 } level := MonsterDifficulty(ac) // We want an object of a level corresponding to the monsters at this place. var quality float64 if len(modifier) == 4 && modifier[3] <= '9' && modifier[3] >= '1' { quality = float64(modifier[3]) - '0' // A value 0 to 4. } cost := math.Pow(2, quality-1) // Will give a value of 0,5, 1, 2, 4, or 8 f := func(up *user) { cp := ChunkFindCached_WLwWLc(up.pl.coord.GetChunkCoord()) owner := cp.owner costCovered := true if owner != OWNER_NONE && owner != OWNER_RESERVED && owner != OWNER_TEST && up.uid != OWNER_TEST { // This time, also include the case where owner of chunk is up. costCovered = score.Pay(owner, cost) } if costCovered { obj := maker(level) AddOneObjectToUser_WLuBl(up, obj) // up.Printf("Added object %#v to %v", obj, up.pl.name) } } numRecepients := ActivatorIterator(f, recepients) return CnfgDefaultTriggerBlockTime + (1+int(cost))*numRecepients*50 }
// Add an inventory item to all recepients. Return a new inhibit time, which depends on the reward // value and number of recipients. func ActivatorMessageInventoryAdd(recepients []quadtree.Object, modifier string, ac *user_coord) int { code := ObjectCode(modifier) var quality float64 if len(modifier) == 4 && modifier[3] <= '9' && modifier[3] >= '1' { quality = float64(modifier[3]) - '0' // A value 0 to 4. } cost := math.Pow(2, quality-1) // Will give a value of 0,5, 1, 2, 4, or 8 f := func(up *user) { cp := ChunkFindCached_WLwWLc(up.Coord.GetChunkCoord()) owner := cp.owner costCovered := true if owner != OWNER_NONE && owner != OWNER_RESERVED && owner != OWNER_TEST && up.Id != OWNER_TEST { // This time, also include the case where owner of chunk is up. costCovered = score.Pay(owner, cost) } if costCovered { AddOneObjectToUser_WLuBl(up, code) // up.Printf("Added object %#v to %v", obj, up.Name) } } numRecepients := ActivatorIterator(f, recepients) return CnfgDefaultTriggerBlockTime + (1+int(cost))*numRecepients*50 }